diff mbox series

[1/1] cmd: simplify bootmenu

Message ID 20220501212236.26942-1-heinrich.schuchardt@canonical.com
State Accepted, archived
Commit d1d7ed7b1eb99089cf027cafaa134b75a9cf3348
Delegated to: Heinrich Schuchardt
Headers show
Series [1/1] cmd: simplify bootmenu | expand

Commit Message

Heinrich Schuchardt May 1, 2022, 9:22 p.m. UTC
* correct output for timeout > 99 s
* don't use spaces to advance to the output column

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 cmd/bootmenu.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
index d573487272..fe35607472 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -68,9 +68,7 @@  static void bootmenu_print_entry(void *data)
 	 * Move cursor to line where the entry will be drown (entry->num)
 	 * First 3 lines contain bootmenu header + 1 empty line
 	 */
-	printf(ANSI_CURSOR_POSITION, entry->num + 4, 1);
-
-	puts("     ");
+	printf(ANSI_CURSOR_POSITION, entry->num + 4, 7);
 
 	if (reverse)
 		puts(ANSI_COLOR_REVERSE);
@@ -86,12 +84,9 @@  static void bootmenu_autoboot_loop(struct bootmenu_data *menu,
 {
 	int i, c;
 
-	if (menu->delay > 0) {
-		printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
-		printf("  Hit any key to stop autoboot: %2d ", menu->delay);
-	}
-
 	while (menu->delay > 0) {
+		printf(ANSI_CURSOR_POSITION, menu->count + 5, 3);
+		printf("Hit any key to stop autoboot: %d ", menu->delay);
 		for (i = 0; i < 100; ++i) {
 			if (!tstc()) {
 				WATCHDOG_RESET();
@@ -125,7 +120,6 @@  static void bootmenu_autoboot_loop(struct bootmenu_data *menu,
 			break;
 
 		--menu->delay;
-		printf("\b\b\b%2d ", menu->delay);
 	}
 
 	printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
@@ -407,8 +401,8 @@  static void menu_display_statusline(struct menu *m)
 
 	printf(ANSI_CURSOR_POSITION, 1, 1);
 	puts(ANSI_CLEAR_LINE);
-	printf(ANSI_CURSOR_POSITION, 2, 1);
-	puts("  *** U-Boot Boot Menu ***");
+	printf(ANSI_CURSOR_POSITION, 2, 3);
+	puts("*** U-Boot Boot Menu ***");
 	puts(ANSI_CLEAR_LINE_TO_END);
 	printf(ANSI_CURSOR_POSITION, 3, 1);
 	puts(ANSI_CLEAR_LINE);
@@ -416,8 +410,8 @@  static void menu_display_statusline(struct menu *m)
 	/* First 3 lines are bootmenu header + 2 empty lines between entries */
 	printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
 	puts(ANSI_CLEAR_LINE);
-	printf(ANSI_CURSOR_POSITION, menu->count + 6, 1);
-	puts("  Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit");
+	printf(ANSI_CURSOR_POSITION, menu->count + 6, 3);
+	puts("Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit");
 	puts(ANSI_CLEAR_LINE_TO_END);
 	printf(ANSI_CURSOR_POSITION, menu->count + 7, 1);
 	puts(ANSI_CLEAR_LINE);