Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 1084a3f

Browse files
committed
Working on integration of IncSet in new branch.
1 parent 09c7152 commit 1084a3f

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

Action.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ typedef enum {
5252
typedef Htop_Reaction (*Htop_Action)();
5353
5454
typedef struct State_ {
55-
IncSet* inc;
5655
Settings* settings;
5756
UsersTable* ut;
5857
ProcessList* pl;
@@ -225,12 +224,14 @@ static Htop_Reaction actionToggleTreeView(State* st) {
225224
}
226225

227226
static Htop_Reaction actionIncFilter(State* st) {
228-
IncSet_activate(st->inc, INC_FILTER);
227+
IncSet* inc = ((MainPanel*)st->panel)->inc;
228+
IncSet_activate(inc, INC_FILTER);
229+
st->pl->incFilter = IncSet_filter(inc);
229230
return HTOP_REFRESH | HTOP_KEEP_FOLLOWING;
230231
}
231232

232233
static Htop_Reaction actionIncSearch(State* st) {
233-
IncSet_activate(st->inc, INC_SEARCH);
234+
IncSet_activate(((MainPanel*)st->panel)->inc, INC_SEARCH);
234235
return HTOP_REFRESH | HTOP_KEEP_FOLLOWING;
235236
}
236237

Action.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ typedef enum {
3131
typedef Htop_Reaction (*Htop_Action)();
3232

3333
typedef struct State_ {
34-
IncSet* inc;
3534
Settings* settings;
3635
UsersTable* ut;
3736
ProcessList* pl;

MainPanel.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ in the source distribution for its full text.
2020
typedef struct MainPanel_ {
2121
Panel super;
2222
State* state;
23+
IncSet* inc;
2324
FunctionBar* fuBar;
2425
Htop_Action *keys;
2526
pid_t pidSearch;
@@ -65,7 +66,13 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
6566
if (ch == 27) {
6667
return HANDLED;
6768
}
68-
if(ch != ERR && this->keys[ch]) {
69+
if (ch != ERR && this->inc->active) {
70+
bool redraw = IncSet_handleKey(this->inc, ch, super, (IncMode_GetPanelValue) MainPanel_getValue, NULL);
71+
if (redraw) {
72+
reaction = HTOP_REFRESH | HTOP_REDRAW_BAR;
73+
}
74+
reaction |= HTOP_KEEP_FOLLOWING;
75+
} else if (ch != ERR && this->keys[ch]) {
6976
reaction |= (this->keys[ch])(this->state);
7077
result = HANDLED;
7178
} else if (isdigit(ch)) {
@@ -92,7 +99,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
9299

93100
if (reaction & HTOP_REDRAW_BAR) {
94101
MainPanel_updateTreeFunctions(this->fuBar, this->state->settings->treeView);
95-
IncSet_drawBar(this->state->inc);
102+
IncSet_drawBar(this->inc);
96103
}
97104
if (reaction & HTOP_UPDATE_PANELHDR) {
98105
ProcessList_printHeader(this->state->pl, Panel_getHeader(super));
@@ -163,6 +170,7 @@ MainPanel* MainPanel_new(FunctionBar* fuBar) {
163170
Panel_init((Panel*) this, 1, 1, 1, 1, Class(Process), false);
164171
this->keys = calloc(KEY_MAX, sizeof(Htop_Action));
165172
this->fuBar = fuBar;
173+
this->inc = IncSet_new(fuBar);
166174

167175
Action_setBindings(this->keys);
168176
Platform_setBindings(this->keys);
@@ -178,6 +186,7 @@ void MainPanel_delete(Object* object) {
178186
Panel* super = (Panel*) object;
179187
MainPanel* this = (MainPanel*) object;
180188
Panel_done(super);
189+
IncSet_delete(this->inc);
181190
free(this->keys);
182191
free(this);
183192
}

MainPanel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ in the source distribution for its full text.
1616
typedef struct MainPanel_ {
1717
Panel super;
1818
State* state;
19+
IncSet* inc;
1920
FunctionBar* fuBar;
2021
Htop_Action *keys;
2122
pid_t pidSearch;

ScreenManager.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
149149
*redraw = true;
150150
}
151151
if (*redraw) {
152-
//pl->incFilter = IncSet_filter(inc);
153152
ProcessList_rebuildPanel(pl);
154153
Header_draw(this->header);
155154
}
@@ -195,13 +194,12 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
195194

196195
if (redraw) {
197196
ScreenManager_drawPanels(this, focus);
197+
FunctionBar* bar = (FunctionBar*) Vector_get(this->fuBars, focus);
198+
if (bar)
199+
this->fuBar = bar;
200+
if (this->fuBar)
201+
FunctionBar_draw(this->fuBar, NULL);
198202
}
199-
200-
FunctionBar* bar = (FunctionBar*) Vector_get(this->fuBars, focus);
201-
if (bar)
202-
this->fuBar = bar;
203-
if (this->fuBar)
204-
FunctionBar_draw(this->fuBar, NULL);
205203

206204
int prevCh = ch;
207205
ch = getch();

htop.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,7 @@ int main(int argc, char** argv) {
233233
}
234234
ProcessList_printHeader(pl, Panel_getHeader((Panel*)panel));
235235

236-
IncSet* inc = IncSet_new(defaultBar);
237-
238236
State state = {
239-
.inc = inc,
240237
.settings = settings,
241238
.ut = ut,
242239
.pl = pl,
@@ -460,7 +457,6 @@ int main(int argc, char** argv) {
460457

461458
ScreenManager_delete(scr);
462459

463-
IncSet_delete(inc);
464460
UsersTable_delete(ut);
465461
Settings_delete(settings);
466462

0 commit comments

Comments
 (0)