summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBastien Dejean <nihilhill@gmail.com>2013-11-14 14:45:27 +0100
committerBastien Dejean <nihilhill@gmail.com>2013-11-14 14:45:27 +0100
commit562197577b01aed5c98979a4fc90bf22662172cf (patch)
treed66b12c2fcb084c364b5bff548c79522c363d9e0
parent450c1ed9b54de4d374bff80735c874bb6f7a4a0f (diff)
downloadnsxiv-562197577b01aed5c98979a4fc90bf22662172cf.tar.zst
Add command to reverse marked images
-rw-r--r--README.md1
-rw-r--r--commands.c12
-rw-r--r--commands.h1
-rw-r--r--config.def.h1
-rw-r--r--sxiv.13
5 files changed, 18 insertions, 0 deletions
diff --git a/README.md b/README.md
index cda09ee..913deac 100644
--- a/README.md
+++ b/README.md
@@ -108,6 +108,7 @@ of small previews is displayed, making it easy to choose an image to open.
D Remove image from file list and go to next image
m Mark/unmark current image
+ M Reverse marked images
N Go [count] marked images forward
P Go [count] marked images backward
diff --git a/commands.c b/commands.c
index ff95f36..9dbe2c0 100644
--- a/commands.c
+++ b/commands.c
@@ -251,6 +251,18 @@ bool it_toggle_image_mark(arg_t a)
return true;
}
+bool it_reverse_marks(arg_t a)
+{
+ int i, cnt = mode == MODE_IMAGE ? filecnt : tns.cnt;
+
+ for (i = 0; i < cnt; i++) {
+ files[i].marked = !files[i].marked;
+ markcnt += files[i].marked ? 1 : -1;
+ }
+
+ return true;
+}
+
bool it_navigate_marked(arg_t a)
{
long n = (long) a;
diff --git a/commands.h b/commands.h
index 118c89a..58bfafb 100644
--- a/commands.h
+++ b/commands.h
@@ -55,6 +55,7 @@ bool it_n_or_last(arg_t);
bool i_navigate_frame(arg_t);
bool i_toggle_animation(arg_t);
bool it_toggle_image_mark(arg_t);
+bool it_reverse_marks(arg_t);
bool it_navigate_marked(arg_t);
bool it_scroll_move(arg_t);
bool it_scroll_screen(arg_t);
diff --git a/config.def.h b/config.def.h
index f5d048a..c5e002f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -95,6 +95,7 @@ static const keymap_t keys[] = {
{ true, XK_space, i_toggle_animation, (arg_t) None },
{ false, XK_m, it_toggle_image_mark, (arg_t) None },
+ { false, XK_M, it_reverse_marks, (arg_t) None },
{ false, XK_N, it_navigate_marked, (arg_t) +1 },
{ false, XK_P, it_navigate_marked, (arg_t) -1 },
diff --git a/sxiv.1 b/sxiv.1
index ee42a00..f8ad0c1 100644
--- a/sxiv.1
+++ b/sxiv.1
@@ -130,6 +130,9 @@ Remove current image from file list and go to next image.
.B m
Mark/unmark the current image.
.TP
+.B M
+Reverse marked images.
+.TP
.B N
Go
.I count