From 36878852efc1673aba445e7affe9c5c554c343d5 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Mon, 17 Nov 2014 22:50:34 +0100 Subject: 33636: add support for a linewise visual selection mode --- Src/Zle/zle_vi.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'Src/Zle/zle_vi.c') diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c index 02877deee..3a4304ced 100644 --- a/Src/Zle/zle_vi.c +++ b/Src/Zle/zle_vi.c @@ -162,12 +162,14 @@ static int getvirange(int wf) { int pos = zlecs, mpos = mark, ret = 0; - int visual = region_active; /* don't trust movement cmd not to change it */ + int visual = region_active; /* movement command might set it */ int mult1 = zmult, hist1 = histline; Thingy k2; if (visual) { pos = mark; + vilinerange = (visual == 2); + region_active = 0; } else { virangeflag = 1; @@ -256,10 +258,8 @@ getvirange(int wf) pos = tmp; } - if (visual && invicmdmode()) { - region_active = 0; + if (visual && invicmdmode()) INCPOS(pos); - } /* Was it a line-oriented move? If so, the command will have set * * the vilinerange flag. In this case, entire lines are taken, * @@ -463,7 +463,15 @@ visubstitute(UNUSED(char **args)) int vichangeeol(UNUSED(char **args)) { - forekill(findeol() - zlecs, CUT_RAW); + int a, b; + if (region_active) { + regionlines(&a, &b); + zlecs = a; + region_active = 0; + cut(zlecs, b - zlecs, CUT_RAW); + shiftchars(zlecs, b - zlecs); + } else + forekill(findeol() - zlecs, CUT_RAW); startvitext(1); return 0; } @@ -721,8 +729,11 @@ viindent(UNUSED(char **args)) { int oldcs = zlecs, c2; - /* get the range */ startvichange(1); + /* force line range */ + if (region_active == 1) + region_active = 2; + /* get the range */ if ((c2 = getvirange(0)) == -1) { vichgflag = 0; return 1; @@ -756,8 +767,11 @@ viunindent(UNUSED(char **args)) { int oldcs = zlecs, c2; - /* get the range */ startvichange(1); + /* force line range */ + if (region_active == 1) + region_active = 2; + /* get the range */ if ((c2 = getvirange(0)) == -1) { vichgflag = 0; return 1; -- cgit 1.4.1