aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commands.c5
-rw-r--r--image.c16
2 files changed, 5 insertions, 16 deletions
diff --git a/commands.c b/commands.c
index 19d2abe..5f523ba 100644
--- a/commands.c
+++ b/commands.c
@@ -273,10 +273,7 @@ bool ci_navigate(arg_t n)
if (prefix > 0)
n *= prefix;
n += fileidx;
- if (n < 0)
- n = 0;
- if (n >= filecnt)
- n = filecnt - 1;
+ n = MAX(0, MIN(n, filecnt - 1));
if (n != fileidx) {
load_image(n);
diff --git a/image.c b/image.c
index ba5b1fe..2904887 100644
--- a/image.c
+++ b/image.c
@@ -898,23 +898,15 @@ bool img_frame_navigate(img_t *img, int d)
return false;
d += img->multi.sel;
- if (d < 0)
- d = 0;
- else if (d >= img->multi.cnt)
- d = img->multi.cnt - 1;
+ d = MAX(0, MIN(d, img->multi.cnt - 1));
return img_frame_goto(img, d);
}
bool img_frame_animate(img_t *img)
{
- if (img->multi.cnt == 0)
- return false;
-
- if (img->multi.sel + 1 >= img->multi.cnt)
- img_frame_goto(img, 0);
+ if (img->multi.cnt > 0)
+ return img_frame_goto(img, (img->multi.sel + 1) % img->multi.cnt);
else
- img_frame_goto(img, img->multi.sel + 1);
- img->dirty = true;
- return true;
+ return false;
}