From ddd028eb3ea628855b4bb35ca7fb40562bd87861 Mon Sep 17 00:00:00 2001 From: Bert Münnich Date: Tue, 30 Sep 2014 21:54:17 +0200 Subject: Unified file count variable for image & thumbnail mode --- commands.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'commands.c') diff --git a/commands.c b/commands.c index afe3e00..26ac483 100644 --- a/commands.c +++ b/commands.c @@ -77,7 +77,7 @@ bool cg_switch_mode(arg_t a) { if (mode == MODE_IMAGE) { if (tns.thumbs == NULL) - tns_init(&tns, files, filecnt, &fileidx, &win); + tns_init(&tns, files, &filecnt, &fileidx, &win); img_close(&img, false); reset_timeout(reset_cursor); if (img.ss.on) { @@ -140,17 +140,12 @@ bool cg_reload_image(arg_t a) bool cg_remove_image(arg_t a) { - if (mode == MODE_IMAGE) { - remove_file(fileidx, true); - load_image(fileidx >= filecnt ? filecnt - 1 : fileidx); - return true; - } else if (fileidx < tns.cnt) { - remove_file(fileidx, true); + remove_file(fileidx, true); + if (mode == MODE_IMAGE) + load_image(fileidx); + else tns.dirty = true; - return true; - } else { - return false; - } + return true; } bool cg_first(arg_t a) @@ -245,12 +240,12 @@ bool cg_navigate_marked(arg_t a) { long n = (long) a; int d, i; - int cnt = mode == MODE_IMAGE ? filecnt : tns.cnt, new = fileidx; + int new = fileidx; if (prefix > 0) n *= prefix; d = n > 0 ? 1 : -1; - for (i = fileidx + d; n != 0 && i >= 0 && i < cnt; i += d) { + for (i = fileidx + d; n != 0 && i >= 0 && i < filecnt; i += d) { if (files[i].marked) { n -= d; new = i; @@ -471,7 +466,7 @@ bool ct_move_sel(arg_t a) bool ct_reload_all(arg_t a) { tns_free(&tns); - tns_init(&tns, files, filecnt, &fileidx, &win); + tns_init(&tns, files, &filecnt, &fileidx, &win); tns.dirty = true; return true; } -- cgit v1.2.3-54-g00ecf