diff options
| author | theimpostor <sahirhoda@gmail.com> | 2024-08-23 06:52:18 -0500 |
|---|---|---|
| committer | theimpostor <sahirhoda@gmail.com> | 2024-08-23 06:52:18 -0500 |
| commit | c3e62dab9e15cd05620c8a71b349026997802428 (patch) | |
| tree | 838b038b7cf451ddddf977c5baa4f892395713e1 /main.go | |
| parent | 2aef9eb77f52940298c7165f4a84c78439d6352f (diff) | |
Ensure chunking writer output is buffered
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -117,9 +117,9 @@ func identifyTerm() { } } -// Breaks up every 250 bytes with a screen dcs end + start sequence +// Inserts screen dcs end + start sequence into long sequences // Based on: https://github.com/chromium/hterm/blob/6846a85f9579a8dfdef4405cc50d9fb17d8944aa/etc/osc52.sh#L23 -const chunkSize = 250 +const chunkSize = 252 type chunkingWriter struct { bytesWritten int64 @@ -189,18 +189,17 @@ func copy(fnames []string) error { defer closetty(tty) // Open buffered output, using default max OSC52 length as buffer size - var out *bufio.Writer - if isScreen { - // TODO: stdout or tty? - out = bufio.NewWriterSize(&chunkingWriter{writer: os.Stdout}, 1000000) - } else { - out = bufio.NewWriterSize(tty, 1000000) - } + out := bufio.NewWriterSize(tty, 1000000) // Start OSC52 fmt.Fprint(out, oscOpen) - b64 := base64.NewEncoder(base64.StdEncoding, out) + var b64 io.WriteCloser + if !isScreen { + b64 = base64.NewEncoder(base64.StdEncoding, out) + } else { + b64 = base64.NewEncoder(base64.StdEncoding, &chunkingWriter{writer: out}) + } for _, fname := range fnames { encode(fname, b64) } |
