From e7372d18a1a661d8c3dba9f51e1f17b5f94171a7 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Wed, 10 Jan 2024 11:17:08 +0100 Subject: New upstream version 3.3.0 --- Panel.c | 126 ++++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 67 insertions(+), 59 deletions(-) (limited to 'Panel.c') diff --git a/Panel.c b/Panel.c index 4ea03f6..4784a65 100644 --- a/Panel.c +++ b/Panel.c @@ -5,6 +5,8 @@ Released under the GNU GPLv2+, see the COPYING file in the source distribution for its full text. */ +#include "config.h" // IWYU pragma: keep + #include "Panel.h" #include @@ -271,8 +273,8 @@ void Panel_draw(Panel* this, bool force_redraw, bool focus, bool highlightSelect int upTo = MINIMUM(first + h, size); int selectionColor = focus - ? CRT_colors[this->selectionColorId] - : CRT_colors[PANEL_SELECTION_UNFOCUS]; + ? CRT_colors[this->selectionColorId] + : CRT_colors[PANEL_SELECTION_UNFOCUS]; if (this->needsRedraw || force_redraw) { int line = 0; @@ -357,72 +359,74 @@ bool Panel_onKey(Panel* this, int key) { } while (0) switch (key) { - case KEY_DOWN: - case KEY_CTRL('N'): - #ifdef KEY_C_DOWN - case KEY_C_DOWN: - #endif - this->selected++; - break; - - case KEY_UP: - case KEY_CTRL('P'): - #ifdef KEY_C_UP - case KEY_C_UP: - #endif - this->selected--; - break; + case KEY_DOWN: + case KEY_CTRL('N'): + #ifdef KEY_C_DOWN + case KEY_C_DOWN: + #endif + this->selected++; + break; + + case KEY_UP: + case KEY_CTRL('P'): + #ifdef KEY_C_UP + case KEY_C_UP: + #endif + this->selected--; + break; + + case KEY_LEFT: + case KEY_CTRL('B'): + if (this->scrollH > 0) { + this->scrollH -= MAXIMUM(CRT_scrollHAmount, 0); + this->needsRedraw = true; + } + break; - case KEY_LEFT: - case KEY_CTRL('B'): - if (this->scrollH > 0) { - this->scrollH -= MAXIMUM(CRT_scrollHAmount, 0); + case KEY_RIGHT: + case KEY_CTRL('F'): + this->scrollH += CRT_scrollHAmount; this->needsRedraw = true; - } - break; + break; - case KEY_RIGHT: - case KEY_CTRL('F'): - this->scrollH += CRT_scrollHAmount; - this->needsRedraw = true; - break; + case KEY_PPAGE: + PANEL_SCROLL(-(this->h - Panel_headerHeight(this))); + break; - case KEY_PPAGE: - PANEL_SCROLL(-(this->h - Panel_headerHeight(this))); - break; + case KEY_NPAGE: + PANEL_SCROLL(+(this->h - Panel_headerHeight(this))); + break; - case KEY_NPAGE: - PANEL_SCROLL(+(this->h - Panel_headerHeight(this))); - break; + case KEY_WHEELUP: + PANEL_SCROLL(-CRT_scrollWheelVAmount); + break; - case KEY_WHEELUP: - PANEL_SCROLL(-CRT_scrollWheelVAmount); - break; + case KEY_WHEELDOWN: + PANEL_SCROLL(+CRT_scrollWheelVAmount); + break; - case KEY_WHEELDOWN: - PANEL_SCROLL(+CRT_scrollWheelVAmount); - break; + case KEY_HOME: + this->selected = 0; + break; - case KEY_HOME: - this->selected = 0; - break; + case KEY_END: + this->selected = size - 1; + break; - case KEY_END: - this->selected = size - 1; - break; + case KEY_CTRL('A'): + case '^': + this->scrollH = 0; + this->needsRedraw = true; + break; - case KEY_CTRL('A'): - case '^': - this->scrollH = 0; - this->needsRedraw = true; - break; - case KEY_CTRL('E'): - case '$': - this->scrollH = MAXIMUM(this->selectedLen - this->w, 0); - this->needsRedraw = true; - break; - default: - return false; + case KEY_CTRL('E'): + case '$': + this->scrollH = MAXIMUM(this->selectedLen - this->w, 0); + this->needsRedraw = true; + break; + + default: + return false; } #undef PANEL_SCROLL @@ -443,6 +447,9 @@ bool Panel_onKey(Panel* this, int key) { HandlerResult Panel_selectByTyping(Panel* this, int ch) { int size = Panel_size(this); + if (ch == '#') + return IGNORED; + if (!this->eventHandlerState) this->eventHandlerState = xCalloc(100, sizeof(char)); char* buffer = this->eventHandlerState; @@ -468,7 +475,8 @@ HandlerResult Panel_selectByTyping(Panel* this, int ch) { len = strlen(buffer); for (int i = 0; i < size; i++) { const char* cur = ((ListItem*) Panel_get(this, i))->value; - while (*cur == ' ') cur++; + while (*cur == ' ') + cur++; if (strncasecmp(cur, buffer, len) == 0) { Panel_setSelected(this, i); return HANDLED; -- cgit v1.2.3