summaryrefslogtreecommitdiff
path: root/Src/Zle/zle_vi.c
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2014-11-17 22:50:34 +0100
committerOliver Kiddle <opk@zsh.org>2014-11-17 22:50:34 +0100
commit36878852efc1673aba445e7affe9c5c554c343d5 (patch)
tree729c1b26eaa97aa717729956ad40eef4fc976474 /Src/Zle/zle_vi.c
parent492b6cec28d70eb4ef34054f414dd1e80102e857 (diff)
downloadzsh-36878852efc1673aba445e7affe9c5c554c343d5.tar.gz
zsh-36878852efc1673aba445e7affe9c5c554c343d5.zip
33636: add support for a linewise visual selection mode
Diffstat (limited to 'Src/Zle/zle_vi.c')
-rw-r--r--Src/Zle/zle_vi.c28
1 files changed, 21 insertions, 7 deletions
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;