From c46d0f292b34987a941a1c29bcd8b03fd6b53ded Mon Sep 17 00:00:00 2001 From: Explorer09 Date: Sat, 11 Jan 2025 05:03:45 +0800 Subject: [PATCH 1/3] Fix "Swap bar" alignment in help screen Regression from b29b33ebb9ae80a95e7d09eb537e0fccc5043d68 The misaligned text is only seen on non-Linux systems. --- Action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Action.c b/Action.c index 56fb3d0cb..a93c64819 100644 --- a/Action.c +++ b/Action.c @@ -758,7 +758,7 @@ static Htop_Reaction actionHelp(State* st) { addbartext(CRT_colors[SWAP_CACHE], "/", "cache"); addbartext(CRT_colors[SWAP_FRONTSWAP], "/", "frontswap"); #else - addbartext(CRT_colors[SWAP_CACHE], " ", ""); + addbartext(CRT_colors[BAR_SHADOW], " ", ""); #endif addbartext(CRT_colors[BAR_SHADOW], " ", "used"); addbartext(CRT_colors[BAR_SHADOW], "/", "total"); From a96b1331658d9c2141522ad98497fc477241f1c6 Mon Sep 17 00:00:00 2001 From: Explorer09 Date: Sat, 11 Jan 2025 05:30:15 +0800 Subject: [PATCH 2/3] Dim memory "buffers" and "cache" when they are hidden from bar and graph --- MemoryMeter.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MemoryMeter.c b/MemoryMeter.c index 36401cb79..6769e3bec 100644 --- a/MemoryMeter.c +++ b/MemoryMeter.c @@ -67,6 +67,7 @@ static void MemoryMeter_updateValues(Meter* this) { static void MemoryMeter_display(const Object* cast, RichString* out) { char buffer[50]; const Meter* this = (const Meter*)cast; + const Settings* settings = this->host->settings; RichString_writeAscii(out, CRT_colors[METER_TEXT], ":"); Meter_humanUnit(buffer, this->total, sizeof(buffer)); @@ -91,12 +92,12 @@ static void MemoryMeter_display(const Object* cast, RichString* out) { } Meter_humanUnit(buffer, this->values[MEMORY_METER_BUFFERS], sizeof(buffer)); - RichString_appendAscii(out, CRT_colors[METER_TEXT], " buffers:"); - RichString_appendAscii(out, CRT_colors[MEMORY_BUFFERS_TEXT], buffer); + RichString_appendAscii(out, settings->showCachedMemory ? CRT_colors[METER_TEXT] : CRT_colors[METER_SHADOW], " buffers:"); + RichString_appendAscii(out, settings->showCachedMemory ? CRT_colors[MEMORY_BUFFERS_TEXT] : CRT_colors[METER_SHADOW], buffer); Meter_humanUnit(buffer, this->values[MEMORY_METER_CACHE], sizeof(buffer)); - RichString_appendAscii(out, CRT_colors[METER_TEXT], " cache:"); - RichString_appendAscii(out, CRT_colors[MEMORY_CACHE], buffer); + RichString_appendAscii(out, settings->showCachedMemory ? CRT_colors[METER_TEXT] : CRT_colors[METER_SHADOW], " cache:"); + RichString_appendAscii(out, settings->showCachedMemory ? CRT_colors[MEMORY_CACHE] : CRT_colors[METER_SHADOW], buffer); /* available memory is not supported on all platforms */ if (isNonnegative(this->values[MEMORY_METER_AVAILABLE])) { From 3daf1bc63b065ac032a5d6835d403b87c3a89a31 Mon Sep 17 00:00:00 2001 From: Explorer09 Date: Sat, 11 Jan 2025 05:31:50 +0800 Subject: [PATCH 3/3] Reflect the "show cached memory" setting in help screen Hide the "buffers/cache" text on the memory bar description when the "show cached memory" setting is off. Signed-off-by: Kang-Che Sung --- Action.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Action.c b/Action.c index a93c64819..986b35463 100644 --- a/Action.c +++ b/Action.c @@ -744,9 +744,13 @@ static Htop_Reaction actionHelp(State* st) { addbartext(CRT_colors[MEMORY_USED], "", "used"); addbartext(CRT_colors[MEMORY_SHARED], "/", "shared"); addbartext(CRT_colors[MEMORY_COMPRESSED], "/", "compressed"); - addbartext(CRT_colors[MEMORY_BUFFERS_TEXT], "/", "buffers"); - addbartext(CRT_colors[MEMORY_CACHE], "/", "cache"); - addbartext(CRT_colors[BAR_SHADOW], " ", "used"); + if (st->host->settings->showCachedMemory) { + addbartext(CRT_colors[MEMORY_BUFFERS_TEXT], "/", "buffers"); + addbartext(CRT_colors[MEMORY_CACHE], "/", "cache"); + addbartext(CRT_colors[BAR_SHADOW], " ", "used"); + } else { + addbartext(CRT_colors[BAR_SHADOW], " ", "used"); + } addbartext(CRT_colors[BAR_SHADOW], "/", "total"); addattrstr(CRT_colors[BAR_BORDER], "]");