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/Editor.cxx | |
| parent | fbc89848986b94a84e1011b11d16d83f5a09c881 (diff) | |
| download | scintilla-mirror-1d801fba7580276f1a91af5019d5d2ac59372a37.tar.gz | |
Feature request #3064696 SCI_VERTICALCENTRECARET: center current line in window.
Diffstat (limited to 'src/Editor.cxx')
| -rw-r--r-- | src/Editor.cxx | 17 | 
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;  | 
