diff options
| author | nyamatongwe <devnull@localhost> | 2002-04-12 07:16:37 +0000 |
|---|---|---|
| committer | nyamatongwe <devnull@localhost> | 2002-04-12 07:16:37 +0000 |
| commit | 8debc5355a55e7fe0b295c49eff924d73b5b1b6f (patch) | |
| tree | c1589b7f4137339b0b304eeb1598d3200edf6fc3 /src/Editor.cxx | |
| parent | 7d81a75c88cf1dbd382611342eff710317bdd7f4 (diff) | |
| download | scintilla-mirror-8debc5355a55e7fe0b295c49eff924d73b5b1b6f.tar.gz | |
Fixed problem where caret would not move to previous line due to wrapping.
Diffstat (limited to 'src/Editor.cxx')
| -rw-r--r-- | src/Editor.cxx | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 00bdfcf57..db5fe54b5 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2887,29 +2887,41 @@ void Editor::NewLine() { EnsureCaretVisible(); } -int Editor::KeyCommand(unsigned int iMessage) { +void Editor::CursorUpOrDown(int direction, bool extend) { Point pt = LocationFromPosition(currentPos); + int posNew = PositionFromLocation( + Point(lastXChosen, pt.y + direction * vs.lineHeight)); + if (direction < 0) { + // Line wrapping may lead to a location on the same line, so + // seek back if that is the case. + // There is an equivalent case when moving down which skips + // over a line but as that does not trap the user it is fine. + Point ptNew = LocationFromPosition(posNew); + while ((posNew > 0) && (pt.y == ptNew.y)) { + posNew--; + ptNew = LocationFromPosition(posNew); + } + } + MovePositionTo(posNew, extend); +} +int Editor::KeyCommand(unsigned int iMessage) { switch (iMessage) { case SCI_LINEDOWN: - MovePositionTo(PositionFromLocation( - Point(lastXChosen, pt.y + vs.lineHeight))); + CursorUpOrDown(1); break; case SCI_LINEDOWNEXTEND: - MovePositionTo(PositionFromLocation( - Point(lastXChosen, pt.y + vs.lineHeight)), true); + CursorUpOrDown(1, true); break; case SCI_LINESCROLLDOWN: ScrollTo(topLine + 1); MoveCaretInsideView(); break; case SCI_LINEUP: - MovePositionTo(PositionFromLocation( - Point(lastXChosen, pt.y - vs.lineHeight))); + CursorUpOrDown(-1); break; case SCI_LINEUPEXTEND: - MovePositionTo(PositionFromLocation( - Point(lastXChosen, pt.y - vs.lineHeight)), true); + CursorUpOrDown(-1, true); break; case SCI_LINESCROLLUP: ScrollTo(topLine - 1); |
