menu: Fix a couple of boot menu alignment issues

This commit is contained in:
mintsuki 2023-07-28 01:36:19 -05:00
parent 8f167bc2e5
commit 5bdb1bbf55

View File

@ -504,9 +504,11 @@ static size_t print_tree(size_t offset, size_t window, const char *shift, size_t
if (max_len == NULL) { if (max_len == NULL) {
max_len = &dummy_max_len; max_len = &dummy_max_len;
} }
if (!level) {
*max_len = 0;
}
if (shift == NULL) { if (shift == NULL) {
no_print = true; no_print = true;
*max_len = 0;
} }
for (;;) { for (;;) {
@ -813,7 +815,7 @@ refresh:
print_tree(tree_offset, terms[0]->rows - 10, NULL, 0, 0, selected_entry, menu_tree, print_tree(tree_offset, terms[0]->rows - 10, NULL, 0, 0, selected_entry, menu_tree,
&selected_menu_entry, &max_tree_len); &selected_menu_entry, &max_tree_len);
size_t tree_prefix_len = terms[0]->cols / 2 - max_tree_len / 2; size_t tree_prefix_len = terms[0]->cols / 2 - DIV_ROUNDUP(max_tree_len, 2);
if (!serial) tree_prefix_len += strlen("") - 1; if (!serial) tree_prefix_len += strlen("") - 1;
char *tree_prefix = ext_mem_alloc(tree_prefix_len); char *tree_prefix = ext_mem_alloc(tree_prefix_len);
memset(tree_prefix, ' ', tree_prefix_len); memset(tree_prefix, ' ', tree_prefix_len);