Set scale mode at startup via argument to -s option

This commit is contained in:
Bert Münnich 2014-02-04 23:05:29 +01:00
parent 43a04c4757
commit 997c8518c5
3 changed files with 20 additions and 12 deletions

View File

@ -82,7 +82,7 @@ of small previews is displayed, making it easy to choose an image to open.
-q Be quiet, disable warnings -q Be quiet, disable warnings
-r Search given directories recursively for images -r Search given directories recursively for images
-S DELAY Enable slideshow and set slideshow delay to DELAY seconds -S DELAY Enable slideshow and set slideshow delay to DELAY seconds
-s Fit images to window -s MODE Set scale mode to MODE ([d]own, [f]it, [w]idth, [h]eight)
-t Start in thumbnail mode -t Start in thumbnail mode
-v Print version information and exit -v Print version information and exit
-Z Same as `-z 100' -Z Same as `-z 100'

View File

@ -33,8 +33,8 @@ const options_t *options = (const options_t*) &_options;
void print_usage(void) void print_usage(void)
{ {
printf("usage: sxiv [-bcFfhioqrstvZ] [-G GAMMA] [-g GEOMETRY] [-n NUM] " printf("usage: sxiv [-bcFfhioqrtvZ] [-G GAMMA] [-g GEOMETRY] [-n NUM] "
"[-N NAME] [-S DELAY] [-z ZOOM] FILES...\n"); "[-N NAME] [-S DELAY] [-s MODE] [-z ZOOM] FILES...\n");
} }
void print_version(void) void print_version(void)
@ -45,7 +45,8 @@ void print_version(void)
void parse_options(int argc, char **argv) void parse_options(int argc, char **argv)
{ {
int n, opt; int n, opt;
char *end; char *end, *s;
const char *scalemodes = "dfwh";
_options.from_stdin = false; _options.from_stdin = false;
_options.to_stdout = false; _options.to_stdout = false;
@ -67,7 +68,7 @@ void parse_options(int argc, char **argv)
_options.thumb_mode = false; _options.thumb_mode = false;
_options.clean_cache = false; _options.clean_cache = false;
while ((opt = getopt(argc, argv, "bcFfG:g:hin:N:oqrS:stvZz:")) != -1) { while ((opt = getopt(argc, argv, "bcFfG:g:hin:N:oqrS:s:tvZz:")) != -1) {
switch (opt) { switch (opt) {
case '?': case '?':
print_usage(); print_usage();
@ -130,7 +131,12 @@ void parse_options(int argc, char **argv)
_options.slideshow = n; _options.slideshow = n;
break; break;
case 's': case 's':
_options.scalemode = SCALE_FIT; s = strchr(scalemodes, optarg[0]);
if (s == NULL || *s == '\0' || strlen(optarg) != 1) {
fprintf(stderr, "sxiv: invalid argument for option -s: %s\n", optarg);
exit(EXIT_FAILURE);
}
_options.scalemode = s - scalemodes;
break; break;
case 't': case 't':
_options.thumb_mode = true; _options.thumb_mode = true;

14
sxiv.1
View File

@ -3,7 +3,7 @@
sxiv \- Simple X Image Viewer sxiv \- Simple X Image Viewer
.SH SYNOPSIS .SH SYNOPSIS
.B sxiv .B sxiv
.RB [ \-bcFfhioqrstvZ ] .RB [ \-bcFfhioqrtvZ ]
.RB [ \-G .RB [ \-G
.IR GAMMA ] .IR GAMMA ]
.RB [ \-g .RB [ \-g
@ -14,6 +14,8 @@ sxiv \- Simple X Image Viewer
.IR NUM ] .IR NUM ]
.RB [ \-S .RB [ \-S
.IR DELAY ] .IR DELAY ]
.RB [ \-s
.IR MODE ]
.RB [ \-z .RB [ \-z
.IR ZOOM ] .IR ZOOM ]
.IR FILE ... .IR FILE ...
@ -50,8 +52,7 @@ Set image gamma to GAMMA (-32..32).
.TP .TP
.BI "\-g " GEOMETRY .BI "\-g " GEOMETRY
Set window position and size. See section GEOMETRY SPECIFICATIONS of X(7) for Set window position and size. See section GEOMETRY SPECIFICATIONS of X(7) for
more information on more information on GEOMETRY argument.
.IR GEOMETRY .
.TP .TP
.BI "\-N " NAME .BI "\-N " NAME
Set the resource name of sxiv's X window to NAME. Set the resource name of sxiv's X window to NAME.
@ -68,7 +69,7 @@ Read names of files to open from standard input.
.B \-o .B \-o
Write list of all marked files to standard output when quitting. In combination Write list of all marked files to standard output when quitting. In combination
with with
.I \-i .B \-i
sxiv can be used as a visual filter/pipe. sxiv can be used as a visual filter/pipe.
.TP .TP
.B \-q .B \-q
@ -80,8 +81,9 @@ Search the given directories recursively for images to view.
.BI "\-S " DELAY .BI "\-S " DELAY
Start in slideshow mode. Set the delay between images to DELAY seconds. Start in slideshow mode. Set the delay between images to DELAY seconds.
.TP .TP
.B \-s .BI "\-s " MODE
Fit images to window. Set scale mode according to MODE character. Supported modes are: [d]own,
[f]it, [w]idth, [h]eight.
.TP .TP
.B \-t .B \-t
Start in thumbnail mode. Start in thumbnail mode.