aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaDoc.html12
-rw-r--r--include/Scintilla.h2
-rw-r--r--include/Scintilla.iface9
-rw-r--r--src/Editor.cxx30
-rw-r--r--src/Editor.h1
5 files changed, 48 insertions, 6 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index 8b1e6dca5..55f397b8b 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -286,6 +286,10 @@ SCI_SETHSCROLLBAR(bool visible)
SCI_GETHSCROLLBAR
SCI_GETXOFFSET
SCI_SETXOFFSET(int xoffset)
+SCI_SETSCROLLWIDTH(int pixelWidth)
+SCI_GETSCROLLWIDTH
+SCI_SETENDATLASTLINE(bool endAtLastLine)
+SCI_GETENDATLASTLINE
</pre>
<p>
SCI_SETCARETPOLICY can be set to a combination of the flags CARET_SLOP
@@ -307,6 +311,14 @@ SCI_SETXOFFSET(int xoffset)
<p>
The xoffset is the horizontal scroll position in pixels.
</p>
+ <p>
+ SCI_SETSCROLLWIDTH sets the document width assumed for scrolling.
+ </p>
+ <p>
+ SCI_SETENDATLASTLINE sets the scroll range so that maximum
+ scroll position has the last line at the bottom of the view (default).
+ Setting this to false allows scrolling one page below the last line.
+ </p>
<h3>
Searching
</h3>
diff --git a/include/Scintilla.h b/include/Scintilla.h
index e5ccd6f11..b4fa06359 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -362,6 +362,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_SETSCROLLWIDTH 2274
#define SCI_GETSCROLLWIDTH 2275
#define SCI_TEXTWIDTH 2276
+#define SCI_SETENDATLASTLINE 2277
+#define SCI_GETENDATLASTLINE 2278
#define SCI_LINEDOWN 2300
#define SCI_LINEDOWNEXTEND 2301
#define SCI_LINEUP 2302
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index 99afef5c0..8a4849025 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -943,6 +943,15 @@ get int GetScrollWidth=2275(,)
# Does not handle tab or control characters.
fun int TextWidth=2276(int style, string text)
+# Sets the scroll range so that maximum scroll position has
+# the last line at the bottom of the view (default).
+# Setting this to false allows scrolling one page below the last line.
+set void SetEndAtLastLine=2277(bool endAtLastLine,)
+
+# Retrieve whether the maximum scroll position has the last
+# line at the bottom of the view.
+get int GetEndAtLastLine=2278(,)
+
## Start of key messages
# Move caret down one line.
fun void LineDown=2300(,)
diff --git a/src/Editor.cxx b/src/Editor.cxx
index db5fe54b5..133e62b40 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -327,6 +327,7 @@ Editor::Editor() {
xCaretMargin = 50;
horizontalScrollBarVisible = true;
scrollWidth = 2000;
+ endAtLastLine = true;
pixmapLine = Surface::Allocate();
pixmapSelMargin = Surface::Allocate();
@@ -452,11 +453,17 @@ int Editor::LinesToScroll() {
int Editor::MaxScrollPos() {
//Platform::DebugPrintf("Lines %d screen = %d maxScroll = %d\n",
//LinesTotal(), LinesOnScreen(), LinesTotal() - LinesOnScreen() + 1);
- int retVal = cs.LinesDisplayed() - LinesOnScreen();
- if (retVal < 0)
+ int retVal = cs.LinesDisplayed();
+ if (endAtLastLine) {
+ retVal -= LinesOnScreen();
+ } else {
+ retVal--;
+ }
+ if (retVal < 0) {
return 0;
- else
+ } else {
return retVal;
+ }
}
static inline bool IsControlCharacter(char ch) {
@@ -2184,9 +2191,9 @@ void Editor::ReconfigureScrollBars() {}
void Editor::SetScrollBars() {
RefreshStyleData();
- int nMax = cs.LinesDisplayed();
- int nPage = nMax - MaxScrollPos() + 1;
- bool modified = ModifyScrollBars(nMax, nPage);
+ int nMax = MaxScrollPos();
+ int nPage = LinesOnScreen();
+ bool modified = ModifyScrollBars(nMax + nPage - 1, nPage);
// TODO: ensure always showing as many lines as possible
// May not be, if, for example, window made larger
@@ -4717,6 +4724,17 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
PLATFORM_ASSERT(lParam);
return TextWidth(wParam, reinterpret_cast<char *>(lParam));
+ case SCI_SETENDATLASTLINE:
+ PLATFORM_ASSERT((wParam == 0) || (wParam ==1));
+ if (endAtLastLine != (wParam != 0)) {
+ endAtLastLine = wParam != 0;
+ SetScrollBars();
+ }
+ break;
+
+ case SCI_GETENDATLASTLINE:
+ return endAtLastLine;
+
case SCI_GETCOLUMN:
return pdoc->GetColumn(wParam);
diff --git a/src/Editor.h b/src/Editor.h
index 353e4ee9f..a86008456 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -201,6 +201,7 @@ 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 endAtLastLine;
Surface *pixmapLine;
Surface *pixmapSelMargin;