From 37e01cbe33714c8fde72220555b92c7d8585d127 Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Thu, 19 May 2022 22:03:12 +0200 Subject: Colorize process state characters in help screen Thanks to @Low-power for the idea Closes #1010 --- Action.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Action.c b/Action.c index 27a9ef5d..5aabcc3f 100644 --- a/Action.c +++ b/Action.c @@ -618,9 +618,23 @@ static Htop_Reaction actionHelp(State* st) { } line++; - mvaddstr(line++, 0, "Process state: R: running; S: sleeping; T: traced/stopped; Z: zombie; D: disk sleep"); +#define addattrstatestr(attr, state, desc) \ + do { \ + addattrstr(attr, state); \ + addattrstr(CRT_colors[DEFAULT_COLOR], ": " desc); \ + } while(0) + + mvaddstr(line, 0, "Process state: "); + addattrstatestr(CRT_colors[PROCESS_RUN_STATE], "R", "running; "); + addattrstatestr(CRT_colors[PROCESS_SHADOW], "S", "sleeping; "); + addattrstatestr(CRT_colors[PROCESS_RUN_STATE], "t", "traced/stopped; "); + addattrstatestr(CRT_colors[PROCESS_D_STATE], "Z", "zombie; "); + addattrstatestr(CRT_colors[PROCESS_D_STATE], "D", "dist sleep"); + attrset(CRT_colors[DEFAULT_COLOR]); - line++; +#undef addattrstatestr + + line += 2; const bool readonly = Settings_isReadonly(); -- cgit v1.2.3