From bf07c713ba431e86edf3773cc7428398c911fc46 Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Sat, 19 Dec 2020 16:46:00 +0100 Subject: [PATCH] Allow for highlighting of deleted executables to be configured Fixes #383 --- DisplayOptionsPanel.c | 1 + Process.c | 4 ++-- Settings.c | 4 ++++ Settings.h | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/DisplayOptionsPanel.c b/DisplayOptionsPanel.c index dd26989f..e945edd9 100644 --- a/DisplayOptionsPanel.c +++ b/DisplayOptionsPanel.c @@ -107,6 +107,7 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* Panel_add(super, (Object*) CheckItem_newByRef("Show custom thread names", &(settings->showThreadNames))); Panel_add(super, (Object*) CheckItem_newByRef("Show program path", &(settings->showProgramPath))); Panel_add(super, (Object*) CheckItem_newByRef("Highlight program \"basename\"", &(settings->highlightBaseName))); + Panel_add(super, (Object*) CheckItem_newByRef("Highlight out-dated/removed programs", &(settings->highlightDeletedExe))); Panel_add(super, (Object*) CheckItem_newByRef("Merge exe, comm and cmdline in Command", &(settings->showMergedCommand))); Panel_add(super, (Object*) CheckItem_newByRef("- Try to find comm in cmdline (when Command is merged)", &(settings->findCommInCmdline))); Panel_add(super, (Object*) CheckItem_newByRef("- Try to strip exe from cmdline (when Command is merged)", &(settings->stripExeFromCmdline))); diff --git a/Process.c b/Process.c index 5236c8b1..f134be53 100644 --- a/Process.c +++ b/Process.c @@ -594,7 +594,7 @@ void Process_writeCommand(const Process* this, int attr, int baseAttr, RichStrin const bool highlightBaseName = this->settings->highlightBaseName; const bool highlightSeparator = true; - const bool highlightDeleted = true; + const bool highlightDeleted = this->settings->highlightDeletedExe; if (!this->mergedCommand.str) { int len = 0; @@ -766,7 +766,7 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field const char* procExe; if (this->procExe) { attr = CRT_colors[Process_isUserlandThread(this) ? PROCESS_THREAD_BASENAME : PROCESS_BASENAME]; - if (this->procExeDeleted) + if (this->procExeDeleted && this->settings->highlightDeletedExe) attr = CRT_colors[FAILED_READ]; procExe = this->procExe + this->procExeBasenameOffset; } else { diff --git a/Settings.c b/Settings.c index 92d96dd5..acb3edfa 100644 --- a/Settings.c +++ b/Settings.c @@ -175,6 +175,8 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini this->showProgramPath = atoi(option[1]); } else if (String_eq(option[0], "highlight_base_name")) { this->highlightBaseName = atoi(option[1]); + } else if (String_eq(option[0], "highlight_deleted_exe")) { + this->highlightDeletedExe = atoi(option[1]); } else if (String_eq(option[0], "highlight_megabytes")) { this->highlightMegabytes = atoi(option[1]); } else if (String_eq(option[0], "highlight_threads")) { @@ -307,6 +309,7 @@ int Settings_write(const Settings* this, bool onCrash) { fprintf(fd, "show_thread_names=%d\n", (int) this->showThreadNames); fprintf(fd, "show_program_path=%d\n", (int) this->showProgramPath); fprintf(fd, "highlight_base_name=%d\n", (int) this->highlightBaseName); + fprintf(fd, "highlight_deleted_exe=%d\n", (int) this->highlightDeletedExe); fprintf(fd, "highlight_megabytes=%d\n", (int) this->highlightMegabytes); fprintf(fd, "highlight_threads=%d\n", (int) this->highlightThreads); fprintf(fd, "highlight_changes=%d\n", (int) this->highlightChanges); @@ -368,6 +371,7 @@ Settings* Settings_new(unsigned int initialCpuCount) { this->treeView = false; this->allBranchesCollapsed = false; this->highlightBaseName = false; + this->highlightDeletedExe = true; this->highlightMegabytes = false; this->detailedCPUTime = false; this->countCPUsFromOne = false; diff --git a/Settings.h b/Settings.h index fb621adb..6cda3a92 100644 --- a/Settings.h +++ b/Settings.h @@ -54,6 +54,7 @@ typedef struct Settings_ { bool hideKernelThreads; bool hideUserlandThreads; bool highlightBaseName; + bool highlightDeletedExe; bool highlightMegabytes; bool highlightThreads; bool highlightChanges;