diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2024-05-14 16:29:22 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2024-05-14 16:32:26 +0900 |
| commit | d274d093afa667a6ac5ee34579807de195ade784 (patch) | |
| tree | e6afa2672209fec387f4e5db2391c518f78bd04a /src/tui/light.go | |
| parent | 6432f00f0d026c61f683c83ded4d2e15317e927e (diff) | |
| download | fzf-d274d093afa667a6ac5ee34579807de195ade784.tar.gz | |
Render UI directly to /dev/tty
See https://github.com/junegunn/fzf/discussions/3792
This allows us to separately capture the standard error from fzf and its
child processes, and there's less chance of user errors of redirecting
the error stream and hiding fzf.
Diffstat (limited to 'src/tui/light.go')
| -rw-r--r-- | src/tui/light.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/tui/light.go b/src/tui/light.go index 3ef8b60e..4d3f58a4 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -73,7 +73,7 @@ func (r *LightRenderer) csi(code string) string { func (r *LightRenderer) flush() { if r.queued.Len() > 0 { - fmt.Fprint(os.Stderr, "\x1b[?7l\x1b[?25l"+r.queued.String()+"\x1b[?25h\x1b[?7h") + fmt.Fprint(r.ttyout, "\x1b[?7l\x1b[?25l"+r.queued.String()+"\x1b[?25h\x1b[?7h") r.queued.Reset() } } @@ -88,6 +88,7 @@ type LightRenderer struct { prevDownTime time.Time clicks [][2]int ttyin *os.File + ttyout *os.File buffer []byte origState *term.State width int @@ -131,6 +132,10 @@ func NewLightRenderer(theme *ColorTheme, forceBlack bool, mouse bool, tabstop in if err != nil { return nil, err } + out, err := openTtyOut() + if err != nil { + out = os.Stderr + } r := LightRenderer{ closed: util.NewAtomicBool(false), theme: theme, @@ -138,6 +143,7 @@ func NewLightRenderer(theme *ColorTheme, forceBlack bool, mouse bool, tabstop in mouse: mouse, clearOnExit: clearOnExit, ttyin: in, + ttyout: out, yoffset: 0, tabstop: tabstop, fullscreen: fullscreen, |
