From 792406e7fcb83d7caf17fbaccff11d4755fa9be9 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 12 Nov 2013 10:40:11 +0100 Subject: doc/tools/print_colors.py: more stable in unfriendly environments --- doc/tools/print_colors.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/doc/tools/print_colors.py b/doc/tools/print_colors.py index ce040b33..b3eba749 100755 --- a/doc/tools/print_colors.py +++ b/doc/tools/print_colors.py @@ -10,10 +10,18 @@ from curses import * @wrapper def main(win): def print_all_colors(attr): - for c in range(0, curses.COLORS): - init_pair(c, c, -1) - win.addstr(str(c) + ' ', color_pair(c) | attr) - use_default_colors() + for c in range(-1, curses.COLORS): + try: + init_pair(c, c, 0) + except: + pass + else: + win.addstr(str(c) + ' ', color_pair(c) | attr) + start_color() + try: + use_default_colors() + except: + pass win.addstr("available colors: %d\n\n" % curses.COLORS) print_all_colors(0) win.addstr("\n\n") -- cgit 1.4.1-2-gfad0