diff options
| author | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-01-30 14:22:59 +0100 |
|---|---|---|
| committer | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-01-30 14:36:20 +0100 |
| commit | e624826447d83f1b79e5442d3695a7528cf578cf (patch) | |
| tree | 9e008039f1db26974d650e26a2f099b91e690e65 | |
| parent | 7fa9feae452ea05a083b17d3f0cdf69bf5d37822 (diff) | |
* Also updated A_XXX attributes to WA_XXX, where the "new" wattr_set() APIs
are used. This doesn't make a difference on ncurses and PDCurses, but the
X/Open standard demands it.
* Allow color pairs up to 32767 instead of only up to 32766.
* We now always require Curses wide-character APIs due to Scinterm,
which has to use mvwin_wch(). We were practically depending on wide-character
support anyway, so this shouldn't really restrict portability.
* teco_curses_add_wc() has been simplified, now that we can rely on
wide-char APIs. Perhaps it should be removed altogether?
| m--------- | contrib/scinterm | 0 | ||||
| -rw-r--r-- | src/interface-curses/curses-info-popup.c | 6 | ||||
| -rw-r--r-- | src/interface-curses/curses-utils.c | 16 | ||||
| -rw-r--r-- | src/interface-curses/curses-utils.h | 9 | ||||
| -rw-r--r-- | src/interface-curses/interface.c | 8 |
5 files changed, 18 insertions, 21 deletions
diff --git a/contrib/scinterm b/contrib/scinterm -Subproject c2f823590a8152433fcba25eb93b48836d8db29 +Subproject c579c794e085e8b4c8cd812d9e2e1613ab70d0c diff --git a/src/interface-curses/curses-info-popup.c b/src/interface-curses/curses-info-popup.c index f7d923d..83d4665 100644 --- a/src/interface-curses/curses-info-popup.c +++ b/src/interface-curses/curses-info-popup.c @@ -102,9 +102,9 @@ teco_curses_info_popup_init_pad(teco_curses_info_popup_t *ctx, attr_t attr, gsho ctx->pad = newpad(pad_lines, COLS - 2); /* - * NOTE: attr could contain A_REVERSE on monochrome terminals, + * NOTE: attr could contain WA_REVERSE on monochrome terminals, * so we use foreground attributes instead of background attributes. - * This way, we can cancel out the A_REVERSE if necessary. + * This way, we can cancel out the WA_REVERSE if necessary. */ wattr_set(ctx->pad, attr, pair, NULL); teco_curses_clrtobot(ctx->pad); @@ -216,7 +216,7 @@ teco_curses_info_popup_show(teco_curses_info_popup_t *ctx, attr_t attr, gshort p * Instead, simply draw reverse blanks. */ wmove(ctx->window, bar_y, COLS-1); - wattr_set(ctx->window, attr ^ A_REVERSE, pair, NULL); + wattr_set(ctx->window, attr ^ WA_REVERSE, pair, NULL); wvline(ctx->window, ' ', bar_height); } diff --git a/src/interface-curses/curses-utils.c b/src/interface-curses/curses-utils.c index 875c332..3b25d56 100644 --- a/src/interface-curses/curses-utils.c +++ b/src/interface-curses/curses-utils.c @@ -53,9 +53,9 @@ teco_curses_format_str(WINDOW *win, const gchar *str, gsize len, gint max_width) /* * The entire background might be in reverse, especially * on monochrome terminals. - * In those cases, we have to __remove__ the A_REVERSE flag. + * In those cases, we have to __remove__ the WA_REVERSE flag. */ - attr_t attrs = A_NORMAL; + attr_t attrs = WA_NORMAL; short pair = 0; wattr_get(win, &attrs, &pair, NULL); @@ -81,28 +81,28 @@ teco_curses_format_str(WINDOW *win, const gchar *str, gsize len, gint max_width) chars_added++; if (chars_added > max_width) goto truncate; - wattr_set(win, attrs ^ A_REVERSE, pair, NULL); + wattr_set(win, attrs ^ WA_REVERSE, pair, NULL); waddch(win, '$'); break; case '\r': chars_added += 2; if (chars_added > max_width) goto truncate; - wattr_set(win, attrs ^ A_REVERSE, pair, NULL); + wattr_set(win, attrs ^ WA_REVERSE, pair, NULL); waddstr(win, "CR"); break; case '\n': chars_added += 2; if (chars_added > max_width) goto truncate; - wattr_set(win, attrs ^ A_REVERSE, pair, NULL); + wattr_set(win, attrs ^ WA_REVERSE, pair, NULL); waddstr(win, "LF"); break; case '\t': chars_added += 3; if (chars_added > max_width) goto truncate; - wattr_set(win, attrs ^ A_REVERSE, pair, NULL); + wattr_set(win, attrs ^ WA_REVERSE, pair, NULL); waddstr(win, "TAB"); break; default: @@ -110,7 +110,7 @@ teco_curses_format_str(WINDOW *win, const gchar *str, gsize len, gint max_width) chars_added += 2; if (chars_added > max_width) goto truncate; - wattr_set(win, attrs ^ A_REVERSE, pair, NULL); + wattr_set(win, attrs ^ WA_REVERSE, pair, NULL); waddch(win, '^'); waddch(win, TECO_CTL_ECHO(*str)); } else { @@ -126,7 +126,7 @@ teco_curses_format_str(WINDOW *win, const gchar *str, gsize len, gint max_width) waddnstr(win, str, clen); } } - /* restore original state of A_REVERSE */ + /* restore original state of WA_REVERSE */ wattr_set(win, attrs, pair, NULL); str += clen; diff --git a/src/interface-curses/curses-utils.h b/src/interface-curses/curses-utils.h index 97fc1cc..c6d9d8d 100644 --- a/src/interface-curses/curses-utils.h +++ b/src/interface-curses/curses-utils.h @@ -27,15 +27,12 @@ guint teco_curses_format_str(WINDOW *win, const gchar *str, gsize len, gint max_ guint teco_curses_format_filename(WINDOW *win, const gchar *filename, gint max_width); -/** - * Add Unicode character to window. - * This is just like wadd_wch(), but does not require wide-char APIs. - */ +/** Add Unicode character to window. */ static inline void teco_curses_add_wc(WINDOW *win, gunichar chr) { - gchar buf[6]; - waddnstr(win, buf, g_unichar_to_utf8(chr, buf)); + wchar_t wc = chr; + waddnwstr(win, &wc, 1); } /** diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c index 4f00bcf..6863a3b 100644 --- a/src/interface-curses/interface.c +++ b/src/interface-curses/interface.c @@ -244,7 +244,7 @@ static struct { static gshort teco_color_pair(attr_t *attr, gshort fg, gshort bg) { - static gshort next_pair = 1; + static guint next_pair = 1; /* * Basic support for monochrome terminals: @@ -255,7 +255,7 @@ teco_color_pair(attr_t *attr, gshort fg, gshort bg) */ if (!has_colors()) { if (bg != COLOR_BLACK) - *attr |= A_REVERSE; + *attr |= WA_REVERSE; return 0; } @@ -264,7 +264,7 @@ teco_color_pair(attr_t *attr, gshort fg, gshort bg) gpointer value = g_hash_table_lookup(teco_interface.pair_table, key); if (G_LIKELY(value != NULL)) return GPOINTER_TO_UINT(value); - if (G_UNLIKELY(next_pair >= MIN(COLOR_PAIRS, G_MAXSHORT))) + if (G_UNLIKELY(next_pair >= MIN(COLOR_PAIRS, G_MAXSHORT+1))) return 0; init_pair(next_pair, fg, bg); g_hash_table_insert(teco_interface.pair_table, key, GUINT_TO_POINTER(next_pair)); @@ -443,7 +443,7 @@ teco_interface_init(gint argc, gchar **argv) teco_cmdline_init(); /* * The default INDIC_STRIKE wouldn't be visible. - * Instead we use INDIC_SQUIGGLE, which is rendered as A_UNDERLINE. + * Instead we use INDIC_SQUIGGLE, which is rendered as WA_UNDERLINE. */ teco_cmdline_ssm(SCI_INDICSETSTYLE, INDICATOR_RUBBEDOUT, INDIC_SQUIGGLE); /* |
