aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-03-16 17:30:16 -0700
committerRob Landley <rob@landley.net>2020-03-16 22:48:59 -0500
commitcae14933a6b32bc7260964439f9def316c7520ba (patch)
tree7e8a00e648bb3784e13152ce668bb1f022b0d06d
parentb580cb38649e61fcbf8c7415d0a6c97d4300fd92 (diff)
downloadtoybox-cae14933a6b32bc7260964439f9def316c7520ba.tar.gz
vi: implement H/M/L.
Turns out I move around using these a lot too. I do tend to have very tall terminals...
-rw-r--r--toys/pending/vi.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/toys/pending/vi.c b/toys/pending/vi.c
index 7b4ca90b..18ce8e6a 100644
--- a/toys/pending/vi.c
+++ b/toys/pending/vi.c
@@ -751,11 +751,30 @@ static int cur_down(int count0, int count1, char *unused)
{
int count = count0*count1;
for (;count--;) TT.cursor = text_nsol(TT.cursor);
-
check_cursor_bounds();
return 1;
}
+static int vi_H(int count0, int count1, char *unused)
+{
+ TT.cursor = text_sol(TT.screen);
+ return 1;
+}
+
+static int vi_L(int count0, int count1, char *unused)
+{
+ TT.cursor = text_sol(TT.screen);
+ cur_down(TT.screen_height-1, 1, 0);
+ return 1;
+}
+
+static int vi_M(int count0, int count1, char *unused)
+{
+ TT.cursor = text_sol(TT.screen);
+ cur_down(TT.screen_height/2, 1, 0);
+ return 1;
+}
+
static int search_str(char *s)
{
size_t pos = text_strstr(TT.cursor+1, s);
@@ -1106,10 +1125,13 @@ struct vi_mov_param vi_movs[] =
{"b", 0, &vi_movb},
{"e", 0, &vi_move},
{"G", 0, &vi_go},
+ {"H", 0, &vi_H},
{"h", 0, &cur_left},
{"j", 0, &cur_down},
{"k", 0, &cur_up},
+ {"L", 0, &vi_L},
{"l", 0, &cur_right},
+ {"M", 0, &vi_M},
{"w", 0, &vi_movw},
{"$", 0, &vi_eol},
{"f", 1, &vi_find_c},