summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortheimpostor <sahirhoda@gmail.com>2022-02-20 10:43:27 -0600
committertheimpostor <sahirhoda@gmail.com>2022-02-20 10:43:27 -0600
commit1d5ca110d40682a08eca54d4b7adeb5a2f0b7fd5 (patch)
treee580ee7b57937a19e4875a257223d96bb3fa7ab7
parent2b1414bee0e5e9c18705adc459e36491c08278b0 (diff)
Buffer output and flush only if no errors
-rw-r--r--main.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/main.go b/main.go
index 938fb84..7df77f6 100644
--- a/main.go
+++ b/main.go
@@ -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()
}