Fix key handling in diff kitten

This commit is contained in:
Kovid Goyal 2021-01-15 09:48:11 +05:30
parent 66341111e6
commit 9c6ba213f9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 4 additions and 4 deletions

View File

@ -93,7 +93,7 @@ class DiffHandler(Handler):
self.highlighting_done = False
self.restore_position: Optional[Reference] = None
for key_def, action in self.opts.key_definitions.items():
self.add_shortcut(action, *key_def)
self.add_shortcut(action, key_def)
def perform_action(self, action: KittensKeyAction) -> None:
func, args = action

View File

@ -36,7 +36,6 @@ class Handler:
self.debug = debug
self.cmd = commander(self)
self._image_manager = image_manager
self._key_shortcuts: Dict[ParsedShortcut, KittensKeyActionType] = {}
@property
def image_manager(self) -> ImageManagerType:
@ -48,6 +47,8 @@ class Handler:
return self._tui_loop.asycio_loop
def add_shortcut(self, action: KittensKeyActionType, spec: Union[str, ParsedShortcut]) -> None:
if not hasattr(self, '_key_shortcuts'):
self._key_shortcuts: Dict[ParsedShortcut, KittensKeyActionType] = {}
if isinstance(spec, str):
from kitty.key_encoding import parse_shortcut
spec = parse_shortcut(spec)

View File

@ -277,14 +277,13 @@ class Loop:
pass
else:
self.handler.on_mouse(ev)
elif q == '~':
elif q in 'u~ABCDHFPQRS':
if csi == '200~':
self.in_bracketed_paste = True
return
elif csi == '201~':
self.in_bracketed_paste = False
return
elif q in 'u~ABCDHFPQRS':
try:
k = decode_key_event(csi[:-1], q)
except Exception: