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
+14 −0
4 files changed
- M commands.c +7 −0
- M commands.h +2 −0
- M config.def.h +1 −0
- M etc/nsxiv.1 +4 −0
| @@ -59,6 +59,13 @@ bool cg_quit(arg_t status) | |||
| 59 | 59 | return None; /* silence tcc warning */ | |
| 60 | 60 | } | |
| 61 | 61 | ||
| 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 | + | ||
| 62 | 69 | bool cg_switch_mode(arg_t _) | |
| 63 | 70 | { | |
| 64 | 71 | if (mode == MODE_IMAGE) { | |
| @@ -12,6 +12,7 @@ bool cg_n_or_last(arg_t); | |||
| 12 | 12 | bool cg_navigate_marked(arg_t); | |
| 13 | 13 | bool cg_prefix_external(arg_t); | |
| 14 | 14 | bool cg_quit(arg_t); | |
| 15 | + | bool cg_pick_quit(arg_t); | |
| 15 | 16 | bool cg_reload_image(arg_t); | |
| 16 | 17 | bool cg_remove_image(arg_t); | |
| 17 | 18 | bool cg_reverse_marks(arg_t); | |
| @@ -57,6 +58,7 @@ bool ct_select(arg_t); | |||
| 57 | 58 | #define g_navigate_marked { cg_navigate_marked, MODE_ALL } | |
| 58 | 59 | #define g_prefix_external { cg_prefix_external, MODE_ALL } | |
| 59 | 60 | #define g_quit { cg_quit, MODE_ALL } | |
| 61 | + | #define g_pick_quit { cg_pick_quit, MODE_ALL } | |
| 60 | 62 | #define g_reload_image { cg_reload_image, MODE_ALL } | |
| 61 | 63 | #define g_remove_image { cg_remove_image, MODE_ALL } | |
| 62 | 64 | #define g_reverse_marks { cg_reverse_marks, MODE_ALL } | |
| @@ -92,6 +92,7 @@ static const KeySym KEYHANDLER_ABORT = XK_Escape; | |||
| 92 | 92 | static const keymap_t keys[] = { | |
| 93 | 93 | /* modifiers key function argument */ | |
| 94 | 94 | { 0, XK_q, g_quit, 0 }, | |
| 95 | + | { 0, XK_Q, g_pick_quit, 0 }, | |
| 95 | 96 | { 0, XK_Return, g_switch_mode, None }, | |
| 96 | 97 | { 0, XK_f, g_toggle_fullscreen, None }, | |
| 97 | 98 | { 0, XK_b, g_toggle_bar, None }, | |
| @@ -135,6 +135,10 @@ Prefix the next command with a number (denoted via | |||
| 135 | 135 | .B q | |
| 136 | 136 | Quit nsxiv. | |
| 137 | 137 | .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 | |
| 138 | 142 | .B Return | |
| 139 | 143 | Switch to thumbnail mode / open selected image in image mode. | |
| 140 | 144 | .TP | |