summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2020-11-21 17:04:25 +0100
committerBenBE <BenBE@geshi.org>2020-12-03 22:41:31 +0100
commit9adb94a379c9478fae2f66725ab6fed4b2aa1036 (patch)
tree1e230cdb4be5038404b4e74a60ca8feb06a2a1ea
parent5fe2a88c08fad97095f75d3ae4c298d05459663f (diff)
Some visual code cleanup
-rw-r--r--Panel.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/Panel.c b/Panel.c
index 9c962e06..9029a844 100644
--- a/Panel.c
+++ b/Panel.c
@@ -355,39 +355,45 @@ bool Panel_onKey(Panel* this, int key) {
this->needsRedraw = true;
}
break;
+
case KEY_RIGHT:
case KEY_CTRL('F'):
this->scrollH += CRT_scrollHAmount;
this->needsRedraw = true;
break;
+
case KEY_PPAGE:
this->selected -= (this->h - 1);
this->scrollV = CLAMP_INDEX(this->scrollV, -(this->h - 1), 0, size - this->h);
this->needsRedraw = true;
break;
+
case KEY_NPAGE:
this->selected += (this->h - 1);
this->scrollV = CLAMP_INDEX(this->scrollV, +(this->h - 1), 0, size - this->h);
this->needsRedraw = true;
break;
+
case KEY_WHEELUP:
this->selected -= CRT_scrollWheelVAmount;
this->scrollV = CLAMP_INDEX(this->scrollV, -CRT_scrollWheelVAmount, 0, size - this->h);
this->needsRedraw = true;
break;
+
case KEY_WHEELDOWN:
- {
this->selected += CRT_scrollWheelVAmount;
this->scrollV = CLAMP_INDEX(this->scrollV, +CRT_scrollWheelVAmount, 0, size - this->h);
this->needsRedraw = true;
break;
- }
+
case KEY_HOME:
this->selected = 0;
break;
+
case KEY_END:
this->selected = size - 1;
break;
+
case KEY_CTRL('A'):
case '^':
this->scrollH = 0;
@@ -412,12 +418,14 @@ bool Panel_onKey(Panel* this, int key) {
this->selected = size - 1;
this->needsRedraw = true;
}
+
return true;
}
HandlerResult Panel_selectByTyping(Panel* this, int ch) {
int size = Panel_size(this);
+
if (!this->eventHandlerState)
this->eventHandlerState = xCalloc(100, sizeof(char));
char* buffer = this->eventHandlerState;
@@ -438,17 +446,21 @@ HandlerResult Panel_selectByTyping(Panel* this, int ch) {
return HANDLED;
}
}
+
// if current word did not match,
// retry considering the character the start of a new word.
buffer[0] = ch;
buffer[1] = '\0';
}
+
return HANDLED;
} else if (ch != ERR) {
buffer[0] = '\0';
}
+
if (ch == 13) {
return BREAK_LOOP;
}
+
return IGNORED;
}

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