Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.
0 votes
in vifm by

Is it possible to choose the key deletion dialogs use for confirmation or rejection? I find Enter for "yes" and Escape for "no" more intuitive, but could not find it in the documentation.

Actually, it would be nice if the keys for each dialog could be set, but I know I'm probably asking too much here.

Thank you!

1 Answer

0 votes
by

Those keys aren't processed by messages at all. See this GitHub issue.

There is :dmap (for all dialogs at once), but error/confirmation messages aren't dialogs.

by

You mean the y/n response to deletion is hardcoded, correct? In that case, am I correct that it comes from modes/msg_dialog.c file? I'll try to modify it. Thank you!

by

That's the right file (although you miss /dialogs/ component). It's not completely hard-coded, those keys are actually mapped, they just aren't configurable and don't behave as "yes" and "no", only as "ok" and "cancel" (see builtin_cmds closer to the top).

by

Many thanks again! This is surely a trivial modification to you (and it was easy with your fine pointers), Xaizek, but I'll add it here in case someone wants to do the same.

(Vifm 0.11) Edit lines 91 and 92 in src/modes/dialogs/msg_dialog.c inside builtin_cmds function to

{WK_C_m, {{&cmd_ctrl_m}, .descr = "agree to the query"}}, {WK_ESC, {{&cmd_ctrl_c}, .descr = "cancel"}},

Then recompile.

by

If you changed those to cmd_y and cmd_n, you've left yourself without a way to close an error dialog. This should do better:

src/modes/dialogs/msg_dialog.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/modes/dialogs/msg_dialog.c b/src/modes/dialogs/msg_dialog.c
index b78c6b698..00b299dc0 100644
--- a/src/modes/dialogs/msg_dialog.c
+++ b/src/modes/dialogs/msg_dialog.c
@@ -336,7 +336,7 @@ prompt_msg_internal(const char title[], const char message[],

   redraw_error_msg(title, message, 0, 0);

-	enter(variants == NULL ? MASK(R_YES, R_NO) : 0);
+	enter(variants == NULL ? MASK(R_YES, R_NO, R_OK, R_CANCEL) : 0);

   modes_redraw();
}
@@ -691,7 +691,7 @@ confirm_deletion(char *files[], int nfiles, int use_trash)
   prompt_msg_internal(title, msg, NULL, 1);
   free(msg);

-	if(result != R_YES)
+	if(result != R_YES && result != R_OK)
   {
       return 0;
   }
...