Krolyxon
Commit 997c851

Branches

Refs →

nsxiv997c851

Set scale mode at startup via argument to -s option

Author
Bert Münnich
Date
2014-02-04 23:05 +0100
Parent
43a04c4
Commit
997c8518c5884fecf03fb3d677dbc6d80d11c9df

+20 −12

3 files changed

  1. M README.md +1 −1
  2. M options.c +11 −5
  3. M sxiv.1 +8 −6
M README.md View
@@ -82,7 +82,7 @@ of small previews is displayed, making it easy to choose an image to open.
8282 -q Be quiet, disable warnings
8383 -r Search given directories recursively for images
8484 -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)
8686 -t Start in thumbnail mode
8787 -v Print version information and exit
8888 -Z Same as `-z 100'
M options.c View
@@ -33,8 +33,8 @@ const options_t *options = (const options_t*) &_options;
3333
3434 void print_usage(void)
3535 {
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");
3838 }
3939
4040 void print_version(void)
@@ -45,7 +45,8 @@ void print_version(void)
4545 void parse_options(int argc, char **argv)
4646 {
4747 int n, opt;
48− char *end;
48+ char *end, *s;
49+ const char *scalemodes = "dfwh";
4950
5051 _options.from_stdin = false;
5152 _options.to_stdout = false;
@@ -67,7 +68,7 @@ void parse_options(int argc, char **argv)
6768 _options.thumb_mode = false;
6869 _options.clean_cache = false;
6970
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) {
7172 switch (opt) {
7273 case '?':
7374 print_usage();
@@ -130,7 +131,12 @@ void parse_options(int argc, char **argv)
130131 _options.slideshow = n;
131132 break;
132133 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;
134140 break;
135141 case 't':
136142 _options.thumb_mode = true;
M sxiv.1 View
@@ -3,7 +3,7 @@
33 sxiv \- Simple X Image Viewer
44 .SH SYNOPSIS
55 .B sxiv
6−.RB [ \-bcFfhioqrstvZ ]
6+.RB [ \-bcFfhioqrtvZ ]
77 .RB [ \-G
88 .IR GAMMA ]
99 .RB [ \-g
@@ -14,6 +14,8 @@ sxiv \- Simple X Image Viewer
1414 .IR NUM ]
1515 .RB [ \-S
1616 .IR DELAY ]
17+.RB [ \-s
18+.IR MODE ]
1719 .RB [ \-z
1820 .IR ZOOM ]
1921 .IR FILE ...
@@ -50,8 +52,7 @@ Set image gamma to GAMMA (-32..32).
5052 .TP
5153 .BI "\-g " GEOMETRY
5254 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.
5556 .TP
5657 .BI "\-N " NAME
5758 Set the resource name of sxiv's X window to NAME.
@@ -68,7 +69,7 @@ Read names of files to open from standard input.
6869 .B \-o
6970 Write list of all marked files to standard output when quitting. In combination
7071 with
71−.I \-i
72+.B \-i
7273 sxiv can be used as a visual filter/pipe.
7374 .TP
7475 .B \-q
@@ -80,8 +81,9 @@ Search the given directories recursively for images to view.
8081 .BI "\-S " DELAY
8182 Start in slideshow mode. Set the delay between images to DELAY seconds.
8283 .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.
8587 .TP
8688 .B \-t
8789 Start in thumbnail mode.