summaryrefslogtreecommitdiffstats
path: root/source/view.c
diff options
context:
space:
mode:
authorYaroslav <valsoray17@users.noreply.github.com>2016-05-25 14:40:23 -0400
committerDave Davenport <DaveDavenport@users.noreply.github.com>2016-05-25 20:40:23 +0200
commitf901494c6a8826023902ced568f24c39300788f4 (patch)
tree2797c6467c88614cfa97e48919ccaef88d4d985b /source/view.c
parent17e93986993ab7dd9121aa39d66d3696fc66b35d (diff)
Switch to stop cycling feature (#407)
* Added 'cycle' option to switch list navigation wrapping * Replaced tabs with spaces * Updating the expected rofi properties with 'cycle' option * Updating documentation with the 'cycle' option
Diffstat (limited to 'source/view.c')
-rw-r--r--source/view.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/source/view.c b/source/view.c
index 320a5db2..ea53f2b5 100644
--- a/source/view.c
+++ b/source/view.c
@@ -798,14 +798,16 @@ inline static void rofi_view_nav_left ( RofiViewState *state )
*/
inline static void rofi_view_nav_up ( RofiViewState *state )
{
+ // If no lines or don't cycle, do nothing.
+ if ( state->filtered_lines == 0 || ( state->selected == 0 && !config.cycle ) ) {
+ return;
+ }
+
// Wrap around.
if ( state->selected == 0 ) {
state->selected = state->filtered_lines;
}
-
- if ( state->selected > 0 ) {
- state->selected--;
- }
+ state->selected--;
state->update = TRUE;
}
@@ -817,8 +819,8 @@ inline static void rofi_view_nav_up ( RofiViewState *state )
*/
inline static void rofi_view_nav_down ( RofiViewState *state )
{
- // If no lines, do nothing.
- if ( state->filtered_lines == 0 ) {
+ // If no lines or don't cycle, do nothing.
+ if ( state->filtered_lines == 0 || ( state->selected == state->filtered_lines - 1 && !config.cycle ) ) {
return;
}
state->selected = state->selected < state->filtered_lines - 1 ? MIN ( state->filtered_lines - 1, state->selected + 1 ) : 0;