From aa5f713e795a1408c3b4a1295aa1f89f0b2faac4 Mon Sep 17 00:00:00 2001
From: nyamatongwe
+
@@ -1075,7 +1076,8 @@ struct TextToFind {
document holding only an end of line sequence has 2 lines.
SCI_GETFIRSTVISIBLELINE
- This returns the line number of the first visible line in the Scintilla view. The first line
+ SCI_SETFIRSTVISIBLELINE(int lineDisplay)
+ These messages retrieve and set the line number of the first visible line in the Scintilla view. The first line
in the document is numbered 0. The value is a visible line rather than a document line.
SCI_LINESONSCREEN
diff --git a/include/Scintilla.h b/include/Scintilla.h
index e38d74cba..a702fd90d 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -485,6 +485,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SC_EFF_QUALITY_LCD_OPTIMIZED 3
#define SCI_SETFONTQUALITY 2611
#define SCI_GETFONTQUALITY 2612
+#define SCI_SETFIRSTVISIBLELINE 2613
#define SCI_TARGETFROMSELECTION 2287
#define SCI_LINESJOIN 2288
#define SCI_LINESSPLIT 2289
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index 64c73327b..05aa5ab9f 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1220,6 +1220,9 @@ set void SetFontQuality=2611(int fontQuality,)
# Retrieve the quality level for text.
get int GetFontQuality=2612(,)
+# Scroll so that a display line is at the top of the display.
+set int SetFirstVisibleLine=2613(int lineDisplay,)
+
# Make the target range start and end be the same as the selection range start and end.
fun void TargetFromSelection=2287(,)
diff --git a/src/Editor.cxx b/src/Editor.cxx
index f6e7b0603..f9eee5acc 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -6499,6 +6499,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_GETFIRSTVISIBLELINE:
return topLine;
+ case SCI_SETFIRSTVISIBLELINE:
+ ScrollTo(wParam);
+ break;
+
case SCI_GETLINE: { // Risk of overwriting the end of the buffer
int lineStart = pdoc->LineStart(wParam);
int lineEnd = pdoc->LineStart(wParam + 1);
diff --git a/test/simpleTests.py b/test/simpleTests.py
index feab296b9..2793361b2 100644
--- a/test/simpleTests.py
+++ b/test/simpleTests.py
@@ -697,6 +697,29 @@ class TestIndicators(unittest.TestCase):
self.assertEquals(self.ed.IndicGetStyle(0), 2)
self.assertEquals(self.ed.IndicGetFore(0), 0xff0080)
+class TestScrolling(unittest.TestCase):
+
+ def setUp(self):
+ self.xite = XiteWin.xiteFrame
+ self.ed = self.xite.ed
+ self.ed.ClearAll()
+ self.ed.EmptyUndoBuffer()
+ # 150 should be enough lines
+ self.ed.InsertText(0, b"a\n" * 150)
+
+ def testTop(self):
+ self.ed.GotoLine(0)
+ self.assertEquals(self.ed.FirstVisibleLine, 0)
+
+ def testLineScroll(self):
+ self.ed.GotoLine(0)
+ self.ed.LineScroll(0, 3)
+ self.assertEquals(self.ed.FirstVisibleLine, 3)
+
+ def testVisibleLine(self):
+ self.ed.FirstVisibleLine = 7
+ self.assertEquals(self.ed.FirstVisibleLine, 7)
+
class TestSearch(unittest.TestCase):
def setUp(self):
--
cgit v1.2.3