summaryrefslogtreecommitdiffstats
path: root/unsupported
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2023-08-22 16:11:05 +1000
committerNathan Scott <nathans@redhat.com>2023-08-30 13:11:57 +1000
commit0f751e991d399769fb8d7800f7c4bccec2ca7f60 (patch)
tree34cd7838f7ebf51049816f9acb6a63cea175af06 /unsupported
parent68f4f10f012d11bd57bb725fe4113b2af937fc1d (diff)
Introduce Row and Table classes for screens beyond top-processes
This commit refactors the Process and ProcessList structures such they each have a new parent - Row and Table, respectively. These new classes handle screen updates relating to anything that could be represented in tabular format, e.g. cgroups, filesystems, etc, without us having to reimplement the display logic repeatedly for each new entity.
Diffstat (limited to 'unsupported')
-rw-r--r--unsupported/UnsupportedProcess.c26
-rw-r--r--unsupported/UnsupportedProcessList.c21
2 files changed, 28 insertions, 19 deletions
diff --git a/unsupported/UnsupportedProcess.c b/unsupported/UnsupportedProcess.c
index 4d8cb080..6df2e36a 100644
--- a/unsupported/UnsupportedProcess.c
+++ b/unsupported/UnsupportedProcess.c
@@ -58,21 +58,20 @@ void Process_delete(Object* cast) {
free(cast);
}
-static void UnsupportedProcess_writeField(const Process* this, RichString* str, ProcessField field) {
- const UnsupportedProcess* up = (const UnsupportedProcess*) this;
- bool coloring = this->host->settings->highlightMegabytes;
+static void UnsupportedProcess_rowWriteField(const Row* super, RichString* str, ProcessField field) {
+ const UnsupportedProcess* up = (const UnsupportedProcess*) super;
+ bool coloring = super->host->settings->highlightMegabytes;
char buffer[256]; buffer[255] = '\0';
int attr = CRT_colors[DEFAULT_COLOR];
size_t n = sizeof(buffer) - 1;
- (void) up;
(void) coloring;
(void) n;
switch (field) {
/* Add platform specific fields */
default:
- Process_writeField(this, str, field);
+ Process_writeField(&up->super, str, field);
return;
}
RichString_appendWide(str, attr, buffer);
@@ -94,11 +93,18 @@ static int UnsupportedProcess_compareByKey(const Process* v1, const Process* v2,
const ProcessClass UnsupportedProcess_class = {
.super = {
- .extends = Class(Process),
- .display = Process_display,
- .delete = Process_delete,
- .compare = Process_compare
+ .super = {
+ .extends = Class(Process),
+ .display = Row_display,
+ .delete = Process_delete,
+ .compare = Process_compare
+ },
+ .isHighlighted = Process_rowIsHighlighted,
+ .isVisible = Process_rowIsVisible,
+ .matchesFilter = Process_rowMatchesFilter,
+ .compareByParent = Process_compareByParent,
+ .sortKeyString = Process_rowGetSortKey,
+ .writeField = UnsupportedProcess_rowWriteField
},
- .writeField = UnsupportedProcess_writeField,
.compareByKey = UnsupportedProcess_compareByKey
};
diff --git a/unsupported/UnsupportedProcessList.c b/unsupported/UnsupportedProcessList.c
index e56f4978..1e29c17a 100644
--- a/unsupported/UnsupportedProcessList.c
+++ b/unsupported/UnsupportedProcessList.c
@@ -15,15 +15,18 @@ in the source distribution for its full text.
ProcessList* ProcessList_new(Machine* host, Hashtable* pidMatchList) {
- ProcessList* this = xCalloc(1, sizeof(ProcessList));
+ UnsupportedProcessList* this = xCalloc(1, sizeof(UnsupportedProcessList));
+ Object_setClass(this, Class(ProcessList));
- ProcessList_init(this, Class(Process), host, pidMatchList);
+ ProcessList* super = &this->super;
+ ProcessList_init(super, Class(Process), host, pidMatchList);
return this;
}
-void ProcessList_delete(ProcessList* this) {
- ProcessList_done(this);
+void ProcessList_delete(Object* cast) {
+ UnsupportedProcessList* this = (UnsupportedProcessList*) cast;
+ ProcessList_done(&this->super);
free(this);
}
@@ -35,9 +38,9 @@ void ProcessList_goThroughEntries(ProcessList* super) {
/* Empty values */
proc->time = proc->time + 10;
- proc->pid = 1;
- proc->ppid = 1;
- proc->tgid = 0;
+ Process_setPid(proc, 1);
+ Process_setParent(proc, 1);
+ Process_setThreadGroup(proc, 0);
Process_updateComm(proc, "commof16char");
Process_updateCmdline(proc, "<unsupported architecture>", 0, 0);
@@ -48,12 +51,12 @@ void ProcessList_goThroughEntries(ProcessList* super) {
free_and_xStrdup(&proc->procCwd, "/current/working/directory");
}
- proc->updated = true;
+ proc->super.updated = true;
proc->state = RUNNING;
proc->isKernelThread = false;
proc->isUserlandThread = false;
- proc->show = true; /* Reflected in settings-> "hideXXX" really */
+ proc->super.show = true; /* Reflected in settings-> "hideXXX" really */
proc->pgrp = 0;
proc->session = 0;
proc->tty_nr = 0;

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