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
84382659
Commit
84382659
authored
Jan 02, 2016
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #95 from mruwek/column-ui-keys
New key-shortcuts for column-ui
parents
a531f5ff
4330421b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
6 deletions
+87
-6
topydo/ui/Main.py
topydo/ui/Main.py
+1
-0
topydo/ui/TodoListWidget.py
topydo/ui/TodoListWidget.py
+86
-6
No files found.
topydo/ui/Main.py
View file @
84382659
...
@@ -258,6 +258,7 @@ class UIApplication(CLIApplicationBase):
...
@@ -258,6 +258,7 @@ class UIApplication(CLIApplicationBase):
no_output
=
lambda
_
:
None
no_output
=
lambda
_
:
None
urwid
.
connect_signal
(
todolist
,
'execute_command'
,
urwid
.
connect_signal
(
todolist
,
'execute_command'
,
lambda
cmd
:
self
.
_execute_handler
(
cmd
,
no_output
))
lambda
cmd
:
self
.
_execute_handler
(
cmd
,
no_output
))
urwid
.
connect_signal
(
todolist
,
'refresh'
,
self
.
mainloop
.
screen
.
clear
)
options
=
self
.
columns
.
options
(
options
=
self
.
columns
.
options
(
width_type
=
'given'
,
width_type
=
'given'
,
...
...
topydo/ui/TodoListWidget.py
View file @
84382659
...
@@ -24,6 +24,8 @@ class TodoListWidget(urwid.LineBox):
...
@@ -24,6 +24,8 @@ class TodoListWidget(urwid.LineBox):
# store a state for multi-key shortcuts (e.g. 'gg')
# store a state for multi-key shortcuts (e.g. 'gg')
self
.
keystate
=
None
self
.
keystate
=
None
# store offset length for postpone command (e.g. '3' for 'p3w')
self
.
_pp_offset
=
''
self
.
_title_widget
=
urwid
.
Text
(
p_title
,
align
=
'center'
)
self
.
_title_widget
=
urwid
.
Text
(
p_title
,
align
=
'center'
)
...
@@ -41,7 +43,7 @@ class TodoListWidget(urwid.LineBox):
...
@@ -41,7 +43,7 @@ class TodoListWidget(urwid.LineBox):
super
().
__init__
(
pile
)
super
().
__init__
(
pile
)
urwid
.
register_signal
(
TodoListWidget
,
[
'execute_command'
])
urwid
.
register_signal
(
TodoListWidget
,
[
'execute_command'
,
'refresh'
])
@
property
@
property
def
view
(
self
):
def
view
(
self
):
...
@@ -107,9 +109,41 @@ class TodoListWidget(urwid.LineBox):
...
@@ -107,9 +109,41 @@ class TodoListWidget(urwid.LineBox):
# make sure to accept normal shortcuts again
# make sure to accept normal shortcuts again
self
.
keystate
=
None
self
.
keystate
=
None
return
return
elif
self
.
keystate
in
[
'p'
,
'ps'
]:
if
p_key
not
in
[
'd'
,
'w'
,
'm'
,
'y'
]:
if
p_key
.
isdigit
():
self
.
_pp_offset
+=
p_key
elif
self
.
keystate
==
'p'
and
p_key
==
's'
:
self
.
keystate
=
'ps'
else
:
self
.
_pp_offset
=
''
self
.
keystate
=
None
else
:
self
.
_postpone_selected_item
(
p_key
)
self
.
_pp_offset
=
''
self
.
keystate
=
None
return
elif
self
.
keystate
==
'r'
:
if
p_key
.
isalpha
():
self
.
_pri_selected_item
(
p_key
)
self
.
keystate
=
None
return
if
p_key
==
'x'
:
if
p_key
==
'x'
:
self
.
_complete_selected_item
()
self
.
_complete_selected_item
()
elif
p_key
==
'p'
:
self
.
keystate
=
'p'
elif
p_key
==
'd'
:
self
.
_remove_selected_item
()
elif
p_key
==
'e'
:
self
.
_edit_selected_item
()
# force screen redraw after editing
urwid
.
emit_signal
(
self
,
'refresh'
)
elif
p_key
==
'r'
:
self
.
keystate
=
'r'
elif
p_key
==
'u'
:
urwid
.
emit_signal
(
self
,
'execute_command'
,
"revert"
)
elif
p_key
==
'j'
:
elif
p_key
==
'j'
:
self
.
listbox
.
keypress
(
p_size
,
'down'
)
self
.
listbox
.
keypress
(
p_size
,
'down'
)
elif
p_key
==
'k'
:
elif
p_key
==
'k'
:
...
@@ -126,16 +160,62 @@ class TodoListWidget(urwid.LineBox):
...
@@ -126,16 +160,62 @@ class TodoListWidget(urwid.LineBox):
def
selectable
(
self
):
def
selectable
(
self
):
return
True
return
True
def
_com
plete_selected_item
(
self
):
def
_com
mand_on_selected
(
self
,
p_cmd_str
):
"""
"""
Marks the highlighted todo item as complete.
Executes command specified by p_cmd_str on selected todo item.
p_cmd_str should be string with one replacement field ('{}') which will
be substituted by id of selected todo item.
"""
"""
try
:
try
:
todo
=
self
.
listbox
.
focus
.
todo
todo
=
self
.
listbox
.
focus
.
todo
self
.
view
.
todolist
.
number
(
todo
)
todo_id
=
str
(
self
.
view
.
todolist
.
number
(
todo
)
)
urwid
.
emit_signal
(
self
,
'execute_command'
,
"do {}"
.
format
(
urwid
.
emit_signal
(
self
,
'execute_command'
,
p_cmd_str
.
format
(
todo_id
))
str
(
self
.
view
.
todolist
.
number
(
todo
))))
except
AttributeError
:
except
AttributeError
:
# No todo item selected
# No todo item selected
pass
pass
def
_complete_selected_item
(
self
):
"""
Marks the highlighted todo item as complete.
"""
self
.
_command_on_selected
(
'do {}'
)
def
_postpone_selected_item
(
self
,
p_pattern
):
"""
Postpones highlighted todo item by p_pattern with optional offset from
_pp_offset attribute.
"""
if
self
.
_pp_offset
==
''
:
self
.
_pp_offset
=
'1'
pattern
=
self
.
_pp_offset
+
p_pattern
if
self
.
keystate
==
'ps'
:
cmd_str
=
'postpone -s {t_id} {pattern}'
.
format
(
t_id
=
'{}'
,
pattern
=
pattern
)
else
:
cmd_str
=
'postpone {t_id} {pattern}'
.
format
(
t_id
=
'{}'
,
pattern
=
pattern
)
self
.
_command_on_selected
(
cmd_str
)
def
_remove_selected_item
(
self
):
"""
Removes the highlighted todo item.
"""
self
.
_command_on_selected
(
'del {}'
)
def
_edit_selected_item
(
self
):
"""
Opens the highlighted todo item in $EDITOR for editing.
"""
self
.
_command_on_selected
(
'edit {}'
)
def
_pri_selected_item
(
self
,
p_priority
):
"""
Sets the priority of the highlighted todo item with value from
p_priority.
"""
cmd_str
=
'pri {t_id} {priority}'
.
format
(
t_id
=
'{}'
,
priority
=
p_priority
)
self
.
_command_on_selected
(
cmd_str
)
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