Krolyxon
Commit 733916a

Branches

Refs →

nsxiv733916a

add a pick quit keybind (#432)

The last time[0] this was discussed, no-one was against it but no-one
was confident in it either and so it was added to nsxiv-extra as a
patch.

But now that enough time has passed, it seems like there's a pretty high
demand for something like this because there's plenty of use-cases that
use nsxiv as a "picker" where it's meant to quickly pick a single file.

And so add this as a convenient default key-bind.

[0]: https://codeberg.org/nsxiv/nsxiv-record/pulls/42
Author
eylles
Date
2023-04-14 19:45 +0000
Committer
NRK · 2023-04-14 19:45 +0000
Parent
4df97db
Commit
733916ad70b5b2d92e7adfecdf53a74dd4617b74

+14 −0

4 files changed

  1. M commands.c +7 −0
  2. M commands.h +2 −0
  3. M config.def.h +1 −0
  4. M etc/nsxiv.1 +4 −0
M commands.c View
@@ -59,6 +59,13 @@ bool cg_quit(arg_t status)
5959 return None; /* silence tcc warning */
6060 }
6161
62+bool cg_pick_quit(arg_t status)
63+{
64+ if (options->to_stdout && markcnt == 0)
65+ printf("%s%c", files[fileidx].name, options->using_null ? '\0' : '\n');
66+ return cg_quit(status);
67+}
68+
6269 bool cg_switch_mode(arg_t _)
6370 {
6471 if (mode == MODE_IMAGE) {
M commands.h View
@@ -12,6 +12,7 @@ bool cg_n_or_last(arg_t);
1212 bool cg_navigate_marked(arg_t);
1313 bool cg_prefix_external(arg_t);
1414 bool cg_quit(arg_t);
15+bool cg_pick_quit(arg_t);
1516 bool cg_reload_image(arg_t);
1617 bool cg_remove_image(arg_t);
1718 bool cg_reverse_marks(arg_t);
@@ -57,6 +58,7 @@ bool ct_select(arg_t);
5758 #define g_navigate_marked { cg_navigate_marked, MODE_ALL }
5859 #define g_prefix_external { cg_prefix_external, MODE_ALL }
5960 #define g_quit { cg_quit, MODE_ALL }
61+#define g_pick_quit { cg_pick_quit, MODE_ALL }
6062 #define g_reload_image { cg_reload_image, MODE_ALL }
6163 #define g_remove_image { cg_remove_image, MODE_ALL }
6264 #define g_reverse_marks { cg_reverse_marks, MODE_ALL }
M config.def.h View
@@ -92,6 +92,7 @@ static const KeySym KEYHANDLER_ABORT = XK_Escape;
9292 static const keymap_t keys[] = {
9393 /* modifiers key function argument */
9494 { 0, XK_q, g_quit, 0 },
95+ { 0, XK_Q, g_pick_quit, 0 },
9596 { 0, XK_Return, g_switch_mode, None },
9697 { 0, XK_f, g_toggle_fullscreen, None },
9798 { 0, XK_b, g_toggle_bar, None },
M etc/nsxiv.1 View
@@ -135,6 +135,10 @@ Prefix the next command with a number (denoted via
135135 .B q
136136 Quit nsxiv.
137137 .TP
138+.B Q
139+Quit nsxiv, but additionally print the current filename when \-o is active and
140+no files have been marked.
141+.TP
138142 .B Return
139143 Switch to thumbnail mode / open selected image in image mode.
140144 .TP