env var for /dev in/out

pull/15/head 1.0.2
Miguel Mota 6 years ago
parent 48f0067b82
commit 6e25a81cda

@ -14,7 +14,8 @@
"sources": [ "sources": [
{ {
"type": "git", "type": "git",
"url": "https://github.com/miguelmota/cointop.git" "url": "https://github.com/miguelmota/cointop.git",
"commit": "48f0067b8242ea60d5981152977c381a2aa13c6e"
} }
] ]
} }

@ -4,7 +4,7 @@
package gocui package gocui
import "github.com/nsf/termbox-go" import "github.com/miguelmota/cointop/pkg/termbox"
// Attribute represents a terminal attribute, like color, font style, etc. They // Attribute represents a terminal attribute, like color, font style, etc. They
// can be combined using bitwise OR (|). Note that it is not possible to // can be combined using bitwise OR (|). Note that it is not possible to

@ -7,7 +7,7 @@ package gocui
import ( import (
"errors" "errors"
"github.com/nsf/termbox-go" "github.com/miguelmota/cointop/pkg/termbox"
) )
var ( var (

@ -4,7 +4,7 @@
package gocui package gocui
import "github.com/nsf/termbox-go" import "github.com/miguelmota/cointop/pkg/termbox"
// Keybidings are used to link a given key-press event with a handler. // Keybidings are used to link a given key-press event with a handler.
type keybinding struct { type keybinding struct {

@ -10,7 +10,7 @@ import (
"io" "io"
"strings" "strings"
"github.com/nsf/termbox-go" "github.com/miguelmota/cointop/pkg/termbox"
) )
// A View is a window. It maintains its own internal buffer and cursor // A View is a window. It maintains its own internal buffer and cursor

@ -2,13 +2,16 @@
package termbox package termbox
import "github.com/mattn/go-runewidth" import (
import "fmt" "fmt"
import "os" "os"
import "os/signal" "os/signal"
import "syscall" "runtime"
import "runtime" "syscall"
import "time" "time"
"github.com/mattn/go-runewidth"
)
// public API // public API
@ -24,11 +27,20 @@ import "time"
func Init() error { func Init() error {
var err error var err error
out, err = os.OpenFile("/dev/tty", syscall.O_WRONLY, 0) devin := os.Getenv("DEV_IN")
if devin == "" {
devin = "/dev/tty"
}
devout := os.Getenv("DEV_OUT")
if devout == "" {
devout = "/dev/tty"
}
out, err = os.OpenFile(devin, syscall.O_WRONLY, 0)
if err != nil { if err != nil {
return err return err
} }
in, err = syscall.Open("/dev/tty", syscall.O_RDONLY, 0) in, err = syscall.Open(devout, syscall.O_RDONLY, 0)
if err != nil { if err != nil {
return err return err
} }
Loading…
Cancel
Save