Skip to content

Commit

Permalink
Weekly Scintilla sync up.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Sep 15, 2024
1 parent 294c105 commit 9200ba8
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 52 deletions.
10 changes: 1 addition & 9 deletions scintilla/lexers/LexHTML.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -750,18 +750,10 @@ void ColouriseHyperTextDoc(Sci_PositionU startPos, Sci_Position length, int init
styler.ColorTo(i, StateToPrint);
styler.ColorTo(i + 1, SCE_H_SGML_ERROR);
}
} else if (scriptLanguage == eScriptSGMLblock) {
if (ch == '>') {
styler.ColorTo(i, StateToPrint);
styler.ColorTo(i + 1, SCE_H_SGML_DEFAULT);
}
}
break;
case SCE_H_SGML_COMMAND:
if ((ch == '-') && (chPrev == '-')) {
styler.ColorTo(i - 1, StateToPrint);
state = SCE_H_SGML_COMMENT;
} else if (!IsSGMLWordChar(ch)) {
if (!IsSGMLWordChar(ch)) {
if (isWordHSGML(styler.GetStartSegment(), i, keywordsSGML, styler)) {
styler.ColorTo(i, StateToPrint);
state = SCE_H_SGML_1ST_PARAM;
Expand Down
63 changes: 27 additions & 36 deletions scintilla/src/Editor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,10 @@ bool Editor::RangeContainsProtected(Sci::Position start, Sci::Position end) cons
return false;
}

bool Editor::RangeContainsProtected(const SelectionRange &range) const noexcept {
return RangeContainsProtected(range.Start().Position(), range.End().Position());
}

bool Editor::SelectionContainsProtected() const noexcept {
for (size_t r = 0; r < sel.Count(); r++) {
if (RangeContainsProtected(sel.Range(r).Start().Position(),
Expand Down Expand Up @@ -1988,27 +1992,22 @@ void Editor::InsertCharacter(std::string_view sv, CharacterSource charSource) {
// Loop in reverse to avoid disturbing positions of selections yet to be processed.
for (auto rit = selPtrs.rbegin(); rit != selPtrs.rend(); ++rit) {
SelectionRange *currentSel = *rit;
if (!RangeContainsProtected(currentSel->Start().Position(),
currentSel->End().Position())) {
if (!RangeContainsProtected(*currentSel)) {
Sci::Position positionInsert = currentSel->Start().Position();
std::string text;
bool forward = false;
if (!currentSel->Empty()) {
const Sci::Position selectionLength = currentSel->Length();
if (selectionLength) {
if (encloseCh) {
if (encloseCh) {
const Sci::Position selectionLength = currentSel->Length();
if (selectionLength) {
forward = currentSel->anchor < currentSel->caret;
text.resize(selectionLength + 2);
text[0] = sv[0];
pdoc->GetCharRange(text.data() + 1, positionInsert, selectionLength);
text[selectionLength + 1] = encloseCh;
}
pdoc->DeleteChars(positionInsert, selectionLength);
currentSel->ClearVirtualSpace();
} else {
// Range is all virtual so collapse to start of virtual space
currentSel->MinimizeVirtualSpace();
}
ClearSelectionRange(*currentSel);
} else if (inOverstrike) {
if (positionInsert < pdoc->LengthNoExcept()) {
if (!pdoc->IsPositionInLineEnd(positionInsert)) {
Expand Down Expand Up @@ -2095,24 +2094,26 @@ void Editor::InsertCharacter(std::string_view sv, CharacterSource charSource) {
}
}

void Editor::ClearSelectionRange(SelectionRange &range) {
if (!range.Empty()) {
if (range.Length()) {
pdoc->DeleteChars(range.Start().Position(), range.Length());
range.ClearVirtualSpace();
} else {
// Range is all virtual so collapse to start of virtual space
range.MinimizeVirtualSpace();
}
}
}

void Editor::ClearBeforeTentativeStart() {
// Make positions for the first composition string.
FilterSelections();
const UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty() || inOverstrike);
for (size_t r = 0; r < sel.Count(); r++) {
if (!RangeContainsProtected(sel.Range(r).Start().Position(),
sel.Range(r).End().Position())) {
const Sci::Position positionInsert = sel.Range(r).Start().Position();
if (!sel.Range(r).Empty()) {
if (sel.Range(r).Length()) {
pdoc->DeleteChars(positionInsert, sel.Range(r).Length());
sel.Range(r).ClearVirtualSpace();
} else {
// Range is all virtual so collapse to start of virtual space
sel.Range(r).MinimizeVirtualSpace();
}
}
RealizeVirtualSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
if (!RangeContainsProtected(sel.Range(r))) {
ClearSelectionRange(sel.Range(r));
RealizeVirtualSpace(sel.Range(r).caret.Position(), sel.Range(r).caret.VirtualSpace());
sel.Range(r).ClearVirtualSpace();
}
}
Expand All @@ -2129,18 +2130,9 @@ void Editor::InsertPaste(const char *text, Sci::Position len) {
} else {
// MultiPaste::Each
for (size_t r = 0; r < sel.Count(); r++) {
if (!RangeContainsProtected(sel.Range(r).Start().Position(),
sel.Range(r).End().Position())) {
if (!RangeContainsProtected(sel.Range(r))) {
Sci::Position positionInsert = sel.Range(r).Start().Position();
if (!sel.Range(r).Empty()) {
if (sel.Range(r).Length()) {
pdoc->DeleteChars(positionInsert, sel.Range(r).Length());
sel.Range(r).ClearVirtualSpace();
} else {
// Range is all virtual so collapse to start of virtual space
sel.Range(r).MinimizeVirtualSpace();
}
}
ClearSelectionRange(sel.Range(r));
positionInsert = RealizeVirtualSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
const Sci::Position lengthInserted = pdoc->InsertString(positionInsert, text, len);
if (lengthInserted > 0) {
Expand Down Expand Up @@ -2191,8 +2183,7 @@ void Editor::ClearSelection(bool retainMultipleSelections) {
// remove EOLs
rangeNew = LineSelectionRange(rangeNew.caret, rangeNew.anchor, true);
}
if (!RangeContainsProtected(rangeNew.Start().Position(),
rangeNew.End().Position())) {
if (!RangeContainsProtected(sel.Range(r))) {
pdoc->DeleteChars(rangeNew.Start().Position(),
rangeNew.Length());
sel.Range(r) = SelectionRange(rangeNew.Start());
Expand Down
2 changes: 2 additions & 0 deletions scintilla/src/Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ class Editor : public EditModel, public DocWatcher {
};
void MultipleSelectAdd(AddNumber addNumber);
bool RangeContainsProtected(Sci::Position start, Sci::Position end) const noexcept;
bool RangeContainsProtected(const SelectionRange &range) const noexcept;
bool SelectionContainsProtected() const noexcept;
Sci::Position MovePositionOutsideChar(Sci::Position pos, Sci::Position moveDir, bool checkLineEnd = true) const noexcept;
SelectionPosition MovePositionOutsideChar(SelectionPosition pos, Sci::Position moveDir, bool checkLineEnd = true) const noexcept;
Expand Down Expand Up @@ -433,6 +434,7 @@ class Editor : public EditModel, public DocWatcher {
SelectionPosition RealizeVirtualSpace(SelectionPosition position);
void AddChar(char ch);
virtual void InsertCharacter(std::string_view sv, Scintilla::CharacterSource charSource);
void ClearSelectionRange(SelectionRange &range);
void ClearBeforeTentativeStart();
void InsertPaste(const char *text, Sci::Position len);
enum class PasteShape {
Expand Down
5 changes: 2 additions & 3 deletions scintilla/src/ScintillaBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,7 @@ void ScintillaBase::AutoCompleteInsert(Sci::Position startPos, Sci::Position rem
} else {
// MultiAutoComplete::Each
for (size_t r = 0; r < sel.Count(); r++) {
if (!RangeContainsProtected(sel.Range(r).Start().Position(),
sel.Range(r).End().Position())) {
if (!RangeContainsProtected(sel.Range(r))) {
Sci::Position positionInsert = sel.Range(r).Start().Position();
positionInsert = RealizeVirtualSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
if (positionInsert - removeLen >= 0) {
Expand Down Expand Up @@ -291,7 +290,7 @@ void ScintillaBase::AutoCompleteStart(Sci::Position lenEntered, const char *list

int lineHeight;
if (vs.autocStyle != StyleDefault) {
AutoSurface surfaceMeasure(this);
const AutoSurface surfaceMeasure(this);
lineHeight = static_cast<int>(std::lround(surfaceMeasure->Height(vs.styles[vs.autocStyle].font.get())));
} else {
lineHeight = vs.lineHeight;
Expand Down
8 changes: 4 additions & 4 deletions version.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ git clone https://github.com/XhmikosR/notepad2-mod.git
Scintilla (upstream)
hg clone http://hg.code.sf.net/p/scintilla/code scintilla
5.5.2
2024-08-29 9582:8dc527767ab0
2024-09-02 9583:b185609d02e2

Lexilla (upstream)
git clone https://github.com/ScintillaOrg/lexilla.git
5.4.0
2024-08-31 ef997e586ea61abc01a52d6a33ed592d81661880
2024-09-15 ff40f9889d00bdc0acc06550fc6015bc6351f239

SciTE (upstream)
hg clone http://hg.code.sf.net/p/scintilla/scite
5.5.2
2024-08-30 6337:1726b0201bc4
2024-09-06 6340:2b1b1f5b0fa8

Boost regex 7.0.1
1.86 https://github.com/boostorg/regex
git clone -b develop https://github.com/boostorg/regex.git
2024-08-24 cb559132939670aa45eb25fd867fce0be8b08837
2024-09-03 bb9f2b198484820498ed4bb46d0898ee28e84757

init submodule:
git submodule init
Expand Down

0 comments on commit 9200ba8

Please sign in to comment.