forked from Mirrors/bubbletea
Disable resize listening on windows since it's not supported
This commit is contained in:
parent
a152cce4b6
commit
debaf312f7
|
@ -0,0 +1,27 @@
|
|||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
package tea
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
)
|
||||
|
||||
// listenForResize sends messages (or errors) when the terminal resizes.
|
||||
// Argument output should be the file descriptor for the terminal; usually
|
||||
// os.Stdout.
|
||||
func listenForResize(output *os.File, msgs chan Msg, errs chan error) {
|
||||
sig := make(chan os.Signal)
|
||||
signal.Notify(sig, syscall.SIGWINCH)
|
||||
for {
|
||||
<-sig
|
||||
w, h, err := terminal.GetSize(int(output.Fd()))
|
||||
if err != nil {
|
||||
errs <- err
|
||||
}
|
||||
msgs <- WindowSizeMsg{w, h}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
// +build windows
|
||||
|
||||
package tea
|
||||
|
||||
import "os"
|
||||
|
||||
// listenForResize is not available on windows because windows does not
|
||||
// implement syscall.SIGWINCH.
|
||||
func listenForResize(output *os.File, msgs chan Msg, errs chan error) {}
|
15
tea.go
15
tea.go
|
@ -2,8 +2,6 @@ package tea
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/muesli/termenv"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
|
@ -132,18 +130,7 @@ func (p *Program) Start() error {
|
|||
}()
|
||||
|
||||
// Listen for window resizes
|
||||
go func() {
|
||||
sig := make(chan os.Signal)
|
||||
signal.Notify(sig, syscall.SIGWINCH)
|
||||
for {
|
||||
<-sig
|
||||
w, h, err := terminal.GetSize(int(output.Fd()))
|
||||
if err != nil {
|
||||
errs <- err
|
||||
}
|
||||
msgs <- WindowSizeMsg{w, h}
|
||||
}
|
||||
}()
|
||||
go listenForResize(output, msgs, errs)
|
||||
|
||||
// Process commands
|
||||
go func() {
|
||||
|
|
Loading…
Reference in New Issue