From c4f26d0aa819e6038968d152c98198e48e52e8e1 Mon Sep 17 00:00:00 2001 From: jj Date: Fri, 28 Sep 2012 10:44:35 +0200 Subject: [PATCH] manipulator: make up/down keys wrap around --- plugins/manipulator.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index f3c6664a1..d676dc2a1 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -534,6 +534,8 @@ void viewscreen_unitlaborsst::feed(set *events) if (do_refresh_names) refreshNames(); + int old_sel_row = sel_row; + if (events->count(interface_key::CURSOR_UP) || events->count(interface_key::CURSOR_UPLEFT) || events->count(interface_key::CURSOR_UPRIGHT)) sel_row--; if (events->count(interface_key::CURSOR_UP_FAST) || events->count(interface_key::CURSOR_UPLEFT_FAST) || events->count(interface_key::CURSOR_UPRIGHT_FAST)) @@ -553,9 +555,20 @@ void viewscreen_unitlaborsst::feed(set *events) } if (sel_row < 0) - sel_row = 0; + { + if (old_sel_row == 0 && events->count(interface_key::CURSOR_UP)) + sel_row = units.size() - 1; + else + sel_row = 0; + } + if (sel_row > units.size() - 1) - sel_row = units.size() - 1; + { + if (old_sel_row == units.size()-1 && events->count(interface_key::CURSOR_DOWN)) + sel_row = 0; + else + sel_row = units.size() - 1; + } if (sel_row < first_row) first_row = sel_row;