Преглед изворни кода

[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 година
родитељ
комит
f0cd4abd07
1 измењених фајлова са 6 додато и 4 уклоњено
  1. 6
    4
      src/hci/tui/settings_ui.c

+ 6
- 4
src/hci/tui/settings_ui.c Прегледај датотеку

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

Loading…
Откажи
Сачувај