aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaDoc.html8
-rw-r--r--include/Scintilla.h3
-rw-r--r--include/Scintilla.iface7
-rw-r--r--src/Editor.cxx26
-rw-r--r--src/Editor.h3
5 files changed, 45 insertions, 2 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index fdb12bc92..36868b308 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -192,7 +192,8 @@ SCI_SELECTALL
SCI_GOTOLINE(int line)
SCI_GOTOPOS(int position)
SCI_GETCURLINE(int textlen, char *text)
-SCI_SETCARETPOLICY(int policy)
+SCI_SETCARETPOLICY(int policy, int slop)
+SCI_SETVISIBLEPOLICY(int policy, int slop)
SCI_LINESONSCREEN
SCI_SELECTIONISRECTANGLE
SCI_SETHSCROLLBAR(bool visible)
@@ -213,7 +214,10 @@ SCI_GETHSCROLLBAR
<p>
SCI_SETCARETPOLICY can be set to a combination of the flags CARET_SLOP,
CARET_CENTER, and CARET_STRICT to change the automatic vertical positioning of the view
- when ensuring a position is visible.
+ when ensuring a position is visible. SCI_SETVISIBLEPOLICY is a similar function that
+ determines how the vertical positioning is determined when SCI_ENSUREVISIBLE is
+ called. It takes VISIBLE_SLOP, VISIBLE_CENTER, and VISIBLE_STRICT flags
+ for the policy parameter.
</p>
<h3>
Searching
diff --git a/include/Scintilla.h b/include/Scintilla.h
index da41bb6bf..099f2e3b7 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -382,6 +382,9 @@ typedef long (*SciFnDirect)(long ptr, unsigned int iMessage, unsigned long wPara
#define SCI_WORDPARTLEFTEXTEND 2391
#define SCI_WORDPARTRIGHT 2392
#define SCI_WORDPARTRIGHTEXTEND 2393
+#define VISIBLE_SLOP 0x01
+#define VISIBLE_STRICT 0x04
+#define SCI_SETVISIBLEPOLICY 2394
#define SCI_GRABFOCUS 2400
#define SCI_STARTRECORD 3001
#define SCI_STOPRECORD 3002
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index f5ea2f965..d1107388f 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1030,6 +1030,13 @@ fun void WordPartRight=2392(,)
# Move to the next change in capitalistion extending selection to new caret position.
fun void WordPartRightExtend=2393(,)
+# Constants for use with SetVisiblePolicy
+val VISIBLE_SLOP=0x01
+#val VISIBLE_CENTER=0x02
+val VISIBLE_STRICT=0x04
+# Set the way the display area is determined when a particular line is to be moved to.
+fun void SetVisiblePolicy=2394(int visiblePolicy, int visibleSlop)
+
# Set the focus to this Scintilla widget.
# GTK+ Specific
fun void GrabFocus=2400(,)
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 6c7bda2b2..85958be8f 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -75,6 +75,9 @@ Editor::Editor() {
caretPolicy = CARET_SLOP;
caretSlop = 0;
+ visiblePolicy = VISIBLE_SLOP;
+ visibleSlop = 0;
+
searchAnchor = 0;
ucWheelScrollLines = 0;
@@ -3148,6 +3151,24 @@ void Editor::EnsureLineVisible(int line) {
SetScrollBars();
Redraw();
}
+ if (visiblePolicy & VISIBLE_SLOP) {
+ if ((topLine > line) || ((visiblePolicy & VISIBLE_STRICT) && (topLine + visibleSlop > line))) {
+ SetTopLine(Platform::Clamp(line - visibleSlop, 0, MaxScrollPos()));
+ SetVerticalScrollPos();
+ Redraw();
+ } else if ((line > topLine + LinesOnScreen() - 1) ||
+ ((visiblePolicy & VISIBLE_STRICT) && (line > topLine + LinesOnScreen() - 1 - visibleSlop))) {
+ SetTopLine(Platform::Clamp(line - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos()));
+ SetVerticalScrollPos();
+ Redraw();
+ }
+ } else {
+ if ((topLine > line) || (line > topLine + LinesOnScreen() - 1) || (visiblePolicy & VISIBLE_STRICT)) {
+ SetTopLine(Platform::Clamp(line - LinesOnScreen() / 2 + 1, 0, MaxScrollPos()));
+ SetVerticalScrollPos();
+ Redraw();
+ }
+ }
}
static bool ValidMargin(unsigned long wParam) {
@@ -4180,6 +4201,11 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) {
caretSlop = lParam;
break;
+ case SCI_SETVISIBLEPOLICY:
+ visiblePolicy = wParam;
+ visibleSlop = lParam;
+ break;
+
case SCI_LINESONSCREEN:
return LinesOnScreen();
diff --git a/src/Editor.h b/src/Editor.h
index 1bcac1665..52b3d7037 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -134,6 +134,9 @@ protected: // ScintillaBase subclass needs access to much of Editor
int caretPolicy;
int caretSlop;
+ int visiblePolicy;
+ int visibleSlop;
+
int searchAnchor;
int displayPopupMenu;