From: Christian Heller Date: Thu, 6 Jun 2013 10:56:37 +0000 (+0200) Subject: Made vertical scroll hint more informative. X-Git-Tag: tce~1243 X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/todo?a=commitdiff_plain;h=154ade9490933893ea32781e9571a6817fec7a1c;p=plomrogue Made vertical scroll hint more informative. --- diff --git a/draw_wins.c b/draw_wins.c index 8603d96..a7da818 100644 --- a/draw_wins.c +++ b/draw_wins.c @@ -99,7 +99,7 @@ void draw_info_win (struct Win * win) { snprintf(text, 100, "Turn: %d", count); draw_with_linebreaks(win, text, 0); } -void draw_scroll_hint (struct Win * win, uint16_t y, uint32_t more_lines, char dir) { +void draw_horizontal_scroll_hint (struct Win * win, uint16_t y, uint32_t more_lines, char dir) { // Draw scroll hint line in win at row y, announce more_lines more lines in direction dir. uint16_t x, offset; char phrase[] = "more lines"; @@ -130,10 +130,10 @@ void draw_keys_win (struct Win * win) { attr_t attri; for (y = 0; y <= world->keyswindata->max && y < win->height; y++) { if (0 == y && offset > 0) { - draw_scroll_hint (win, y, offset + 1, '^'); + draw_horizontal_scroll_hint (win, y, offset + 1, '^'); continue; } else if (win->height == y + 1 && 0 < world->keyswindata->max - (win->height + offset - 1)) { - draw_scroll_hint (win, y, world->keyswindata->max - (offset + win->height) + 2, 'v'); + draw_horizontal_scroll_hint (win, y, world->keyswindata->max - (offset + win->height) + 2, 'v'); continue; } attri = 0; if (y == world->keyswindata->select - offset) { diff --git a/draw_wins.h b/draw_wins.h index 4ed3c24..20b5676 100644 --- a/draw_wins.h +++ b/draw_wins.h @@ -3,5 +3,5 @@ void draw_text_from_bottom (struct Win *, char *); void draw_log_win (struct Win *); void draw_map_win (struct Win *); void draw_info_win (struct Win *); -void draw_scroll_hint (struct Win *, uint16_t, uint32_t, char); +void draw_horizontal_scroll_hint (struct Win *, uint16_t, uint32_t, char); void draw_keys_win (struct Win *); diff --git a/windows.c b/windows.c index 461a98e..47c1a44 100644 --- a/windows.c +++ b/windows.c @@ -171,6 +171,23 @@ void draw_windows (struct Win * win) { if (0 != win->next) { draw_windows (win->next); } } +void draw_vertical_scroll_hint (struct WinMeta * win_meta, uint16_t x, uint32_t more_cols, char dir) { +// Draw scroll hint line in win at col x of pad display, announce more_cols more columns in direction dir. + uint16_t y, offset; + offset = 0; + char phrase[] = "more columns"; + char * scrolldesc = malloc((3 * sizeof(char)) + strlen(phrase) + 10); // 10 = max chars for uint32_t string + sprintf(scrolldesc, " %d %s ", more_cols, phrase); + offset = 1; + if (win_meta->height > (strlen(scrolldesc) + 1)) + offset = (win_meta->height - strlen(scrolldesc)) / 2; + for (y = 0; y < win_meta->height; y++) + if (y >= offset && y < strlen(scrolldesc) + offset) + mvwaddch(win_meta->pad, y, x, scrolldesc[y - offset] | A_REVERSE); + else + mvwaddch(win_meta->pad, y, x, dir | A_REVERSE); + free(scrolldesc); } + void draw_all_windows (struct WinMeta * win_meta) { // Draw pad with all windows and their borders, plus scrolling hints. erase(); @@ -194,11 +211,11 @@ void draw_all_windows (struct WinMeta * win_meta) { free(all_corners); uint16_t y; if (win_meta->pad_offset > 0) - for (y = 0; y < win_meta->height; y++) - mvwaddch(win_meta->pad, y, win_meta->pad_offset, '<' | A_REVERSE); + draw_vertical_scroll_hint(win_meta, win_meta->pad_offset, win_meta->pad_offset + 1, '<'); if (win_meta->pad_offset + win_meta->width < getmaxx(win_meta->pad) - 1) for (y = 0; y < win_meta->height; y++) - mvwaddch(win_meta->pad, y, win_meta->pad_offset + win_meta->width - 1, '>' | A_REVERSE); + draw_vertical_scroll_hint(win_meta, win_meta->pad_offset + win_meta->width - 1, + getmaxx(win_meta->pad) - (win_meta->pad_offset + win_meta->width + 1), '>'); pnoutrefresh(win_meta->pad, 0, win_meta->pad_offset, 0, 0, win_meta->height, win_meta->width - 1); } doupdate(); } diff --git a/windows.h b/windows.h index 904cc9f..522f26f 100644 --- a/windows.h +++ b/windows.h @@ -39,6 +39,7 @@ void destroy_window (struct Win *); void draw_windows (struct Win *); void draw_windows_borders (struct Win *, struct Win *, struct Corners *, uint16_t); void draw_window_borders (struct Win *, char); +void draw_vertical_scroll_hint (struct WinMeta *, uint16_t, uint32_t, char); void draw_all_windows (struct WinMeta *); void resize_active_window (struct WinMeta *, uint16_t, uint16_t); void cycle_active_window (struct WinMeta *, char);