diff options
| author | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-01-26 19:50:03 +0100 |
|---|---|---|
| committer | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-01-26 19:50:03 +0100 |
| commit | 7fa9feae452ea05a083b17d3f0cdf69bf5d37822 (patch) | |
| tree | 080b0d24fad4bceee74cae6a41a56db434aa930d /src/interface-curses/curses-info-popup.c | |
| parent | 59d3c24f198ca4628fb69c8da163f103bafebc43 (diff) | |
Curses: support up to 32767 color pairsHEADmaster-fmsbw-cimaster
* Instead of ORing COLOR_PAIR() into attributes, always pass separate `pair` arguments.
Since they are `short` this allows for up to 32767 color pairs.
Previously, we could only count on 256 color pairs (or 128 for SciTECO and Scinterm each).
* Analoguous changes have been made to Scinterm.
See also https://github.com/orbitalquark/scinterm/pull/37
Since it only correctly checks for overflows at the end of the color pair space, we allocate the second
half of that space to Scinterm.
It is now very unlikely to overflow the color pair space, though.
* This wasn't critical of course since even the 128 pairs would be unlikely to exhaust as long
as we support only 16 ANSI colors.
Scinterm however supports arbitrary RGB colors and we might want to do so soon as well.
Diffstat (limited to 'src/interface-curses/curses-info-popup.c')
| -rw-r--r-- | src/interface-curses/curses-info-popup.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/interface-curses/curses-info-popup.c b/src/interface-curses/curses-info-popup.c index edb6e15..f7d923d 100644 --- a/src/interface-curses/curses-info-popup.c +++ b/src/interface-curses/curses-info-popup.c @@ -73,7 +73,7 @@ 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) +teco_curses_info_popup_init_pad(teco_curses_info_popup_t *ctx, attr_t attr, gshort pair) { int pad_lines; /**! pad height */ gint pad_cols; /**! entry columns */ @@ -106,7 +106,7 @@ teco_curses_info_popup_init_pad(teco_curses_info_popup_t *ctx, attr_t attr) * so we use foreground attributes instead of background attributes. * This way, we can cancel out the A_REVERSE if necessary. */ - wattrset(ctx->pad, attr); + wattr_set(ctx->pad, attr, pair, NULL); teco_curses_clrtobot(ctx->pad); /* @@ -161,7 +161,7 @@ teco_curses_info_popup_init_pad(teco_curses_info_popup_t *ctx, attr_t attr) } void -teco_curses_info_popup_show(teco_curses_info_popup_t *ctx, attr_t attr) +teco_curses_info_popup_show(teco_curses_info_popup_t *ctx, attr_t attr, gshort pair) { if (!ctx->length) /* nothing to display */ @@ -171,7 +171,7 @@ teco_curses_info_popup_show(teco_curses_info_popup_t *ctx, attr_t attr) delwin(ctx->window); if (!ctx->pad) - teco_curses_info_popup_init_pad(ctx, attr); + teco_curses_info_popup_init_pad(ctx, attr, pair); gint pad_lines = getmaxy(ctx->pad); /* @@ -183,15 +183,17 @@ teco_curses_info_popup_show(teco_curses_info_popup_t *ctx, attr_t attr) /* window covers message, scintilla and info windows */ ctx->window = newwin(popup_lines, 0, LINES - teco_cmdline.height - popup_lines, 0); - wattrset(ctx->window, attr); + wattr_set(ctx->window, attr, pair, NULL); - wborder(ctx->window, - ACS_VLINE, - ACS_VLINE, /* may be overwritten with scrollbar */ - ACS_HLINE, - ' ', /* no bottom line */ - ACS_ULCORNER, ACS_URCORNER, - ACS_VLINE, ACS_VLINE); + /* + * NOTE: wborder() is broken for large pair numbers, at least on ncurses. + */ + waddch(ctx->window, ACS_ULCORNER); + whline(ctx->window, ACS_HLINE, COLS - 2); + mvwaddch(ctx->window, 0, COLS - 1, ACS_URCORNER); + mvwvline(ctx->window, 1, 0, ACS_VLINE, getmaxy(ctx->window)-1); + /* may be overwritten with scrollbar */ + mvwvline(ctx->window, 1, COLS - 1, ACS_VLINE, getmaxy(ctx->window)-1); copywin(ctx->pad, ctx->window, ctx->pad_first_line, 0, @@ -214,7 +216,7 @@ teco_curses_info_popup_show(teco_curses_info_popup_t *ctx, attr_t attr) * Instead, simply draw reverse blanks. */ wmove(ctx->window, bar_y, COLS-1); - wattrset(ctx->window, attr ^ A_REVERSE); + wattr_set(ctx->window, attr ^ A_REVERSE, pair, NULL); wvline(ctx->window, ' ', bar_height); } |
