diff options
Diffstat (limited to 'SignalsPanel.c')
-rw-r--r-- | SignalsPanel.c | 79 |
1 files changed, 46 insertions, 33 deletions
diff --git a/SignalsPanel.c b/SignalsPanel.c index 83dfda86..7bd4b3b2 100644 --- a/SignalsPanel.c +++ b/SignalsPanel.c @@ -1,7 +1,7 @@ #include "SignalsPanel.h" #include "Panel.h" -#include "SignalItem.h" +#include "ListItem.h" #include "RichString.h" #include "debug.h" @@ -13,37 +13,14 @@ typedef struct SignalsPanel_ { Panel super; - - int state; - Signal** signals; + ListItem** signals; } SignalsPanel; }*/ -static HandlerResult SignalsPanel_eventHandler(Panel* super, int ch) { - SignalsPanel* this = (SignalsPanel*) super; - - int size = Panel_size(super); - - if (ch <= 255 && isdigit(ch)) { - int sgn = ch-48 + this->state; - for (int i = 0; i < size; i++) - if (((Signal*) Panel_get(super, i))->number == sgn) { - Panel_setSelected(super, i); - break; - } - this->state = sgn * 10; - if (this->state > 100) - this->state = 0; - return HANDLED; - } else { - this->state = 0; - } - if (ch == 13) { - return BREAK_LOOP; - } - return IGNORED; -} +#ifndef SIGNAL_COUNT +#define SIGNAL_COUNT 34 +#endif static void SignalsPanel_delete(Object* object) { Panel* super = (Panel*) object; @@ -53,16 +30,53 @@ static void SignalsPanel_delete(Object* object) { free(this); } +static ListItem** Signal_getSignalTable() { + ListItem** signals = malloc(sizeof(ListItem*) * SIGNAL_COUNT); + signals[0] = ListItem_new(" 0 Cancel", 0); + signals[1] = ListItem_new(" 1 SIGHUP", 1); + signals[2] = ListItem_new(" 2 SIGINT", 2); + signals[3] = ListItem_new(" 3 SIGQUIT", 3); + signals[4] = ListItem_new(" 4 SIGILL", 4); + signals[5] = ListItem_new(" 5 SIGTRAP", 5); + signals[6] = ListItem_new(" 6 SIGABRT", 6); + signals[7] = ListItem_new(" 6 SIGIOT", 6); + signals[8] = ListItem_new(" 7 SIGBUS", 7); + signals[9] = ListItem_new(" 8 SIGFPE", 8); + signals[10] = ListItem_new(" 9 SIGKILL", 9); + signals[11] = ListItem_new("10 SIGUSR1", 10); + signals[12] = ListItem_new("11 SIGSEGV", 11); + signals[13] = ListItem_new("12 SIGUSR2", 12); + signals[14] = ListItem_new("13 SIGPIPE", 13); + signals[15] = ListItem_new("14 SIGALRM", 14); + signals[16] = ListItem_new("15 SIGTERM", 15); + signals[17] = ListItem_new("16 SIGSTKFLT", 16); + signals[18] = ListItem_new("17 SIGCHLD", 17); + signals[19] = ListItem_new("18 SIGCONT", 18); + signals[20] = ListItem_new("19 SIGSTOP", 19); + signals[21] = ListItem_new("20 SIGTSTP", 20); + signals[22] = ListItem_new("21 SIGTTIN", 21); + signals[23] = ListItem_new("22 SIGTTOU", 22); + signals[24] = ListItem_new("23 SIGURG", 23); + signals[25] = ListItem_new("24 SIGXCPU", 24); + signals[26] = ListItem_new("25 SIGXFSZ", 25); + signals[27] = ListItem_new("26 SIGVTALRM", 26); + signals[28] = ListItem_new("27 SIGPROF", 27); + signals[29] = ListItem_new("28 SIGWINCH", 28); + signals[30] = ListItem_new("29 SIGIO", 29); + signals[31] = ListItem_new("29 SIGPOLL", 29); + signals[32] = ListItem_new("30 SIGPWR", 30); + signals[33] = ListItem_new("31 SIGSYS", 31); + return signals; +} + SignalsPanel* SignalsPanel_new(int x, int y, int w, int h) { SignalsPanel* this = (SignalsPanel*) malloc(sizeof(SignalsPanel)); Panel* super = (Panel*) this; - Panel_init(super, x, y, w, h, SIGNAL_CLASS, true); + Panel_init(super, x, y, w, h, LISTITEM_CLASS, true); ((Object*)this)->delete = SignalsPanel_delete; this->signals = Signal_getSignalTable(); - super->eventHandler = SignalsPanel_eventHandler; - int sigCount = Signal_getSignalCount(); - for(int i = 0; i < sigCount; i++) + for(int i = 0; i < SIGNAL_COUNT; i++) Panel_set(super, i, (Object*) this->signals[i]); SignalsPanel_reset(this); return this; @@ -73,5 +87,4 @@ void SignalsPanel_reset(SignalsPanel* this) { Panel_setHeader(super, "Send signal:"); Panel_setSelected(super, 16); // 16th item is SIGTERM - this->state = 0; } |