diff options
| author | nyamatongwe <devnull@localhost> | 2002-01-24 11:40:14 +0000 | 
|---|---|---|
| committer | nyamatongwe <devnull@localhost> | 2002-01-24 11:40:14 +0000 | 
| commit | 9b8808b1566a77f0b6359d111e6b7bcf9b31c02a (patch) | |
| tree | 1f2d73003b4d62dc1710aa9854f6df498f2e3145 /src/Editor.cxx | |
| parent | e4772b7376e6b1527c3ed88ac2dba0bc95b6452a (diff) | |
| download | scintilla-mirror-9b8808b1566a77f0b6359d111e6b7bcf9b31c02a.tar.gz | |
Fixed problem with ensuring the caret is visible hen it is on a wrapped
line.
Diffstat (limited to 'src/Editor.cxx')
| -rw-r--r-- | src/Editor.cxx | 21 | 
1 files changed, 20 insertions, 1 deletions
| diff --git a/src/Editor.cxx b/src/Editor.cxx index 5b33f7b2d..f4f4a1b14 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -647,6 +647,25 @@ void Editor::MoveCaretInsideView() {  	}  } +int Editor::DisplayFromPosition(int pos) { +	int lineDoc = pdoc->LineFromPosition(pos); +	int lineDisplay = cs.DisplayFromDoc(lineDoc); +	AutoSurface surface(IsUnicodeMode()); +	if (surface) { +		unsigned int posLineStart = pdoc->LineStart(lineDoc); +		int posInLine = pos - posLineStart; +		lineDisplay--; // To make up for first increment ahead. +		LineLayout ll; +		LayoutLine(lineDoc, surface, vs, ll, wrapWidth); +		for (int subLine=0; subLine<ll.lines; subLine++) { + 			if (posInLine >= ll.lineStarts[subLine]) { +				lineDisplay++; +			} +		} +	} +	return lineDisplay; +} +  void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) {  	//Platform::DebugPrintf("EnsureCaretVisible %d %s\n", xOffset, useMargin ? " margin" : " ");  	PRectangle rcClient = GetTextRectangle(); @@ -657,7 +676,7 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) {  	Point pt = LocationFromPosition(posCaret);  	Point ptEOL = LocationFromPosition(pdoc->LineEndPosition(posCaret));  	Point ptBottomCaret = pt; -	int lineCaret = cs.DisplayFromDoc(pdoc->LineFromPosition(posCaret)); +	int lineCaret = DisplayFromPosition(posCaret);  	ptBottomCaret.y += vs.lineHeight - 1;  	// Ensure the caret is reasonably visible in context: | 
