diff options
Diffstat (limited to 'src/interface-curses')
| -rw-r--r-- | src/interface-curses/curses-info-popup.c | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/src/interface-curses/curses-info-popup.c b/src/interface-curses/curses-info-popup.c index 332d434..e53f6ef 100644 --- a/src/interface-curses/curses-info-popup.c +++ b/src/interface-curses/curses-info-popup.c @@ -71,7 +71,6 @@ teco_curses_info_popup_add(teco_curses_info_popup_t *ctx, teco_popup_entry_type_ static void teco_curses_info_popup_init_pad(teco_curses_info_popup_t *ctx, attr_t attr) { - int cols = getmaxx(stdscr); /**! screen width */ int pad_lines; /**! pad height */ gint pad_cols; /**! entry columns */ gint pad_colwidth; /**! width per entry column */ @@ -82,10 +81,10 @@ teco_curses_info_popup_init_pad(teco_curses_info_popup_t *ctx, attr_t attr) * Otherwise 2 characters after the entry. */ gint reserve = teco_ed & TECO_ED_ICONS ? 2+1 : 2; - pad_colwidth = MIN(ctx->longest + reserve, cols - 2); + pad_colwidth = MIN(ctx->longest + reserve, COLS - 2); /* pad_cols = floor((cols - 2) / pad_colwidth) */ - pad_cols = (cols - 2) / pad_colwidth; + pad_cols = (COLS - 2) / pad_colwidth; /* pad_lines = ceil(length / pad_cols) */ pad_lines = (ctx->length+pad_cols-1) / pad_cols; @@ -96,7 +95,7 @@ teco_curses_info_popup_init_pad(teco_curses_info_popup_t *ctx, attr_t attr) * it will be drawn into the popup window which has left * and right borders. */ - ctx->pad = newpad(pad_lines, cols - 2); + ctx->pad = newpad(pad_lines, COLS - 2); /* * NOTE: attr could contain A_REVERSE on monochrome terminals, @@ -157,9 +156,6 @@ teco_curses_info_popup_show(teco_curses_info_popup_t *ctx, attr_t attr) /* nothing to display */ return; - int lines, cols; /* screen dimensions */ - getmaxyx(stdscr, lines, cols); - if (ctx->window) delwin(ctx->window); @@ -171,10 +167,10 @@ teco_curses_info_popup_show(teco_curses_info_popup_t *ctx, attr_t attr) * Popup window can cover all but one screen row. * Another row is reserved for the top border. */ - gint popup_lines = MIN(pad_lines + 1, lines - 1); + gint popup_lines = MIN(pad_lines + 1, LINES - 1); /* window covers message, scintilla and info windows */ - ctx->window = newwin(popup_lines, 0, lines - 1 - popup_lines, 0); + ctx->window = newwin(popup_lines, 0, LINES - 1 - popup_lines, 0); wattrset(ctx->window, attr); @@ -188,7 +184,7 @@ teco_curses_info_popup_show(teco_curses_info_popup_t *ctx, attr_t attr) copywin(ctx->pad, ctx->window, ctx->pad_first_line, 0, - 1, 1, popup_lines - 1, cols - 2, FALSE); + 1, 1, popup_lines - 1, COLS - 2, FALSE); if (pad_lines <= popup_lines - 1) /* no need for scrollbar */ @@ -200,13 +196,13 @@ teco_curses_info_popup_show(teco_curses_info_popup_t *ctx, attr_t attr) /* bar_y = floor(pad_first_line/pad_lines * (popup_lines-2)) + 1 */ gint bar_y = ctx->pad_first_line*(popup_lines-2) / pad_lines + 1; - mvwvline(ctx->window, 1, cols-1, ACS_CKBOARD, popup_lines-2); + mvwvline(ctx->window, 1, COLS-1, ACS_CKBOARD, popup_lines-2); /* * We do not use ACS_BLOCK here since it will not * always be drawn as a solid block (e.g. xterm). * Instead, simply draw reverse blanks. */ - wmove(ctx->window, bar_y, cols-1); + wmove(ctx->window, bar_y, COLS-1); wattrset(ctx->window, attr ^ A_REVERSE); wvline(ctx->window, ' ', bar_height); } @@ -227,7 +223,6 @@ teco_curses_info_popup_show(teco_curses_info_popup_t *ctx, attr_t attr) const teco_string_t * teco_curses_info_popup_getentry(teco_curses_info_popup_t *ctx, gint y, gint x) { - int cols = getmaxx(stdscr); /**! screen width */ gint pad_cols; /**! entry columns */ gint pad_colwidth; /**! width per entry column */ @@ -240,10 +235,10 @@ teco_curses_info_popup_getentry(teco_curses_info_popup_t *ctx, gint y, gint x) * Otherwise 2 characters after the entry. */ gint reserve = teco_ed & TECO_ED_ICONS ? 2+1 : 2; - pad_colwidth = MIN(ctx->longest + reserve, cols - 2); + pad_colwidth = MIN(ctx->longest + reserve, COLS - 2); /* pad_cols = floor((cols - 2) / pad_colwidth) */ - pad_cols = (cols - 2) / pad_colwidth; + pad_cols = (COLS - 2) / pad_colwidth; gint cur_col = 0; for (teco_stailq_entry_t *cur = ctx->list.first; cur != NULL; cur = cur->next) { @@ -265,9 +260,8 @@ teco_curses_info_popup_getentry(teco_curses_info_popup_t *ctx, gint y, gint x) void teco_curses_info_popup_scroll_page(teco_curses_info_popup_t *ctx) { - gint lines = getmaxy(stdscr); gint pad_lines = getmaxy(ctx->pad); - gint popup_lines = MIN(pad_lines + 1, lines - 1); + gint popup_lines = MIN(pad_lines + 1, LINES - 1); /* progress scroll position */ ctx->pad_first_line += popup_lines - 1; @@ -281,9 +275,8 @@ teco_curses_info_popup_scroll_page(teco_curses_info_popup_t *ctx) void teco_curses_info_popup_scroll(teco_curses_info_popup_t *ctx, gint delta) { - gint lines = getmaxy(stdscr); gint pad_lines = getmaxy(ctx->pad); - gint popup_lines = MIN(pad_lines + 1, lines - 1); + gint popup_lines = MIN(pad_lines + 1, LINES - 1); ctx->pad_first_line = MAX(ctx->pad_first_line+delta, 0); if (pad_lines - ctx->pad_first_line < popup_lines - 1) |
