From bf69923b6df52d6d8739718b2011097e6114733f Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Fri, 31 Jan 2020 08:49:58 +1100 Subject: [PATCH] fix keybinding issues with freebsd/openbsd --- go.mod | 2 +- go.sum | 2 + .../jesseduffield/termbox-go/api.go | 39 ++++++++++++------- vendor/modules.txt | 2 +- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 875f430f7..4815437b8 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/jesseduffield/gocui v0.3.1-0.20200112025325-6c933915c351 github.com/jesseduffield/pty v1.2.1 github.com/jesseduffield/rollrus v0.0.0-20190701125922-dd028cb0bfd7 // indirect - github.com/jesseduffield/termbox-go v0.0.0-20190630083001-9dd53af7214e // indirect + github.com/jesseduffield/termbox-go v0.0.0-20200130214842-1d31d1faa3c9 // indirect github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect github.com/mattn/go-colorable v0.1.4 // indirect diff --git a/go.sum b/go.sum index 2fd3dc495..2abe9ed48 100644 --- a/go.sum +++ b/go.sum @@ -89,6 +89,8 @@ github.com/jesseduffield/rollrus v0.0.0-20190701125922-dd028cb0bfd7 h1:CRD7bVjlG github.com/jesseduffield/rollrus v0.0.0-20190701125922-dd028cb0bfd7/go.mod h1:VspA3aTkEo0Q7TPCLmX1uHNP+Wb4iSDX09hmTRo1QYc= github.com/jesseduffield/termbox-go v0.0.0-20190630083001-9dd53af7214e h1:tth7wr6+sfSbdpRWWrwvLYyS56HyIRVfq0Qcl2h28wM= github.com/jesseduffield/termbox-go v0.0.0-20190630083001-9dd53af7214e/go.mod h1:anMibpZtqNxjDbxrcDEAwSdaJ37vyUeM1f/M4uekib4= +github.com/jesseduffield/termbox-go v0.0.0-20200130214842-1d31d1faa3c9 h1:iBBk1lhFwjwJw//J2m1yyz9S368GeXQTpMVACTyQMh0= +github.com/jesseduffield/termbox-go v0.0.0-20200130214842-1d31d1faa3c9/go.mod h1:anMibpZtqNxjDbxrcDEAwSdaJ37vyUeM1f/M4uekib4= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= diff --git a/vendor/github.com/jesseduffield/termbox-go/api.go b/vendor/github.com/jesseduffield/termbox-go/api.go index 3aa437115..07c1dda42 100644 --- a/vendor/github.com/jesseduffield/termbox-go/api.go +++ b/vendor/github.com/jesseduffield/termbox-go/api.go @@ -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 @@ -26,13 +29,21 @@ func Init() error { var err error - out, err = os.OpenFile("/dev/tty", syscall.O_WRONLY, 0) - if err != nil { - return err - } - in, err = syscall.Open("/dev/tty", syscall.O_RDONLY, 0) - if err != nil { - return err + if runtime.GOOS == "openbsd" || runtime.GOOS == "freebsd" { + out, err = os.OpenFile("/dev/tty", os.O_RDWR, 0) + if err != nil { + return err + } + in = int(out.Fd()) + } else { + out, err = os.OpenFile("/dev/tty", os.O_WRONLY, 0) + if err != nil { + return err + } + in, err = syscall.Open("/dev/tty", syscall.O_RDONLY, 0) + if err != nil { + return err + } } err = setup_term() diff --git a/vendor/modules.txt b/vendor/modules.txt index 634a9f659..d8d5714b7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -36,7 +36,7 @@ github.com/jbenet/go-context/io github.com/jesseduffield/gocui # github.com/jesseduffield/pty v1.2.1 github.com/jesseduffield/pty -# github.com/jesseduffield/termbox-go v0.0.0-20190630083001-9dd53af7214e +# github.com/jesseduffield/termbox-go v0.0.0-20200130214842-1d31d1faa3c9 github.com/jesseduffield/termbox-go # github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 github.com/kardianos/osext