Commit 52a04262 authored by Jacek Sowiński's avatar Jacek Sowiński

Give access to keymap of "column_actions"

Action names and default config for them:

```ini
[column_keymap]
0 = first_column
$ = last_column
h = prev_column
l = next_column
A = append_column
I = insert_column
E = edit_column
D = delete_column
Y = copy_column
L = swap_left
R = swap_right
```
parent 84110a3c
......@@ -77,3 +77,14 @@ x = cmd do {}
pp = postpone
ps = postpone_s
pr = pri
0 = first_column
$ = last_column
h = prev_column
l = next_column
A = append_column
I = insert_column
E = edit_column
D = delete_column
Y = copy_column
L = swap_left
R = swap_right
......@@ -124,7 +124,18 @@ class _Config:
'x': 'cmd do {}',
'pp': 'postpone',
'ps': 'postpone_s',
'pr': 'pri'
'pr': 'pri',
'0': 'first_column',
'$': 'last_column',
'h': 'prev_column',
'l': 'next_column',
'A': 'append_column',
'I': 'insert_column',
'E': 'edit_column',
'D': 'delete_column',
'Y': 'copy_column',
'L': 'swap_left',
'R': 'swap_right',
},
}
......
......@@ -232,22 +232,28 @@ class UIApplication(CLIApplicationBase):
self.column_mode = _COPY_COLUMN
self._viewwidget_visible = True
def _column_action_handler(self, p_action):
dispatch = {
'first_column': self._focus_first_column,
'last_column': self._focus_last_column,
'prev_column': self._focus_previous_column,
'next_column': self._focus_next_column,
'append_column': self._append_column,
'insert_column': self._insert_column,
'edit_column': self._edit_column,
'delete_column': self._delete_column,
'copy_column': self._copy_column,
'swap_left': self._swap_column_left,
'swap_right': self._swap_column_right,
}
dispatch[p_action]()
def _handle_input(self, p_input):
dispatch = {
':': self._focus_commandline,
'0': self._focus_first_column,
'$': self._focus_last_column,
'left': self._focus_previous_column,
'h': self._focus_previous_column,
'right': self._focus_next_column,
'l': self._focus_next_column,
'A': self._append_column,
'I': self._insert_column,
'E': self._edit_column,
'D': self._delete_column,
'Y': self._copy_column,
'L': self._swap_column_left,
'R': self._swap_column_right,
}
try:
......@@ -303,6 +309,7 @@ class UIApplication(CLIApplicationBase):
urwid.connect_signal(todolist, 'refresh', self.mainloop.screen.clear)
urwid.connect_signal(todolist, 'add_pending_action', self._set_alarm)
urwid.connect_signal(todolist, 'remove_pending_action', self._remove_alarm)
urwid.connect_signal(todolist, 'column_action', self._column_action_handler)
options = self.columns.options(
width_type='given',
......
......@@ -71,6 +71,7 @@ class TodoListWidget(urwid.LineBox):
'refresh',
'add_pending_action',
'remove_pending_action',
'column_action',
])
@property
......@@ -238,9 +239,27 @@ class TodoListWidget(urwid.LineBox):
Executes built-in action specified in p_action_str.
Currently supported actions are: 'up', 'down', 'home', 'end',
'postpone', 'postpone_s' and 'pri'.
'first_column', 'last_column', 'prev_column', 'next_column',
'append_column', 'insert_column', 'edit_column', 'delete_column',
'copy_column', swap_right', 'swap_left', 'postpone', 'postpone_s' and
'pri'.
"""
if p_action_str in ['up', 'down']:
column_actions = ['first_column',
'last_column',
'prev_column',
'next_column',
'append_column',
'insert_column',
'edit_column',
'delete_column',
'copy_column',
'swap_left',
'swap_right',
]
if p_action_str in column_actions:
urwid.emit_signal(self, 'column_action', p_action_str)
elif p_action_str in ['up', 'down']:
self.listbox.keypress(p_size, p_action_str)
elif p_action_str == 'home':
self._scroll_to_top(p_size)
......
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