Introduction
Introduction Statistics Contact Development Disclaimer Help
tvi: > and < commands - neatvi - [fork] simple vi-type editor with UTF-8 support
git clone git://src.adamsgaard.dk/neatvi
Log
Files
Refs
README
---
commit 4f52394ea85044002b49f0286219a30524cea4ab
parent 09cb6ffbd817e3ad3b6755e3a59e7841ac2f009c
Author: Ali Gholami Rudi <[email protected]>
Date: Sat, 16 May 2015 09:25:50 +0430
vi: > and < commands
Diffstat:
M vi.c | 32 +++++++++++++++++++++++++++++…
1 file changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/vi.c b/vi.c
t@@ -717,7 +717,7 @@ static void vi_change(int r1, int c1, int r2, int c2, int …
free(post);
}
-static void vi_pipe(int r1, int c1, int r2, int c2, int lnmode, int closed)
+static void vi_pipe(int r1, int r2)
{
char *text;
char *rep;
t@@ -737,6 +737,30 @@ static void vi_pipe(int r1, int c1, int r2, int c2, int l…
free(rep);
}
+static void vi_shift(int r1, int r2, int dir)
+{
+ struct sbuf *sb;
+ char *ln;
+ int i;
+ if (r2 < r1)
+ swap(&r1, &r2);
+ for (i = r1; i <= r2; i++) {
+ if (!(ln = lbuf_get(xb, i)))
+ continue;
+ sb = sbuf_make();
+ if (dir > 0)
+ sbuf_chr(sb, '\t');
+ else
+ ln = ln[0] == ' ' || ln[0] == '\t' ? ln + 1 : ln;
+ sbuf_str(sb, ln);
+ lbuf_rm(xb, i, i + 1);
+ lbuf_put(xb, i, sbuf_buf(sb));
+ sbuf_free(sb);
+ }
+ xrow = r1;
+ lbuf_postindents(xb, &xrow, &xcol);
+}
+
static int vc_motion(int cmd)
{
int r1 = xrow, r2 = xrow; /* region rows */
t@@ -769,7 +793,9 @@ static int vc_motion(int cmd)
if (cmd == 'c')
vi_change(r1, c1, r2, c2, lnmode, closed);
if (cmd == '!')
- vi_pipe(r1, c1, r2, c2, lnmode, closed);
+ vi_pipe(r1, r2);
+ if (cmd == '>' || cmd == '<')
+ vi_shift(r1, r2, cmd == '>' ? +1 : -1);
return 0;
}
t@@ -1039,6 +1065,8 @@ static void vi(void)
case 'd':
case 'y':
case '!':
+ case '>':
+ case '<':
if (!vc_motion(c))
redraw = 1;
break;
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.