Skip to content

Commit

Permalink
feat(Vim Motion): add motion 0 (move cursor to first char of a line)
Browse files Browse the repository at this point in the history
  • Loading branch information
IMOitself committed Sep 25, 2024
1 parent a5e2da1 commit e97e119
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/src/main/java/imo/text/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ void moveCursorX(int amount){
invalidate();
}

void moveCursorToFirstChar(){
currCharPosition = 0;
invalidate();
}




Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/imo/text/Keyboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public static void configKeyboard(Activity activity){

TextView keyH = mActivity.findViewById(R.id.key_H);
TextView keyL = mActivity.findViewById(R.id.key_L);
TextView key0 = mActivity.findViewById(R.id.key_0);

keyH.setOnClickListener(new View.OnClickListener() {
@Override
Expand All @@ -123,6 +124,12 @@ public void onClick(View view) {
mEditor.moveCursorX(1);
}
});
key0.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mEditor.moveCursorToFirstChar();
}
});
}

private static void configKey(int viewId, int width, int height, int colorId){
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<resources>
<string name="app_name">text</string>
<!-- slowly gonna introduce characters for vim macros -->
<string name="_0"> </string>
<string name="_0">0</string>
<string name="_1"> </string>
<string name="_2"> </string>
<string name="_3"> </string>
Expand Down

0 comments on commit e97e119

Please sign in to comment.