Browse Source

[menu] Truncate menu title when necessary

Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Christian Hesse 12 years ago
parent
commit
b3adabd07b
1 changed files with 3 additions and 2 deletions
  1. 3
    2
      src/hci/tui/menu_ui.c

+ 3
- 2
src/hci/tui/menu_ui.c View File

307
 		const char *select, struct menu_item **selected ) {
307
 		const char *select, struct menu_item **selected ) {
308
 	struct menu_item *item;
308
 	struct menu_item *item;
309
 	struct menu_ui ui;
309
 	struct menu_ui ui;
310
+	char buf[ MENU_COLS + 1 /* NUL */ ];
310
 	int labelled_count = 0;
311
 	int labelled_count = 0;
311
 	int rc;
312
 	int rc;
312
 
313
 
348
 
349
 
349
 	/* Draw initial content */
350
 	/* Draw initial content */
350
 	attron ( A_BOLD );
351
 	attron ( A_BOLD );
351
-	mvprintw ( TITLE_ROW, ( ( COLS - strlen ( ui.menu->title ) ) / 2 ),
352
-		   "%s", ui.menu->title );
352
+	snprintf ( buf, sizeof ( buf ), "%s", ui.menu->title );
353
+	mvprintw ( TITLE_ROW, ( ( COLS - strlen ( buf ) ) / 2 ), "%s", buf );
353
 	attroff ( A_BOLD );
354
 	attroff ( A_BOLD );
354
 	draw_menu_items ( &ui );
355
 	draw_menu_items ( &ui );
355
 	draw_menu_item ( &ui, ui.selected );
356
 	draw_menu_item ( &ui, ui.selected );

Loading…
Cancel
Save