Commit ea855aef authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

Remove references to ListBox

parent 73de9f1e
......@@ -15,8 +15,8 @@ typedef struct AvailableMetersPanel_ {
Panel super;
Settings* settings;
Panel* leftBox;
Panel* rightBox;
Panel* leftPanel;
Panel* rightPanel;
ScreenManager* scr;
} AvailableMetersPanel;
......@@ -29,8 +29,8 @@ AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Panel* leftMe
((Object*)this)->delete = AvailableMetersPanel_delete;
this->settings = settings;
this->leftBox = leftMeters;
this->rightBox = rightMeters;
this->leftPanel = leftMeters;
this->rightPanel = rightMeters;
this->scr = scr;
super->eventHandler = AvailableMetersPanel_EventHandler;
......@@ -64,9 +64,9 @@ void AvailableMetersPanel_delete(Object* object) {
}
/* 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);
Panel_add(lb, (Object*) Meter_toListItem(meter));
Panel_add(panel, (Object*) Meter_toListItem(meter));
}
HandlerResult AvailableMetersPanel_EventHandler(Panel* super, int ch) {
......@@ -83,7 +83,7 @@ HandlerResult AvailableMetersPanel_EventHandler(Panel* super, int ch) {
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;
break;
}
......@@ -91,7 +91,7 @@ HandlerResult AvailableMetersPanel_EventHandler(Panel* super, int ch) {
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;
break;
}
......
......@@ -17,8 +17,8 @@ typedef struct AvailableMetersPanel_ {
Panel super;
Settings* settings;
Panel* leftBox;
Panel* rightBox;
Panel* leftPanel;
Panel* rightPanel;
ScreenManager* scr;
} AvailableMetersPanel;
......
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
* 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) {
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);
this->fuBar = NULL;
this->itemCount--;
return lb;
return panel;
}
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 lastX = 0;
for (int i = 0; i < items - 1; i++) {
Panel* lb = (Panel*) Vector_get(this->items, i);
Panel_resize(lb, lb->w, LINES-y1+y2);
Panel_move(lb, lastX, y1);
lastX = lb->x + lb->w + 1;
Panel* panel = (Panel*) Vector_get(this->items, i);
Panel_resize(panel, panel->w, LINES-y1+y2);
Panel_move(panel, lastX, y1);
lastX = panel->x + panel->w + 1;
}
Panel* lb = (Panel*) Vector_get(this->items, items-1);
Panel_resize(lb, COLS-x1+x2-lastX, LINES-y1+y2);
Panel_move(lb, lastX, y1);
Panel* panel = (Panel*) Vector_get(this->items, items-1);
Panel_resize(panel, COLS-x1+x2-lastX, LINES-y1+y2);
Panel_move(panel, lastX, y1);
}
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
bool quit = false;
int focus = 0;
Panel* lbFocus = (Panel*) Vector_get(this->items, focus);
Panel* panelFocus = (Panel*) Vector_get(this->items, focus);
if (this->fuBar)
FunctionBar_draw(this->fuBar, NULL);
......@@ -134,11 +134,11 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
while (!quit) {
int items = this->itemCount;
for (int i = 0; i < items; i++) {
Panel* lb = (Panel*) Vector_get(this->items, i);
Panel_draw(lb, i == focus);
Panel* panel = (Panel*) Vector_get(this->items, i);
Panel_draw(panel, i == focus);
if (i < items) {
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);
} else {
for (int i = 0; i < this->itemCount; i++) {
Panel* lb = (Panel*) Vector_get(this->items, i);
if (mevent.x > lb->x && mevent.x <= lb->x+lb->w &&
mevent.y > lb->y && mevent.y <= lb->y+lb->h) {
Panel* panel = (Panel*) Vector_get(this->items, i);
if (mevent.x > panel->x && mevent.x <= panel->x+panel->w &&
mevent.y > panel->y && mevent.y <= panel->y+panel->h) {
focus = i;
lbFocus = lb;
Panel_setSelected(lb, mevent.y - lb->y + lb->scrollV - 1);
panelFocus = panel;
Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV - 1);
loop = true;
break;
}
......@@ -174,8 +174,8 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
}
if (loop) continue;
if (lbFocus->eventHandler) {
HandlerResult result = lbFocus->eventHandler(lbFocus, ch);
if (panelFocus->eventHandler) {
HandlerResult result = panelFocus->eventHandler(panelFocus, ch);
if (result == HANDLED) {
continue;
} else if (result == BREAK_LOOP) {
......@@ -196,8 +196,8 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
tryLeft:
if (focus > 0)
focus--;
lbFocus = (Panel*) Vector_get(this->items, focus);
if (Panel_getSize(lbFocus) == 0 && focus > 0)
panelFocus = (Panel*) Vector_get(this->items, focus);
if (Panel_getSize(panelFocus) == 0 && focus > 0)
goto tryLeft;
break;
case KEY_RIGHT:
......@@ -205,8 +205,8 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
tryRight:
if (focus < this->itemCount - 1)
focus++;
lbFocus = (Panel*) Vector_get(this->items, focus);
if (Panel_getSize(lbFocus) == 0 && focus < this->itemCount - 1)
panelFocus = (Panel*) Vector_get(this->items, focus);
if (Panel_getSize(panelFocus) == 0 && focus < this->itemCount - 1)
goto tryRight;
break;
case KEY_F(10):
......@@ -215,11 +215,11 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
quit = true;
continue;
default:
Panel_onKey(lbFocus, ch);
Panel_onKey(panelFocus, ch);
break;
}
}
*lastFocus = lbFocus;
*lastFocus = panelFocus;
*lastKey = ch;
}
......@@ -81,7 +81,7 @@ void TraceScreen_run(TraceScreen* this) {
}
fcntl(fdpair[0], F_SETFL, O_NONBLOCK);
FILE* strace = fdopen(fdpair[0], "r");
Panel* lb = this->display;
Panel* panel = this->display;
int fd_strace = fileno(strace);
TraceScreen_draw(this);
CRT_disableDelay();
......@@ -105,31 +105,31 @@ void TraceScreen_run(TraceScreen* this) {
if (buffer[i] == '\n') {
buffer[i] = '\0';
if (contLine) {
ListItem_append((ListItem*)Panel_get(lb,
Panel_getSize(lb)-1), line);
ListItem_append((ListItem*)Panel_get(panel,
Panel_getSize(panel)-1), line);
contLine = false;
} else {
Panel_add(lb, (Object*) ListItem_new(line, 0));
Panel_add(panel, (Object*) ListItem_new(line, 0));
}
line = buffer+i+1;
}
}
if (line < buffer+nread) {
Panel_add(lb, (Object*) ListItem_new(line, 0));
Panel_add(panel, (Object*) ListItem_new(line, 0));
buffer[nread] = '\0';
contLine = true;
}
if (follow)
Panel_setSelected(lb, Panel_getSize(lb)-1);
Panel_draw(lb, true);
Panel_setSelected(panel, Panel_getSize(panel)-1);
Panel_draw(panel, true);
}
int ch = getch();
if (ch == KEY_MOUSE) {
MEVENT mevent;
int ok = getmouse(&mevent);
if (ok == OK)
if (mevent.y >= lb->y && mevent.y < LINES - 1) {
Panel_setSelected(lb, mevent.y - lb->y + lb->scrollV);
if (mevent.y >= panel->y && mevent.y < LINES - 1) {
Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV);
follow = false;
ch = 0;
} if (mevent.y == LINES - 1)
......@@ -147,21 +147,21 @@ void TraceScreen_run(TraceScreen* this) {
case KEY_F(4):
follow = !follow;
if (follow)
Panel_setSelected(lb, Panel_getSize(lb)-1);
Panel_setSelected(panel, Panel_getSize(panel)-1);
break;
case 'q':
case 27:
looping = false;
break;
case KEY_RESIZE:
Panel_resize(lb, COLS, LINES-2);
Panel_resize(panel, COLS, LINES-2);
TraceScreen_draw(this);
break;
default:
follow = false;
Panel_onKey(lb, ch);
Panel_onKey(panel, ch);
}
Panel_draw(lb, true);
Panel_draw(panel, true);
}
kill(child, SIGTERM);
waitpid(child, NULL, 0);
......
......@@ -126,62 +126,62 @@ void showHelp() {
static void Setup_run(Settings* settings, int headerHeight) {
ScreenManager* scr = ScreenManager_new(0, headerHeight, 0, -1, HORIZONTAL, true);
CategoriesPanel* lbCategories = CategoriesPanel_new(settings, scr);
ScreenManager_add(scr, (Panel*) lbCategories, NULL, 16);
CategoriesPanel_makeMetersPage(lbCategories);
Panel* lbFocus;
CategoriesPanel* panelCategories = CategoriesPanel_new(settings, scr);
ScreenManager_add(scr, (Panel*) panelCategories, NULL, 16);
CategoriesPanel_makeMetersPage(panelCategories);
Panel* panelFocus;
int ch;
ScreenManager_run(scr, &lbFocus, &ch);
ScreenManager_run(scr, &panelFocus, &ch);
ScreenManager_delete(scr);
}
static bool changePriority(Panel* lb, int delta) {
static bool changePriority(Panel* panel, int delta) {
bool anyTagged = false;
for (int i = 0; i < Panel_getSize(lb); i++) {
Process* p = (Process*) Panel_get(lb, i);
for (int i = 0; i < Panel_getSize(panel); i++) {
Process* p = (Process*) Panel_get(panel, i);
if (p->tag) {
Process_setPriority(p, p->nice + delta);
anyTagged = true;
}
}
if (!anyTagged) {
Process* p = (Process*) Panel_getSelected(lb);
Process* p = (Process*) Panel_getSelected(panel);
Process_setPriority(p, p->nice + delta);
}
return anyTagged;
}
static HandlerResult pickWithEnter(Panel* lb, int ch) {
static HandlerResult pickWithEnter(Panel* panel, int ch) {
if (ch == 13)
return BREAK_LOOP;
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"};
int fuEvents[2] = {13, 27};
if (!lb->eventHandler)
if (!panel->eventHandler)
Panel_setEventHandler(list, pickWithEnter);
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, lb, NULL, -1);
Panel* lbFocus;
ScreenManager_add(scr, panel, NULL, -1);
Panel* panelFocus;
int ch;
ScreenManager_run(scr, &lbFocus, &ch);
ScreenManager_run(scr, &panelFocus, &ch);
ScreenManager_delete(scr);
Panel_move(lb, 0, y);
Panel_resize(lb, COLS, LINES-y-1);
Panel_move(panel, 0, y);
Panel_resize(panel, COLS, LINES-y-1);
FunctionBar_draw(prevBar, NULL);
if (lbFocus == list && ch == 13) {
if (panelFocus == list && ch == 13) {
return Panel_getSelected(list);
}
return NULL;
}
void addUserToList(int key, void* userCast, void* lbCast) {
void addUserToList(int key, void* userCast, void* panelCast) {
char* user = (char*) userCast;
Panel* lb = (Panel*) lbCast;
Panel_add(lb, (Object*) ListItem_new(user, key));
Panel* panel = (Panel*) panelCast;
Panel_add(panel, (Object*) ListItem_new(user, key));
}
void setUserOnly(const char* userName, bool* userOnly, uid_t* userId) {
......@@ -219,14 +219,14 @@ int main(int argc, char** argv) {
exit(1);
}
Panel* lb;
Panel* panel;
int quit = 0;
int refreshTimeout = 0;
int resetRefreshTimeout = 5;
bool doRefresh = true;
Settings* settings;
Panel* lbk = NULL;
Panel* killPanel = NULL;
char incSearchBuffer[INCSEARCH_MAX];
int incSearchIndex = 0;
......@@ -248,8 +248,8 @@ int main(int argc, char** argv) {
CRT_init(settings->delay, settings->colorScheme);
lb = Panel_new(0, headerHeight, COLS, LINES - headerHeight - 2, PROCESS_CLASS, false);
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
panel = Panel_new(0, headerHeight, COLS, LINES - headerHeight - 2, PROCESS_CLASS, false);
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
char* searchFunctions[3] = {"Next ", "Exit ", " Search: "};
char* searchKeys[3] = {"F3", "Esc", " "};
......@@ -285,9 +285,9 @@ int main(int argc, char** argv) {
if (doRefresh) {
incSearchIndex = 0;
incSearchBuffer[0] = 0;
int currPos = Panel_getSelectedIndex(lb);
int currPos = Panel_getSelectedIndex(panel);
int currPid = 0;
int currScrollV = lb->scrollV;
int currScrollV = panel->scrollV;
if (follow)
currPid = ProcessList_get(pl, currPos)->pid;
if (recalculate)
......@@ -296,18 +296,18 @@ int main(int argc, char** argv) {
ProcessList_sort(pl);
refreshTimeout = 1;
}
Panel_prune(lb);
Panel_prune(panel);
int size = ProcessList_size(pl);
int lbi = 0;
int index = 0;
for (int i = 0; i < size; i++) {
Process* p = ProcessList_get(pl, i);
if (!userOnly || (p->st_uid == userId)) {
Panel_set(lb, lbi, (Object*)p);
if ((!follow && lbi == currPos) || (follow && p->pid == currPid)) {
Panel_setSelected(lb, lbi);
lb->scrollV = currScrollV;
Panel_set(panel, index, (Object*)p);
if ((!follow && index == currPos) || (follow && p->pid == currPid)) {
Panel_setSelected(panel, index);
panel->scrollV = currScrollV;
}
lbi++;
index++;
}
}
}
......@@ -315,7 +315,7 @@ int main(int argc, char** argv) {
Header_draw(header);
Panel_draw(lb, true);
Panel_draw(panel, true);
int prev = ch;
ch = getch();
......@@ -334,7 +334,7 @@ int main(int argc, char** argv) {
if (incSearchMode) {
doRefresh = false;
if (ch == KEY_F(3)) {
int here = Panel_getSelectedIndex(lb);
int here = Panel_getSelectedIndex(panel);
int size = ProcessList_size(pl);
int i = here+1;
while (i != here) {
......@@ -342,7 +342,7 @@ int main(int argc, char** argv) {
i = 0;
Process* p = ProcessList_get(pl, i);
if (String_contains_i(p->comm, incSearchBuffer)) {
Panel_setSelected(lb, i);
Panel_setSelected(panel, i);
break;
}
i++;
......@@ -367,7 +367,7 @@ int main(int argc, char** argv) {
for (int i = 0; i < ProcessList_size(pl); i++) {
Process* p = ProcessList_get(pl, i);
if (String_contains_i(p->comm, incSearchBuffer)) {
Panel_setSelected(lb, i);
Panel_setSelected(panel, i);
found = true;
break;
}
......@@ -381,8 +381,8 @@ int main(int argc, char** argv) {
}
if (isdigit((char)ch)) {
int pid = ch-48 + acc;
for (int i = 0; i < ProcessList_size(pl) && ((Process*) Panel_getSelected(lb))->pid != pid; i++)
Panel_setSelected(lb, i);
for (int i = 0; i < ProcessList_size(pl) && ((Process*) Panel_getSelected(panel))->pid != pid; i++)
Panel_setSelected(panel, i);
acc = pid * 10;
if (acc > 100000)
acc = 0;
......@@ -395,8 +395,8 @@ int main(int argc, char** argv) {
MEVENT mevent;
int ok = getmouse(&mevent);
if (ok == OK) {
if (mevent.y >= lb->y + 1 && mevent.y < LINES - 1) {
Panel_setSelected(lb, mevent.y - lb->y + lb->scrollV - 1);
if (mevent.y >= panel->y + 1 && mevent.y < LINES - 1) {
Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV - 1);
doRefresh = false;
refreshTimeout = resetRefreshTimeout;
follow = true;
......@@ -413,7 +413,7 @@ int main(int argc, char** argv) {
switch (ch) {
case KEY_RESIZE:
Panel_resize(lb, COLS, LINES-headerHeight-1);
Panel_resize(panel, COLS, LINES-headerHeight-1);
if (incSearchMode)
FunctionBar_draw(searchBar, incSearchBuffer);
else
......@@ -425,7 +425,7 @@ int main(int argc, char** argv) {
pl->sortKey = PERCENT_MEM;
pl->treeView = false;
settings->changed = true;
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
break;
}
case 'T':
......@@ -434,13 +434,13 @@ int main(int argc, char** argv) {
pl->sortKey = TIME;
pl->treeView = false;
settings->changed = true;
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
break;
}
case 'U':
{
for (int i = 0; i < Panel_getSize(lb); i++) {
Process* p = (Process*) Panel_get(lb, i);
for (int i = 0; i < Panel_getSize(panel); i++) {
Process* p = (Process*) Panel_get(panel, i);
p->tag = false;
}
doRefresh = true;
......@@ -452,7 +452,7 @@ int main(int argc, char** argv) {
pl->sortKey = PERCENT_CPU;
pl->treeView = false;
settings->changed = true;
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
break;
}
case KEY_F(1):
......@@ -472,14 +472,14 @@ int main(int argc, char** argv) {
}
case ' ':
{
Process* p = (Process*) Panel_getSelected(lb);
Process* p = (Process*) Panel_getSelected(panel);
Process_toggleTag(p);
Panel_onKey(lb, KEY_DOWN);
Panel_onKey(panel, KEY_DOWN);
break;
}
case 's':
{
TraceScreen* ts = TraceScreen_new((Process*) Panel_getSelected(lb));
TraceScreen* ts = TraceScreen_new((Process*) Panel_getSelected(panel));
TraceScreen_run(ts);
TraceScreen_delete(ts);
clear();
......@@ -494,10 +494,10 @@ int main(int argc, char** argv) {
{
Setup_run(settings, headerHeight);
// 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);
Panel_move(lb, 0, headerHeight);
Panel_resize(lb, COLS, LINES-headerHeight-1);
Panel_move(panel, 0, headerHeight);
Panel_resize(panel, COLS, LINES-headerHeight-1);
FunctionBar_draw(defaultBar, NULL);
refreshTimeout = 0;
break;
......@@ -509,14 +509,14 @@ int main(int argc, char** argv) {
}
case 'u':
{
Panel* lbu = Panel_new(0, 0, 0, 0, LISTITEM_CLASS, true);
Panel_setHeader(lbu, "Show processes of:");
UsersTable_foreach(ut, addUserToList, lbu);
Vector_sort(lbu->items);
Panel* usersPanel = Panel_new(0, 0, 0, 0, LISTITEM_CLASS, true);
Panel_setHeader(usersPanel, "Show processes of:");
UsersTable_foreach(ut, addUserToList, usersPanel);
Vector_sort(usersPanel->items);
ListItem* allUsers = ListItem_new("All users", -1);
Panel_insert(lbu, 0, (Object*) allUsers);
Panel_insert(usersPanel, 0, (Object*) allUsers);
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 == allUsers) {
userOnly = false;
......@@ -530,20 +530,20 @@ int main(int argc, char** argv) {
case KEY_F(9):
case 'k':
{
if (!lbk) {
lbk = (Panel*) SignalsPanel_new(0, 0, 0, 0);
if (!killPanel) {
killPanel = (Panel*) SignalsPanel_new(0, 0, 0, 0);
}
SignalsPanel_reset((SignalsPanel*) lbk);
SignalsPanel_reset((SignalsPanel*) killPanel);
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->number != 0) {
Panel_setHeader(lb, "Sending...");
Panel_draw(lb, true);
Panel_setHeader(panel, "Sending...");
Panel_draw(panel, true);
refresh();
bool anyTagged = false;
for (int i = 0; i < Panel_getSize(lb); i++) {
Process* p = (Process*) Panel_get(lb, i);
for (int i = 0; i < Panel_getSize(panel); i++) {
Process* p = (Process*) Panel_get(panel, i);
if (p->tag) {
Process_sendSignal(p, signal->number);
Process_toggleTag(p);
......@@ -551,13 +551,13 @@ int main(int argc, char** argv) {
}
}
if (!anyTagged) {
Process* p = (Process*) Panel_getSelected(lb);
Process* p = (Process*) Panel_getSelected(panel);
Process_sendSignal(p, signal->number);
}
napms(500);
}
}
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
refreshTimeout = 0;
break;
}
......@@ -572,25 +572,25 @@ int main(int argc, char** argv) {
case '.':
case KEY_F(6):
{
Panel* lbf = Panel_new(0,0,0,0,LISTITEM_CLASS,true);
Panel_setHeader(lbf, "Sort by");
Panel* sortPanel = Panel_new(0,0,0,0,LISTITEM_CLASS,true);
Panel_setHeader(sortPanel, "Sort by");
char* fuFunctions[2] = {"Sort ", "Cancel "};
ProcessField* fields = pl->fields;
for (int i = 0; fields[i]; 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)
Panel_setSelected(lbf, i);
Panel_setSelected(sortPanel, i);
free(name);
}
ListItem* field = (ListItem*) pickFromList(lb, lbf, 15, headerHeight, fuFunctions, defaultBar);
ListItem* field = (ListItem*) pickFromList(panel, sortPanel, 15, headerHeight, fuFunctions, defaultBar);
if (field) {
pl->treeView = false;
settings->changed = true;
pl->sortKey = field->key;
}
((Object*)lbf)->delete((Object*)lbf);
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
((Object*)sortPanel)->delete((Object*)sortPanel);
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
refreshTimeout = 0;
break;
}
......@@ -607,14 +607,14 @@ int main(int argc, char** argv) {
case '=':
case '+':
{
doRefresh = changePriority(lb, 1);
doRefresh = changePriority(panel, 1);
break;
}
case KEY_F(7):
case ']':
case '-':
{
doRefresh = changePriority(lb, -1);
doRefresh = changePriority(panel, -1);
break;
}
case KEY_F(3):
......@@ -641,7 +641,7 @@ int main(int argc, char** argv) {
default:
doRefresh = false;
refreshTimeout = resetRefreshTimeout;
Panel_onKey(lb, ch);
Panel_onKey(panel, ch);
break;
}
follow = false;
......@@ -658,9 +658,9 @@ int main(int argc, char** argv) {
ProcessList_delete(pl);
FunctionBar_delete((Object*)searchBar);
FunctionBar_delete((Object*)defaultBar);
((Object*)lb)->delete((Object*)lb);
if (lbk)
((Object*)lbk)->delete((Object*)lbk);
((Object*)panel)->delete((Object*)panel);
if (killPanel)
((Object*)killPanel)->delete((Object*)killPanel);
UsersTable_delete(ut);
Settings_delete(settings);
debug_done();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment