summaryrefslogtreecommitdiffstats
path: root/Row.c
diff options
context:
space:
mode:
authorSohaib Mohamed <sohaib.amhmd@gmail.com>2023-08-22 16:46:59 +1000
committerNathan Scott <nathans@redhat.com>2023-08-30 13:11:57 +1000
commit53bdcab942298e0e452d62237bc18e3a4cd551cf (patch)
treee7a62910b9f4a1a58560a4ded2e6f7e83d0b631e /Row.c
parent0f751e991d399769fb8d7800f7c4bccec2ca7f60 (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 'Row.c')
-rw-r--r--Row.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/Row.c b/Row.c
index 09a32069..67893d39 100644
--- a/Row.c
+++ b/Row.c
@@ -40,6 +40,11 @@ void Row_init(Row* this, const Machine* host) {
this->updated = false;
}
+void Row_done(Row* this) {
+ assert(this != NULL);
+ (void) this;
+}
+
static inline bool Row_isNew(const Row* this) {
const Machine* host = this->host;
if (host->monotonicMs < this->seenStampMs)
@@ -56,7 +61,7 @@ static inline bool Row_isTomb(const Row* this) {
void Row_display(const Object* cast, RichString* out) {
const Row* this = (const Row*) cast;
const Settings* settings = this->host->settings;
- const ProcessField* fields = settings->ss->fields;
+ const RowField* fields = settings->ss->fields;
for (int i = 0; fields[i]; i++)
As_Row(this)->writeField(this, out, fields[i]);
@@ -127,7 +132,7 @@ static const char* alignedTitleDynamicColumn(const Settings* settings, int key,
if (!width || abs(width) > DYNAMIC_MAX_COLUMN_WIDTH)
width = DYNAMIC_DEFAULT_COLUMN_WIDTH;
- xSnprintf(titleBuffer, titleBufferSize, "%*s", width, column->heading);
+ xSnprintf(titleBuffer, titleBufferSize, "%*s ", width, column->heading);
return titleBuffer;
}
@@ -430,7 +435,7 @@ void Row_printLeftAlignedField(RichString* str, int attr, const char* content, u
RichString_appendChr(str, attr, ' ', width + 1 - columns);
}
-void Row_printPercentage(float val, char* buffer, size_t n, uint8_t width, int* attr) {
+int Row_printPercentage(float val, char* buffer, size_t n, uint8_t width, int* attr) {
if (isNonnegative(val)) {
if (val < 0.05F)
*attr = CRT_colors[PROCESS_SHADOW];
@@ -445,11 +450,11 @@ void Row_printPercentage(float val, char* buffer, size_t n, uint8_t width, int*
val = 100.0F;
}
- xSnprintf(buffer, n, "%*.*f ", width, precision, val);
- } else {
- *attr = CRT_colors[PROCESS_SHADOW];
- xSnprintf(buffer, n, "%*.*s ", width, width, "N/A");
+ return xSnprintf(buffer, n, "%*.*f ", width, precision, val);
}
+
+ *attr = CRT_colors[PROCESS_SHADOW];
+ return xSnprintf(buffer, n, "%*.*s ", width, width, "N/A");
}
void Row_toggleTag(Row* this) {

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