mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-29 19:33:49 -07:00
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.
This commit is contained in:
@@ -14,6 +14,8 @@ import (
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
var tty string
|
||||
|
||||
func IsLightRendererSupported() bool {
|
||||
return true
|
||||
}
|
||||
@@ -48,12 +50,14 @@ func (r *LightRenderer) closePlatform() {
|
||||
// NOOP
|
||||
}
|
||||
|
||||
func openTtyIn() (*os.File, error) {
|
||||
in, err := os.OpenFile(consoleDevice, syscall.O_RDONLY, 0)
|
||||
func openTty(mode int) (*os.File, error) {
|
||||
in, err := os.OpenFile(consoleDevice, mode, 0)
|
||||
if err != nil {
|
||||
tty := ttyname()
|
||||
if len(tty) == 0 {
|
||||
tty = ttyname()
|
||||
}
|
||||
if len(tty) > 0 {
|
||||
if in, err := os.OpenFile(tty, syscall.O_RDONLY, 0); err == nil {
|
||||
if in, err := os.OpenFile(tty, mode, 0); err == nil {
|
||||
return in, nil
|
||||
}
|
||||
}
|
||||
@@ -62,6 +66,14 @@ func openTtyIn() (*os.File, error) {
|
||||
return in, nil
|
||||
}
|
||||
|
||||
func openTtyIn() (*os.File, error) {
|
||||
return openTty(syscall.O_RDONLY)
|
||||
}
|
||||
|
||||
func openTtyOut() (*os.File, error) {
|
||||
return openTty(syscall.O_WRONLY)
|
||||
}
|
||||
|
||||
func (r *LightRenderer) setupTerminal() {
|
||||
term.MakeRaw(r.fd())
|
||||
}
|
||||
|
Reference in New Issue
Block a user