Introduction
Introduction Statistics Contact Development Disclaimer Help
tren: use ren_placeholder() to find character width - neatvi - [fork] simple vi…
git clone git://src.adamsgaard.dk/neatvi
Log
Files
Refs
README
---
commit 0d6850fad63e1064e503cda0b3f072e771eeaced
parent 6b277fa8365863fddf94654a739152959a10e3ee
Author: Ali Gholami Rudi <[email protected]>
Date: Mon, 8 Feb 2021 00:05:38 +0330
ren: use ren_placeholder() to find character width
Diffstat:
M ren.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/ren.c b/ren.c
t@@ -125,13 +125,14 @@ int ren_next(char *s, int p, int dir)
return s && uc_chr(s, ren_off(s, p))[0] != '\n' ? p : -1;
}
-static char *ren_placeholder(char *s)
+static char *ren_placeholder(char *s, int *wid)
{
char *src, *dst;
- int wid, i;
- int c = uc_code(s);
- for (i = 0; !conf_placeholder(i, &src, &dst, &wid); i++)
- if (uc_code(src) == c)
+ int i;
+ if (wid)
+ *wid = 1;
+ for (i = 0; !conf_placeholder(i, &src, &dst, wid); i++)
+ if (src[0] == s[0] && uc_code(src) == uc_code(s))
return dst;
if (uc_iscomb(s)) {
static char buf[16];
t@@ -147,18 +148,16 @@ static char *ren_placeholder(char *s)
int ren_cwid(char *s, int pos)
{
- char *src, *dst;
- int wid, i;
+ int wid;
if (s[0] == '\t')
return 8 - (pos & 7);
- for (i = 0; !conf_placeholder(i, &src, &dst, &wid); i++)
- if (uc_code(src) == uc_code(s))
- return wid;
+ if (ren_placeholder(s, &wid))
+ return wid;
return uc_wid(s);
}
char *ren_translate(char *s, char *ln)
{
- char *p = ren_placeholder(s);
+ char *p = ren_placeholder(s, NULL);
return p || !xshape ? p : uc_shape(ln, s);
}
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.