tled: specify the first and last visible columns in led_posctx() - neatvi - [fork] simple vi-type editor with UTF-8 support
HTML git clone git://src.adamsgaard.dk/neatvi
DIR Log
DIR Files
DIR Refs
DIR README
---
DIR commit 86c9ce2ce6d2ca663846199b322fcb341e23d527
DIR parent 2cf2cba137d3316342f56e7e035c74e214b1cbb2
HTML Author: Ali Gholami Rudi <ali@rudi.ir>
Date: Wed, 2 Sep 2015 00:59:20 +0430
led: specify the first and last visible columns in led_posctx()
Diffstat:
M led.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
---
DIR diff --git a/led.c b/led.c
t@@ -25,15 +25,15 @@ static char *kmap_map(char *kmap, int c)
return keymap[c] ? keymap[c] : cs;
}
-static int led_posctx(int dir, int pos)
+static int led_posctx(int dir, int pos, int beg, int end)
{
- return dir >= 0 ? pos - xleft : xcols - (pos - xleft) - 1;
+ return dir >= 0 ? pos - beg : end - pos - 1;
}
/* map cursor horizontal position to terminal column number */
int led_pos(char *s, int pos)
{
- return led_posctx(dir_context(s), pos);
+ return led_posctx(dir_context(s), pos, xleft, xleft + xcols);
}
static int led_offdir(char **chrs, int *pos, int i)
t@@ -80,12 +80,12 @@ static char *led_render(char *s0, int cbeg, int cend)
memset(off, 0xff, (cend - cbeg) * sizeof(off[0]));
for (i = 0; i < n; i++) {
int curwid = ren_cwid(chrs[i], pos[i]);
- int curbeg = led_posctx(ctx, pos[i]);
- int curend = led_posctx(ctx, pos[i] + curwid - 1);
+ int curbeg = led_posctx(ctx, pos[i], cbeg, cend);
+ int curend = led_posctx(ctx, pos[i] + curwid - 1, cbeg, cend);
if (curbeg >= 0 && curbeg < (cend - cbeg) &&
curend >= 0 && curend < (cend - cbeg))
for (j = 0; j < curwid; j++)
- off[led_posctx(ctx, pos[i] + j)] = i;
+ off[led_posctx(ctx, pos[i] + j, cbeg, cend)] = i;
}
att = syn_highlight(ex_filetype(), s0);
led_markrev(n, chrs, pos, att);