Skip to content

Commit

Permalink
feat(Vim Motion): multi line navigation support for motion H and L
Browse files Browse the repository at this point in the history
  • Loading branch information
IMOitself committed Oct 4, 2024
1 parent 003354a commit d223baa
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app/src/main/java/imo/text/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,20 @@ public boolean onTouchEvent(MotionEvent event) {
void moveCursorX(int amount){
int newCharPosition = amount + currCharPosition;

if(newCharPosition < 0) return;
if(newCharPosition >= Lines.get(currLinePosition).charRects.size()) return;
if(newCharPosition < 0) {
int prevLinePosition = currLinePosition - 1;
if(prevLinePosition < 0) return;

currLinePosition = prevLinePosition;
newCharPosition = Lines.get(currLinePosition).charRects.size() - 1;
}
if(newCharPosition >= Lines.get(currLinePosition).charRects.size()) {
int nextLinePosition = currLinePosition + 1;
if(nextLinePosition >= Lines.size()) return;

currLinePosition = nextLinePosition;
newCharPosition = 0;
}

currCharPosition = newCharPosition;
invalidate();
Expand Down

0 comments on commit d223baa

Please sign in to comment.