mirror of https://github.com/xzeldon/htop.git
Remove references to ListBox
This commit is contained in:
parent
73de9f1ed4
commit
ea855aef73
|
@ -15,8 +15,8 @@ typedef struct AvailableMetersPanel_ {
|
||||||
Panel super;
|
Panel super;
|
||||||
|
|
||||||
Settings* settings;
|
Settings* settings;
|
||||||
Panel* leftBox;
|
Panel* leftPanel;
|
||||||
Panel* rightBox;
|
Panel* rightPanel;
|
||||||
ScreenManager* scr;
|
ScreenManager* scr;
|
||||||
} AvailableMetersPanel;
|
} AvailableMetersPanel;
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@ AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Panel* leftMe
|
||||||
((Object*)this)->delete = AvailableMetersPanel_delete;
|
((Object*)this)->delete = AvailableMetersPanel_delete;
|
||||||
|
|
||||||
this->settings = settings;
|
this->settings = settings;
|
||||||
this->leftBox = leftMeters;
|
this->leftPanel = leftMeters;
|
||||||
this->rightBox = rightMeters;
|
this->rightPanel = rightMeters;
|
||||||
this->scr = scr;
|
this->scr = scr;
|
||||||
super->eventHandler = AvailableMetersPanel_EventHandler;
|
super->eventHandler = AvailableMetersPanel_EventHandler;
|
||||||
|
|
||||||
|
@ -64,9 +64,9 @@ void AvailableMetersPanel_delete(Object* object) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* private */
|
/* private */
|
||||||
inline void AvailableMetersPanel_addHeader(Header* header, Panel* lb, MeterType* type, int param, HeaderSide side) {
|
inline void AvailableMetersPanel_addHeader(Header* header, Panel* panel, MeterType* type, int param, HeaderSide side) {
|
||||||
Meter* meter = (Meter*) Header_addMeter(header, type, param, side);
|
Meter* meter = (Meter*) Header_addMeter(header, type, param, side);
|
||||||
Panel_add(lb, (Object*) Meter_toListItem(meter));
|
Panel_add(panel, (Object*) Meter_toListItem(meter));
|
||||||
}
|
}
|
||||||
|
|
||||||
HandlerResult AvailableMetersPanel_EventHandler(Panel* super, int ch) {
|
HandlerResult AvailableMetersPanel_EventHandler(Panel* super, int ch) {
|
||||||
|
@ -83,7 +83,7 @@ HandlerResult AvailableMetersPanel_EventHandler(Panel* super, int ch) {
|
||||||
case 'l':
|
case 'l':
|
||||||
case 'L':
|
case 'L':
|
||||||
{
|
{
|
||||||
AvailableMetersPanel_addHeader(header, this->leftBox, Meter_types[type], param, LEFT_HEADER);
|
AvailableMetersPanel_addHeader(header, this->leftPanel, Meter_types[type], param, LEFT_HEADER);
|
||||||
result = HANDLED;
|
result = HANDLED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ HandlerResult AvailableMetersPanel_EventHandler(Panel* super, int ch) {
|
||||||
case 'r':
|
case 'r':
|
||||||
case 'R':
|
case 'R':
|
||||||
{
|
{
|
||||||
AvailableMetersPanel_addHeader(header, this->rightBox, Meter_types[type], param, RIGHT_HEADER);
|
AvailableMetersPanel_addHeader(header, this->rightPanel, Meter_types[type], param, RIGHT_HEADER);
|
||||||
result = HANDLED;
|
result = HANDLED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ typedef struct AvailableMetersPanel_ {
|
||||||
Panel super;
|
Panel super;
|
||||||
|
|
||||||
Settings* settings;
|
Settings* settings;
|
||||||
Panel* leftBox;
|
Panel* leftPanel;
|
||||||
Panel* rightBox;
|
Panel* rightPanel;
|
||||||
ScreenManager* scr;
|
ScreenManager* scr;
|
||||||
} AvailableMetersPanel;
|
} AvailableMetersPanel;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
|
|
||||||
|
What's new in version 0.6.3
|
||||||
|
|
||||||
|
* Internal change: rename TypedVector to Vector and
|
||||||
|
ListBox (and related classes) to Panel.
|
||||||
|
|
||||||
What's new in version 0.6.2
|
What's new in version 0.6.2
|
||||||
|
|
||||||
* BUGFIX: Fixed crash when using some .htoprc files from 0.6
|
* BUGFIX: Fixed crash when using some .htoprc files from 0.6
|
||||||
|
|
|
@ -91,11 +91,11 @@ void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int
|
||||||
|
|
||||||
Panel* ScreenManager_remove(ScreenManager* this, int index) {
|
Panel* ScreenManager_remove(ScreenManager* this, int index) {
|
||||||
assert(this->itemCount > index);
|
assert(this->itemCount > index);
|
||||||
Panel* lb = (Panel*) Vector_remove(this->items, index);
|
Panel* panel = (Panel*) Vector_remove(this->items, index);
|
||||||
Vector_remove(this->fuBars, index);
|
Vector_remove(this->fuBars, index);
|
||||||
this->fuBar = NULL;
|
this->fuBar = NULL;
|
||||||
this->itemCount--;
|
this->itemCount--;
|
||||||
return lb;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenManager_setFunctionBar(ScreenManager* this, FunctionBar* fuBar) {
|
void ScreenManager_setFunctionBar(ScreenManager* this, FunctionBar* fuBar) {
|
||||||
|
@ -112,21 +112,21 @@ void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2) {
|
||||||
int items = this->itemCount;
|
int items = this->itemCount;
|
||||||
int lastX = 0;
|
int lastX = 0;
|
||||||
for (int i = 0; i < items - 1; i++) {
|
for (int i = 0; i < items - 1; i++) {
|
||||||
Panel* lb = (Panel*) Vector_get(this->items, i);
|
Panel* panel = (Panel*) Vector_get(this->items, i);
|
||||||
Panel_resize(lb, lb->w, LINES-y1+y2);
|
Panel_resize(panel, panel->w, LINES-y1+y2);
|
||||||
Panel_move(lb, lastX, y1);
|
Panel_move(panel, lastX, y1);
|
||||||
lastX = lb->x + lb->w + 1;
|
lastX = panel->x + panel->w + 1;
|
||||||
}
|
}
|
||||||
Panel* lb = (Panel*) Vector_get(this->items, items-1);
|
Panel* panel = (Panel*) Vector_get(this->items, items-1);
|
||||||
Panel_resize(lb, COLS-x1+x2-lastX, LINES-y1+y2);
|
Panel_resize(panel, COLS-x1+x2-lastX, LINES-y1+y2);
|
||||||
Panel_move(lb, lastX, y1);
|
Panel_move(panel, lastX, y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
int focus = 0;
|
int focus = 0;
|
||||||
|
|
||||||
Panel* lbFocus = (Panel*) Vector_get(this->items, focus);
|
Panel* panelFocus = (Panel*) Vector_get(this->items, focus);
|
||||||
if (this->fuBar)
|
if (this->fuBar)
|
||||||
FunctionBar_draw(this->fuBar, NULL);
|
FunctionBar_draw(this->fuBar, NULL);
|
||||||
|
|
||||||
|
@ -134,11 +134,11 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||||
while (!quit) {
|
while (!quit) {
|
||||||
int items = this->itemCount;
|
int items = this->itemCount;
|
||||||
for (int i = 0; i < items; i++) {
|
for (int i = 0; i < items; i++) {
|
||||||
Panel* lb = (Panel*) Vector_get(this->items, i);
|
Panel* panel = (Panel*) Vector_get(this->items, i);
|
||||||
Panel_draw(lb, i == focus);
|
Panel_draw(panel, i == focus);
|
||||||
if (i < items) {
|
if (i < items) {
|
||||||
if (this->orientation == HORIZONTAL) {
|
if (this->orientation == HORIZONTAL) {
|
||||||
mvvline(lb->y, lb->x+lb->w, ' ', lb->h+1);
|
mvvline(panel->y, panel->x+panel->w, ' ', panel->h+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,12 +159,12 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||||
ch = FunctionBar_synthesizeEvent(this->fuBar, mevent.x);
|
ch = FunctionBar_synthesizeEvent(this->fuBar, mevent.x);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < this->itemCount; i++) {
|
for (int i = 0; i < this->itemCount; i++) {
|
||||||
Panel* lb = (Panel*) Vector_get(this->items, i);
|
Panel* panel = (Panel*) Vector_get(this->items, i);
|
||||||
if (mevent.x > lb->x && mevent.x <= lb->x+lb->w &&
|
if (mevent.x > panel->x && mevent.x <= panel->x+panel->w &&
|
||||||
mevent.y > lb->y && mevent.y <= lb->y+lb->h) {
|
mevent.y > panel->y && mevent.y <= panel->y+panel->h) {
|
||||||
focus = i;
|
focus = i;
|
||||||
lbFocus = lb;
|
panelFocus = panel;
|
||||||
Panel_setSelected(lb, mevent.y - lb->y + lb->scrollV - 1);
|
Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV - 1);
|
||||||
loop = true;
|
loop = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -174,8 +174,8 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||||
}
|
}
|
||||||
if (loop) continue;
|
if (loop) continue;
|
||||||
|
|
||||||
if (lbFocus->eventHandler) {
|
if (panelFocus->eventHandler) {
|
||||||
HandlerResult result = lbFocus->eventHandler(lbFocus, ch);
|
HandlerResult result = panelFocus->eventHandler(panelFocus, ch);
|
||||||
if (result == HANDLED) {
|
if (result == HANDLED) {
|
||||||
continue;
|
continue;
|
||||||
} else if (result == BREAK_LOOP) {
|
} else if (result == BREAK_LOOP) {
|
||||||
|
@ -196,8 +196,8 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||||
tryLeft:
|
tryLeft:
|
||||||
if (focus > 0)
|
if (focus > 0)
|
||||||
focus--;
|
focus--;
|
||||||
lbFocus = (Panel*) Vector_get(this->items, focus);
|
panelFocus = (Panel*) Vector_get(this->items, focus);
|
||||||
if (Panel_getSize(lbFocus) == 0 && focus > 0)
|
if (Panel_getSize(panelFocus) == 0 && focus > 0)
|
||||||
goto tryLeft;
|
goto tryLeft;
|
||||||
break;
|
break;
|
||||||
case KEY_RIGHT:
|
case KEY_RIGHT:
|
||||||
|
@ -205,8 +205,8 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||||
tryRight:
|
tryRight:
|
||||||
if (focus < this->itemCount - 1)
|
if (focus < this->itemCount - 1)
|
||||||
focus++;
|
focus++;
|
||||||
lbFocus = (Panel*) Vector_get(this->items, focus);
|
panelFocus = (Panel*) Vector_get(this->items, focus);
|
||||||
if (Panel_getSize(lbFocus) == 0 && focus < this->itemCount - 1)
|
if (Panel_getSize(panelFocus) == 0 && focus < this->itemCount - 1)
|
||||||
goto tryRight;
|
goto tryRight;
|
||||||
break;
|
break;
|
||||||
case KEY_F(10):
|
case KEY_F(10):
|
||||||
|
@ -215,11 +215,11 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||||
quit = true;
|
quit = true;
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
Panel_onKey(lbFocus, ch);
|
Panel_onKey(panelFocus, ch);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*lastFocus = lbFocus;
|
*lastFocus = panelFocus;
|
||||||
*lastKey = ch;
|
*lastKey = ch;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ void TraceScreen_run(TraceScreen* this) {
|
||||||
}
|
}
|
||||||
fcntl(fdpair[0], F_SETFL, O_NONBLOCK);
|
fcntl(fdpair[0], F_SETFL, O_NONBLOCK);
|
||||||
FILE* strace = fdopen(fdpair[0], "r");
|
FILE* strace = fdopen(fdpair[0], "r");
|
||||||
Panel* lb = this->display;
|
Panel* panel = this->display;
|
||||||
int fd_strace = fileno(strace);
|
int fd_strace = fileno(strace);
|
||||||
TraceScreen_draw(this);
|
TraceScreen_draw(this);
|
||||||
CRT_disableDelay();
|
CRT_disableDelay();
|
||||||
|
@ -105,31 +105,31 @@ void TraceScreen_run(TraceScreen* this) {
|
||||||
if (buffer[i] == '\n') {
|
if (buffer[i] == '\n') {
|
||||||
buffer[i] = '\0';
|
buffer[i] = '\0';
|
||||||
if (contLine) {
|
if (contLine) {
|
||||||
ListItem_append((ListItem*)Panel_get(lb,
|
ListItem_append((ListItem*)Panel_get(panel,
|
||||||
Panel_getSize(lb)-1), line);
|
Panel_getSize(panel)-1), line);
|
||||||
contLine = false;
|
contLine = false;
|
||||||
} else {
|
} else {
|
||||||
Panel_add(lb, (Object*) ListItem_new(line, 0));
|
Panel_add(panel, (Object*) ListItem_new(line, 0));
|
||||||
}
|
}
|
||||||
line = buffer+i+1;
|
line = buffer+i+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (line < buffer+nread) {
|
if (line < buffer+nread) {
|
||||||
Panel_add(lb, (Object*) ListItem_new(line, 0));
|
Panel_add(panel, (Object*) ListItem_new(line, 0));
|
||||||
buffer[nread] = '\0';
|
buffer[nread] = '\0';
|
||||||
contLine = true;
|
contLine = true;
|
||||||
}
|
}
|
||||||
if (follow)
|
if (follow)
|
||||||
Panel_setSelected(lb, Panel_getSize(lb)-1);
|
Panel_setSelected(panel, Panel_getSize(panel)-1);
|
||||||
Panel_draw(lb, true);
|
Panel_draw(panel, true);
|
||||||
}
|
}
|
||||||
int ch = getch();
|
int ch = getch();
|
||||||
if (ch == KEY_MOUSE) {
|
if (ch == KEY_MOUSE) {
|
||||||
MEVENT mevent;
|
MEVENT mevent;
|
||||||
int ok = getmouse(&mevent);
|
int ok = getmouse(&mevent);
|
||||||
if (ok == OK)
|
if (ok == OK)
|
||||||
if (mevent.y >= lb->y && mevent.y < LINES - 1) {
|
if (mevent.y >= panel->y && mevent.y < LINES - 1) {
|
||||||
Panel_setSelected(lb, mevent.y - lb->y + lb->scrollV);
|
Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV);
|
||||||
follow = false;
|
follow = false;
|
||||||
ch = 0;
|
ch = 0;
|
||||||
} if (mevent.y == LINES - 1)
|
} if (mevent.y == LINES - 1)
|
||||||
|
@ -147,21 +147,21 @@ void TraceScreen_run(TraceScreen* this) {
|
||||||
case KEY_F(4):
|
case KEY_F(4):
|
||||||
follow = !follow;
|
follow = !follow;
|
||||||
if (follow)
|
if (follow)
|
||||||
Panel_setSelected(lb, Panel_getSize(lb)-1);
|
Panel_setSelected(panel, Panel_getSize(panel)-1);
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
case 27:
|
case 27:
|
||||||
looping = false;
|
looping = false;
|
||||||
break;
|
break;
|
||||||
case KEY_RESIZE:
|
case KEY_RESIZE:
|
||||||
Panel_resize(lb, COLS, LINES-2);
|
Panel_resize(panel, COLS, LINES-2);
|
||||||
TraceScreen_draw(this);
|
TraceScreen_draw(this);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
follow = false;
|
follow = false;
|
||||||
Panel_onKey(lb, ch);
|
Panel_onKey(panel, ch);
|
||||||
}
|
}
|
||||||
Panel_draw(lb, true);
|
Panel_draw(panel, true);
|
||||||
}
|
}
|
||||||
kill(child, SIGTERM);
|
kill(child, SIGTERM);
|
||||||
waitpid(child, NULL, 0);
|
waitpid(child, NULL, 0);
|
||||||
|
|
166
htop.c
166
htop.c
|
@ -126,62 +126,62 @@ void showHelp() {
|
||||||
|
|
||||||
static void Setup_run(Settings* settings, int headerHeight) {
|
static void Setup_run(Settings* settings, int headerHeight) {
|
||||||
ScreenManager* scr = ScreenManager_new(0, headerHeight, 0, -1, HORIZONTAL, true);
|
ScreenManager* scr = ScreenManager_new(0, headerHeight, 0, -1, HORIZONTAL, true);
|
||||||
CategoriesPanel* lbCategories = CategoriesPanel_new(settings, scr);
|
CategoriesPanel* panelCategories = CategoriesPanel_new(settings, scr);
|
||||||
ScreenManager_add(scr, (Panel*) lbCategories, NULL, 16);
|
ScreenManager_add(scr, (Panel*) panelCategories, NULL, 16);
|
||||||
CategoriesPanel_makeMetersPage(lbCategories);
|
CategoriesPanel_makeMetersPage(panelCategories);
|
||||||
Panel* lbFocus;
|
Panel* panelFocus;
|
||||||
int ch;
|
int ch;
|
||||||
ScreenManager_run(scr, &lbFocus, &ch);
|
ScreenManager_run(scr, &panelFocus, &ch);
|
||||||
ScreenManager_delete(scr);
|
ScreenManager_delete(scr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool changePriority(Panel* lb, int delta) {
|
static bool changePriority(Panel* panel, int delta) {
|
||||||
bool anyTagged = false;
|
bool anyTagged = false;
|
||||||
for (int i = 0; i < Panel_getSize(lb); i++) {
|
for (int i = 0; i < Panel_getSize(panel); i++) {
|
||||||
Process* p = (Process*) Panel_get(lb, i);
|
Process* p = (Process*) Panel_get(panel, i);
|
||||||
if (p->tag) {
|
if (p->tag) {
|
||||||
Process_setPriority(p, p->nice + delta);
|
Process_setPriority(p, p->nice + delta);
|
||||||
anyTagged = true;
|
anyTagged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!anyTagged) {
|
if (!anyTagged) {
|
||||||
Process* p = (Process*) Panel_getSelected(lb);
|
Process* p = (Process*) Panel_getSelected(panel);
|
||||||
Process_setPriority(p, p->nice + delta);
|
Process_setPriority(p, p->nice + delta);
|
||||||
}
|
}
|
||||||
return anyTagged;
|
return anyTagged;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HandlerResult pickWithEnter(Panel* lb, int ch) {
|
static HandlerResult pickWithEnter(Panel* panel, int ch) {
|
||||||
if (ch == 13)
|
if (ch == 13)
|
||||||
return BREAK_LOOP;
|
return BREAK_LOOP;
|
||||||
return IGNORED;
|
return IGNORED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Object* pickFromList(Panel* lb, Panel* list, int x, int y, char** keyLabels, FunctionBar* prevBar) {
|
static Object* pickFromList(Panel* panel, Panel* list, int x, int y, char** keyLabels, FunctionBar* prevBar) {
|
||||||
char* fuKeys[2] = {"Enter", "Esc"};
|
char* fuKeys[2] = {"Enter", "Esc"};
|
||||||
int fuEvents[2] = {13, 27};
|
int fuEvents[2] = {13, 27};
|
||||||
if (!lb->eventHandler)
|
if (!panel->eventHandler)
|
||||||
Panel_setEventHandler(list, pickWithEnter);
|
Panel_setEventHandler(list, pickWithEnter);
|
||||||
ScreenManager* scr = ScreenManager_new(0, y, 0, -1, HORIZONTAL, false);
|
ScreenManager* scr = ScreenManager_new(0, y, 0, -1, HORIZONTAL, false);
|
||||||
ScreenManager_add(scr, list, FunctionBar_new(2, keyLabels, fuKeys, fuEvents), x - 1);
|
ScreenManager_add(scr, list, FunctionBar_new(2, keyLabels, fuKeys, fuEvents), x - 1);
|
||||||
ScreenManager_add(scr, lb, NULL, -1);
|
ScreenManager_add(scr, panel, NULL, -1);
|
||||||
Panel* lbFocus;
|
Panel* panelFocus;
|
||||||
int ch;
|
int ch;
|
||||||
ScreenManager_run(scr, &lbFocus, &ch);
|
ScreenManager_run(scr, &panelFocus, &ch);
|
||||||
ScreenManager_delete(scr);
|
ScreenManager_delete(scr);
|
||||||
Panel_move(lb, 0, y);
|
Panel_move(panel, 0, y);
|
||||||
Panel_resize(lb, COLS, LINES-y-1);
|
Panel_resize(panel, COLS, LINES-y-1);
|
||||||
FunctionBar_draw(prevBar, NULL);
|
FunctionBar_draw(prevBar, NULL);
|
||||||
if (lbFocus == list && ch == 13) {
|
if (panelFocus == list && ch == 13) {
|
||||||
return Panel_getSelected(list);
|
return Panel_getSelected(list);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addUserToList(int key, void* userCast, void* lbCast) {
|
void addUserToList(int key, void* userCast, void* panelCast) {
|
||||||
char* user = (char*) userCast;
|
char* user = (char*) userCast;
|
||||||
Panel* lb = (Panel*) lbCast;
|
Panel* panel = (Panel*) panelCast;
|
||||||
Panel_add(lb, (Object*) ListItem_new(user, key));
|
Panel_add(panel, (Object*) ListItem_new(user, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUserOnly(const char* userName, bool* userOnly, uid_t* userId) {
|
void setUserOnly(const char* userName, bool* userOnly, uid_t* userId) {
|
||||||
|
@ -219,14 +219,14 @@ int main(int argc, char** argv) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Panel* lb;
|
Panel* panel;
|
||||||
int quit = 0;
|
int quit = 0;
|
||||||
int refreshTimeout = 0;
|
int refreshTimeout = 0;
|
||||||
int resetRefreshTimeout = 5;
|
int resetRefreshTimeout = 5;
|
||||||
bool doRefresh = true;
|
bool doRefresh = true;
|
||||||
Settings* settings;
|
Settings* settings;
|
||||||
|
|
||||||
Panel* lbk = NULL;
|
Panel* killPanel = NULL;
|
||||||
|
|
||||||
char incSearchBuffer[INCSEARCH_MAX];
|
char incSearchBuffer[INCSEARCH_MAX];
|
||||||
int incSearchIndex = 0;
|
int incSearchIndex = 0;
|
||||||
|
@ -248,8 +248,8 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
CRT_init(settings->delay, settings->colorScheme);
|
CRT_init(settings->delay, settings->colorScheme);
|
||||||
|
|
||||||
lb = Panel_new(0, headerHeight, COLS, LINES - headerHeight - 2, PROCESS_CLASS, false);
|
panel = Panel_new(0, headerHeight, COLS, LINES - headerHeight - 2, PROCESS_CLASS, false);
|
||||||
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
|
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
|
||||||
|
|
||||||
char* searchFunctions[3] = {"Next ", "Exit ", " Search: "};
|
char* searchFunctions[3] = {"Next ", "Exit ", " Search: "};
|
||||||
char* searchKeys[3] = {"F3", "Esc", " "};
|
char* searchKeys[3] = {"F3", "Esc", " "};
|
||||||
|
@ -285,9 +285,9 @@ int main(int argc, char** argv) {
|
||||||
if (doRefresh) {
|
if (doRefresh) {
|
||||||
incSearchIndex = 0;
|
incSearchIndex = 0;
|
||||||
incSearchBuffer[0] = 0;
|
incSearchBuffer[0] = 0;
|
||||||
int currPos = Panel_getSelectedIndex(lb);
|
int currPos = Panel_getSelectedIndex(panel);
|
||||||
int currPid = 0;
|
int currPid = 0;
|
||||||
int currScrollV = lb->scrollV;
|
int currScrollV = panel->scrollV;
|
||||||
if (follow)
|
if (follow)
|
||||||
currPid = ProcessList_get(pl, currPos)->pid;
|
currPid = ProcessList_get(pl, currPos)->pid;
|
||||||
if (recalculate)
|
if (recalculate)
|
||||||
|
@ -296,18 +296,18 @@ int main(int argc, char** argv) {
|
||||||
ProcessList_sort(pl);
|
ProcessList_sort(pl);
|
||||||
refreshTimeout = 1;
|
refreshTimeout = 1;
|
||||||
}
|
}
|
||||||
Panel_prune(lb);
|
Panel_prune(panel);
|
||||||
int size = ProcessList_size(pl);
|
int size = ProcessList_size(pl);
|
||||||
int lbi = 0;
|
int index = 0;
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
Process* p = ProcessList_get(pl, i);
|
Process* p = ProcessList_get(pl, i);
|
||||||
if (!userOnly || (p->st_uid == userId)) {
|
if (!userOnly || (p->st_uid == userId)) {
|
||||||
Panel_set(lb, lbi, (Object*)p);
|
Panel_set(panel, index, (Object*)p);
|
||||||
if ((!follow && lbi == currPos) || (follow && p->pid == currPid)) {
|
if ((!follow && index == currPos) || (follow && p->pid == currPid)) {
|
||||||
Panel_setSelected(lb, lbi);
|
Panel_setSelected(panel, index);
|
||||||
lb->scrollV = currScrollV;
|
panel->scrollV = currScrollV;
|
||||||
}
|
}
|
||||||
lbi++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,7 +315,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
Header_draw(header);
|
Header_draw(header);
|
||||||
|
|
||||||
Panel_draw(lb, true);
|
Panel_draw(panel, true);
|
||||||
int prev = ch;
|
int prev = ch;
|
||||||
ch = getch();
|
ch = getch();
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ int main(int argc, char** argv) {
|
||||||
if (incSearchMode) {
|
if (incSearchMode) {
|
||||||
doRefresh = false;
|
doRefresh = false;
|
||||||
if (ch == KEY_F(3)) {
|
if (ch == KEY_F(3)) {
|
||||||
int here = Panel_getSelectedIndex(lb);
|
int here = Panel_getSelectedIndex(panel);
|
||||||
int size = ProcessList_size(pl);
|
int size = ProcessList_size(pl);
|
||||||
int i = here+1;
|
int i = here+1;
|
||||||
while (i != here) {
|
while (i != here) {
|
||||||
|
@ -342,7 +342,7 @@ int main(int argc, char** argv) {
|
||||||
i = 0;
|
i = 0;
|
||||||
Process* p = ProcessList_get(pl, i);
|
Process* p = ProcessList_get(pl, i);
|
||||||
if (String_contains_i(p->comm, incSearchBuffer)) {
|
if (String_contains_i(p->comm, incSearchBuffer)) {
|
||||||
Panel_setSelected(lb, i);
|
Panel_setSelected(panel, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
@ -367,7 +367,7 @@ int main(int argc, char** argv) {
|
||||||
for (int i = 0; i < ProcessList_size(pl); i++) {
|
for (int i = 0; i < ProcessList_size(pl); i++) {
|
||||||
Process* p = ProcessList_get(pl, i);
|
Process* p = ProcessList_get(pl, i);
|
||||||
if (String_contains_i(p->comm, incSearchBuffer)) {
|
if (String_contains_i(p->comm, incSearchBuffer)) {
|
||||||
Panel_setSelected(lb, i);
|
Panel_setSelected(panel, i);
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -381,8 +381,8 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
if (isdigit((char)ch)) {
|
if (isdigit((char)ch)) {
|
||||||
int pid = ch-48 + acc;
|
int pid = ch-48 + acc;
|
||||||
for (int i = 0; i < ProcessList_size(pl) && ((Process*) Panel_getSelected(lb))->pid != pid; i++)
|
for (int i = 0; i < ProcessList_size(pl) && ((Process*) Panel_getSelected(panel))->pid != pid; i++)
|
||||||
Panel_setSelected(lb, i);
|
Panel_setSelected(panel, i);
|
||||||
acc = pid * 10;
|
acc = pid * 10;
|
||||||
if (acc > 100000)
|
if (acc > 100000)
|
||||||
acc = 0;
|
acc = 0;
|
||||||
|
@ -395,8 +395,8 @@ int main(int argc, char** argv) {
|
||||||
MEVENT mevent;
|
MEVENT mevent;
|
||||||
int ok = getmouse(&mevent);
|
int ok = getmouse(&mevent);
|
||||||
if (ok == OK) {
|
if (ok == OK) {
|
||||||
if (mevent.y >= lb->y + 1 && mevent.y < LINES - 1) {
|
if (mevent.y >= panel->y + 1 && mevent.y < LINES - 1) {
|
||||||
Panel_setSelected(lb, mevent.y - lb->y + lb->scrollV - 1);
|
Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV - 1);
|
||||||
doRefresh = false;
|
doRefresh = false;
|
||||||
refreshTimeout = resetRefreshTimeout;
|
refreshTimeout = resetRefreshTimeout;
|
||||||
follow = true;
|
follow = true;
|
||||||
|
@ -413,7 +413,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case KEY_RESIZE:
|
case KEY_RESIZE:
|
||||||
Panel_resize(lb, COLS, LINES-headerHeight-1);
|
Panel_resize(panel, COLS, LINES-headerHeight-1);
|
||||||
if (incSearchMode)
|
if (incSearchMode)
|
||||||
FunctionBar_draw(searchBar, incSearchBuffer);
|
FunctionBar_draw(searchBar, incSearchBuffer);
|
||||||
else
|
else
|
||||||
|
@ -425,7 +425,7 @@ int main(int argc, char** argv) {
|
||||||
pl->sortKey = PERCENT_MEM;
|
pl->sortKey = PERCENT_MEM;
|
||||||
pl->treeView = false;
|
pl->treeView = false;
|
||||||
settings->changed = true;
|
settings->changed = true;
|
||||||
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
|
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'T':
|
case 'T':
|
||||||
|
@ -434,13 +434,13 @@ int main(int argc, char** argv) {
|
||||||
pl->sortKey = TIME;
|
pl->sortKey = TIME;
|
||||||
pl->treeView = false;
|
pl->treeView = false;
|
||||||
settings->changed = true;
|
settings->changed = true;
|
||||||
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
|
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'U':
|
case 'U':
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Panel_getSize(lb); i++) {
|
for (int i = 0; i < Panel_getSize(panel); i++) {
|
||||||
Process* p = (Process*) Panel_get(lb, i);
|
Process* p = (Process*) Panel_get(panel, i);
|
||||||
p->tag = false;
|
p->tag = false;
|
||||||
}
|
}
|
||||||
doRefresh = true;
|
doRefresh = true;
|
||||||
|
@ -452,7 +452,7 @@ int main(int argc, char** argv) {
|
||||||
pl->sortKey = PERCENT_CPU;
|
pl->sortKey = PERCENT_CPU;
|
||||||
pl->treeView = false;
|
pl->treeView = false;
|
||||||
settings->changed = true;
|
settings->changed = true;
|
||||||
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
|
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KEY_F(1):
|
case KEY_F(1):
|
||||||
|
@ -472,14 +472,14 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
case ' ':
|
case ' ':
|
||||||
{
|
{
|
||||||
Process* p = (Process*) Panel_getSelected(lb);
|
Process* p = (Process*) Panel_getSelected(panel);
|
||||||
Process_toggleTag(p);
|
Process_toggleTag(p);
|
||||||
Panel_onKey(lb, KEY_DOWN);
|
Panel_onKey(panel, KEY_DOWN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 's':
|
case 's':
|
||||||
{
|
{
|
||||||
TraceScreen* ts = TraceScreen_new((Process*) Panel_getSelected(lb));
|
TraceScreen* ts = TraceScreen_new((Process*) Panel_getSelected(panel));
|
||||||
TraceScreen_run(ts);
|
TraceScreen_run(ts);
|
||||||
TraceScreen_delete(ts);
|
TraceScreen_delete(ts);
|
||||||
clear();
|
clear();
|
||||||
|
@ -494,10 +494,10 @@ int main(int argc, char** argv) {
|
||||||
{
|
{
|
||||||
Setup_run(settings, headerHeight);
|
Setup_run(settings, headerHeight);
|
||||||
// TODO: shouldn't need this, colors should be dynamic
|
// TODO: shouldn't need this, colors should be dynamic
|
||||||
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
|
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
|
||||||
headerHeight = Header_calculateHeight(header);
|
headerHeight = Header_calculateHeight(header);
|
||||||
Panel_move(lb, 0, headerHeight);
|
Panel_move(panel, 0, headerHeight);
|
||||||
Panel_resize(lb, COLS, LINES-headerHeight-1);
|
Panel_resize(panel, COLS, LINES-headerHeight-1);
|
||||||
FunctionBar_draw(defaultBar, NULL);
|
FunctionBar_draw(defaultBar, NULL);
|
||||||
refreshTimeout = 0;
|
refreshTimeout = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -509,14 +509,14 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
case 'u':
|
case 'u':
|
||||||
{
|
{
|
||||||
Panel* lbu = Panel_new(0, 0, 0, 0, LISTITEM_CLASS, true);
|
Panel* usersPanel = Panel_new(0, 0, 0, 0, LISTITEM_CLASS, true);
|
||||||
Panel_setHeader(lbu, "Show processes of:");
|
Panel_setHeader(usersPanel, "Show processes of:");
|
||||||
UsersTable_foreach(ut, addUserToList, lbu);
|
UsersTable_foreach(ut, addUserToList, usersPanel);
|
||||||
Vector_sort(lbu->items);
|
Vector_sort(usersPanel->items);
|
||||||
ListItem* allUsers = ListItem_new("All users", -1);
|
ListItem* allUsers = ListItem_new("All users", -1);
|
||||||
Panel_insert(lbu, 0, (Object*) allUsers);
|
Panel_insert(usersPanel, 0, (Object*) allUsers);
|
||||||
char* fuFunctions[2] = {"Show ", "Cancel "};
|
char* fuFunctions[2] = {"Show ", "Cancel "};
|
||||||
ListItem* picked = (ListItem*) pickFromList(lb, lbu, 20, headerHeight, fuFunctions, defaultBar);
|
ListItem* picked = (ListItem*) pickFromList(panel, usersPanel, 20, headerHeight, fuFunctions, defaultBar);
|
||||||
if (picked) {
|
if (picked) {
|
||||||
if (picked == allUsers) {
|
if (picked == allUsers) {
|
||||||
userOnly = false;
|
userOnly = false;
|
||||||
|
@ -530,20 +530,20 @@ int main(int argc, char** argv) {
|
||||||
case KEY_F(9):
|
case KEY_F(9):
|
||||||
case 'k':
|
case 'k':
|
||||||
{
|
{
|
||||||
if (!lbk) {
|
if (!killPanel) {
|
||||||
lbk = (Panel*) SignalsPanel_new(0, 0, 0, 0);
|
killPanel = (Panel*) SignalsPanel_new(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
SignalsPanel_reset((SignalsPanel*) lbk);
|
SignalsPanel_reset((SignalsPanel*) killPanel);
|
||||||
char* fuFunctions[2] = {"Send ", "Cancel "};
|
char* fuFunctions[2] = {"Send ", "Cancel "};
|
||||||
Signal* signal = (Signal*) pickFromList(lb, lbk, 15, headerHeight, fuFunctions, defaultBar);
|
Signal* signal = (Signal*) pickFromList(panel, killPanel, 15, headerHeight, fuFunctions, defaultBar);
|
||||||
if (signal) {
|
if (signal) {
|
||||||
if (signal->number != 0) {
|
if (signal->number != 0) {
|
||||||
Panel_setHeader(lb, "Sending...");
|
Panel_setHeader(panel, "Sending...");
|
||||||
Panel_draw(lb, true);
|
Panel_draw(panel, true);
|
||||||
refresh();
|
refresh();
|
||||||
bool anyTagged = false;
|
bool anyTagged = false;
|
||||||
for (int i = 0; i < Panel_getSize(lb); i++) {
|
for (int i = 0; i < Panel_getSize(panel); i++) {
|
||||||
Process* p = (Process*) Panel_get(lb, i);
|
Process* p = (Process*) Panel_get(panel, i);
|
||||||
if (p->tag) {
|
if (p->tag) {
|
||||||
Process_sendSignal(p, signal->number);
|
Process_sendSignal(p, signal->number);
|
||||||
Process_toggleTag(p);
|
Process_toggleTag(p);
|
||||||
|
@ -551,13 +551,13 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!anyTagged) {
|
if (!anyTagged) {
|
||||||
Process* p = (Process*) Panel_getSelected(lb);
|
Process* p = (Process*) Panel_getSelected(panel);
|
||||||
Process_sendSignal(p, signal->number);
|
Process_sendSignal(p, signal->number);
|
||||||
}
|
}
|
||||||
napms(500);
|
napms(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
|
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
|
||||||
refreshTimeout = 0;
|
refreshTimeout = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -572,25 +572,25 @@ int main(int argc, char** argv) {
|
||||||
case '.':
|
case '.':
|
||||||
case KEY_F(6):
|
case KEY_F(6):
|
||||||
{
|
{
|
||||||
Panel* lbf = Panel_new(0,0,0,0,LISTITEM_CLASS,true);
|
Panel* sortPanel = Panel_new(0,0,0,0,LISTITEM_CLASS,true);
|
||||||
Panel_setHeader(lbf, "Sort by");
|
Panel_setHeader(sortPanel, "Sort by");
|
||||||
char* fuFunctions[2] = {"Sort ", "Cancel "};
|
char* fuFunctions[2] = {"Sort ", "Cancel "};
|
||||||
ProcessField* fields = pl->fields;
|
ProcessField* fields = pl->fields;
|
||||||
for (int i = 0; fields[i]; i++) {
|
for (int i = 0; fields[i]; i++) {
|
||||||
char* name = String_trim(Process_printField(fields[i]));
|
char* name = String_trim(Process_printField(fields[i]));
|
||||||
Panel_add(lbf, (Object*) ListItem_new(name, fields[i]));
|
Panel_add(sortPanel, (Object*) ListItem_new(name, fields[i]));
|
||||||
if (fields[i] == pl->sortKey)
|
if (fields[i] == pl->sortKey)
|
||||||
Panel_setSelected(lbf, i);
|
Panel_setSelected(sortPanel, i);
|
||||||
free(name);
|
free(name);
|
||||||
}
|
}
|
||||||
ListItem* field = (ListItem*) pickFromList(lb, lbf, 15, headerHeight, fuFunctions, defaultBar);
|
ListItem* field = (ListItem*) pickFromList(panel, sortPanel, 15, headerHeight, fuFunctions, defaultBar);
|
||||||
if (field) {
|
if (field) {
|
||||||
pl->treeView = false;
|
pl->treeView = false;
|
||||||
settings->changed = true;
|
settings->changed = true;
|
||||||
pl->sortKey = field->key;
|
pl->sortKey = field->key;
|
||||||
}
|
}
|
||||||
((Object*)lbf)->delete((Object*)lbf);
|
((Object*)sortPanel)->delete((Object*)sortPanel);
|
||||||
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
|
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
|
||||||
refreshTimeout = 0;
|
refreshTimeout = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -607,14 +607,14 @@ int main(int argc, char** argv) {
|
||||||
case '=':
|
case '=':
|
||||||
case '+':
|
case '+':
|
||||||
{
|
{
|
||||||
doRefresh = changePriority(lb, 1);
|
doRefresh = changePriority(panel, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KEY_F(7):
|
case KEY_F(7):
|
||||||
case ']':
|
case ']':
|
||||||
case '-':
|
case '-':
|
||||||
{
|
{
|
||||||
doRefresh = changePriority(lb, -1);
|
doRefresh = changePriority(panel, -1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KEY_F(3):
|
case KEY_F(3):
|
||||||
|
@ -641,7 +641,7 @@ int main(int argc, char** argv) {
|
||||||
default:
|
default:
|
||||||
doRefresh = false;
|
doRefresh = false;
|
||||||
refreshTimeout = resetRefreshTimeout;
|
refreshTimeout = resetRefreshTimeout;
|
||||||
Panel_onKey(lb, ch);
|
Panel_onKey(panel, ch);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
follow = false;
|
follow = false;
|
||||||
|
@ -658,9 +658,9 @@ int main(int argc, char** argv) {
|
||||||
ProcessList_delete(pl);
|
ProcessList_delete(pl);
|
||||||
FunctionBar_delete((Object*)searchBar);
|
FunctionBar_delete((Object*)searchBar);
|
||||||
FunctionBar_delete((Object*)defaultBar);
|
FunctionBar_delete((Object*)defaultBar);
|
||||||
((Object*)lb)->delete((Object*)lb);
|
((Object*)panel)->delete((Object*)panel);
|
||||||
if (lbk)
|
if (killPanel)
|
||||||
((Object*)lbk)->delete((Object*)lbk);
|
((Object*)killPanel)->delete((Object*)killPanel);
|
||||||
UsersTable_delete(ut);
|
UsersTable_delete(ut);
|
||||||
Settings_delete(settings);
|
Settings_delete(settings);
|
||||||
debug_done();
|
debug_done();
|
||||||
|
|
Loading…
Reference in New Issue