aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Editor.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r--src/Editor.cxx17
1 files changed, 16 insertions, 1 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;