diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2019-08-07 20:21:44 +0100 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2019-08-07 20:21:44 +0100 |
commit | e889f417c7edd3d47a54b9464e1b6b72c3f7ae1c (patch) | |
tree | 1ed3a5e8e2b2c41dc73a34e01991de892572e035 | |
parent | 760eed07885a28bd82351d64f24d1f325373dbaf (diff) | |
download | imv-e889f417c7edd3d47a54b9464e1b6b72c3f7ae1c.tar.gz |
imv: Improve slideshow command
-rw-r--r-- | src/imv.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -1601,15 +1601,24 @@ static void command_set_slideshow_duration(struct list *args, const char *argstr (void)argstr; struct imv *imv = data; if (args->len == 2) { - long int delta = strtol(args->items[1], NULL, 10); + const char *arg = args->items[1]; + const char prefix = *arg; - /* Ensure we can't go below 0 */ - if (delta < 0 && (size_t)labs(delta) > imv->slideshow.duration) { - imv->slideshow.duration = 0; + int new_duration = imv->slideshow.duration; + + long int arg_num = strtol(arg, NULL, 10); + + if (prefix == '+' || prefix == '-') { + new_duration += arg_num; } else { - imv->slideshow.duration += delta; + new_duration = arg_num; + } + + if (new_duration < 0) { + new_duration = 0; } + imv->slideshow.duration = new_duration; imv->need_redraw = true; } } |