blob: a84407e50a9cd052089f333334d92d1ea0af4b84 [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 Lange94ad1112021-09-22 11:33:00 +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
mayurdahibhate1b74dfe2021-04-29 20:42:43 +053017
Daniel Langea5c46502023-03-29 10:43:58 +020018#define INCMODE_MAX 128
Hisham Muhammad2a734052012-11-10 00:31:37 +000019
20typedef enum {
21 INC_SEARCH = 0,
22 INC_FILTER = 1
23} IncType;
24
Hisham Muhammad2a734052012-11-10 00:31:37 +000025typedef struct IncMode_ {
Benny Baumann61e14d42020-10-31 23:28:02 +010026 char buffer[INCMODE_MAX + 1];
Hisham Muhammad2a734052012-11-10 00:31:37 +000027 int index;
28 FunctionBar* bar;
29 bool isFilter;
30} IncMode;
31
32typedef struct IncSet_ {
33 IncMode modes[2];
34 IncMode* active;
Hisham Muhammad72ba20f2021-08-31 15:38:52 +100035 Panel* panel;
Hisham Muhammad2a734052012-11-10 00:31:37 +000036 FunctionBar* defaultBar;
37 bool filtering;
Hisham572546f2016-05-05 10:30:06 -030038 bool found;
Hisham Muhammad2a734052012-11-10 00:31:37 +000039} IncSet;
40
Christian Göttsche6b3dbd52020-10-27 21:26:37 +010041static inline const char* IncSet_filter(const IncSet* this) {
42 return this->filtering ? this->modes[INC_FILTER].buffer : NULL;
43}
44
Christian Göttsche958112c2021-01-05 14:45:12 +010045void IncSet_setFilter(IncSet* this, const char* filter);
46
Hisham Muhammad2a734052012-11-10 00:31:37 +000047typedef const char* (*IncMode_GetPanelValue)(Panel*, int);
48
Zev Weiss7b7822b2020-09-02 02:38:44 -050049void IncSet_reset(IncSet* this, IncType type);
syrrim8d7afb32018-11-03 15:59:55 -040050
Zev Weiss7b7822b2020-09-02 02:38:44 -050051IncSet* IncSet_new(FunctionBar* bar);
Hisham Muhammad2a734052012-11-10 00:31:37 +000052
Zev Weiss7b7822b2020-09-02 02:38:44 -050053void IncSet_delete(IncSet* this);
Hisham Muhammad2a734052012-11-10 00:31:37 +000054
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
Hisham Muhammad72ba20f2021-08-31 15:38:52 +100061void IncSet_drawBar(const IncSet* this, int attr);
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