mirror of https://github.com/xzeldon/htop.git
Move FunctionBar inside Panel
This commit is contained in:
parent
1084a3ff8f
commit
d0c72c3fb2
36
Action.c
36
Action.c
|
@ -61,18 +61,16 @@ typedef struct State_ {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
Object* Action_pickFromVector(State* st, Panel* list, int x, const char** keyLabels) {
|
Object* Action_pickFromVector(State* st, Panel* list, int x) {
|
||||||
Panel* panel = st->panel;
|
Panel* panel = st->panel;
|
||||||
Header* header = st->header;
|
Header* header = st->header;
|
||||||
Settings* settings = st->settings;
|
Settings* settings = st->settings;
|
||||||
|
|
||||||
int y = panel->y;
|
int y = panel->y;
|
||||||
const char* fuKeys[] = {"Enter", "Esc", NULL};
|
|
||||||
int fuEvents[] = {13, 27};
|
|
||||||
ScreenManager* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, false);
|
ScreenManager* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, false);
|
||||||
scr->allowFocusChange = false;
|
scr->allowFocusChange = false;
|
||||||
ScreenManager_add(scr, list, FunctionBar_new(keyLabels, fuKeys, fuEvents), x - 1);
|
ScreenManager_add(scr, list, x - 1);
|
||||||
ScreenManager_add(scr, panel, NULL, -1);
|
ScreenManager_add(scr, panel, -1);
|
||||||
Panel* panelFocus;
|
Panel* panelFocus;
|
||||||
int ch;
|
int ch;
|
||||||
bool unfollow = false;
|
bool unfollow = false;
|
||||||
|
@ -100,12 +98,10 @@ Object* Action_pickFromVector(State* st, Panel* list, int x, const char** keyLab
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
static const char* CategoriesFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};
|
|
||||||
|
|
||||||
static void Action_runSetup(Settings* settings, const Header* header, ProcessList* pl) {
|
static void Action_runSetup(Settings* settings, const Header* header, ProcessList* pl) {
|
||||||
ScreenManager* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, true);
|
ScreenManager* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, true);
|
||||||
CategoriesPanel* panelCategories = CategoriesPanel_new(scr, settings, (Header*) header, pl);
|
CategoriesPanel* panelCategories = CategoriesPanel_new(scr, settings, (Header*) header, pl);
|
||||||
ScreenManager_add(scr, (Panel*) panelCategories, FunctionBar_new(CategoriesFunctions, NULL, NULL), 16);
|
ScreenManager_add(scr, (Panel*) panelCategories, 16);
|
||||||
CategoriesPanel_makeMetersPage(panelCategories);
|
CategoriesPanel_makeMetersPage(panelCategories);
|
||||||
Panel* panelFocus;
|
Panel* panelFocus;
|
||||||
int ch;
|
int ch;
|
||||||
|
@ -165,11 +161,14 @@ static inline Htop_Reaction setSortKey(Settings* settings, ProcessField sortKey)
|
||||||
return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_UPDATE_PANELHDR;
|
return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_UPDATE_PANELHDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* SortFunctions[] = {"Sort ", "Cancel ", NULL};
|
||||||
|
static const char* SortKeys[] = {"Enter", "Esc", NULL};
|
||||||
|
static int SortEvents[] = {13, 27};
|
||||||
|
|
||||||
static Htop_Reaction sortBy(State* st) {
|
static Htop_Reaction sortBy(State* st) {
|
||||||
Htop_Reaction reaction = HTOP_OK;
|
Htop_Reaction reaction = HTOP_OK;
|
||||||
Panel* sortPanel = Panel_new(0, 0, 0, 0, true, Class(ListItem));
|
Panel* sortPanel = Panel_new(0, 0, 0, 0, true, Class(ListItem), FunctionBar_new(SortFunctions, SortKeys, SortEvents));
|
||||||
Panel_setHeader(sortPanel, "Sort by");
|
Panel_setHeader(sortPanel, "Sort by");
|
||||||
const char* fuFunctions[] = {"Sort ", "Cancel ", NULL};
|
|
||||||
ProcessField* fields = st->settings->fields;
|
ProcessField* fields = st->settings->fields;
|
||||||
for (int i = 0; fields[i]; i++) {
|
for (int i = 0; fields[i]; i++) {
|
||||||
char* name = String_trim(Process_fields[fields[i]].name);
|
char* name = String_trim(Process_fields[fields[i]].name);
|
||||||
|
@ -178,7 +177,7 @@ static Htop_Reaction sortBy(State* st) {
|
||||||
Panel_setSelected(sortPanel, i);
|
Panel_setSelected(sortPanel, i);
|
||||||
free(name);
|
free(name);
|
||||||
}
|
}
|
||||||
ListItem* field = (ListItem*) Action_pickFromVector(st, sortPanel, 15, fuFunctions);
|
ListItem* field = (ListItem*) Action_pickFromVector(st, sortPanel, 15);
|
||||||
if (field) {
|
if (field) {
|
||||||
reaction |= setSortKey(st->settings, field->key);
|
reaction |= setSortKey(st->settings, field->key);
|
||||||
}
|
}
|
||||||
|
@ -280,8 +279,7 @@ static Htop_Reaction actionSetAffinity(State* st) {
|
||||||
Panel* affinityPanel = AffinityPanel_new(st->pl, affinity);
|
Panel* affinityPanel = AffinityPanel_new(st->pl, affinity);
|
||||||
Affinity_delete(affinity);
|
Affinity_delete(affinity);
|
||||||
|
|
||||||
const char* fuFunctions[] = {"Set ", "Cancel ", NULL};
|
void* set = Action_pickFromVector(st, affinityPanel, 15);
|
||||||
void* set = Action_pickFromVector(st, affinityPanel, 15, fuFunctions);
|
|
||||||
if (set) {
|
if (set) {
|
||||||
Affinity* affinity = AffinityPanel_getAffinity(affinityPanel, st->pl);
|
Affinity* affinity = AffinityPanel_getAffinity(affinityPanel, st->pl);
|
||||||
bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) Affinity_set, (size_t) affinity, NULL);
|
bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) Affinity_set, (size_t) affinity, NULL);
|
||||||
|
@ -295,8 +293,7 @@ static Htop_Reaction actionSetAffinity(State* st) {
|
||||||
|
|
||||||
static Htop_Reaction actionKill(State* st) {
|
static Htop_Reaction actionKill(State* st) {
|
||||||
Panel* signalsPanel = (Panel*) SignalsPanel_new();
|
Panel* signalsPanel = (Panel*) SignalsPanel_new();
|
||||||
const char* fuFunctions[] = {"Send ", "Cancel ", NULL};
|
ListItem* sgn = (ListItem*) Action_pickFromVector(st, signalsPanel, 15);
|
||||||
ListItem* sgn = (ListItem*) Action_pickFromVector(st, signalsPanel, 15, fuFunctions);
|
|
||||||
if (sgn) {
|
if (sgn) {
|
||||||
if (sgn->key != 0) {
|
if (sgn->key != 0) {
|
||||||
Panel_setHeader(st->panel, "Sending...");
|
Panel_setHeader(st->panel, "Sending...");
|
||||||
|
@ -310,15 +307,18 @@ static Htop_Reaction actionKill(State* st) {
|
||||||
return HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
|
return HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* UsersFunctions[] = {"Show ", "Cancel ", NULL};
|
||||||
|
static const char* UsersKeys[] = {"Enter", "Esc", NULL};
|
||||||
|
static int UsersEvents[] = {13, 27};
|
||||||
|
|
||||||
static Htop_Reaction actionFilterByUser(State* st) {
|
static Htop_Reaction actionFilterByUser(State* st) {
|
||||||
Panel* usersPanel = Panel_new(0, 0, 0, 0, true, Class(ListItem));
|
Panel* usersPanel = Panel_new(0, 0, 0, 0, true, Class(ListItem), FunctionBar_new(UsersFunctions, UsersKeys, UsersEvents));
|
||||||
Panel_setHeader(usersPanel, "Show processes of:");
|
Panel_setHeader(usersPanel, "Show processes of:");
|
||||||
UsersTable_foreach(st->ut, addUserToVector, usersPanel);
|
UsersTable_foreach(st->ut, addUserToVector, usersPanel);
|
||||||
Vector_insertionSort(usersPanel->items);
|
Vector_insertionSort(usersPanel->items);
|
||||||
ListItem* allUsers = ListItem_new("All users", -1);
|
ListItem* allUsers = ListItem_new("All users", -1);
|
||||||
Panel_insert(usersPanel, 0, (Object*) allUsers);
|
Panel_insert(usersPanel, 0, (Object*) allUsers);
|
||||||
const char* fuFunctions[] = {"Show ", "Cancel ", NULL};
|
ListItem* picked = (ListItem*) Action_pickFromVector(st, usersPanel, 20);
|
||||||
ListItem* picked = (ListItem*) Action_pickFromVector(st, usersPanel, 20, fuFunctions);
|
|
||||||
if (picked) {
|
if (picked) {
|
||||||
if (picked == allUsers) {
|
if (picked == allUsers) {
|
||||||
st->pl->userId = -1;
|
st->pl->userId = -1;
|
||||||
|
|
2
Action.h
2
Action.h
|
@ -39,7 +39,7 @@ typedef struct State_ {
|
||||||
} State;
|
} State;
|
||||||
|
|
||||||
|
|
||||||
Object* Action_pickFromVector(State* st, Panel* list, int x, const char** keyLabels);
|
Object* Action_pickFromVector(State* st, Panel* list, int x);
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,12 @@ PanelClass AffinityPanel_class = {
|
||||||
.eventHandler = AffinityPanel_eventHandler
|
.eventHandler = AffinityPanel_eventHandler
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char* AffinityFunctions[] = {"Set ", "Cancel ", NULL};
|
||||||
|
static const char* AffinityKeys[] = {"Enter", "Esc", NULL};
|
||||||
|
static int AffinityEvents[] = {13, 27};
|
||||||
|
|
||||||
Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity) {
|
Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity) {
|
||||||
Panel* this = Panel_new(1, 1, 1, 1, true, Class(CheckItem));
|
Panel* this = Panel_new(1, 1, 1, 1, true, Class(CheckItem), FunctionBar_new(AffinityFunctions, AffinityKeys, AffinityEvents));
|
||||||
Object_setClass(this, Class(AffinityPanel));
|
Object_setClass(this, Class(AffinityPanel));
|
||||||
|
|
||||||
Panel_setHeader(this, "Use CPUs:");
|
Panel_setHeader(this, "Use CPUs:");
|
||||||
|
|
|
@ -26,6 +26,8 @@ typedef struct AvailableColumnsPanel_ {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
static const char* AvailableColumnsFunctions[] = {" ", " ", " ", " ", "Add ", " ", " ", " ", " ", "Done ", NULL};
|
||||||
|
|
||||||
static void AvailableColumnsPanel_delete(Object* object) {
|
static void AvailableColumnsPanel_delete(Object* object) {
|
||||||
Panel* super = (Panel*) object;
|
Panel* super = (Panel*) object;
|
||||||
AvailableColumnsPanel* this = (AvailableColumnsPanel*) object;
|
AvailableColumnsPanel* this = (AvailableColumnsPanel*) object;
|
||||||
|
@ -71,7 +73,8 @@ PanelClass AvailableColumnsPanel_class = {
|
||||||
AvailableColumnsPanel* AvailableColumnsPanel_new(Panel* columns) {
|
AvailableColumnsPanel* AvailableColumnsPanel_new(Panel* columns) {
|
||||||
AvailableColumnsPanel* this = AllocThis(AvailableColumnsPanel);
|
AvailableColumnsPanel* this = AllocThis(AvailableColumnsPanel);
|
||||||
Panel* super = (Panel*) this;
|
Panel* super = (Panel*) this;
|
||||||
Panel_init(super, 1, 1, 1, 1, Class(ListItem), true);
|
FunctionBar* fuBar = FunctionBar_new(AvailableColumnsFunctions, NULL, NULL);
|
||||||
|
Panel_init(super, 1, 1, 1, 1, Class(ListItem), true, fuBar);
|
||||||
|
|
||||||
Panel_setHeader(super, "Available Columns");
|
Panel_setHeader(super, "Available Columns");
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,10 @@ typedef struct AvailableMetersPanel_ {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
static const char* AvailableMetersFunctions[] = {"Add ", "Done ", NULL};
|
||||||
|
static const char* AvailableMetersKeys[] = {"Enter", "Esc"};
|
||||||
|
static int AvailableMetersEvents[] = {13, 27};
|
||||||
|
|
||||||
static void AvailableMetersPanel_delete(Object* object) {
|
static void AvailableMetersPanel_delete(Object* object) {
|
||||||
Panel* super = (Panel*) object;
|
Panel* super = (Panel*) object;
|
||||||
AvailableMetersPanel* this = (AvailableMetersPanel*) object;
|
AvailableMetersPanel* this = (AvailableMetersPanel*) object;
|
||||||
|
@ -102,7 +106,8 @@ PanelClass AvailableMetersPanel_class = {
|
||||||
AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Header* header, Panel* leftMeters, Panel* rightMeters, ScreenManager* scr, ProcessList* pl) {
|
AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Header* header, Panel* leftMeters, Panel* rightMeters, ScreenManager* scr, ProcessList* pl) {
|
||||||
AvailableMetersPanel* this = AllocThis(AvailableMetersPanel);
|
AvailableMetersPanel* this = AllocThis(AvailableMetersPanel);
|
||||||
Panel* super = (Panel*) this;
|
Panel* super = (Panel*) this;
|
||||||
Panel_init(super, 1, 1, 1, 1, Class(ListItem), true);
|
FunctionBar* fuBar = FunctionBar_new(AvailableMetersFunctions, AvailableMetersKeys, AvailableMetersEvents);
|
||||||
|
Panel_init(super, 1, 1, 1, 1, Class(ListItem), true, fuBar);
|
||||||
|
|
||||||
this->settings = settings;
|
this->settings = settings;
|
||||||
this->header = header;
|
this->header = header;
|
||||||
|
|
|
@ -34,21 +34,7 @@ typedef struct CategoriesPanel_ {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
static const char* MetersFunctions[] = {"Type ", "Move ", "Delete", "Done ", NULL};
|
static const char* CategoriesFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};
|
||||||
static const char* MetersKeys[] = {"Space", "Enter", "Del", "Esc"};
|
|
||||||
static int MetersEvents[] = {' ', 13, 27, KEY_DC};
|
|
||||||
|
|
||||||
static const char* AvailableMetersFunctions[] = {"Add ", "Done ", NULL};
|
|
||||||
static const char* AvailableMetersKeys[] = {"Enter", "Esc"};
|
|
||||||
static int AvailableMetersEvents[] = {13, 27};
|
|
||||||
|
|
||||||
static const char* DisplayOptionsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};
|
|
||||||
|
|
||||||
static const char* ColumnsFunctions[] = {" ", " ", " ", " ", " ", " ", "MoveUp", "MoveDn", "Remove", "Done ", NULL};
|
|
||||||
|
|
||||||
static const char* ColorsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};
|
|
||||||
|
|
||||||
static const char* AvailableColumnsFunctions[] = {" ", " ", " ", " ", "Add ", " ", " ", " ", " ", "Done ", NULL};
|
|
||||||
|
|
||||||
static void CategoriesPanel_delete(Object* object) {
|
static void CategoriesPanel_delete(Object* object) {
|
||||||
Panel* super = (Panel*) object;
|
Panel* super = (Panel*) object;
|
||||||
|
@ -63,26 +49,26 @@ void CategoriesPanel_makeMetersPage(CategoriesPanel* this) {
|
||||||
leftMeters->rightNeighbor = rightMeters;
|
leftMeters->rightNeighbor = rightMeters;
|
||||||
rightMeters->leftNeighbor = leftMeters;
|
rightMeters->leftNeighbor = leftMeters;
|
||||||
Panel* availableMeters = (Panel*) AvailableMetersPanel_new(this->settings, this->header, (Panel*) leftMeters, (Panel*) rightMeters, this->scr, this->pl);
|
Panel* availableMeters = (Panel*) AvailableMetersPanel_new(this->settings, this->header, (Panel*) leftMeters, (Panel*) rightMeters, this->scr, this->pl);
|
||||||
ScreenManager_add(this->scr, (Panel*) leftMeters, FunctionBar_new(MetersFunctions, MetersKeys, MetersEvents), 20);
|
ScreenManager_add(this->scr, (Panel*) leftMeters, 20);
|
||||||
ScreenManager_add(this->scr, (Panel*) rightMeters, FunctionBar_new(MetersFunctions, MetersKeys, MetersEvents), 20);
|
ScreenManager_add(this->scr, (Panel*) rightMeters, 20);
|
||||||
ScreenManager_add(this->scr, availableMeters, FunctionBar_new(AvailableMetersFunctions, AvailableMetersKeys, AvailableMetersEvents), -1);
|
ScreenManager_add(this->scr, availableMeters, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CategoriesPanel_makeDisplayOptionsPage(CategoriesPanel* this) {
|
static void CategoriesPanel_makeDisplayOptionsPage(CategoriesPanel* this) {
|
||||||
Panel* displayOptions = (Panel*) DisplayOptionsPanel_new(this->settings, this->scr);
|
Panel* displayOptions = (Panel*) DisplayOptionsPanel_new(this->settings, this->scr);
|
||||||
ScreenManager_add(this->scr, displayOptions, FunctionBar_new(DisplayOptionsFunctions, NULL, NULL), -1);
|
ScreenManager_add(this->scr, displayOptions, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CategoriesPanel_makeColorsPage(CategoriesPanel* this) {
|
static void CategoriesPanel_makeColorsPage(CategoriesPanel* this) {
|
||||||
Panel* colors = (Panel*) ColorsPanel_new(this->settings, this->scr);
|
Panel* colors = (Panel*) ColorsPanel_new(this->settings, this->scr);
|
||||||
ScreenManager_add(this->scr, colors, FunctionBar_new(ColorsFunctions, NULL, NULL), -1);
|
ScreenManager_add(this->scr, colors, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CategoriesPanel_makeColumnsPage(CategoriesPanel* this) {
|
static void CategoriesPanel_makeColumnsPage(CategoriesPanel* this) {
|
||||||
Panel* columns = (Panel*) ColumnsPanel_new(this->settings);
|
Panel* columns = (Panel*) ColumnsPanel_new(this->settings);
|
||||||
Panel* availableColumns = (Panel*) AvailableColumnsPanel_new(columns);
|
Panel* availableColumns = (Panel*) AvailableColumnsPanel_new(columns);
|
||||||
ScreenManager_add(this->scr, columns, FunctionBar_new(ColumnsFunctions, NULL, NULL), 20);
|
ScreenManager_add(this->scr, columns, 20);
|
||||||
ScreenManager_add(this->scr, availableColumns, FunctionBar_new(AvailableColumnsFunctions, NULL, NULL), -1);
|
ScreenManager_add(this->scr, availableColumns, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HandlerResult CategoriesPanel_eventHandler(Panel* super, int ch) {
|
static HandlerResult CategoriesPanel_eventHandler(Panel* super, int ch) {
|
||||||
|
@ -150,7 +136,8 @@ PanelClass CategoriesPanel_class = {
|
||||||
CategoriesPanel* CategoriesPanel_new(ScreenManager* scr, Settings* settings, Header* header, ProcessList* pl) {
|
CategoriesPanel* CategoriesPanel_new(ScreenManager* scr, Settings* settings, Header* header, ProcessList* pl) {
|
||||||
CategoriesPanel* this = AllocThis(CategoriesPanel);
|
CategoriesPanel* this = AllocThis(CategoriesPanel);
|
||||||
Panel* super = (Panel*) this;
|
Panel* super = (Panel*) this;
|
||||||
Panel_init(super, 1, 1, 1, 1, Class(ListItem), true);
|
FunctionBar* fuBar = FunctionBar_new(CategoriesFunctions, NULL, NULL);
|
||||||
|
Panel_init(super, 1, 1, 1, 1, Class(ListItem), true, fuBar);
|
||||||
|
|
||||||
this->scr = scr;
|
this->scr = scr;
|
||||||
this->settings = settings;
|
this->settings = settings;
|
||||||
|
|
|
@ -34,6 +34,8 @@ typedef struct ColorsPanel_ {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
static const char* ColorsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};
|
||||||
|
|
||||||
static const char* ColorSchemeNames[] = {
|
static const char* ColorSchemeNames[] = {
|
||||||
"Default",
|
"Default",
|
||||||
"Monochromatic",
|
"Monochromatic",
|
||||||
|
@ -94,7 +96,8 @@ PanelClass ColorsPanel_class = {
|
||||||
ColorsPanel* ColorsPanel_new(Settings* settings, ScreenManager* scr) {
|
ColorsPanel* ColorsPanel_new(Settings* settings, ScreenManager* scr) {
|
||||||
ColorsPanel* this = AllocThis(ColorsPanel);
|
ColorsPanel* this = AllocThis(ColorsPanel);
|
||||||
Panel* super = (Panel*) this;
|
Panel* super = (Panel*) this;
|
||||||
Panel_init(super, 1, 1, 1, 1, Class(CheckItem), true);
|
FunctionBar* fuBar = FunctionBar_new(ColorsFunctions, NULL, NULL);
|
||||||
|
Panel_init(super, 1, 1, 1, 1, Class(CheckItem), true, fuBar);
|
||||||
|
|
||||||
this->settings = settings;
|
this->settings = settings;
|
||||||
this->scr = scr;
|
this->scr = scr;
|
||||||
|
|
|
@ -28,6 +28,8 @@ typedef struct ColumnsPanel_ {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
static const char* ColumnsFunctions[] = {" ", " ", " ", " ", " ", " ", "MoveUp", "MoveDn", "Remove", "Done ", NULL};
|
||||||
|
|
||||||
static void ColumnsPanel_delete(Object* object) {
|
static void ColumnsPanel_delete(Object* object) {
|
||||||
Panel* super = (Panel*) object;
|
Panel* super = (Panel*) object;
|
||||||
ColumnsPanel* this = (ColumnsPanel*) object;
|
ColumnsPanel* this = (ColumnsPanel*) object;
|
||||||
|
@ -121,7 +123,8 @@ PanelClass ColumnsPanel_class = {
|
||||||
ColumnsPanel* ColumnsPanel_new(Settings* settings) {
|
ColumnsPanel* ColumnsPanel_new(Settings* settings) {
|
||||||
ColumnsPanel* this = AllocThis(ColumnsPanel);
|
ColumnsPanel* this = AllocThis(ColumnsPanel);
|
||||||
Panel* super = (Panel*) this;
|
Panel* super = (Panel*) this;
|
||||||
Panel_init(super, 1, 1, 1, 1, Class(ListItem), true);
|
FunctionBar* fuBar = FunctionBar_new(ColumnsFunctions, NULL, NULL);
|
||||||
|
Panel_init(super, 1, 1, 1, 1, Class(ListItem), true, fuBar);
|
||||||
|
|
||||||
this->settings = settings;
|
this->settings = settings;
|
||||||
this->moving = false;
|
this->moving = false;
|
||||||
|
|
|
@ -27,6 +27,8 @@ typedef struct DisplayOptionsPanel_ {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
static const char* DisplayOptionsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};
|
||||||
|
|
||||||
static void DisplayOptionsPanel_delete(Object* object) {
|
static void DisplayOptionsPanel_delete(Object* object) {
|
||||||
Panel* super = (Panel*) object;
|
Panel* super = (Panel*) object;
|
||||||
DisplayOptionsPanel* this = (DisplayOptionsPanel*) object;
|
DisplayOptionsPanel* this = (DisplayOptionsPanel*) object;
|
||||||
|
@ -72,7 +74,8 @@ PanelClass DisplayOptionsPanel_class = {
|
||||||
DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* scr) {
|
DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* scr) {
|
||||||
DisplayOptionsPanel* this = AllocThis(DisplayOptionsPanel);
|
DisplayOptionsPanel* this = AllocThis(DisplayOptionsPanel);
|
||||||
Panel* super = (Panel*) this;
|
Panel* super = (Panel*) this;
|
||||||
Panel_init(super, 1, 1, 1, 1, Class(CheckItem), true);
|
FunctionBar* fuBar = FunctionBar_new(DisplayOptionsFunctions, NULL, NULL);
|
||||||
|
Panel_init(super, 1, 1, 1, 1, Class(CheckItem), true, fuBar);
|
||||||
|
|
||||||
this->settings = settings;
|
this->settings = settings;
|
||||||
this->scr = scr;
|
this->scr = scr;
|
||||||
|
|
|
@ -6,19 +6,18 @@ in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FunctionBar.h"
|
#include "FunctionBar.h"
|
||||||
|
|
||||||
#include "CRT.h"
|
#include "CRT.h"
|
||||||
|
#include "RichString.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
/*{
|
/*{
|
||||||
#include "Object.h"
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
typedef struct FunctionBar_ {
|
typedef struct FunctionBar_ {
|
||||||
Object super;
|
|
||||||
int size;
|
int size;
|
||||||
char** functions;
|
char** functions;
|
||||||
char** keys;
|
char** keys;
|
||||||
|
@ -34,12 +33,8 @@ static const char* FunctionBar_FLabels[] = {" ", " ", " ", "
|
||||||
|
|
||||||
static int FunctionBar_FEvents[] = {KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5), KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10)};
|
static int FunctionBar_FEvents[] = {KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5), KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10)};
|
||||||
|
|
||||||
ObjectClass FunctionBar_class = {
|
|
||||||
.delete = FunctionBar_delete
|
|
||||||
};
|
|
||||||
|
|
||||||
FunctionBar* FunctionBar_new(const char** functions, const char** keys, int* events) {
|
FunctionBar* FunctionBar_new(const char** functions, const char** keys, int* events) {
|
||||||
FunctionBar* this = AllocThis(FunctionBar);
|
FunctionBar* this = calloc(1, sizeof(FunctionBar));
|
||||||
this->functions = calloc(16, sizeof(char*));
|
this->functions = calloc(16, sizeof(char*));
|
||||||
if (!functions) {
|
if (!functions) {
|
||||||
functions = FunctionBar_FLabels;
|
functions = FunctionBar_FLabels;
|
||||||
|
@ -67,8 +62,7 @@ FunctionBar* FunctionBar_new(const char** functions, const char** keys, int* eve
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FunctionBar_delete(Object* cast) {
|
void FunctionBar_delete(FunctionBar* this) {
|
||||||
FunctionBar* this = (FunctionBar*) cast;
|
|
||||||
for (int i = 0; i < 15 && this->functions[i]; i++) {
|
for (int i = 0; i < 15 && this->functions[i]; i++) {
|
||||||
free(this->functions[i]);
|
free(this->functions[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,10 @@ Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Object.h"
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
typedef struct FunctionBar_ {
|
typedef struct FunctionBar_ {
|
||||||
Object super;
|
|
||||||
int size;
|
int size;
|
||||||
char** functions;
|
char** functions;
|
||||||
char** keys;
|
char** keys;
|
||||||
|
@ -21,11 +21,9 @@ typedef struct FunctionBar_ {
|
||||||
} FunctionBar;
|
} FunctionBar;
|
||||||
|
|
||||||
|
|
||||||
extern ObjectClass FunctionBar_class;
|
|
||||||
|
|
||||||
FunctionBar* FunctionBar_new(const char** functions, const char** keys, int* events);
|
FunctionBar* FunctionBar_new(const char** functions, const char** keys, int* events);
|
||||||
|
|
||||||
void FunctionBar_delete(Object* cast);
|
void FunctionBar_delete(FunctionBar* this);
|
||||||
|
|
||||||
void FunctionBar_setLabel(FunctionBar* this, int event, const char* text);
|
void FunctionBar_setLabel(FunctionBar* this, int event, const char* text);
|
||||||
|
|
||||||
|
|
5
IncSet.c
5
IncSet.c
|
@ -73,7 +73,7 @@ static inline void IncMode_initFilter(IncMode* filter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void IncMode_done(IncMode* mode) {
|
static inline void IncMode_done(IncMode* mode) {
|
||||||
FunctionBar_delete((Object*)mode->bar);
|
FunctionBar_delete(mode->bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
IncSet* IncSet_new(FunctionBar* bar) {
|
IncSet* IncSet_new(FunctionBar* bar) {
|
||||||
|
@ -202,10 +202,11 @@ const char* IncSet_getListItemValue(Panel* panel, int i) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void IncSet_activate(IncSet* this, IncType type) {
|
void IncSet_activate(IncSet* this, IncType type, FunctionBar** setBar) {
|
||||||
this->active = &(this->modes[type]);
|
this->active = &(this->modes[type]);
|
||||||
this->bar = this->active->bar;
|
this->bar = this->active->bar;
|
||||||
FunctionBar_draw(this->active->bar, this->active->buffer);
|
FunctionBar_draw(this->active->bar, this->active->buffer);
|
||||||
|
setBar =
|
||||||
}
|
}
|
||||||
|
|
||||||
void IncSet_drawBar(IncSet* this) {
|
void IncSet_drawBar(IncSet* this) {
|
||||||
|
|
22
MainPanel.c
22
MainPanel.c
|
@ -30,13 +30,15 @@ typedef bool(*MainPanel_ForeachProcessFn)(Process*, size_t);
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
void MainPanel_updateTreeFunctions(FunctionBar* fuBar, bool mode) {
|
static const char* MainFunctions[] = {"Help ", "Setup ", "Search", "Filter", "Tree ", "SortBy", "Nice -", "Nice +", "Kill ", "Quit ", NULL};
|
||||||
|
|
||||||
|
void MainPanel_updateTreeFunctions(MainPanel* this, bool mode) {
|
||||||
if (mode) {
|
if (mode) {
|
||||||
FunctionBar_setLabel(fuBar, KEY_F(5), "Sorted");
|
FunctionBar_setLabel(this->fuBar, KEY_F(5), "Sorted");
|
||||||
FunctionBar_setLabel(fuBar, KEY_F(6), "Collap");
|
FunctionBar_setLabel(this->fuBar, KEY_F(6), "Collap");
|
||||||
} else {
|
} else {
|
||||||
FunctionBar_setLabel(fuBar, KEY_F(5), "Tree ");
|
FunctionBar_setLabel(this->fuBar, KEY_F(5), "Tree ");
|
||||||
FunctionBar_setLabel(fuBar, KEY_F(6), "SortBy");
|
FunctionBar_setLabel(this->fuBar, KEY_F(6), "SortBy");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +100,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reaction & HTOP_REDRAW_BAR) {
|
if (reaction & HTOP_REDRAW_BAR) {
|
||||||
MainPanel_updateTreeFunctions(this->fuBar, this->state->settings->treeView);
|
MainPanel_updateTreeFunctions(this, this->state->settings->treeView);
|
||||||
IncSet_drawBar(this->inc);
|
IncSet_drawBar(this->inc);
|
||||||
}
|
}
|
||||||
if (reaction & HTOP_UPDATE_PANELHDR) {
|
if (reaction & HTOP_UPDATE_PANELHDR) {
|
||||||
|
@ -165,12 +167,12 @@ PanelClass MainPanel_class = {
|
||||||
.eventHandler = MainPanel_eventHandler
|
.eventHandler = MainPanel_eventHandler
|
||||||
};
|
};
|
||||||
|
|
||||||
MainPanel* MainPanel_new(FunctionBar* fuBar) {
|
MainPanel* MainPanel_new() {
|
||||||
MainPanel* this = AllocThis(MainPanel);
|
MainPanel* this = AllocThis(MainPanel);
|
||||||
Panel_init((Panel*) this, 1, 1, 1, 1, Class(Process), false);
|
this->fuBar = FunctionBar_new(MainFunctions, NULL, NULL);
|
||||||
|
Panel_init((Panel*) this, 1, 1, 1, 1, Class(Process), false, this->fuBar);
|
||||||
this->keys = calloc(KEY_MAX, sizeof(Htop_Action));
|
this->keys = calloc(KEY_MAX, sizeof(Htop_Action));
|
||||||
this->fuBar = fuBar;
|
this->inc = IncSet_new(this->fuBar);
|
||||||
this->inc = IncSet_new(fuBar);
|
|
||||||
|
|
||||||
Action_setBindings(this->keys);
|
Action_setBindings(this->keys);
|
||||||
Platform_setBindings(this->keys);
|
Platform_setBindings(this->keys);
|
||||||
|
|
|
@ -25,7 +25,7 @@ typedef struct MainPanel_ {
|
||||||
typedef bool(*MainPanel_ForeachProcessFn)(Process*, size_t);
|
typedef bool(*MainPanel_ForeachProcessFn)(Process*, size_t);
|
||||||
|
|
||||||
|
|
||||||
void MainPanel_updateTreeFunctions(FunctionBar* fuBar, bool mode);
|
void MainPanel_updateTreeFunctions(MainPanel* this, bool mode);
|
||||||
|
|
||||||
void MainPanel_pidSearch(MainPanel* this, int ch);
|
void MainPanel_pidSearch(MainPanel* this, int ch);
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, in
|
||||||
|
|
||||||
extern PanelClass MainPanel_class;
|
extern PanelClass MainPanel_class;
|
||||||
|
|
||||||
MainPanel* MainPanel_new(FunctionBar* fuBar);
|
MainPanel* MainPanel_new();
|
||||||
|
|
||||||
void MainPanel_setState(MainPanel* this, State* state);
|
void MainPanel_setState(MainPanel* this, State* state);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,10 @@ struct MetersPanel_ {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
static const char* MetersFunctions[] = {"Type ", "Move ", "Delete", "Done ", NULL};
|
||||||
|
static const char* MetersKeys[] = {"Space", "Enter", "Del", "Esc"};
|
||||||
|
static int MetersEvents[] = {' ', 13, 27, KEY_DC};
|
||||||
|
|
||||||
static void MetersPanel_delete(Object* object) {
|
static void MetersPanel_delete(Object* object) {
|
||||||
Panel* super = (Panel*) object;
|
Panel* super = (Panel*) object;
|
||||||
MetersPanel* this = (MetersPanel*) object;
|
MetersPanel* this = (MetersPanel*) object;
|
||||||
|
@ -172,7 +176,8 @@ PanelClass MetersPanel_class = {
|
||||||
MetersPanel* MetersPanel_new(Settings* settings, const char* header, Vector* meters, ScreenManager* scr) {
|
MetersPanel* MetersPanel_new(Settings* settings, const char* header, Vector* meters, ScreenManager* scr) {
|
||||||
MetersPanel* this = AllocThis(MetersPanel);
|
MetersPanel* this = AllocThis(MetersPanel);
|
||||||
Panel* super = (Panel*) this;
|
Panel* super = (Panel*) this;
|
||||||
Panel_init(super, 1, 1, 1, 1, Class(ListItem), true);
|
FunctionBar* fuBar = FunctionBar_new(MetersFunctions, MetersKeys, MetersEvents);
|
||||||
|
Panel_init(super, 1, 1, 1, 1, Class(ListItem), true, fuBar);
|
||||||
|
|
||||||
this->settings = settings;
|
this->settings = settings;
|
||||||
this->meters = meters;
|
this->meters = meters;
|
||||||
|
|
|
@ -12,6 +12,7 @@ in the source distribution for its full text.
|
||||||
#include "ListItem.h"
|
#include "ListItem.h"
|
||||||
#include "IncSet.h"
|
#include "IncSet.h"
|
||||||
#include "String.h"
|
#include "String.h"
|
||||||
|
#include "FunctionBar.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -26,7 +27,6 @@ in the source distribution for its full text.
|
||||||
/*{
|
/*{
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
#include "FunctionBar.h"
|
|
||||||
|
|
||||||
typedef struct OpenFiles_Data_ {
|
typedef struct OpenFiles_Data_ {
|
||||||
char* data[256];
|
char* data[256];
|
||||||
|
@ -47,21 +47,21 @@ typedef struct OpenFilesScreen_ {
|
||||||
Process* process;
|
Process* process;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
Panel* display;
|
Panel* display;
|
||||||
FunctionBar* bar;
|
|
||||||
} OpenFilesScreen;
|
} OpenFilesScreen;
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
static const char* ofsFunctions[] = {"Search ", "Filter ", "Refresh", "Done ", NULL};
|
static const char* OpenFilesScreenFunctions[] = {"Search ", "Filter ", "Refresh", "Done ", NULL};
|
||||||
|
|
||||||
static const char* ofsKeys[] = {"F3", "F4", "F5", "Esc"};
|
static const char* OpenFilesScreenKeys[] = {"F3", "F4", "F5", "Esc"};
|
||||||
|
|
||||||
static int ofsEvents[] = {KEY_F(3), KEY_F(4), KEY_F(5), 27};
|
static int OpenFilesScreenEvents[] = {KEY_F(3), KEY_F(4), KEY_F(5), 27};
|
||||||
|
|
||||||
OpenFilesScreen* OpenFilesScreen_new(Process* process) {
|
OpenFilesScreen* OpenFilesScreen_new(Process* process) {
|
||||||
OpenFilesScreen* this = (OpenFilesScreen*) malloc(sizeof(OpenFilesScreen));
|
OpenFilesScreen* this = (OpenFilesScreen*) malloc(sizeof(OpenFilesScreen));
|
||||||
this->process = process;
|
this->process = process;
|
||||||
this->display = Panel_new(0, 1, COLS, LINES-3, false, Class(ListItem));
|
FunctionBar* bar = FunctionBar_new(OpenFilesScreenFunctions, OpenFilesScreenKeys, OpenFilesScreenEvents);
|
||||||
|
this->display = Panel_new(0, 1, COLS, LINES-3, false, Class(ListItem), bar);
|
||||||
if (Process_isThread(process))
|
if (Process_isThread(process))
|
||||||
this->pid = process->tgid;
|
this->pid = process->tgid;
|
||||||
else
|
else
|
||||||
|
@ -173,7 +173,7 @@ void OpenFilesScreen_run(OpenFilesScreen* this) {
|
||||||
Panel* panel = this->display;
|
Panel* panel = this->display;
|
||||||
Panel_setHeader(panel, " FD TYPE DEVICE SIZE NODE NAME");
|
Panel_setHeader(panel, " FD TYPE DEVICE SIZE NODE NAME");
|
||||||
|
|
||||||
FunctionBar* bar = FunctionBar_new(ofsFunctions, ofsKeys, ofsEvents);
|
FunctionBar* bar = panel->defaultBar;
|
||||||
IncSet* inc = IncSet_new(bar);
|
IncSet* inc = IncSet_new(bar);
|
||||||
|
|
||||||
Vector* lines = Vector_new(panel->items->type, true, DEFAULT_SIZE);
|
Vector* lines = Vector_new(panel->items->type, true, DEFAULT_SIZE);
|
||||||
|
@ -241,6 +241,5 @@ void OpenFilesScreen_run(OpenFilesScreen* this) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector_delete(lines);
|
Vector_delete(lines);
|
||||||
FunctionBar_delete((Object*)bar);
|
|
||||||
IncSet_delete(inc);
|
IncSet_delete(inc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ in the source distribution for its full text.
|
||||||
|
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
#include "FunctionBar.h"
|
|
||||||
|
|
||||||
typedef struct OpenFiles_Data_ {
|
typedef struct OpenFiles_Data_ {
|
||||||
char* data[256];
|
char* data[256];
|
||||||
|
@ -32,7 +31,6 @@ typedef struct OpenFilesScreen_ {
|
||||||
Process* process;
|
Process* process;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
Panel* display;
|
Panel* display;
|
||||||
FunctionBar* bar;
|
|
||||||
} OpenFilesScreen;
|
} OpenFilesScreen;
|
||||||
|
|
||||||
|
|
||||||
|
|
12
Panel.c
12
Panel.c
|
@ -24,6 +24,7 @@ in the source distribution for its full text.
|
||||||
/*{
|
/*{
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "Vector.h"
|
#include "Vector.h"
|
||||||
|
#include "FunctionBar.h"
|
||||||
|
|
||||||
typedef struct Panel_ Panel;
|
typedef struct Panel_ Panel;
|
||||||
|
|
||||||
|
@ -61,6 +62,8 @@ struct Panel_ {
|
||||||
int scrollV;
|
int scrollV;
|
||||||
short scrollH;
|
short scrollH;
|
||||||
bool needsRedraw;
|
bool needsRedraw;
|
||||||
|
FunctionBar* currentBar;
|
||||||
|
FunctionBar* defaultBar;
|
||||||
RichString header;
|
RichString header;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -86,11 +89,11 @@ PanelClass Panel_class = {
|
||||||
.eventHandler = Panel_selectByTyping
|
.eventHandler = Panel_selectByTyping
|
||||||
};
|
};
|
||||||
|
|
||||||
Panel* Panel_new(int x, int y, int w, int h, bool owner, ObjectClass* type) {
|
Panel* Panel_new(int x, int y, int w, int h, bool owner, ObjectClass* type, FunctionBar* fuBar) {
|
||||||
Panel* this;
|
Panel* this;
|
||||||
this = malloc(sizeof(Panel));
|
this = malloc(sizeof(Panel));
|
||||||
Object_setClass(this, Class(Panel));
|
Object_setClass(this, Class(Panel));
|
||||||
Panel_init(this, x, y, w, h, type, owner);
|
Panel_init(this, x, y, w, h, type, owner, fuBar);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +103,7 @@ void Panel_delete(Object* cast) {
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Panel_init(Panel* this, int x, int y, int w, int h, ObjectClass* type, bool owner) {
|
void Panel_init(Panel* this, int x, int y, int w, int h, ObjectClass* type, bool owner, FunctionBar* fuBar) {
|
||||||
this->x = x;
|
this->x = x;
|
||||||
this->y = y;
|
this->y = y;
|
||||||
this->w = w;
|
this->w = w;
|
||||||
|
@ -113,12 +116,15 @@ void Panel_init(Panel* this, int x, int y, int w, int h, ObjectClass* type, bool
|
||||||
this->oldSelected = 0;
|
this->oldSelected = 0;
|
||||||
this->needsRedraw = true;
|
this->needsRedraw = true;
|
||||||
RichString_beginAllocated(this->header);
|
RichString_beginAllocated(this->header);
|
||||||
|
this->defaultBar = fuBar;
|
||||||
|
this->currentBar = fuBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Panel_done(Panel* this) {
|
void Panel_done(Panel* this) {
|
||||||
assert (this != NULL);
|
assert (this != NULL);
|
||||||
free(this->eventHandlerState);
|
free(this->eventHandlerState);
|
||||||
Vector_delete(this->items);
|
Vector_delete(this->items);
|
||||||
|
FunctionBar_delete(this->defaultBar);
|
||||||
RichString_end(this->header);
|
RichString_end(this->header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
7
Panel.h
7
Panel.h
|
@ -13,6 +13,7 @@ in the source distribution for its full text.
|
||||||
|
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "Vector.h"
|
#include "Vector.h"
|
||||||
|
#include "FunctionBar.h"
|
||||||
|
|
||||||
typedef struct Panel_ Panel;
|
typedef struct Panel_ Panel;
|
||||||
|
|
||||||
|
@ -50,6 +51,8 @@ struct Panel_ {
|
||||||
int scrollV;
|
int scrollV;
|
||||||
short scrollH;
|
short scrollH;
|
||||||
bool needsRedraw;
|
bool needsRedraw;
|
||||||
|
FunctionBar* currentBar;
|
||||||
|
FunctionBar* defaultBar;
|
||||||
RichString header;
|
RichString header;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,11 +71,11 @@ struct Panel_ {
|
||||||
|
|
||||||
extern PanelClass Panel_class;
|
extern PanelClass Panel_class;
|
||||||
|
|
||||||
Panel* Panel_new(int x, int y, int w, int h, bool owner, ObjectClass* type);
|
Panel* Panel_new(int x, int y, int w, int h, bool owner, ObjectClass* type, FunctionBar* fuBar);
|
||||||
|
|
||||||
void Panel_delete(Object* cast);
|
void Panel_delete(Object* cast);
|
||||||
|
|
||||||
void Panel_init(Panel* this, int x, int y, int w, int h, ObjectClass* type, bool owner);
|
void Panel_init(Panel* this, int x, int y, int w, int h, ObjectClass* type, bool owner, FunctionBar* fuBar);
|
||||||
|
|
||||||
void Panel_done(Panel* this);
|
void Panel_done(Panel* this);
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,7 @@ typedef struct ScreenManager_ {
|
||||||
int y2;
|
int y2;
|
||||||
Orientation orientation;
|
Orientation orientation;
|
||||||
Vector* panels;
|
Vector* panels;
|
||||||
Vector* fuBars;
|
|
||||||
int panelCount;
|
int panelCount;
|
||||||
const FunctionBar* fuBar;
|
|
||||||
const Header* header;
|
const Header* header;
|
||||||
const Settings* settings;
|
const Settings* settings;
|
||||||
bool owner;
|
bool owner;
|
||||||
|
@ -52,10 +50,8 @@ ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation ori
|
||||||
this->y1 = y1;
|
this->y1 = y1;
|
||||||
this->x2 = x2;
|
this->x2 = x2;
|
||||||
this->y2 = y2;
|
this->y2 = y2;
|
||||||
this->fuBar = NULL;
|
|
||||||
this->orientation = orientation;
|
this->orientation = orientation;
|
||||||
this->panels = Vector_new(Class(Panel), owner, DEFAULT_SIZE);
|
this->panels = Vector_new(Class(Panel), owner, DEFAULT_SIZE);
|
||||||
this->fuBars = Vector_new(Class(FunctionBar), true, DEFAULT_SIZE);
|
|
||||||
this->panelCount = 0;
|
this->panelCount = 0;
|
||||||
this->header = header;
|
this->header = header;
|
||||||
this->settings = settings;
|
this->settings = settings;
|
||||||
|
@ -66,7 +62,6 @@ ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation ori
|
||||||
|
|
||||||
void ScreenManager_delete(ScreenManager* this) {
|
void ScreenManager_delete(ScreenManager* this) {
|
||||||
Vector_delete(this->panels);
|
Vector_delete(this->panels);
|
||||||
Vector_delete(this->fuBars);
|
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +69,7 @@ inline int ScreenManager_size(ScreenManager* this) {
|
||||||
return this->panelCount;
|
return this->panelCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int size) {
|
void ScreenManager_add(ScreenManager* this, Panel* item, int size) {
|
||||||
if (this->orientation == HORIZONTAL) {
|
if (this->orientation == HORIZONTAL) {
|
||||||
int lastX = 0;
|
int lastX = 0;
|
||||||
if (this->panelCount > 0) {
|
if (this->panelCount > 0) {
|
||||||
|
@ -91,11 +86,6 @@ void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int
|
||||||
}
|
}
|
||||||
// TODO: VERTICAL
|
// TODO: VERTICAL
|
||||||
Vector_add(this->panels, item);
|
Vector_add(this->panels, item);
|
||||||
if (fuBar)
|
|
||||||
Vector_add(this->fuBars, fuBar);
|
|
||||||
else
|
|
||||||
Vector_add(this->fuBars, FunctionBar_new(NULL, NULL, NULL));
|
|
||||||
if (!this->fuBar && fuBar) this->fuBar = fuBar;
|
|
||||||
item->needsRedraw = true;
|
item->needsRedraw = true;
|
||||||
this->panelCount++;
|
this->panelCount++;
|
||||||
}
|
}
|
||||||
|
@ -103,8 +93,6 @@ void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int
|
||||||
Panel* ScreenManager_remove(ScreenManager* this, int idx) {
|
Panel* ScreenManager_remove(ScreenManager* this, int idx) {
|
||||||
assert(this->panelCount > idx);
|
assert(this->panelCount > idx);
|
||||||
Panel* panel = (Panel*) Vector_remove(this->panels, idx);
|
Panel* panel = (Panel*) Vector_remove(this->panels, idx);
|
||||||
Vector_remove(this->fuBars, idx);
|
|
||||||
this->fuBar = NULL;
|
|
||||||
this->panelCount--;
|
this->panelCount--;
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
@ -173,8 +161,6 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||||
int focus = 0;
|
int focus = 0;
|
||||||
|
|
||||||
Panel* panelFocus = (Panel*) Vector_get(this->panels, focus);
|
Panel* panelFocus = (Panel*) Vector_get(this->panels, focus);
|
||||||
if (this->fuBar)
|
|
||||||
FunctionBar_draw(this->fuBar, NULL);
|
|
||||||
|
|
||||||
double oldTime = 0.0;
|
double oldTime = 0.0;
|
||||||
|
|
||||||
|
@ -194,11 +180,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||||
|
|
||||||
if (redraw) {
|
if (redraw) {
|
||||||
ScreenManager_drawPanels(this, focus);
|
ScreenManager_drawPanels(this, focus);
|
||||||
FunctionBar* bar = (FunctionBar*) Vector_get(this->fuBars, focus);
|
FunctionBar_draw(panelFocus->currentBar, NULL);
|
||||||
if (bar)
|
|
||||||
this->fuBar = bar;
|
|
||||||
if (this->fuBar)
|
|
||||||
FunctionBar_draw(this->fuBar, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int prevCh = ch;
|
int prevCh = ch;
|
||||||
|
@ -209,7 +191,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||||
int ok = getmouse(&mevent);
|
int ok = getmouse(&mevent);
|
||||||
if (ok == OK) {
|
if (ok == OK) {
|
||||||
if (mevent.y == LINES - 1) {
|
if (mevent.y == LINES - 1) {
|
||||||
ch = FunctionBar_synthesizeEvent(this->fuBar, mevent.x);
|
ch = FunctionBar_synthesizeEvent(panelFocus->currentBar, mevent.x);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < this->panelCount; i++) {
|
for (int i = 0; i < this->panelCount; i++) {
|
||||||
Panel* panel = (Panel*) Vector_get(this->panels, i);
|
Panel* panel = (Panel*) Vector_get(this->panels, i);
|
||||||
|
|
|
@ -27,9 +27,7 @@ typedef struct ScreenManager_ {
|
||||||
int y2;
|
int y2;
|
||||||
Orientation orientation;
|
Orientation orientation;
|
||||||
Vector* panels;
|
Vector* panels;
|
||||||
Vector* fuBars;
|
|
||||||
int panelCount;
|
int panelCount;
|
||||||
const FunctionBar* fuBar;
|
|
||||||
const Header* header;
|
const Header* header;
|
||||||
const Settings* settings;
|
const Settings* settings;
|
||||||
bool owner;
|
bool owner;
|
||||||
|
@ -43,7 +41,7 @@ void ScreenManager_delete(ScreenManager* this);
|
||||||
|
|
||||||
extern int ScreenManager_size(ScreenManager* this);
|
extern int ScreenManager_size(ScreenManager* this);
|
||||||
|
|
||||||
void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int size);
|
void ScreenManager_add(ScreenManager* this, Panel* item, int size);
|
||||||
|
|
||||||
Panel* ScreenManager_remove(ScreenManager* this, int idx);
|
Panel* ScreenManager_remove(ScreenManager* this, int idx);
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,12 @@ static SignalItem signals[] = {
|
||||||
{ .name = "31 SIGSYS", .number = 31 },
|
{ .name = "31 SIGSYS", .number = 31 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char* SignalsFunctions[] = {"Send ", "Cancel ", NULL};
|
||||||
|
static const char* SignalsKeys[] = {"Enter", "Esc", NULL};
|
||||||
|
static int SignalsEvents[] = {13, 27};
|
||||||
|
|
||||||
Panel* SignalsPanel_new() {
|
Panel* SignalsPanel_new() {
|
||||||
Panel* this = Panel_new(1, 1, 1, 1, true, Class(ListItem));
|
Panel* this = Panel_new(1, 1, 1, 1, true, Class(ListItem), FunctionBar_new(SignalsFunctions, SignalsKeys, SignalsEvents));
|
||||||
for(unsigned int i = 0; i < sizeof(signals)/sizeof(SignalItem); i++)
|
for(unsigned int i = 0; i < sizeof(signals)/sizeof(SignalItem); i++)
|
||||||
Panel_set(this, i, (Object*) ListItem_new(signals[i].name, signals[i].number));
|
Panel_set(this, i, (Object*) ListItem_new(signals[i].name, signals[i].number));
|
||||||
Panel_setHeader(this, "Send signal:");
|
Panel_setHeader(this, "Send signal:");
|
||||||
|
|
|
@ -12,6 +12,7 @@ in the source distribution for its full text.
|
||||||
#include "ListItem.h"
|
#include "ListItem.h"
|
||||||
#include "IncSet.h"
|
#include "IncSet.h"
|
||||||
#include "String.h"
|
#include "String.h"
|
||||||
|
#include "FunctionBar.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -27,7 +28,6 @@ in the source distribution for its full text.
|
||||||
/*{
|
/*{
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
#include "FunctionBar.h"
|
|
||||||
|
|
||||||
typedef struct TraceScreen_ {
|
typedef struct TraceScreen_ {
|
||||||
Process* process;
|
Process* process;
|
||||||
|
@ -37,16 +37,17 @@ typedef struct TraceScreen_ {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
static const char* tsFunctions[] = {"Search ", "Filter ", "AutoScroll ", "Stop Tracing ", "Done ", NULL};
|
static const char* TraceScreenFunctions[] = {"Search ", "Filter ", "AutoScroll ", "Stop Tracing ", "Done ", NULL};
|
||||||
|
|
||||||
static const char* tsKeys[] = {"F3", "F4", "F8", "F9", "Esc"};
|
static const char* TraceScreenKeys[] = {"F3", "F4", "F8", "F9", "Esc"};
|
||||||
|
|
||||||
static int tsEvents[] = {KEY_F(3), KEY_F(4), KEY_F(8), KEY_F(9), 27};
|
static int TraceScreenEvents[] = {KEY_F(3), KEY_F(4), KEY_F(8), KEY_F(9), 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 = Panel_new(0, 1, COLS, LINES-2, false, Class(ListItem));
|
FunctionBar* fuBar = FunctionBar_new(TraceScreenFunctions, TraceScreenKeys, TraceScreenEvents);
|
||||||
|
this->display = Panel_new(0, 1, COLS, LINES-2, false, Class(ListItem), fuBar);
|
||||||
this->tracing = true;
|
this->tracing = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +106,7 @@ void TraceScreen_run(TraceScreen* this) {
|
||||||
bool follow = false;
|
bool follow = false;
|
||||||
bool looping = true;
|
bool looping = true;
|
||||||
|
|
||||||
FunctionBar* bar = FunctionBar_new(tsFunctions, tsKeys, tsEvents);
|
FunctionBar* bar = panel->defaultBar;
|
||||||
IncSet* inc = IncSet_new(bar);
|
IncSet* inc = IncSet_new(bar);
|
||||||
|
|
||||||
Vector* lines = Vector_new(panel->items->type, true, DEFAULT_SIZE);
|
Vector* lines = Vector_new(panel->items->type, true, DEFAULT_SIZE);
|
||||||
|
@ -219,7 +220,6 @@ void TraceScreen_run(TraceScreen* this) {
|
||||||
}
|
}
|
||||||
|
|
||||||
IncSet_delete(inc);
|
IncSet_delete(inc);
|
||||||
FunctionBar_delete((Object*)bar);
|
|
||||||
Vector_delete(lines);
|
Vector_delete(lines);
|
||||||
|
|
||||||
kill(child, SIGTERM);
|
kill(child, SIGTERM);
|
||||||
|
|
|
@ -11,7 +11,6 @@ in the source distribution for its full text.
|
||||||
|
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
#include "FunctionBar.h"
|
|
||||||
|
|
||||||
typedef struct TraceScreen_ {
|
typedef struct TraceScreen_ {
|
||||||
Process* process;
|
Process* process;
|
||||||
|
|
10
htop.c
10
htop.c
|
@ -35,8 +35,6 @@ static void printVersionFlag() {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* defaultFunctions[] = {"Help ", "Setup ", "Search", "Filter", "Tree ", "SortBy", "Nice -", "Nice +", "Kill ", "Quit ", NULL};
|
|
||||||
|
|
||||||
static void printHelpFlag() {
|
static void printHelpFlag() {
|
||||||
fputs("htop " VERSION " - " COPYRIGHT "\n"
|
fputs("htop " VERSION " - " COPYRIGHT "\n"
|
||||||
"Released under the GNU GPL.\n\n"
|
"Released under the GNU GPL.\n\n"
|
||||||
|
@ -219,12 +217,10 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
CRT_init(settings->delay, settings->colorScheme);
|
CRT_init(settings->delay, settings->colorScheme);
|
||||||
|
|
||||||
FunctionBar* defaultBar = FunctionBar_new(defaultFunctions, NULL, NULL);
|
MainPanel* panel = MainPanel_new();
|
||||||
|
|
||||||
MainPanel* panel = MainPanel_new(defaultBar);
|
|
||||||
ProcessList_setPanel(pl, (Panel*) panel);
|
ProcessList_setPanel(pl, (Panel*) panel);
|
||||||
|
|
||||||
MainPanel_updateTreeFunctions(defaultBar, settings->treeView);
|
MainPanel_updateTreeFunctions(panel, settings->treeView);
|
||||||
|
|
||||||
if (flags.sortKey > 0) {
|
if (flags.sortKey > 0) {
|
||||||
settings->sortKey = flags.sortKey;
|
settings->sortKey = flags.sortKey;
|
||||||
|
@ -243,7 +239,7 @@ int main(int argc, char** argv) {
|
||||||
MainPanel_setState(panel, &state);
|
MainPanel_setState(panel, &state);
|
||||||
|
|
||||||
ScreenManager* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, true);
|
ScreenManager* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, true);
|
||||||
ScreenManager_add(scr, (Panel*) panel, defaultBar, -1);
|
ScreenManager_add(scr, (Panel*) panel, -1);
|
||||||
|
|
||||||
ProcessList_scan(pl);
|
ProcessList_scan(pl);
|
||||||
millisleep(75);
|
millisleep(75);
|
||||||
|
|
|
@ -13,8 +13,13 @@ in the source distribution for its full text.
|
||||||
#include "ListItem.h"
|
#include "ListItem.h"
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
static const char* IOPriorityFunctions[] = {"Set ", "Cancel ", NULL};
|
||||||
|
static const char* IOPriorityKeys[] = {"Enter", "Esc", NULL};
|
||||||
|
static int IOPriorityEvents[] = {13, 27};
|
||||||
|
|
||||||
Panel* IOPriorityPanel_new(IOPriority currPrio) {
|
Panel* IOPriorityPanel_new(IOPriority currPrio) {
|
||||||
Panel* this = Panel_new(1, 1, 1, 1, true, Class(ListItem));
|
FunctionBar* fuBar = FunctionBar_new(IOPriorityFunctions, IOPriorityKeys, IOPriorityEvents);
|
||||||
|
Panel* this = Panel_new(1, 1, 1, 1, true, Class(ListItem), fuBar);
|
||||||
|
|
||||||
Panel_setHeader(this, "IO Priority:");
|
Panel_setHeader(this, "IO Priority:");
|
||||||
Panel_add(this, (Object*) ListItem_new("None (based on nice)", IOPriority_None));
|
Panel_add(this, (Object*) ListItem_new("None (based on nice)", IOPriority_None));
|
||||||
|
|
|
@ -46,8 +46,7 @@ static Htop_Reaction Platform_actionSetIOPriority(State* st) {
|
||||||
if (!p) return HTOP_OK;
|
if (!p) return HTOP_OK;
|
||||||
IOPriority ioprio = p->ioPriority;
|
IOPriority ioprio = p->ioPriority;
|
||||||
Panel* ioprioPanel = IOPriorityPanel_new(ioprio);
|
Panel* ioprioPanel = IOPriorityPanel_new(ioprio);
|
||||||
const char* fuFunctions[] = {"Set ", "Cancel ", NULL};
|
void* set = Action_pickFromVector(st, ioprioPanel, 21);
|
||||||
void* set = Action_pickFromVector(st, ioprioPanel, 21, fuFunctions);
|
|
||||||
if (set) {
|
if (set) {
|
||||||
IOPriority ioprio = IOPriorityPanel_getIOPriority(ioprioPanel);
|
IOPriority ioprio = IOPriorityPanel_getIOPriority(ioprioPanel);
|
||||||
bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) LinuxProcess_setIOPriority, (size_t) ioprio, NULL);
|
bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) LinuxProcess_setIOPriority, (size_t) ioprio, NULL);
|
||||||
|
|
Loading…
Reference in New Issue