diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2017-11-23 21:33:33 +0000 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2017-11-23 22:18:28 +0000 |
commit | 65c9826bab96fe9925b7bc03caec2298f57a04a0 (patch) | |
tree | 24e17cf1dbf8e0023084f660aedbfc70d0599c5b /src/navigator.c | |
parent | 599a48746a6ff07405dc9abcfb872cca58e4aa47 (diff) | |
download | imv-65c9826bab96fe9925b7bc03caec2298f57a04a0.tar.gz |
Move remaining actions to bindable commands
Diffstat (limited to 'src/navigator.c')
-rw-r--r-- | src/navigator.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/navigator.c b/src/navigator.c index 60e98af..9defcbc 100644 --- a/src/navigator.c +++ b/src/navigator.c @@ -130,7 +130,7 @@ const char *imv_navigator_selection(struct imv_navigator *nav) void imv_navigator_select_rel(struct imv_navigator *nav, int direction) { - int prev_path = nav->cur_path; + const int prev_path = nav->cur_path; if(nav->num_paths == 0) { return; } @@ -158,6 +158,29 @@ void imv_navigator_select_rel(struct imv_navigator *nav, int direction) return; } +void imv_navigator_select_abs(struct imv_navigator *nav, int index) +{ + const int prev_path = nav->cur_path; + /* allow -1 to indicate the last image */ + if(index < 0) { + index += nav->num_paths; + + /* but if they go farther back than the first image, stick to first image */ + if(index < 0) { + index = 0; + } + } + + /* stick to last image if we go beyond it */ + if(index >= nav->num_paths) { + index = nav->num_paths - 1; + } + + nav->cur_path = index; + nav->changed = prev_path != nav->cur_path; + nav->last_move_direction = (index >= prev_path) ? 1 : -1; +} + void imv_navigator_remove(struct imv_navigator *nav, const char *path) { int removed = -1; |