diff options
-rw-r--r-- | include/Scintilla.h | 1 | ||||
-rw-r--r-- | include/Scintilla.iface | 4 | ||||
-rw-r--r-- | src/Editor.cxx | 46 | ||||
-rw-r--r-- | src/Editor.h | 2 |
4 files changed, 32 insertions, 21 deletions
diff --git a/include/Scintilla.h b/include/Scintilla.h index fee9f9922..0185d3e5b 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -334,6 +334,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_TOGGLEFOLD 2231 #define SCI_ENSUREVISIBLE 2232 #define SCI_SETFOLDFLAGS 2233 +#define SCI_ENSUREVISIBLEENFORCEPOLICY 2234 #define SCI_SETTABINDENTS 2260 #define SCI_GETTABINDENTS 2261 #define SCI_SETBACKSPACEUNINDENTS 2262 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 2f0baebb6..4bce389e9 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -848,6 +848,10 @@ fun void EnsureVisible=2232(int line,) # Set some debugging options for folding fun void SetFoldFlags=2233(int flags,) +# Ensure a particular line is visible by expanding any header line hiding it. +# Use the currently set visibility policy to determine which range to display. +fun void EnsureVisibleEnforcePolicy=2234(int line,) + # Sets whether a tab pressed when caret is within indentation indents set void SetTabIndents=2260(bool tabIndents,) diff --git a/src/Editor.cxx b/src/Editor.cxx index 1735de498..5b72ac579 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -3482,12 +3482,12 @@ void Editor::ToggleContraction(int line) { // Recurse up from this line to find any folds that prevent this line from being visible // and unfold them all. -void Editor::EnsureLineVisible(int lineDoc) { +void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { if (!cs.GetVisible(lineDoc)) { int lineParent = pdoc->GetFoldParent(lineDoc); if (lineParent >= 0) { if (lineDoc != lineParent) - EnsureLineVisible(lineParent); + EnsureLineVisible(lineParent, enforcePolicy); if (!cs.GetExpanded(lineParent)) { cs.SetExpanded(lineParent, 1); Expand(lineParent, true); @@ -3496,23 +3496,25 @@ void Editor::EnsureLineVisible(int lineDoc) { SetScrollBars(); Redraw(); } - int lineDisplay = cs.DisplayFromDoc(lineDoc); - if (visiblePolicy & VISIBLE_SLOP) { - if ((topLine > lineDisplay) || ((visiblePolicy & VISIBLE_STRICT) && (topLine + visibleSlop > lineDisplay))) { - SetTopLine(Platform::Clamp(lineDisplay - visibleSlop, 0, MaxScrollPos())); - SetVerticalScrollPos(); - Redraw(); - } else if ((lineDisplay > topLine + LinesOnScreen() - 1) || - ((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) { - SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos())); - SetVerticalScrollPos(); - Redraw(); - } - } else { - if ((topLine > lineDisplay) || (lineDisplay > topLine + LinesOnScreen() - 1) || (visiblePolicy & VISIBLE_STRICT)) { - SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos())); - SetVerticalScrollPos(); - Redraw(); + if (enforcePolicy) { + int lineDisplay = cs.DisplayFromDoc(lineDoc); + if (visiblePolicy & VISIBLE_SLOP) { + if ((topLine > lineDisplay) || ((visiblePolicy & VISIBLE_STRICT) && (topLine + visibleSlop > lineDisplay))) { + SetTopLine(Platform::Clamp(lineDisplay - visibleSlop, 0, MaxScrollPos())); + SetVerticalScrollPos(); + Redraw(); + } else if ((lineDisplay > topLine + LinesOnScreen() - 1) || + ((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) { + SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos())); + SetVerticalScrollPos(); + Redraw(); + } + } else { + if ((topLine > lineDisplay) || (lineDisplay > topLine + LinesOnScreen() - 1) || (visiblePolicy & VISIBLE_STRICT)) { + SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos())); + SetVerticalScrollPos(); + Redraw(); + } } } } @@ -4637,7 +4639,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_ENSUREVISIBLE: - EnsureLineVisible(wParam); + EnsureLineVisible(wParam, false); + break; + + case SCI_ENSUREVISIBLEENFORCEPOLICY: + EnsureLineVisible(wParam, true); break; case SCI_SEARCHANCHOR: diff --git a/src/Editor.h b/src/Editor.h index 3d7c54e8e..d42f5ad14 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -328,7 +328,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void Expand(int &line, bool doExpand); void ToggleContraction(int line); - void EnsureLineVisible(int lineDoc); + void EnsureLineVisible(int lineDoc, bool enforcePolicy); int ReplaceTarget(bool replacePatterns, const char *text, int length=-1); virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0; |