From 0353e6eea265f5f6fa53eb75300529d9ffa6d4fa Mon Sep 17 00:00:00 2001 From: AndrĂ¡s Mohari Date: Wed, 13 Nov 2013 20:54:09 +0100 Subject: Add support for changing the gamma value --- options.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'options.c') diff --git a/options.c b/options.c index e47ad37..574f871 100644 --- a/options.c +++ b/options.c @@ -33,7 +33,7 @@ const options_t *options = (const options_t*) &_options; void print_usage(void) { - printf("usage: sxiv [-bcdFfhioqrstvZ] [-g GEOMETRY] [-n NUM] " + printf("usage: sxiv [-bcdFfhioqrstvZ] [-g GEOMETRY] [-G GAMMA] [-n NUM] " "[-N name] [-z ZOOM] FILES...\n"); } @@ -44,7 +44,7 @@ void print_version(void) void parse_options(int argc, char **argv) { - int opt, t; + int opt, t, gamma; _options.from_stdin = false; _options.to_stdout = false; @@ -53,6 +53,7 @@ void parse_options(int argc, char **argv) _options.scalemode = SCALE_MODE; _options.zoom = 1.0; + _options.gamma = 0; _options.fixed_win = false; _options.fullscreen = false; @@ -64,7 +65,7 @@ void parse_options(int argc, char **argv) _options.thumb_mode = false; _options.clean_cache = false; - while ((opt = getopt(argc, argv, "bcdFfg:hin:N:oqrstvZz:")) != -1) { + while ((opt = getopt(argc, argv, "bcdFfg:G:hin:N:oqrstvZz:")) != -1) { switch (opt) { case '?': print_usage(); @@ -87,6 +88,14 @@ void parse_options(int argc, char **argv) case 'g': _options.geometry = optarg; break; + case 'G': + if (sscanf(optarg, "%d", &gamma) <= 0) { + fprintf(stderr, "sxiv: invalid argument for option -G: %s\n", + optarg); + exit(EXIT_FAILURE); + } + _options.gamma = gamma; + break; case 'h': print_usage(); exit(EXIT_SUCCESS); -- cgit v1.2.3-54-g00ecf