New option: -n, start at given picture
This commit is contained in:
parent
00e6cd2bd1
commit
2252a0148d
2
Makefile
2
Makefile
|
@ -1,6 +1,6 @@
|
|||
all: sxiv
|
||||
|
||||
VERSION=git-20110522
|
||||
VERSION=git-20110525
|
||||
|
||||
CC?=gcc
|
||||
DESTDIR?=
|
||||
|
|
|
@ -40,6 +40,7 @@ sxiv supports the following command-line options:
|
|||
-f Start in fullscreen mode
|
||||
-g GEOMETRY Set window position and size
|
||||
(see section GEOMETRY SPECIFICATIONS of X(7))
|
||||
-n NUM Start at picture NUM
|
||||
-p Pixelize, i.e. turn off image anti-aliasing
|
||||
-q Be quiet, disable warnings
|
||||
-r Search given directories recursively for images
|
||||
|
|
8
main.c
8
main.c
|
@ -231,14 +231,14 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
filecnt = fileidx;
|
||||
fileidx = 0;
|
||||
|
||||
if (!filecnt) {
|
||||
if (!fileidx) {
|
||||
fprintf(stderr, "sxiv: no valid image file given, aborting\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
filecnt = fileidx;
|
||||
fileidx = options->startnum < filecnt ? options->startnum : filecnt - 1;
|
||||
|
||||
win_init(&win);
|
||||
img_init(&img, &win);
|
||||
|
||||
|
|
17
options.c
17
options.c
|
@ -31,7 +31,7 @@ options_t _options;
|
|||
const options_t *options = (const options_t*) &_options;
|
||||
|
||||
void print_usage() {
|
||||
printf("usage: sxiv [-cdFfhpqrstvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n");
|
||||
printf("usage: sxiv [-cdFfhpqrstvZ] [-g GEOMETRY] [-n NUM] [-z ZOOM] FILES...\n");
|
||||
}
|
||||
|
||||
void print_version() {
|
||||
|
@ -40,7 +40,9 @@ void print_version() {
|
|||
|
||||
void parse_options(int argc, char **argv) {
|
||||
float z;
|
||||
int opt;
|
||||
int n, opt;
|
||||
|
||||
_options.startnum = 0;
|
||||
|
||||
_options.scalemode = SCALE_MODE;
|
||||
_options.zoom = 1.0;
|
||||
|
@ -55,7 +57,7 @@ void parse_options(int argc, char **argv) {
|
|||
_options.clean_cache = 0;
|
||||
_options.recursive = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "cdFfg:hpqrstvZz:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "cdFfg:hn:pqrstvZz:")) != -1) {
|
||||
switch (opt) {
|
||||
case '?':
|
||||
print_usage();
|
||||
|
@ -78,6 +80,15 @@ void parse_options(int argc, char **argv) {
|
|||
case 'h':
|
||||
print_usage();
|
||||
exit(0);
|
||||
case 'n':
|
||||
if (!sscanf(optarg, "%d", &n) || n < 1) {
|
||||
fprintf(stderr, "sxiv: invalid argument for option -n: %s\n",
|
||||
optarg);
|
||||
exit(1);
|
||||
} else {
|
||||
_options.startnum = n - 1;
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
_options.aa = 0;
|
||||
break;
|
||||
|
|
|
@ -23,8 +23,9 @@
|
|||
|
||||
typedef struct {
|
||||
const char **filenames;
|
||||
int filecnt;
|
||||
unsigned char from_stdin;
|
||||
int filecnt;
|
||||
int startnum;
|
||||
|
||||
scalemode_t scalemode;
|
||||
float zoom;
|
||||
|
|
5
sxiv.1
5
sxiv.1
|
@ -6,6 +6,8 @@ sxiv \- Simple (or small or suckless) X Image Viewer
|
|||
.RB [ \-cdFfhpqrstvZ ]
|
||||
.RB [ \-g
|
||||
.IR GEOMETRY ]
|
||||
.RB [ \-n
|
||||
.IR NUM ]
|
||||
.RB [ \-z
|
||||
.IR ZOOM ]
|
||||
.IR FILE ...
|
||||
|
@ -49,6 +51,9 @@ Set window position and size. See section GEOMETRY SPECIFICATIONS of X(7) for
|
|||
more information on
|
||||
.IR GEOMETRY .
|
||||
.TP
|
||||
.BI "\-n " NUM
|
||||
Start at picture number NUM.
|
||||
.TP
|
||||
.B \-h
|
||||
Print brief usage information to standard output and exit.
|
||||
.TP
|
||||
|
|
Loading…
Reference in a new issue