diff --git a/scintilla/call/ScintillaCall.cxx b/scintilla/call/ScintillaCall.cxx index c9cf2b0ca..0c4433e8c 100644 --- a/scintilla/call/ScintillaCall.cxx +++ b/scintilla/call/ScintillaCall.cxx @@ -387,14 +387,6 @@ void ScintillaCall::SetIMEInteraction(Scintilla::IMEInteraction imeInteraction) Call(Message::SetIMEInteraction, static_cast(imeInteraction)); } -bool ScintillaCall::IsIMEOpen() { - return Call(Message::IsIMEOpen); -} - -bool ScintillaCall::IsIMEModeCJK() { - return Call(Message::IsIMEModeCJK); -} - void ScintillaCall::MarkerDefine(int markerNumber, Scintilla::MarkerSymbol markerSymbol) { Call(Message::MarkerDefine, markerNumber, static_cast(markerSymbol)); } diff --git a/scintilla/doc/Lexer.txt b/scintilla/doc/Lexer.txt index 9b9e54f5a..d7023b36b 100644 --- a/scintilla/doc/Lexer.txt +++ b/scintilla/doc/Lexer.txt @@ -89,7 +89,7 @@ loop iterates over characters, like this: An alternative would be to use a "state-based" approach. The outer loop would iterate over states, like this: - lengthDoc = startPos+lenth ; + lengthDoc = startPos+length ; for ( unsigned int i = startPos ;; ) { char ch = styler.SafeGetCharAt(i); int new_state = 0 ; diff --git a/scintilla/doc/ScintillaDoc.html b/scintilla/doc/ScintillaDoc.html index a2af4f64f..5c92043cc 100644 --- a/scintilla/doc/ScintillaDoc.html +++ b/scintilla/doc/ScintillaDoc.html @@ -1444,6 +1444,9 @@ struct Sci_TextRangeFull { SCI_GETSELECTIONSERIALIZED(<unused>, char *selectionString) → position
Set or query the selection type and positions as a serialized string. The format of this string may change in future versions so should not be persisted beyond the current session.

+

The format is currently
[selType:R|L|T] [# mainRange ,] [anchor [v virtualSpace] [- caret [v virtualSpace]]] [, ...] +
Example of a multiple selection with virtual space: #1,5v3-2,1 +

SC_ELEMENT_SELECTION_ADDITIONAL_TEXT : colouralpha
@@ -2031,7 +2034,7 @@ struct Sci_TextToFindFull {

SCI_GETUNDOSEQUENCE → int
Determine if an undo sequence is active with a positive value indicating that a sequence is active and 0 that there is no current sequence. The value returned is the nesting depth of the sequence, that is, the number of times SCI_BEGINUNDOACTION - was called without a correspnding SCI_ENDUNDOACTION. + was called without a corresponding SCI_ENDUNDOACTION. A negative value indicates an error.

SCI_ADDUNDOACTION(int token, int flags)
@@ -3840,8 +3843,8 @@ struct Sci_TextToFindFull {

SCI_STYLESETINVISIBLEREPRESENTATION(int style, const char *representation)
SCI_STYLEGETINVISIBLEREPRESENTATION(int style, char *representation NUL-terminated) → int
When a style is made invisible with SCI_STYLESETVISIBLE, text is difficult to edit as - the cursor can be at both sides of the invisible text segment. With these messages invisible text segements can be made visible with a single - UTF8 characater giving the user an indication if the cursor is left or right of the invisible text. The character is displayed using the current style.

+ the cursor can be at both sides of the invisible text segment. With these messages invisible text segments can be made visible with a single + UTF8 character giving the user an indication if the cursor is left or right of the invisible text. The character is displayed using the current style.

The representation parameter is a zero terminated string holding the one character used to represent the invisible text segment. Only the first character is used, the character is decoded as UTF-8.

@@ -8274,10 +8277,10 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ style is wider than the window then the break occurs after the last character that completely fits on the line. The horizontal scroll bar does not appear when wrap mode is on.

-

For wrapped lines Scintilla can draw visual flags (little arrows) at end of a a subline of a - wrapped line and at begin of the next subline. These can be enabled individually, but if Scintilla - draws the visual flag at the beginning of the next subline this subline will be indented by one char. - Independent from drawing a visual flag at the begin the subline can have an indention.

+

For wrapped lines Scintilla can draw visual flags (little arrows) at end of a a subline of a + wrapped line and at begin of the next subline. These can be enabled individually, but if Scintilla + draws the visual flag at the beginning of the next subline this subline will be indented by one char. + Independent from drawing a visual flag at the begin the subline can have an indentation.

Much of the time used by Scintilla is spent on laying out and drawing text. The same text layout calculations may be performed many times even when the data used in these calculations @@ -8441,7 +8444,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ STYLE_DEFAULT. There are no limits on indent sizes, but values less than 0 or large values may have undesirable effects.
- The indention of sublines is independent of visual flags, but if + The indentation of sublines is independent of visual flags, but if SC_WRAPVISUALFLAG_START is set an indent of at least 1 is used.

diff --git a/scintilla/doc/ScintillaHistory.html b/scintilla/doc/ScintillaHistory.html index 5f0901b7a..e8b55793b 100644 --- a/scintilla/doc/ScintillaHistory.html +++ b/scintilla/doc/ScintillaHistory.html @@ -590,9 +590,27 @@ 8day Ahmet Sait + Sven Ritter

Releases

+

+ Release 5.5.8 +

+

Release 5.5.7

@@ -1779,7 +1797,7 @@
  • Remove SetLexer, SetLexerLanguage, and LoadLexerLibrary methods. - These have been superceded by Lexilla and the SetILexer API. + These have been superseded by Lexilla and the SetILexer API.
  • Improve the platform layer interface. diff --git a/scintilla/include/Scintilla.iface b/scintilla/include/Scintilla.iface index cc33bc961..61c1cf848 100644 --- a/scintilla/include/Scintilla.iface +++ b/scintilla/include/Scintilla.iface @@ -311,11 +311,6 @@ get IMEInteraction GetIMEInteraction=2678(,) # Choose to display the IME in a window or inline. set void SetIMEInteraction=2679(IMEInteraction imeInteraction,) -# >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> -get bool IsIMEOpen=6003(,) -get bool IsIMEModeCJK=6004(,) -# <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< - enu Alpha=SC_ALPHA_ val SC_ALPHA_TRANSPARENT=0 val SC_ALPHA_OPAQUE=255 diff --git a/scintilla/include/ScintillaCall.h b/scintilla/include/ScintillaCall.h index 149e60e7a..41c55f89e 100644 --- a/scintilla/include/ScintillaCall.h +++ b/scintilla/include/ScintillaCall.h @@ -142,8 +142,6 @@ public: std::string FontLocale(); Scintilla::IMEInteraction IMEInteraction(); void SetIMEInteraction(Scintilla::IMEInteraction imeInteraction); - bool IsIMEOpen(); - bool IsIMEModeCJK(); void MarkerDefine(int markerNumber, Scintilla::MarkerSymbol markerSymbol); void MarkerSetFore(int markerNumber, Colour fore); void MarkerSetBack(int markerNumber, Colour back); diff --git a/scintilla/include/ScintillaMessages.h b/scintilla/include/ScintillaMessages.h index 13ac5a382..2d474773a 100644 --- a/scintilla/include/ScintillaMessages.h +++ b/scintilla/include/ScintillaMessages.h @@ -71,8 +71,6 @@ enum class Message { GetFontLocale = 2761, GetIMEInteraction = 2678, SetIMEInteraction = 2679, - IsIMEOpen = 6003, - IsIMEModeCJK = 6004, MarkerDefine = 2040, MarkerSetFore = 2041, MarkerSetBack = 2042, diff --git a/scintilla/scripts/FileGenerator.py b/scintilla/scripts/FileGenerator.py index 71fb3eb82..f798e1d6b 100644 --- a/scintilla/scripts/FileGenerator.py +++ b/scintilla/scripts/FileGenerator.py @@ -181,5 +181,5 @@ def UpdateFileFromLines(path, lines, lineEndToUse): def ReplaceREInFile(path, match, replace, count=1): with codecs.open(path, "r", "utf-8") as f: contents = f.read() - contents = re.sub(match, replace, contents, count=count) + contents = re.sub(match, replace, contents, count) UpdateFile(path, contents) diff --git a/scintilla/src/CellBuffer.cxx b/scintilla/src/CellBuffer.cxx index 6bd4e16d5..165dccedd 100644 --- a/scintilla/src/CellBuffer.cxx +++ b/scintilla/src/CellBuffer.cxx @@ -26,7 +26,9 @@ #include "Debugging.h" +// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> #include "Scintilla.h" +// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< #include "Position.h" #include "SplitVector.h" #include "Partitioning.h" diff --git a/scintilla/src/Document.h b/scintilla/src/Document.h index 6ccc13b2e..c4da95967 100644 --- a/scintilla/src/Document.h +++ b/scintilla/src/Document.h @@ -109,7 +109,7 @@ public: virtual ~RegexSearchBase() = default; virtual Sci::Position FindText(Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s, - bool caseSensitive, bool word, bool wordStart, Scintilla::FindOption flags, Sci::Position *length) = 0; + bool caseSensitive, bool word, bool wordStart, Scintilla::FindOption flags, Sci::Position *length) = 0; ///@return String with the substitutions, must remain valid until the next call or destruction virtual const char *SubstituteByPosition(Document *doc, const char *text, Sci::Position *length) = 0; diff --git a/scintilla/src/EditModel.cxx b/scintilla/src/EditModel.cxx index 4f9f9a6d9..65d39f9e7 100644 --- a/scintilla/src/EditModel.cxx +++ b/scintilla/src/EditModel.cxx @@ -105,10 +105,6 @@ EditModel::EditModel() : braces{} { highlightGuideColumn = 0; hasFocus = false; primarySelection = true; - // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> - imeIsOpen = false; - imeIsInModeCJK = false; - // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< imeInteraction = IMEInteraction::Windowed; bidirectional = Bidirectional::Disabled; foldFlags = FoldFlag::None; diff --git a/scintilla/src/EditModel.h b/scintilla/src/EditModel.h index 7e847e8c3..dcaf99613 100644 --- a/scintilla/src/EditModel.h +++ b/scintilla/src/EditModel.h @@ -68,10 +68,6 @@ public: bool primarySelection; std::string copySeparator; - // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> - bool imeIsOpen; - bool imeIsInModeCJK; - // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< Scintilla::IMEInteraction imeInteraction; Scintilla::Bidirectional bidirectional; diff --git a/scintilla/src/EditView.cxx b/scintilla/src/EditView.cxx index 364c16868..285bb2b2c 100644 --- a/scintilla/src/EditView.cxx +++ b/scintilla/src/EditView.cxx @@ -400,7 +400,6 @@ void LayoutSegments(IPositionCache *pCache, void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width, bool callerMultiThreaded) { if (!ll) return; - const Sci::Line line = ll->LineNumber(); PLATFORM_ASSERT(line < model.pdoc->LinesTotal()); PLATFORM_ASSERT(ll->chars); @@ -547,6 +546,7 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt const TextSegment &ts = segments.back(); lastSegItalics = (!ts.representation) && ((ll->chars[ts.end() - 1] != ' ') && vstyle.styles[ll->styles[ts.start]].italic); } + // Small hack to make lines that end with italics not cut off the edge of the last character if (lastSegItalics) { ll->positions[numCharsInLine] += vstyle.lastSegItalicsOffset; @@ -2335,7 +2335,6 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi } } } - void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line line, int xStart, PRectangle rcLine, int subLine, Sci::Line lineVisible) { diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index fe21da46a..f7b8af402 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -13,7 +13,9 @@ #include #include +// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> #include +// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< #include #include #include @@ -634,7 +636,7 @@ SelectionRange Editor::LineSelectionRange(SelectionPosition currentPos_, Selecti currentPos_ = SelectionPosition(pdoc->LineStartPosition(currentPos_.Position())); anchor_ = SelectionPosition(pdoc->LineEndPosition(anchor_.Position())); } - return {currentPos_, anchor_}; + return SelectionRange(currentPos_, anchor_); } void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_) { @@ -5981,7 +5983,6 @@ std::unique_ptr Editor::CreateMeasurementSurface() const { return surf; } -// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> std::unique_ptr Editor::CreateDrawingSurface(SurfaceID sid, std::optional technologyOpt) const { if (!wMain.GetID()) { return {}; @@ -5991,7 +5992,6 @@ std::unique_ptr Editor::CreateDrawingSurface(SurfaceID sid, std::option surf->SetMode(CurrentSurfaceMode()); return surf; } -// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< Sci::Line Editor::WrapCount(Sci::Line line) { AutoSurface surface(this); @@ -7449,14 +7449,6 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { case Message::GetIMEInteraction: return static_cast(imeInteraction); - // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> - case Message::IsIMEOpen: - return static_cast(imeIsOpen); - - case Message::IsIMEModeCJK: - return static_cast(imeIsInModeCJK); - // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< - case Message::SetBidirectional: // Message::SetBidirectional is implemented on platform subclasses if they support bidirectional text. break; @@ -9187,7 +9179,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { return DefWndProc(iMessage, wParam, lParam); } - // If there was a change that needs its selection saved and it wasn't explicity saved + // If there was a change that needs its selection saved and it wasn't explicitly saved // then do that here. RememberCurrentSelectionForRedoOntoStack(); diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h index 99def9cbc..26f3c1941 100644 --- a/scintilla/src/Editor.h +++ b/scintilla/src/Editor.h @@ -466,9 +466,7 @@ protected: // ScintillaBase subclass needs access to much of Editor virtual void NotifyChange() = 0; virtual void NotifyFocus(bool focus); virtual void SetCtrlID(int identifier); - // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> virtual int GetCtrlID() const noexcept { return ctrlID; } - // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< virtual void NotifyParent(Scintilla::NotificationData scn) = 0; virtual void NotifyStyleToNeeded(Sci::Position endStyleNeeded); void NotifyChar(int ch, Scintilla::CharacterSource charSource); @@ -543,9 +541,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void CopyText(size_t length, const char *text); void SetDragPosition(SelectionPosition newPos); virtual void DisplayCursor(Window::Cursor c); - // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> virtual bool DragThreshold(Point ptStart, Point ptNow) noexcept; - // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< virtual void StartDrag(); void DropAt(SelectionPosition position, const char *value, size_t lengthValue, bool moving, bool rectangular); void DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular); @@ -591,11 +587,9 @@ protected: // ScintillaBase subclass needs access to much of Editor virtual void IdleWork(); virtual void QueueIdleWork(WorkItems items, Sci::Position upTo=0); - // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> virtual int SupportsFeature(Scintilla::Supports feature) const noexcept; virtual bool PaintContains(PRectangle rc) const noexcept; bool PaintContainsMargin() const noexcept; - // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< void CheckForChangeOutsidePaint(Range r); void SetBraceHighlight(Sci::Position pos0, Sci::Position pos1, int matchStyle); @@ -630,9 +624,7 @@ protected: // ScintillaBase subclass needs access to much of Editor virtual std::string UTF8FromEncoded(std::string_view encoded) const = 0; virtual std::string EncodedFromUTF8(std::string_view utf8) const = 0; virtual std::unique_ptr CreateMeasurementSurface() const; - // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> virtual std::unique_ptr CreateDrawingSurface(SurfaceID sid, std::optional technologyOpt = {}) const; - // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< Sci::Line WrapCount(Sci::Line line); void AddStyledText(const char *buffer, Sci::Position appendLength); diff --git a/scintilla/src/PerLine.cxx b/scintilla/src/PerLine.cxx index 5ea36892c..b394b4973 100644 --- a/scintilla/src/PerLine.cxx +++ b/scintilla/src/PerLine.cxx @@ -32,7 +32,8 @@ using namespace Scintilla::Internal; -MarkerHandleSet::MarkerHandleSet() = default; +MarkerHandleSet::MarkerHandleSet() { +} bool MarkerHandleSet::Empty() const noexcept { return mhList.empty(); diff --git a/scintilla/src/Platform.h b/scintilla/src/Platform.h index a12ea5244..035fb3f86 100644 --- a/scintilla/src/Platform.h +++ b/scintilla/src/Platform.h @@ -103,7 +103,7 @@ typedef void *IdlerID; * Font management. */ -constexpr const char *localeNameDefault = "en-US"; +constexpr const char *localeNameDefault = "en-us"; struct FontParameters { const char *faceName; @@ -385,6 +385,6 @@ constexpr long LongFromTwoShorts(short a,short b) noexcept { } -} // namespace +} #endif diff --git a/scintilla/src/PositionCache.cxx b/scintilla/src/PositionCache.cxx index 6ab2c70f2..9e18ca26c 100644 --- a/scintilla/src/PositionCache.cxx +++ b/scintilla/src/PositionCache.cxx @@ -167,22 +167,20 @@ bool LineLayout::InLine(int offset, int line) const noexcept { } int LineLayout::SubLineFromPosition(int posInLine, PointEnd pe) const noexcept { - if (!lineStarts || (posInLine > maxLineLength)) { + if (lines <= 1 || (posInLine >= numCharsBeforeEOL)) { return lines - 1; } - for (int line = 0; line < lines; line++) { - if (FlagSet(pe, PointEnd::subLineEnd)) { - // Return subline not start of next - if (lineStarts[line + 1] <= posInLine + 1) - return line; - } else { - if (lineStarts[line + 1] <= posInLine) - return line; + // Return subline not start of next for PointEnd::subLineEnd + posInLine -= FlagSet(pe, PointEnd::subLineEnd) ? 1 : 0; + int line = 1; + for (; line < lines; line++) { + if (lineStarts[line] > posInLine) { + break; } } - return lines - 1; + return line - 1; } void LineLayout::AddLineStart(Sci::Position start) { @@ -317,7 +315,7 @@ Interval LineLayout::SpanByte(int index) const noexcept { } int LineLayout::EndLineStyle() const noexcept { - return styles[numCharsBeforeEOL > 0 ? numCharsBeforeEOL-1 : 0]; + return styles[std::max(numCharsBeforeEOL - 1, 0)]; } void LineLayout::WrapLine(const Document *pdoc, Sci::Position posLineStart, Wrap wrapState, XYPOSITION wrapWidth) { diff --git a/scintilla/src/PositionCache.h b/scintilla/src/PositionCache.h index 0ecaf4475..4ece0a518 100644 --- a/scintilla/src/PositionCache.h +++ b/scintilla/src/PositionCache.h @@ -169,7 +169,6 @@ public: Sci::Line linesOnScreen, Sci::Line linesInDoc); }; - class Representation { public: static constexpr size_t maxLength = 200; @@ -268,6 +267,7 @@ public: }; std::unique_ptr CreatePositionCache(); + } #endif diff --git a/scintilla/src/Selection.cxx b/scintilla/src/Selection.cxx index 795570ee2..967033bff 100644 --- a/scintilla/src/Selection.cxx +++ b/scintilla/src/Selection.cxx @@ -29,23 +29,24 @@ namespace { // Generically convert a string to a integer value throwing if the conversion failed. // Failures include values that are out of range for the destination variable. template -void ValueFromString(std::string_view sv, T &value) { +void ValueFromString(std::string_view &sv, T &value) { const std::from_chars_result res = std::from_chars(sv.data(), sv.data() + sv.size(), value); if (res.ec != std::errc{}) { if (res.ec == std::errc::result_out_of_range) throw std::runtime_error("from_chars out of range."); throw std::runtime_error("from_chars failed."); } + sv.remove_prefix(res.ptr - sv.data()); } } -SelectionPosition::SelectionPosition(std::string_view sv) : position(0) { - if (const size_t v = sv.find('v'); v != std::string_view::npos) { - ValueFromString(sv.substr(v + 1), virtualSpace); - sv = sv.substr(0, v); - } +SelectionPosition::SelectionPosition(std::string_view &sv) : position(0) { ValueFromString(sv, position); + if (!sv.empty() && sv.front() == 'v') { + sv.remove_prefix(1); + ValueFromString(sv, virtualSpace); + } } void SelectionPosition::MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length, bool moveForEqual) noexcept { @@ -109,14 +110,13 @@ std::string SelectionPosition::ToString() const { return result; } -SelectionRange::SelectionRange(std::string_view sv) { - const size_t dash = sv.find('-'); - if (dash == std::string_view::npos) { - anchor = SelectionPosition(sv); +SelectionRange::SelectionRange(std::string_view &sv) { + anchor = SelectionPosition(sv); + if (sv.empty() || sv.front() != '-') { caret = anchor; } else { - anchor = SelectionPosition(sv.substr(0, dash)); - caret = SelectionPosition(sv.substr(dash + 1)); + sv.remove_prefix(1); + caret = SelectionPosition(sv); } } @@ -274,10 +274,13 @@ Selection::Selection(std::string_view sv) : mainRange(0), moveExtends(false), te sv.remove_prefix(1); } - // Non-zero main index at end after '#' - if (const size_t hash = sv.find('#'); hash != std::string_view::npos) { - ValueFromString(sv.substr(hash + 1), mainRange); - sv = sv.substr(0, hash); + // Non-zero main index at start after '#' + if (!sv.empty() && sv.front() == '#') { + sv.remove_prefix(1); + ValueFromString(sv, mainRange); + if (!sv.empty() && sv.front() == ',') { + sv.remove_prefix(1); + } } // Remainder is list of ranges @@ -288,13 +291,12 @@ Selection::Selection(std::string_view sv) : mainRange(0), moveExtends(false), te ranges.emplace_back(SelectionPosition(0)); } } else { - size_t comma = sv.find(','); - while (comma != std::string_view::npos) { - ranges.emplace_back(sv.substr(0, comma)); - sv.remove_prefix(comma + 1); - comma = sv.find(','); + while (!sv.empty()) { + if (sv.front() == ',') { + sv.remove_prefix(1); + } + ranges.emplace_back(sv); } - ranges.emplace_back(sv); if (mainRange >= ranges.size()) { mainRange = ranges.size() - 1; } @@ -595,6 +597,11 @@ std::string Selection::ToString() const { // No prefix. break; } + if (mainRange > 0) { + result += '#'; + result += std::to_string(mainRange); + result += ','; + } if (selType == SelTypes::rectangle || selType == SelTypes::thin) { result += rangeRectangular.ToString(); } else { @@ -606,10 +613,5 @@ std::string Selection::ToString() const { } } - if (mainRange > 0) { - result += '#'; - result += std::to_string(mainRange); - } - return result; } diff --git a/scintilla/src/Selection.h b/scintilla/src/Selection.h index 6779ee7ce..1a57d2e78 100644 --- a/scintilla/src/Selection.h +++ b/scintilla/src/Selection.h @@ -20,7 +20,7 @@ public: if (virtualSpace < 0) virtualSpace = 0; } - explicit SelectionPosition(std::string_view sv); + explicit SelectionPosition(std::string_view &sv); void Reset() noexcept { position = 0; virtualSpace = 0; @@ -121,7 +121,7 @@ struct SelectionRange { } constexpr SelectionRange(Sci::Position caret_, Sci::Position anchor_) noexcept : caret(caret_), anchor(anchor_) { } - explicit SelectionRange(std::string_view sv); + explicit SelectionRange(std::string_view &sv); SelectionSegment AsSegment() const noexcept { return {caret, anchor}; } diff --git a/scintilla/src/Style.cxx b/scintilla/src/Style.cxx index ff9dc12b8..16643fb95 100644 --- a/scintilla/src/Style.cxx +++ b/scintilla/src/Style.cxx @@ -74,7 +74,9 @@ Style::Style(const char *fontName_) noexcept : back(white), eolFilled(false), underline(false), + // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> strike(false), + // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< caseForce(CaseForce::mixed), visible(true), changeable(true), diff --git a/scintilla/src/ViewStyle.cxx b/scintilla/src/ViewStyle.cxx index 4bfd1fd57..f1301aec5 100644 --- a/scintilla/src/ViewStyle.cxx +++ b/scintilla/src/ViewStyle.cxx @@ -61,10 +61,12 @@ bool MarginStyle::ShowsFolding() const noexcept { void FontRealised::Realise(Surface &surface, int zoomLevel, Technology technology, const FontSpecification &fs, const char *localeName) { PLATFORM_ASSERT(fs.fontName); + // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> //~measurements.sizeZoomed = fs.size + zoomLevel * FontSizeMultiplier; //~if (measurements.sizeZoomed <= FontSizeMultiplier) // May fail if sizeZoomed < 1 //~ measurements.sizeZoomed = FontSizeMultiplier; measurements.sizeZoomed = GetFontSizeZoomed(fs.size, zoomLevel); + // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< const float deviceHeight = static_cast(surface.DeviceHeightFont(measurements.sizeZoomed)); const FontParameters fp(fs.fontName, deviceHeight / FontSizeMultiplier, fs.weight, diff --git a/scintilla/src/ViewStyle.h b/scintilla/src/ViewStyle.h index d87883f00..28474d536 100644 --- a/scintilla/src/ViewStyle.h +++ b/scintilla/src/ViewStyle.h @@ -8,7 +8,9 @@ #ifndef VIEWSTYLE_H #define VIEWSTYLE_H +// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> #include "Scintilla.h" +// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< namespace Scintilla::Internal { diff --git a/scintilla/win32/ListBox.cxx b/scintilla/win32/ListBox.cxx index 258f592df..fb2632a44 100644 --- a/scintilla/win32/ListBox.cxx +++ b/scintilla/win32/ListBox.cxx @@ -77,6 +77,13 @@ void *PtrFromLParam(Scintilla::sptr_t lParam) noexcept { return reinterpret_cast(lParam); } +// These are reasonable initial guesses that may be refined by measurement or calls. +constexpr SIZE sizeList { 150, 80 }; +constexpr int commonLineHeight = 10; +constexpr unsigned int commonCharacterWidth = 8; +constexpr int commonItemLength = 12; +constexpr int defaultVisibleRows = 9; + struct ListItemData { const char *text; int pixId; @@ -115,11 +122,11 @@ public: } }; -const TCHAR ListBoxX_ClassName[] = TEXT("ListBoxX"); +const TCHAR *ListBoxX_ClassName = TEXT("ListBoxX"); ColourRGBA ColourElement(std::optional colour, int nIndex) { if (colour.has_value()) { - return colour.value(); + return colour.value().Opaque(); } return ColourFromSys(nIndex); } @@ -143,7 +150,7 @@ struct LBGraphics { } class ListBoxX : public ListBox { - int lineHeight = 10; + int lineHeight = commonLineHeight; HFONT fontCopy {}; std::unique_ptr fontWin; Technology technology = Technology::Default; @@ -152,9 +159,9 @@ class ListBoxX : public ListBox { HWND lb {}; bool unicodeMode = false; int codePage = 0; - int desiredVisibleRows = 9; + int desiredVisibleRows = defaultVisibleRows; int maxItemCharacters = 0; - unsigned int aveCharWidth = 8; + unsigned int aveCharWidth = commonCharacterWidth; Window *parent = nullptr; WNDPROC prevWndProc{}; int ctrlID = 0; @@ -248,10 +255,11 @@ void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHei HWND hwndParent = HwndFromWindow(*parent); HINSTANCE hinstanceParent = GetWindowInstance(hwndParent); // Window created as popup so not clipped within parent client area + constexpr int startPosition = 100; // Arbitrary as will be moved immediately wid = ::CreateWindowEx( WS_EX_WINDOWEDGE, ListBoxX_ClassName, TEXT(""), WS_POPUP | frameStyle, - 100,100, 150,80, hwndParent, + startPosition,startPosition, sizeList.cx,sizeList.cy, hwndParent, {}, hinstanceParent, this); @@ -272,7 +280,8 @@ void ListBoxX::SetFont(const Font *font) { fontCopy = pfm->HFont(); SetWindowFont(lb, fontCopy, 0); fontWin = pfm->Duplicate(); - codePage = unicodeMode ? CpUtf8 : CodePageFromCharSet(fontWin->GetCharacterSet(), 1252); + codePage = unicodeMode ? CpUtf8 : + CodePageFromCharSet(fontWin->GetCharacterSet(), codePageWindowsLatin); graphics.Release(); } } @@ -303,7 +312,6 @@ PRectangle ListBoxX::GetDesiredRect() { int width = MinClientWidth(); int textSize = 0; - int averageCharWidth = 8; // Make a measuring surface std::unique_ptr surfaceItem(Surface::Allocate(technology)); @@ -320,7 +328,7 @@ PRectangle ListBoxX::GetDesiredRect() { } maxCharWidth = static_cast(std::ceil(surfaceItem->WidthText(fontWin.get(), "W"))); - averageCharWidth = static_cast(surfaceItem->AverageCharWidth(fontWin.get())); + const int averageCharWidth = static_cast(surfaceItem->AverageCharWidth(fontWin.get())); width = std::max({ width, textSize, (maxItemCharacters + 1) * averageCharWidth }); @@ -536,16 +544,13 @@ void ListBoxX::AdjustWindowRect(PRectangle *rc, UINT dpiAdjust) const noexcept { } int ListBoxX::ItemHeight() const noexcept { - int itemHeight = lineHeight + (TextInset.y * 2); + const int itemHeight = lineHeight + (TextInset.y * 2); const int pixHeight = images.GetHeight() + (ImageInset.y * 2); - if (itemHeight < pixHeight) { - itemHeight = pixHeight; - } - return itemHeight; + return std::max(itemHeight, pixHeight); } int ListBoxX::MinClientWidth() const noexcept { - return 12 * (aveCharWidth+aveCharWidth/3); + return commonItemLength * (aveCharWidth+aveCharWidth/3); } POINT ListBoxX::MinTrackSize() const noexcept { @@ -558,7 +563,7 @@ POINT ListBoxX::MinTrackSize() const noexcept { POINT ListBoxX::MaxTrackSize() const noexcept { PRectangle rc = PRectangle::FromInts(0, 0, std::max(static_cast(MinClientWidth()), - maxCharWidth * maxItemCharacters + TextInset.x * 2 + + (maxCharWidth * maxItemCharacters) + (TextInset.x * 2) + TextOffset() + SystemMetricsForDpi(SM_CXVSCROLL, dpi)), ItemHeight() * lti.Count()); AdjustWindowRect(&rc, dpi); @@ -745,7 +750,7 @@ void ListBoxX::CentreItem(int n) { } void ListBoxX::AllocateBitMap() { - const SIZE extent { GetClientExtent().x, lineHeight }; + const SIZE extent { GetClientExtent().x, ItemHeight() }; graphics.bm.Create({}, extent.cx, -extent.cy, nullptr); if (!graphics.bm) { @@ -845,7 +850,7 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam 0, WC_LISTBOXW, L"", WS_CHILD | WS_VSCROLL | WS_VISIBLE | LBS_OWNERDRAWFIXED | LBS_NODATA | LBS_NOINTEGRALHEIGHT, - 0, 0, 150,80, hWnd, + 0, 0, sizeList.cx, sizeList.cy, hWnd, reinterpret_cast(static_cast(ctrlID)), hinstanceParent, nullptr); @@ -934,10 +939,7 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam const int nRows = GetVisibleRows(); int linesToScroll = std::clamp(nRows - 1, 1, 3); linesToScroll *= wheelDelta.Actions(); - int top = ListBox_GetTopIndex(lb) + linesToScroll; - if (top < 0) { - top = 0; - } + const int top = std::max(0, ListBox_GetTopIndex(lb) + linesToScroll); ListBox_SetTopIndex(lb, top); } break; diff --git a/scintilla/win32/PlatWin.h b/scintilla/win32/PlatWin.h index 39e98d49d..8ebf5bd7a 100644 --- a/scintilla/win32/PlatWin.h +++ b/scintilla/win32/PlatWin.h @@ -18,6 +18,8 @@ constexpr FLOAT dpiDefault = USER_DEFAULT_SCREEN_DPI; // Used for defining font size with LOGFONT constexpr int pointsPerInch = 72; +constexpr UINT codePageWindowsLatin = 1252; + extern void Platform_Initialise(void *hInstance) noexcept; extern void Platform_Finalise(bool fromDllMain) noexcept; diff --git a/scintilla/win32/Scintilla.vcxproj b/scintilla/win32/Scintilla.vcxproj index 1fc1312ba..7035422f8 100644 --- a/scintilla/win32/Scintilla.vcxproj +++ b/scintilla/win32/Scintilla.vcxproj @@ -86,7 +86,7 @@ Level4 _USRDLL;%(PreprocessorDefinitions) ..\include;..\src; - true + false true false ProgramDatabase diff --git a/scintilla/win32/ScintillaWin.cxx b/scintilla/win32/ScintillaWin.cxx index 40eb8d8a4..064bb9746 100644 --- a/scintilla/win32/ScintillaWin.cxx +++ b/scintilla/win32/ScintillaWin.cxx @@ -335,9 +335,12 @@ public: void SetCompositionFont(const ViewStyle &vs, int style, UINT dpi) const { LOGFONTW lf{}; - int sizeZoomed = vs.styles[style].size + (vs.zoomLevel * FontSizeMultiplier); - if (sizeZoomed <= 2 * FontSizeMultiplier) // Hangs if sizeZoomed <= 1 - sizeZoomed = 2 * FontSizeMultiplier; + // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> + //int sizeZoomed = vs.styles[style].size + (vs.zoomLevel * FontSizeMultiplier); + //if (sizeZoomed <= 2 * FontSizeMultiplier) // Hangs if sizeZoomed <= 1 + // sizeZoomed = 2 * FontSizeMultiplier; + int const sizeZoomed = GetFontSizeZoomed(vs.styles[style].size, vs.zoomLevel); + // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< // The negative is to allow for leading lf.lfHeight = -::MulDiv(sizeZoomed, dpi, pointsPerInch * FontSizeMultiplier); lf.lfWeight = static_cast(vs.styles[style].weight); @@ -1638,8 +1641,8 @@ UINT CodePageFromCharSet(CharacterSet characterSet, UINT documentCodePage) noexc return CpUtf8; } switch (characterSet) { - case CharacterSet::Ansi: return 1252; - case CharacterSet::Default: return documentCodePage ? documentCodePage : 1252; + case CharacterSet::Ansi: return codePageWindowsLatin; + case CharacterSet::Default: return documentCodePage ? documentCodePage : codePageWindowsLatin; case CharacterSet::Baltic: return 1257; case CharacterSet::ChineseBig5: return 950; case CharacterSet::EastEurope: return 1250; @@ -3419,22 +3422,6 @@ void ScintillaWin::ImeStartComposition() { if (stylesValid) { // Since the style creation code has been made platform independent, // The logfont for the IME is recreated here. - // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> - //const int styleHere = pdoc->StyleIndexAt(sel.MainCaret()); - //LOGFONTW lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L""}; - //int sizeZoomed = GetFontSizeZoomed(vs.styles[styleHere].size, vs.zoomLevel); - //// The negative is to allow for leading - //lf.lfHeight = -::MulDiv(sizeZoomed, dpi, 72*FontSizeMultiplier); - //lf.lfWeight = static_cast(vs.styles[styleHere].weight); - //lf.lfItalic = vs.styles[styleHere].italic ? 1 : 0; - //lf.lfCharSet = DEFAULT_CHARSET; - //lf.lfFaceName[0] = L'\0'; - //if (vs.styles[styleHere].fontName) { - // const char* fontName = vs.styles[styleHere].fontName; - // UTF16FromUTF8(std::string_view(fontName), lf.lfFaceName, LF_FACESIZE); - //} - // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< - imc.SetCompositionFont(vs, pdoc->StyleIndexAt(sel.MainCaret()), dpi); } // Caret is displayed in IME window. So, caret in Scintilla is useless.