nsxiv27bbaab
Support for DELAY as a floating point number including less than 1 second while maintaining backward compatibiitiy with integer arguments.
+12 −11
6 files changed
| @@ -74,8 +74,8 @@ void img_init(img_t *img, win_t *win) | |||
| 74 | 74 | imlib_context_set_color_modifier(img->cmod); | |
| 75 | 75 | img->gamma = MIN(MAX(options->gamma, -GAMMA_RANGE), GAMMA_RANGE); | |
| 76 | 76 | ||
| 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; | |
| 79 | 79 | } | |
| 80 | 80 | ||
| 81 | 81 | #if HAVE_LIBEXIF | |
| @@ -60,7 +60,7 @@ typedef struct { | |||
| 60 | 60 | ||
| 61 | 61 | struct { | |
| 62 | 62 | bool on; | |
| 63 | − | int delay; | |
| 63 | + | float delay; | |
| 64 | 64 | } ss; | |
| 65 | 65 | ||
| 66 | 66 | multi_img_t multi; | |
| @@ -372,7 +372,7 @@ void update_info(void) | |||
| 372 | 372 | } else { | |
| 373 | 373 | bar_put(r, "%s", mark); | |
| 374 | 374 | if (img.ss.on) | |
| 375 | − | bar_put(r, "%ds | ", img.ss.delay); | |
| 375 | + | bar_put(r, "%2.1fs | ", img.ss.delay); | |
| 376 | 376 | if (img.gamma != 0) | |
| 377 | 377 | bar_put(r, "G%+d | ", img.gamma); | |
| 378 | 378 | bar_put(r, "%3d%% | ", (int) (img.zoom * 100.0)); | |
| @@ -44,6 +44,7 @@ void print_version(void) | |||
| 44 | 44 | void parse_options(int argc, char **argv) | |
| 45 | 45 | { | |
| 46 | 46 | int n, opt; | |
| 47 | + | float f; | |
| 47 | 48 | char *end, *s; | |
| 48 | 49 | const char *scalemodes = "dfwh"; | |
| 49 | 50 | ||
| @@ -59,7 +60,7 @@ void parse_options(int argc, char **argv) | |||
| 59 | 60 | _options.zoom = 1.0; | |
| 60 | 61 | _options.animate = false; | |
| 61 | 62 | _options.gamma = 0; | |
| 62 | − | _options.slideshow = 0; | |
| 63 | + | _options.slideshow = 0.0; | |
| 63 | 64 | ||
| 64 | 65 | _options.fullscreen = false; | |
| 65 | 66 | _options.embed = 0; | |
| @@ -128,10 +129,10 @@ void parse_options(int argc, char **argv) | |||
| 128 | 129 | _options.recursive = true; | |
| 129 | 130 | break; | |
| 130 | 131 | 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) | |
| 133 | 134 | error(EXIT_FAILURE, 0, "Invalid argument for option -S: %s", optarg); | |
| 134 | − | _options.slideshow = n; | |
| 135 | + | _options.slideshow = (float) f; | |
| 135 | 136 | break; | |
| 136 | 137 | case 's': | |
| 137 | 138 | s = strchr(scalemodes, optarg[0]); | |
| @@ -36,7 +36,7 @@ typedef struct { | |||
| 36 | 36 | float zoom; | |
| 37 | 37 | bool animate; | |
| 38 | 38 | int gamma; | |
| 39 | − | int slideshow; | |
| 39 | + | float slideshow; | |
| 40 | 40 | ||
| 41 | 41 | /* window: */ | |
| 42 | 42 | bool fullscreen; | |
| @@ -81,7 +81,7 @@ Be quiet, disable warnings to standard error stream. | |||
| 81 | 81 | Search the given directories recursively for images to view. | |
| 82 | 82 | .TP | |
| 83 | 83 | .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. | |
| 85 | 85 | .TP | |
| 86 | 86 | .BI "\-s " MODE | |
| 87 | 87 | 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. | |||
| 330 | 330 | .TP | |
| 331 | 331 | .B s | |
| 332 | 332 | Toggle slideshow mode and/or set the delay between images to | |
| 333 | − | .I count | |
| 333 | + | .I count (integer prefix only) | |
| 334 | 334 | seconds. | |
| 335 | 335 | .SH MOUSE COMMANDS | |
| 336 | 336 | The following mouse mappings are available in image mode: | |