]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[settings] Return to first row on navigating to a new settings block
authorMichael Brown <mcb30@ipxe.org>
Wed, 23 Mar 2011 01:49:00 +0000 (01:49 +0000)
committerMichael Brown <mcb30@ipxe.org>
Wed, 23 Mar 2011 01:51:02 +0000 (01:51 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/hci/tui/settings_ui.c

index b40cd0af9b8d3a1d9a29be695adadf041845a449..b33d929a096babb5d260c7878c68f2b4ce29d775 100644 (file)
@@ -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 );