diff options
author | Bert Münnich <ber.t@gmx.com> | 2011-10-16 16:08:55 +0200 |
---|---|---|
committer | Bert Münnich <ber.t@gmx.com> | 2011-10-16 16:08:55 +0200 |
commit | dc727b8dce89811d755ed03d11688b13a42e794a (patch) | |
tree | 09b19fc4cff7b12c1ae2ef6ff626175f1a4674ad /commands.c | |
parent | 960026d600d3824832dc83f925962f2d2d5839d7 (diff) | |
download | nsxiv-dc727b8dce89811d755ed03d11688b13a42e794a.tar.zst |
Added support for number prefix for commands
Diffstat (limited to 'commands.c')
-rw-r--r-- | commands.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -46,6 +46,8 @@ extern win_t win; extern fileinfo_t *files; extern int filecnt, fileidx; +extern int prefix; + bool it_quit(arg_t a) { cleanup(); exit(EXIT_SUCCESS); @@ -143,12 +145,14 @@ bool it_first(arg_t a) { } } -bool it_last(arg_t a) { - if (mode == MODE_IMAGE && fileidx != filecnt - 1) { - load_image(filecnt - 1); +bool it_n_or_last(arg_t a) { + int n = prefix != 0 && prefix - 1 < filecnt ? prefix - 1 : filecnt - 1; + + if (mode == MODE_IMAGE && fileidx != n) { + load_image(n); return true; - } else if (mode == MODE_THUMB && tns.sel != tns.cnt - 1) { - tns.sel = tns.cnt - 1; + } else if (mode == MODE_THUMB && tns.sel != n) { + tns.sel = n; tns.dirty = true; return true; } else { |