aboutsummaryrefslogtreecommitdiffstats
path: root/Panel.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:00:26 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:00:26 +0200
commitbea9b4798717b6f4e31085506dfc179eeb8dc17c (patch)
treee6b16257d9e7f8fb87b05dcdb8a0ba8bb3419eb7 /Panel.c
parent1767b21eb219fb9ac332aca9f7c3abecd97b6b39 (diff)
downloaddebian_htop-bea9b4798717b6f4e31085506dfc179eeb8dc17c.tar.gz
debian_htop-bea9b4798717b6f4e31085506dfc179eeb8dc17c.tar.bz2
debian_htop-bea9b4798717b6f4e31085506dfc179eeb8dc17c.zip
Imported Upstream version 0.8.3upstream/0.8.3
Diffstat (limited to 'Panel.c')
-rw-r--r--Panel.c63
1 files changed, 47 insertions, 16 deletions
diff --git a/Panel.c b/Panel.c
index 00ff4c6..3ae492e 100644
--- a/Panel.c
+++ b/Panel.c
@@ -94,9 +94,9 @@ void Panel_init(Panel* this, int x, int y, int w, int h, char* type, bool owner)
this->selected = 0;
this->oldSelected = 0;
this->needsRedraw = true;
- this->header.len = 0;
+ RichString_prune(&(this->header));
if (String_eq(CRT_termType, "linux"))
- this->scrollHAmount = 40;
+ this->scrollHAmount = 20;
else
this->scrollHAmount = 5;
}
@@ -213,7 +213,7 @@ int Panel_getSelectedIndex(Panel* this) {
return this->selected;
}
-int Panel_getSize(Panel* this) {
+int Panel_size(Panel* this) {
assert (this != NULL);
return Vector_size(this->items);
@@ -326,43 +326,74 @@ void Panel_draw(Panel* this, bool focus) {
move(0, 0);
}
-void Panel_onKey(Panel* this, int key) {
+bool Panel_onKey(Panel* this, int key) {
assert (this != NULL);
switch (key) {
case KEY_DOWN:
if (this->selected + 1 < Vector_size(this->items))
this->selected++;
- break;
+ return true;
case KEY_UP:
if (this->selected > 0)
this->selected--;
- break;
+ return true;
+ #ifdef KEY_C_DOWN
+ case KEY_C_DOWN:
+ if (this->selected + 1 < Vector_size(this->items)) {
+ this->selected++;
+ if (this->scrollV < Vector_size(this->items) - this->h) {
+ this->scrollV++;
+ this->needsRedraw = true;
+ }
+ }
+ return true;
+ #endif
+ #ifdef KEY_C_UP
+ case KEY_C_UP:
+ if (this->selected > 0) {
+ this->selected--;
+ if (this->scrollV > 0) {
+ this->scrollV--;
+ this->needsRedraw = true;
+ }
+ }
+ return true;
+ #endif
case KEY_LEFT:
if (this->scrollH > 0) {
- this->scrollH -= this->scrollHAmount;
+ this->scrollH -= 5;
this->needsRedraw = true;
}
- break;
+ return true;
case KEY_RIGHT:
- this->scrollH += this->scrollHAmount;
+ this->scrollH += 5;
this->needsRedraw = true;
- break;
+ return true;
case KEY_PPAGE:
- this->selected -= this->h;
+ this->selected -= (this->h - 1);
+ this->scrollV -= (this->h - 1);
if (this->selected < 0)
this->selected = 0;
- break;
+ if (this->scrollV < 0)
+ this->scrollV = 0;
+ this->needsRedraw = true;
+ return true;
case KEY_NPAGE:
- this->selected += this->h;
+ this->selected += (this->h - 1);
int size = Vector_size(this->items);
if (this->selected >= size)
this->selected = size - 1;
- break;
+ this->scrollV += (this->h - 1);
+ if (this->scrollV >= MAX(0, size - this->h))
+ this->scrollV = MAX(0, size - this->h - 1);
+ this->needsRedraw = true;
+ return true;
case KEY_HOME:
this->selected = 0;
- break;
+ return true;
case KEY_END:
this->selected = Vector_size(this->items) - 1;
- break;
+ return true;
}
+ return false;
}

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