From f0cd4abd0780606e04b007251e91621695ba259b Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 23 Mar 2011 01:49:00 +0000 Subject: [PATCH] [settings] Return to first row on navigating to a new settings block Signed-off-by: Michael Brown --- src/hci/tui/settings_ui.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/hci/tui/settings_ui.c b/src/hci/tui/settings_ui.c index b40cd0af9..b33d929a0 100644 --- a/src/hci/tui/settings_ui.c +++ b/src/hci/tui/settings_ui.c @@ -444,6 +444,7 @@ static void init_widget ( struct setting_widget *widget, static int main_loop ( struct settings *settings ) { struct setting_widget widget; int redraw = 1; + int move; unsigned int next; int key; int rc; @@ -497,15 +498,15 @@ static int main_loop ( struct settings *settings ) { /* Process keypress */ key = getkey ( 0 ); - next = widget.current; + move = 0; switch ( key ) { case KEY_DOWN: if ( widget.current < ( widget.num_rows - 1 ) ) - next++; + move = +1; break; case KEY_UP: if ( widget.current > 0 ) - next--; + move = -1; break; case CTRL_D: if ( ! widget.row.setting ) @@ -534,7 +535,8 @@ static int main_loop ( struct settings *settings ) { } break; } - if ( next != widget.current ) { + if ( move ) { + next = ( widget.current + move ); draw_setting_row ( &widget ); redraw = 1; reveal_setting_row ( &widget, next );