diff options
| author | theimpostor <sahirhoda@gmail.com> | 2022-02-20 10:43:27 -0600 |
|---|---|---|
| committer | theimpostor <sahirhoda@gmail.com> | 2022-02-20 10:43:27 -0600 |
| commit | 1d5ca110d40682a08eca54d4b7adeb5a2f0b7fd5 (patch) | |
| tree | e580ee7b57937a19e4875a257223d96bb3fa7ab7 /main.go | |
| parent | 2b1414bee0e5e9c18705adc459e36491c08278b0 (diff) | |
Buffer output and flush only if no errors
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -1,6 +1,7 @@ package main import ( + "bufio" "encoding/base64" "flag" "fmt" @@ -45,14 +46,20 @@ func main() { fnames = []string{"-"} } + // Open buffered output, using default max OSC52 length as buffer size + out := bufio.NewWriterSize(os.Stdout, 1000000) + // Start OSC52 - fmt.Print("\033]52;c;") - b64 := base64.NewEncoder(base64.StdEncoding, os.Stdout) + fmt.Fprintf(out, "\033]52;c;") + + b64 := base64.NewEncoder(base64.StdEncoding, out) for _, fname := range fnames { encode(fname, b64) } b64.Close() // End OSC52 - fmt.Print("\a") + fmt.Fprintf(out, "\a") + + out.Flush() } |
