From 30e9673fdb22905df853ef07b3826fa19b28831c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 28 Nov 2015 18:37:29 +0100 Subject: vis: improve switching to prompt mode A call to vis_prompt_show will now automatically switch to prompt mode. Within the prompt leave/enter handlers the focused window (vis->win) will still point to the document window not the one referring to the prompt. The selection marks '< and '> are now only updated when a visual mode is left. --- vis.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'vis.c') diff --git a/vis.c b/vis.c index 1ab6e4e..c37dc28 100644 --- a/vis.c +++ b/vis.c @@ -462,9 +462,10 @@ void vis_prompt_show(Vis *vis, const char *title, const char *text) { if (vis->prompt_window) return; vis->prompt_window = vis->win; - vis->win = vis->prompt; vis->prompt_type = title[0]; vis->ui->prompt(vis->ui, title, text); + vis_mode_switch(vis, VIS_MODE_PROMPT); + vis->win = vis->prompt; } void vis_prompt_hide(Vis *vis) { @@ -544,7 +545,7 @@ static void action_do(Vis *vis, Action *a) { View *view = win->view; if (a->op == &ops[VIS_OP_FILTER] && !vis->mode->visual) - vis_mode_switch(vis, VIS_MODE_VISUAL); + vis_mode_switch(vis, VIS_MODE_VISUAL_LINE); if (a->count < 1) a->count = 1; @@ -671,11 +672,10 @@ static void action_do(Vis *vis, Action *a) { vis_mode_switch(vis, VIS_MODE_REPLACE); } else if (a->op == &ops[VIS_OP_FILTER]) { if (a->arg.s) { - if (vis_cmd(vis, a->arg.s)) - vis_mode_switch(vis, VIS_MODE_NORMAL); + vis_mode_switch(vis, VIS_MODE_NORMAL); + vis_cmd(vis, a->arg.s); } else { vis_prompt_show(vis, ":", "'<,'>!"); - vis_mode_switch(vis, VIS_MODE_PROMPT); } } else if (vis->mode == &vis_modes[VIS_MODE_OPERATOR]) { mode_set(vis, vis->mode_prev); -- cgit v1.2.3