Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Fixing color initialization. I assumed 16 colors were defined, but th…
Browse files Browse the repository at this point in the history
…at isn't standard on all terminals. Now only assuming the first 8.
  • Loading branch information
penrods authored and aatchison committed Feb 27, 2017
1 parent 6feac48 commit 49b1530
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions mycroft/client/text/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,26 +164,22 @@ def init_screen():
global CLR_LOG_DEBUG

if curses.has_colors():
bg = curses.COLOR_WHITE
for i in range(0, curses.COLORS):
curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
bg = curses.COLOR_BLACK
for i in range(1, curses.COLORS):
curses.init_pair(i + 1, i, bg)
bg = curses.COLOR_BLACK

# Colors:
# 1 = black on white 9 = dk gray
# 2 = dk red 10 = red
# 3 = dk green 11 = green
# 4 = dk yellow 12 = yellow
# 5 = dk blue 13 = blue
# 6 = dk purple 14 = purple
# 7 = dk cyan 15 = cyan
# 8 = lt gray 16 = white
CLR_HEADING = curses.color_pair(16)

# Colors (on black backgound):
# 1 = white 5 = dk blue
# 2 = dk red 6 = dk purple
# 3 = dk green 7 = dk cyan
# 4 = dk yellow 8 = lt gray
CLR_HEADING = curses.color_pair(1)
CLR_CHAT_RESP = curses.color_pair(7)
CLR_CHAT_QUERY = curses.color_pair(8)
CLR_CMDLINE = curses.color_pair(15)
CLR_INPUT = curses.color_pair(16)
CLR_LOG1 = curses.color_pair(8)
CLR_CHAT_QUERY = curses.color_pair(1)
CLR_CMDLINE = curses.color_pair(7)
CLR_INPUT = curses.color_pair(1)
CLR_LOG1 = curses.color_pair(3)
CLR_LOG2 = curses.color_pair(6)
CLR_LOG_DEBUG = curses.color_pair(4)

Expand Down Expand Up @@ -427,7 +423,9 @@ def main(stdscr):
except KeyboardInterrupt, e:
logger.exception(e)
finally:
print "quitting"
scr.clear()
scr.refresh()
scr = None
pass


Expand Down Expand Up @@ -475,3 +473,4 @@ def simple_cli():
simple_cli()
else:
curses.wrapper(main)
curses.endwin()

0 comments on commit 49b1530

Please sign in to comment.