From: Christian Heller Date: Sat, 26 Dec 2020 21:02:53 +0000 (+0100) Subject: Fix color changes breaking ncurses usage on some terminals. X-Git-Url: https://plomlompom.com/repos/?p=plomrogue2;a=commitdiff_plain;h=a2a99a46b65a881027d4724c4f2ecd23c2ba60ed Fix color changes breaking ncurses usage on some terminals. --- diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index 9d2ab3b..d6d8242 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -809,8 +809,9 @@ class TUI: self.restore_input_values() def set_default_colors(self): - curses.init_color(1, 1000, 1000, 1000) - curses.init_color(2, 0, 0, 0) + if curses.can_change_color(): + curses.init_color(7, 1000, 1000, 1000) + curses.init_color(0, 0, 0, 0) self.do_refresh = True def set_random_colors(self): @@ -819,8 +820,9 @@ class TUI: import random return int(offset + random.random()*375) - curses.init_color(1, rand(625), rand(625), rand(625)) - curses.init_color(2, rand(0), rand(0), rand(0)) + if curses.can_change_color(): + curses.init_color(7, rand(625), rand(625), rand(625)) + curses.init_color(0, rand(0), rand(0), rand(0)) self.do_refresh = True def get_info(self): @@ -1240,10 +1242,14 @@ class TUI: 'dance': 'DANCE', } - curses.curs_set(False) # hide cursor + curses.curs_set(0) # hide cursor curses.start_color() self.set_default_colors() - curses.init_pair(1, 1, 2) + curses.init_pair(1, 7, 0) + if not curses.can_change_color(): + self.log_msg('@ unfortunately, your terminal does not seem to ' + 'support re-definition of colors; you might miss out ' + 'on some color effects') stdscr.timeout(10) reset_screen_size() self.explorer = YX(0, 0)