diff options
-rw-r--r-- | Process.c | 12 | ||||
-rw-r--r-- | Process.h | 3 | ||||
-rw-r--r-- | ProcessList.c | 4 | ||||
-rw-r--r-- | Settings.c | 1 | ||||
-rw-r--r-- | htop.c | 7 |
5 files changed, 16 insertions, 11 deletions
@@ -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) { @@ -9,8 +9,8 @@ in the source distribution for its full text. */ #include <stdbool.h> -#include <sys/types.h> #include <time.h> +#include <sys/types.h> #include "Object.h" #include "RichString.h" @@ -78,6 +78,7 @@ typedef struct Process_ { bool tag; bool showChildren; bool show; + bool wasShown; unsigned int pgrp; unsigned int session; unsigned int tty_nr; diff --git a/ProcessList.c b/ProcessList.c index 1ae7b9cc..364de1e0 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -14,6 +14,7 @@ in the source distribution for its full text. #include "CRT.h" #include "XUtils.h" + ProcessList* ProcessList_init(ProcessList* this, const ObjectClass* klass, UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) { this->processes = Vector_new(klass, true, DEFAULT_SIZE); this->processTable = Hashtable_new(140, false); @@ -306,6 +307,7 @@ void ProcessList_scan(ProcessList* this, bool pauseProcessUpdate) { for (int i = 0; i < Vector_size(this->processes); i++) { Process* p = (Process*) Vector_get(this->processes, i); p->updated = false; + p->wasShown = p->show; p->show = true; } @@ -334,7 +336,7 @@ void ProcessList_scan(ProcessList* this, bool pauseProcessUpdate) { } } else if (p->updated == false) { // process no longer exists - if (this->settings->highlightChanges) { + if (this->settings->highlightChanges && p->wasShown) { // mark tombed p->tombTs = this->scanTs + this->settings->highlightDelaySecs; } else { @@ -313,6 +313,7 @@ Settings* Settings_new(int initialCpuCount) { this->updateProcessNames = false; this->showProgramPath = true; this->highlightThreads = true; + this->highlightChanges = false; this->highlightDelaySecs = DEFAULT_HIGHLIGHT_SECS; #ifdef HAVE_LIBHWLOC this->topologyAffinity = false; @@ -50,14 +50,14 @@ static void printHelpFlag(void) { "-d --delay=DELAY Set the delay between updates, in tenths of seconds\n" "-F --filter=FILTER Show only the commands matching the given filter\n" "-h --help Print this help screen\n" + "-H --highlight-changes[=DELAY] Highlight new and old processes\n" "-M --no-mouse Disable the mouse\n" - "-p --pid=PID,[,PID,PID...] Show only the given PIDs\n" + "-p --pid=PID[,PID,PID...] Show only the given PIDs\n" "-s --sort-key=COLUMN Sort by COLUMN (try --sort-key=help for a list)\n" "-t --tree Show the tree view by default\n" "-u --user[=USERNAME] Show only processes for a given user (or $USER)\n" "-U --no-unicode Do not use unicode but plain ASCII\n" "-V --version Print version info\n" - "-H --highlight-changes[=DELAY] Highlight new and old processes\n" "\n" "Long options may be passed with a single dash.\n\n" "Press F1 inside htop for online help.\n" @@ -212,7 +212,8 @@ static CommandLineSettings parseArguments(int argc, char** argv) { } if (delay) { if (sscanf(delay, "%16d", &(flags.highlightDelaySecs)) == 1) { - if (flags.highlightDelaySecs < 1) flags.highlightDelaySecs = 1; + if (flags.highlightDelaySecs < 1) + flags.highlightDelaySecs = 1; } else { fprintf(stderr, "Error: invalid highlight delay value \"%s\".\n", delay); exit(1); |