Merge branch 'misc' of https://github.com/cgzones/htop into cgzones-misc

This commit is contained in:
Christian Göttsche 2020-12-22 17:30:29 +11:00 committed by Nathan Scott
commit 3fb0024fd3
6 changed files with 25 additions and 35 deletions

View File

@ -14,15 +14,6 @@
#include "XUtils.h" #include "XUtils.h"
const InfoScreenClass EnvScreen_class = {
.super = {
.extends = Class(Object),
.delete = EnvScreen_delete
},
.scan = EnvScreen_scan,
.draw = EnvScreen_draw
};
EnvScreen* EnvScreen_new(Process* process) { EnvScreen* EnvScreen_new(Process* process) {
EnvScreen* this = xMalloc(sizeof(EnvScreen)); EnvScreen* this = xMalloc(sizeof(EnvScreen));
Object_setClass(this, Class(EnvScreen)); Object_setClass(this, Class(EnvScreen));
@ -33,11 +24,11 @@ void EnvScreen_delete(Object* this) {
free(InfoScreen_done((InfoScreen*)this)); free(InfoScreen_done((InfoScreen*)this));
} }
void EnvScreen_draw(InfoScreen* this) { static void EnvScreen_draw(InfoScreen* this) {
InfoScreen_drawTitled(this, "Environment of process %d - %s", this->process->pid, Process_getCommand(this->process)); InfoScreen_drawTitled(this, "Environment of process %d - %s", this->process->pid, Process_getCommand(this->process));
} }
void EnvScreen_scan(InfoScreen* this) { static void EnvScreen_scan(InfoScreen* this) {
Panel* panel = this->display; Panel* panel = this->display;
int idx = MAXIMUM(Panel_getSelectedIndex(panel), 0); int idx = MAXIMUM(Panel_getSelectedIndex(panel), 0);
@ -59,3 +50,12 @@ void EnvScreen_scan(InfoScreen* this) {
Vector_insertionSort(panel->items); Vector_insertionSort(panel->items);
Panel_setSelected(panel, idx); Panel_setSelected(panel, idx);
} }
const InfoScreenClass EnvScreen_class = {
.super = {
.extends = Class(Object),
.delete = EnvScreen_delete
},
.scan = EnvScreen_scan,
.draw = EnvScreen_draw
};

View File

@ -15,8 +15,4 @@ EnvScreen* EnvScreen_new(Process* process);
void EnvScreen_delete(Object* this); void EnvScreen_delete(Object* this);
void EnvScreen_draw(InfoScreen* this);
void EnvScreen_scan(InfoScreen* this);
#endif #endif

View File

@ -16,7 +16,6 @@ typedef struct InfoScreen_ {
Object super; Object super;
const Process* process; const Process* process;
Panel* display; Panel* display;
FunctionBar* bar;
IncSet* inc; IncSet* inc;
Vector* lines; Vector* lines;
} InfoScreen; } InfoScreen;

View File

@ -55,6 +55,7 @@ void Panel_init(Panel* this, int x, int y, int w, int h, const ObjectClass* type
this->scrollH = 0; this->scrollH = 0;
this->selected = 0; this->selected = 0;
this->oldSelected = 0; this->oldSelected = 0;
this->selectedLen = 0;
this->needsRedraw = true; this->needsRedraw = true;
this->wasFocus = false; this->wasFocus = false;
RichString_beginAllocated(this->header); RichString_beginAllocated(this->header);

View File

@ -35,16 +35,6 @@ static const char* const TraceScreenKeys[] = {"F3", "F4", "F8", "F9", "Esc"};
static const int TraceScreenEvents[] = {KEY_F(3), KEY_F(4), KEY_F(8), KEY_F(9), 27}; static const int TraceScreenEvents[] = {KEY_F(3), KEY_F(4), KEY_F(8), KEY_F(9), 27};
const InfoScreenClass TraceScreen_class = {
.super = {
.extends = Class(Object),
.delete = TraceScreen_delete
},
.draw = TraceScreen_draw,
.onErr = TraceScreen_updateTrace,
.onKey = TraceScreen_onKey,
};
TraceScreen* TraceScreen_new(Process* process) { TraceScreen* TraceScreen_new(Process* process) {
// This initializes all TraceScreen variables to "false" so only default = true ones need to be set below // This initializes all TraceScreen variables to "false" so only default = true ones need to be set below
TraceScreen* this = xCalloc(1, sizeof(TraceScreen)); TraceScreen* this = xCalloc(1, sizeof(TraceScreen));
@ -70,7 +60,7 @@ void TraceScreen_delete(Object* cast) {
free(InfoScreen_done((InfoScreen*)this)); free(InfoScreen_done((InfoScreen*)this));
} }
void TraceScreen_draw(InfoScreen* this) { static void TraceScreen_draw(InfoScreen* this) {
InfoScreen_drawTitled(this, "Trace of process %d - %s", this->process->pid, Process_getCommand(this->process)); InfoScreen_drawTitled(this, "Trace of process %d - %s", this->process->pid, Process_getCommand(this->process));
} }
@ -127,7 +117,7 @@ err:
return false; return false;
} }
void TraceScreen_updateTrace(InfoScreen* super) { static void TraceScreen_updateTrace(InfoScreen* super) {
TraceScreen* this = (TraceScreen*) super; TraceScreen* this = (TraceScreen*) super;
char buffer[1025]; char buffer[1025];
@ -172,7 +162,7 @@ void TraceScreen_updateTrace(InfoScreen* super) {
} }
} }
bool TraceScreen_onKey(InfoScreen* super, int ch) { static bool TraceScreen_onKey(InfoScreen* super, int ch) {
TraceScreen* this = (TraceScreen*) super; TraceScreen* this = (TraceScreen*) super;
switch(ch) { switch(ch) {
case 'f': case 'f':
@ -191,3 +181,13 @@ bool TraceScreen_onKey(InfoScreen* super, int ch) {
this->follow = false; this->follow = false;
return false; return false;
} }
const InfoScreenClass TraceScreen_class = {
.super = {
.extends = Class(Object),
.delete = TraceScreen_delete
},
.draw = TraceScreen_draw,
.onErr = TraceScreen_updateTrace,
.onKey = TraceScreen_onKey,
};

View File

@ -32,12 +32,6 @@ TraceScreen* TraceScreen_new(Process* process);
void TraceScreen_delete(Object* cast); void TraceScreen_delete(Object* cast);
void TraceScreen_draw(InfoScreen* this);
bool TraceScreen_forkTracer(TraceScreen* this); bool TraceScreen_forkTracer(TraceScreen* this);
void TraceScreen_updateTrace(InfoScreen* super);
bool TraceScreen_onKey(InfoScreen* super, int ch);
#endif #endif