mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
Enable ANSI compressor
With this change all ANSI output will be piped through an ANSI compressor that eliminates redundant ANSI sequences. As such the compressor can be considered "lossless".
This commit is contained in:
committed by
Christian Rocha
parent
1f12bda862
commit
c29912c179
@@ -7,6 +7,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/muesli/ansi/compressor"
|
||||
"github.com/muesli/reflow/truncate"
|
||||
)
|
||||
|
||||
@@ -22,7 +23,7 @@ const (
|
||||
// In cases where very high performance is needed the renderer can be told
|
||||
// to exclude ranges of lines, allowing them to be written to directly.
|
||||
type standardRenderer struct {
|
||||
out io.Writer
|
||||
out io.WriteCloser
|
||||
buf bytes.Buffer
|
||||
framerate time.Duration
|
||||
ticker *time.Ticker
|
||||
@@ -46,7 +47,7 @@ type standardRenderer struct {
|
||||
// with os.Stdout as the first argument.
|
||||
func newRenderer(out io.Writer, mtx *sync.Mutex) renderer {
|
||||
return &standardRenderer{
|
||||
out: out,
|
||||
out: &compressor.Writer{Forward: out},
|
||||
mtx: mtx,
|
||||
framerate: defaultFramerate,
|
||||
}
|
||||
@@ -66,6 +67,7 @@ func (r *standardRenderer) stop() {
|
||||
r.flush()
|
||||
clearLine(r.out)
|
||||
close(r.done)
|
||||
r.out.Close()
|
||||
}
|
||||
|
||||
// kill halts the renderer. The final frame will not be rendered.
|
||||
|
||||
Reference in New Issue
Block a user