mirror of https://github.com/xzeldon/htop.git
parent
d464be13db
commit
572546f806
4
Action.c
4
Action.c
|
@ -328,7 +328,7 @@ static Htop_Reaction actionFilterByUser(State* st) {
|
|||
return HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
|
||||
}
|
||||
|
||||
static Htop_Reaction actionFollow(State* st) {
|
||||
Htop_Reaction Action_follow(State* st) {
|
||||
st->pl->following = MainPanel_selectedPid((MainPanel*)st->panel);
|
||||
Panel_setSelectionColor(st->panel, CRT_colors[PANEL_SELECTION_FOLLOW]);
|
||||
return HTOP_KEEP_FOLLOWING;
|
||||
|
@ -557,7 +557,7 @@ void Action_setBindings(Htop_Action* keys) {
|
|||
keys['='] = actionExpandOrCollapse;
|
||||
keys['-'] = actionExpandOrCollapse;
|
||||
keys['u'] = actionFilterByUser;
|
||||
keys['F'] = actionFollow;
|
||||
keys['F'] = Action_follow;
|
||||
keys['S'] = actionSetup;
|
||||
keys['C'] = actionSetup;
|
||||
keys[KEY_F(2)] = actionSetup;
|
||||
|
|
2
Action.h
2
Action.h
|
@ -49,6 +49,8 @@ Htop_Reaction Action_setSortKey(Settings* settings, ProcessField sortKey);
|
|||
|
||||
// ----------------------------------------
|
||||
|
||||
Htop_Reaction Action_follow(State* st);
|
||||
|
||||
|
||||
void Action_setBindings(Htop_Action* keys);
|
||||
|
||||
|
|
16
IncSet.c
16
IncSet.c
|
@ -40,6 +40,7 @@ typedef struct IncSet_ {
|
|||
IncMode* active;
|
||||
FunctionBar* defaultBar;
|
||||
bool filtering;
|
||||
bool found;
|
||||
} IncSet;
|
||||
|
||||
typedef const char* (*IncMode_GetPanelValue)(Panel*, int);
|
||||
|
@ -114,7 +115,7 @@ static void updateWeakPanel(IncSet* this, Panel* panel, Vector* lines) {
|
|||
}
|
||||
}
|
||||
|
||||
static void search(IncMode* mode, Panel* panel, IncMode_GetPanelValue getPanelValue) {
|
||||
static bool search(IncMode* mode, Panel* panel, IncMode_GetPanelValue getPanelValue) {
|
||||
int size = Panel_size(panel);
|
||||
bool found = false;
|
||||
for (int i = 0; i < size; i++) {
|
||||
|
@ -128,6 +129,7 @@ static void search(IncMode* mode, Panel* panel, IncMode_GetPanelValue getPanelVa
|
|||
FunctionBar_draw(mode->bar, mode->buffer);
|
||||
else
|
||||
FunctionBar_drawAttr(mode->bar, mode->buffer, CRT_colors[FAILED_SEARCH]);
|
||||
return found;
|
||||
}
|
||||
|
||||
bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue getPanelValue, Vector* lines) {
|
||||
|
@ -151,7 +153,8 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
|
|||
}
|
||||
}
|
||||
doSearch = false;
|
||||
} else if (ch < 255 && isprint((char)ch) && (mode->index < INCMODE_MAX)) {
|
||||
} else if (ch < 255 && isprint((char)ch)) {
|
||||
if (mode->index < INCMODE_MAX) {
|
||||
mode->buffer[mode->index] = ch;
|
||||
mode->index++;
|
||||
mode->buffer[mode->index] = 0;
|
||||
|
@ -159,7 +162,9 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
|
|||
filterChanged = true;
|
||||
if (mode->index == 1) this->filtering = true;
|
||||
}
|
||||
} else if ((ch == KEY_BACKSPACE || ch == 127) && (mode->index > 0)) {
|
||||
}
|
||||
} else if ((ch == KEY_BACKSPACE || ch == 127)) {
|
||||
if (mode->index > 0) {
|
||||
mode->index--;
|
||||
mode->buffer[mode->index] = 0;
|
||||
if (mode->isFilter) {
|
||||
|
@ -169,6 +174,9 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
|
|||
IncMode_reset(mode);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
doSearch = false;
|
||||
}
|
||||
} else if (ch == KEY_RESIZE) {
|
||||
Panel_resize(panel, COLS, LINES-panel->y-1);
|
||||
} else {
|
||||
|
@ -187,7 +195,7 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
|
|||
doSearch = false;
|
||||
}
|
||||
if (doSearch) {
|
||||
search(mode, panel, getPanelValue);
|
||||
this->found = search(mode, panel, getPanelValue);
|
||||
}
|
||||
if (filterChanged && lines) {
|
||||
updateWeakPanel(this, panel, lines);
|
||||
|
|
1
IncSet.h
1
IncSet.h
|
@ -35,6 +35,7 @@ typedef struct IncSet_ {
|
|||
IncMode* active;
|
||||
FunctionBar* defaultBar;
|
||||
bool filtering;
|
||||
bool found;
|
||||
} IncSet;
|
||||
|
||||
typedef const char* (*IncMode_GetPanelValue)(Panel*, int);
|
||||
|
|
|
@ -83,6 +83,9 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
|
|||
result = HANDLED;
|
||||
} else if (ch != ERR && this->inc->active) {
|
||||
bool filterChanged = IncSet_handleKey(this->inc, ch, super, (IncMode_GetPanelValue) MainPanel_getValue, NULL);
|
||||
if (this->inc->found) {
|
||||
reaction |= Action_follow(this->state);
|
||||
}
|
||||
if (filterChanged) {
|
||||
this->state->pl->incFilter = IncSet_filter(this->inc);
|
||||
reaction = HTOP_REFRESH | HTOP_REDRAW_BAR;
|
||||
|
|
Loading…
Reference in New Issue