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. --- src/interface-curses/interface.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') 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