diff options
-rw-r--r-- | doc/ScintillaDoc.html | 11 | ||||
-rw-r--r-- | include/Scintilla.h | 2 | ||||
-rw-r--r-- | include/Scintilla.iface | 6 | ||||
-rw-r--r-- | src/Editor.cxx | 19 | ||||
-rw-r--r-- | src/Editor.h | 2 |
5 files changed, 38 insertions, 2 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index a5080468f..22e4a7658 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -1337,6 +1337,8 @@ struct TextToFind { <a class="message" href="#SCI_SETXOFFSET">SCI_SETXOFFSET(int xOffset)</a><br /> <a class="message" href="#SCI_SETSCROLLWIDTH">SCI_SETSCROLLWIDTH(int pixelWidth)</a><br /> <a class="message" href="#SCI_GETSCROLLWIDTH">SCI_GETSCROLLWIDTH</a><br /> + <a class="message" href="#SCI_SETSCROLLWIDTHTRACKING">SCI_SETSCROLLWIDTHTRACKING(bool tracking)</a><br /> + <a class="message" href="#SCI_GETSCROLLWIDTHTRACKING">SCI_GETSCROLLWIDTHTRACKING</a><br /> <a class="message" href="#SCI_SETENDATLASTLINE">SCI_SETENDATLASTLINE(bool endAtLastLine)</a><br /> <a class="message" href="#SCI_GETENDATLASTLINE">SCI_GETENDATLASTLINE</a><br /> @@ -1643,7 +1645,14 @@ struct TextToFind { For performance, Scintilla does not measure the display width of the document to determine the properties of the horizontal scroll bar. Instead, an assumed width is used. These messages set and get the document width in pixels assumed by Scintilla. - The default value is 2000.</p> + The default value is 2000. + To ensure the width of the currently visible lines can be scrolled use + <a class="message" href="#SCI_SETSCROLLWIDTHTRACKING"><code>SCI_SETSCROLLWIDTHTRACKING</code></a></p> + + <p><b id="SCI_SETSCROLLWIDTHTRACKING">SCI_SETSCROLLWIDTHTRACKING(bool tracking)</b><br /> + <b id="SCI_GETSCROLLWIDTHTRACKING">SCI_GETSCROLLWIDTHTRACKING</b><br /> + If scroll width tracking is enabled then the scroll width is adjusted to ensure that all of the lines currently + displayed can be completely scrolled. This mode never adjusts the scroll width to be narrower.</p> <p><b id="SCI_SETENDATLASTLINE">SCI_SETENDATLASTLINE(bool endAtLastLine)</b><br /> <b id="SCI_GETENDATLASTLINE">SCI_GETENDATLASTLINE</b><br /> diff --git a/include/Scintilla.h b/include/Scintilla.h index 450865cc1..f4eca1aef 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -448,6 +448,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETLAYOUTCACHE 2273 #define SCI_SETSCROLLWIDTH 2274 #define SCI_GETSCROLLWIDTH 2275 +#define SCI_SETSCROLLWIDTHTRACKING 2516 +#define SCI_GETSCROLLWIDTHTRACKING 2517 #define SCI_TEXTWIDTH 2276 #define SCI_SETENDATLASTLINE 2277 #define SCI_GETENDATLASTLINE 2278 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 3c52ce35e..2b7a0f1e6 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1143,6 +1143,12 @@ set void SetScrollWidth=2274(int pixelWidth,) # Retrieve the document width assumed for scrolling. get int GetScrollWidth=2275(,) +# Sets whether the maximum width line displayed is used to set scroll width. +set void SetScrollWidthTracking=2516(bool tracking,) + +# Retrieve whether the scroll width tracks wide lines. +get bool GetScrollWidthTracking=2517(,) + # Measure the pixel width of some text in a particular style. # NUL terminated text argument. # Does not handle tab or control characters. diff --git a/src/Editor.cxx b/src/Editor.cxx index b7fa63e22..5d79d550a 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -138,6 +138,8 @@ Editor::Editor() { xCaretMargin = 50; horizontalScrollBarVisible = true; scrollWidth = 2000; + trackLineWidth = false; + lineWidthMaxSeen = 0; verticalScrollBarVisible = true; endAtLastLine = true; caretSticky = false; @@ -1205,7 +1207,7 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { xOffset = xOffsetNew; if (xOffsetNew > 0) { PRectangle rcText = GetTextRectangle(); - if (horizontalScrollBarVisible == true && + if (horizontalScrollBarVisible && rcText.Width() + xOffset > scrollWidth) { scrollWidth = xOffset + rcText.Width(); SetScrollBars(); @@ -2948,6 +2950,9 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { yposScreen += vs.lineHeight; visibleLine++; + + lineWidthMaxSeen = Platform::Maximum( + lineWidthMaxSeen, ll->positions[ll->numCharsInLine]); //gdk_flush(); } ll.Set(0); @@ -5353,6 +5358,10 @@ void Editor::Tick() { } } } + if (horizontalScrollBarVisible && trackLineWidth && (lineWidthMaxSeen > scrollWidth)) { + scrollWidth = lineWidthMaxSeen; + SetScrollBars(); + } if ((dwellDelay < SC_TIME_FOREVER) && (ticksToDwell > 0) && (!HaveMouseCapture())) { @@ -6464,6 +6473,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETSCROLLWIDTH: PLATFORM_ASSERT(wParam > 0); if ((wParam > 0) && (wParam != static_cast<unsigned int >(scrollWidth))) { + lineWidthMaxSeen = 0; scrollWidth = wParam; SetScrollBars(); } @@ -6472,6 +6482,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETSCROLLWIDTH: return scrollWidth; + case SCI_SETSCROLLWIDTHTRACKING: + trackLineWidth = wParam != 0; + break; + + case SCI_GETSCROLLWIDTHTRACKING: + return trackLineWidth; + case SCI_LINESJOIN: LinesJoin(); break; diff --git a/src/Editor.h b/src/Editor.h index 501abb632..2115af7d9 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -136,6 +136,8 @@ protected: // ScintillaBase subclass needs access to much of Editor int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret bool horizontalScrollBarVisible; int scrollWidth; + bool trackLineWidth; + int lineWidthMaxSeen; bool verticalScrollBarVisible; bool endAtLastLine; bool caretSticky; |