debugprintln should be in-band for the loop

This commit is contained in:
Kovid Goyal 2022-08-31 15:27:08 +05:30
parent 5cc5759f3e
commit 6d6bba4a4c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -3,6 +3,8 @@
package loop package loop
import ( import (
"encoding/base64"
"fmt"
"kitty/tools/tty" "kitty/tools/tty"
"time" "time"
@ -132,7 +134,17 @@ func (self *Loop) KillIfSignalled() {
func (self *Loop) DebugPrintln(args ...interface{}) { func (self *Loop) DebugPrintln(args ...interface{}) {
if self.controlling_term != nil { if self.controlling_term != nil {
self.controlling_term.DebugPrintln(args...) const limit = 2048
msg := fmt.Sprintln(args...)
for i := 0; i < len(msg); i += limit {
end := i + limit
if end > len(msg) {
end = len(msg)
}
self.QueueWriteString("\x1bP@kitty-print|")
self.QueueWriteString(base64.StdEncoding.EncodeToString([]byte(msg[i:end])))
self.QueueWriteString("\x1b\\")
}
} }
} }
@ -146,7 +158,7 @@ func (self *Loop) WakeupMainThread() {
func (self *Loop) QueueWriteString(data string) IdType { func (self *Loop) QueueWriteString(data string) IdType {
self.write_msg_id_counter++ self.write_msg_id_counter++
msg := write_msg{str: data, id: self.write_msg_id_counter} msg := write_msg{str: data, bytes: nil, id: self.write_msg_id_counter}
self.add_write_to_pending_queue(&msg) self.add_write_to_pending_queue(&msg)
return msg.id return msg.id
} }