From ba2cf86f1889a334772aba56186a14150a96b2f3 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 2 Feb 2026 18:11:44 +0100 Subject: fixup color pair support: updated Scinterm again This is for some minor cleanup. --- contrib/scinterm | 2 +- src/interface-curses/interface.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/contrib/scinterm b/contrib/scinterm index 5a89baa..03310b9 160000 --- a/contrib/scinterm +++ b/contrib/scinterm @@ -1 +1 @@ -Subproject commit 5a89baa751e2655f3f11be90c2130e19244acf05 +Subproject commit 03310b95bdd5b8500e281ce9066d109ccaaaf25c diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c index 6863a3b..45821f9 100644 --- a/src/interface-curses/interface.c +++ b/src/interface-curses/interface.c @@ -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+1))) + if (G_UNLIKELY(next_pair >= COLOR_PAIRS || next_pair > G_MAXSHORT)) return 0; init_pair(next_pair, fg, bg); g_hash_table_insert(teco_interface.pair_table, key, GUINT_TO_POINTER(next_pair)); @@ -746,7 +746,11 @@ teco_interface_init_interactive(GError **error) teco_interface.pair_table = g_hash_table_new(g_direct_hash, g_direct_equal); start_color(); - /* Scinterm uses shorts for color pairs, so G_MAXSHORT is the maximum */ + /* + * Scinterm uses shorts for color pairs, so G_MAXSHORT is the maximum. + * Some Curses implementations (NetBSD, PDCurses) may support less, + * but set COLOR_PAIRS accordingly. + */ scintilla_set_color_offsets(0, MIN(COLOR_PAIRS, G_MAXSHORT)/2); /* -- cgit v1.2.3