From cae14933a6b32bc7260964439f9def316c7520ba Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 16 Mar 2020 17:30:16 -0700 Subject: vi: implement H/M/L. Turns out I move around using these a lot too. I do tend to have very tall terminals... --- toys/pending/vi.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'toys/pending/vi.c') 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}, -- cgit v1.2.3