aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commands.c35
-rw-r--r--commands.h1
-rw-r--r--config.def.h2
3 files changed, 29 insertions, 9 deletions
diff --git a/commands.c b/commands.c
index 920e590..b869175 100644
--- a/commands.c
+++ b/commands.c
@@ -17,6 +17,7 @@
*/
#define _POSIX_C_SOURCE 200112L
+#define _IMAGE_CONFIG
#include <stdlib.h>
#include <string.h>
@@ -27,6 +28,7 @@
#include "image.h"
#include "thumbs.h"
#include "util.h"
+#include "config.h"
void cleanup(void);
void remove_file(int, bool);
@@ -48,6 +50,10 @@ extern int filecnt, fileidx;
extern int prefix;
+const int ss_delays[] = {
+ 1, 2, 3, 5, 10, 15, 20, 30, 60, 120, 180, 300, 600
+};
+
bool it_quit(arg_t a) {
cleanup();
exit(EXIT_SUCCESS);
@@ -118,7 +124,7 @@ bool i_navigate(arg_t a) {
long n = (long) a;
if (mode == MODE_IMAGE) {
- if (prefix)
+ if (prefix > 0)
n *= prefix;
n += fileidx;
if (n < 0)
@@ -345,22 +351,22 @@ bool i_toggle_slideshow(arg_t a) {
bool i_adjust_slideshow(arg_t a) {
long d = (long) a;
- int i, delays[] = { 1, 2, 3, 5, 10, 15, 20, 30, 60, 120, 180, 300, 600 };
+ int i;
if (mode != MODE_IMAGE || !img.slideshow)
return false;
if (d < 0) {
- for (i = ARRLEN(delays) - 2; i >= 0; i--) {
- if (img.ss_delay > delays[i] * 1000) {
- img.ss_delay = delays[i] * 1000;
+ for (i = ARRLEN(ss_delays) - 2; i >= 0; i--) {
+ if (img.ss_delay > ss_delays[i] * 1000) {
+ img.ss_delay = ss_delays[i] * 1000;
return true;
}
}
} else {
- for (i = 1; i < ARRLEN(delays); i++) {
- if (img.ss_delay < delays[i] * 1000) {
- img.ss_delay = delays[i] * 1000;
+ for (i = 1; i < ARRLEN(ss_delays); i++) {
+ if (img.ss_delay < ss_delays[i] * 1000) {
+ img.ss_delay = ss_delays[i] * 1000;
return true;
}
}
@@ -368,6 +374,19 @@ bool i_adjust_slideshow(arg_t a) {
return false;
}
+bool i_reset_slideshow(arg_t a) {
+ if (mode != MODE_IMAGE || !img.slideshow)
+ return false;
+
+ if (prefix > 0) {
+ img.ss_delay = MIN(prefix, ss_delays[ARRLEN(ss_delays) - 1]);
+ img.ss_delay = MAX(img.ss_delay, ss_delays[0]) * 1000;
+ } else {
+ img.ss_delay = SLIDESHOW_DELAY * 1000;
+ }
+ return true;
+}
+
bool i_toggle_antialias(arg_t a) {
if (mode == MODE_IMAGE) {
img_toggle_antialias(&img);
diff --git a/commands.h b/commands.h
index ab44c5e..061ebc3 100644
--- a/commands.h
+++ b/commands.h
@@ -62,6 +62,7 @@ bool i_fit_to_img(arg_t);
bool i_rotate(arg_t);
bool i_toggle_slideshow(arg_t);
bool i_adjust_slideshow(arg_t);
+bool i_reset_slideshow(arg_t);
bool i_toggle_antialias(arg_t);
bool it_toggle_alpha(arg_t);
bool it_open_with(arg_t);
diff --git a/config.def.h b/config.def.h
index 2e54b99..d8bb47f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -121,8 +121,8 @@ static const keymap_t keys[] = {
{ false, XK_s, i_toggle_slideshow, (arg_t) None },
{ true, XK_plus, i_adjust_slideshow, (arg_t) +1 },
- { true, XK_equal, i_adjust_slideshow, (arg_t) +1 },
{ true, XK_minus, i_adjust_slideshow, (arg_t) -1 },
+ { true, XK_equal, i_reset_slideshow, (arg_t) None },
{ false, XK_a, i_toggle_antialias, (arg_t) None },
{ false, XK_A, it_toggle_alpha, (arg_t) None },