Przeglądaj źródła

[settings] Add support for navigation keys in "config" user interface

Add support for page up, page down, home and end keys, matching the
navigation logic used in the menu user interface.

Originally-implemented-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 lat temu
rodzic
commit
75bd5b54a8
1 zmienionych plików z 27 dodań i 9 usunięć
  1. 27
    9
      src/hci/tui/settings_ui.c

+ 27
- 9
src/hci/tui/settings_ui.c Wyświetl plik

@@ -508,13 +508,25 @@ static int main_loop ( struct settings *settings ) {
508 508
 			key = getkey ( 0 );
509 509
 			move = 0;
510 510
 			switch ( key ) {
511
+			case KEY_UP:
512
+				move = -1;
513
+				break;
511 514
 			case KEY_DOWN:
512
-				if ( widget.current < ( widget.num_rows - 1 ) )
513
-					move = +1;
515
+				move = +1;
514 516
 				break;
515
-			case KEY_UP:
516
-				if ( widget.current > 0 )
517
-					move = -1;
517
+			case KEY_PPAGE:
518
+				move = ( widget.first_visible -
519
+					 widget.current - 1 );
520
+				break;
521
+			case KEY_NPAGE:
522
+				move = ( widget.first_visible - widget.current
523
+					 + SETTINGS_LIST_ROWS );
524
+				break;
525
+			case KEY_HOME:
526
+				move = -widget.num_rows;
527
+				break;
528
+			case KEY_END:
529
+				move = +widget.num_rows;
518 530
 				break;
519 531
 			case CTRL_D:
520 532
 				if ( ! widget.row.setting )
@@ -545,10 +557,16 @@ static int main_loop ( struct settings *settings ) {
545 557
 			}
546 558
 			if ( move ) {
547 559
 				next = ( widget.current + move );
548
-				draw_setting_row ( &widget );
549
-				redraw = 1;
550
-				reveal_setting_row ( &widget, next );
551
-				select_setting_row ( &widget, next );
560
+				if ( ( int ) next < 0 )
561
+					next = 0;
562
+				if ( next >= widget.num_rows )
563
+					next = ( widget.num_rows - 1 );
564
+				if ( next != widget.current ) {
565
+					draw_setting_row ( &widget );
566
+					redraw = 1;
567
+					reveal_setting_row ( &widget, next );
568
+					select_setting_row ( &widget, next );
569
+				}
552 570
 			}
553 571
 		}
554 572
 	}

Ładowanie…
Anuluj
Zapisz