Krolyxon
Commit fa81707

Branches

Refs →

nsxivfa81707

New key mapping: D, remove image from file list

Author
Bert
Date
2011-04-06 23:33 +0200
Parent
facd7e3
Commit
fa81707540b716b6d819d209bcb7629fe2739111

+42 −8

3 files changed

  1. M README.md +2 −1
  2. M main.c +36 −4
  3. M sxiv.1 +4 −3
M README.md View
@@ -53,7 +53,6 @@ sxiv supports the following command-line options:
5353 Use the following keys to control the basic behaviour of sxiv:
5454
5555 q Quit sxiv
56− Escape Quit sxiv and return an exit value of 2 (useful for scripting)
5756 f Toggle fullscreen mode (requires an EWMH/NetWM compliant
5857 window manager)
5958
@@ -73,6 +72,7 @@ Inside image view mode, the following key mappings are available:
7372 a Toggle anti-aliasing
7473 A Toggle visibility of alpha-channel, i.e. transparency
7574 r Reload image
75+ D Remove image from file list and go to next image
7676 Return Switch to thumbnail mode
7777
7878 Additionally, the image view offers the following mouse commands:
@@ -91,6 +91,7 @@ In thumbnail mode, the following key and mouse mappings are available:
9191
9292 h,j,k,l Move selection left/down/up/right (also with arrow keys)
9393 g/G Move selection to first/last image
94+ D Remove selected image from file list and select next image
9495 Return Open selected image
9596
9697 Button1 Select image/open image if it is already selected
M main.c View
@@ -370,7 +370,7 @@ void redraw() {
370370 }
371371
372372 void on_keypress(XKeyEvent *kev) {
373− int x, y;
373+ int i, x, y;
374374 unsigned int w, h;
375375 char key;
376376 KeySym ksym;
@@ -385,10 +385,10 @@ void on_keypress(XKeyEvent *kev) {
385385 #ifdef EXT_COMMANDS
386386 /* external commands from commands.h */
387387 if (CLEANMASK(kev->state) & ControlMask) {
388− for (x = 0; x < LEN(commands); ++x) {
389− if (commands[x].ksym == ksym) {
388+ for (i = 0; i < LEN(commands); ++i) {
389+ if (commands[i].ksym == ksym) {
390390 win_set_cursor(&win, CURSOR_WATCH);
391− if (run_command(commands[x].cmdline, commands[x].reload)) {
391+ if (run_command(commands[i].cmdline, commands[i].reload)) {
392392 if (mode == MODE_NORMAL) {
393393 img_close(&img, 1);
394394 load_image(fileidx);
@@ -571,6 +571,38 @@ void on_keypress(XKeyEvent *kev) {
571571 win_toggle_fullscreen(&win);
572572 /* render on next configurenotify */
573573 break;
574+
575+ case XK_D:
576+ if (mode == MODE_THUMBS) {
577+ if (tns.sel >= tns.cnt)
578+ break;
579+ i = tns.sel;
580+ } else {
581+ i = fileidx;
582+ }
583+ if (filecnt == 1) {
584+ cleanup();
585+ exit(0);
586+ }
587+ if (i + 1 < filecnt)
588+ memmove(filenames + i, filenames + i + 1, (filecnt - i - 1) *
589+ sizeof(const char*));
590+ else if (fileidx)
591+ fileidx--;
592+ if (i + 1 < tns.cnt) {
593+ memmove(tns.thumbs + i, tns.thumbs + i + 1, (tns.cnt - i - 1) *
594+ sizeof(thumb_t));
595+ memset(tns.thumbs + tns.cnt - 1, 0, sizeof(thumb_t));
596+ } else if (tns.sel) {
597+ tns.sel--;
598+ }
599+ filecnt--;
600+ if (mode == MODE_NORMAL)
601+ load_image(fileidx);
602+ if (i < tns.cnt)
603+ tns.cnt--;
604+ changed = tns.dirty = 1;
605+ break;
574606 }
575607
576608 if (changed)
M sxiv.1 View
@@ -82,9 +82,6 @@ at startup.
8282 .B q
8383 Quit sxiv.
8484 .TP
85−.B Escape
86−Quit sxiv and return an exit value of 2.
87−.TP
8885 .B Return
8986 Switch to thumbnail mode; in thumbnail mode: open selected image.
9087 .SS Navigate image list
@@ -156,6 +153,10 @@ Toggle visibility of alpha-channel, i.e. image transparency.
156153 .TP
157154 .B r
158155 Reload image.
156+.TP
157+.B D
158+Remove image from file list and go to next image; in thumbnail mode: remove
159+selected image from file list and select next image.
159160 .SH MOUSE COMMANDS
160161 .SS Navigate image list
161162 .TP