Introduction
Introduction Statistics Contact Development Disclaimer Help
tled: for cursor position assume 'a' is inserted - neatvi - [fork] simple vi-ty…
git clone git://src.adamsgaard.dk/neatvi
Log
Files
Refs
README
---
commit 330453e1a6cd79f6c85ddc7a454f37c784b1ae9a
parent 3472b9c90eea860d3aff4e9c555fbaab6f4f90bf
Author: Ali Gholami Rudi <[email protected]>
Date: Sun, 10 May 2015 18:58:08 +0430
led: for cursor position assume 'a' is inserted
Diffstat:
M led.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/led.c b/led.c
t@@ -48,26 +48,29 @@ static int led_lastword(char *s)
return r - s;
}
+/* the position of the cursor for inserting another character */
+static int led_insertionpos(struct sbuf *sb)
+{
+ int len = sbuf_len(sb);
+ char *chr = keymap(led_kmap, 'a');
+ int col;
+ sbuf_str(sb, chr);
+ col = ren_cursor(sbuf_buf(sb),
+ ren_pos(sbuf_buf(sb), uc_slen(sbuf_buf(sb)) - 1));
+ sbuf_cut(sb, len);
+ return col;
+}
+
static void led_printparts(char *pref, char *main, char *post)
{
struct sbuf *ln;
int col;
- int cur;
- int dir;
ln = sbuf_make();
sbuf_str(ln, pref);
sbuf_str(ln, main);
- cur = uc_slen(sbuf_buf(ln)) - 1;
- dir = uc_dir(sbuf_buf(ln) + led_lastchar(sbuf_buf(ln)));
+ col = led_insertionpos(ln);
sbuf_str(ln, post);
led_print(sbuf_buf(ln), -1);
- col = ren_cursor(sbuf_buf(ln), ren_pos(sbuf_buf(ln), MAX(cur, 0)));
- if (cur >= 0) {
- if (dir < 0 || (!dir && ren_dir(sbuf_buf(ln)) < 0))
- col = MAX(col - 1, 0);
- else
- col += 1;
- }
term_pos(-1, col);
sbuf_free(ln);
}
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.