mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-18 22:44:50 +02:00
A facility to easily have child programs print to kitty stdout
Works better than the kitty-print DCS escape code as that tends to get interleaved with other writes to the tty since the loop infrastructure writes in a separate I/O thread.
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
@@ -340,6 +341,14 @@ func (self *Term) GetSize() (*unix.Winsize, error) {
|
||||
func Ctermid() string { return "/dev/tty" }
|
||||
|
||||
func DebugPrintln(a ...any) {
|
||||
if fds := os.Getenv(`KITTY_STDIO_FORWARDED`); fds != "" {
|
||||
if fd, err := strconv.Atoi(fds); err == nil && fd > -1 {
|
||||
if f := os.NewFile(uintptr(fd), "<kitty_stdout>"); f != nil {
|
||||
fmt.Fprintln(f, a...)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
term, err := OpenControllingTerm()
|
||||
if err == nil {
|
||||
defer term.Close()
|
||||
|
||||
Reference in New Issue
Block a user