tled: use the attribute of \n for blanks - neatvi - [fork] simple vi-type edito… | |
git clone git://src.adamsgaard.dk/neatvi | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit a4917ea76e33803c53332bc622d870b36c7371c9 | |
parent e8b863838feddbd51f6aac60c849eee0783d8d10 | |
Author: Ali Gholami Rudi <[email protected]> | |
Date: Sun, 19 Jan 2020 19:58:34 +0330 | |
led: use the attribute of \n for blanks | |
Diffstat: | |
M led.c | 9 ++++++++- | |
1 file changed, 8 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/led.c b/led.c | |
t@@ -65,10 +65,12 @@ static char *led_render(char *s0, int cbeg, int cend, char… | |
struct sbuf *out; | |
int i, j; | |
int ctx = dir_context(s0); | |
+ int att_blank = 0; /* the attribute of blank space */ | |
chrs = uc_chop(s0, &n); | |
pos = ren_position(s0); | |
off = malloc((cend - cbeg) * sizeof(off[0])); | |
memset(off, 0xff, (cend - cbeg) * sizeof(off[0])); | |
+ /* initialise off[] using pos[] */ | |
for (i = 0; i < n; i++) { | |
int curwid = ren_cwid(chrs[i], pos[i]); | |
int curbeg = led_posctx(ctx, pos[i], cbeg, cend); | |
t@@ -79,12 +81,17 @@ static char *led_render(char *s0, int cbeg, int cend, char… | |
off[led_posctx(ctx, pos[i] + j, cbeg, cend)] =… | |
} | |
att = syn_highlight(xhl ? syn : "", s0); | |
+ /* the attribute of \n character is used for blanks */ | |
+ for (i = 0; i < n; i++) | |
+ if (chrs[i][0] == '\n') | |
+ att_blank = att[i]; | |
led_markrev(n, chrs, pos, att); | |
+ /* generate term output */ | |
out = sbuf_make(); | |
i = cbeg; | |
while (i < cend) { | |
int o = off[i - cbeg]; | |
- int att_new = o >= 0 ? att[o] : 0; | |
+ int att_new = o >= 0 ? att[o] : att_blank; | |
sbuf_str(out, term_att(att_new, att_old)); | |
att_old = att_new; | |
if (o >= 0) { |