dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit 25df24414cd47c62bc72e0cf0ef223f156349331
parent 33764364dfc0e6de2e13e2d856cfa2254d558262
Author: Leonardo Taccari <iamleot@gmail.com>
Date:   Wed, 20 Jan 2016 12:13:39 +0100

vt: explicitly initialize all color pairs to (0, 0)

The NetBSD curses(3) library by default initializes all
color pairs to (7, 0) i.e. white text on black background.
In contrast with ncurses where pairs are initialized to (0, 0)
by default.

The NetBSD behaviour caused an infinite loop in vt_color_get
because all pairs were seemingly allocated to a reserved color
pair.

Diffstat:
vt.c | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/vt.c b/vt.c @@ -1827,6 +1827,14 @@ static void init_colors(void) color_pairs_max = MIN(COLOR_PAIRS, MAX_COLOR_PAIRS); if (COLORS) color2palette = calloc((COLORS + 2) * (COLORS + 2), sizeof(short)); + /* + * XXX: On undefined color-pairs NetBSD curses pair_content() set fg + * and bg to default colors while ncurses set them respectively to + * 0 and 0. Initialize all color-pairs in order to have consistent + * behaviour despite the implementation used. + */ + for (short i = 1; i < COLOR_PAIRS; i++) + init_pair(i, 0, 0); vt_color_reserve(COLOR_WHITE, COLOR_BLACK); }