From 539b874b7617f0b5acc0eea5399609dabba15e2b Mon Sep 17 00:00:00 2001 From: Joursoir Date: Mon, 29 Nov 2021 01:14:12 +0300 Subject: panel: add support for highlighting --- Library/UefiShellUfmCommandLib/panel.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Library/UefiShellUfmCommandLib/panel.c b/Library/UefiShellUfmCommandLib/panel.c index 39439fc..d242df6 100644 --- a/Library/UefiShellUfmCommandLib/panel.c +++ b/Library/UefiShellUfmCommandLib/panel.c @@ -14,6 +14,28 @@ #define SIZE_COLS 7 #define MODIFYTIME_COLS 12 +STATIC VOID highlight_line(struct panel_ctx *p, UINTN line, INT32 fg, INT32 bg) +{ + CHAR16 *str; + INT32 attr; + UINTN ui_line; + + ui_line = (line-1) % p->list_lines; + attr = p->wlist->attr[ui_line][0]; + if(fg < 0x0) + fg = attr & 0x0F; + if(bg < 0x0) + bg = ((attr & 0xF0) >> 4); + attr = EFI_TEXT_ATTR(fg, bg); + + wattrset(p->wlist, attr); + str = p->wlist->text[ui_line]; + mvwprintf(p->wlist, 0, ui_line, str); + wattroff(p->wlist); + + wrefresh(p->wlist); +} + STATIC VOID set_cwd(struct panel_ctx *p, CONST CHAR16 *path) { if(p->cwd) { -- cgit v1.2.3-18-g5258