Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
a46cb090
Commit
a46cb090
authored
Jul 05, 2015
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Give todo items the color according to their priority.
parent
c8131432
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
3 deletions
+61
-3
topydo/ui/Colors.py
topydo/ui/Colors.py
+36
-0
topydo/ui/TodoWidget.py
topydo/ui/TodoWidget.py
+25
-3
No files found.
topydo/ui/Colors.py
0 → 100644
View file @
a46cb090
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
""" Provides color support suitable for urwid. """
COLOR_MAP
=
{
'black'
:
'black'
,
'red'
:
'dark red'
,
'green'
:
'dark green'
,
'yellow'
:
'brown'
,
'blue'
:
'dark blue'
,
'magenta'
:
'dark magenta'
,
'cyan'
:
'dark cyan'
,
'gray'
:
'light gray'
,
'darkgray'
:
'dark gray'
,
'light-red'
:
'light red'
,
'light-green'
:
'light green'
,
'light-yellow'
:
'yellow'
,
'light-blue'
:
'light blue'
,
'light-magenta'
:
'light magenta'
,
'light-cyan'
:
'light cyan'
,
'white'
:
'white'
,
}
topydo/ui/TodoWidget.py
View file @
a46cb090
...
@@ -16,6 +16,9 @@
...
@@ -16,6 +16,9 @@
from
six
import
text_type
,
u
from
six
import
text_type
,
u
from
topydo.lib.Config
import
config
from
topydo.ui.Colors
import
COLOR_MAP
import
urwid
import
urwid
class
TodoWidget
(
urwid
.
WidgetWrap
):
class
TodoWidget
(
urwid
.
WidgetWrap
):
...
@@ -32,8 +35,8 @@ class TodoWidget(urwid.WidgetWrap):
...
@@ -32,8 +35,8 @@ class TodoWidget(urwid.WidgetWrap):
# strip the first characters off
# strip the first characters off
todo_text
=
todo_text
[
4
:]
todo_text
=
todo_text
[
4
:]
priority_widget
=
urwid
.
Text
(
priority_text
)
id_widget
=
urwid
.
Text
(
text_type
(
p_number
),
align
=
'right'
)
id_widget
=
urwid
.
Text
(
text_type
(
p_number
),
align
=
'right'
)
priority_widget
=
urwid
.
Text
(
priority_text
)
self
.
text_widget
=
urwid
.
Text
(
todo_text
)
self
.
text_widget
=
urwid
.
Text
(
todo_text
)
self
.
columns
=
urwid
.
Columns
(
self
.
columns
=
urwid
.
Columns
(
...
@@ -45,11 +48,30 @@ class TodoWidget(urwid.WidgetWrap):
...
@@ -45,11 +48,30 @@ class TodoWidget(urwid.WidgetWrap):
dividechars
=
1
dividechars
=
1
)
)
attr
=
urwid
.
AttrSpec
(
'black'
,
'light gray'
,
16
)
self
.
widget
=
urwid
.
AttrMap
(
self
.
widget
=
urwid
.
AttrMap
(
self
.
columns
,
{},
attr
)
self
.
columns
,
self
.
_markup
(
p_todo
,
False
),
# no focus
self
.
_markup
(
p_todo
,
True
)
# focus
)
super
(
TodoWidget
,
self
).
__init__
(
self
.
widget
)
super
(
TodoWidget
,
self
).
__init__
(
self
.
widget
)
def
_markup
(
self
,
p_todo
,
p_focus
):
priority_colors
=
config
().
priority_colors
()
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
]
except
KeyError
:
fg_color
=
'black'
if
p_focus
else
'default'
bg_color
=
'light gray'
if
p_focus
else
'default'
return
urwid
.
AttrSpec
(
fg_color
,
bg_color
,
16
)
def
keypress
(
self
,
p_size
,
p_key
):
def
keypress
(
self
,
p_size
,
p_key
):
"""
"""
Override keypress to prevent the wrapped Columns widget to
Override keypress to prevent the wrapped Columns widget to
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment