From 3d8fa0b926a463006773534411df91be2b9d68ed Mon Sep 17 00:00:00 2001 From: WHR Date: Tue, 17 May 2022 11:54:48 +0800 Subject: [PATCH] Mark item separator in default color on help screen Closes: #1014 --- Action.c | 59 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/Action.c b/Action.c index cb132b4a..12db6951 100644 --- a/Action.c +++ b/Action.c @@ -571,46 +571,57 @@ static Htop_Reaction actionHelp(State* st) { line++; mvaddstr(line++, 0, "CPU usage bar: "); +#define addbartext(attr, prefix, text) \ + do { \ + addattrstr(CRT_colors[DEFAULT_COLOR], prefix); \ + addattrstr(attr, text); \ + } while(0) + addattrstr(CRT_colors[BAR_BORDER], "["); + addbartext(CRT_colors[CPU_NICE_TEXT], "", "low"); + addbartext(CRT_colors[CPU_NORMAL], "/", "normal"); + addbartext(CRT_colors[CPU_SYSTEM], "/", "kernel"); if (st->settings->detailedCPUTime) { - addattrstr(CRT_colors[CPU_NICE_TEXT], "low"); addstr("/"); - addattrstr(CRT_colors[CPU_NORMAL], "normal"); addstr("/"); - addattrstr(CRT_colors[CPU_SYSTEM], "kernel"); addstr("/"); - addattrstr(CRT_colors[CPU_IRQ], "irq"); addstr("/"); - addattrstr(CRT_colors[CPU_SOFTIRQ], "soft-irq"); addstr("/"); - addattrstr(CRT_colors[CPU_STEAL], "steal"); addstr("/"); - addattrstr(CRT_colors[CPU_GUEST], "guest"); addstr("/"); - addattrstr(CRT_colors[CPU_IOWAIT], "io-wait"); - addattrstr(CRT_colors[BAR_SHADOW], " used%"); + addbartext(CRT_colors[CPU_IRQ], "/", "irq"); + addbartext(CRT_colors[CPU_SOFTIRQ], "/", "soft-irq"); + addbartext(CRT_colors[CPU_STEAL], "/", "steal"); + addbartext(CRT_colors[CPU_GUEST], "/", "guest"); + addbartext(CRT_colors[CPU_IOWAIT], "/", "io-wait"); + addbartext(CRT_colors[BAR_SHADOW], " ", "used%"); } else { - addattrstr(CRT_colors[CPU_NICE_TEXT], "low-priority"); addstr("/"); - addattrstr(CRT_colors[CPU_NORMAL], "normal"); addstr("/"); - addattrstr(CRT_colors[CPU_SYSTEM], "kernel"); addstr("/"); - addattrstr(CRT_colors[CPU_GUEST], "virtualized"); - addattrstr(CRT_colors[BAR_SHADOW], " used%"); + addbartext(CRT_colors[CPU_GUEST], "/", "guest"); + addbartext(CRT_colors[BAR_SHADOW], " ", "used%"); } addattrstr(CRT_colors[BAR_BORDER], "]"); + attrset(CRT_colors[DEFAULT_COLOR]); mvaddstr(line++, 0, "Memory bar: "); addattrstr(CRT_colors[BAR_BORDER], "["); - addattrstr(CRT_colors[MEMORY_USED], "used"); addstr("/"); - addattrstr(CRT_colors[MEMORY_BUFFERS_TEXT], "buffers"); addstr("/"); - addattrstr(CRT_colors[MEMORY_SHARED], "shared"); addstr("/"); - addattrstr(CRT_colors[MEMORY_CACHE], "cache"); - addattrstr(CRT_colors[BAR_SHADOW], " used/total"); + addbartext(CRT_colors[MEMORY_USED], "", "used"); + addbartext(CRT_colors[MEMORY_BUFFERS_TEXT], "/", "buffers"); + addbartext(CRT_colors[MEMORY_SHARED], "/", "shared"); + addbartext(CRT_colors[MEMORY_CACHE], "/", "cache"); + addbartext(CRT_colors[BAR_SHADOW], " ", "used"); + addbartext(CRT_colors[BAR_SHADOW], "/", "totel"); addattrstr(CRT_colors[BAR_BORDER], "]"); + attrset(CRT_colors[DEFAULT_COLOR]); mvaddstr(line++, 0, "Swap bar: "); addattrstr(CRT_colors[BAR_BORDER], "["); - addattrstr(CRT_colors[SWAP], "used"); + addbartext(CRT_colors[SWAP], "", "used"); #ifdef HTOP_LINUX - addstr("/"); - addattrstr(CRT_colors[SWAP_CACHE], "cache"); - addattrstr(CRT_colors[BAR_SHADOW], " used/total"); + addbartext(CRT_colors[SWAP_CACHE], "/", "cache"); #else - addattrstr(CRT_colors[BAR_SHADOW], " used/total"); + addbartext(CRT_colors[SWAP_CACHE], " ", ""); #endif + addbartext(CRT_colors[BAR_SHADOW], " ", "used"); + addbartext(CRT_colors[BAR_SHADOW], "/", "total"); addattrstr(CRT_colors[BAR_BORDER], "]"); + + line++; + +#undef addbartext + attrset(CRT_colors[DEFAULT_COLOR]); mvaddstr(line++, 0, "Type and layout of header meters are configurable in the setup screen."); if (CRT_colorScheme == COLORSCHEME_MONOCHROME) {