summaryrefslogtreecommitdiffstats
path: root/IncSet.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-12-16 21:46:11 +0100
committerChristian Göttsche <cgzones@googlemail.com>2020-12-20 17:01:50 +0100
commite3862aa67e37ecef0eb8f82ba1f4a710ffac9c02 (patch)
treeaa906dac3ffca307c01b9dc78ed75082aecf238c /IncSet.c
parent7e7a53c415b82cceee6173922987b772b1d51c10 (diff)
Rework drawing of FunctionBar
Draw the FunctionBar within Panel_draw instead of manually throughout the code. Add an optional PanelClass function drawFunctionBar, to allow specific panels to override the default FunctionBar_draw call. Rework the code on color change, to really change all colors (selection markers and panel headers). Closes: #402
Diffstat (limited to 'IncSet.c')
-rw-r--r--IncSet.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/IncSet.c b/IncSet.c
index 8cd850b3..af8e3aef 100644
--- a/IncSet.c
+++ b/IncSet.c
@@ -54,12 +54,13 @@ static inline void IncMode_done(IncMode* mode) {
}
IncSet* IncSet_new(FunctionBar* bar) {
- IncSet* this = xCalloc(1, sizeof(IncSet));
+ IncSet* this = xMalloc(sizeof(IncSet));
IncMode_initSearch(&(this->modes[INC_SEARCH]));
IncMode_initFilter(&(this->modes[INC_FILTER]));
this->active = NULL;
- this->filtering = false;
this->defaultBar = bar;
+ this->filtering = false;
+ this->found = false;
return this;
}
@@ -99,20 +100,14 @@ static void updateWeakPanel(IncSet* this, Panel* panel, Vector* lines) {
static bool search(IncMode* mode, Panel* panel, IncMode_GetPanelValue getPanelValue) {
int size = Panel_size(panel);
- bool found = false;
for (int i = 0; i < size; i++) {
if (String_contains_i(getPanelValue(panel, i), mode->buffer)) {
Panel_setSelected(panel, i);
- found = true;
- break;
+ return true;
}
}
- FunctionBar_drawExtra(mode->bar,
- mode->buffer,
- found ? -1 : CRT_colors[FAILED_SEARCH],
- true);
- return found;
+ return false;
}
static bool IncMode_find(IncMode* mode, Panel* panel, IncMode_GetPanelValue getPanelValue, int step) {
@@ -202,7 +197,6 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
}
this->active = NULL;
Panel_setDefaultBar(panel);
- FunctionBar_draw(this->defaultBar);
doSearch = false;
}
if (doSearch) {
@@ -221,13 +215,12 @@ const char* IncSet_getListItemValue(Panel* panel, int i) {
void IncSet_activate(IncSet* this, IncType type, Panel* panel) {
this->active = &(this->modes[type]);
- FunctionBar_drawExtra(this->active->bar, this->active->buffer, -1, true);
panel->currentBar = this->active->bar;
}
void IncSet_drawBar(const IncSet* this) {
if (this->active) {
- FunctionBar_drawExtra(this->active->bar, this->active->buffer, -1, true);
+ FunctionBar_drawExtra(this->active->bar, this->active->buffer, (this->active->isFilter || this->found) ? -1 : CRT_colors[FAILED_SEARCH], true);
} else {
FunctionBar_draw(this->defaultBar);
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy