Commit 78f641b2 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Don't initialize the same color map over and over again.

Initialize it on startup and use that color map, instead of
instantiating it for every todo widget.
parent b6dcc13e
......@@ -35,16 +35,6 @@ COLOR_MAP = {
'white': 'white',
}
def color_map256():
"""
Returns dict where topydo colorscheme config values are linked to values
supported by urwid. 16 standard color names and 256-color indexes are
supported.
"""
color_map = dict()
for i in range(256):
color_map[str(i)] = 'h' + str(i)
color_map.update(COLOR_MAP)
return color_map
# Add 256 urwid-like colors
for i in range(256):
COLOR_MAP[str(i)] = 'h' + str(i)
......@@ -16,7 +16,7 @@
from topydo.lib.Config import config
from topydo.lib.ListFormat import ListFormatParser
from topydo.ui.Colors import color_map256
from topydo.ui.Colors import COLOR_MAP
import urwid
......@@ -31,14 +31,13 @@ def _markup(p_todo, p_focus):
"""
priority_colors = config().priority_colors()
color_map = color_map256()
try:
# retrieve the assigned value in the config file
fg_color = priority_colors[p_todo.priority()]
# convert to a color that urwid understands
fg_color = color_map[fg_color]
fg_color = COLOR_MAP[fg_color]
except KeyError:
fg_color = 'black' if p_focus else 'default'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment