diff --git a/etc/nsxiv.1 b/etc/nsxiv.1 index 2e01302..999f91b 100644 --- a/etc/nsxiv.1 +++ b/etc/nsxiv.1 @@ -99,8 +99,8 @@ may be a floating-point number. Set scale mode according to MODE character. Supported modes are: [d]own, [f]it, [F]ill, [w]idth, [h]eight. .TP -.B "\-t, \-\-thumbnail" -Start in thumbnail mode. +.BR "\-t, \-\-thumbnail" [=no] +Start in thumbnail mode. The long option accepts an optional "no" to disable it. .TP .B "\-v, \-\-version" Print version information to standard output and exit. diff --git a/options.c b/options.c index 933485e..b9a244c 100644 --- a/options.c +++ b/options.c @@ -76,6 +76,7 @@ void parse_options(int argc, char **argv) OPT_START = UCHAR_MAX, OPT_AA, OPT_AL, + OPT_THUMB, OPT_BG, OPT_CA, OPT_CD @@ -99,7 +100,9 @@ void parse_options(int argc, char **argv) { "recursive", 'r', OPTPARSE_NONE }, { "ss-delay", 'S', OPTPARSE_REQUIRED }, { "scale-mode", 's', OPTPARSE_REQUIRED }, - { "thumbnail", 't', OPTPARSE_NONE }, + /* short opt `-t` doesn't accept optional arg for backwards compatibility reasons */ + { NULL, 't', OPTPARSE_NONE }, + { "thumbnail", OPT_THUMB, OPTPARSE_OPTIONAL }, { "version", 'v', OPTPARSE_NONE }, { "zoom-100", 'Z', OPTPARSE_NONE }, { "zoom", 'z', OPTPARSE_REQUIRED }, @@ -268,6 +271,11 @@ void parse_options(int argc, char **argv) error(EXIT_FAILURE, 0, "Invalid argument for option --alpha-layer: %s", op.optarg); _options.alpha_layer = op.optarg == NULL; break; + case OPT_THUMB: + if (op.optarg != NULL && !STREQ(op.optarg, "no")) + error(EXIT_FAILURE, 0, "Invalid argument for option --thumbnail: %s", op.optarg); + _options.thumb_mode = op.optarg == NULL; + break; case OPT_BG: if (op.optarg != NULL && !STREQ(op.optarg, "no")) error(EXIT_FAILURE, 0, "Invalid argument for option --bg-cache: %s", op.optarg);