소스 검색

[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…
취소
저장