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

Rename ListBox to Panel, matching dit.

parent a853faaa
#include "SignalsListBox.h" #include "SignalsPanel.h"
#include "ListBox.h" #include "Panel.h"
#include "SignalItem.h" #include "SignalItem.h"
#include "RichString.h" #include "RichString.h"
...@@ -11,56 +11,56 @@ ...@@ -11,56 +11,56 @@
/*{ /*{
typedef struct SignalsListBox_ { typedef struct SignalsPanel_ {
ListBox super; Panel super;
int state; int state;
Signal** signals; Signal** signals;
} SignalsListBox; } SignalsPanel;
}*/ }*/
SignalsListBox* SignalsListBox_new(int x, int y, int w, int h) { SignalsPanel* SignalsPanel_new(int x, int y, int w, int h) {
SignalsListBox* this = (SignalsListBox*) malloc(sizeof(SignalsListBox)); SignalsPanel* this = (SignalsPanel*) malloc(sizeof(SignalsPanel));
ListBox* super = (ListBox*) this; Panel* super = (Panel*) this;
ListBox_init(super, x, y, w, h, SIGNAL_CLASS, true); Panel_init(super, x, y, w, h, SIGNAL_CLASS, true);
((Object*)this)->delete = SignalsListBox_delete; ((Object*)this)->delete = SignalsPanel_delete;
this->signals = Signal_getSignalTable(); this->signals = Signal_getSignalTable();
super->eventHandler = SignalsListBox_EventHandler; super->eventHandler = SignalsPanel_EventHandler;
int sigCount = Signal_getSignalCount(); int sigCount = Signal_getSignalCount();
for(int i = 0; i < sigCount; i++) for(int i = 0; i < sigCount; i++)
ListBox_set(super, i, (Object*) this->signals[i]); Panel_set(super, i, (Object*) this->signals[i]);
SignalsListBox_reset(this); SignalsPanel_reset(this);
return this; return this;
} }
void SignalsListBox_delete(Object* object) { void SignalsPanel_delete(Object* object) {
ListBox* super = (ListBox*) object; Panel* super = (Panel*) object;
SignalsListBox* this = (SignalsListBox*) object; SignalsPanel* this = (SignalsPanel*) object;
ListBox_done(super); Panel_done(super);
free(this->signals); free(this->signals);
free(this); free(this);
} }
void SignalsListBox_reset(SignalsListBox* this) { void SignalsPanel_reset(SignalsPanel* this) {
ListBox* super = (ListBox*) this; Panel* super = (Panel*) this;
ListBox_setHeader(super, "Send signal:"); Panel_setHeader(super, "Send signal:");
ListBox_setSelected(super, 16); // 16th item is SIGTERM Panel_setSelected(super, 16); // 16th item is SIGTERM
this->state = 0; this->state = 0;
} }
HandlerResult SignalsListBox_EventHandler(ListBox* super, int ch) { HandlerResult SignalsPanel_EventHandler(Panel* super, int ch) {
SignalsListBox* this = (SignalsListBox*) super; SignalsPanel* this = (SignalsPanel*) super;
int size = ListBox_getSize(super); int size = Panel_getSize(super);
if (ch <= 255 && isdigit(ch)) { if (ch <= 255 && isdigit(ch)) {
int signal = ch-48 + this->state; int signal = ch-48 + this->state;
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
if (((Signal*) ListBox_get(super, i))->number == signal) { if (((Signal*) Panel_get(super, i))->number == signal) {
ListBox_setSelected(super, i); Panel_setSelected(super, i);
break; break;
} }
this->state = signal * 10; this->state = signal * 10;
......
/* Do not edit this file. It was automatically genarated. */ /* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_SignalsListBox #ifndef HEADER_SignalsPanel
#define HEADER_SignalsListBox #define HEADER_SignalsPanel
#include "ListBox.h" #include "Panel.h"
#include "SignalItem.h" #include "SignalItem.h"
#include "RichString.h" #include "RichString.h"
...@@ -13,20 +13,20 @@ ...@@ -13,20 +13,20 @@
#include <ctype.h> #include <ctype.h>
typedef struct SignalsListBox_ { typedef struct SignalsPanel_ {
ListBox super; Panel super;
int state; int state;
Signal** signals; Signal** signals;
} SignalsListBox; } SignalsPanel;
SignalsListBox* SignalsListBox_new(int x, int y, int w, int h); SignalsPanel* SignalsPanel_new(int x, int y, int w, int h);
void SignalsListBox_delete(Object* object); void SignalsPanel_delete(Object* object);
void SignalsListBox_reset(SignalsListBox* this); void SignalsPanel_reset(SignalsPanel* this);
HandlerResult SignalsListBox_EventHandler(ListBox* super, int ch); HandlerResult SignalsPanel_EventHandler(Panel* super, int ch);
#endif #endif
...@@ -18,14 +18,14 @@ in the source distribution for its full text. ...@@ -18,14 +18,14 @@ in the source distribution for its full text.
#include "ProcessList.h" #include "ProcessList.h"
#include "Process.h" #include "Process.h"
#include "ListItem.h" #include "ListItem.h"
#include "ListBox.h" #include "Panel.h"
#include "FunctionBar.h" #include "FunctionBar.h"
/*{ /*{
typedef struct TraceScreen_ { typedef struct TraceScreen_ {
Process* process; Process* process;
ListBox* display; Panel* display;
FunctionBar* bar; FunctionBar* bar;
bool tracing; bool tracing;
} TraceScreen; } TraceScreen;
...@@ -44,14 +44,14 @@ static int tbEvents[3] = {KEY_F(4), KEY_F(5), 27}; ...@@ -44,14 +44,14 @@ static int tbEvents[3] = {KEY_F(4), KEY_F(5), 27};
TraceScreen* TraceScreen_new(Process* process) { TraceScreen* TraceScreen_new(Process* process) {
TraceScreen* this = (TraceScreen*) malloc(sizeof(TraceScreen)); TraceScreen* this = (TraceScreen*) malloc(sizeof(TraceScreen));
this->process = process; this->process = process;
this->display = ListBox_new(0, 1, COLS, LINES-2, LISTITEM_CLASS, true); this->display = Panel_new(0, 1, COLS, LINES-2, LISTITEM_CLASS, true);
this->bar = FunctionBar_new(3, tbFunctions, tbKeys, tbEvents); this->bar = FunctionBar_new(3, tbFunctions, tbKeys, tbEvents);
this->tracing = true; this->tracing = true;
return this; return this;
} }
void TraceScreen_delete(TraceScreen* this) { void TraceScreen_delete(TraceScreen* this) {
ListBox_delete((Object*)this->display); Panel_delete((Object*)this->display);
FunctionBar_delete((Object*)this->bar); FunctionBar_delete((Object*)this->bar);
free(this); free(this);
} }
...@@ -81,7 +81,7 @@ void TraceScreen_run(TraceScreen* this) { ...@@ -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");
ListBox* lb = this->display; Panel* lb = this->display;
int fd_strace = fileno(strace); int fd_strace = fileno(strace);
TraceScreen_draw(this); TraceScreen_draw(this);
CRT_disableDelay(); CRT_disableDelay();
...@@ -105,23 +105,23 @@ void TraceScreen_run(TraceScreen* this) { ...@@ -105,23 +105,23 @@ 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*)ListBox_get(lb, ListItem_append((ListItem*)Panel_get(lb,
ListBox_getSize(lb)-1), line); Panel_getSize(lb)-1), line);
contLine = false; contLine = false;
} else { } else {
ListBox_add(lb, (Object*) ListItem_new(line, 0)); Panel_add(lb, (Object*) ListItem_new(line, 0));
} }
line = buffer+i+1; line = buffer+i+1;
} }
} }
if (line < buffer+nread) { if (line < buffer+nread) {
ListBox_add(lb, (Object*) ListItem_new(line, 0)); Panel_add(lb, (Object*) ListItem_new(line, 0));
buffer[nread] = '\0'; buffer[nread] = '\0';
contLine = true; contLine = true;
} }
if (follow) if (follow)
ListBox_setSelected(lb, ListBox_getSize(lb)-1); Panel_setSelected(lb, Panel_getSize(lb)-1);
ListBox_draw(lb, true); Panel_draw(lb, true);
} }
int ch = getch(); int ch = getch();
if (ch == KEY_MOUSE) { if (ch == KEY_MOUSE) {
...@@ -129,7 +129,7 @@ void TraceScreen_run(TraceScreen* this) { ...@@ -129,7 +129,7 @@ void TraceScreen_run(TraceScreen* this) {
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 >= lb->y && mevent.y < LINES - 1) {
ListBox_setSelected(lb, mevent.y - lb->y + lb->scrollV); Panel_setSelected(lb, mevent.y - lb->y + lb->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) { ...@@ -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)
ListBox_setSelected(lb, ListBox_getSize(lb)-1); Panel_setSelected(lb, Panel_getSize(lb)-1);
break; break;
case 'q': case 'q':
case 27: case 27:
looping = false; looping = false;
break; break;
case KEY_RESIZE: case KEY_RESIZE:
ListBox_resize(lb, COLS, LINES-2); Panel_resize(lb, COLS, LINES-2);
TraceScreen_draw(this); TraceScreen_draw(this);
break; break;
default: default:
follow = false; follow = false;
ListBox_onKey(lb, ch); Panel_onKey(lb, ch);
} }
ListBox_draw(lb, true); Panel_draw(lb, true);
} }
kill(child, SIGTERM); kill(child, SIGTERM);
waitpid(child, NULL, 0); waitpid(child, NULL, 0);
......
...@@ -15,12 +15,12 @@ in the source distribution for its full text. ...@@ -15,12 +15,12 @@ in the source distribution for its full text.
#include <fcntl.h> #include <fcntl.h>
#include "ProcessList.h" #include "ProcessList.h"
#include "ListBox.h" #include "Panel.h"
#include "FunctionBar.h" #include "FunctionBar.h"
typedef struct TraceScreen_ { typedef struct TraceScreen_ {
Process* process; Process* process;
ListBox* display; Panel* display;
FunctionBar* bar; FunctionBar* bar;
bool tracing; bool tracing;
} TraceScreen; } TraceScreen;
......
...@@ -14,7 +14,7 @@ in the source distribution for its full text. ...@@ -14,7 +14,7 @@ in the source distribution for its full text.
#include "ProcessList.h" #include "ProcessList.h"
#include "CRT.h" #include "CRT.h"
#include "ListBox.h" #include "Panel.h"
#include "UsersTable.h" #include "UsersTable.h"
#include "SignalItem.h" #include "SignalItem.h"
#include "RichString.h" #include "RichString.h"
...@@ -22,8 +22,8 @@ in the source distribution for its full text. ...@@ -22,8 +22,8 @@ in the source distribution for its full text.
#include "ScreenManager.h" #include "ScreenManager.h"
#include "FunctionBar.h" #include "FunctionBar.h"
#include "ListItem.h" #include "ListItem.h"
#include "CategoriesListBox.h" #include "CategoriesPanel.h"
#include "SignalsListBox.h" #include "SignalsPanel.h"
#include "TraceScreen.h" #include "TraceScreen.h"
#include "config.h" #include "config.h"
...@@ -126,62 +126,62 @@ void showHelp() { ...@@ -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);
CategoriesListBox* lbCategories = CategoriesListBox_new(settings, scr); CategoriesPanel* lbCategories = CategoriesPanel_new(settings, scr);
ScreenManager_add(scr, (ListBox*) lbCategories, NULL, 16); ScreenManager_add(scr, (Panel*) lbCategories, NULL, 16);
CategoriesListBox_makeMetersPage(lbCategories); CategoriesPanel_makeMetersPage(lbCategories);
ListBox* lbFocus; Panel* lbFocus;
int ch; int ch;
ScreenManager_run(scr, &lbFocus, &ch); ScreenManager_run(scr, &lbFocus, &ch);
ScreenManager_delete(scr); ScreenManager_delete(scr);
} }
static bool changePriority(ListBox* lb, int delta) { static bool changePriority(Panel* lb, int delta) {
bool anyTagged = false; bool anyTagged = false;
for (int i = 0; i < ListBox_getSize(lb); i++) { for (int i = 0; i < Panel_getSize(lb); i++) {
Process* p = (Process*) ListBox_get(lb, i); Process* p = (Process*) Panel_get(lb, 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*) ListBox_getSelected(lb); Process* p = (Process*) Panel_getSelected(lb);
Process_setPriority(p, p->nice + delta); Process_setPriority(p, p->nice + delta);
} }
return anyTagged; return anyTagged;
} }
static HandlerResult pickWithEnter(ListBox* lb, int ch) { static HandlerResult pickWithEnter(Panel* lb, int ch) {
if (ch == 13) if (ch == 13)
return BREAK_LOOP; return BREAK_LOOP;
return IGNORED; return IGNORED;
} }
static Object* pickFromList(ListBox* lb, ListBox* list, int x, int y, char** keyLabels, FunctionBar* prevBar) { static Object* pickFromList(Panel* lb, 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 (!lb->eventHandler)
ListBox_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, lb, NULL, -1);
ListBox* lbFocus; Panel* lbFocus;
int ch; int ch;
ScreenManager_run(scr, &lbFocus, &ch); ScreenManager_run(scr, &lbFocus, &ch);
ScreenManager_delete(scr); ScreenManager_delete(scr);
ListBox_move(lb, 0, y); Panel_move(lb, 0, y);
ListBox_resize(lb, COLS, LINES-y-1); Panel_resize(lb, COLS, LINES-y-1);
FunctionBar_draw(prevBar, NULL); FunctionBar_draw(prevBar, NULL);
if (lbFocus == list && ch == 13) { if (lbFocus == list && ch == 13) {
return ListBox_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* lbCast) {
char* user = (char*) userCast; char* user = (char*) userCast;
ListBox* lb = (ListBox*) lbCast; Panel* lb = (Panel*) lbCast;
ListBox_add(lb, (Object*) ListItem_new(user, key)); Panel_add(lb, (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) { ...@@ -219,14 +219,14 @@ int main(int argc, char** argv) {
exit(1); exit(1);
} }
ListBox* lb; Panel* lb;
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;
ListBox* lbk = NULL; Panel* lbk = 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) { ...@@ -248,8 +248,8 @@ int main(int argc, char** argv) {
CRT_init(settings->delay, settings->colorScheme); CRT_init(settings->delay, settings->colorScheme);
lb = ListBox_new(0, headerHeight, COLS, LINES - headerHeight - 2, PROCESS_CLASS, false); lb = Panel_new(0, headerHeight, COLS, LINES - headerHeight - 2, PROCESS_CLASS, false);
ListBox_setRichHeader(lb, ProcessList_printHeader(pl)); Panel_setRichHeader(lb, 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,7 +285,7 @@ int main(int argc, char** argv) { ...@@ -285,7 +285,7 @@ int main(int argc, char** argv) {
if (doRefresh) { if (doRefresh) {
incSearchIndex = 0; incSearchIndex = 0;
incSearchBuffer[0] = 0; incSearchBuffer[0] = 0;
int currPos = ListBox_getSelectedIndex(lb); int currPos = Panel_getSelectedIndex(lb);
int currPid = 0; int currPid = 0;
int currScrollV = lb->scrollV; int currScrollV = lb->scrollV;
if (follow) if (follow)
...@@ -296,15 +296,15 @@ int main(int argc, char** argv) { ...@@ -296,15 +296,15 @@ int main(int argc, char** argv) {
ProcessList_sort(pl); ProcessList_sort(pl);
refreshTimeout = 1; refreshTimeout = 1;
} }
ListBox_prune(lb); Panel_prune(lb);
int size = ProcessList_size(pl); int size = ProcessList_size(pl);
int lbi = 0; int lbi = 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)) {
ListBox_set(lb, lbi, (Object*)p); Panel_set(lb, lbi, (Object*)p);
if ((!follow && lbi == currPos) || (follow && p->pid == currPid)) { if ((!follow && lbi == currPos) || (follow && p->pid == currPid)) {
ListBox_setSelected(lb, lbi); Panel_setSelected(lb, lbi);
lb->scrollV = currScrollV; lb->scrollV = currScrollV;
} }
lbi++; lbi++;
...@@ -315,7 +315,7 @@ int main(int argc, char** argv) { ...@@ -315,7 +315,7 @@ int main(int argc, char** argv) {
Header_draw(header); Header_draw(header);
ListBox_draw(lb, true); Panel_draw(lb, true);
int prev = ch; int prev = ch;
ch = getch(); ch = getch();
...@@ -334,7 +334,7 @@ int main(int argc, char** argv) { ...@@ -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 = ListBox_getSelectedIndex(lb); int here = Panel_getSelectedIndex(lb);
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) { ...@@ -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)) {
ListBox_setSelected(lb, i); Panel_setSelected(lb, i);
break; break;
} }
i++; i++;
...@@ -367,7 +367,7 @@ int main(int argc, char** argv) { ...@@ -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)) {
ListBox_setSelected(lb, i); Panel_setSelected(lb, i);
found = true; found = true;
break; break;
} }
...@@ -381,8 +381,8 @@ int main(int argc, char** argv) { ...@@ -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*) ListBox_getSelected(lb))->pid != pid; i++) for (int i = 0; i < ProcessList_size(pl) && ((Process*) Panel_getSelected(lb))->pid != pid; i++)
ListBox_setSelected(lb, i); Panel_setSelected(lb, i);
acc = pid * 10; acc = pid * 10;
if (acc > 100000) if (acc > 100000)
acc = 0; acc = 0;
...@@ -396,7 +396,7 @@ int main(int argc, char** argv) { ...@@ -396,7 +396,7 @@ int main(int argc, char** argv) {
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 >= lb->y + 1 && mevent.y < LINES - 1) {
ListBox_setSelected(lb, mevent.y - lb->y + lb->scrollV - 1); Panel_setSelected(lb, mevent.y - lb->y + lb->scrollV - 1);
doRefresh = false; doRefresh = false;
refreshTimeout = resetRefreshTimeout; refreshTimeout = resetRefreshTimeout;
follow = true; follow = true;
...@@ -413,7 +413,7 @@ int main(int argc, char** argv) { ...@@ -413,7 +413,7 @@ int main(int argc, char** argv) {
switch (ch) { switch (ch) {
case KEY_RESIZE: case KEY_RESIZE:
ListBox_resize(lb, COLS, LINES-headerHeight-1); Panel_resize(lb, 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) { ...@@ -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;
ListBox_setRichHeader(lb, ProcessList_printHeader(pl)); Panel_setRichHeader(lb, ProcessList_printHeader(pl));
break; break;
} }
case 'T': case 'T':
...@@ -434,13 +434,13 @@ int main(int argc, char** argv) { ...@@ -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;
ListBox_setRichHeader(lb, ProcessList_printHeader(pl)); Panel_setRichHeader(lb, ProcessList_printHeader(pl));
break; break;
} }
case 'U': case 'U':
{ {
for (int i = 0; i < ListBox_getSize(lb); i++) { for (int i = 0; i < Panel_getSize(lb); i++) {
Process* p = (Process*) ListBox_get(lb, i); Process* p = (Process*) Panel_get(lb, i);
p->tag = false; p->tag = false;
} }
doRefresh = true; doRefresh = true;
...@@ -452,7 +452,7 @@ int main(int argc, char** argv) { ...@@ -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;
ListBox_setRichHeader(lb, ProcessList_printHeader(pl)); Panel_setRichHeader(lb, ProcessList_printHeader(pl));
break; break;
} }
case KEY_F(1): case KEY_F(1):
...@@ -472,14 +472,14 @@ int main(int argc, char** argv) { ...@@ -472,14 +472,14 @@ int main(int argc, char** argv) {
} }
case ' ': case ' ':
{ {
Process* p = (Process*) ListBox_getSelected(lb); Process* p = (Process*) Panel_getSelected(lb);
Process_toggleTag(p); Process_toggleTag(p);
ListBox_onKey(lb, KEY_DOWN); Panel_onKey(lb, KEY_DOWN);
break; break;
} }
case 's': case 's':
{ {
TraceScreen* ts = TraceScreen_new((Process*) ListBox_getSelected(lb)); TraceScreen* ts = TraceScreen_new((Process*) Panel_getSelected(lb));
TraceScreen_run(ts); TraceScreen_run(ts);
TraceScreen_delete(ts); TraceScreen_delete(ts);
clear(); clear();
...@@ -494,10 +494,10 @@ int main(int argc, char** argv) { ...@@ -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
ListBox_setRichHeader(lb, ProcessList_printHeader(pl)); Panel_setRichHeader(lb, ProcessList_printHeader(pl));
headerHeight = Header_calculateHeight(header); headerHeight = Header_calculateHeight(header);
ListBox_move(lb, 0, headerHeight); Panel_move(lb, 0, headerHeight);
ListBox_resize(lb, COLS, LINES-headerHeight-1); Panel_resize(lb, COLS, LINES-headerHeight-1);
FunctionBar_draw(defaultBar, NULL); FunctionBar_draw(defaultBar, NULL);
refreshTimeout = 0; refreshTimeout = 0;
break; break;
...@@ -509,12 +509,12 @@ int main(int argc, char** argv) { ...@@ -509,12 +509,12 @@ int main(int argc, char** argv) {
} }
case 'u': case 'u':
{ {
ListBox* lbu = ListBox_new(0, 0, 0, 0, LISTITEM_CLASS, true); Panel* lbu = Panel_new(0, 0, 0, 0, LISTITEM_CLASS, true);
ListBox_setHeader(lbu, "Show processes of:"); Panel_setHeader(lbu, "Show processes of:");
UsersTable_foreach(ut, addUserToList, lbu); UsersTable_foreach(ut, addUserToList, lbu);
Vector_sort(lbu->items); Vector_sort(lbu->items);
ListItem* allUsers = ListItem_new("All users", -1); ListItem* allUsers = ListItem_new("All users", -1);
ListBox_insert(lbu, 0, (Object*) allUsers); Panel_insert(lbu, 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(lb, lbu, 20, headerHeight, fuFunctions, defaultBar);
if (picked) { if (picked) {
...@@ -531,19 +531,19 @@ int main(int argc, char** argv) { ...@@ -531,19 +531,19 @@ int main(int argc, char** argv) {
case 'k': case 'k':
{ {
if (!lbk) { if (!lbk) {
lbk = (ListBox*) SignalsListBox_new(0, 0, 0, 0); lbk = (Panel*) SignalsPanel_new(0, 0, 0, 0);
} }
SignalsListBox_reset((SignalsListBox*) lbk); SignalsPanel_reset((SignalsPanel*) lbk);
char* fuFunctions[2] = {"Send ", "Cancel "}; char* fuFunctions[2] = {"Send ", "Cancel "};
Signal* signal = (Signal*) pickFromList(lb, lbk, 15, headerHeight, fuFunctions, defaultBar); Signal* signal = (Signal*) pickFromList(lb, lbk, 15, headerHeight, fuFunctions, defaultBar);
if (signal) { if (signal) {
if (signal->number != 0) { if (signal->number != 0) {
ListBox_setHeader(lb, "Sending..."); Panel_setHeader(lb, "Sending...");
ListBox_draw(lb, true); Panel_draw(lb, true);
refresh(); refresh();
bool anyTagged = false; bool anyTagged = false;
for (int i = 0; i < ListBox_getSize(lb); i++) { for (int i = 0; i < Panel_getSize(lb); i++) {
Process* p = (Process*) ListBox_get(lb, i); Process* p = (Process*) Panel_get(lb, 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) { ...@@ -551,13 +551,13 @@ int main(int argc, char** argv) {
} }
} }
if (!anyTagged) { if (!anyTagged) {
Process* p = (Process*) ListBox_getSelected(lb); Process* p = (Process*) Panel_getSelected(lb);
Process_sendSignal(p, signal->number); Process_sendSignal(p, signal->number);
} }
napms(500); napms(500);
} }
} }
ListBox_setRichHeader(lb, ProcessList_printHeader(pl)); Panel_setRichHeader(lb, ProcessList_printHeader(pl));
refreshTimeout = 0; refreshTimeout = 0;
break; break;
} }
...@@ -572,15 +572,15 @@ int main(int argc, char** argv) { ...@@ -572,15 +572,15 @@ int main(int argc, char** argv) {
case '.': case '.':
case KEY_F(6): case KEY_F(6):
{ {
ListBox* lbf = ListBox_new(0,0,0,0,LISTITEM_CLASS,true); Panel* lbf = Panel_new(0,0,0,0,LISTITEM_CLASS,true);
ListBox_setHeader(lbf, "Sort by"); Panel_setHeader(lbf, "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]));
ListBox_add(lbf, (Object*) ListItem_new(name, fields[i])); Panel_add(lbf, (Object*) ListItem_new(name, fields[i]));
if (fields[i] == pl->sortKey) if (fields[i] == pl->sortKey)
ListBox_setSelected(lbf, i); Panel_setSelected(lbf, i);
free(name); free(name);
} }
ListItem* field = (ListItem*) pickFromList(lb, lbf, 15, headerHeight, fuFunctions, defaultBar); ListItem* field = (ListItem*) pickFromList(lb, lbf, 15, headerHeight, fuFunctions, defaultBar);
...@@ -590,7 +590,7 @@ int main(int argc, char** argv) { ...@@ -590,7 +590,7 @@ int main(int argc, char** argv) {
pl->sortKey = field->key; pl->sortKey = field->key;
} }
((Object*)lbf)->delete((Object*)lbf); ((Object*)lbf)->delete((Object*)lbf);
ListBox_setRichHeader(lb, ProcessList_printHeader(pl)); Panel_setRichHeader(lb, ProcessList_printHeader(pl));
refreshTimeout = 0; refreshTimeout = 0;
break; break;
} }
...@@ -641,7 +641,7 @@ int main(int argc, char** argv) { ...@@ -641,7 +641,7 @@ int main(int argc, char** argv) {
default: default:
doRefresh = false; doRefresh = false;
refreshTimeout = resetRefreshTimeout; refreshTimeout = resetRefreshTimeout;
ListBox_onKey(lb, ch); Panel_onKey(lb, ch);
break; break;
} }
follow = false; follow = false;
......
...@@ -11,7 +11,7 @@ in the source distribution for its full text. ...@@ -11,7 +11,7 @@ in the source distribution for its full text.
#include "ProcessList.h" #include "ProcessList.h"
#include "CRT.h" #include "CRT.h"
#include "ListBox.h" #include "Panel.h"
#include "UsersTable.h" #include "UsersTable.h"
#include "SignalItem.h" #include "SignalItem.h"
#include "RichString.h" #include "RichString.h"
...@@ -19,8 +19,8 @@ in the source distribution for its full text. ...@@ -19,8 +19,8 @@ in the source distribution for its full text.
#include "ScreenManager.h" #include "ScreenManager.h"
#include "FunctionBar.h" #include "FunctionBar.h"
#include "ListItem.h" #include "ListItem.h"
#include "CategoriesListBox.h" #include "CategoriesPanel.h"
#include "SignalsListBox.h" #include "SignalsPanel.h"
#include "config.h" #include "config.h"
#include "debug.h" #include "debug.h"
......
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