aboutsummaryrefslogtreecommitdiffstats
path: root/Panel.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-07-25 18:25:28 +0200
committerDaniel Lange <DLange@git.local>2016-07-25 18:25:28 +0200
commit31b71b67011fa52f091df6fe536a11d6d0bfb256 (patch)
tree31cb222871017376af8b7435d24cf4961863fa93 /Panel.c
parent8c82a38002ce09db2a0b83dab8b598cf1ab0596c (diff)
downloaddebian_htop-31b71b67011fa52f091df6fe536a11d6d0bfb256.tar.gz
debian_htop-31b71b67011fa52f091df6fe536a11d6d0bfb256.tar.bz2
debian_htop-31b71b67011fa52f091df6fe536a11d6d0bfb256.zip
Imported Upstream version 2.0.2upstream/2.0.2
Diffstat (limited to 'Panel.c')
-rw-r--r--Panel.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/Panel.c b/Panel.c
index 1c45714..579a82c 100644
--- a/Panel.c
+++ b/Panel.c
@@ -61,6 +61,7 @@ struct Panel_ {
Vector* items;
int selected;
int oldSelected;
+ int selectedLen;
void* eventHandlerState;
int scrollV;
short scrollH;
@@ -82,10 +83,7 @@ struct Panel_ {
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
-#define KEY_CTRLN 0016 /* control-n key */
-#define KEY_CTRLP 0020 /* control-p key */
-#define KEY_CTRLF 0006 /* control-f key */
-#define KEY_CTRLB 0002 /* control-b key */
+#define KEY_CTRL(l) ((l)-'A'+1)
PanelClass Panel_class = {
.super = {
@@ -327,6 +325,7 @@ void Panel_draw(Panel* this, bool focus) {
if (selected) {
attrset(selectionColor);
RichString_setAttr(&item, selectionColor);
+ this->selectedLen = itemLen;
}
mvhline(y + line, x, ' ', this->w);
if (amt > 0)
@@ -352,6 +351,7 @@ void Panel_draw(Panel* this, bool focus) {
RichString_begin(new);
Object_display(newObj, &new);
int newLen = RichString_sizeVal(new);
+ this->selectedLen = newLen;
mvhline(y+ this->oldSelected - first, x+0, ' ', this->w);
if (scrollH < oldLen)
RichString_printoffnVal(old, y+this->oldSelected - first, x,
@@ -376,11 +376,11 @@ bool Panel_onKey(Panel* this, int key) {
int size = Vector_size(this->items);
switch (key) {
case KEY_DOWN:
- case KEY_CTRLN:
+ case KEY_CTRL('N'):
this->selected++;
break;
case KEY_UP:
- case KEY_CTRLP:
+ case KEY_CTRL('P'):
this->selected--;
break;
#ifdef KEY_C_DOWN
@@ -394,14 +394,14 @@ bool Panel_onKey(Panel* this, int key) {
break;
#endif
case KEY_LEFT:
- case KEY_CTRLB:
+ case KEY_CTRL('B'):
if (this->scrollH > 0) {
- this->scrollH -= CRT_scrollHAmount;
+ this->scrollH -= MAX(CRT_scrollHAmount, 0);
this->needsRedraw = true;
}
break;
case KEY_RIGHT:
- case KEY_CTRLF:
+ case KEY_CTRL('F'):
this->scrollH += CRT_scrollHAmount;
this->needsRedraw = true;
break;
@@ -412,7 +412,7 @@ bool Panel_onKey(Panel* this, int key) {
break;
case KEY_NPAGE:
this->selected += (this->h - 1);
- this->scrollV += (this->h - 1);
+ this->scrollV = MIN(MAX(0, Vector_size(this->items) - this->h), this->selected - this->h);
this->needsRedraw = true;
break;
case KEY_WHEELUP:
@@ -436,6 +436,16 @@ bool Panel_onKey(Panel* this, int key) {
case KEY_END:
this->selected = size - 1;
break;
+ case KEY_CTRL('A'):
+ case '^':
+ this->scrollH = 0;
+ this->needsRedraw = true;
+ break;
+ case KEY_CTRL('E'):
+ case '$':
+ this->scrollH = MAX(this->selectedLen - this->w, 0);
+ this->needsRedraw = true;
+ break;
default:
return false;
}

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