Skip to content

Commit

Permalink
libshell|AbstractLineEditor: Move between lines based on advance width
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed May 21, 2013
1 parent 53104cb commit 901b278
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doomsday/libshell/src/abstractlineeditor.cpp
Expand Up @@ -126,14 +126,15 @@ DENG2_PIMPL(AbstractLineEditor)
DENG2_ASSERT(lineOff == 1 || lineOff == -1);

de::Vector2i const linePos = lineCursorPos();
int const destWidth = wraps->rangeWidth(Range(lineSpan(linePos.y).range.start, cursor));

// Check for no room.
if(!linePos.y && lineOff < 0) return false;
if(linePos.y == wraps->height() - 1 && lineOff > 0) return false;

// Move cursor onto the adjacent line.
WrappedLine span = lineSpan(linePos.y + lineOff);
cursor = span.range.start + linePos.x;
cursor = wraps->indexAtWidth(span.range, destWidth);
if(!span.isFinal) span.range.end--;
if(cursor > span.range.end) cursor = span.range.end;

Expand Down

0 comments on commit 901b278

Please sign in to comment.