From 9587c93fd59d1e1972536e48797fa8c8648a82ff Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Tue, 22 Aug 2017 21:48:40 +0100 Subject: Reimplement -n flag --- src/imv.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/imv.c b/src/imv.c index 84e2317..63addcf 100644 --- a/src/imv.c +++ b/src/imv.c @@ -17,14 +17,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "imv.h" +#include #include #include #include -#include #include +#include +#include + #include #include -#include #include "commands.h" #include "list.h" @@ -364,6 +366,23 @@ int imv_run(struct imv *imv) if(!setup_window(imv)) return 1; + if(imv->starting_path) { + int index = imv_navigator_find_path(imv->navigator, imv->starting_path); + if(index == -1) { + index = (int) strtol(imv->starting_path, NULL, 10); + index -= 1; /* input is 1-indexed, internally we're 0 indexed */ + if(errno == EINVAL) { + index = -1; + } + } + + if(index >= 0) { + imv_navigator_select_str(imv->navigator, index); + } else { + fprintf(stderr, "Invalid starting image: %s\n", imv->starting_path); + } + } + /* cache current image's dimensions */ int iw = 0; int ih = 0; -- cgit v1.2.3