Introduction
Introduction Statistics Contact Development Disclaimer Help
tex: do not reorder/highlight lines longer than lim - neatvi - [fork] simple vi…
git clone git://src.adamsgaard.dk/neatvi
Log
Files
Refs
README
---
commit 73484384d37bca6602d718a7aa946a01af44a56a
parent caead42d731b8e10d6401d6028f63be6962fb0b2
Author: Ali Gholami Rudi <[email protected]>
Date: Thu, 17 Feb 2022 12:20:49 +0330
ex: do not reorder/highlight lines longer than lim
Diffstat:
M ex.c | 2 ++
M ren.c | 22 ++++++++++++++++++++--
M vi.h | 1 +
3 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/ex.c b/ex.c
t@@ -22,6 +22,7 @@ int xshape = 1; /* perform letter sha…
int xorder = 1; /* change the order of characters */
int xkmap = 0; /* the current keymap */
int xkmap_alt = 1; /* the alternate keymap */
+int xlim = 256; /* do not process lines longer than thi…
static char xkwd[EXLEN]; /* the last searched keyword */
static char xrep[EXLEN]; /* the last replacement */
static int xkwddir; /* the last search direction */
t@@ -769,6 +770,7 @@ static struct option {
{"order", "xorder", &xorder},
{"hl", "highlight", &xhl},
{"hll", "highlightline", &xhll},
+ {"lim", "linelimit", &xlim},
};
static char *cutword(char *s, char *d)
diff --git a/ren.c b/ren.c
t@@ -5,8 +5,8 @@
#include <string.h>
#include "vi.h"
-/* specify the screen position of the characters in s */
-int *ren_position(char *s)
+/* specify the screen position of the characters in s; reordering version */
+int *ren_position_reorder(char *s)
{
int i, n;
char **chrs = uc_chop(s, &n);
t@@ -30,6 +30,24 @@ int *ren_position(char *s)
return pos;
}
+/* specify the screen position of the characters in s; fast version */
+int *ren_position(char *s)
+{
+ int cpos = 0;
+ int *pos;
+ int i;
+ int n = uc_slen(s);
+ if (n <= xlim && xorder)
+ return ren_position_reorder(s);
+ pos = malloc((n + 1) * sizeof(pos[0]));
+ for (i = 0; i < n; i++, s += uc_len(s)) {
+ pos[i] = cpos;
+ cpos += ren_cwid(s, cpos);
+ }
+ pos[i] = cpos;
+ return pos;
+}
+
int ren_wid(char *s)
{
int *pos = ren_position(s);
diff --git a/vi.h b/vi.h
t@@ -213,3 +213,4 @@ extern int xhl;
extern int xhll;
extern int xkmap;
extern int xkmap_alt;
+extern int xlim;
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.