aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2026-02-02 18:11:44 +0100
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2026-02-02 18:11:44 +0100
commitba2cf86f1889a334772aba56186a14150a96b2f3 (patch)
treed54b59495d0b4b051b83d26fba8747741258d67f /src
parentd0b9287ed3557efd11603afc30aa7781b03e262a (diff)
fixup color pair support: updated Scinterm againHEADmaster-fmsbw-cimaster
This is for some minor cleanup.
Diffstat (limited to 'src')
-rw-r--r--src/interface-curses/interface.c8
1 files changed, 6 insertions, 2 deletions
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);
/*