aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2017-03-08 21:16:30 +0000
committerGitHub <noreply@github.com>2017-03-08 21:16:30 +0000
commitcee36733b5db5dcd0b479663000f889788468c80 (patch)
treed3aa4cd11ff9671dc2cfe0d89677f95f2892798e
parentf489b0363b059aa7161d2a92a98c2dc8c067b8a8 (diff)
parentffffb53a1d2c21fa5334b78a1f2bf0b440ebbeb6 (diff)
downloadimv-cee36733b5db5dcd0b479663000f889788468c80.tar.gz
Merge pull request #104 from alkino/master
Add command 'X' to remove image from disk too
-rw-r--r--doc/imv.12
-rw-r--r--src/main.c12
2 files changed, 13 insertions, 1 deletions
diff --git a/doc/imv.1 b/doc/imv.1
index 1f20b34..ca416c4 100644
--- a/doc/imv.1
+++ b/doc/imv.1
@@ -117,6 +117,8 @@ Pan up.
Pan right.
.It Cm x
Close current image.
+.It Cm X
+Close current image and remove it from disk.
.It Cm d
Toggle display of textual overlay.
.It Cm f
diff --git a/src/main.c b/src/main.c
index a8396aa..1e3df67 100644
--- a/src/main.c
+++ b/src/main.c
@@ -417,7 +417,17 @@ int main(int argc, char** argv)
break;
case SDLK_x:
if(!e.key.repeat) {
- imv_navigator_remove(&nav, imv_navigator_selection(&nav));
+ char* path = strdup(imv_navigator_selection(&nav));
+ imv_navigator_remove(&nav, path);
+
+ if (SDL_GetModState() & KMOD_SHIFT) {
+ if (remove(path)) {
+ fprintf(stderr, "Warning: can't remove %s from disk.\n", path);
+ }
+ }
+
+ free(path);
+
/* reset slideshow delay */
delay_msec = 0;
}