Procházet zdrojové kódy

New option: -a, do not filter out unsupported files

master
Bert před 13 roky
rodič
revize
facd7e3b42
7 změnil soubory, kde provedl 35 přidání a 15 odebrání
  1. +1
    -1
      Makefile
  2. +2
    -0
      README.md
  3. binární
      invalid.png
  4. +19
    -11
      main.c
  5. +6
    -2
      options.c
  6. +1
    -0
      options.h
  7. +6
    -1
      sxiv.1

+ 1
- 1
Makefile Zobrazit soubor

@@ -1,6 +1,6 @@
all: sxiv

VERSION=git-20110405
VERSION=git-20110406

CC?=gcc
PREFIX?=/usr/local


+ 2
- 0
README.md Zobrazit soubor

@@ -34,6 +34,8 @@ small previews is displayed, making it easy to choose an image to open.

sxiv supports the following command-line options:

-a Display all given files, do not filter out unsupported files
(shorter startup time for long file list or slow file types)
-d Scale all images to 100%, but fit large images into window
-F Use size-hints to make the window fixed/floating
-f Start in fullscreen mode


binární
invalid.png Zobrazit soubor

Před Za
Šířka: 32  |  Výška: 32  |  Velikost: 351 B

+ 19
- 11
main.c Zobrazit soubor

@@ -77,19 +77,22 @@ void cleanup() {
}

int load_image(int new) {
int ret = 0;
struct stat fstats;

if (new >= 0 && new < filecnt) {
win_set_cursor(&win, CURSOR_WATCH);
img_close(&img, 0);
fileidx = new;
if (!stat(filenames[fileidx], &fstats))
filesize = fstats.st_size;
else
filesize = 0;
return img_load(&img, filenames[fileidx]);
} else {
return 0;
if (!(ret = img_load(&img, filenames[fileidx])))
win_set_cursor(&win, CURSOR_NONE);
}

return ret;
}

int main(int argc, char **argv) {
@@ -199,7 +202,7 @@ int check_append(const char *filename) {
if (access(filename, R_OK)) {
warn("could not open file: %s", filename);
return 0;
} else if (img_check(filename)) {
} else if (options->all || img_check(filename)) {
if (fileidx == filecnt) {
filecnt *= 2;
filenames = (const char**) s_realloc(filenames,
@@ -353,10 +356,15 @@ unsigned char drag;
int mox, moy;

void redraw() {
if (mode == MODE_NORMAL)
if (mode == MODE_NORMAL) {
img_render(&img, &win);
else
if (timo_cursor)
win_set_cursor(&win, CURSOR_ARROW);
else if (!drag)
win_set_cursor(&win, CURSOR_NONE);
} else {
tns_render(&tns, &win);
}
update_title();
timo_redraw = 0;
}
@@ -390,7 +398,8 @@ void on_keypress(XKeyEvent *kev) {
}
redraw();
}
win_set_cursor(&win, mode == MODE_NORMAL ? CURSOR_NONE : CURSOR_ARROW);
if (mode == MODE_THUMBS)
win_set_cursor(&win, CURSOR_ARROW);
return;
}
}
@@ -515,7 +524,6 @@ void on_keypress(XKeyEvent *kev) {
case XK_Return:
load_image(tns.sel);
mode = MODE_NORMAL;
win_set_cursor(&win, CURSOR_NONE);
changed = 1;
break;

@@ -580,6 +588,9 @@ void on_buttonpress(XButtonEvent *bev) {
changed = 0;

if (mode == MODE_NORMAL) {
win_set_cursor(&win, CURSOR_ARROW);
timo_cursor = TO_CURSOR_HIDE;

switch (bev->button) {
case Button1:
if (fileidx + 1 < filecnt)
@@ -672,9 +683,6 @@ void run() {
timo_cursor = timo_redraw = 0;
drag = 0;

if (mode == MODE_NORMAL)
timo_cursor = TO_CURSOR_HIDE;

while (1) {
if (mode == MODE_THUMBS && tns.cnt < filecnt) {
win_set_cursor(&win, CURSOR_WATCH);


+ 6
- 2
options.c Zobrazit soubor

@@ -31,7 +31,7 @@ options_t _options;
const options_t *options = (const options_t*) &_options;

void print_usage() {
printf("usage: sxiv [-dFfhpqrstvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n");
printf("usage: sxiv [-adFfhpqrstvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n");
}

void print_version() {
@@ -51,14 +51,18 @@ void parse_options(int argc, char **argv) {
_options.fullscreen = 0;
_options.geometry = NULL;

_options.all = 0;
_options.quiet = 0;
_options.recursive = 0;

while ((opt = getopt(argc, argv, "dFfg:hpqrstvZz:")) != -1) {
while ((opt = getopt(argc, argv, "adFfg:hpqrstvZz:")) != -1) {
switch (opt) {
case '?':
print_usage();
exit(1);
case 'a':
_options.all = 1;
break;
case 'd':
_options.scalemode = SCALE_DOWN;
break;


+ 1
- 0
options.h Zobrazit soubor

@@ -35,6 +35,7 @@ typedef struct {
unsigned char fullscreen;
char *geometry;

unsigned char all;
unsigned char quiet;
unsigned char recursive;
} options_t;


+ 6
- 1
sxiv.1 Zobrazit soubor

@@ -3,7 +3,7 @@
sxiv \- Simple (or small or suckless) X Image Viewer
.SH SYNOPSIS
.B sxiv
.RB [ \-dFfhpqrstvZ ]
.RB [ \-adFfhpqrstvZ ]
.RB [ \-g
.IR GEOMETRY ]
.RB [ \-z
@@ -28,6 +28,11 @@ Please note, that the fullscreen mode requires an EWMH/NetWM compliant window
manager.
.SH OPTIONS
.TP
.B \-a
Display all given files, do not filter out unsupported files. This might result
in a much shorter startup time, when the file list is very long or contains
large files of slow loadable types, e.g. gif and progressive jpg.
.TP
.B \-d
Scale all images to 100%, but fit large images into window.
.TP


Načítá se…
Zrušit
Uložit