diff options
author | nyamatongwe <unknown> | 2000-11-01 04:59:16 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2000-11-01 04:59:16 +0000 |
commit | 87e57a5bdad06acf4ef0cfd7550dfac629c51833 (patch) | |
tree | 199ec5ab363f926492c05e6e04c0f89885f3d25b /src | |
parent | 5aea253e5bc2a11a74f4872e24d7bb9b08649414 (diff) | |
download | scintilla-mirror-87e57a5bdad06acf4ef0cfd7550dfac629c51833.tar.gz |
Change from Stephan to scroll to horizontal 0 position when possible.
Diffstat (limited to 'src')
-rw-r--r-- | src/Editor.cxx | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index d6eea354f..466f5efc0 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -551,6 +551,8 @@ void Editor::MoveCaretInsideView() { void Editor::EnsureCaretVisible(bool useMargin) { //Platform::DebugPrintf("EnsureCaretVisible %d\n", xOffset); PRectangle rcClient = GetTextRectangle(); + int rcClientFullWidth = rcClient.Width(); + bool forceHZero = false; int posCaret = currentPos; if (posDrag >= 0) posCaret = posDrag; @@ -569,7 +571,14 @@ void Editor::EnsureCaretVisible(bool useMargin) { rcClient.left = rcClient.left + xMargin; rcClient.right = rcClient.right - xMargin; - if (!rcClient.Contains(pt) || !rcClient.Contains(ptBottomCaret) || (caretPolicy & CARET_STRICT)) { + // If scrolled horizontally, check whether scrolling back to col 0 would + // still leave the caret on screen; do this if so since it's nicer + // to be able to see the start of lines + if (xOffset > 0 && pt.x >= 0 && pt.x <= rcClientFullWidth - xMargin) { + forceHZero = true; + } + + if (!rcClient.Contains(pt) || !rcClient.Contains(ptBottomCaret) || (caretPolicy & CARET_STRICT) || (forceHZero)) { //Platform::DebugPrintf("EnsureCaretVisible move, (%d,%d) (%d,%d)\n", pt.x, pt.y, rcClient.left, rcClient.right); // It should be possible to scroll the window to show the caret, // but this fails to remove the caret on GTK+ @@ -592,7 +601,9 @@ void Editor::EnsureCaretVisible(bool useMargin) { } } int xOffsetNew = xOffset; - if (pt.x < rcClient.left) { + if (forceHZero) { + xOffsetNew = 0; + } else if (pt.x < rcClient.left) { xOffsetNew = xOffset - (rcClient.left - pt.x); } else if (pt.x >= rcClient.right) { xOffsetNew = xOffset + (pt.x - rcClient.right); |