This commit is contained in:
Kovid Goyal 2022-12-12 16:49:18 +05:30
parent b6c6316b7b
commit 95e05ce9ec
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 10 additions and 2 deletions

View File

@ -28,7 +28,7 @@ class SetTabTitle(RemoteCommand):
' title of the currently active window in the tab is used.' ' title of the currently active window in the tab is used.'
) )
options_spec = MATCH_TAB_OPTION options_spec = MATCH_TAB_OPTION
args = RemoteCommand.Args(spec='TITLE ...', json_field='title') args = RemoteCommand.Args(spec='TITLE ...', json_field='title', special_parse='expand_ansi_c_escapes_in_args(args...)')
def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType: def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType:
return {'title': ' '.join(args), 'match': opts.match} return {'title': ' '.join(args), 'match': opts.match}

View File

@ -33,7 +33,7 @@ class SetWindowTitle(RemoteCommand):
By default, the title will be permanently changed and programs running in the window will not be able to change it By default, the title will be permanently changed and programs running in the window will not be able to change it
again. If you want to allow other programs to change it afterwards, use this option. again. If you want to allow other programs to change it afterwards, use this option.
''' + '\n\n' + MATCH_WINDOW_OPTION ''' + '\n\n' + MATCH_WINDOW_OPTION
args = RemoteCommand.Args(json_field='title', spec='[TITLE ...]') args = RemoteCommand.Args(json_field='title', spec='[TITLE ...]', special_parse='expand_ansi_c_escapes_in_args(args...)')
def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType: def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType:
ans = {'match': opts.match, 'temporary': opts.temporary} ans = {'match': opts.match, 'temporary': opts.temporary}

View File

@ -22,6 +22,7 @@ import (
"kitty/tools/tui" "kitty/tools/tui"
"kitty/tools/tui/loop" "kitty/tools/tui/loop"
"kitty/tools/utils" "kitty/tools/utils"
"kitty/tools/utils/shlex"
"github.com/jamesruan/go-rfc1924/base85" "github.com/jamesruan/go-rfc1924/base85"
) )
@ -35,6 +36,13 @@ type GlobalOptions struct {
var global_options GlobalOptions var global_options GlobalOptions
func expand_ansi_c_escapes_in_args(args ...string) (string, error) {
for i, x := range args {
args[i] = shlex.ExpandANSICEscapes(x)
}
return strings.Join(args, " "), nil
}
func set_payload_string_field(io_data *rc_io_data, field, data string) { func set_payload_string_field(io_data *rc_io_data, field, data string) {
payload_interface := reflect.ValueOf(&io_data.rc.Payload).Elem() payload_interface := reflect.ValueOf(&io_data.rc.Payload).Elem()
struct_in_interface := reflect.New(payload_interface.Elem().Type()).Elem() struct_in_interface := reflect.New(payload_interface.Elem().Type()).Elem()