mirror of https://github.com/xzeldon/htop.git
Make clicks on leftmost panel in the Setup screen change setup pages,
like the keyboard navigation does. Fixes bug reported by Tero Keinanen. https://sourceforge.net/tracker/index.php?func=detail&aid=1754735&group_id=108839&atid=651633
This commit is contained in:
parent
062433fe04
commit
5ed2b85c84
|
@ -64,37 +64,43 @@ HandlerResult CategoriesPanel_eventHandler(Panel* super, int ch) {
|
||||||
|
|
||||||
HandlerResult result = IGNORED;
|
HandlerResult result = IGNORED;
|
||||||
|
|
||||||
int previous = Panel_getSelectedIndex(super);
|
int selected = Panel_getSelectedIndex(super);
|
||||||
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
case EVENT_SETSELECTED:
|
||||||
|
result = HANDLED;
|
||||||
|
break;
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
case KEY_DOWN:
|
case KEY_DOWN:
|
||||||
case KEY_NPAGE:
|
case KEY_NPAGE:
|
||||||
case KEY_PPAGE:
|
case KEY_PPAGE:
|
||||||
case KEY_HOME:
|
case KEY_HOME:
|
||||||
case KEY_END: {
|
case KEY_END: {
|
||||||
|
int previous = selected;
|
||||||
Panel_onKey(super, ch);
|
Panel_onKey(super, ch);
|
||||||
int selected = Panel_getSelectedIndex(super);
|
selected = Panel_getSelectedIndex(super);
|
||||||
if (previous != selected) {
|
if (previous != selected)
|
||||||
int size = ScreenManager_size(this->scr);
|
result = HANDLED;
|
||||||
for (int i = 1; i < size; i++)
|
break;
|
||||||
ScreenManager_remove(this->scr, 1);
|
}
|
||||||
switch (selected) {
|
}
|
||||||
case 0:
|
|
||||||
CategoriesPanel_makeMetersPage(this);
|
if (result == HANDLED) {
|
||||||
break;
|
int size = ScreenManager_size(this->scr);
|
||||||
case 1:
|
for (int i = 1; i < size; i++)
|
||||||
CategoriesPanel_makeDisplayOptionsPage(this);
|
ScreenManager_remove(this->scr, 1);
|
||||||
break;
|
switch (selected) {
|
||||||
case 2:
|
case 0:
|
||||||
CategoriesPanel_makeColorsPage(this);
|
CategoriesPanel_makeMetersPage(this);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 1:
|
||||||
CategoriesPanel_makeColumnsPage(this);
|
CategoriesPanel_makeDisplayOptionsPage(this);
|
||||||
break;
|
break;
|
||||||
}
|
case 2:
|
||||||
}
|
CategoriesPanel_makeColorsPage(this);
|
||||||
result = HANDLED;
|
break;
|
||||||
|
case 3:
|
||||||
|
CategoriesPanel_makeColumnsPage(this);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
Panel.c
5
Panel.c
|
@ -31,6 +31,8 @@ typedef enum HandlerResult_ {
|
||||||
BREAK_LOOP
|
BREAK_LOOP
|
||||||
} HandlerResult;
|
} HandlerResult;
|
||||||
|
|
||||||
|
#define EVENT_SETSELECTED -1
|
||||||
|
|
||||||
typedef HandlerResult(*Panel_EventHandler)(Panel*, int);
|
typedef HandlerResult(*Panel_EventHandler)(Panel*, int);
|
||||||
|
|
||||||
struct Panel_ {
|
struct Panel_ {
|
||||||
|
@ -222,6 +224,9 @@ void Panel_setSelected(Panel* this, int selected) {
|
||||||
|
|
||||||
selected = MAX(0, MIN(Vector_size(this->items) - 1, selected));
|
selected = MAX(0, MIN(Vector_size(this->items) - 1, selected));
|
||||||
this->selected = selected;
|
this->selected = selected;
|
||||||
|
if (this->eventHandler) {
|
||||||
|
this->eventHandler(this, EVENT_SETSELECTED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Panel_draw(Panel* this, bool focus) {
|
void Panel_draw(Panel* this, bool focus) {
|
||||||
|
|
Loading…
Reference in New Issue