aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/calcurse.h2
-rw-r--r--src/utils.c35
-rw-r--r--src/wins.c35
3 files changed, 49 insertions, 23 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index d9d4e1e..bad10c9 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -1144,7 +1144,7 @@ long date_sec_change(long, int, int);
long update_time_in_date(long, unsigned, unsigned);
time_t get_sec_date(struct date);
long min2sec(unsigned);
-void draw_scrollbar(WINDOW *, int, int, int, int, int, unsigned);
+void draw_scrollbar(struct scrollwin *);
void item_in_popup(const char *, const char *, const char *, const char *);
time_t get_today(void);
long now(void);
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);
}
/*
diff --git a/src/wins.c b/src/wins.c
index c129dec..d664e3e 100644
--- a/src/wins.c
+++ b/src/wins.c
@@ -357,25 +357,32 @@ void wins_scrollwin_draw_deco(struct scrollwin *sw, int hilt)
/* Display a scrolling window. */
void wins_scrollwin_display(struct scrollwin *sw)
{
- int inner_y = (conf.compact_panels ? 1 : 3);
- int inner_x = 1;
+ int inner_y = sw->y + (conf.compact_panels ? 1 : 3);
+ int inner_x = sw->x + 1;
int inner_h = sw->h - (conf.compact_panels ? 2 : 4);
int inner_w = sw->w - 2;
- if (sw->line_num > inner_h) {
- int sbar_h = MAX(inner_h * inner_h / sw->line_num, 1);
- int sbar_y = inner_y + sw->line_off * (inner_h - sbar_h) / (sw->line_num - inner_h);
- int sbar_x = sw->w - 1;
-
- draw_scrollbar(sw->win, sbar_y, sbar_x, sbar_h, inner_y,
- inner_y + inner_h - 1, 1);
- }
-
+ if (sw->line_num > inner_h)
+ draw_scrollbar(sw);
wmove(win[STA].p, 0, 0);
wnoutrefresh(sw->win);
- pnoutrefresh(sw->inner, sw->line_off, 0, sw->y + inner_y,
- sw->x + inner_x, sw->y + inner_y + inner_h - 1,
- sw->x + inner_x + inner_w - 1);
+ /*
+ (sw->line_off, 0): upper left corner in pad to display;
+ scrolling is achieved by in/decreasing sw->line_off
+ between 0 and line_num - inner.h
+
+ (Y,X)=(inner_y,inner_x): upper left corner in screen window
+ (Y,X) + (inner_h - 1,inner_w - 1): lower right corner in screen window
+
+ |-inner_w-|
+ (Y,X)-> +---------+ -
+ | | |
+ | (pad) | inner_h
+ | | |
+ +---------+ <- -
+ */
+ pnoutrefresh(sw->inner, sw->line_off, 0, inner_y, inner_x,
+ inner_y + inner_h - 1, inner_x + inner_w - 1);
wins_doupdate();
}