Work on porting kittens to use new key infrastructure

Also move type definitions into their own module
This commit is contained in:
Kovid Goyal
2021-01-14 21:35:48 +05:30
parent 0714fd376b
commit 027c5a57f1
30 changed files with 524 additions and 721 deletions

View File

@@ -8,9 +8,9 @@ import sys
from typing import TYPE_CHECKING, Dict, Generator, List, Optional
from kitty.config import parse_send_text_bytes
from kitty.key_encoding import (
WindowSystemKeyEvent, decode_key_event_as_window_system_key
)
from kitty.key_encoding import decode_key_event_as_window_system_key
from kitty.fast_data_types import KeyEvent as WindowSystemKeyEvent
from .base import (
MATCH_TAB_OPTION, MATCH_WINDOW_OPTION, ArgsType, Boss, MatchError,
PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType,
@@ -145,7 +145,8 @@ Do not send text to the active window, even if it is one of the matched windows.
elif encoding == 'base64':
data = base64.standard_b64decode(q)
elif encoding == 'kitty-key':
data = decode_key_event_as_window_system_key(q)
data = base64.standard_b64decode(q)
data = decode_key_event_as_window_system_key(data)
else:
raise TypeError(f'Invalid encoding for send-text data: {encoding}')
exclude_active = payload_get('exclude_active')
@@ -153,7 +154,7 @@ Do not send text to the active window, even if it is one of the matched windows.
if window is not None:
if not exclude_active or window is not boss.active_window:
if isinstance(data, WindowSystemKeyEvent):
kdata = window.encoded_key(data.code, mods=data.mods, action=data.action)
kdata = window.encoded_key(data)
if kdata:
window.write_to_child(kdata)
else: