| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 1 | #ifndef HEADER_IncSet |
| 2 | #define HEADER_IncSet |
| 3 | /* |
| 4 | htop - IncSet.h |
| 5 | (C) 2005-2012 Hisham H. Muhammad |
| Daniel Lange | 94ad111 | 2021-09-22 11:33:00 +0200 | [diff] [blame] | 6 | Released under the GNU GPLv2+, see the COPYING file |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 7 | in the source distribution for its full text. |
| 8 | */ |
| 9 | |
| Benny Baumann | e1c9687 | 2020-09-18 19:23:04 +0200 | [diff] [blame] | 10 | #include <stdbool.h> |
| Benny Baumann | 0f52629 | 2020-09-19 13:55:23 +0200 | [diff] [blame] | 11 | #include <stddef.h> |
| Benny Baumann | e1c9687 | 2020-09-18 19:23:04 +0200 | [diff] [blame] | 12 | |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 13 | #include "FunctionBar.h" |
| 14 | #include "Panel.h" |
| Benny Baumann | 0f52629 | 2020-09-19 13:55:23 +0200 | [diff] [blame] | 15 | #include "Vector.h" |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 16 | |
| mayurdahibhate | 1b74dfe | 2021-04-29 20:42:43 +0530 | [diff] [blame] | 17 | |
| Daniel Lange | a5c4650 | 2023-03-29 10:43:58 +0200 | [diff] [blame] | 18 | #define INCMODE_MAX 128 |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 19 | |
| 20 | typedef enum { |
| 21 | INC_SEARCH = 0, |
| 22 | INC_FILTER = 1 |
| 23 | } IncType; |
| 24 | |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 25 | typedef struct IncMode_ { |
| Benny Baumann | 61e14d4 | 2020-10-31 23:28:02 +0100 | [diff] [blame] | 26 | char buffer[INCMODE_MAX + 1]; |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 27 | int index; |
| 28 | FunctionBar* bar; |
| 29 | bool isFilter; |
| 30 | } IncMode; |
| 31 | |
| 32 | typedef struct IncSet_ { |
| 33 | IncMode modes[2]; |
| 34 | IncMode* active; |
| Hisham Muhammad | 72ba20f | 2021-08-31 15:38:52 +1000 | [diff] [blame] | 35 | Panel* panel; |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 36 | FunctionBar* defaultBar; |
| 37 | bool filtering; |
| Hisham | 572546f | 2016-05-05 10:30:06 -0300 | [diff] [blame] | 38 | bool found; |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 39 | } IncSet; |
| 40 | |
| Christian Göttsche | 6b3dbd5 | 2020-10-27 21:26:37 +0100 | [diff] [blame] | 41 | static inline const char* IncSet_filter(const IncSet* this) { |
| 42 | return this->filtering ? this->modes[INC_FILTER].buffer : NULL; |
| 43 | } |
| 44 | |
| Christian Göttsche | 958112c | 2021-01-05 14:45:12 +0100 | [diff] [blame] | 45 | void IncSet_setFilter(IncSet* this, const char* filter); |
| 46 | |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 47 | typedef const char* (*IncMode_GetPanelValue)(Panel*, int); |
| 48 | |
| Zev Weiss | 7b7822b | 2020-09-02 02:38:44 -0500 | [diff] [blame] | 49 | void IncSet_reset(IncSet* this, IncType type); |
| syrrim | 8d7afb3 | 2018-11-03 15:59:55 -0400 | [diff] [blame] | 50 | |
| Zev Weiss | 7b7822b | 2020-09-02 02:38:44 -0500 | [diff] [blame] | 51 | IncSet* IncSet_new(FunctionBar* bar); |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 52 | |
| Zev Weiss | 7b7822b | 2020-09-02 02:38:44 -0500 | [diff] [blame] | 53 | void IncSet_delete(IncSet* this); |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 54 | |
| Zev Weiss | 7b7822b | 2020-09-02 02:38:44 -0500 | [diff] [blame] | 55 | bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue getPanelValue, Vector* lines); |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 56 | |
| Zev Weiss | 7b7822b | 2020-09-02 02:38:44 -0500 | [diff] [blame] | 57 | const char* IncSet_getListItemValue(Panel* panel, int i); |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 58 | |
| Zev Weiss | 7b7822b | 2020-09-02 02:38:44 -0500 | [diff] [blame] | 59 | void IncSet_activate(IncSet* this, IncType type, Panel* panel); |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 60 | |
| Hisham Muhammad | 72ba20f | 2021-08-31 15:38:52 +1000 | [diff] [blame] | 61 | void IncSet_drawBar(const IncSet* this, int attr); |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 62 | |
| Zev Weiss | 7b7822b | 2020-09-02 02:38:44 -0500 | [diff] [blame] | 63 | int IncSet_synthesizeEvent(IncSet* this, int x); |
| Hisham Muhammad | ade7993 | 2015-03-23 17:04:53 -0300 | [diff] [blame] | 64 | |
| Hisham Muhammad | 2a73405 | 2012-11-10 00:31:37 +0000 | [diff] [blame] | 65 | #endif |