From 177b83de9c74825cf0ae0e3ec10c500eb8809023 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Wed, 7 Jul 2021 02:43:07 +0200 Subject: [PATCH] menu: Prefer left alignment for titles which are not divisible by 2 --- stage23/menu.c | 18 +++++++++--------- test/limine.cfg | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/stage23/menu.c b/stage23/menu.c index ddf43664..cf03f3e9 100644 --- a/stage23/menu.c +++ b/stage23/menu.c @@ -155,11 +155,11 @@ static char *config_entry_editor(const char *title, const char *orig_entry) { bool syntax_highlighting_enabled = true; char *syntax_highlighting_enabled_config = config_get_value(NULL, 0, "EDITOR_HIGHLIGHTING"); if (!strcmp(syntax_highlighting_enabled_config, "no")) syntax_highlighting_enabled = false; - + validation_enabled = true; char *validation_enabled_config = config_get_value(NULL, 0, "EDITOR_VALIDATION"); if (!strcmp(validation_enabled_config, "no")) validation_enabled = false; - + static char *buffer = NULL; if (buffer == NULL) buffer = ext_mem_alloc(EDITOR_MAX_BUFFER_SIZE); @@ -168,7 +168,7 @@ static char *config_entry_editor(const char *title, const char *orig_entry) { refresh: invalid_syntax = false; - + clear(true); disable_cursor(); print("\n\n \e[36m %s \e[37m\n\n\n", menu_branding); @@ -188,7 +188,7 @@ refresh: // FALLTHRU default: { int title_length = strlen(title); - if (i == (term_cols / 2) - (title_length / 2) - 1) { + if (i == (term_cols / 2) - DIV_ROUNDUP(title_length, 2)) { print("%s", title); i += title_length - 1; } else { @@ -263,10 +263,10 @@ refresh: if (current_line >= window_offset) { line_offset++; - + // switch to token type 1 if equals sign if (token_type == TOK_KEY && buffer[i] == '=') token_type = TOK_EQUALS; - + // syntax highlighting if (syntax_highlighting_enabled) { switch (token_type) { @@ -286,12 +286,12 @@ refresh: } else { print("%c", buffer[i]); } - + // switch to token type 2 after equals sign if (token_type == TOK_EQUALS) token_type = TOK_VALUE; } } - + // syntax error alert if (validation_enabled) { int x, y; @@ -474,7 +474,7 @@ char *menu(char **cmdline) { else timeout = strtoui(timeout_config, NULL, 10); } - + bool editor_enabled = true; char *editor_enabled_config = config_get_value(NULL, 0, "EDITOR_ENABLED"); if (!strcmp(editor_enabled_config, "no")) editor_enabled = false; diff --git a/test/limine.cfg b/test/limine.cfg index 3f42f8b1..b4bf521f 100644 --- a/test/limine.cfg +++ b/test/limine.cfg @@ -1,6 +1,6 @@ DEFAULT_ENTRY=1 TIMEOUT=3 -GRAPHICS=yes +#GRAPHICS=yes MENU_FONT=boot:///boot/font.bin VERBOSE=yes