nsxivfacd7e3
New option: -a, do not filter out unsupported files
+35 −15
7 files changed
- M Makefile +1 −1
- M README.md +2 −0
- A invalid.png
- M main.c +19 −11
- M options.c +6 −2
- M options.h +1 −0
- M sxiv.1 +6 −1
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | all: sxiv | |
| 2 | 2 | ||
| 3 | − | VERSION=git-20110405 | |
| 3 | + | VERSION=git-20110406 | |
| 4 | 4 | ||
| 5 | 5 | CC?=gcc | |
| 6 | 6 | PREFIX?=/usr/local | |
| @@ -34,6 +34,8 @@ small previews is displayed, making it easy to choose an image to open. | |||
| 34 | 34 | ||
| 35 | 35 | sxiv supports the following command-line options: | |
| 36 | 36 | ||
| 37 | + | -a Display all given files, do not filter out unsupported files | |
| 38 | + | (shorter startup time for long file list or slow file types) | |
| 37 | 39 | -d Scale all images to 100%, but fit large images into window | |
| 38 | 40 | -F Use size-hints to make the window fixed/floating | |
| 39 | 41 | -f Start in fullscreen mode | |
[Binary file]
| @@ -77,19 +77,22 @@ void cleanup() { | |||
| 77 | 77 | } | |
| 78 | 78 | ||
| 79 | 79 | int load_image(int new) { | |
| 80 | + | int ret = 0; | |
| 80 | 81 | struct stat fstats; | |
| 81 | 82 | ||
| 82 | 83 | if (new >= 0 && new < filecnt) { | |
| 84 | + | win_set_cursor(&win, CURSOR_WATCH); | |
| 83 | 85 | img_close(&img, 0); | |
| 84 | 86 | fileidx = new; | |
| 85 | 87 | if (!stat(filenames[fileidx], &fstats)) | |
| 86 | 88 | filesize = fstats.st_size; | |
| 87 | 89 | else | |
| 88 | 90 | filesize = 0; | |
| 89 | − | return img_load(&img, filenames[fileidx]); | |
| 90 | − | } else { | |
| 91 | − | return 0; | |
| 91 | + | if (!(ret = img_load(&img, filenames[fileidx]))) | |
| 92 | + | win_set_cursor(&win, CURSOR_NONE); | |
| 92 | 93 | } | |
| 94 | + | ||
| 95 | + | return ret; | |
| 93 | 96 | } | |
| 94 | 97 | ||
| 95 | 98 | int main(int argc, char **argv) { | |
| @@ -199,7 +202,7 @@ int check_append(const char *filename) { | |||
| 199 | 202 | if (access(filename, R_OK)) { | |
| 200 | 203 | warn("could not open file: %s", filename); | |
| 201 | 204 | return 0; | |
| 202 | − | } else if (img_check(filename)) { | |
| 205 | + | } else if (options->all || img_check(filename)) { | |
| 203 | 206 | if (fileidx == filecnt) { | |
| 204 | 207 | filecnt *= 2; | |
| 205 | 208 | filenames = (const char**) s_realloc(filenames, | |
| @@ -353,10 +356,15 @@ unsigned char drag; | |||
| 353 | 356 | int mox, moy; | |
| 354 | 357 | ||
| 355 | 358 | void redraw() { | |
| 356 | − | if (mode == MODE_NORMAL) | |
| 359 | + | if (mode == MODE_NORMAL) { | |
| 357 | 360 | img_render(&img, &win); | |
| 358 | − | else | |
| 361 | + | if (timo_cursor) | |
| 362 | + | win_set_cursor(&win, CURSOR_ARROW); | |
| 363 | + | else if (!drag) | |
| 364 | + | win_set_cursor(&win, CURSOR_NONE); | |
| 365 | + | } else { | |
| 359 | 366 | tns_render(&tns, &win); | |
| 367 | + | } | |
| 360 | 368 | update_title(); | |
| 361 | 369 | timo_redraw = 0; | |
| 362 | 370 | } | |
| @@ -390,7 +398,8 @@ void on_keypress(XKeyEvent *kev) { | |||
| 390 | 398 | } | |
| 391 | 399 | redraw(); | |
| 392 | 400 | } | |
| 393 | − | win_set_cursor(&win, mode == MODE_NORMAL ? CURSOR_NONE : CURSOR_ARROW); | |
| 401 | + | if (mode == MODE_THUMBS) | |
| 402 | + | win_set_cursor(&win, CURSOR_ARROW); | |
| 394 | 403 | return; | |
| 395 | 404 | } | |
| 396 | 405 | } | |
| @@ -515,7 +524,6 @@ void on_keypress(XKeyEvent *kev) { | |||
| 515 | 524 | case XK_Return: | |
| 516 | 525 | load_image(tns.sel); | |
| 517 | 526 | mode = MODE_NORMAL; | |
| 518 | − | win_set_cursor(&win, CURSOR_NONE); | |
| 519 | 527 | changed = 1; | |
| 520 | 528 | break; | |
| 521 | 529 | ||
| @@ -580,6 +588,9 @@ void on_buttonpress(XButtonEvent *bev) { | |||
| 580 | 588 | changed = 0; | |
| 581 | 589 | ||
| 582 | 590 | if (mode == MODE_NORMAL) { | |
| 591 | + | win_set_cursor(&win, CURSOR_ARROW); | |
| 592 | + | timo_cursor = TO_CURSOR_HIDE; | |
| 593 | + | ||
| 583 | 594 | switch (bev->button) { | |
| 584 | 595 | case Button1: | |
| 585 | 596 | if (fileidx + 1 < filecnt) | |
| @@ -672,9 +683,6 @@ void run() { | |||
| 672 | 683 | timo_cursor = timo_redraw = 0; | |
| 673 | 684 | drag = 0; | |
| 674 | 685 | ||
| 675 | − | if (mode == MODE_NORMAL) | |
| 676 | − | timo_cursor = TO_CURSOR_HIDE; | |
| 677 | − | ||
| 678 | 686 | while (1) { | |
| 679 | 687 | if (mode == MODE_THUMBS && tns.cnt < filecnt) { | |
| 680 | 688 | win_set_cursor(&win, CURSOR_WATCH); | |
| @@ -31,7 +31,7 @@ options_t _options; | |||
| 31 | 31 | const options_t *options = (const options_t*) &_options; | |
| 32 | 32 | ||
| 33 | 33 | void print_usage() { | |
| 34 | − | printf("usage: sxiv [-dFfhpqrstvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n"); | |
| 34 | + | printf("usage: sxiv [-adFfhpqrstvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n"); | |
| 35 | 35 | } | |
| 36 | 36 | ||
| 37 | 37 | void print_version() { | |
| @@ -51,14 +51,18 @@ void parse_options(int argc, char **argv) { | |||
| 51 | 51 | _options.fullscreen = 0; | |
| 52 | 52 | _options.geometry = NULL; | |
| 53 | 53 | ||
| 54 | + | _options.all = 0; | |
| 54 | 55 | _options.quiet = 0; | |
| 55 | 56 | _options.recursive = 0; | |
| 56 | 57 | ||
| 57 | − | while ((opt = getopt(argc, argv, "dFfg:hpqrstvZz:")) != -1) { | |
| 58 | + | while ((opt = getopt(argc, argv, "adFfg:hpqrstvZz:")) != -1) { | |
| 58 | 59 | switch (opt) { | |
| 59 | 60 | case '?': | |
| 60 | 61 | print_usage(); | |
| 61 | 62 | exit(1); | |
| 63 | + | case 'a': | |
| 64 | + | _options.all = 1; | |
| 65 | + | break; | |
| 62 | 66 | case 'd': | |
| 63 | 67 | _options.scalemode = SCALE_DOWN; | |
| 64 | 68 | break; | |
| @@ -35,6 +35,7 @@ typedef struct { | |||
| 35 | 35 | unsigned char fullscreen; | |
| 36 | 36 | char *geometry; | |
| 37 | 37 | ||
| 38 | + | unsigned char all; | |
| 38 | 39 | unsigned char quiet; | |
| 39 | 40 | unsigned char recursive; | |
| 40 | 41 | } options_t; | |
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | sxiv \- Simple (or small or suckless) X Image Viewer | |
| 4 | 4 | .SH SYNOPSIS | |
| 5 | 5 | .B sxiv | |
| 6 | − | .RB [ \-dFfhpqrstvZ ] | |
| 6 | + | .RB [ \-adFfhpqrstvZ ] | |
| 7 | 7 | .RB [ \-g | |
| 8 | 8 | .IR GEOMETRY ] | |
| 9 | 9 | .RB [ \-z | |
| @@ -28,6 +28,11 @@ Please note, that the fullscreen mode requires an EWMH/NetWM compliant window | |||
| 28 | 28 | manager. | |
| 29 | 29 | .SH OPTIONS | |
| 30 | 30 | .TP | |
| 31 | + | .B \-a | |
| 32 | + | Display all given files, do not filter out unsupported files. This might result | |
| 33 | + | in a much shorter startup time, when the file list is very long or contains | |
| 34 | + | large files of slow loadable types, e.g. gif and progressive jpg. | |
| 35 | + | .TP | |
| 31 | 36 | .B \-d | |
| 32 | 37 | Scale all images to 100%, but fit large images into window. | |
| 33 | 38 | .TP | |