diff options
author | nyamatongwe <devnull@localhost> | 2010-10-20 16:03:21 +1100 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2010-10-20 16:03:21 +1100 |
commit | 1d801fba7580276f1a91af5019d5d2ac59372a37 (patch) | |
tree | 45f8662892a932b7cd329fddb97302f66ac2c60a /src | |
parent | fbc89848986b94a84e1011b11d16d83f5a09c881 (diff) | |
download | scintilla-mirror-1d801fba7580276f1a91af5019d5d2ac59372a37.tar.gz |
Feature request #3064696 SCI_VERTICALCENTRECARET: center current line in window.
Diffstat (limited to 'src')
-rw-r--r-- | src/Editor.cxx | 17 | ||||
-rw-r--r-- | src/Editor.h | 3 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 681cb12cd..c03ff8f31 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -995,6 +995,16 @@ void Editor::HorizontalScrollTo(int xPos) { } } +void Editor::VerticalCentreCaret() { + int lineDoc = pdoc->LineFromPosition(sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret()); + int lineDisplay = cs.DisplayFromDoc(lineDoc); + int newTop = lineDisplay - (LinesOnScreen() / 2); + if (topLine != newTop) { + SetTopLine(newTop > 0 ? newTop : 0); + RedrawRect(GetClientRectangle()); + } +} + void Editor::MoveCaretInsideView(bool ensureVisible) { PRectangle rcClient = GetTextRectangle(); Point pt = PointMainCaret(); @@ -4589,6 +4599,7 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lPar case SCI_PAGEDOWNRECTEXTEND: case SCI_SELECTIONDUPLICATE: case SCI_COPYALLOWLINE: + case SCI_VERTICALCENTRECARET: break; // Filter out all others like display changes. Also, newlines are redundant @@ -6319,7 +6330,7 @@ void Editor::StyleToPositionInView(Position pos) { int styleAtEnd = pdoc->StyleAt(pos-1); pdoc->EnsureStyledTo(pos); if ((endWindow > pos) && (styleAtEnd != pdoc->StyleAt(pos-1))) { - // Style at end of line changed so is multi-line change like starting a comment + // Style at end of line changed so is multi-line change like starting a comment // so require rest of window to be styled. pdoc->EnsureStyledTo(endWindow); } @@ -6794,6 +6805,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { CopyAllowLine(); break; + case SCI_VERTICALCENTRECARET: + VerticalCentreCaret(); + break; + case SCI_COPYRANGE: CopyRangeToClipboard(wParam, lParam); break; diff --git a/src/Editor.h b/src/Editor.h index 17683c63a..50948e2e3 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -219,7 +219,7 @@ protected: // ScintillaBase subclass needs access to much of Editor PRectangle rcPaint; bool paintingAllText; StyleNeeded styleNeeded; - + int modEventMask; SelectionText drag; @@ -328,6 +328,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void ScrollTo(int line, bool moveThumb=true); virtual void ScrollText(int linesToMove); void HorizontalScrollTo(int xPos); + void VerticalCentreCaret(); void MoveCaretInsideView(bool ensureVisible=true); int DisplayFromPosition(int pos); |