aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
Diffstat (limited to 'toys')
-rw-r--r--toys/pending/vi.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/toys/pending/vi.c b/toys/pending/vi.c
index 62cbbab0..7b4ca90b 100644
--- a/toys/pending/vi.c
+++ b/toys/pending/vi.c
@@ -1414,7 +1414,10 @@ static void draw_page()
tty_jump(0, TT.screen_height);
tty_esc("2K");
if (TT.vi_mode == 2) printf("\x1b[1m-- INSERT --\x1b[m");
- if (!TT.vi_mode) printf("\x1b[1m%s \x1b[m",TT.il->data);
+ if (!TT.vi_mode) {
+ cx_scr = printf("%s",TT.il->data);
+ cy_scr = TT.screen_height;
+ }
sprintf(toybuf, "%zu / %zu,%d,%d", TT.cursor, TT.filesize,
TT.cur_row+1, TT.cur_col+1);
@@ -1424,10 +1427,8 @@ static void draw_page()
tty_jump(TT.screen_width-strlen(toybuf), TT.screen_height);
printf("%s", toybuf);
- if (TT.vi_mode) tty_jump(cx_scr, cy_scr);
-
+ tty_jump(cx_scr, cy_scr);
xflush(1);
-
}
void vi_main(void)
@@ -1435,7 +1436,7 @@ void vi_main(void)
char keybuf[16] = {0};
char vi_buf[16] = {0};
char utf8_code[8] = {0};
- int utf8_dec_p = 0, vi_buf_pos = 0;
+ int utf8_dec_p = 0, vi_buf_pos = 0, i;
FILE *script = 0;
if (FLAG(s)) script = fopen(TT.s, "r");
@@ -1510,6 +1511,25 @@ void vi_main(void)
case 'i':
TT.vi_mode = 2;
break;
+ case 'B'-'@':
+ for (i=0; i<TT.screen_height-2; ++i) TT.screen = text_psol(TT.screen);
+ // TODO: if we're on the bottom visible line, move the cursor up.
+ if (TT.screen > TT.cursor) TT.cursor = TT.screen;
+ break;
+ case 'E'-'@':
+ TT.screen = text_nsol(TT.screen);
+ // TODO: real vi keeps the x position.
+ if (TT.screen > TT.cursor) TT.cursor = TT.screen;
+ break;
+ case 'F'-'@':
+ for (i=0; i<TT.screen_height-2; ++i) TT.screen = text_nsol(TT.screen);
+ // TODO: real vi keeps the x position.
+ if (TT.screen > TT.cursor) TT.cursor = TT.screen;
+ break;
+ case 'U'-'@':
+ TT.screen = text_psol(TT.screen);
+ // TODO: if we're on the bottom visible line, move the cursor up.
+ break;
case 27:
vi_buf[0] = 0;
vi_buf_pos = 0;