diff options
author | Sohaib Mohamed <sohaib.amhmd@gmail.com> | 2023-08-22 16:46:59 +1000 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2023-08-30 13:11:57 +1000 |
commit | 53bdcab942298e0e452d62237bc18e3a4cd551cf (patch) | |
tree | e7a62910b9f4a1a58560a4ded2e6f7e83d0b631e /Settings.h | |
parent | 0f751e991d399769fb8d7800f7c4bccec2ca7f60 (diff) |
Support dynamic screens with 'top-most' entities beyond processes
This implements our concept of 'dynamic screens' in htop, with a
first use-case of pcp-htop displaying things like top-filesystem
and top-cgroups under new screen tabs. However the idea is more
general than use in pcp-htop and we've paved the way here for us
to collectively build mroe general tabular screens in core htop,
as well.
From the pcp-htop side of things, dynamic screens are configured
using text-based configuration files that define the mapping for
PCP metrics to columns (and metric instances to rows). Metrics
are defined either directly (via metric names) or indirectly via
PCP derived metric specifications. Value scaling and the units
displayed is automatic based on PCP metric units and data types.
This commit represents a collaborative effort of several months,
primarily between myself, Nathan and BenBE.
Signed-off-by: Sohaib Mohamed <sohaib.amhmd@gmail.com>
Signed-off-by: Nathan Scott <nathans@redhat.com>
Diffstat (limited to 'Settings.h')
-rw-r--r-- | Settings.h | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -21,10 +21,14 @@ in the source distribution for its full text. #define CONFIG_READER_MIN_VERSION 3 +struct DynamicScreen_; +struct Table_; + typedef struct { const char* name; const char* columns; const char* sortKey; + const char* treeSortKey; } ScreenDefaults; typedef struct { @@ -34,7 +38,9 @@ typedef struct { } MeterColumnSetting; typedef struct ScreenSettings_ { - char* name; + char* heading; /* user-editable screen name (pretty) */ + char* dynamic; /* from DynamicScreen config (fixed) */ + struct Table_* table; RowField* fields; uint32_t flags; int direction; @@ -42,7 +48,7 @@ typedef struct ScreenSettings_ { RowField sortKey; RowField treeSortKey; bool treeView; - bool treeViewAlwaysByID; + bool treeViewAlwaysByPID; bool allBranchesCollapsed; } ScreenSettings; @@ -53,6 +59,7 @@ typedef struct Settings_ { MeterColumnSetting* hColumns; Hashtable* dynamicColumns; /* runtime-discovered columns */ Hashtable* dynamicMeters; /* runtime-discovered meters */ + Hashtable* dynamicScreens; /* runtime-discovered screens */ ScreenSettings** screens; unsigned int nScreens; @@ -106,7 +113,7 @@ typedef struct Settings_ { static inline RowField ScreenSettings_getActiveSortKey(const ScreenSettings* this) { return (this->treeView) - ? (this->treeViewAlwaysByID ? 1 : this->treeSortKey) + ? (this->treeViewAlwaysByPID ? 1 : this->treeSortKey) : this->sortKey; } @@ -118,10 +125,12 @@ void Settings_delete(Settings* this); int Settings_write(const Settings* this, bool onCrash); -Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicMeters, Hashtable* dynamicColumns); +Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicMeters, Hashtable* dynamicColumns, Hashtable* dynamicScreens); ScreenSettings* Settings_newScreen(Settings* this, const ScreenDefaults* defaults); +ScreenSettings* Settings_newDynamicScreen(Settings* this, const char* tab, const struct DynamicScreen_* screen, struct Table_* table); + void ScreenSettings_delete(ScreenSettings* this); void ScreenSettings_invertSortOrder(ScreenSettings* this); |