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": [
{
"type": "git",
"url": "https://github.com/miguelmota/cointop.git"
"url": "https://github.com/miguelmota/cointop.git",
"commit": "48f0067b8242ea60d5981152977c381a2aa13c6e"
}
]
}

@ -4,7 +4,7 @@
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
// can be combined using bitwise OR (|). Note that it is not possible to

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

@ -4,7 +4,7 @@
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.
type keybinding struct {

@ -10,7 +10,7 @@ import (
"io"
"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

@ -2,13 +2,16 @@
package termbox
import "github.com/mattn/go-runewidth"
import "fmt"
import "os"
import "os/signal"
import "syscall"
import "runtime"
import "time"
import (
"fmt"
"os"
"os/signal"
"runtime"
"syscall"
"time"
"github.com/mattn/go-runewidth"
)
// public API
@ -24,11 +27,20 @@ import "time"
func Init() 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 {
return err
}
in, err = syscall.Open("/dev/tty", syscall.O_RDONLY, 0)
in, err = syscall.Open(devout, syscall.O_RDONLY, 0)
if err != nil {
return err
}
Loading…
Cancel
Save