summaryrefslogtreecommitdiffstats
path: root/Panel.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2014-02-27 16:35:22 -0300
committerHisham Muhammad <hisham@gobolinux.org>2014-02-27 16:35:22 -0300
commit6d90e58c01c606841753fb23b4effe3d815223cd (patch)
tree99153968af5251fdfbf534e1fc5b8e606f652c67 /Panel.c
parent953ec71235f51934014f025ea113e788238e2e24 (diff)
alignment improvements
Diffstat (limited to 'Panel.c')
-rw-r--r--Panel.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/Panel.c b/Panel.c
index 70e84e20..26b11908 100644
--- a/Panel.c
+++ b/Panel.c
@@ -53,12 +53,12 @@ struct Panel_ {
WINDOW* window;
Vector* items;
int selected;
- int scrollV, scrollH;
- int scrollHAmount;
int oldSelected;
+ char* eventHandlerBuffer;
+ int scrollV;
+ short scrollH;
bool needsRedraw;
RichString header;
- char* eventHandlerBuffer;
};
}*/
@@ -110,10 +110,6 @@ void Panel_init(Panel* this, int x, int y, int w, int h, ObjectClass* type, bool
this->oldSelected = 0;
this->needsRedraw = true;
RichString_beginAllocated(this->header);
- if (String_eq(CRT_termType, "linux"))
- this->scrollHAmount = 20;
- else
- this->scrollHAmount = 5;
}
void Panel_done(Panel* this) {
@@ -299,18 +295,16 @@ void Panel_draw(Panel* this, bool focus) {
Object_display(itemObj, &item);
int itemLen = RichString_sizeVal(item);
int amt = MIN(itemLen - scrollH, this->w);
- if (i == this->selected) {
+ bool selected = (i == this->selected);
+ if (selected) {
attrset(highlight);
RichString_setAttr(&item, highlight);
- mvhline(y + j, x+0, ' ', this->w);
- if (amt > 0)
- RichString_printoffnVal(item, y+j, x+0, scrollH, amt);
- attrset(CRT_colors[RESET_COLOR]);
- } else {
- mvhline(y+j, x+0, ' ', this->w);
- if (amt > 0)
- RichString_printoffnVal(item, y+j, x+0, scrollH, amt);
}
+ mvhline(y + j, x, ' ', this->w);
+ if (amt > 0)
+ RichString_printoffnVal(item, y+j, x, scrollH, amt);
+ if (selected)
+ attrset(CRT_colors[RESET_COLOR]);
RichString_end(item);
}
for (int i = y + (last - first); i < y + this->h; i++)
@@ -330,13 +324,13 @@ void Panel_draw(Panel* this, bool focus) {
mvhline(y+ this->oldSelected - this->scrollV, x+0, ' ', this->w);
if (scrollH < oldLen)
RichString_printoffnVal(old, y+this->oldSelected - this->scrollV, x,
- this->scrollH, MIN(oldLen - scrollH, this->w));
+ scrollH, MIN(oldLen - scrollH, this->w));
attrset(highlight);
mvhline(y+this->selected - this->scrollV, x+0, ' ', this->w);
RichString_setAttr(&new, highlight);
if (scrollH < newLen)
RichString_printoffnVal(new, y+this->selected - this->scrollV, x,
- this->scrollH, MIN(newLen - scrollH, this->w));
+ scrollH, MIN(newLen - scrollH, this->w));
attrset(CRT_colors[RESET_COLOR]);
RichString_end(new);
RichString_end(old);
@@ -383,13 +377,13 @@ bool Panel_onKey(Panel* this, int key) {
case KEY_LEFT:
case KEY_CTRLB:
if (this->scrollH > 0) {
- this->scrollH -= 5;
+ this->scrollH -= CRT_scrollHAmount;
this->needsRedraw = true;
}
return true;
case KEY_RIGHT:
case KEY_CTRLF:
- this->scrollH += 5;
+ this->scrollH += CRT_scrollHAmount;
this->needsRedraw = true;
return true;
case KEY_PPAGE:

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