aboutsummaryrefslogtreecommitdiffstats
path: root/IncSet.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-07-25 18:25:29 +0200
committerDaniel Lange <DLange@git.local>2016-07-25 18:25:29 +0200
commitaed86a83b9120528c2a2a5c137d443917682d4b4 (patch)
tree979855616d56f2864dedc7b88798e9831614e9ee /IncSet.c
parent6ca259100661aa0be46c8645773d32a8a6a5f312 (diff)
parent31b71b67011fa52f091df6fe536a11d6d0bfb256 (diff)
downloaddebian_htop-aed86a83b9120528c2a2a5c137d443917682d4b4.tar.gz
debian_htop-aed86a83b9120528c2a2a5c137d443917682d4b4.tar.bz2
debian_htop-aed86a83b9120528c2a2a5c137d443917682d4b4.zip
Merge tag 'upstream/2.0.2'
Upstream version 2.0.2
Diffstat (limited to 'IncSet.c')
-rw-r--r--IncSet.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/IncSet.c b/IncSet.c
index 0149382..c7f889c 100644
--- a/IncSet.c
+++ b/IncSet.c
@@ -40,6 +40,7 @@ typedef struct IncSet_ {
IncMode* active;
FunctionBar* defaultBar;
bool filtering;
+ bool found;
} IncSet;
typedef const char* (*IncMode_GetPanelValue)(Panel*, int);
@@ -114,7 +115,7 @@ static void updateWeakPanel(IncSet* this, Panel* panel, Vector* lines) {
}
}
-static void search(IncMode* mode, Panel* panel, IncMode_GetPanelValue getPanelValue) {
+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++) {
@@ -128,6 +129,7 @@ static void search(IncMode* mode, Panel* panel, IncMode_GetPanelValue getPanelVa
FunctionBar_draw(mode->bar, mode->buffer);
else
FunctionBar_drawAttr(mode->bar, mode->buffer, CRT_colors[FAILED_SEARCH]);
+ return found;
}
bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue getPanelValue, Vector* lines) {
@@ -151,23 +153,29 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
}
}
doSearch = false;
- } else if (ch < 255 && isprint((char)ch) && (mode->index < INCMODE_MAX)) {
- mode->buffer[mode->index] = ch;
- mode->index++;
- mode->buffer[mode->index] = 0;
- if (mode->isFilter) {
- filterChanged = true;
- if (mode->index == 1) this->filtering = true;
+ } else if (ch < 255 && isprint((char)ch)) {
+ if (mode->index < INCMODE_MAX) {
+ mode->buffer[mode->index] = ch;
+ mode->index++;
+ mode->buffer[mode->index] = 0;
+ if (mode->isFilter) {
+ filterChanged = true;
+ if (mode->index == 1) this->filtering = true;
+ }
}
- } else if ((ch == KEY_BACKSPACE || ch == 127) && (mode->index > 0)) {
- mode->index--;
- mode->buffer[mode->index] = 0;
- if (mode->isFilter) {
- filterChanged = true;
- if (mode->index == 0) {
- this->filtering = false;
- IncMode_reset(mode);
+ } else if ((ch == KEY_BACKSPACE || ch == 127)) {
+ if (mode->index > 0) {
+ mode->index--;
+ mode->buffer[mode->index] = 0;
+ if (mode->isFilter) {
+ filterChanged = true;
+ if (mode->index == 0) {
+ this->filtering = false;
+ IncMode_reset(mode);
+ }
}
+ } else {
+ doSearch = false;
}
} else if (ch == KEY_RESIZE) {
Panel_resize(panel, COLS, LINES-panel->y-1);
@@ -187,7 +195,7 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
doSearch = false;
}
if (doSearch) {
- search(mode, panel, getPanelValue);
+ this->found = search(mode, panel, getPanelValue);
}
if (filterChanged && lines) {
updateWeakPanel(this, panel, lines);

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