aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Stallinger <astallinger@posteo.net>2019-05-16 13:29:08 +0200
committerHarry Jeffery <harry@exec64.co.uk>2019-07-24 22:52:32 +0100
commita3402091ca02329d5d31d8fe8768e04d6285bd13 (patch)
tree4b9877d17be7328cd6dade4942f64b36122ecd2c
parente37e5c02da64f2ab3d4f716c9139d4b1fc17ef2d (diff)
downloadimv-a3402091ca02329d5d31d8fe8768e04d6285bd13.tar.gz
Improve select_rel
select_rel was capped to -1 and 1 before
-rw-r--r--src/navigator.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/navigator.c b/src/navigator.c
index b4c5107..46bae67 100644
--- a/src/navigator.c
+++ b/src/navigator.c
@@ -127,21 +127,21 @@ void imv_navigator_select_rel(struct imv_navigator *nav, int direction)
}
if (direction > 1) {
- direction = 1;
+ direction = direction % nav->num_paths;
} else if (direction < -1) {
- direction = -1;
+ direction = direction % nav->num_paths;
} else if (direction == 0) {
return;
}
nav->cur_path += direction;
- if (nav->cur_path == nav->num_paths) {
+ if (nav->cur_path >= nav->num_paths) {
/* Wrap after the end of the list */
- nav->cur_path = 0;
+ nav->cur_path = nav->cur_path - nav->num_paths;
nav->wrapped = 1;
} else if (nav->cur_path < 0) {
/* Wrap before the start of the list */
- nav->cur_path = nav->num_paths - 1;
+ nav->cur_path = nav->num_paths + nav->cur_path;
nav->wrapped = 1;
}
nav->last_move_direction = direction;