aboutsummaryrefslogtreecommitdiffstats
path: root/IncSet.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:01:07 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:01:07 +0200
commitff9409b1737627857eb47f64f536a3f66b6a09a4 (patch)
tree61b631ba551e68a4f656b8b76ff7bd0d9955fc64 /IncSet.c
parentf75ab6d2c11e8a8e18191b087564aedebbeb96c5 (diff)
downloaddebian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.gz
debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.bz2
debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.zip
Imported Upstream version 2.0.0upstream/2.0.0
Diffstat (limited to 'IncSet.c')
-rw-r--r--IncSet.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/IncSet.c b/IncSet.c
index 40aa923..0149382 100644
--- a/IncSet.c
+++ b/IncSet.c
@@ -6,7 +6,7 @@ in the source distribution for its full text.
*/
#include "IncSet.h"
-#include "String.h"
+#include "StringUtils.h"
#include "Panel.h"
#include "ListItem.h"
#include "CRT.h"
@@ -38,7 +38,6 @@ typedef struct IncMode_ {
typedef struct IncSet_ {
IncMode modes[2];
IncMode* active;
- FunctionBar* bar;
FunctionBar* defaultBar;
bool filtering;
} IncSet;
@@ -73,16 +72,15 @@ static inline void IncMode_initFilter(IncMode* filter) {
}
static inline void IncMode_done(IncMode* mode) {
- FunctionBar_delete((Object*)mode->bar);
+ FunctionBar_delete(mode->bar);
}
IncSet* IncSet_new(FunctionBar* bar) {
- IncSet* this = calloc(1, sizeof(IncSet));
+ IncSet* this = xCalloc(1, sizeof(IncSet));
IncMode_initSearch(&(this->modes[INC_SEARCH]));
IncMode_initFilter(&(this->modes[INC_FILTER]));
this->active = NULL;
this->filtering = false;
- this->bar = bar;
this->defaultBar = bar;
return this;
}
@@ -137,7 +135,7 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
return true;
IncMode* mode = this->active;
int size = Panel_size(panel);
- bool filterChange = false;
+ bool filterChanged = false;
bool doSearch = true;
if (ch == KEY_F(3)) {
if (size == 0) return true;
@@ -153,27 +151,29 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
}
}
doSearch = false;
- } else if (isprint((char)ch) && (mode->index < INCMODE_MAX)) {
+ } 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) {
- filterChange = true;
+ 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) {
- filterChange = true;
+ filterChanged = true;
if (mode->index == 0) {
this->filtering = false;
IncMode_reset(mode);
}
}
+ } else if (ch == KEY_RESIZE) {
+ Panel_resize(panel, COLS, LINES-panel->y-1);
} else {
if (mode->isFilter) {
- filterChange = true;
+ filterChanged = true;
if (ch == 27) {
this->filtering = false;
IncMode_reset(mode);
@@ -182,17 +182,17 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
IncMode_reset(mode);
}
this->active = NULL;
- this->bar = this->defaultBar;
+ Panel_setDefaultBar(panel);
FunctionBar_draw(this->defaultBar, NULL);
doSearch = false;
}
if (doSearch) {
search(mode, panel, getPanelValue);
}
- if (filterChange && lines) {
+ if (filterChanged && lines) {
updateWeakPanel(this, panel, lines);
}
- return filterChange;
+ return filterChanged;
}
const char* IncSet_getListItemValue(Panel* panel, int i) {
@@ -202,12 +202,24 @@ const char* IncSet_getListItemValue(Panel* panel, int i) {
return "";
}
-void IncSet_activate(IncSet* this, IncType type) {
+void IncSet_activate(IncSet* this, IncType type, Panel* panel) {
this->active = &(this->modes[type]);
- this->bar = this->active->bar;
FunctionBar_draw(this->active->bar, this->active->buffer);
+ panel->currentBar = this->active->bar;
}
void IncSet_drawBar(IncSet* this) {
- FunctionBar_draw(this->bar, this->active ? this->active->buffer : NULL);
+ if (this->active) {
+ FunctionBar_draw(this->active->bar, this->active->buffer);
+ } else {
+ FunctionBar_draw(this->defaultBar, NULL);
+ }
+}
+
+int IncSet_synthesizeEvent(IncSet* this, int x) {
+ if (this->active) {
+ return FunctionBar_synthesizeEvent(this->active->bar, x);
+ } else {
+ return FunctionBar_synthesizeEvent(this->defaultBar, x);
+ }
}

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