diff --git a/cmd/termshark/termshark.go b/cmd/termshark/termshark.go index 7a98ff1..2269ee2 100644 --- a/cmd/termshark/termshark.go +++ b/cmd/termshark/termshark.go @@ -316,7 +316,6 @@ func cmain() int { // using the gcla fork of tcell for another application). usetty = "/dev/tty" } - os.Setenv("GOWID_TTY", usetty) // Allow the user to override the shell's TERM variable this way. Perhaps the user runs // under screen/tmux, and the TERM variable doesn't reflect the fact their preferred @@ -846,7 +845,7 @@ func cmain() int { } }() - if app, err = ui.Build(); err != nil { + if app, err = ui.Build(usetty); err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) // Tcell returns ExitError now because if its internal terminfo DB does not have // a matching entry, it tries to build one with infocmp. @@ -1176,7 +1175,7 @@ Loop: appRunner.Start() // Reinstate our terminal overrides that allow ctrl-z - if err := ctrlzLineDisc.Set(); err != nil { + if err := ctrlzLineDisc.Set(usetty); err != nil { ui.OpenError(fmt.Sprintf("Unexpected error setting Ctrl-z handler: %v\n", err), app) } @@ -1274,7 +1273,7 @@ Loop: appRunner.Start() // Reinstate our terminal overrides that allow ctrl-z - if err := ctrlzLineDisc.Set(); err != nil { + if err := ctrlzLineDisc.Set(usetty); err != nil { ui.OpenError(fmt.Sprintf("Unexpected error setting Ctrl-z handler: %v\n", err), app) } diff --git a/go.mod b/go.mod index d7218db..885b954 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/blang/semver v3.5.1+incompatible github.com/flytam/filenamify v1.1.0 github.com/gcla/deep v1.0.2 - github.com/gcla/gowid v1.3.1-0.20220603022106-4d04cba8013a + github.com/gcla/gowid v1.3.1-0.20220626203558-a594805196f2 github.com/gcla/tail v1.0.1-0.20190505190527-650e90873359 github.com/gcla/term v0.0.0-20220601234708-3e6af2ebff27 github.com/gdamore/tcell/v2 v2.5.0 diff --git a/go.sum b/go.sum index 4030df7..18002f9 100644 --- a/go.sum +++ b/go.sum @@ -146,6 +146,8 @@ github.com/gcla/deep v1.0.2 h1:qBOx6eepcOSRYnHJ+f2ih4hP4Vca1YnLtXxp73n5KWI= github.com/gcla/deep v1.0.2/go.mod h1:evE9pbpSGhItmFoBIk8hPOIC/keKTGYhFl6Le1Av+GE= github.com/gcla/gowid v1.3.1-0.20220603022106-4d04cba8013a h1:8kh1ORv/P5ruPPoZBMrXAxw406+o9Uvg4fPblsMfcUo= github.com/gcla/gowid v1.3.1-0.20220603022106-4d04cba8013a/go.mod h1:7T4Xzfznq31XvQyAOX+SZzQjvF7RX16mjXDXGB7R/44= +github.com/gcla/gowid v1.3.1-0.20220626203558-a594805196f2 h1:lTVa5VHxePP+1aMijXK0+McQdHL6RFFciSFp6VZ+oEk= +github.com/gcla/gowid v1.3.1-0.20220626203558-a594805196f2/go.mod h1:7T4Xzfznq31XvQyAOX+SZzQjvF7RX16mjXDXGB7R/44= github.com/gcla/tail v1.0.1-0.20190505190527-650e90873359 h1:3xEhacR7pIJV8daurdBygptxhzTJeYFqJp1V6SDl+pE= github.com/gcla/tail v1.0.1-0.20190505190527-650e90873359/go.mod h1:Wn+pZpM98JHSOYkPDtmdvlqmc0OzQGHWOsHB2d28WtQ= github.com/gcla/term v0.0.0-20220601234708-3e6af2ebff27 h1:OmzD2vZl1UeSblMmUo4mKjnrtsn+VLxhkkqnDOPHrXY= diff --git a/tty/tty.go b/tty/tty.go index ccb75dd..58ddd8e 100644 --- a/tty/tty.go +++ b/tty/tty.go @@ -37,18 +37,11 @@ func (t *TerminalSignals) Restore() { t.set = false } -func (t *TerminalSignals) Set() error { +func (t *TerminalSignals) Set(outtty string) error { var e error var newtios unix.Termios var fd uintptr - outtty := "/dev/tty" - - gwtty := os.Getenv("GOWID_TTY") - if gwtty != "" { - outtty = gwtty - } - if t.out, e = os.OpenFile(outtty, os.O_WRONLY, 0); e != nil { goto failed } diff --git a/ui/ui.go b/ui/ui.go index c39f3d2..824d442 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -3289,7 +3289,7 @@ func ApplyCurrentTheme(app gowid.IApp) { //====================================================================== -func Build() (*gowid.App, error) { +func Build(tty string) (*gowid.App, error) { var err error var app *gowid.App @@ -4358,6 +4358,7 @@ func Build() (*gowid.App, error) { Log: log.StandardLogger(), EnableBracketedPaste: true, DontActivate: true, + Tty: tty, }) if err != nil {