From f2a3d73212ad63e1081278347c189f2554cab8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bert=20M=C3=BCnnich?= Date: Thu, 16 Aug 2012 13:40:04 +0200 Subject: New command: i_alternate, go to last image, issue #65 --- commands.c | 10 ++++++++++ commands.h | 1 + config.def.h | 1 + main.c | 2 ++ 4 files changed, 14 insertions(+) diff --git a/commands.c b/commands.c index 8868091..e742016 100644 --- a/commands.c +++ b/commands.c @@ -46,6 +46,7 @@ extern win_t win; extern fileinfo_t *files; extern int filecnt, fileidx; +extern int alternate; extern int prefix; @@ -155,6 +156,15 @@ bool i_navigate(arg_t a) { return false; } +bool i_alternate(arg_t a) { + if (mode == MODE_IMAGE) { + load_image(alternate); + return true; + } else { + return false; + } +} + bool it_first(arg_t a) { if (mode == MODE_IMAGE && fileidx != 0) { load_image(0); diff --git a/commands.h b/commands.h index 0e324c8..3c00718 100644 --- a/commands.h +++ b/commands.h @@ -49,6 +49,7 @@ bool t_reload_all(arg_t); bool it_reload_image(arg_t); bool it_remove_image(arg_t); bool i_navigate(arg_t); +bool i_alternate(arg_t); bool it_first(arg_t); bool it_n_or_last(arg_t); bool i_navigate_frame(arg_t); diff --git a/config.def.h b/config.def.h index 49dac49..42e1774 100644 --- a/config.def.h +++ b/config.def.h @@ -73,6 +73,7 @@ static const keymap_t keys[] = { { false, XK_BackSpace, i_navigate, (arg_t) -1 }, { false, XK_bracketright, i_navigate, (arg_t) +10 }, { false, XK_bracketleft, i_navigate, (arg_t) -10 }, + { true, XK_6, i_alternate, (arg_t) None }, { false, XK_g, it_first, (arg_t) None }, { false, XK_G, it_n_or_last, (arg_t) None }, diff --git a/main.c b/main.c index 2483d10..5f8a0ca 100644 --- a/main.c +++ b/main.c @@ -62,6 +62,7 @@ win_t win; fileinfo_t *files; int filecnt, fileidx; +int alternate; size_t filesize; int prefix; @@ -217,6 +218,7 @@ void load_image(int new) { } files[new].loaded = true; + alternate = fileidx; fileidx = new; if (stat(files[new].path, &fstats) == 0) filesize = fstats.st_size; -- cgit v1.2.3