Browse Source

[settings] Return to first row on navigating to a new settings block

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
f0cd4abd07
1 changed files with 6 additions and 4 deletions
  1. 6
    4
      src/hci/tui/settings_ui.c

+ 6
- 4
src/hci/tui/settings_ui.c View File

444
 static int main_loop ( struct settings *settings ) {
444
 static int main_loop ( struct settings *settings ) {
445
 	struct setting_widget widget;
445
 	struct setting_widget widget;
446
 	int redraw = 1;
446
 	int redraw = 1;
447
+	int move;
447
 	unsigned int next;
448
 	unsigned int next;
448
 	int key;
449
 	int key;
449
 	int rc;
450
 	int rc;
497
 
498
 
498
 			/* Process keypress */
499
 			/* Process keypress */
499
 			key = getkey ( 0 );
500
 			key = getkey ( 0 );
500
-			next = widget.current;
501
+			move = 0;
501
 			switch ( key ) {
502
 			switch ( key ) {
502
 			case KEY_DOWN:
503
 			case KEY_DOWN:
503
 				if ( widget.current < ( widget.num_rows - 1 ) )
504
 				if ( widget.current < ( widget.num_rows - 1 ) )
504
-					next++;
505
+					move = +1;
505
 				break;
506
 				break;
506
 			case KEY_UP:
507
 			case KEY_UP:
507
 				if ( widget.current > 0 )
508
 				if ( widget.current > 0 )
508
-					next--;
509
+					move = -1;
509
 				break;
510
 				break;
510
 			case CTRL_D:
511
 			case CTRL_D:
511
 				if ( ! widget.row.setting )
512
 				if ( ! widget.row.setting )
534
 				}
535
 				}
535
 				break;
536
 				break;
536
 			}
537
 			}
537
-			if ( next != widget.current ) {
538
+			if ( move ) {
539
+				next = ( widget.current + move );
538
 				draw_setting_row ( &widget );
540
 				draw_setting_row ( &widget );
539
 				redraw = 1;
541
 				redraw = 1;
540
 				reveal_setting_row ( &widget, next );
542
 				reveal_setting_row ( &widget, next );

Loading…
Cancel
Save