From 0c8ed234bddcdc7c40edc049a9a941c1f0579149 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Thu, 3 Jan 2013 18:47:18 +0000 Subject: [PATCH] Cope with terminals that don't support colour Reported by Tim Cuthbertson. --- display.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/display.py b/display.py index cd185be..3cc697e 100644 --- a/display.py +++ b/display.py @@ -17,8 +17,8 @@ COLOURS = { 'WHITE' : 7, } -set_fg = curses.tigetstr('setf') or '' -normal = curses.tigetstr('sgr0') or '' +set_fg = curses.tigetstr('setf') or None +normal = curses.tigetstr('sgr0') or None def checking(msg, indent = 2): global cursor_pos @@ -49,4 +49,7 @@ def error_new_line(msg, colour = 'RED'): print highlight(msg, colour) def highlight(msg, colour): - return curses.tparm(set_fg, COLOURS[colour]) + msg + curses.tparm(normal) + if set_fg and normal: + return curses.tparm(set_fg, COLOURS[colour]) + msg + curses.tparm(normal) + else: + return msg -- 2.11.4.GIT