From dde71c6637905e1707bd1020c93e930f4b0a480b Mon Sep 17 00:00:00 2001 From: Adam Saponara Date: Fri, 30 Oct 2020 21:56:16 -0400 Subject: Highlight new and old processes (#74) --- Process.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'Process.c') diff --git a/Process.c b/Process.c index 842232f7..f78720a5 100644 --- a/Process.c +++ b/Process.c @@ -6,6 +6,7 @@ Released under the GNU GPLv2, see the COPYING file in the source distribution for its full text. */ + #include "config.h" // IWYU pragma: keep #include "Process.h" @@ -381,6 +382,12 @@ void Process_display(const Object* cast, RichString* out) { RichString_setAttr(out, CRT_colors[PROCESS_SHADOW]); if (this->tag == true) RichString_setAttr(out, CRT_colors[PROCESS_TAG]); + if (this->settings->highlightChanges) { + if (Process_isNew(this)) + out->highlightAttr = CRT_colors[PROCESS_NEW]; + if (Process_isTomb(this)) + out->highlightAttr = CRT_colors[PROCESS_TOMB]; + } assert(out->chlen > 0); } @@ -413,6 +420,16 @@ void Process_toggleTag(Process* this) { this->tag = this->tag == true ? false : true; } +bool Process_isNew(const Process* this) { + if (this->processList && this->processList->scanTs >= this->seenTs) + return (this->processList->scanTs - this->seenTs <= this->processList->settings->highlightDelaySecs); + return false; +} + +bool Process_isTomb(const Process* this) { + return (this->tombTs > 0); +} + bool Process_setPriority(Process* this, int priority) { CRT_dropPrivileges(); int old_prio = getpriority(PRIO_PROCESS, this->pid); -- cgit v1.2.3 From a83f515f0fb75a079601be0d2e0e24b9402c9e15 Mon Sep 17 00:00:00 2001 From: Adam Saponara Date: Sat, 31 Oct 2020 20:36:53 -0400 Subject: Address items from review --- Process.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Process.c') diff --git a/Process.c b/Process.c index f78720a5..d3e6f4c6 100644 --- a/Process.c +++ b/Process.c @@ -6,7 +6,6 @@ Released under the GNU GPLv2, see the COPYING file in the source distribution for its full text. */ - #include "config.h" // IWYU pragma: keep #include "Process.h" @@ -383,10 +382,10 @@ void Process_display(const Object* cast, RichString* out) { if (this->tag == true) RichString_setAttr(out, CRT_colors[PROCESS_TAG]); if (this->settings->highlightChanges) { - if (Process_isNew(this)) - out->highlightAttr = CRT_colors[PROCESS_NEW]; if (Process_isTomb(this)) out->highlightAttr = CRT_colors[PROCESS_TOMB]; + else if (Process_isNew(this)) + out->highlightAttr = CRT_colors[PROCESS_NEW]; } assert(out->chlen > 0); } @@ -421,13 +420,14 @@ void Process_toggleTag(Process* this) { } bool Process_isNew(const Process* this) { - if (this->processList && this->processList->scanTs >= this->seenTs) - return (this->processList->scanTs - this->seenTs <= this->processList->settings->highlightDelaySecs); + assert(this->processList); + if (this->processList->scanTs >= this->seenTs) + return this->processList->scanTs - this->seenTs <= this->processList->settings->highlightDelaySecs; return false; } bool Process_isTomb(const Process* this) { - return (this->tombTs > 0); + return this->tombTs > 0; } bool Process_setPriority(Process* this, int priority) { -- cgit v1.2.3