aboutsummaryrefslogtreecommitdiffstats
path: root/IncSet.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-07-25 18:25:28 +0200
committerDaniel Lange <DLange@git.local>2016-07-25 18:25:28 +0200
commit31b71b67011fa52f091df6fe536a11d6d0bfb256 (patch)
tree31cb222871017376af8b7435d24cf4961863fa93 /IncSet.c
parent8c82a38002ce09db2a0b83dab8b598cf1ab0596c (diff)
downloaddebian_htop-31b71b67011fa52f091df6fe536a11d6d0bfb256.tar.gz
debian_htop-31b71b67011fa52f091df6fe536a11d6d0bfb256.tar.bz2
debian_htop-31b71b67011fa52f091df6fe536a11d6d0bfb256.zip
Imported Upstream version 2.0.2upstream/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