diff --git a/Build/Notepad3.ini b/Build/Notepad3.ini index c40e9d859..f666dcc02 100644 Binary files a/Build/Notepad3.ini and b/Build/Notepad3.ini differ diff --git a/scintilla/include/Platform.h b/scintilla/include/Platform.h index 92180b354..de661dba5 100644 --- a/scintilla/include/Platform.h +++ b/scintilla/include/Platform.h @@ -99,7 +99,7 @@ class Point { XYPOSITION x; XYPOSITION y; - explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) : x(x_), y(y_) { + constexpr explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) : x(x_), y(y_) { } static Point FromInts(int x_, int y_) { @@ -217,15 +217,15 @@ class ColourDesired { return co; } - unsigned int GetRed() const { + unsigned char GetRed() const { return co & 0xff; } - unsigned int GetGreen() const { + unsigned char GetGreen() const { return (co >> 8) & 0xff; } - unsigned int GetBlue() const { + unsigned char GetBlue() const { return (co >> 16) & 0xff; } }; diff --git a/scintilla/lexers/LexHTML.cxx b/scintilla/lexers/LexHTML.cxx index e17ba116c..948617184 100644 --- a/scintilla/lexers/LexHTML.cxx +++ b/scintilla/lexers/LexHTML.cxx @@ -58,7 +58,7 @@ inline bool IsOperator(int ch) { static void GetTextSegment(Accessor &styler, Sci_PositionU start, Sci_PositionU end, char *s, size_t len) { Sci_PositionU i = 0; for (; (i < end - start + 1) && (i < len-1); i++) { - s[i] = static_cast(MakeLowerCase(styler[start + i])); + s[i] = MakeLowerCase(styler[start + i]); } s[i] = '\0'; } @@ -267,7 +267,7 @@ static int classifyTagHTML(Sci_PositionU start, Sci_PositionU end, for (Sci_PositionU cPos = start; cPos <= end && i < 30; cPos++) { char ch = styler[cPos]; if ((ch != '<') && (ch != '/')) { - withSpace[i++] = caseSensitive ? ch : static_cast(MakeLowerCase(ch)); + withSpace[i++] = caseSensitive ? ch : MakeLowerCase(ch); } } diff --git a/scintilla/lexlib/CharacterSet.cxx b/scintilla/lexlib/CharacterSet.cxx index 791177fcc..2a1dabc1c 100644 --- a/scintilla/lexlib/CharacterSet.cxx +++ b/scintilla/lexlib/CharacterSet.cxx @@ -18,8 +18,8 @@ namespace Scintilla { int CompareCaseInsensitive(const char *a, const char *b) { while (*a && *b) { if (*a != *b) { - const char upperA = static_cast(MakeUpperCase(*a)); - const char upperB = static_cast(MakeUpperCase(*b)); + const char upperA = MakeUpperCase(*a); + const char upperB = MakeUpperCase(*b); if (upperA != upperB) return upperA - upperB; } @@ -33,8 +33,8 @@ int CompareCaseInsensitive(const char *a, const char *b) { int CompareNCaseInsensitive(const char *a, const char *b, size_t len) { while (*a && *b && len) { if (*a != *b) { - const char upperA = static_cast(MakeUpperCase(*a)); - const char upperB = static_cast(MakeUpperCase(*b)); + const char upperA = MakeUpperCase(*a); + const char upperB = MakeUpperCase(*b); if (upperA != upperB) return upperA - upperB; } diff --git a/scintilla/lexlib/CharacterSet.h b/scintilla/lexlib/CharacterSet.h index be906ceaa..5965f38ca 100644 --- a/scintilla/lexlib/CharacterSet.h +++ b/scintilla/lexlib/CharacterSet.h @@ -167,16 +167,18 @@ inline bool isoperator(int ch) { return false; } -// Simple case functions for ASCII. +// Simple case functions for ASCII supersets. -inline int MakeUpperCase(int ch) { +template +inline T MakeUpperCase(T ch) { if (ch < 'a' || ch > 'z') return ch; else - return static_cast(ch - 'a' + 'A'); + return ch - 'a' + 'A'; } -inline int MakeLowerCase(int ch) { +template +inline T MakeLowerCase(T ch) { if (ch < 'A' || ch > 'Z') return ch; else diff --git a/scintilla/src/AutoComplete.cxx b/scintilla/src/AutoComplete.cxx index 966df7d47..fc4f947a5 100644 --- a/scintilla/src/AutoComplete.cxx +++ b/scintilla/src/AutoComplete.cxx @@ -49,7 +49,7 @@ AutoComplete::~AutoComplete() { } } -bool AutoComplete::Active() const { +bool AutoComplete::Active() const noexcept { return active; } @@ -70,7 +70,7 @@ void AutoComplete::SetStopChars(const char *stopChars_) { stopChars = stopChars_; } -bool AutoComplete::IsStopChar(char ch) { +bool AutoComplete::IsStopChar(char ch) const noexcept { return ch && (stopChars.find(ch) != std::string::npos); } @@ -78,7 +78,7 @@ void AutoComplete::SetFillUpChars(const char *fillUpChars_) { fillUpChars = fillUpChars_; } -bool AutoComplete::IsFillUpChar(char ch) { +bool AutoComplete::IsFillUpChar(char ch) const noexcept { return ch && (fillUpChars.find(ch) != std::string::npos); } @@ -86,7 +86,7 @@ void AutoComplete::SetSeparator(char separator_) { separator = separator_; } -char AutoComplete::GetSeparator() const { +char AutoComplete::GetSeparator() const noexcept { return separator; } @@ -94,7 +94,7 @@ void AutoComplete::SetTypesep(char separator_) { typesep = separator_; } -char AutoComplete::GetTypesep() const { +char AutoComplete::GetTypesep() const noexcept { return typesep; } diff --git a/scintilla/src/AutoComplete.h b/scintilla/src/AutoComplete.h index ed14f1776..6440c13d4 100644 --- a/scintilla/src/AutoComplete.h +++ b/scintilla/src/AutoComplete.h @@ -45,7 +45,7 @@ class AutoComplete { ~AutoComplete(); /// Is the auto completion list displayed? - bool Active() const; + bool Active() const noexcept; /// Display the auto completion list positioned to be near a character position void Start(Window &parent, int ctrlID, Sci::Position position, Point location, @@ -53,19 +53,19 @@ class AutoComplete { /// The stop chars are characters which, when typed, cause the auto completion list to disappear void SetStopChars(const char *stopChars_); - bool IsStopChar(char ch); + bool IsStopChar(char ch) const noexcept; /// The fillup chars are characters which, when typed, fill up the selected word void SetFillUpChars(const char *fillUpChars_); - bool IsFillUpChar(char ch); + bool IsFillUpChar(char ch) const noexcept; /// The separator character is used when interpreting the list in SetList void SetSeparator(char separator_); - char GetSeparator() const; + char GetSeparator() const noexcept; /// The typesep character is used for separating the word from the type void SetTypesep(char separator_); - char GetTypesep() const; + char GetTypesep() const noexcept; /// The list string contains a sequence of words separated by the separator character void SetList(const char *list); diff --git a/scintilla/src/CallTip.cxx b/scintilla/src/CallTip.cxx index 3d62dba88..f8bb77c48 100644 --- a/scintilla/src/CallTip.cxx +++ b/scintilla/src/CallTip.cxx @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -150,7 +151,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s, } else if (IsTabCharacter(s[startSeg])) { xEnd = NextTabPos(x); } else { - xEnd = x + RoundXYPosition(surface->WidthText(font, s + startSeg, endSeg - startSeg)); + xEnd = x + static_cast(lround(surface->WidthText(font, s + startSeg, endSeg - startSeg))); if (draw) { rcClient.left = static_cast(x); rcClient.right = static_cast(xEnd); @@ -172,7 +173,7 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) { PRectangle rcClient(1.0f, 1.0f, rcClientSize.right - 1, rcClientSize.bottom - 1); // To make a nice small call tip window, it is only sized to fit most normal characters without accents - const int ascent = RoundXYPosition(surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font)); + const int ascent = static_cast(lround(surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font))); // For each line... // Draw the definition in three parts: before highlight, highlighted, after highlight @@ -184,7 +185,7 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) { while (moreChunks) { const char *chunkEnd = strchr(chunkVal, '\n'); - if (chunkEnd == NULL) { + if (!chunkEnd) { chunkEnd = chunkVal + strlen(chunkVal); moreChunks = false; } @@ -253,7 +254,7 @@ void CallTip::MouseClick(Point pt) { PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, const char *defn, const char *faceName, int size, int codePage_, int characterSet, - int technology, Window &wParent) { + int technology, const Window &wParent) { clickPlace = 0; val = defn; codePage = codePage_; @@ -270,18 +271,12 @@ PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, co font.Create(fp); // Look for multiple lines in the text // Only support \n here - simply means container must avoid \r! - int numLines = 1; - const char *newline; - const char *look = val.c_str(); + const int numLines = 1 + static_cast(std::count(val.begin(), val.end(), '\n')); rectUp = PRectangle(0,0,0,0); rectDown = PRectangle(0,0,0,0); offsetMain = insetX; // changed to right edge of any arrows const int width = PaintContents(surfaceMeasure.get(), false) + insetX; - while ((newline = strchr(look, '\n')) != NULL) { - look = newline + 1; - numLines++; - } - lineHeight = RoundXYPosition(surfaceMeasure->Height(font)); + lineHeight = static_cast(lround(surfaceMeasure->Height(font))); // The returned // rectangle is aligned to the right edge of the last arrow encountered in diff --git a/scintilla/src/CallTip.h b/scintilla/src/CallTip.h index cb5d2c12c..9c00a777d 100644 --- a/scintilla/src/CallTip.h +++ b/scintilla/src/CallTip.h @@ -63,7 +63,7 @@ class CallTip { /// Setup the calltip and return a rectangle of the area required. PRectangle CallTipStart(Sci::Position pos, Point pt, int textHeight, const char *defn, const char *faceName, int size, int codePage_, - int characterSet, int technology, Window &wParent); + int characterSet, int technology, const Window &wParent); void CallTipCancel(); diff --git a/scintilla/src/ContractionState.cxx b/scintilla/src/ContractionState.cxx index b513c20a6..57d9b7a1c 100644 --- a/scintilla/src/ContractionState.cxx +++ b/scintilla/src/ContractionState.cxx @@ -286,7 +286,8 @@ bool ContractionState::SetFoldDisplayText(Sci::Line lineDoc, const char *t EnsureData(); const char *foldText = foldDisplayTexts->ValueAt(lineDoc).get(); if (!foldText || !text || 0 != strcmp(text, foldText)) { - foldDisplayTexts->SetValueAt(lineDoc, UniqueStringCopy(text)); + UniqueString uns = UniqueStringCopy(text); + foldDisplayTexts->SetValueAt(lineDoc, std::move(uns)); Check(); return true; } else { diff --git a/scintilla/src/EditView.cxx b/scintilla/src/EditView.cxx index 772cc3cd1..adb0305ba 100644 --- a/scintilla/src/EditView.cxx +++ b/scintilla/src/EditView.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "Platform.h" @@ -86,9 +87,9 @@ static int WidthStyledText(Surface *surface, const ViewStyle &vs, int styleOffse int width = 0; size_t start = 0; while (start < len) { - const size_t style = styles[start]; + const unsigned char style = styles[start]; size_t endSegment = start; - while ((endSegment + 1 < len) && (static_cast(styles[endSegment + 1]) == style)) + while ((endSegment + 1 < len) && (styles[endSegment + 1] == style)) endSegment++; FontAlias fontText = vs.styles[style + styleOffset].font; width += static_cast(surface->WidthText(fontText, text + start, @@ -280,13 +281,13 @@ void EditView::AllocateGraphics(const ViewStyle &vsDraw) { } static const char *ControlCharacterString(unsigned char ch) { - const char *reps[] = { + const char * const reps[] = { "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" }; - if (ch < ELEMENTS(reps)) { + if (ch < std::size(reps)) { return reps[ch]; } else { return "BAD"; @@ -433,15 +434,15 @@ void EditView::LayoutLine(const EditModel &model, Sci::Line line, Surface *surfa for (int charInLine = 0; charInLinechars[charInLine]; if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseUpper) - ll->chars[charInLine] = static_cast(MakeUpperCase(chDoc)); + ll->chars[charInLine] = MakeUpperCase(chDoc); else if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseLower) - ll->chars[charInLine] = static_cast(MakeLowerCase(chDoc)); + ll->chars[charInLine] = MakeLowerCase(chDoc); else if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseCamel) { if ((model.pdoc->IsASCIIWordByte(ll->chars[charInLine])) && ((charInLine == 0) || (!model.pdoc->IsASCIIWordByte(ll->chars[charInLine - 1])))) { - ll->chars[charInLine] = static_cast(MakeUpperCase(chDoc)); + ll->chars[charInLine] = MakeUpperCase(chDoc); } else { - ll->chars[charInLine] = static_cast(MakeLowerCase(chDoc)); + ll->chars[charInLine] = MakeLowerCase(chDoc); } } } @@ -722,7 +723,7 @@ SelectionPosition EditView::SPositionFromLineX(Surface *surface, const EditModel return SelectionPosition(model.pdoc->MovePositionOutsideChar(positionInLine + posLineStart, 1)); } #ifdef NP3_MATCH_BRACE_RECT_SEL_PATCH - const XYPOSITION spaceWidth = EndSpaceWidth(model,vs,ll,lineDoc); + const XYPOSITION spaceWidth = EndSpaceWidth(model,vs,ll,lineDoc); #else const XYPOSITION spaceWidth = vs.styles[ll->EndLineStyle()].spaceWidth; #endif @@ -810,10 +811,10 @@ static ColourDesired TextBackground(const EditModel &model, const ViewStyle &vsD } } -void EditView::DrawIndentGuide(Surface *surface, Sci::Line lineVisible, int lineHeight, Sci::Position start, PRectangle rcSegment, bool highlight) { +void EditView::DrawIndentGuide(Surface *surface, Sci::Line lineVisible, int lineHeight, XYPOSITION start, PRectangle rcSegment, bool highlight) { const Point from = Point::FromInts(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0); - const PRectangle rcCopyArea = PRectangle::FromInts(static_cast(start + 1), static_cast(rcSegment.top), - static_cast(start + 2), static_cast(rcSegment.bottom)); + const PRectangle rcCopyArea(start + 1, rcSegment.top, + start + 2, rcSegment.bottom); surface->Copy(rcCopyArea, from, highlight ? *pixmapIndentGuideHighlight : *pixmapIndentGuide); } @@ -938,7 +939,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle rcSegment.left = xStart + ll->positions[eolPos] - static_cast(subLineStart)+virtualSpace; rcSegment.right = xStart + ll->positions[eolPos + 1] - static_cast(subLineStart)+virtualSpace; blobsWidth += rcSegment.Width(); - char hexits[4]; + char hexits[4] = ""; const char *ctrlChar; const unsigned char chEOL = ll->chars[eolPos]; const int styleMain = ll->styles[eolPos]; @@ -1188,8 +1189,8 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con if (model.foldDisplayTextStyle == SC_FOLDDISPLAYTEXT_BOXED) { surface->PenColour(textFore); PRectangle rcBox = rcSegment; - rcBox.left = static_cast(RoundXYPosition(rcSegment.left)); - rcBox.right = static_cast(RoundXYPosition(rcSegment.right)); + rcBox.left = round(rcSegment.left); + rcBox.right = round(rcSegment.right); surface->MoveTo(static_cast(rcBox.left), static_cast(rcBox.top)); surface->LineTo(static_cast(rcBox.left), static_cast(rcBox.bottom)); surface->MoveTo(static_cast(rcBox.right), static_cast(rcBox.top)); @@ -1391,7 +1392,7 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt xposCaret += xStart; if (model.posDrag.IsValid()) { /* Dragging text, use a line caret */ - rcCaret.left = static_cast(RoundXYPosition(xposCaret - caretWidthOffset)); + rcCaret.left = round(xposCaret - caretWidthOffset); rcCaret.right = rcCaret.left + vsDraw.caretWidth; } else if (model.inOverstrike && drawOverstrikeCaret) { /* Overstrike (insert mode), use a modified bar caret */ @@ -1409,7 +1410,7 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt } } else { /* Line caret */ - rcCaret.left = static_cast(RoundXYPosition(xposCaret - caretWidthOffset)); + rcCaret.left = round(xposCaret - caretWidthOffset); rcCaret.right = rcCaret.left + vsDraw.caretWidth; } const ColourDesired caretColour = mainCaret ? vsDraw.caretcolour : vsDraw.additionalCaretColour; @@ -1725,7 +1726,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi indentCount <= (ll->positions[i + 1] - epsilon) / indentWidth; indentCount++) { if (indentCount > 0) { - const int xIndent = static_cast(indentCount * indentWidth); + const XYPOSITION xIndent = floor(indentCount * indentWidth); DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, (ll->xHighlightGuide == xIndent)); } @@ -1804,7 +1805,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi indentCount <= (ll->positions[cpos + ts.start + 1] - epsilon) / indentWidth; indentCount++) { if (indentCount > 0) { - const int xIndent = static_cast(indentCount * indentWidth); + const XYPOSITION xIndent = floor(indentCount * indentWidth); DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, (ll->xHighlightGuide == xIndent)); } @@ -1881,7 +1882,7 @@ void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &mode } for (int indentPos = model.pdoc->IndentSize(); indentPos < indentSpace; indentPos += model.pdoc->IndentSize()) { - const int xIndent = static_cast(indentPos * vsDraw.spaceWidth); + const XYPOSITION xIndent = floor(indentPos * vsDraw.spaceWidth); if (xIndent < xStartText) { DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcLine, (ll->xHighlightGuide == xIndent)); @@ -2215,7 +2216,7 @@ static ColourDesired InvertedLight(ColourDesired orig) { return ColourDesired(std::min(r, 0xffu), std::min(g, 0xffu), std::min(b, 0xffu)); } -Sci::Position EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure, +Sci::Position EditView::FormatRange(bool draw, const Sci_RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure, const EditModel &model, const ViewStyle &vs) { // Can't use measurements cached for screen posCache.Clear(); diff --git a/scintilla/src/EditView.h b/scintilla/src/EditView.h index 387795bfc..7d8f6fe5e 100644 --- a/scintilla/src/EditView.h +++ b/scintilla/src/EditView.h @@ -126,7 +126,7 @@ class EditView { Sci::Line DisplayFromPosition(Surface *surface, const EditModel &model, Sci::Position pos, const ViewStyle &vs); Sci::Position StartEndDisplayLine(Surface *surface, const EditModel &model, Sci::Position pos, bool start, const ViewStyle &vs); - void DrawIndentGuide(Surface *surface, Sci::Line lineVisible, int lineHeight, Sci::Position start, PRectangle rcSegment, bool highlight); + void DrawIndentGuide(Surface *surface, Sci::Line lineVisible, int lineHeight, XYPOSITION start, PRectangle rcSegment, bool highlight); void DrawEOL(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, PRectangle rcLine, Sci::Line line, Sci::Position lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart, ColourOptional background); @@ -150,7 +150,7 @@ class EditView { const ViewStyle &vsDraw); void FillLineRemainder(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line line, PRectangle rcArea, int subLine) const; - Sci::Position FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure, + Sci::Position FormatRange(bool draw, const Sci_RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure, const EditModel &model, const ViewStyle &vs); }; diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index 554fd01dc..2e25080ea 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "Platform.h" @@ -28,6 +29,7 @@ #include "Scintilla.h" #include "StringCopy.h" +#include "CharacterSet.h" #include "Position.h" #include "UniqueString.h" #include "SplitVector.h" @@ -204,13 +206,13 @@ void Editor::SetRepresentations() { reprs.Clear(); // C0 control set - const char *reps[] = { + const char * const reps[] = { "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" }; - for (size_t j=0; j < ELEMENTS(reps); j++) { + for (size_t j=0; j < std::size(reps); j++) { const char c[2] = { static_cast(j), 0 }; reprs.SetRepresentation(c, reps[j]); } @@ -218,13 +220,13 @@ void Editor::SetRepresentations() { // C1 control set // As well as Unicode mode, ISO-8859-1 should use these if (IsUnicodeMode()) { - const char *repsC1[] = { + const char * const repsC1[] = { "PAD", "HOP", "BPH", "NBH", "IND", "NEL", "SSA", "ESA", "HTS", "HTJ", "VTS", "PLD", "PLU", "RI", "SS2", "SS3", "DCS", "PU1", "PU2", "STS", "CCH", "MW", "SPA", "EPA", "SOS", "SGCI", "SCI", "CSI", "ST", "OSC", "PM", "APC" }; - for (size_t j=0; j < ELEMENTS(repsC1); j++) { + for (size_t j=0; j < std::size(repsC1); j++) { const char c1[3] = { '\xc2', static_cast(0x80+j), 0 }; reprs.SetRepresentation(c1, repsC1[j]); } @@ -1632,7 +1634,7 @@ void Editor::LinesSplit(int pixelWidth) { } } -void Editor::PaintSelMargin(Surface *surfaceWindow, PRectangle &rc) { +void Editor::PaintSelMargin(Surface *surfaceWindow, const PRectangle &rc) { if (vs.fixedColumnWidth == 0) return; @@ -1777,7 +1779,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { // This is mostly copied from the Paint method but with some things omitted // such as the margin markers, line numbers, selection and caret // Should be merged back into a combined Draw method. -Sci::Position Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { +Sci::Position Editor::FormatRange(bool draw, const Sci_RangeToFormat *pfr) { if (!pfr) return 0; @@ -2612,7 +2614,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { if (mh.modificationType & SC_MOD_CHANGEANNOTATION) { const Sci::Line lineDoc = pdoc->SciLineFromPosition(mh.position); if (vs.annotationVisible) { - if (pcs->SetHeight(lineDoc, static_cast(pcs->GetHeight(lineDoc) + mh.annotationLinesAdded))) { + if (pcs->SetHeight(lineDoc, pcs->GetHeight(lineDoc) + static_cast(mh.annotationLinesAdded))) { SetScrollBars(); } Redraw(); @@ -4092,12 +4094,10 @@ std::string Editor::CaseMapString(const std::string &s, int caseMapping) { for (char &ch : ret) { switch (caseMapping) { case cmUpper: - if (ch >= 'a' && ch <= 'z') - ch = static_cast(ch - 'a' + 'A'); + ch = MakeUpperCase(ch); break; case cmLower: - if (ch >= 'A' && ch <= 'Z') - ch = static_cast(ch - 'A' + 'a'); + ch = MakeLowerCase(ch); break; } } diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h index 523304ae5..39dd15c71 100644 --- a/scintilla/src/Editor.h +++ b/scintilla/src/Editor.h @@ -375,10 +375,10 @@ class Editor : public EditModel, public DocWatcher { void LinesJoin(); void LinesSplit(int pixelWidth); - void PaintSelMargin(Surface *surfaceWindow, PRectangle &rc); + void PaintSelMargin(Surface *surfaceWindow, const PRectangle &rc); void RefreshPixMaps(Surface *surfaceWindow); void Paint(Surface *surfaceWindow, PRectangle rcArea); - Sci::Position FormatRange(bool draw, Sci_RangeToFormat *pfr); + Sci::Position FormatRange(bool draw, const Sci_RangeToFormat *pfr); int TextWidth(int style, const char *text); virtual void SetVerticalScrollPos() = 0; diff --git a/scintilla/src/Indicator.cxx b/scintilla/src/Indicator.cxx index 5e229039e..077d12740 100644 --- a/scintilla/src/Indicator.cxx +++ b/scintilla/src/Indicator.cxx @@ -5,6 +5,8 @@ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. +#include + #include #include #include @@ -21,8 +23,8 @@ using namespace Scintilla; static PRectangle PixelGridAlign(const PRectangle &rc) { // Move left and right side to nearest pixel to avoid blurry visuals - return PRectangle::FromInts(static_cast(rc.left + 0.5), static_cast(rc.top), - static_cast(rc.right + 0.5), static_cast(rc.bottom)); + return PRectangle::FromInts(static_cast(lround(rc.left)), static_cast(rc.top), + static_cast(lround(rc.right)), static_cast(rc.bottom)); } void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, DrawState drawState, int value) const { @@ -36,8 +38,8 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r surface->PenColour(sacDraw.fore); const int ymid = static_cast(rc.bottom + rc.top) / 2; if (sacDraw.style == INDIC_SQUIGGLE) { - int x = static_cast(rc.left+0.5); - const int xLast = static_cast(rc.right+0.5); + int x = static_cast(lround(rc.left)); + const int xLast = static_cast(lround(rc.right)); int y = 0; surface->MoveTo(x, static_cast(rc.top) + y); while (x < xLast) { @@ -175,7 +177,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r if (rcCharacter.Width() >= 0.1) { const int pixelHeight = static_cast(rc.Height() - 1.0f); // 1 pixel onto next line if multiphase const XYPOSITION x = (sacDraw.style == INDIC_POINT) ? (rcCharacter.left) : ((rcCharacter.right + rcCharacter.left) / 2); - const int ix = static_cast(x + 0.5f); + const int ix = static_cast(lround(x)); const int iy = static_cast(rc.top + 1.0f); Point pts[] = { Point::FromInts(ix - pixelHeight, iy + pixelHeight), // Left diff --git a/scintilla/src/RunStyles.cxx b/scintilla/src/RunStyles.cxx index f92da5047..23392436b 100644 --- a/scintilla/src/RunStyles.cxx +++ b/scintilla/src/RunStyles.cxx @@ -6,9 +6,11 @@ #include #include +#include #include #include #include +#include #include #include @@ -306,5 +308,7 @@ void RunStyles::Check() const { template class Scintilla::RunStyles; template class Scintilla::RunStyles; +#if PTRDIFF_MAX != INT_MAX template class Scintilla::RunStyles; template class Scintilla::RunStyles; +#endif diff --git a/scintilla/src/Selection.h b/scintilla/src/Selection.h index 88d225826..6530abf86 100644 --- a/scintilla/src/Selection.h +++ b/scintilla/src/Selection.h @@ -173,7 +173,7 @@ class Selection { void AddSelectionWithoutTrim(SelectionRange range); void DropSelection(size_t r); void DropAdditionalRanges(); - void TentativeSelection(const SelectionRange &range); + void TentativeSelection(const SelectionRange &range); void CommitTentative(); int CharacterInSelection(Sci::Position posCharacter) const; int InSelectionForEOL(Sci::Position pos) const; diff --git a/scintilla/src/SparseVector.h b/scintilla/src/SparseVector.h index 11a126a1a..0667e54c4 100644 --- a/scintilla/src/SparseVector.h +++ b/scintilla/src/SparseVector.h @@ -77,11 +77,11 @@ class SparseVector { if (position == startPartition) { // Already a value at this position, so replace ClearValue(partition); - values->SetValueAt(partition, std::move(value)); + values->SetValueAt(partition, std::forward(value)); } else { // Insert a new element starts->InsertPartition(partition + 1, position); - values->Insert(partition + 1, std::move(value)); + values->Insert(partition + 1, std::forward(value)); } } } diff --git a/scintilla/src/SplitVector.h b/scintilla/src/SplitVector.h index 16dec6e98..3fb595eef 100644 --- a/scintilla/src/SplitVector.h +++ b/scintilla/src/SplitVector.h @@ -130,14 +130,14 @@ class SplitVector { if (position < 0) { ; } else { - body[position] = std::move(v); + body[position] = std::forward(v); } } else { PLATFORM_ASSERT(position < lengthBody); if (position >= lengthBody) { ; } else { - body[gapLength + position] = std::move(v); + body[gapLength + position] = std::forward(v); } } } diff --git a/scintilla/src/XPM.cxx b/scintilla/src/XPM.cxx index f83c3d6a8..04dc530bf 100644 --- a/scintilla/src/XPM.cxx +++ b/scintilla/src/XPM.cxx @@ -105,15 +105,15 @@ void XPM::Init(const char *const *linesForm) { for (int c=0; c(colourDef[0]); + const char code = colourDef[0]; colourDef += 4; ColourDesired colour(0xff, 0xff, 0xff); if (*colourDef == '#') { colour.Set(colourDef); } else { - codeTransparent = static_cast(code); + codeTransparent = code; } - colourCodeTable[code] = colour; + colourCodeTable[static_cast(code)] = colour; } for (int y=0; y(colour.GetRed()); - pixel[1] = static_cast(colour.GetGreen()); - pixel[2] = static_cast(colour.GetBlue()); + pixel[0] = colour.GetRed(); + pixel[1] = colour.GetGreen(); + pixel[2] = colour.GetBlue(); pixel[3] = static_cast(alpha); } diff --git a/scintilla/src/XPM.h b/scintilla/src/XPM.h index a2bd6cb91..2af0ae84e 100644 --- a/scintilla/src/XPM.h +++ b/scintilla/src/XPM.h @@ -59,7 +59,7 @@ class RGBAImage { float GetScaledWidth() const { return width / scale; } int CountBytes() const; const unsigned char *Pixels() const; - void SetPixel(int x, int y, ColourDesired colour, int alpha=0xff); + void SetPixel(int x, int y, ColourDesired colour, int alpha); }; /** diff --git a/scintilla/win32/PlatWin.cxx b/scintilla/win32/PlatWin.cxx index 8abf51913..a74a21238 100644 --- a/scintilla/win32/PlatWin.cxx +++ b/scintilla/win32/PlatWin.cxx @@ -188,6 +188,11 @@ struct FormatAndMetrics { yInternalLeading(yInternalLeading_) { } #endif + FormatAndMetrics(const FormatAndMetrics &) = delete; + FormatAndMetrics(FormatAndMetrics &&) = delete; + FormatAndMetrics &operator=(const FormatAndMetrics &) = delete; + FormatAndMetrics &operator=(FormatAndMetrics &&) = delete; + ~FormatAndMetrics() { if (hfont) ::DeleteObject(hfont); @@ -233,7 +238,13 @@ HFONT FormatAndMetrics::HFont() { #define CLEARTYPE_QUALITY 5 #endif -static BYTE Win32MapFontQuality(int extraFontFlag) { +namespace { + +FormatAndMetrics *FamFromFontID(void *fid) { + return static_cast(fid); +} + +BYTE Win32MapFontQuality(int extraFontFlag) { switch (extraFontFlag & SC_EFF_QUALITY_MASK) { case SC_EFF_QUALITY_NON_ANTIALIASED: @@ -251,7 +262,7 @@ static BYTE Win32MapFontQuality(int extraFontFlag) { } #if defined(USE_D2D) -static D2D1_TEXT_ANTIALIAS_MODE DWriteMapFontQuality(int extraFontFlag) { +D2D1_TEXT_ANTIALIAS_MODE DWriteMapFontQuality(int extraFontFlag) { switch (extraFontFlag & SC_EFF_QUALITY_MASK) { case SC_EFF_QUALITY_NON_ANTIALIASED: @@ -269,12 +280,14 @@ static D2D1_TEXT_ANTIALIAS_MODE DWriteMapFontQuality(int extraFontFlag) { } #endif +} + static void SetLogFont(LOGFONTW &lf, const char *faceName, int characterSet, float size, int weight, bool italic, int extraFontFlag) { lf = LOGFONTW(); // The negative is to allow for leading - lf.lfHeight = -(abs(static_cast(size + 0.5))); + lf.lfHeight = -(abs(lround(size))); lf.lfWeight = weight; - lf.lfItalic = static_cast(italic ? 1 : 0); + lf.lfItalic = italic ? 1 : 0; lf.lfCharSet = static_cast(characterSet); lf.lfQuality = Win32MapFontQuality(extraFontFlag); UTF16FromUTF8(faceName, strlen(faceName)+1, lf.lfFaceName, LF_FACESIZE); @@ -285,7 +298,7 @@ static void SetLogFont(LOGFONTW &lf, const char *faceName, int characterSet, flo * If one font is the same as another, its hash will be the same, but if the hash is the * same then they may still be different. */ -static int HashFont(const FontParameters &fp) { +static int HashFont(const FontParameters &fp) noexcept { return static_cast(fp.size) ^ (fp.characterSet << 10) ^ @@ -304,12 +317,12 @@ class FontCached : Font { int technology; int hash; explicit FontCached(const FontParameters &fp); - ~FontCached() override {} bool SameAs(const FontParameters &fp); void Release() override; static FontCached *first; public: + ~FontCached() override {} static FontID FindOrCreate(const FontParameters &fp); static void ReleaseId(FontID fid_); }; @@ -324,15 +337,15 @@ FontCached::FontCached(const FontParameters &fp) : fid = 0; if (technology == SCWIN_TECH_GDI) { HFONT hfont = ::CreateFontIndirectW(&lf); - fid = static_cast(new FormatAndMetrics(hfont, fp.extraFontFlag, fp.characterSet)); + fid = new FormatAndMetrics(hfont, fp.extraFontFlag, fp.characterSet); } else { #if defined(USE_D2D) IDWriteTextFormat *pTextFormat; const int faceSize = 200; WCHAR wszFace[faceSize]; UTF16FromUTF8(fp.faceName, strlen(fp.faceName)+1, wszFace, faceSize); - FLOAT fHeight = fp.size; - DWRITE_FONT_STYLE style = fp.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL; + const FLOAT fHeight = fp.size; + const DWRITE_FONT_STYLE style = fp.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL; HRESULT hr = pIDWriteFactory->CreateTextFormat(wszFace, NULL, static_cast(fp.weight), style, @@ -364,7 +377,7 @@ FontCached::FontCached(const FontParameters &fp) : pTextLayout->Release(); pTextFormat->SetLineSpacing(DWRITE_LINE_SPACING_METHOD_UNIFORM, lineMetrics[0].height, lineMetrics[0].baseline); } - fid = static_cast(new FormatAndMetrics(pTextFormat, fp.extraFontFlag, fp.characterSet, yAscent, yDescent, yInternalLeading)); + fid = new FormatAndMetrics(pTextFormat, fp.extraFontFlag, fp.characterSet, yAscent, yDescent, yInternalLeading); } #endif } @@ -375,7 +388,7 @@ bool FontCached::SameAs(const FontParameters &fp) { if ( (size == fp.size) && (lf.lfWeight == fp.weight) && - (lf.lfItalic == static_cast(fp.italic ? 1 : 0)) && + (lf.lfItalic == (fp.italic ? 1 : 0)) && (lf.lfCharSet == fp.characterSet) && (lf.lfQuality == Win32MapFontQuality(fp.extraFontFlag)) && (technology == fp.technology)) { @@ -387,8 +400,8 @@ bool FontCached::SameAs(const FontParameters &fp) { } void FontCached::Release() { - delete static_cast(fid); - fid = 0; + delete FamFromFontID(fid); + fid = nullptr; } FontID FontCached::FindOrCreate(const FontParameters &fp) { @@ -469,7 +482,10 @@ class VarBuffer { } // Deleted so VarBuffer objects can not be copied. VarBuffer(const VarBuffer &) = delete; + VarBuffer(VarBuffer &&) = delete; VarBuffer &operator=(const VarBuffer &) = delete; + VarBuffer &operator=(VarBuffer &&) = delete; + ~VarBuffer() { if (buffer != bufferStandard) { delete []buffer; @@ -519,7 +535,10 @@ class SurfaceGDI : public Surface { SurfaceGDI(); // Deleted so SurfaceGDI objects can not be copied. SurfaceGDI(const SurfaceGDI &) = delete; + SurfaceGDI(SurfaceGDI &&) = delete; SurfaceGDI &operator=(const SurfaceGDI &) = delete; + SurfaceGDI &operator=(SurfaceGDI &&) = delete; + ~SurfaceGDI() override; void Init(WindowID wid) override; @@ -666,14 +685,14 @@ void SurfaceGDI::BrushColor(ColourDesired back) { brushOld = 0; } // Only ever want pure, non-dithered brushes - ColourDesired colourNearest = ColourDesired(::GetNearestColor(hdc, back.AsLong())); + const ColourDesired colourNearest = ColourDesired(::GetNearestColor(hdc, back.AsLong())); brush = ::CreateSolidBrush(colourNearest.AsLong()); brushOld = static_cast(::SelectObject(hdc, brush)); } void SurfaceGDI::SetFont(Font &font_) { if (font_.GetID() != font) { - FormatAndMetrics *pfm = static_cast(font_.GetID()); + const FormatAndMetrics *pfm = FamFromFontID(font_.GetID()); PLATFORM_ASSERT(pfm->technology == SCWIN_TECH_GDI); if (fontOld) { ::SelectObject(hdc, pfm->hfont); @@ -721,7 +740,7 @@ void SurfaceGDI::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired void SurfaceGDI::FillRectangle(PRectangle rc, ColourDesired back) { // Using ExtTextOut rather than a FillRect ensures that no dithering occurs. // There is no need to allocate a brush either. - RECT rcw = RectFromPRectangle(rc); + const RECT rcw = RectFromPRectangle(rc); ::SetBkColor(hdc, back.AsLong()); ::ExtTextOut(hdc, rcw.left, rcw.top, ETO_OPAQUE, &rcw, TEXT(""), 0, NULL); } @@ -732,7 +751,7 @@ void SurfaceGDI::FillRectangle(PRectangle rc, Surface &surfacePattern) { br = ::CreatePatternBrush(static_cast(surfacePattern).bitmap); else // Something is wrong so display in red br = ::CreateSolidBrush(RGB(0xff, 0, 0)); - RECT rcw = RectFromPRectangle(rc); + const RECT rcw = RectFromPRectangle(rc); ::FillRect(hdc, &rcw, br); ::DeleteObject(br); } @@ -747,15 +766,17 @@ void SurfaceGDI::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesir 8, 8); } +namespace { + // Plot a point into a DWORD buffer symmetrically to all 4 quadrants -static void AllFour(DWORD *pixels, int width, int height, int x, int y, DWORD val) { +void AllFour(DWORD *pixels, int width, int height, int x, int y, DWORD val) { pixels[y*width+x] = val; pixels[y*width+width-1-x] = val; pixels[(height-1-y)*width+x] = val; pixels[(height-1-y)*width+width-1-x] = val; } -static DWORD dwordFromBGRA(byte b, byte g, byte r, byte a) { +DWORD dwordFromBGRA(byte b, byte g, byte r, byte a) { union { byte pixVal[4]; DWORD val; @@ -767,35 +788,38 @@ static DWORD dwordFromBGRA(byte b, byte g, byte r, byte a) { return converter.val; } +DWORD dwordMultiplied(ColourDesired colour, unsigned int alpha) { + return dwordFromBGRA( + static_cast(colour.GetBlue() * alpha / 255), + static_cast(colour.GetGreen() * alpha / 255), + static_cast(colour.GetRed() * alpha / 255), + static_cast(alpha)); +} + +} + void SurfaceGDI::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, ColourDesired outline, int alphaOutline, int /* flags*/ ) { const RECT rcw = RectFromPRectangle(rc); if (rc.Width() > 0) { HDC hMemDC = ::CreateCompatibleDC(hdc); - int width = static_cast(rc.Width()); - int height = static_cast(rc.Height()); + const int width = rcw.right - rcw.left; + const int height = rcw.bottom - rcw.top; // Ensure not distorted too much by corners when small cornerSize = std::min(cornerSize, (std::min(width, height) / 2) - 2); const BITMAPINFO bpih = {{sizeof(BITMAPINFOHEADER), width, height, 1, 32, BI_RGB, 0, 0, 0, 0, 0}, {{0, 0, 0, 0}}}; - void *image = 0; + void *image = nullptr; HBITMAP hbmMem = CreateDIBSection(hMemDC, &bpih, DIB_RGB_COLORS, &image, NULL, 0); if (hbmMem) { HBITMAP hbmOld = SelectBitmap(hMemDC, hbmMem); - DWORD valEmpty = dwordFromBGRA(0,0,0,0); - DWORD valFill = dwordFromBGRA( - static_cast(fill.GetBlue() * alphaFill / 255), - static_cast(fill.GetGreen() * alphaFill / 255), - static_cast(fill.GetRed() * alphaFill / 255), - static_cast(alphaFill)); - DWORD valOutline = dwordFromBGRA( - static_cast(outline.GetBlue() * alphaFill / 255), - static_cast(outline.GetGreen() * alphaFill / 255), - static_cast(outline.GetRed() * alphaFill / 255), - static_cast(alphaOutline)); + const DWORD valEmpty = dwordFromBGRA(0,0,0,0); + const DWORD valFill = dwordMultiplied(fill, alphaFill); + const DWORD valOutline = dwordMultiplied(outline, alphaOutline); + DWORD *pixels = static_cast(image); for (int y=0; y(&image), NULL, 0); + DIB_RGB_COLORS, &image, NULL, 0); if (hbmMem) { HBITMAP hbmOld = SelectBitmap(hMemDC, hbmMem); for (int y=height-1; y>=0; y--) { for (int x=0; x(image) + (y*width+x) * 4; const unsigned char alpha = pixelsImage[3]; // Input is RGBA, output is BGRA with premultiplied alpha pixel[2] = static_cast((*pixelsImage++) * alpha / 255); pixel[1] = static_cast((*pixelsImage++) * alpha / 255); pixel[0] = static_cast((*pixelsImage++) * alpha / 255); - pixel[3] = static_cast(*pixelsImage++); + pixel[3] = *pixelsImage++; } } - BLENDFUNCTION merge = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; + const BLENDFUNCTION merge = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; AlphaBlend(hdc, static_cast(rc.left), static_cast(rc.top), static_cast(rc.Width()), static_cast(rc.Height()), hMemDC, 0, 0, width, height, merge); @@ -1078,7 +1102,9 @@ class SurfaceD2D : public Surface { SurfaceD2D(); // Deleted so SurfaceD2D objects can not be copied. SurfaceD2D(const SurfaceD2D &) = delete; + SurfaceD2D(SurfaceD2D &&) = delete; SurfaceD2D &operator=(const SurfaceD2D &) = delete; + SurfaceD2D &operator=(SurfaceD2D &&) = delete; virtual ~SurfaceD2D() override; void SetScale(); @@ -1209,7 +1235,7 @@ void SurfaceD2D::InitPixMap(int width, int height, Surface *surface_, WindowID) SetScale(); SurfaceD2D *psurfOther = static_cast(surface_); ID2D1BitmapRenderTarget *pCompatibleRenderTarget = NULL; - D2D1_SIZE_F desiredSize = D2D1::SizeF(static_cast(width), static_cast(height)); + const D2D1_SIZE_F desiredSize = D2D1::SizeF(static_cast(width), static_cast(height)); D2D1_PIXEL_FORMAT desiredFormat; #ifdef __MINGW32__ desiredFormat.format = DXGI_FORMAT_UNKNOWN; @@ -1252,7 +1278,7 @@ void SurfaceD2D::D2DPenColour(ColourDesired fore, int alpha) { } void SurfaceD2D::SetFont(Font &font_) { - FormatAndMetrics *pfm = static_cast(font_.GetID()); + const FormatAndMetrics *pfm = FamFromFontID(font_.GetID()); PLATFORM_ASSERT(pfm->technology == SCWIN_TECH_DIRECTWRITE); pTextFormat = pfm->pTextFormat; yAscent = pfm->yAscent; @@ -1297,11 +1323,6 @@ static int Delta(int difference) { return 0; } -// Round to integer, with halfway cases rounding down. -static float RoundFloat(float f) { - return std::floor(f+0.5f); -} - void SurfaceD2D::LineTo(int x_, int y_) { if (pRenderTarget) { const int xDiff = x_ - x; @@ -1316,7 +1337,7 @@ void SurfaceD2D::LineTo(int x_, int y_) { const int yEnd = y_ - yDelta; const int top = std::min(y, yEnd); const int height = abs(y - yEnd) + 1; - D2D1_RECT_F rectangle1 = D2D1::RectF(static_cast(left), static_cast(top), + const D2D1_RECT_F rectangle1 = D2D1::RectF(static_cast(left), static_cast(top), static_cast(left+width), static_cast(top+height)); pRenderTarget->FillRectangle(&rectangle1, pBrush); } else if ((abs(xDiff) == abs(yDiff))) { @@ -1344,7 +1365,7 @@ void SurfaceD2D::Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired hr = geometry->Open(&sink); if (SUCCEEDED(hr)) { sink->BeginFigure(D2D1::Point2F(pts[0].x + 0.5f, pts[0].y + 0.5f), D2D1_FIGURE_BEGIN_FILLED); - for (size_t i=1; i(npts); i++) { + for (int i=1; iAddLine(D2D1::Point2F(pts[i].x + 0.5f, pts[i].y + 0.5f)); } sink->EndFigure(D2D1_FIGURE_END_CLOSED); @@ -1364,7 +1385,7 @@ void SurfaceD2D::Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired void SurfaceD2D::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) { if (pRenderTarget) { - D2D1_RECT_F rectangle1 = D2D1::RectF(RoundFloat(rc.left) + 0.5f, rc.top+0.5f, RoundFloat(rc.right) - 0.5f, rc.bottom-0.5f); + const D2D1_RECT_F rectangle1 = D2D1::RectF(round(rc.left) + 0.5f, rc.top+0.5f, round(rc.right) - 0.5f, rc.bottom-0.5f); D2DPenColour(back); pRenderTarget->FillRectangle(&rectangle1, pBrush); D2DPenColour(fore); @@ -1375,7 +1396,7 @@ void SurfaceD2D::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired void SurfaceD2D::FillRectangle(PRectangle rc, ColourDesired back) { if (pRenderTarget) { D2DPenColour(back); - D2D1_RECT_F rectangle1 = D2D1::RectF(RoundFloat(rc.left), rc.top, RoundFloat(rc.right), rc.bottom); + const D2D1_RECT_F rectangle1 = D2D1::RectF(round(rc.left), rc.top, round(rc.right), rc.bottom); pRenderTarget->FillRectangle(&rectangle1, pBrush); } } @@ -1389,7 +1410,7 @@ void SurfaceD2D::FillRectangle(PRectangle rc, Surface &surfacePattern) { HRESULT hr = pCompatibleRenderTarget->GetBitmap(&pBitmap); if (SUCCEEDED(hr)) { ID2D1BitmapBrush *pBitmapBrush = NULL; - D2D1_BITMAP_BRUSH_PROPERTIES brushProperties = + const D2D1_BITMAP_BRUSH_PROPERTIES brushProperties = D2D1::BitmapBrushProperties(D2D1_EXTEND_MODE_WRAP, D2D1_EXTEND_MODE_WRAP, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR); // Create the bitmap brush. @@ -1425,23 +1446,23 @@ void SurfaceD2D::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil if (pRenderTarget) { if (cornerSize == 0) { // When corner size is zero, draw square rectangle to prevent blurry pixels at corners - D2D1_RECT_F rectFill = D2D1::RectF(RoundFloat(rc.left) + 1.0f, rc.top + 1.0f, RoundFloat(rc.right) - 1.0f, rc.bottom - 1.0f); + const D2D1_RECT_F rectFill = D2D1::RectF(round(rc.left) + 1.0f, rc.top + 1.0f, round(rc.right) - 1.0f, rc.bottom - 1.0f); D2DPenColour(fill, alphaFill); pRenderTarget->FillRectangle(rectFill, pBrush); - D2D1_RECT_F rectOutline = D2D1::RectF(RoundFloat(rc.left) + 0.5f, rc.top + 0.5f, RoundFloat(rc.right) - 0.5f, rc.bottom - 0.5f); + const D2D1_RECT_F rectOutline = D2D1::RectF(round(rc.left) + 0.5f, rc.top + 0.5f, round(rc.right) - 0.5f, rc.bottom - 0.5f); D2DPenColour(outline, alphaOutline); pRenderTarget->DrawRectangle(rectOutline, pBrush); } else { const float cornerSizeF = static_cast(cornerSize); D2D1_ROUNDED_RECT roundedRectFill = { - D2D1::RectF(RoundFloat(rc.left) + 1.0f, rc.top + 1.0f, RoundFloat(rc.right) - 1.0f, rc.bottom - 1.0f), + D2D1::RectF(round(rc.left) + 1.0f, rc.top + 1.0f, round(rc.right) - 1.0f, rc.bottom - 1.0f), cornerSizeF, cornerSizeF}; D2DPenColour(fill, alphaFill); pRenderTarget->FillRoundedRectangle(roundedRectFill, pBrush); D2D1_ROUNDED_RECT roundedRect = { - D2D1::RectF(RoundFloat(rc.left) + 0.5f, rc.top + 0.5f, RoundFloat(rc.right) - 0.5f, rc.bottom - 0.5f), + D2D1::RectF(round(rc.left) + 0.5f, rc.top + 0.5f, round(rc.right) - 0.5f, rc.bottom - 0.5f), cornerSizeF, cornerSizeF}; D2DPenColour(outline, alphaOutline); pRenderTarget->DrawRoundedRectangle(roundedRect, pBrush); @@ -1472,7 +1493,7 @@ void SurfaceD2D::DrawRGBAImage(PRectangle rc, int width, int height, const unsig } ID2D1Bitmap *bitmap = 0; - D2D1_SIZE_U size = D2D1::SizeU(width, height); + const D2D1_SIZE_U size = D2D1::SizeU(width, height); D2D1_BITMAP_PROPERTIES props = {{DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED}, 72.0, 72.0}; const HRESULT hr = pRenderTarget->CreateBitmap(size, &image[0], @@ -1487,7 +1508,7 @@ void SurfaceD2D::DrawRGBAImage(PRectangle rc, int width, int height, const unsig void SurfaceD2D::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) { if (pRenderTarget) { - FLOAT radius = rc.Width() / 2.0f; + const FLOAT radius = rc.Width() / 2.0f; D2D1_ELLIPSE ellipse = { D2D1::Point2F((rc.left + rc.right) / 2.0f, (rc.top + rc.bottom) / 2.0f), radius,radius}; @@ -1811,11 +1832,11 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo) { ::ClientToScreen(static_cast(relativeTo.GetID()), &ptOther); rc.Move(static_cast(ptOther.x), static_cast(ptOther.y)); - RECT rcMonitor = RectFromPRectangle(rc); + const RECT rcMonitor = RectFromPRectangle(rc); HMONITOR hMonitor = MonitorFromRect(&rcMonitor, MONITOR_DEFAULTTONEAREST); // If hMonitor is NULL, that's just the main screen anyways. - RECT rcWork = RectFromMonitor(hMonitor); + const RECT rcWork = RectFromMonitor(hMonitor); if (rcWork.left < rcWork.right) { // Now clamp our desired rectangle to fit inside the work area @@ -1854,11 +1875,11 @@ void Window::InvalidateAll() { } void Window::InvalidateRectangle(PRectangle rc) { - RECT rcw = RectFromPRectangle(rc); + const RECT rcw = RectFromPRectangle(rc); ::InvalidateRect(static_cast(wid), &rcw, FALSE); } -static LRESULT Window_SendMessage(Window *w, UINT msg, WPARAM wParam=0, LPARAM lParam=0) { +static LRESULT Window_SendMessage(const Window *w, UINT msg, WPARAM wParam=0, LPARAM lParam=0) { return ::SendMessage(static_cast(w->GetID()), msg, wParam, lParam); } @@ -1892,7 +1913,7 @@ static HCURSOR GetReverseArrowCursor() { FlipBitmap(info.hbmMask, bmp.bmWidth, bmp.bmHeight); if (info.hbmColor != NULL) FlipBitmap(info.hbmColor, bmp.bmWidth, bmp.bmHeight); - info.xHotspot = static_cast(bmp.bmWidth) - 1 - info.xHotspot; + info.xHotspot = bmp.bmWidth - 1 - info.xHotspot; reverseArrowCursor = ::CreateIconIndirect(&info); if (reverseArrowCursor != NULL) @@ -1941,12 +1962,12 @@ void Window::SetCursor(Cursor curs) { /* Returns rectangle of monitor pt is on, both rect and pt are in Window's coordinates */ PRectangle Window::GetMonitorRect(Point pt) { - PRectangle rcPosition = GetPosition(); + const PRectangle rcPosition = GetPosition(); POINT ptDesktop = {static_cast(pt.x + rcPosition.left), static_cast(pt.y + rcPosition.top)}; HMONITOR hMonitor = MonitorFromPoint(ptDesktop, MONITOR_DEFAULTTONEAREST); - RECT rcWork = RectFromMonitor(hMonitor); + const RECT rcWork = RectFromMonitor(hMonitor); if (rcWork.left < rcWork.right) { PRectangle rcMonitor( rcWork.left - rcPosition.left, @@ -1970,18 +1991,13 @@ class LineToItem { std::vector data; public: - LineToItem() { - } - ~LineToItem() { - Clear(); - } void Clear() { words.clear(); data.clear(); } - ListItemData Get(int index) const { - if (index >= 0 && index < static_cast(data.size())) { + ListItemData Get(size_t index) const { + if (index < data.size()) { return data[index]; } else { ListItemData missing = {"", -1}; @@ -2086,7 +2102,7 @@ class ListBoxX : public ListBox { void RegisterImage(int type, const char *xpm_data) override; void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) override; void ClearRegisteredImages() override; - virtual void SetDelegate(IListBoxDelegate *lbDelegate) override; + void SetDelegate(IListBoxDelegate *lbDelegate) override; void SetList(const char *list, char separator, char typesep) override; void Draw(DRAWITEMSTRUCT *pDrawItem); LRESULT WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam); @@ -2194,7 +2210,7 @@ PRectangle ListBoxX::GetDesiredRect() { } int ListBoxX::TextOffset() const { - int pixWidth = images.GetWidth(); + const int pixWidth = images.GetWidth(); return static_cast(pixWidth == 0 ? ItemInset.x : ItemInset.x + pixWidth + (ImageInset.x * 2)); } @@ -2278,9 +2294,9 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) { } const ListItemData item = lti.Get(pDrawItem->itemID); - int pixId = item.pixId; + const int pixId = item.pixId; const char *text = item.text; - int len = static_cast(strlen(text)); + const int len = static_cast(strlen(text)); RECT rcText = rcBox; ::InsetRect(&rcText, static_cast(TextInset.x), static_cast(TextInset.y)); @@ -2299,14 +2315,14 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) { if (technology == SCWIN_TECH_GDI) { surfaceItem->Init(pDrawItem->hDC, pDrawItem->hwndItem); const long left = pDrawItem->rcItem.left + static_cast(ItemInset.x + ImageInset.x); - PRectangle rcImage = PRectangle::FromInts(left, pDrawItem->rcItem.top, + const PRectangle rcImage = PRectangle::FromInts(left, pDrawItem->rcItem.top, left + images.GetWidth(), pDrawItem->rcItem.bottom); surfaceItem->DrawRGBAImage(rcImage, pimage->GetWidth(), pimage->GetHeight(), pimage->Pixels()); ::SetTextAlign(pDrawItem->hDC, TA_TOP); } else { #if defined(USE_D2D) - D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties( + const D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties( D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat( DXGI_FORMAT_B8G8R8A8_UNORM, @@ -2326,7 +2342,7 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) { surfaceItem->Init(pDCRT, pDrawItem->hwndItem); pDCRT->BeginDraw(); const long left = pDrawItem->rcItem.left + static_cast(ItemInset.x + ImageInset.x); - PRectangle rcImage = PRectangle::FromInts(left, pDrawItem->rcItem.top, + const PRectangle rcImage = PRectangle::FromInts(left, pDrawItem->rcItem.top, left + images.GetWidth(), pDrawItem->rcItem.bottom); surfaceItem->DrawRGBAImage(rcImage, pimage->GetWidth(), pimage->GetHeight(), pimage->Pixels()); @@ -2390,7 +2406,7 @@ void ListBoxX::SetList(const char *list, char separator, char typesep) { } // Finally populate the listbox itself with the correct number of items - int count = lti.Count(); + const int count = lti.Count(); ::SendMessage(lb, LB_INITSTORAGE, count, 0); for (int j=0; j b) - return a; - else - return b; -} - void ListBoxX::ResizeToCursor() { PRectangle rc = GetPosition(); POINT ptw; @@ -2494,13 +2496,13 @@ void ListBoxX::ResizeToCursor() { break; } - POINT ptMin = MinTrackSize(); - POINT ptMax = MaxTrackSize(); + const POINT ptMin = MinTrackSize(); + const POINT ptMax = MaxTrackSize(); // We don't allow the left edge to move at present, but just in case - rc.left = XYMaximum(XYMinimum(rc.left, rcPreSize.right - ptMin.x), rcPreSize.right - ptMax.x); - rc.top = XYMaximum(XYMinimum(rc.top, rcPreSize.bottom - ptMin.y), rcPreSize.bottom - ptMax.y); - rc.right = XYMaximum(XYMinimum(rc.right, rcPreSize.left + ptMax.x), rcPreSize.left + ptMin.x); - rc.bottom = XYMaximum(XYMinimum(rc.bottom, rcPreSize.top + ptMax.y), rcPreSize.top + ptMin.y); + rc.left = std::clamp(rc.left, rcPreSize.right - ptMax.x, rcPreSize.right - ptMin.x); + rc.top = std::clamp(rc.top, rcPreSize.bottom - ptMax.y, rcPreSize.bottom - ptMin.y); + rc.right = std::clamp(rc.right, rcPreSize.left + ptMin.x, rcPreSize.left + ptMax.x); + rc.bottom = std::clamp(rc.bottom, rcPreSize.top + ptMin.y, rcPreSize.top + ptMax.y); SetPosition(rc); } @@ -2620,7 +2622,7 @@ void ListBoxX::CentreItem(int n) { const int visible = extent.y/ItemHeight(); if (visible < Length()) { const LRESULT top = ::SendMessage(lb, LB_GETTOPINDEX, 0, 0); - int half = (visible - 1) / 2; + const int half = (visible - 1) / 2; if (n > (top + half)) ::SendMessage(lb, LB_SETTOPINDEX, n - half , 0); } @@ -2629,7 +2631,7 @@ void ListBoxX::CentreItem(int n) { // Performs a double-buffered paint operation to avoid flicker void ListBoxX::Paint(HDC hDC) { - POINT extent = GetClientExtent(); + const POINT extent = GetClientExtent(); HBITMAP hBitmap = ::CreateCompatibleBitmap(hDC, extent.x, extent.y); HDC bitmapDC = ::CreateCompatibleDC(hDC); HBITMAP hBitmapOld = SelectBitmap(bitmapDC, hBitmap); @@ -2672,7 +2674,7 @@ LRESULT PASCAL ListBoxX::ControlWndProc(HWND hWnd, UINT iMessage, WPARAM wParam, // We must take control of selection to prevent the ListBox activating // the popup const LRESULT lResult = ::SendMessage(hWnd, LB_ITEMFROMPOINT, 0, lParam); - int item = LOWORD(lResult); + const int item = LOWORD(lResult); if (HIWORD(lResult) == 0 && item >= 0) { ::SendMessage(hWnd, LB_SETCURSEL, item, 0); ListBoxX *lbx = static_cast(PointerFromWindow(::GetParent(hWnd))); diff --git a/src/Edit.c b/src/Edit.c index dec5e407c..383a2cee8 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -347,24 +347,27 @@ void __fastcall _ClearTextBuffer(HWND hwnd) { SendMessage(hwnd, SCI_CANCEL, 0, 0); - if (SendMessage(hwnd, SCI_GETREADONLY, 0, 0)) { SendMessage(hwnd, SCI_SETREADONLY, false, 0); } + IgnoreNotifyChangeEvent(); + + if (SciCall_GetReadOnly()) { SciCall_SetReadOnly(false); } UndoRedoActionMap(-1, NULL); - SciCall_SetUndoCollection(false); - SendMessage(hwnd, SCI_CLEARALL, 0, 0); - SendMessage(hwnd, SCI_MARKERDELETEALL, (WPARAM)MARKER_NP3_BOOKMARK, 0); - EditClearAllOccurrenceMarkers(hwnd, 0, -1); if (EditToggleView(g_hwndEdit, false)) { EditToggleView(g_hwndEdit, true); } + SendMessage(hwnd, SCI_CLEARALL, 0, 0); + SendMessage(hwnd, SCI_MARKERDELETEALL, (WPARAM)MARKER_NP3_BOOKMARK, 0); + SciCall_SetUndoCollection(true); SendMessage(hwnd, SCI_SETSCROLLWIDTH, 1, 0); SendMessage(hwnd, SCI_SETXOFFSET, 0, 0); + + ObserveNotifyChangeEvent(); } @@ -7972,16 +7975,10 @@ int FileVars_GetEncoding(LPFILEVARS lpfv) { #define FOLD_CHILDREN SCMOD_CTRL #define FOLD_SIBLINGS SCMOD_SHIFT -bool __stdcall FoldToggleNode(DocLn ln, FOLD_ACTION action) +bool __forceinline _FoldToggleNode(DocLn ln, FOLD_ACTION action) { - const bool fExpanded = SciCall_GetFoldExpanded(ln); - - if ((action == FOLD && fExpanded) || (action == EXPAND && !fExpanded)) - { - SciCall_ToggleFold(ln); - return true; - } - else if (action == SNIFF) + bool const fExpanded = SciCall_GetFoldExpanded(ln); + if ((action == SNIFF) || ((action == FOLD) && fExpanded) || ((action == EXPAND) && !fExpanded)) { SciCall_ToggleFold(ln); return true; @@ -8020,48 +8017,75 @@ void __stdcall EditFoldPerformAction(DocLn ln, int mode, FOLD_ACTION action) if (lv < lvStop || (lv == lvStop && fHeader && ln != lnNode)) return; else if (fHeader && (lv == lvNode || (lv > lvNode && mode & FOLD_CHILDREN))) - FoldToggleNode(ln, action); + _FoldToggleNode(ln, action); } } else { - FoldToggleNode(ln, action); + _FoldToggleNode(ln, action); } } -void EditFoldToggleAll(FOLD_ACTION action) +void EditToggleFolds(FOLD_ACTION action, bool bForceAll) { - static FOLD_ACTION sLastAction = EXPAND; + static FOLD_ACTION sbLastSniffAllAction = EXPAND; - bool fToggled = false; - - DocLn lnTotal = SciCall_GetLineCount(); + bool bAllLines = true; + DocLn iStartLine = 0; + DocLn iEndLine = SciCall_GetLineCount() - 1; - if (action == SNIFF) + if (!bForceAll && !SciCall_IsSelectionEmpty()) { - int cntFolded = 0; - int cntExpanded = 0; - for (int ln = 0; ln < lnTotal; ++ln) - { - if (SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG) + DocLn const iBegLn = SciCall_LineFromPosition(SciCall_GetSelectionStart()); + DocLn const iEndLn = SciCall_LineFromPosition(SciCall_GetSelectionEnd()); + // selection range must span at least two lines + if (iBegLn != iEndLn) { + iStartLine = iBegLn; + iEndLine = iEndLn; + bAllLines = false; + } + } + + bool fToggled = false; + + if (bAllLines) { + if (action == SNIFF) { + // determine majority to find action for all + int cntFolded = 0; + int cntExpanded = 0; + for (DocLn ln = iStartLine; ln <= iEndLine; ++ln) { - if (SciCall_GetFoldExpanded(ln)) - ++cntExpanded; - else - ++cntFolded; + if (SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG) + { + if (SciCall_GetLastChild(ln, -1) != ln) + { + if (SciCall_GetFoldExpanded(ln)) + ++cntExpanded; + else + ++cntFolded; + } + } } + if (cntFolded == cntExpanded) { + action = (sbLastSniffAllAction == FOLD) ? EXPAND : FOLD; + } + else { + action = (cntFolded < cntExpanded) ? FOLD : EXPAND; + } + sbLastSniffAllAction = action; } - if (cntFolded == cntExpanded) - action = (sLastAction == FOLD) ? EXPAND : FOLD; - else - action = (cntFolded < cntExpanded) ? FOLD : EXPAND; - } - for (int ln = 0; ln < lnTotal; ++ln) + SciCall_FoldAll(action); + fToggled = true; + } + else // in selection { - if (SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG) + for (DocLn ln = iStartLine; ln <= iEndLine; ++ln) { - if (FoldToggleNode(ln, action)) { fToggled = true; } + if (SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG) + { + if (_FoldToggleNode(ln, action)) { fToggled = !fToggled ? true : false; } + } } } if (fToggled) { SciCall_ScrollCaret(); } @@ -8146,7 +8170,7 @@ void EditFoldAltArrow(FOLD_MOVE move, FOLD_ACTION action) if (SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG) { if (action != SNIFF) { - FoldToggleNode(ln, action); + _FoldToggleNode(ln, action); } } } diff --git a/src/Edit.h b/src/Edit.h index f4484a6ec..15eb5b0af 100644 --- a/src/Edit.h +++ b/src/Edit.h @@ -157,9 +157,9 @@ int FileVars_GetEncoding(LPFILEVARS); // Folding Functions // typedef enum { - EXPAND = 1, - SNIFF = 0, - FOLD = -1 + FOLD = SC_FOLDACTION_CONTRACT, + EXPAND = SC_FOLDACTION_EXPAND, + SNIFF = SC_FOLDACTION_TOGGLE } FOLD_ACTION; typedef enum { @@ -168,7 +168,7 @@ typedef enum { DOWN = 1 } FOLD_MOVE; -void EditFoldToggleAll(FOLD_ACTION); +void EditToggleFolds(FOLD_ACTION,bool); void EditFoldClick(DocLn, int); void EditFoldAltArrow(FOLD_MOVE, FOLD_ACTION); diff --git a/src/Notepad3.c b/src/Notepad3.c index 177213ec1..fe150dc55 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -2448,7 +2448,7 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam) EnableCmd(hmenu, CMD_CTRLENTER, !ro); EnableCmd(hmenu, IDM_EDIT_INSERT_TAG, !ro); - EnableCmd(hmenu,IDM_EDIT_INSERT_ENCODING, *Encoding_GetParseNames(Encoding_Current(CPI_GET) && !ro)); + EnableCmd(hmenu, IDM_EDIT_INSERT_ENCODING, (Encoding_GetParseNames(Encoding_Current(CPI_GET)) != NULL) && !ro); EnableCmd(hmenu,IDM_EDIT_INSERT_SHORTDATE,!ro); EnableCmd(hmenu,IDM_EDIT_INSERT_LONGDATE,!ro); @@ -4375,13 +4375,13 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_VIEW_FOLDING: g_bShowCodeFolding = (g_bShowCodeFolding) ? false : true; Style_SetFolding(g_hwndEdit, g_bShowCodeFolding); - if (!g_bShowCodeFolding) { EditFoldToggleAll(EXPAND); } + if (!g_bShowCodeFolding) { EditToggleFolds(EXPAND, true); } UpdateToolbar(); break; case IDM_VIEW_TOGGLEFOLDS: - EditFoldToggleAll(SNIFF); + EditToggleFolds(SNIFF, false); break; @@ -7243,7 +7243,7 @@ void UpdateToolbar() EnableTool(IDT_EDIT_COPY, !b1 && !ro); EnableTool(IDT_EDIT_CLEAR, !b1 && !ro); - EnableTool(IDT_VIEW_TOGGLEFOLDS, b2 && (g_bCodeFoldingAvailable && g_bShowCodeFolding) && !tv); + EnableTool(IDT_VIEW_TOGGLEFOLDS, b2 && (g_bCodeFoldingAvailable && g_bShowCodeFolding)); EnableTool(IDT_VIEW_TOGGLE_VIEW, b2 && ((g_iMarkOccurrences > 0) && !g_bMarkOccurrencesMatchVisible)); CheckTool(IDT_VIEW_TOGGLE_VIEW, tv); diff --git a/src/Notepad3.rc b/src/Notepad3.rc index 2c2700cd2..e96a5ef9f 100644 --- a/src/Notepad3.rc +++ b/src/Notepad3.rc @@ -332,7 +332,7 @@ BEGIN MENUITEM "Selection &Margin\tCtrl+Shift+M", IDM_VIEW_MARGIN MENUITEM SEPARATOR MENUITEM "Code &Folding\tCtrl+Shift+Alt+F", IDM_VIEW_FOLDING - MENUITEM "&Toggle All Folds\tCtrl+Shift+F", IDM_VIEW_TOGGLEFOLDS + MENUITEM "&Toggle Folds\tCtrl+Shift+F", IDM_VIEW_TOGGLEFOLDS MENUITEM SEPARATOR MENUITEM "Show Tool&bar", IDM_VIEW_TOOLBAR MENUITEM "C&ustomize Toolbar...", IDM_VIEW_CUSTOMIZETB @@ -1522,7 +1522,7 @@ BEGIN IDT_FILE_PRINT "Print" IDT_FILE_OPENFAV "Favorites" IDT_FILE_ADDTOFAV "Add to Favorites" - IDT_VIEW_TOGGLEFOLDS "Toggle All Folds" + IDT_VIEW_TOGGLEFOLDS "Toggle Folds" IDT_FILE_LAUNCH "Execute Document" IDT_VIEW_TOGGLE_VIEW "Focused View" END diff --git a/src/SciCall.h b/src/SciCall.h index 399b52840..e1667baf0 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -309,12 +309,13 @@ DeclareSciCallV2(IndicatorFillRange, INDICATORFILLRANGE, DocPos, position, DocPo // // DeclareSciCallR1(GetLineVisible, GETLINEVISIBLE, bool, DocLn, line) -DeclareSciCallV2(SetFoldLevel, SETFOLDLEVEL, DocLn, line, int, flags) +DeclareSciCallV2(SetFoldLevel, SETFOLDLEVEL, DocLn, line, int, level) DeclareSciCallR1(GetFoldLevel, GETFOLDLEVEL, int, DocLn, line) DeclareSciCallV1(SetFoldFlags, SETFOLDFLAGS, int, flags) DeclareSciCallV1(FoldDisplayTextSetStyle, FOLDDISPLAYTEXTSETSTYLE, int, flags) -DeclareSciCallR1(GetFoldParent, GETFOLDPARENT, int, DocLn, line) -DeclareSciCallR1(GetFoldExpanded, GETFOLDEXPANDED, int, DocLn, line) +DeclareSciCallR1(GetFoldParent, GETFOLDPARENT, DocLn, DocLn, line) +DeclareSciCallR2(GetLastChild, GETLASTCHILD, DocLn, DocLn, line, int, level) +DeclareSciCallR1(GetFoldExpanded, GETFOLDEXPANDED, bool, DocLn, line) DeclareSciCallV1(ToggleFold, TOGGLEFOLD, DocLn, line) DeclareSciCallV1(FoldAll, FOLDALL, int, flags) DeclareSciCallV1(EnsureVisible, ENSUREVISIBLE, DocLn, line)