diff options
author | Daniel Lange <DLange@git.local> | 2021-09-21 08:35:19 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2021-09-21 08:35:19 +0200 |
commit | 69f439eff387a6ecb52734e400b297a3c85f2285 (patch) | |
tree | 2a988b7868b749654796183ba70b4272965da1bf /IncSet.c | |
parent | c55320e9e2a8916e911bcd39ab37b79e3a7d03b2 (diff) | |
download | debian_htop-69f439eff387a6ecb52734e400b297a3c85f2285.tar.gz debian_htop-69f439eff387a6ecb52734e400b297a3c85f2285.tar.bz2 debian_htop-69f439eff387a6ecb52734e400b297a3c85f2285.zip |
New upstream version 3.1.0upstream/3.1.0
Diffstat (limited to 'IncSet.c')
-rw-r--r-- | IncSet.c | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -29,6 +29,13 @@ void IncSet_reset(IncSet* this, IncType type) { IncMode_reset(&this->modes[type]); } +void IncSet_setFilter(IncSet* this, const char* filter) { + IncMode* mode = &this->modes[INC_FILTER]; + size_t len = String_safeStrncpy(mode->buffer, filter, sizeof(mode->buffer)); + mode->index = len; + this->filtering = true; +} + static const char* const searchFunctions[] = {"Next ", "Prev ", "Cancel ", " Search: ", NULL}; static const char* const searchKeys[] = {"F3", "S-F3", "Esc", " "}; static const int searchEvents[] = {KEY_F(3), KEY_F(15), 27, ERR}; @@ -70,8 +77,8 @@ void IncSet_delete(IncSet* this) { free(this); } -static void updateWeakPanel(IncSet* this, Panel* panel, Vector* lines) { - Object* selected = Panel_getSelected(panel); +static void updateWeakPanel(const IncSet* this, Panel* panel, Vector* lines) { + const Object* selected = Panel_getSelected(panel); Panel_prune(panel); if (this->filtering) { int n = 0; @@ -98,7 +105,7 @@ static void updateWeakPanel(IncSet* this, Panel* panel, Vector* lines) { } } -static bool search(IncMode* mode, Panel* panel, IncMode_GetPanelValue getPanelValue) { +static bool search(const IncMode* mode, Panel* panel, IncMode_GetPanelValue getPanelValue) { int size = Panel_size(panel); for (int i = 0; i < size; i++) { if (String_contains_i(getPanelValue(panel, i), mode->buffer)) { @@ -110,7 +117,7 @@ static bool search(IncMode* mode, Panel* panel, IncMode_GetPanelValue getPanelVa return false; } -static bool IncMode_find(IncMode* mode, Panel* panel, IncMode_GetPanelValue getPanelValue, int step) { +static bool IncMode_find(const IncMode* mode, Panel* panel, IncMode_GetPanelValue getPanelValue, int step) { int size = Panel_size(panel); int here = Panel_getSelectedIndex(panel); int i = here; @@ -201,7 +208,7 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue } const char* IncSet_getListItemValue(Panel* panel, int i) { - ListItem* l = (ListItem*) Panel_get(panel, i); + const ListItem* l = (const ListItem*) Panel_get(panel, i); return l ? l->value : ""; } |