From bc818d9222ab69a4bbb876d5843dcc4874accd48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 18 Jan 2017 14:56:57 +0100 Subject: vis: support count for insertion and replacement Fix #372 --- main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index f1e32fa..e6dc036 100644 --- a/main.c +++ b/main.c @@ -33,6 +33,8 @@ static const char *suspend(Vis*, const char *keys, const Arg *arg); static const char *switchmode(Vis*, const char *keys, const Arg *arg); /* switch to insert mode after performing movement indicated by arg->i */ static const char *insertmode(Vis*, const char *keys, const Arg *arg); +/* switch to replace mode after performing movement indicated by arg->i */ +static const char *replacemode(Vis*, const char *keys, const Arg *arg); /* set mark indicated by keys to current cursor position */ static const char *mark_set(Vis*, const char *keys, const Arg *arg); /* add a new line either before or after the one where the cursor currently is */ @@ -617,12 +619,12 @@ static const KeyAction vis_action[] = { [VIS_ACTION_MODE_INSERT] = { "vis-mode-insert", "Enter insert mode", - switchmode, { .i = VIS_MODE_INSERT } + insertmode, { .i = VIS_MOVE_NOP } }, [VIS_ACTION_MODE_REPLACE] = { "vis-mode-replace", "Enter replace mode", - switchmode, { .i = VIS_MODE_REPLACE } + replacemode, { .i = VIS_MOVE_NOP } }, [VIS_ACTION_MODE_OPERATOR_PENDING] = { "vis-mode-operator-pending", @@ -2006,6 +2008,12 @@ static const char *insertmode(Vis *vis, const char *keys, const Arg *arg) { return keys; } +static const char *replacemode(Vis *vis, const char *keys, const Arg *arg) { + vis_operator(vis, VIS_OP_MODESWITCH, VIS_MODE_REPLACE); + vis_motion(vis, arg->i); + return keys; +} + static const char *unicode_info(Vis *vis, const char *keys, const Arg *arg) { View *view = vis_view(vis); Text *txt = vis_text(vis); -- cgit v1.2.3