| tvi: for ex messages use "---" filetype - neatvi - [fork] simple vi-type editor… | |
| git clone git://src.adamsgaard.dk/neatvi | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit d9562b264f00d015c0bcd75bd8fa3e4cece9eddb | |
| parent 89738c4b7ea3a3d705c408090a85c14610158251 | |
| Author: Ali Gholami Rudi <[email protected]> | |
| Date: Fri, 10 Mar 2017 14:10:40 +0330 | |
| vi: for ex messages use "---" filetype | |
| Diffstat: | |
| M led.c | 22 +++++++++++++++++++--- | |
| M vi.c | 2 +- | |
| M vi.h | 1 + | |
| 3 files changed, 21 insertions(+), 4 deletions(-) | |
| --- | |
| diff --git a/led.c b/led.c | |
| t@@ -1,3 +1,4 @@ | |
| +/* line editing and drawing */ | |
| #include <ctype.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| t@@ -33,6 +34,7 @@ static int led_offdir(char **chrs, int *pos, int i) | |
| return 0; | |
| } | |
| +/* highlight text in reverse direction */ | |
| static void led_markrev(int n, char **chrs, int *pos, int *att) | |
| { | |
| int i = 0, j; | |
| t@@ -51,7 +53,8 @@ static void led_markrev(int n, char **chrs, int *pos, int *a… | |
| } | |
| } | |
| -static char *led_render(char *s0, int cbeg, int cend) | |
| +/* render and highlight a line */ | |
| +static char *led_render(char *s0, int cbeg, int cend, char *syn) | |
| { | |
| int n; | |
| int *pos; /* pos[i]: the screen position of the i-th character … | |
| t@@ -75,7 +78,7 @@ static char *led_render(char *s0, int cbeg, int cend) | |
| for (j = 0; j < curwid; j++) | |
| off[led_posctx(ctx, pos[i] + j, cbeg, cend)] =… | |
| } | |
| - att = syn_highlight(ex_filetype(), s0); | |
| + att = syn_highlight(syn, s0); | |
| led_markrev(n, chrs, pos, att); | |
| out = sbuf_make(); | |
| i = cbeg; | |
| t@@ -107,9 +110,20 @@ static char *led_render(char *s0, int cbeg, int cend) | |
| return sbuf_done(out); | |
| } | |
| +/* print a line on the screen */ | |
| void led_print(char *s, int row) | |
| { | |
| - char *r = led_render(s, xleft, xleft + xcols); | |
| + char *r = led_render(s, xleft, xleft + xcols, ex_filetype()); | |
| + term_pos(row, 0); | |
| + term_kill(); | |
| + term_str(r); | |
| + free(r); | |
| +} | |
| + | |
| +/* print a line on the screen; for ex messages */ | |
| +void led_printmsg(char *s, int row) | |
| +{ | |
| + char *r = led_render(s, xleft, xleft + xcols, "---"); | |
| term_pos(row, 0); | |
| term_kill(); | |
| term_str(r); | |
| t@@ -199,6 +213,7 @@ static char *led_readchar(int c, char *kmap) | |
| return kmap_map(kmap, c); | |
| } | |
| +/* read a character from the terminal */ | |
| char *led_read(char **kmap) | |
| { | |
| int c = term_read(); | |
| t@@ -218,6 +233,7 @@ char *led_read(char **kmap) | |
| return NULL; | |
| } | |
| +/* read a line from the terminal */ | |
| static char *led_line(char *pref, char *post, char *ai, int ai_max, int *key, … | |
| { | |
| struct sbuf *sb; | |
| diff --git a/vi.c b/vi.c | |
| t@@ -45,7 +45,7 @@ static void vi_drawmsg(void) | |
| { | |
| int oleft = xleft; | |
| xleft = 0; | |
| - led_print(vi_msg, xrows); | |
| + led_printmsg(vi_msg, xrows); | |
| vi_msg[0] = '\0'; | |
| xleft = oleft; | |
| } | |
| diff --git a/vi.h b/vi.h | |
| t@@ -133,6 +133,7 @@ char *led_prompt(char *pref, char *post, char **kmap); | |
| char *led_input(char *pref, char *post, char **kmap); | |
| char *led_read(char **kmap); | |
| void led_print(char *msg, int row); | |
| +void led_printmsg(char *s, int row); | |
| int led_pos(char *s, int pos); | |
| /* ex commands */ |