diff options
author | NRK <nrk@disroot.org> | 2021-10-28 11:43:36 +0600 |
---|---|---|
committer | eylles <ed.ylles1997@gmail.com> | 2021-10-29 17:45:55 -0600 |
commit | d0b5005a023da1e436665fc1d795b20246dd9d80 (patch) | |
tree | 871f4cfd1f2e429a2bbb7f6cd227b5769e841421 | |
parent | 8934744c60a3ef34eb65a6082d59da8ad2234d6c (diff) |
-0 sends NULL separated file-list to key-handler
with this change `-0` is turned into a more generic switch which can be
used to send NULL-separated file-list to the key-handler as well.
this also means `-0` no longer implicitly enables `-o`
Closes: https://github.com/nsxiv/nsxiv/issues/140
-rw-r--r-- | commands.c | 2 | ||||
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | nsxiv.1 | 4 | ||||
-rw-r--r-- | nsxiv.h | 2 | ||||
-rw-r--r-- | options.c | 5 |
5 files changed, 7 insertions, 8 deletions
@@ -59,7 +59,7 @@ bool cg_quit(arg_t _) if (options->to_stdout && markcnt > 0) { for (i = 0; i < filecnt; i++) { if (files[i].flags & FF_MARK) - printf("%s%c", files[i].name, options->stdout_separator); + printf("%s%c", files[i].name, options->using_null ? '\0' : '\n'); } } exit(EXIT_SUCCESS); @@ -547,7 +547,7 @@ void run_key_handler(const char *key, unsigned int mask) for (f = i = 0; f < fcnt; i++) { if ((marked && (files[i].flags & FF_MARK)) || (!marked && i == fileidx)) { stat(files[i].path, &oldst[f]); - fprintf(pfs, "%s\n", files[i].name); + fprintf(pfs, "%s%c", files[i].name, options->using_null ? '\0' : '\n'); f++; } } @@ -127,8 +127,8 @@ The same as `\-z 100'. Set zoom level to ZOOM percent. .TP .B \-0 -Same as \-o, however the marked files are NULL separated. This option implies -\-o. +Use NULL-separator. With this option output of \-o and file-list sent to the +key-handler will be seperated by a NULL character. .SH KEYBOARD COMMANDS .SS General The following keyboard commands are available in both image and thumbnail mode: @@ -256,7 +256,7 @@ struct opt { char **filenames; bool from_stdin; bool to_stdout; - char stdout_separator; + bool using_null; bool recursive; int filecnt; int startnum; @@ -52,7 +52,7 @@ void parse_options(int argc, char **argv) _options.from_stdin = false; _options.to_stdout = false; - _options.stdout_separator = '\n'; + _options.using_null = false; _options.recursive = false; _options.startnum = 0; @@ -181,8 +181,7 @@ void parse_options(int argc, char **argv) _options.zoom = (float) n / 100.0; break; case '0': - _options.stdout_separator = '\0'; - _options.to_stdout = true; /* -0 implies -o */ + _options.using_null = true; break; } } |