nsxivfa81707
New key mapping: D, remove image from file list
+42 −8
3 files changed
| @@ -53,7 +53,6 @@ sxiv supports the following command-line options: | |||
| 53 | 53 | Use the following keys to control the basic behaviour of sxiv: | |
| 54 | 54 | ||
| 55 | 55 | q Quit sxiv | |
| 56 | − | Escape Quit sxiv and return an exit value of 2 (useful for scripting) | |
| 57 | 56 | f Toggle fullscreen mode (requires an EWMH/NetWM compliant | |
| 58 | 57 | window manager) | |
| 59 | 58 | ||
| @@ -73,6 +72,7 @@ Inside image view mode, the following key mappings are available: | |||
| 73 | 72 | a Toggle anti-aliasing | |
| 74 | 73 | A Toggle visibility of alpha-channel, i.e. transparency | |
| 75 | 74 | r Reload image | |
| 75 | + | D Remove image from file list and go to next image | |
| 76 | 76 | Return Switch to thumbnail mode | |
| 77 | 77 | ||
| 78 | 78 | Additionally, the image view offers the following mouse commands: | |
| @@ -91,6 +91,7 @@ In thumbnail mode, the following key and mouse mappings are available: | |||
| 91 | 91 | ||
| 92 | 92 | h,j,k,l Move selection left/down/up/right (also with arrow keys) | |
| 93 | 93 | g/G Move selection to first/last image | |
| 94 | + | D Remove selected image from file list and select next image | |
| 94 | 95 | Return Open selected image | |
| 95 | 96 | ||
| 96 | 97 | Button1 Select image/open image if it is already selected | |
| @@ -370,7 +370,7 @@ void redraw() { | |||
| 370 | 370 | } | |
| 371 | 371 | ||
| 372 | 372 | void on_keypress(XKeyEvent *kev) { | |
| 373 | − | int x, y; | |
| 373 | + | int i, x, y; | |
| 374 | 374 | unsigned int w, h; | |
| 375 | 375 | char key; | |
| 376 | 376 | KeySym ksym; | |
| @@ -385,10 +385,10 @@ void on_keypress(XKeyEvent *kev) { | |||
| 385 | 385 | #ifdef EXT_COMMANDS | |
| 386 | 386 | /* external commands from commands.h */ | |
| 387 | 387 | 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) { | |
| 390 | 390 | 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)) { | |
| 392 | 392 | if (mode == MODE_NORMAL) { | |
| 393 | 393 | img_close(&img, 1); | |
| 394 | 394 | load_image(fileidx); | |
| @@ -571,6 +571,38 @@ void on_keypress(XKeyEvent *kev) { | |||
| 571 | 571 | win_toggle_fullscreen(&win); | |
| 572 | 572 | /* render on next configurenotify */ | |
| 573 | 573 | 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; | |
| 574 | 606 | } | |
| 575 | 607 | ||
| 576 | 608 | if (changed) | |
| @@ -82,9 +82,6 @@ at startup. | |||
| 82 | 82 | .B q | |
| 83 | 83 | Quit sxiv. | |
| 84 | 84 | .TP | |
| 85 | − | .B Escape | |
| 86 | − | Quit sxiv and return an exit value of 2. | |
| 87 | − | .TP | |
| 88 | 85 | .B Return | |
| 89 | 86 | Switch to thumbnail mode; in thumbnail mode: open selected image. | |
| 90 | 87 | .SS Navigate image list | |
| @@ -156,6 +153,10 @@ Toggle visibility of alpha-channel, i.e. image transparency. | |||
| 156 | 153 | .TP | |
| 157 | 154 | .B r | |
| 158 | 155 | 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. | |
| 159 | 160 | .SH MOUSE COMMANDS | |
| 160 | 161 | .SS Navigate image list | |
| 161 | 162 | .TP | |