Skip to content

Commit

Permalink
Merge branch 'improve-filter-label' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Lange authored and Daniel Lange committed Apr 14, 2022
2 parents df955c8 + c6f946e commit 99aa906
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CommandLine.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ int CommandLine_run(const char* name, int argc, char** argv) {
MainPanel* panel = MainPanel_new();
ProcessList_setPanel(pl, (Panel*) panel);

MainPanel_updateTreeFunctions(panel, settings->ss->treeView);
MainPanel_updateLabels(panel, settings->ss->treeView, flags.commFilter);

State state = {
.settings = settings,
Expand Down
7 changes: 4 additions & 3 deletions MainPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ in the source distribution for its full text.
static const char* const MainFunctions[] = {"Help ", "Setup ", "Search", "Filter", "Tree ", "SortBy", "Nice -", "Nice +", "Kill ", "Quit ", NULL};
static const char* const MainFunctions_ro[] = {"Help ", "Setup ", "Search", "Filter", "Tree ", "SortBy", " ", " ", " ", "Quit ", NULL};

void MainPanel_updateTreeFunctions(MainPanel* this, bool mode) {
void MainPanel_updateLabels(MainPanel* this, bool list, bool filter) {
FunctionBar* bar = MainPanel_getFunctionBar(this);
FunctionBar_setLabel(bar, KEY_F(5), mode ? "List " : "Tree ");
FunctionBar_setLabel(bar, KEY_F(5), list ? "List " : "Tree ");
FunctionBar_setLabel(bar, KEY_F(4), filter ? "FILTER" : "Filter");
}

static void MainPanel_pidSearch(MainPanel* this, int ch) {
Expand Down Expand Up @@ -122,7 +123,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
}

if (reaction & HTOP_REDRAW_BAR) {
MainPanel_updateTreeFunctions(this, settings->ss->treeView);
MainPanel_updateLabels(this, settings->ss->treeView, this->state->pl->incFilter);
}
if (reaction & HTOP_RESIZE) {
result |= RESIZE;
Expand Down
3 changes: 2 additions & 1 deletion MainPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ typedef bool(*MainPanel_ForeachProcessFn)(Process*, Arg);

#define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar)

void MainPanel_updateTreeFunctions(MainPanel* this, bool mode);
// update the Label Keys in the MainPanel bar, list: list / tree mode, filter: filter (inc) active / inactive
void MainPanel_updateLabels(MainPanel* this, bool list, bool filter);

int MainPanel_selectedPid(MainPanel* this);

Expand Down

0 comments on commit 99aa906

Please sign in to comment.