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,6 +307,7 @@ int show_menu ( struct menu *menu, unsigned int timeout_ms,
307 307
 		const char *select, struct menu_item **selected ) {
308 308
 	struct menu_item *item;
309 309
 	struct menu_ui ui;
310
+	char buf[ MENU_COLS + 1 /* NUL */ ];
310 311
 	int labelled_count = 0;
311 312
 	int rc;
312 313
 
@@ -348,8 +349,8 @@ int show_menu ( struct menu *menu, unsigned int timeout_ms,
348 349
 
349 350
 	/* Draw initial content */
350 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 354
 	attroff ( A_BOLD );
354 355
 	draw_menu_items ( &ui );
355 356
 	draw_menu_item ( &ui, ui.selected );

Loading…
Cancel
Save