diff options
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Zle/zle_bindings.c | 4 | ||||
-rw-r--r-- | Src/Zle/zle_keymap.c | 22 | ||||
-rw-r--r-- | Src/Zle/zle_refresh.c | 5 | ||||
-rw-r--r-- | Src/Zle/zle_vi.c | 8 |
4 files changed, 26 insertions, 13 deletions
diff --git a/Src/Zle/zle_bindings.c b/Src/Zle/zle_bindings.c index 682691347..50a29551d 100644 --- a/Src/Zle/zle_bindings.c +++ b/Src/Zle/zle_bindings.c @@ -376,7 +376,7 @@ int vicmdbind[128] = { /* S */ z_vichangewholeline, /* T */ z_vifindprevcharskip, /* U */ z_undefinedkey, - /* V */ z_undefinedkey, + /* V */ z_visuallinemode, /* W */ z_viforwardblankword, /* X */ z_vibackwarddeletechar, /* Y */ z_viyankwholeline, @@ -408,7 +408,7 @@ int vicmdbind[128] = { /* s */ z_visubstitute, /* t */ z_vifindnextcharskip, /* u */ z_viundochange, - /* v */ z_undefinedkey, + /* v */ z_visualmode, /* w */ z_viforwardword, /* x */ z_videletechar, /* y */ z_viyank, diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index 6a7107609..216e302d0 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -1277,8 +1277,10 @@ default_bindings(void) Keymap vmap = newkeymap(NULL, "viins"); Keymap emap = newkeymap(NULL, "emacs"); Keymap amap = newkeymap(NULL, "vicmd"); + Keymap oppmap = newkeymap(NULL, "viopp"); + Keymap vismap = newkeymap(NULL, "visual"); Keymap smap = newkeymap(NULL, ".safe"); - Keymap vimaps[2], kptr; + Keymap vimaps[2], vilmaps[2], kptr; char buf[3], *ed; int i; @@ -1332,6 +1334,22 @@ default_bindings(void) add_cursor_key(kptr, TCLEFTCURSOR, t_vibackwardchar, 'D'); add_cursor_key(kptr, TCRIGHTCURSOR, t_viforwardchar, 'C'); } + vilmaps[0] = oppmap; + vilmaps[1] = vismap; + for (i = 0; i < 2; i++) { + /* vi visual selection and operator pending local maps */ + kptr = vilmaps[i]; + add_cursor_key(kptr, TCUPCURSOR, t_upline, 'A'); + add_cursor_key(kptr, TCDOWNCURSOR, t_downline, 'B'); + bindkey(kptr, "k", refthingy(t_upline), NULL); + bindkey(kptr, "j", refthingy(t_downline), NULL); + } + /* escape in operator pending cancels the operation */ + bindkey(oppmap, "\33", refthingy(t_vicmdmode), NULL); + bindkey(vismap, "o", refthingy(t_exchangepointandmark), NULL); + bindkey(vismap, "p", refthingy(t_putreplaceselection), NULL); + bindkey(vismap, "x", refthingy(t_videlete), NULL); + bindkey(vismap, "~", refthingy(t_vioperswapcase), NULL); /* emacs mode: arrow keys */ add_cursor_key(emap, TCUPCURSOR, t_uplineorhistory, 'A'); @@ -1373,6 +1391,8 @@ default_bindings(void) linkkeymap(vmap, "viins", 0); linkkeymap(emap, "emacs", 0); linkkeymap(amap, "vicmd", 0); + linkkeymap(oppmap, "viopp", 0); + linkkeymap(vismap, "visual", 0); linkkeymap(smap, ".safe", 1); if (((ed = zgetenv("VISUAL")) && strstr(ed, "vi")) || ((ed = zgetenv("EDITOR")) && strstr(ed, "vi"))) diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index f0351ad15..467629d25 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -1037,8 +1037,6 @@ zrefresh(void) region_highlights[0].start = mark; region_highlights[0].end = zlecs; } - if (invicmdmode()) - INCPOS(region_highlights[0].end); if (region_active == 2) { int origcs = zlecs; zlecs = region_highlights[0].end; @@ -1046,7 +1044,8 @@ zrefresh(void) zlecs = region_highlights[0].start; region_highlights[0].start = findbol(); zlecs = origcs; - } + } else if (invicmdmode()) + INCPOS(region_highlights[0].end); } else { region_highlights[0].start = region_highlights[0].end = -1; } diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c index 3a4304ced..84cba7759 100644 --- a/Src/Zle/zle_vi.c +++ b/Src/Zle/zle_vi.c @@ -258,7 +258,7 @@ getvirange(int wf) pos = tmp; } - if (visual && invicmdmode()) + if (visual == 1 && invicmdmode()) INCPOS(pos); /* Was it a line-oriented move? If so, the command will have set * @@ -389,9 +389,6 @@ videletechar(char **args) startvichange(-1); - if (region_active) - return killregion(args); - /* handle negative argument */ if (n < 0) { int ret; @@ -804,9 +801,6 @@ vibackwarddeletechar(char **args) if (invicmdmode()) startvichange(-1); - if (region_active) - return killregion(args); - /* handle negative argument */ if (n < 0) { int ret; |