diff options
author | Benny Baumann <BenBE@geshi.org> | 2020-11-01 01:09:51 +0100 |
---|---|---|
committer | Benny Baumann <BenBE@geshi.org> | 2020-11-02 22:15:01 +0100 |
commit | 45869513bfebba80cc2ab42e4218f68b34b1e6ac (patch) | |
tree | f064631dbff141bf1c945db8cff40b7bb82fd169 /IncSet.c | |
parent | 61e14d4bb25268593019e6df3eb02264b4ac8e0e (diff) |
Embracing branches
Diffstat (limited to 'IncSet.c')
-rw-r--r-- | IncSet.c | 37 |
1 files changed, 26 insertions, 11 deletions
@@ -79,7 +79,10 @@ static void updateWeakPanel(IncSet* this, Panel* panel, Vector* lines) { ListItem* line = (ListItem*)Vector_get(lines, i); if (String_contains_i(line->value, incFilter)) { Panel_add(panel, (Object*)line); - if (selected == (Object*)line) Panel_setSelected(panel, n); + if (selected == (Object*)line) { + Panel_setSelected(panel, n); + } + n++; } } @@ -87,7 +90,9 @@ static void updateWeakPanel(IncSet* this, Panel* panel, Vector* lines) { for (int i = 0; i < Vector_size(lines); i++) { Object* line = Vector_get(lines, i); Panel_add(panel, line); - if (selected == line) Panel_setSelected(panel, i); + if (selected == line) { + Panel_setSelected(panel, i); + } } } } @@ -115,10 +120,17 @@ static bool IncMode_find(IncMode* mode, Panel* panel, IncMode_GetPanelValue getP int here = Panel_getSelectedIndex(panel); int i = here; for (;;) { - i+=step; - if (i == size) i = 0; - if (i == -1) i = size - 1; - if (i == here) return false; + i += step; + if (i == size) { + i = 0; + } + if (i == -1) { + i = size - 1; + } + if (i == here) { + return false; + } + if (String_contains_i(getPanelValue(panel, i), mode->buffer)) { Panel_setSelected(panel, i); return true; @@ -137,12 +149,15 @@ bool IncSet_prev(IncSet* this, IncType type, Panel* panel, IncMode_GetPanelValue bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue getPanelValue, Vector* lines) { if (ch == ERR) return true; + IncMode* mode = this->active; int size = Panel_size(panel); bool filterChanged = false; bool doSearch = true; if (ch == KEY_F(3)) { - if (size == 0) return true; + if (size == 0) + return true; + IncMode_find(mode, panel, getPanelValue, 1); doSearch = false; } else if (0 < ch && ch < 255 && isprint((unsigned char)ch)) { @@ -152,7 +167,9 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue mode->buffer[mode->index] = 0; if (mode->isFilter) { filterChanged = true; - if (mode->index == 1) this->filtering = true; + if (mode->index == 1) { + this->filtering = true; + } } } } else if ((ch == KEY_BACKSPACE || ch == 127)) { @@ -199,9 +216,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); - if (l) - return l->value; - return ""; + return l ? l->value : ""; } void IncSet_activate(IncSet* this, IncType type, Panel* panel) { |