Use ANSI C escapes rather than python string literals
This commit is contained in:
parent
ac60715ee2
commit
402c8b6803
@ -3968,8 +3968,8 @@ when pressing specified shortcut keys. For example::
|
||||
map ctrl+alt+a send_text all Special text
|
||||
|
||||
This will send "Special text" when you press the :kbd:`Ctrl+Alt+A` key
|
||||
combination. The text to be sent is a python string literal so you can use
|
||||
escapes like :code:`\\\\x1b` to send control codes or :code:`\\\\u21fb` to send
|
||||
combination. The text to be sent decodes :link:`ANSI C escapes <https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html>`
|
||||
so you can use escapes like :code:`\\\\x1b` to send control codes or :code:`\\\\u21fb` to send
|
||||
Unicode characters (or you can just input the Unicode characters directly as
|
||||
UTF-8 text). You can use ``kitty +kitten show_key`` to get the key escape
|
||||
codes you want to emulate.
|
||||
|
||||
@ -67,7 +67,7 @@ def shlex_parse(func: str, rest: str) -> FuncArgsType:
|
||||
|
||||
|
||||
def parse_send_text_bytes(text: str) -> bytes:
|
||||
return python_string(text).encode('utf-8')
|
||||
return defines.expand_ansi_c_escapes(text).encode('utf-8')
|
||||
|
||||
|
||||
@func_with_args('send_text')
|
||||
@ -204,7 +204,7 @@ def paste_from_buffer(func: str, rest: str) -> FuncArgsType:
|
||||
def paste_parse(func: str, rest: str) -> FuncArgsType:
|
||||
text = ''
|
||||
try:
|
||||
text = python_string(rest)
|
||||
text = defines.expand_ansi_c_escapes(rest)
|
||||
except Exception:
|
||||
log_error('Ignoring invalid paste string: ' + rest)
|
||||
return func, [text]
|
||||
|
||||
@ -74,8 +74,9 @@ class SendText(RemoteCommand):
|
||||
short_desc = 'Send arbitrary text to specified windows'
|
||||
desc = (
|
||||
'Send arbitrary text to specified windows. The text follows Python'
|
||||
' escaping rules. So you can use escapes like :code:`\\\\x1b` to send control codes'
|
||||
' and :code:`\\\\u21fa` to send unicode characters. If you use the :option:`kitty @ send-text --match` option'
|
||||
' escaping rules. So you can use :link:`escapes <https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html>`'
|
||||
' like :code:`\\\\x1b` to send control codes'
|
||||
' and :code:`\\\\u21fa` to send Unicode characters. If you use the :option:`kitty @ send-text --match` option'
|
||||
' the text will be sent to all matched windows. By default, text is sent to'
|
||||
' only the currently active window.'
|
||||
)
|
||||
|
||||
@ -1547,7 +1547,7 @@ class Window:
|
||||
def show_last_non_empty_command_output(self) -> None:
|
||||
self.show_cmd_output(CommandOutput.last_non_empty, 'Last non-empty command output')
|
||||
|
||||
@ac('cp', 'Paste the specified text into the current window')
|
||||
@ac('cp', 'Paste the specified text into the current window. ANSI C escapes are decoded.')
|
||||
def paste(self, text: str) -> None:
|
||||
self.paste_with_actions(text)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user