aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichal Koutenský <koutak.m@gmail.com>2015-11-13 21:54:38 +0100
committerHarry Jeffery <harry@exec64.co.uk>2015-11-13 21:45:01 +0000
commit0b2be425c3427f0c1d311b4523c107b25a0e8c0c (patch)
tree8f75040f5c5b682c7c4c2b10be93ba164a0f5e1f /src
parent33d2d45e4ec604dbcce84d8ca83dcb828c1eb1f2 (diff)
downloadimv-0b2be425c3427f0c1d311b4523c107b25a0e8c0c.tar.gz
sxiv-like 'start at' option
Diffstat (limited to 'src')
-rw-r--r--src/main.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index fc73455..9cd9563 100644
--- a/src/main.c
+++ b/src/main.c
@@ -31,13 +31,14 @@ struct {
int stdin;
int recursive;
int actual;
-} g_options = {0,0,0,0};
+ long int start_at;
+} g_options = {0,0,0,0,0};
void print_usage(const char* name)
{
fprintf(stdout,
"imv %s\n"
- "Usage: %s [-irfah] [images...]\n"
+ "Usage: %s [-irfah] [-n NUM] [images...]\n"
"\n"
"Flags:\n"
" -i: Read paths from stdin. One path per line.\n"
@@ -46,6 +47,9 @@ void print_usage(const char* name)
" -a: Default to images' actual size\n"
" -h: Print this help\n"
"\n"
+ "Options:\n"
+ " -n NUM: Starts at picture number NUM.\n"
+ "\n"
"Mouse:\n"
" Click+Drag to Pan\n"
" MouseWheel to Zoom\n"
@@ -88,8 +92,10 @@ void parse_args(int argc, char** argv)
const char* name = argv[0];
char o;
+ char* end;
+ long int n;
- while((o = getopt(argc, argv, "firah")) != -1) {
+ while((o = getopt(argc, argv, "firahn:")) != -1) {
switch(o) {
case 'f': g_options.fullscreen = 1; break;
case 'i':
@@ -99,6 +105,14 @@ void parse_args(int argc, char** argv)
case 'r': g_options.recursive = 1; break;
case 'a': g_options.actual = 1; break;
case 'h': print_usage(name); exit(0); break;
+ case 'n':
+ n = strtol(optarg,&end,0);
+ if(*end != '\0' || n <= 0) {
+ fprintf(stderr, "Warning: wrong value for '-n'.\n");
+ } else {
+ g_options.start_at = n - 1;
+ }
+ break;
case '?':
fprintf(stderr, "Unknown argument '%c'. Aborting.\n", optopt);
exit(1);
@@ -189,6 +203,10 @@ int main(int argc, char** argv)
double last_time = SDL_GetTicks() / 1000.0;
+ for(long int i = 0; i < g_options.start_at; ++i) {
+ imv_navigator_next_path(&nav);
+ }
+
int quit = 0;
while(!quit) {
SDL_Event e;