diff options
author | Lars Henriksen <LarsHenriksen@get2net.dk> | 2017-12-08 21:09:50 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2017-12-10 14:33:31 +0100 |
commit | 9e060b96c2c5997342a06b9958db0bf470646a96 (patch) | |
tree | ad78ccd19676abe6fd58602b5f72ce914a111d86 /src/utils.c | |
parent | e733d09ea02897e7013a0745223b777ae5981fd5 (diff) | |
download | calcurse-9e060b96c2c5997342a06b9958db0bf470646a96.tar.gz calcurse-9e060b96c2c5997342a06b9958db0bf470646a96.zip |
Scrollbar and right window border
When a scrollbar is on display in APP or TOD windows, the right
vertical border (outside the scrollbar) is not highlighted
when the window is selected.
The scrollbar itself is always highlighted:
- when APP or TOD is deselected
- in configuration windows where borders otherwise are not
The patch moves the scrollbar parameters from arguments of
draw_scrollbar() to the function itself.
The highlight argument to draw_scrollbar() was always 1.
Instead call circumstances are figured out and highlight set
accordingly.
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/utils.c b/src/utils.c index 2440c44..2879de7 100644 --- a/src/utils.c +++ b/src/utils.c @@ -575,17 +575,36 @@ long min2sec(unsigned minutes) * can not be displayed inside the corresponding panel. */ void -draw_scrollbar(WINDOW * win, int y, int x, int length, - int bar_top, int bar_bottom, unsigned hilt) +draw_scrollbar(struct scrollwin *sw) { - mvwvline(win, bar_top, x, ACS_VLINE, bar_bottom - bar_top + 1); + int y = (conf.compact_panels ? 1 : 3); + int h = sw->h - (conf.compact_panels ? 2 : 4); + + int sbar_h = MAX(h * h / sw->line_num, 1); + int sbar_y = y + sw->line_off * (h - sbar_h) / (sw->line_num - h); + int sbar_x = sw->w - 1; + + /* which scrollwin am I? */ + enum win swid = -1; + if (strcmp(sw->label, _("TODO")) == 0) + swid = TOD; + else if (strcmp(sw->label, _("Appointments")) == 0) + swid = APP; + /* + * Redraw the vertical right border. + * For APP and TOD this is done as part of the move up/down. + */ + if (swid == -1) + mvwvline(sw->win, y, sbar_x, ACS_VLINE, h); + + int hilt = swid == wins_slctd(); if (hilt) - custom_apply_attr(win, ATTR_HIGHEST); - wattron(win, A_REVERSE); - mvwvline(win, y, x, ' ', length); - wattroff(win, A_REVERSE); + custom_apply_attr(sw->win, ATTR_HIGHEST); + wattron(sw->win, A_REVERSE); + mvwvline(sw->win, sbar_y, sbar_x, ' ', sbar_h); + wattroff(sw->win, A_REVERSE); if (hilt) - custom_remove_attr(win, ATTR_HIGHEST); + custom_remove_attr(sw->win, ATTR_HIGHEST); } /* |