summaryrefslogtreecommitdiffstats
path: root/Settings.h
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 /Settings.h
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 'Settings.h')
-rw-r--r--Settings.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/Settings.h b/Settings.h
index 41a60f59..35520638 100644
--- a/Settings.h
+++ b/Settings.h
@@ -33,7 +33,9 @@ typedef struct Settings_ {
int delay;
int direction;
+ int treeDirection;
ProcessField sortKey;
+ ProcessField treeSortKey;
bool countCPUsFromOne;
bool detailedCPUTime;
@@ -71,6 +73,16 @@ typedef struct Settings_ {
#define Settings_cpuId(settings, cpu) ((settings)->countCPUsFromOne ? (cpu)+1 : (cpu))
+static inline ProcessField Settings_getActiveSortKey(const Settings* this) {
+ return (this->treeView)
+ ? (this->treeViewAlwaysByPID ? PID : this->treeSortKey)
+ : this->sortKey;
+}
+
+static inline int Settings_getActiveDirection(const Settings* this) {
+ return this->treeView ? this->treeDirection : this->direction;
+}
+
void Settings_delete(Settings* this);
bool Settings_write(Settings* this);
@@ -79,4 +91,6 @@ Settings* Settings_new(int initialCpuCount);
void Settings_invertSortOrder(Settings* this);
+void Settings_setSortKey(Settings* this, ProcessField sortKey);
+
#endif

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