Krolyxon
Commit 27bbaab

Branches

Refs →

nsxiv27bbaab

Support for DELAY as a floating point number including less than 1 second while maintaining backward compatibiitiy with integer arguments.

Author
Don Hejna
Date
2016-11-27 20:36 -0800
Parent
32b29e6
Commit
27bbaab976e02d2458099de96ec71d14aa1ade8e

+12 −11

6 files changed

  1. M image.c +2 −2
  2. M image.h +1 −1
  3. M main.c +1 −1
  4. M options.c +5 −4
  5. M options.h +1 −1
  6. M sxiv.1 +2 −2
M image.c View
@@ -74,8 +74,8 @@ void img_init(img_t *img, win_t *win)
7474 imlib_context_set_color_modifier(img->cmod);
7575 img->gamma = MIN(MAX(options->gamma, -GAMMA_RANGE), GAMMA_RANGE);
7676
77− img->ss.on = options->slideshow > 0;
78− img->ss.delay = options->slideshow > 0 ? options->slideshow : SLIDESHOW_DELAY;
77+ img->ss.on = options->slideshow > 0.0;
78+ img->ss.delay = options->slideshow > 0.0 ? options->slideshow : SLIDESHOW_DELAY;
7979 }
8080
8181 #if HAVE_LIBEXIF
M image.h View
@@ -60,7 +60,7 @@ typedef struct {
6060
6161 struct {
6262 bool on;
63− int delay;
63+ float delay;
6464 } ss;
6565
6666 multi_img_t multi;
M main.c View
@@ -372,7 +372,7 @@ void update_info(void)
372372 } else {
373373 bar_put(r, "%s", mark);
374374 if (img.ss.on)
375− bar_put(r, "%ds | ", img.ss.delay);
375+ bar_put(r, "%2.1fs | ", img.ss.delay);
376376 if (img.gamma != 0)
377377 bar_put(r, "G%+d | ", img.gamma);
378378 bar_put(r, "%3d%% | ", (int) (img.zoom * 100.0));
M options.c View
@@ -44,6 +44,7 @@ void print_version(void)
4444 void parse_options(int argc, char **argv)
4545 {
4646 int n, opt;
47+ float f;
4748 char *end, *s;
4849 const char *scalemodes = "dfwh";
4950
@@ -59,7 +60,7 @@ void parse_options(int argc, char **argv)
5960 _options.zoom = 1.0;
6061 _options.animate = false;
6162 _options.gamma = 0;
62− _options.slideshow = 0;
63+ _options.slideshow = 0.0;
6364
6465 _options.fullscreen = false;
6566 _options.embed = 0;
@@ -128,10 +129,10 @@ void parse_options(int argc, char **argv)
128129 _options.recursive = true;
129130 break;
130131 case 'S':
131− n = strtol(optarg, &end, 0);
132− if (*end != '\0' || n <= 0)
132+ f = (float) strtof(optarg, &end);
133+ if (*end != '\0' || f <= 0.0)
133134 error(EXIT_FAILURE, 0, "Invalid argument for option -S: %s", optarg);
134− _options.slideshow = n;
135+ _options.slideshow = (float) f;
135136 break;
136137 case 's':
137138 s = strchr(scalemodes, optarg[0]);
M options.h View
@@ -36,7 +36,7 @@ typedef struct {
3636 float zoom;
3737 bool animate;
3838 int gamma;
39− int slideshow;
39+ float slideshow;
4040
4141 /* window: */
4242 bool fullscreen;
M sxiv.1 View
@@ -81,7 +81,7 @@ Be quiet, disable warnings to standard error stream.
8181 Search the given directories recursively for images to view.
8282 .TP
8383 .BI "\-S " DELAY
84−Start in slideshow mode. Set the delay between images to DELAY seconds.
84+Start in slideshow mode. Set the delay between images to DELAY (float, e.g. 1, 3.1, 0.01) seconds.
8585 .TP
8686 .BI "\-s " MODE
8787 Set scale mode according to MODE character. Supported modes are: [d]own,
@@ -330,7 +330,7 @@ Toggle visibility of alpha-channel, i.e. image transparency.
330330 .TP
331331 .B s
332332 Toggle slideshow mode and/or set the delay between images to
333−.I count
333+.I count (integer prefix only)
334334 seconds.
335335 .SH MOUSE COMMANDS
336336 The following mouse mappings are available in image mode: