summaryrefslogtreecommitdiffstats
path: root/darwin
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2015-08-20 00:32:47 -0300
committerHisham Muhammad <hisham@gobolinux.org>2015-08-20 00:32:47 -0300
commit9428010121d849344b33b66dec312b6a51ea564f (patch)
treeae4284959359c87a1748240e5a568742e7e1db00 /darwin
parent8bd603cb68fb5dd768b5b23ffe0c6f09f5340ceb (diff)
Make column width calculation dynamic.
Closes #228.
Diffstat (limited to 'darwin')
-rw-r--r--darwin/Platform.c33
-rw-r--r--darwin/Platform.h3
2 files changed, 9 insertions, 27 deletions
diff --git a/darwin/Platform.c b/darwin/Platform.c
index 57c4d0ce..2c8ed2cf 100644
--- a/darwin/Platform.c
+++ b/darwin/Platform.c
@@ -82,7 +82,6 @@ void Platform_setBindings(Htop_Action* keys) {
int Platform_numberOfFields = 100;
char* Process_pidFormat = "%7u ";
-char* Process_tpgidFormat = "%7u ";
int Platform_getUptime() {
struct timeval bootTime, currTime;
@@ -117,29 +116,15 @@ int Platform_getMaxPid() {
return 99999;
}
-void Process_setupColumnWidths() {
- int maxPid = Platform_getMaxPid();
- if (maxPid == -1) return;
- if (maxPid > 99999) {
- Process_fields[PID].title = " PID ";
- Process_fields[PPID].title = " PPID ";
- Process_fields[TPGID].title = " TPGID ";
- Process_fields[TGID].title = " TGID ";
- Process_fields[PGRP].title = " PGRP ";
- Process_fields[SESSION].title = " SESN ";
- Process_pidFormat = "%7u ";
- Process_tpgidFormat = "%7d ";
- } else {
- Process_fields[PID].title = " PID ";
- Process_fields[PPID].title = " PPID ";
- Process_fields[TPGID].title = "TPGID ";
- Process_fields[TGID].title = " TGID ";
- Process_fields[PGRP].title = " PGRP ";
- Process_fields[SESSION].title = " SESN ";
- Process_pidFormat = "%5u ";
- Process_tpgidFormat = "%5d ";
- }
-}
+ProcessPidColumn Process_pidColumns[] = {
+ { .id = PID, .label = "PID" },
+ { .id = PPID, .label = "PPID" },
+ { .id = TPGID, .label = "TPGID" },
+ { .id = TGID, .label = "TGID" },
+ { .id = PGRP, .label = "PGRP" },
+ { .id = SESSION, .label = "SESN" },
+ { .id = 0, .label = NULL },
+};
double Platform_setCPUValues(Meter* mtr, int cpu) {
/* All just from CPUMeter.c */
diff --git a/darwin/Platform.h b/darwin/Platform.h
index eaf0cd7f..f670c7f6 100644
--- a/darwin/Platform.h
+++ b/darwin/Platform.h
@@ -24,7 +24,6 @@ void Platform_setBindings(Htop_Action* keys);
extern int Platform_numberOfFields;
extern char* Process_pidFormat;
-extern char* Process_tpgidFormat;
int Platform_getUptime();
@@ -32,8 +31,6 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen);
int Platform_getMaxPid();
-void Process_setupColumnWidths();
-
double Platform_setCPUValues(Meter* mtr, int cpu);
void Platform_setMemoryValues(Meter* mtr);

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