From 1f788a318bedc0e6a83632c1f126e747c0430d6c Mon Sep 17 00:00:00 2001 From: NRK Date: Tue, 17 Jan 2023 15:48:59 +0600 Subject: add cli flag --alpha-layer now that we have long-opts, we don't have to worry about exhausting the alphabet list for short-opts. so adding a cli flag to set/unset the checker background makes sense. ref: https://codeberg.org/nsxiv/nsxiv/issues/404 --- options.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'options.c') diff --git a/options.c b/options.c index ac91c63..37ad60d 100644 --- a/options.c +++ b/options.c @@ -66,8 +66,13 @@ static void print_version(void) void parse_options(int argc, char **argv) { - enum { /* ensure these can't be represented in a single byte */ - OPT_AA = UCHAR_MAX + 1 + enum { + /* ensure these can't be represented in a single byte in order + * to avoid conflicts with short opts + */ + OPT_START = UCHAR_MAX, + OPT_AA, + OPT_AL }; static const struct optparse_long longopts[] = { { "framerate", 'A', OPTPARSE_REQUIRED }, @@ -95,6 +100,7 @@ void parse_options(int argc, char **argv) { "zoom", 'z', OPTPARSE_REQUIRED }, { "null", '0', OPTPARSE_NONE }, { "anti-alias", OPT_AA, OPTPARSE_OPTIONAL }, + { "alpha-layer", OPT_AL, OPTPARSE_OPTIONAL }, { 0 }, /* end */ }; @@ -115,6 +121,7 @@ void parse_options(int argc, char **argv) _options.scalemode = SCALE_DOWN; _options.zoom = 1.0; _options.anti_alias = ANTI_ALIAS; + _options.alpha_layer = ALPHA_LAYER; _options.animate = false; _options.gamma = 0; _options.slideshow = 0; @@ -247,6 +254,11 @@ void parse_options(int argc, char **argv) error(EXIT_FAILURE, 0, "Invalid argument for option --anti-alias: %s", op.optarg); _options.anti_alias = op.optarg == NULL; break; + case OPT_AL: + if (op.optarg != NULL && !STREQ(op.optarg, "no")) + error(EXIT_FAILURE, 0, "Invalid argument for option --alpha-layer: %s", op.optarg); + _options.alpha_layer = op.optarg == NULL; + break; } } -- cgit v1.2.3-54-g00ecf