set tview tty to stdin when read json from stdin

develop 1.2.1
skanehira 4 years ago
parent 763423109a
commit f170037d81

@ -9,7 +9,6 @@ import (
"github.com/gdamore/tcell"
"github.com/gofrs/uuid"
"github.com/rivo/tview"
"golang.org/x/crypto/ssh/terminal"
)
const (
@ -157,9 +156,7 @@ func (t *Tree) SetKeybindings(g *Gui) {
case '?':
g.NaviPanel()
case 'e':
if terminal.IsTerminal(0) {
g.EditWithEditor()
}
g.EditWithEditor()
case ' ':
current := t.GetCurrentNode()
current.SetExpanded(!current.IsExpanded())

@ -8,6 +8,7 @@ import (
"net/http"
"os"
"path/filepath"
"syscall"
"github.com/mitchellh/go-homedir"
"github.com/skanehira/tson/gui"
@ -43,6 +44,7 @@ func init() {
} else {
log.SetOutput(ioutil.Discard)
}
}
func run() int {
@ -57,13 +59,16 @@ func run() int {
if err != nil {
return printError(err)
}
}
} else {
if !terminal.IsTerminal(0) {
var err error
i, err = gui.UnMarshalJSON(os.Stdin)
if err != nil {
return printError(err)
}
if !terminal.IsTerminal(0) {
var err error
i, err = gui.UnMarshalJSON(os.Stdin)
if err != nil {
return printError(err)
// set tview tty to stdin
os.Stdin = os.NewFile(uintptr(syscall.Stderr), "/dev/tty")
}
}

Loading…
Cancel
Save