mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-08-17 02:20:25 +03:00
Fix @ send-key not working to send keys to self over TTY
This commit is contained in:
parent
a3d8be5e2f
commit
c1af14c22a
@ -335,7 +335,6 @@ def go_declaration(self) -> str:
|
||||
|
||||
def go_code_for_remote_command(name: str, cmd: RemoteCommand, template: str) -> str:
|
||||
template = '\n' + template[len('//go:build exclude'):]
|
||||
NO_RESPONSE_BASE = 'false'
|
||||
af: List[str] = []
|
||||
a = af.append
|
||||
af.extend(cmd.args.as_go_completion_code('ans'))
|
||||
@ -405,13 +404,14 @@ def go_code_for_remote_command(name: str, cmd: RemoteCommand, template: str) ->
|
||||
argspec = cmd.args.spec
|
||||
if argspec:
|
||||
argspec = ' ' + argspec
|
||||
NO_RESPONSE = 'true' if cmd.disallow_responses else 'false'
|
||||
ans = replace(
|
||||
template,
|
||||
CMD_NAME=name, __FILE__=__file__, CLI_NAME=name.replace('_', '-'),
|
||||
SHORT_DESC=serialize_as_go_string(cmd.short_desc),
|
||||
LONG_DESC=serialize_as_go_string(cmd.desc.strip()),
|
||||
IS_ASYNC='true' if cmd.is_asynchronous else 'false',
|
||||
NO_RESPONSE_BASE=NO_RESPONSE_BASE, ADD_FLAGS_CODE='\n'.join(af),
|
||||
NO_RESPONSE_BASE=NO_RESPONSE, ADD_FLAGS_CODE='\n'.join(af),
|
||||
WAIT_TIMEOUT=str(cmd.response_timeout),
|
||||
OPTIONS_DECLARATION_CODE='\n'.join(od),
|
||||
JSON_DECLARATION_CODE='\n'.join(jd),
|
||||
|
@ -331,6 +331,7 @@ class RemoteCommand:
|
||||
argspec = args_count = args_completion = ArgsHandling()
|
||||
field_to_option_map: Optional[Dict[str, str]] = None
|
||||
reads_streaming_data: bool = False
|
||||
disallow_responses: bool = False
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.desc = self.desc or self.short_desc
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
|
||||
class SendKey(RemoteCommand):
|
||||
disallow_responses = True
|
||||
protocol_spec = __doc__ = '''
|
||||
keys+/list.str: The keys to send
|
||||
match/str: A string indicating the window to send text to
|
||||
@ -33,8 +34,12 @@ class SendKey(RemoteCommand):
|
||||
'Send arbitrary key presses to specified windows. All specified keys are sent first as press events'
|
||||
' then as release events in reverse order. Keys are sent to the programs running in the windows.'
|
||||
' They are sent only if the current keyboard mode for the program supports the particular key.'
|
||||
' For example: send-key ctrl+a ctrl+b'
|
||||
)
|
||||
' For example: send-key ctrl+a ctrl+b. Note that errors are not reported, for technical reasons,'
|
||||
' so send-key always succeeds, even if no key was sent to any window.'
|
||||
)
|
||||
# since send-key can send data over the tty to the window in which it was
|
||||
# run --no-reponse is always in effect for it, hence errors are not
|
||||
# reported.
|
||||
options_spec = MATCH_WINDOW_OPTION + '\n\n' + MATCH_TAB_OPTION.replace('--match -m', '--match-tab -t') + '''\n
|
||||
--all
|
||||
type=bool-set
|
||||
@ -54,11 +59,8 @@ def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: Arg
|
||||
def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType:
|
||||
windows = self.windows_for_payload(boss, None, payload_get, window_match_name='match')
|
||||
keys = payload_get('keys')
|
||||
sent = False
|
||||
for w in windows:
|
||||
if not w.send_key(*keys):
|
||||
sent = True
|
||||
sent
|
||||
w.send_key(*keys)
|
||||
return None
|
||||
|
||||
|
||||
|
@ -72,6 +72,7 @@ def __call__(self, window: Window, focused: bool) -> None:
|
||||
|
||||
|
||||
class SendText(RemoteCommand):
|
||||
disallow_responses = True
|
||||
protocol_spec = __doc__ = '''
|
||||
data+/str: The data being sent. Can be either: text: followed by text or base64: followed by standard base64 encoded bytes
|
||||
match/str: A string indicating the window to send text to
|
||||
|
@ -31,7 +31,6 @@ func make_file_gen(f *os.File) func(*rc_io_data) (bool, error) {
|
||||
|
||||
}
|
||||
func parse_send_text(io_data *rc_io_data, args []string) error {
|
||||
io_data.rc.NoResponse = true
|
||||
generators := make([]func(io_data *rc_io_data) (bool, error), 0, 1)
|
||||
|
||||
if len(args) > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user