nsxiv997c851
Set scale mode at startup via argument to -s option
+20 −12
3 files changed
| @@ -82,7 +82,7 @@ of small previews is displayed, making it easy to choose an image to open. | |||
| 82 | 82 | -q Be quiet, disable warnings | |
| 83 | 83 | -r Search given directories recursively for images | |
| 84 | 84 | -S DELAY Enable slideshow and set slideshow delay to DELAY seconds | |
| 85 | − | -s Fit images to window | |
| 85 | + | -s MODE Set scale mode to MODE ([d]own, [f]it, [w]idth, [h]eight) | |
| 86 | 86 | -t Start in thumbnail mode | |
| 87 | 87 | -v Print version information and exit | |
| 88 | 88 | -Z Same as `-z 100' | |
| @@ -33,8 +33,8 @@ const options_t *options = (const options_t*) &_options; | |||
| 33 | 33 | ||
| 34 | 34 | void print_usage(void) | |
| 35 | 35 | { | |
| 36 | − | printf("usage: sxiv [-bcFfhioqrstvZ] [-G GAMMA] [-g GEOMETRY] [-n NUM] " | |
| 37 | − | "[-N NAME] [-S DELAY] [-z ZOOM] FILES...\n"); | |
| 36 | + | printf("usage: sxiv [-bcFfhioqrtvZ] [-G GAMMA] [-g GEOMETRY] [-n NUM] " | |
| 37 | + | "[-N NAME] [-S DELAY] [-s MODE] [-z ZOOM] FILES...\n"); | |
| 38 | 38 | } | |
| 39 | 39 | ||
| 40 | 40 | void print_version(void) | |
| @@ -45,7 +45,8 @@ void print_version(void) | |||
| 45 | 45 | void parse_options(int argc, char **argv) | |
| 46 | 46 | { | |
| 47 | 47 | int n, opt; | |
| 48 | − | char *end; | |
| 48 | + | char *end, *s; | |
| 49 | + | const char *scalemodes = "dfwh"; | |
| 49 | 50 | ||
| 50 | 51 | _options.from_stdin = false; | |
| 51 | 52 | _options.to_stdout = false; | |
| @@ -67,7 +68,7 @@ void parse_options(int argc, char **argv) | |||
| 67 | 68 | _options.thumb_mode = false; | |
| 68 | 69 | _options.clean_cache = false; | |
| 69 | 70 | ||
| 70 | − | while ((opt = getopt(argc, argv, "bcFfG:g:hin:N:oqrS:stvZz:")) != -1) { | |
| 71 | + | while ((opt = getopt(argc, argv, "bcFfG:g:hin:N:oqrS:s:tvZz:")) != -1) { | |
| 71 | 72 | switch (opt) { | |
| 72 | 73 | case '?': | |
| 73 | 74 | print_usage(); | |
| @@ -130,7 +131,12 @@ void parse_options(int argc, char **argv) | |||
| 130 | 131 | _options.slideshow = n; | |
| 131 | 132 | break; | |
| 132 | 133 | case 's': | |
| 133 | − | _options.scalemode = SCALE_FIT; | |
| 134 | + | s = strchr(scalemodes, optarg[0]); | |
| 135 | + | if (s == NULL || *s == '\0' || strlen(optarg) != 1) { | |
| 136 | + | fprintf(stderr, "sxiv: invalid argument for option -s: %s\n", optarg); | |
| 137 | + | exit(EXIT_FAILURE); | |
| 138 | + | } | |
| 139 | + | _options.scalemode = s - scalemodes; | |
| 134 | 140 | break; | |
| 135 | 141 | case 't': | |
| 136 | 142 | _options.thumb_mode = true; | |
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | sxiv \- Simple X Image Viewer | |
| 4 | 4 | .SH SYNOPSIS | |
| 5 | 5 | .B sxiv | |
| 6 | − | .RB [ \-bcFfhioqrstvZ ] | |
| 6 | + | .RB [ \-bcFfhioqrtvZ ] | |
| 7 | 7 | .RB [ \-G | |
| 8 | 8 | .IR GAMMA ] | |
| 9 | 9 | .RB [ \-g | |
| @@ -14,6 +14,8 @@ sxiv \- Simple X Image Viewer | |||
| 14 | 14 | .IR NUM ] | |
| 15 | 15 | .RB [ \-S | |
| 16 | 16 | .IR DELAY ] | |
| 17 | + | .RB [ \-s | |
| 18 | + | .IR MODE ] | |
| 17 | 19 | .RB [ \-z | |
| 18 | 20 | .IR ZOOM ] | |
| 19 | 21 | .IR FILE ... | |
| @@ -50,8 +52,7 @@ Set image gamma to GAMMA (-32..32). | |||
| 50 | 52 | .TP | |
| 51 | 53 | .BI "\-g " GEOMETRY | |
| 52 | 54 | Set window position and size. See section GEOMETRY SPECIFICATIONS of X(7) for | |
| 53 | − | more information on | |
| 54 | − | .IR GEOMETRY . | |
| 55 | + | more information on GEOMETRY argument. | |
| 55 | 56 | .TP | |
| 56 | 57 | .BI "\-N " NAME | |
| 57 | 58 | Set the resource name of sxiv's X window to NAME. | |
| @@ -68,7 +69,7 @@ Read names of files to open from standard input. | |||
| 68 | 69 | .B \-o | |
| 69 | 70 | Write list of all marked files to standard output when quitting. In combination | |
| 70 | 71 | with | |
| 71 | − | .I \-i | |
| 72 | + | .B \-i | |
| 72 | 73 | sxiv can be used as a visual filter/pipe. | |
| 73 | 74 | .TP | |
| 74 | 75 | .B \-q | |
| @@ -80,8 +81,9 @@ Search the given directories recursively for images to view. | |||
| 80 | 81 | .BI "\-S " DELAY | |
| 81 | 82 | Start in slideshow mode. Set the delay between images to DELAY seconds. | |
| 82 | 83 | .TP | |
| 83 | − | .B \-s | |
| 84 | − | Fit images to window. | |
| 84 | + | .BI "\-s " MODE | |
| 85 | + | Set scale mode according to MODE character. Supported modes are: [d]own, | |
| 86 | + | [f]it, [w]idth, [h]eight. | |
| 85 | 87 | .TP | |
| 86 | 88 | .B \-t | |
| 87 | 89 | Start in thumbnail mode. | |