diff options
author | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:32 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:32 +0200 |
commit | 2004bbc3ef28ada3acca05f5d5fa9108121a6784 (patch) | |
tree | 4b032c0acba5f80caf8b2802aa175f472334a26c /Panel.c | |
parent | e2b58f0ab81b2aafeb8c29a69abad7829fa21ab3 (diff) | |
download | debian_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.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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; |