From a3402091ca02329d5d31d8fe8768e04d6285bd13 Mon Sep 17 00:00:00 2001 From: Andreas Stallinger Date: Thu, 16 May 2019 13:29:08 +0200 Subject: Improve select_rel select_rel was capped to -1 and 1 before --- src/navigator.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/navigator.c') 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; -- cgit v1.2.3