summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Geier <geier@lostpackets.de>2017-03-03 19:11:53 +0000
committerChristian Geier <geier@lostpackets.de>2017-03-06 10:52:25 +0000
commitac0818b2a3fc89087be308b00176d1609ffb3562 (patch)
treeab51534279174124c828e6806139901c9e159f7b
parenta7b3cc6060743feaae4b13dd667696160b88e1ca (diff)
FIX (ikhal): show current keybindings in help
This solution is much less elegant than the original one, as it always shows all keybindings, but at least it shows the currently used ones.
-rw-r--r--CHANGELOG.rst1
-rw-r--r--khal/ui/__init__.py19
-rw-r--r--khal/ui/base.py57
3 files changed, 22 insertions, 55 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index b90a2bd9..77e47cc3 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -23,6 +23,7 @@ not released yet
* FIX `at`'s default header will now show the datetime quried for (instead of
just the date)
* FIX validate vdir metadata in color files
+* FIX show the actually configured keybindings in ikhal
* NEW khal will now show cancelled events with a big CANCELLED in front (can be
configured via event formatting)
diff --git a/khal/ui/__init__.py b/khal/ui/__init__.py
index 254f7bf8..9382d506 100644
--- a/khal/ui/__init__.py
+++ b/khal/ui/__init__.py
@@ -735,7 +735,6 @@ class EventColumn(urwid.WidgetWrap):
('weight', 1, ContainerWidget(self.dlistbox))
], dividechars=0, focus_column=0)
new_pane.title = editor.title
- new_pane.get_keys = editor.get_keys
def teardown(data):
self.editor = False
@@ -1064,11 +1063,6 @@ class EventEditor(urwid.WidgetWrap):
def title(self): # Window title
return 'Edit: {}'.format(self.summary.get_edit_text())
- def get_keys(self):
- return [(['arrowsu'], 'navigate through properties'),
- (['enter'], 'edit property'),
- (['esc'], 'abort')]
-
@classmethod
def selectable(cls):
return True
@@ -1357,6 +1351,7 @@ class ClassicView(Pane):
columns,
title="Search results for \"{}\" (Esc for backtrack)".format(search_term),
)
+ pane._conf = self._conf
columns.set_focus_column(1)
self.window.open(pane)
@@ -1368,18 +1363,6 @@ class ClassicView(Pane):
self.init = False
return rval
- def get_keys(self):
- """return all bound keys"""
- # FIXME show current bindings
- return [(['arrows'], 'navigate through the calendar'),
- (['t'], 're-focus on today'),
- (['enter', 'tab'], 'select a date/event, show/edit event'),
- (['n'], 'create event on selected day'),
- (['d'], 'delete selected event'),
- (['e'], 'export selected event'),
- (['q', 'esc'], 'previous pane/quit'),
- ]
-
def new_event(self, date, end):
"""create a new event starting on date and ending on end (if given)"""
self.eventscolumn.original_widget.new(date, end)
diff --git a/khal/ui/base.py b/khal/ui/base.py
index 72b5229b..d8cbde1f 100644
--- a/khal/ui/base.py
+++ b/khal/ui/base.py
@@ -46,27 +46,14 @@ class Pane(urwid.WidgetWrap):
def title(self):
return self._title
+ def selectable(self):
+ """mark this widget as selectable"""
+ return True
+
@property
def description(self):
return self._description
- def get_keys(self):
- """Return a description of the keystrokes recognized by this pane.
-
- This method returns a list of tuples describing the keys
- handled by a pane. This list is used to build a contextual
- pane help. Each tuple is a pair of a list of keys and a
- description.
-
- The abstract pane returns the default keys handled by the
- window. Panes which do not override these keys should extend
- this list.
- """
- return [(['up', 'down', 'pg.up', 'pg.down'],
- 'navigate through the fields.'),
- (['esc'], 'backtrack to the previous pane.'),
- (['F1', '?'], 'open this pane help.')]
-
def dialog(self, text, buttons):
"""Open a dialog box.
@@ -87,26 +74,23 @@ class Pane(urwid.WidgetWrap):
overlay = urwid.Overlay(content, self, 'center', ('relative', 70), ('relative', 70), None)
self.window.open(overlay)
+ def keypress(self, size, key):
+ """Handle application-wide key strokes."""
+ if key in ['f1', '?']:
+ self.show_keybindings()
+ else:
+ return super().keypress(size, key)
-class HelpPane(Pane):
-
- """A contextual help screen."""
-
- def __init__(self, pane):
- content = []
- for key_list, description in pane.get_keys():
- key_text = []
- for key in key_list:
- if key_text:
- key_text.append(', ')
- key_text.append(('bright', key))
- content.append(
- urwid.Columns(
- [urwid.Padding(urwid.Text(key_text), left=10),
- urwid.Padding(urwid.Text(description), right=10)]))
+ def show_keybindings(self):
+ lines = list()
+ lines.append(' Command Keys')
+ lines.append(' ======= ====')
+ for command, keys in self._conf['keybindings'].items():
+ lines.append(' {:20} {}'.format(command, keys))
+ lines.append('')
+ lines.append("Press `Escape` to close this window")
- Pane.__init__(self, urwid.ListBox(urwid.SimpleListWalker(content)),
- 'Help')
+ self.dialog('\n'.join(lines), [])
class Window(urwid.Frame):
@@ -178,8 +162,7 @@ class Window(urwid.Frame):
self.backtrack()
elif key == 'esc' and not self.is_top_level():
self.backtrack()
- elif key in ['f1', '?']:
- self.open(HelpPane(self._get_current_pane()))
+ return key
def _update(self, pane):
self.set_body(pane)