diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Editor.cxx | 21 | ||||
| -rw-r--r-- | src/Editor.h | 1 | 
2 files changed, 21 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: diff --git a/src/Editor.h b/src/Editor.h index 9bd308ce1..036d7e23d 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -270,6 +270,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	virtual void ScrollText(int linesToMove);  	void HorizontalScrollTo(int xPos);  	void MoveCaretInsideView(); +	int DisplayFromPosition(int pos);  	void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true);  	void ShowCaretAtCurrentPosition();  	void DropCaret(); | 
