瀏覽代碼

[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 年之前
父節點
當前提交
b3adabd07b
共有 1 個檔案被更改,包括 3 行新增2 行删除
  1. 3
    2
      src/hci/tui/menu_ui.c

+ 3
- 2
src/hci/tui/menu_ui.c 查看文件

@@ -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…
取消
儲存