Pārlūkot izejas kodu

[menu] Adapt user interface to fit display size

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 gadus atpakaļ
vecāks
revīzija
f79592545b
1 mainītis faili ar 8 papildinājumiem un 8 dzēšanām
  1. 8
    8
      src/hci/tui/menu_ui.c

+ 8
- 8
src/hci/tui/menu_ui.c Parādīt failu

@@ -40,19 +40,19 @@ FILE_LICENCE ( GPL2_OR_LATER );
40 40
 #define CPAIR_SEPARATOR	3
41 41
 
42 42
 /* Screen layout */
43
-#define TITLE_ROW	1
44
-#define MENU_ROW	3
45
-#define MENU_COL	1
46
-#define MENU_ROWS	18
47
-#define MENU_COLS	78
48
-#define MENU_PAD	2
43
+#define TITLE_ROW	1U
44
+#define MENU_ROW	3U
45
+#define MENU_COL	1U
46
+#define MENU_ROWS	( LINES - 2U - MENU_ROW )
47
+#define MENU_COLS	( COLS - 2U )
48
+#define MENU_PAD	2U
49 49
 
50 50
 /** A menu user interface */
51 51
 struct menu_ui {
52 52
 	/** Menu */
53 53
 	struct menu *menu;
54 54
 	/** Number of menu items */
55
-	int count;
55
+	unsigned int count;
56 56
 	/** Currently selected item */
57 57
 	int selected;
58 58
 	/** First visible item */
@@ -269,7 +269,7 @@ static int menu_loop ( struct menu_ui *ui, struct menu_item **selected ) {
269 269
 			if ( ui->selected < 0 ) {
270 270
 				ui->selected = 0;
271 271
 				move = +1;
272
-			} else if ( ui->selected >= ui->count ) {
272
+			} else if ( ui->selected >= ( int ) ui->count ) {
273 273
 				ui->selected = ( ui->count - 1 );
274 274
 				move = -1;
275 275
 			}

Notiek ielāde…
Atcelt
Saglabāt