diff options
author | nyamatongwe <unknown> | 2002-01-24 11:40:14 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2002-01-24 11:40:14 +0000 |
commit | 8d892af3202770ce8d770baec2092886c5780c43 (patch) | |
tree | 1f2d73003b4d62dc1710aa9854f6df498f2e3145 /src | |
parent | 01dce90a53e864aa280506904441b9e1efb53da3 (diff) | |
download | scintilla-mirror-8d892af3202770ce8d770baec2092886c5780c43.tar.gz |
Fixed problem with ensuring the caret is visible hen it is on a wrapped
line.
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(); |