Commit 7eca1de9 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Merge pull request #91 from mruwek/column-ui-256color

Switch column-ui to 256 color-mode
parents 78850e9f 8fadc4b5
...@@ -34,3 +34,17 @@ COLOR_MAP = { ...@@ -34,3 +34,17 @@ COLOR_MAP = {
'light-cyan': 'light cyan', 'light-cyan': 'light cyan',
'white': 'white', '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
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from topydo.lib.Config import config from topydo.lib.Config import config
from topydo.ui.Colors import COLOR_MAP from topydo.ui.Colors import color_map256
import urwid import urwid
...@@ -56,19 +56,20 @@ class TodoWidget(urwid.WidgetWrap): ...@@ -56,19 +56,20 @@ class TodoWidget(urwid.WidgetWrap):
def _markup(self, p_todo, p_focus): def _markup(self, p_todo, p_focus):
priority_colors = config().priority_colors() priority_colors = config().priority_colors()
color_map = color_map256()
try: try:
# retrieve the assigned value in the config file # retrieve the assigned value in the config file
fg_color = priority_colors[p_todo.priority()] fg_color = priority_colors[p_todo.priority()]
# convert to a color that urwid understands # convert to a color that urwid understands
fg_color = COLOR_MAP[fg_color] fg_color = color_map[fg_color]
except KeyError: except KeyError:
fg_color = 'black' if p_focus else 'default' fg_color = 'black' if p_focus else 'default'
bg_color = 'light gray' if p_focus else 'default' bg_color = 'light gray' if p_focus else 'default'
return urwid.AttrSpec(fg_color, bg_color, 16) return urwid.AttrSpec(fg_color, bg_color, 256)
def keypress(self, p_size, p_key): def keypress(self, p_size, p_key):
""" """
......
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