summaryrefslogtreecommitdiffstats
path: root/ProcessList.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2020-12-18 11:03:31 -0300
committerBenBE <BenBE@geshi.org>2020-12-19 16:02:34 +0100
commit2327260ee888146beab3da66507c7744334a6973 (patch)
tree06b3919321515cc4fdea7de0b5ead4744f3600ec /ProcessList.c
parente8c6994f40c9c69089e9f80abb2f895d2e077c7e (diff)
Separate tree and list sort orders
Implements the suggestion from https://github.com/htop-dev/htop/issues/399#issuecomment-747861013 Thanks to the refactors from 0bd5c8fb5da and 6393baa74e5, this was really easy and clean to do. It maintains the "Tree view always by PID" option in the Settings, which results in some specific behaviors such as "clicking on the column header to exit tree view" and "picking a new sort order to exit tree view", for the sake of the muscle memory of long time htop users. :)
Diffstat (limited to 'ProcessList.c')
-rw-r--r--ProcessList.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ProcessList.c b/ProcessList.c
index 54b69184..02ce373f 100644
--- a/ProcessList.c
+++ b/ProcessList.c
@@ -85,6 +85,8 @@ void ProcessList_printHeader(ProcessList* this, RichString* header) {
const Settings* settings = this->settings;
const ProcessField* fields = settings->fields;
+ ProcessField key = Settings_getActiveSortKey(settings);
+
for (int i = 0; fields[i]; i++) {
const char* field = Process_fields[fields[i]].title;
if (!field) {
@@ -94,7 +96,7 @@ void ProcessList_printHeader(ProcessList* this, RichString* header) {
int color;
if (settings->treeView && settings->treeViewAlwaysByPID) {
color = CRT_colors[PANEL_HEADER_FOCUS];
- } else if (settings->sortKey == fields[i]) {
+ } else if (key == fields[i]) {
color = CRT_colors[PANEL_SELECTION_FOCUS];
} else {
color = CRT_colors[PANEL_HEADER_FOCUS];
@@ -355,7 +357,7 @@ static long ProcessList_treeProcessCompareByPID(const void* v1, const void* v2)
static void ProcessList_buildTree(ProcessList* this) {
int node_counter = 1;
int node_index = 0;
- int direction = this->settings->direction;
+ int direction = Settings_getActiveDirection(this->settings);
// Sort by PID
Vector_quickSortCustomCompare(this->processes, ProcessList_treeProcessCompareByPID);

© 2014-2024 Faster IT GmbH | imprint | privacy policy