aboutsummaryrefslogtreecommitdiffstats
path: root/Panel.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2024-01-10 11:17:08 +0100
committerDaniel Lange <DLange@git.local>2024-01-10 11:17:08 +0100
commite7372d18a1a661d8c3dba9f51e1f17b5f94171a7 (patch)
treee8270dd60ec096bee8157dbadf029e15ed584592 /Panel.c
parent937052b231259a47d881d539ad5748245ef55b99 (diff)
downloaddebian_htop-e7372d18a1a661d8c3dba9f51e1f17b5f94171a7.tar.gz
debian_htop-e7372d18a1a661d8c3dba9f51e1f17b5f94171a7.tar.bz2
debian_htop-e7372d18a1a661d8c3dba9f51e1f17b5f94171a7.zip
New upstream version 3.3.0
Diffstat (limited to 'Panel.c')
-rw-r--r--Panel.c126
1 files changed, 67 insertions, 59 deletions
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 <assert.h>
@@ -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;

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