From 04b42e96126e6fd79edfbde9b7230bc977c657de Mon Sep 17 00:00:00 2001 From: Shelley Chen Date: Mon, 13 Feb 2017 13:52:17 -0800 Subject: [PATCH] poppy: Highlight menu selection Reverse foreground/background colors for highlighted selection. BUG=chrome-os-partner:61275 BRANCH=None TEST=reboot and make sure selection is highlighted CQ-DEPEND=CL:442747 Change-Id: Iaf33cf6140a3ce774a67e3ac7d381d5e05feeddb Signed-off-by: Shelley Chen Reviewed-on: https://chromium-review.googlesource.com/442690 Reviewed-by: Randall Spangler --- firmware/lib/vboot_ui_menu.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c index 045dd9bced..1adb364dd8 100644 --- a/firmware/lib/vboot_ui_menu.c +++ b/firmware/lib/vboot_ui_menu.c @@ -329,41 +329,30 @@ VbError_t vb2_get_current_menu_size(VB_MENU menu, char ***menu_array, int *size) * * @return VBERROR_SUCCESS, or non-zero error code if error. */ -// TODO: will probably have to print menu a -// line at a time to center the text at X. -// Otherwise, only the first line will be lined up -// vertically properly. -// which is why x is currently 0. -// also, want to calculate what center is eventually instead of -// hard-coding it. -// at least right now there's no overlapping with the debug -// printouts. VbError_t vb2_print_current_menu() { - char m_str[1024]; - const char *selected = "==> "; - const char *deselected = " "; int size = 0; int i = 0; static char **m = NULL; + int highlight = 0; + // TODO: We probably want to center this text. + int xindex = 50; + int yindex = 30; - memset(m_str, 0, strlen(m_str)); // TODO: need to check for error code. vb2_get_current_menu_size(current_menu, &m, &size); VB2_DEBUG("vb2_print_current_menu:\n"); + // TODO: do clear screen here. /* Create menu string */ for (i = 0; i < size; i++) { - if (current_menu_idx == i) { - strncat(m_str, selected, strlen(selected)); - } else { - strncat(m_str, deselected, strlen(deselected)); - } - strncat(m_str, m[i], strlen(m[i])); + highlight = !!(current_menu_idx == i); + VbExDisplayText(xindex, yindex, m[i], highlight); + VB2_DEBUG("[%d,%d]: %s", xindex, yindex, m[i]); + yindex++; } - VB2_DEBUG("%s", m_str); - return VbExDisplayText(0,30,m_str); + return VBERROR_SUCCESS; } /**