소스 검색

[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 12 년 전
부모
커밋
75bd5b54a8
1개의 변경된 파일27개의 추가작업 그리고 9개의 파일을 삭제
  1. 27
    9
      src/hci/tui/settings_ui.c

+ 27
- 9
src/hci/tui/settings_ui.c 파일 보기

508
 			key = getkey ( 0 );
508
 			key = getkey ( 0 );
509
 			move = 0;
509
 			move = 0;
510
 			switch ( key ) {
510
 			switch ( key ) {
511
+			case KEY_UP:
512
+				move = -1;
513
+				break;
511
 			case KEY_DOWN:
514
 			case KEY_DOWN:
512
-				if ( widget.current < ( widget.num_rows - 1 ) )
513
-					move = +1;
515
+				move = +1;
514
 				break;
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
 				break;
530
 				break;
519
 			case CTRL_D:
531
 			case CTRL_D:
520
 				if ( ! widget.row.setting )
532
 				if ( ! widget.row.setting )
545
 			}
557
 			}
546
 			if ( move ) {
558
 			if ( move ) {
547
 				next = ( widget.current + move );
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
 	}

Loading…
취소
저장