Improving Command display/sort

This commit is contained in:
Narendran Gopalakrishnan
2020-10-17 16:24:45 +05:30
committed by BenBE
parent 42c842c190
commit 09fe94da18
18 changed files with 593 additions and 16 deletions

View File

@ -416,6 +416,10 @@ void Process_done(Process* this) {
free(this->comm);
}
static const char* Process_getCommandStr(const Process* p) {
return p->comm ? p->comm : "";
}
const ProcessClass Process_class = {
.super = {
.extends = Class(Object),
@ -424,6 +428,7 @@ const ProcessClass Process_class = {
.compare = Process_compare
},
.writeField = Process_writeField,
.getCommandStr = Process_getCommandStr,
};
void Process_init(Process* this, const struct Settings_* settings) {
@ -503,7 +508,7 @@ long Process_compare(const void* v1, const void* v2) {
case PERCENT_MEM:
return SPACESHIP_NUMBER(p2->m_resident, p1->m_resident);
case COMM:
return SPACESHIP_NULLSTR(p1->comm, p2->comm);
return SPACESHIP_NULLSTR(Process_getCommand(p1), Process_getCommand(p2));
case MAJFLT:
return SPACESHIP_NUMBER(p2->majflt, p1->majflt);
case MINFLT: