aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandra Kosiacka <kosiacka@uni.coventry.ac.uk>2015-12-10 14:02:47 +0000
committerAleksandra Kosiacka <kosiacka@uni.coventry.ac.uk>2015-12-10 14:02:47 +0000
commita08087af7acde585e51a2ca0a32578fa28c5d733 (patch)
tree002eb93be4f38df1b2677e582c7365cb6cef0e2d
parent40003f9a45eaf69cc3aac8e5935ac87d80cc12f2 (diff)
downloadimv-a08087af7acde585e51a2ca0a32578fa28c5d733.tar.gz
add -l option for listing all open images on exit
fixes #43
-rw-r--r--doc/imv.15
-rw-r--r--src/main.c18
2 files changed, 18 insertions, 5 deletions
diff --git a/doc/imv.1 b/doc/imv.1
index a8896b8..0acf447 100644
--- a/doc/imv.1
+++ b/doc/imv.1
@@ -3,7 +3,7 @@
imv \- image viewer
.SH SYNOPSIS
.nf
-\fBimv\fP [-rfaudh] [-n <NUM|PATH>] [-b COLOR] [-e FONT:SIZE] [-t SECONDS] [images...]
+\fBimv\fP [-rfaudlh] [-n <NUM|PATH>] [-b COLOR] [-e FONT:SIZE] [-t SECONDS] [images...]
.fi
.sp
.SH DESCRIPTION
@@ -30,6 +30,9 @@ Use nearest neighbour resampling. Recommended for pixel art.
.B -d
Show overlay.
.TP
+.B -l
+List open files on exit.
+.TP
.B -h
Print help.
.SH OPTIONS
diff --git a/src/main.c b/src/main.c
index a63e0ce..eee5ef6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -36,6 +36,7 @@ struct {
int actual;
int nearest_neighbour;
int solid_bg;
+ int list;
unsigned int delay;
unsigned char bg_r;
unsigned char bg_g;
@@ -43,13 +44,13 @@ struct {
int overlay;
const char *start_at;
const char *font;
-} g_options = {0,0,0,0,0,1,0,0,0,0,0,NULL,"FreeMono:24"};
+} g_options = {0,0,0,0,0,1,0,0,0,0,0,0,NULL,"FreeMono:24"};
void print_usage(const char* name)
{
fprintf(stdout,
"imv %s\n"
- "Usage: %s [-rfaudh] [-n <NUM|PATH>] [-b BG] [-e FONT:SIZE] [-t SECONDS] [-] [images...]\n"
+ "Usage: %s [-rfaudlh] [-n <NUM|PATH>] [-b BG] [-e FONT:SIZE] [-t SECONDS] [-] [images...]\n"
"\n"
"Flags:\n"
" -: Read paths from stdin. One path per line.\n"
@@ -58,6 +59,7 @@ void print_usage(const char* name)
" -a: Default to images' actual size\n"
" -u: Use nearest neighbour resampling.\n"
" -d: Show overlay\n"
+ " -l: List open files on exit.\n"
" -h: Print this help\n"
"\n"
"Options:\n"
@@ -112,7 +114,7 @@ void parse_args(int argc, char** argv)
const char* name = argv[0];
char o;
- while((o = getopt(argc, argv, "firaudhn:b:e:t:")) != -1) {
+ while((o = getopt(argc, argv, "firaudhln:b:e:t:")) != -1) {
switch(o) {
case 'f': g_options.fullscreen = 1; break;
case 'i':
@@ -124,6 +126,7 @@ void parse_args(int argc, char** argv)
case 'u': g_options.nearest_neighbour = 1; break;
case 'd': g_options.overlay = 1; break;
case 'h': print_usage(name); exit(0); break;
+ case 'l': g_options.list = 1; break;
case 'n':
g_options.start_at = optarg;
break;
@@ -549,7 +552,14 @@ int main(int argc, char** argv)
/* sleep a little bit so we don't waste CPU time */
SDL_Delay(10);
}
-
+ while(g_options.list) {
+ const char *path = imv_navigator_selection(&nav);
+ if(!path) {
+ break;
+ }
+ fprintf(stdout, "%s\n", path);
+ imv_navigator_remove(&nav, path);
+ }
/* clean up our resources now that we're exiting */
imv_destroy_loader(&ldr);
imv_destroy_texture(&tex);