Fix kitty-tool @ send-text not processing ANSI escapes

This commit is contained in:
Kovid Goyal 2022-11-25 21:09:51 +05:30
parent f9a22d0bc7
commit 15a7aeff4d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -7,6 +7,8 @@ import (
"errors"
"io"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"kitty/tools/utils/shlex"
"os"
"strings"
)
@ -19,13 +21,16 @@ func parse_send_text(io_data *rc_io_data, args []string) error {
generators := make([]func(io_data *rc_io_data) (bool, error), 0, 1)
if len(args) > 0 {
for i, arg := range args {
args[i] = shlex.ExpandANSICEscapes(arg)
}
text := strings.Join(args, " ")
text_gen := func(io_data *rc_io_data) (bool, error) {
limit := len(text)
if limit > 2048 {
limit = 2048
}
set_payload_data(io_data, "text:"+text[:limit])
set_payload_data(io_data, "base64:"+base64.StdEncoding.EncodeToString(utils.UnsafeStringToBytes(text[:limit])))
text = text[limit:]
return len(text) == 0, nil
}