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
|
map ctrl+alt+a send_text all Special text
|
||||||
|
|
||||||
This will send "Special text" when you press the :kbd:`Ctrl+Alt+A` key
|
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
|
combination. The text to be sent decodes :link:`ANSI C escapes <https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html>`
|
||||||
escapes like :code:`\\\\x1b` to send control codes or :code:`\\\\u21fb` to send
|
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
|
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
|
UTF-8 text). You can use ``kitty +kitten show_key`` to get the key escape
|
||||||
codes you want to emulate.
|
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:
|
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')
|
@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:
|
def paste_parse(func: str, rest: str) -> FuncArgsType:
|
||||||
text = ''
|
text = ''
|
||||||
try:
|
try:
|
||||||
text = python_string(rest)
|
text = defines.expand_ansi_c_escapes(rest)
|
||||||
except Exception:
|
except Exception:
|
||||||
log_error('Ignoring invalid paste string: ' + rest)
|
log_error('Ignoring invalid paste string: ' + rest)
|
||||||
return func, [text]
|
return func, [text]
|
||||||
|
|||||||
@ -74,8 +74,9 @@ class SendText(RemoteCommand):
|
|||||||
short_desc = 'Send arbitrary text to specified windows'
|
short_desc = 'Send arbitrary text to specified windows'
|
||||||
desc = (
|
desc = (
|
||||||
'Send arbitrary text to specified windows. The text follows Python'
|
'Send arbitrary text to specified windows. The text follows Python'
|
||||||
' escaping rules. So you can use escapes like :code:`\\\\x1b` to send control codes'
|
' escaping rules. So you can use :link:`escapes <https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html>`'
|
||||||
' and :code:`\\\\u21fa` to send unicode characters. If you use the :option:`kitty @ send-text --match` option'
|
' 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'
|
' the text will be sent to all matched windows. By default, text is sent to'
|
||||||
' only the currently active window.'
|
' only the currently active window.'
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1547,7 +1547,7 @@ class Window:
|
|||||||
def show_last_non_empty_command_output(self) -> None:
|
def show_last_non_empty_command_output(self) -> None:
|
||||||
self.show_cmd_output(CommandOutput.last_non_empty, 'Last non-empty command output')
|
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:
|
def paste(self, text: str) -> None:
|
||||||
self.paste_with_actions(text)
|
self.paste_with_actions(text)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user