mirror of https://github.com/xzeldon/htop.git
reduce code
This commit is contained in:
parent
88f6de2352
commit
3885648881
|
@ -11,63 +11,60 @@
|
|||
|
||||
/*{
|
||||
|
||||
typedef struct SignalItem_ {
|
||||
const char* name;
|
||||
int number;
|
||||
} SignalItem;
|
||||
|
||||
typedef struct SignalsPanel_ {
|
||||
Panel super;
|
||||
ListItem** signals;
|
||||
} SignalsPanel;
|
||||
|
||||
}*/
|
||||
|
||||
#ifndef SIGNAL_COUNT
|
||||
#define SIGNAL_COUNT 34
|
||||
#endif
|
||||
|
||||
static void SignalsPanel_delete(Object* object) {
|
||||
Panel* super = (Panel*) object;
|
||||
SignalsPanel* this = (SignalsPanel*) object;
|
||||
Panel_done(super);
|
||||
free(this->signals);
|
||||
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;
|
||||
}
|
||||
static SignalItem signals[] = {
|
||||
{ .name = " 0 Cancel", .number = 0 },
|
||||
{ .name = " 1 SIGHUP", .number = 1 },
|
||||
{ .name = " 2 SIGINT", .number = 2 },
|
||||
{ .name = " 3 SIGQUIT", .number = 3 },
|
||||
{ .name = " 4 SIGILL", .number = 4 },
|
||||
{ .name = " 5 SIGTRAP", .number = 5 },
|
||||
{ .name = " 6 SIGABRT", .number = 6 },
|
||||
{ .name = " 6 SIGIOT", .number = 6 },
|
||||
{ .name = " 7 SIGBUS", .number = 7 },
|
||||
{ .name = " 8 SIGFPE", .number = 8 },
|
||||
{ .name = " 9 SIGKILL", .number = 9 },
|
||||
{ .name = "10 SIGUSR1", .number = 10 },
|
||||
{ .name = "11 SIGSEGV", .number = 11 },
|
||||
{ .name = "12 SIGUSR2", .number = 12 },
|
||||
{ .name = "13 SIGPIPE", .number = 13 },
|
||||
{ .name = "14 SIGALRM", .number = 14 },
|
||||
{ .name = "15 SIGTERM", .number = 15 },
|
||||
{ .name = "16 SIGSTKFLT", .number = 16 },
|
||||
{ .name = "17 SIGCHLD", .number = 17 },
|
||||
{ .name = "18 SIGCONT", .number = 18 },
|
||||
{ .name = "19 SIGSTOP", .number = 19 },
|
||||
{ .name = "20 SIGTSTP", .number = 20 },
|
||||
{ .name = "21 SIGTTIN", .number = 21 },
|
||||
{ .name = "22 SIGTTOU", .number = 22 },
|
||||
{ .name = "23 SIGURG", .number = 23 },
|
||||
{ .name = "24 SIGXCPU", .number = 24 },
|
||||
{ .name = "25 SIGXFSZ", .number = 25 },
|
||||
{ .name = "26 SIGVTALRM", .number = 26 },
|
||||
{ .name = "27 SIGPROF", .number = 27 },
|
||||
{ .name = "28 SIGWINCH", .number = 28 },
|
||||
{ .name = "29 SIGIO", .number = 29 },
|
||||
{ .name = "29 SIGPOLL", .number = 29 },
|
||||
{ .name = "30 SIGPWR", .number = 30 },
|
||||
{ .name = "31 SIGSYS", .number = 31 },
|
||||
};
|
||||
|
||||
SignalsPanel* SignalsPanel_new(int x, int y, int w, int h) {
|
||||
SignalsPanel* this = (SignalsPanel*) malloc(sizeof(SignalsPanel));
|
||||
|
@ -75,9 +72,8 @@ SignalsPanel* SignalsPanel_new(int x, int y, int w, int h) {
|
|||
Panel_init(super, x, y, w, h, LISTITEM_CLASS, true);
|
||||
((Object*)this)->delete = SignalsPanel_delete;
|
||||
|
||||
this->signals = Signal_getSignalTable();
|
||||
for(int i = 0; i < SIGNAL_COUNT; i++)
|
||||
Panel_set(super, i, (Object*) this->signals[i]);
|
||||
for(unsigned int i = 0; i < sizeof(signals)/sizeof(SignalItem); i++)
|
||||
Panel_set(super, i, (Object*) ListItem_new(signals[i].name, signals[i].number));
|
||||
SignalsPanel_reset(this);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -13,16 +13,16 @@
|
|||
#include <ctype.h>
|
||||
|
||||
|
||||
typedef struct SignalItem_ {
|
||||
const char* name;
|
||||
int number;
|
||||
} SignalItem;
|
||||
|
||||
typedef struct SignalsPanel_ {
|
||||
Panel super;
|
||||
ListItem** signals;
|
||||
} SignalsPanel;
|
||||
|
||||
|
||||
#ifndef SIGNAL_COUNT
|
||||
#define SIGNAL_COUNT 34
|
||||
#endif
|
||||
|
||||
SignalsPanel* SignalsPanel_new(int x, int y, int w, int h);
|
||||
|
||||
void SignalsPanel_reset(SignalsPanel* this);
|
||||
|
|
Loading…
Reference in New Issue