aboutsummaryrefslogtreecommitdiffstats
path: root/Panel.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:00:32 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:00:32 +0200
commit2004bbc3ef28ada3acca05f5d5fa9108121a6784 (patch)
tree4b032c0acba5f80caf8b2802aa175f472334a26c /Panel.c
parente2b58f0ab81b2aafeb8c29a69abad7829fa21ab3 (diff)
downloaddebian_htop-2004bbc3ef28ada3acca05f5d5fa9108121a6784.tar.gz
debian_htop-2004bbc3ef28ada3acca05f5d5fa9108121a6784.tar.bz2
debian_htop-2004bbc3ef28ada3acca05f5d5fa9108121a6784.zip
Imported Upstream version 1.0.2upstream/1.0.2
Diffstat (limited to 'Panel.c')
-rw-r--r--Panel.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/Panel.c b/Panel.c
index b090c52..d0f69bf 100644
--- a/Panel.c
+++ b/Panel.c
@@ -199,8 +199,10 @@ Object* Panel_remove(Panel* this, int i) {
Object* Panel_getSelected(Panel* this) {
assert (this != NULL);
-
- return Vector_get(this->items, this->selected);
+ if (Vector_size(this->items) > 0)
+ return Vector_get(this->items, this->selected);
+ else
+ return NULL;
}
void Panel_moveSelectedUp(Panel* this) {
@@ -248,7 +250,11 @@ void Panel_draw(Panel* this, bool focus) {
int scrollH = this->scrollH;
int y = this->y; int x = this->x;
int first = this->scrollV;
- int last = MIN(itemCount, this->scrollV + MIN(itemCount, this->h));
+ if (itemCount > this->h && first > itemCount - this->h) {
+ first = itemCount - this->h;
+ this->scrollV = first;
+ }
+ int last = MIN(itemCount, first + MIN(itemCount, this->h));
if (this->selected < first) {
first = this->selected;
this->scrollV = first;

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