mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
send_text other than from stdin works
This commit is contained in:
@@ -87,6 +87,14 @@ type wrapped_serializer struct {
|
||||
all_payloads_done bool
|
||||
}
|
||||
|
||||
func debug_to_log(args ...interface{}) {
|
||||
f, err := os.OpenFile("/tmp/kdlog", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
|
||||
if err == nil {
|
||||
fmt.Fprintln(f, args...)
|
||||
f.Close()
|
||||
}
|
||||
}
|
||||
|
||||
func (self *wrapped_serializer) next(io_data *rc_io_data) ([]byte, error) {
|
||||
const prefix = "\x1bP@kitty-cmd"
|
||||
const suffix = "\x1b\\"
|
||||
@@ -197,6 +205,7 @@ func get_response(do_io func(io_data *rc_io_data) ([]byte, error), io_data *rc_i
|
||||
if errors.Is(err, os.ErrDeadlineExceeded) {
|
||||
io_data.rc.Payload = nil
|
||||
io_data.rc.CancelAsync = true
|
||||
io_data.multiple_payload_generator = nil
|
||||
io_data.rc.NoResponse = true
|
||||
io_data.serializer.state = 0
|
||||
do_io(io_data)
|
||||
|
||||
@@ -10,16 +10,18 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type generator_function func(io_data *rc_io_data) (bool, error)
|
||||
|
||||
func parse_send_text(io_data *rc_io_data, args []string) error {
|
||||
generators := make([]generator_function, 0, 1)
|
||||
generators := make([]func(io_data *rc_io_data) (bool, error), 0, 1)
|
||||
|
||||
if len(args) > 0 {
|
||||
text := strings.Join(args, " ")
|
||||
text_gen := func(io_data *rc_io_data) (bool, error) {
|
||||
set_payload_data(io_data, "text:"+text[:2048])
|
||||
text = text[2048:]
|
||||
limit := len(text)
|
||||
if limit > 2048 {
|
||||
limit = 2048
|
||||
}
|
||||
set_payload_data(io_data, "text:"+text[:limit])
|
||||
text = text[limit:]
|
||||
return len(text) == 0, nil
|
||||
}
|
||||
generators = append(generators, text_gen)
|
||||
|
||||
Reference in New Issue
Block a user