Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable help close/cancel key #1584

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions alot/commands/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def apply(self, ui):
linewidgets.append(line)

body = urwid.ListBox(linewidgets)
titletext = 'Bindings Help (escape cancels)'
titletext = 'Bindings Help (%s cancels)' % settings.help_cancel_key

box = DialogBox(body, titletext,
bodyattr=text_att,
Expand All @@ -694,7 +694,7 @@ def apply(self, ui):
overlay = urwid.Overlay(box, ui.root_widget, 'center',
('relative', 70), 'middle',
('relative', 70))
ui.show_as_root_until_keypress(overlay, 'esc')
ui.show_as_root_until_keypress(overlay, settings.help_cancel_key)
else:
logging.debug('HELP %s', self.commandname)
parser = commands.lookup_parser(self.commandname, ui.mode)
Expand Down
3 changes: 3 additions & 0 deletions alot/defaults/default.bindings
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@ q = exit
'g h' = move parent
'g l' = move first reply
' ' = move next

[help]
esc = cancel
12 changes: 12 additions & 0 deletions alot/settings/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,3 +532,15 @@ def represent_datetime(self, d):
else:
rep = pretty_datetime(d)
return rep

@property
def help_cancel_key(self):
"""
Returns cancel key for help overlays
"""
if not hasattr(self, '__help_cancel_key'):
_, helpmap = self.get_keybindings('help')
helpmap = {v: k for k, v in helpmap.items()}
self.__help_cancel_key = helpmap.get('cancel', 'esc')

return self.__help_cancel_key
5 changes: 3 additions & 2 deletions alot/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,13 +628,14 @@ def clear(*_):

if block:
# put "cancel to continue" widget as overlay on main widget
txt = build_line('(escape continues)', priority)
txt = build_line('(%s continues)' % settings.help_cancel_key,
priority)
overlay = urwid.Overlay(txt, self.root_widget,
('fixed left', 0),
('fixed right', 0),
('fixed bottom', 0),
None)
self.show_as_root_until_keypress(overlay, 'esc',
self.show_as_root_until_keypress(overlay, settings.help_cancel_key,
afterwards=clear)
else:
if timeout >= 0:
Expand Down