blob: b07840f7e980c049c9acb600aae609734ceaa751 [file] [log] [blame]
Hisham Muhammad2a734052012-11-10 00:31:37 +00001#ifndef HEADER_IncSet
2#define HEADER_IncSet
3/*
4htop - IncSet.h
5(C) 2005-2012 Hisham H. Muhammad
Daniel Lange079c2ab2020-10-05 09:51:32 +02006Released under the GNU GPLv2, see the COPYING file
Hisham Muhammad2a734052012-11-10 00:31:37 +00007in the source distribution for its full text.
8*/
9
Benny Baumanne1c96872020-09-18 19:23:04 +020010#include <stdbool.h>
Benny Baumann0f526292020-09-19 13:55:23 +020011#include <stddef.h>
Benny Baumanne1c96872020-09-18 19:23:04 +020012
Hisham Muhammad2a734052012-11-10 00:31:37 +000013#include "FunctionBar.h"
14#include "Panel.h"
Benny Baumann0f526292020-09-19 13:55:23 +020015#include "Vector.h"
Hisham Muhammad2a734052012-11-10 00:31:37 +000016
17#define INCMODE_MAX 40
18
19typedef enum {
20 INC_SEARCH = 0,
21 INC_FILTER = 1
22} IncType;
23
Hisham Muhammad2a734052012-11-10 00:31:37 +000024typedef struct IncMode_ {
Benny Baumann61e14d42020-10-31 23:28:02 +010025 char buffer[INCMODE_MAX + 1];
Hisham Muhammad2a734052012-11-10 00:31:37 +000026 int index;
27 FunctionBar* bar;
28 bool isFilter;
29} IncMode;
30
31typedef struct IncSet_ {
32 IncMode modes[2];
33 IncMode* active;
Hisham Muhammad2a734052012-11-10 00:31:37 +000034 FunctionBar* defaultBar;
35 bool filtering;
Hisham572546f2016-05-05 10:30:06 -030036 bool found;
Hisham Muhammad2a734052012-11-10 00:31:37 +000037} IncSet;
38
Christian Göttsche6b3dbd52020-10-27 21:26:37 +010039static inline const char* IncSet_filter(const IncSet* this) {
40 return this->filtering ? this->modes[INC_FILTER].buffer : NULL;
41}
42
Hisham Muhammad2a734052012-11-10 00:31:37 +000043typedef const char* (*IncMode_GetPanelValue)(Panel*, int);
44
Zev Weiss7b7822b2020-09-02 02:38:44 -050045void IncSet_reset(IncSet* this, IncType type);
syrrim8d7afb32018-11-03 15:59:55 -040046
Zev Weiss7b7822b2020-09-02 02:38:44 -050047IncSet* IncSet_new(FunctionBar* bar);
Hisham Muhammad2a734052012-11-10 00:31:37 +000048
Zev Weiss7b7822b2020-09-02 02:38:44 -050049void IncSet_delete(IncSet* this);
Hisham Muhammad2a734052012-11-10 00:31:37 +000050
Zev Weiss7b7822b2020-09-02 02:38:44 -050051bool IncSet_next(IncSet* this, IncType type, Panel* panel, IncMode_GetPanelValue getPanelValue);
syrrim8d7afb32018-11-03 15:59:55 -040052
Zev Weiss7b7822b2020-09-02 02:38:44 -050053bool IncSet_prev(IncSet* this, IncType type, Panel* panel, IncMode_GetPanelValue getPanelValue);
syrrim8d7afb32018-11-03 15:59:55 -040054
Zev Weiss7b7822b2020-09-02 02:38:44 -050055bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue getPanelValue, Vector* lines);
Hisham Muhammad2a734052012-11-10 00:31:37 +000056
Zev Weiss7b7822b2020-09-02 02:38:44 -050057const char* IncSet_getListItemValue(Panel* panel, int i);
Hisham Muhammad2a734052012-11-10 00:31:37 +000058
Zev Weiss7b7822b2020-09-02 02:38:44 -050059void IncSet_activate(IncSet* this, IncType type, Panel* panel);
Hisham Muhammad2a734052012-11-10 00:31:37 +000060
Christian Göttscheb47bc662020-10-05 15:14:54 +020061void IncSet_drawBar(const IncSet* this);
Hisham Muhammad2a734052012-11-10 00:31:37 +000062
Zev Weiss7b7822b2020-09-02 02:38:44 -050063int IncSet_synthesizeEvent(IncSet* this, int x);
Hisham Muhammadade79932015-03-23 17:04:53 -030064
Hisham Muhammad2a734052012-11-10 00:31:37 +000065#endif