Krolyxon
Commit d0b5005

Branches

Refs →

nsxivd0b5005

-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`
Author
NRK
Date
2021-10-28 11:43 +0600
Committer
eylles · 2021-10-29 17:45 -0600
Parent
8934744
Commit
d0b5005a023da1e436665fc1d795b20246dd9d80

+7 −8

5 files changed

  1. M commands.c +1 −1
  2. M main.c +1 −1
  3. M nsxiv.1 +2 −2
  4. M nsxiv.h +1 −1
  5. M options.c +2 −3
M commands.c View
@@ -59,7 +59,7 @@ bool cg_quit(arg_t _)
5959 if (options->to_stdout && markcnt > 0) {
6060 for (i = 0; i < filecnt; i++) {
6161 if (files[i].flags & FF_MARK)
62− printf("%s%c", files[i].name, options->stdout_separator);
62+ printf("%s%c", files[i].name, options->using_null ? '\0' : '\n');
6363 }
6464 }
6565 exit(EXIT_SUCCESS);
M main.c View
@@ -547,7 +547,7 @@ void run_key_handler(const char *key, unsigned int mask)
547547 for (f = i = 0; f < fcnt; i++) {
548548 if ((marked && (files[i].flags & FF_MARK)) || (!marked && i == fileidx)) {
549549 stat(files[i].path, &oldst[f]);
550− fprintf(pfs, "%s\n", files[i].name);
550+ fprintf(pfs, "%s%c", files[i].name, options->using_null ? '\0' : '\n');
551551 f++;
552552 }
553553 }
M nsxiv.1 View
@@ -127,8 +127,8 @@ The same as `\-z 100'.
127127 Set zoom level to ZOOM percent.
128128 .TP
129129 .B \-0
130−Same as \-o, however the marked files are NULL separated. This option implies
131−\-o.
130+Use NULL-separator. With this option output of \-o and file-list sent to the
131+key-handler will be seperated by a NULL character.
132132 .SH KEYBOARD COMMANDS
133133 .SS General
134134 The following keyboard commands are available in both image and thumbnail mode:
M nsxiv.h View
@@ -256,7 +256,7 @@ struct opt {
256256 char **filenames;
257257 bool from_stdin;
258258 bool to_stdout;
259− char stdout_separator;
259+ bool using_null;
260260 bool recursive;
261261 int filecnt;
262262 int startnum;
M options.c View
@@ -52,7 +52,7 @@ void parse_options(int argc, char **argv)
5252
5353 _options.from_stdin = false;
5454 _options.to_stdout = false;
55− _options.stdout_separator = '\n';
55+ _options.using_null = false;
5656 _options.recursive = false;
5757 _options.startnum = 0;
5858
@@ -181,8 +181,7 @@ void parse_options(int argc, char **argv)
181181 _options.zoom = (float) n / 100.0;
182182 break;
183183 case '0':
184− _options.stdout_separator = '\0';
185− _options.to_stdout = true; /* -0 implies -o */
184+ _options.using_null = true;
186185 break;
187186 }
188187 }