mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
Disable OnResize command on Windows
This commit is contained in:
16
commands.go
16
commands.go
@@ -4,8 +4,6 @@ package boba
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
@@ -62,17 +60,3 @@ func GetTerminalSize(newMsgFunc func(int, int, error) TerminalSizeMsg) Cmd {
|
|||||||
return newMsgFunc(w, h, err)
|
return newMsgFunc(w, h, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnResize is used to listen for window resizes. Use GetTerminalSize to get
|
|
||||||
// the windows dimensions. We don't fetch the window size with this command to
|
|
||||||
// avoid a potential performance hit making the necessary system calls, since
|
|
||||||
// this command could potentially run a lot. On that note, consider debouncing
|
|
||||||
// this function.
|
|
||||||
func OnResize(newMsgFunc func() Msg) Cmd {
|
|
||||||
return func() Msg {
|
|
||||||
sig := make(chan os.Signal)
|
|
||||||
signal.Notify(sig, syscall.SIGWINCH)
|
|
||||||
<-sig
|
|
||||||
return newMsgFunc()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
23
commands_unix.go
Normal file
23
commands_unix.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
package boba
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OnResize is used to listen for window resizes. Use GetTerminalSize to get
|
||||||
|
// the windows dimensions. We don't fetch the window size with this command to
|
||||||
|
// avoid a potential performance hit making the necessary system calls, since
|
||||||
|
// this command could potentially run a lot. On that note, consider debouncing
|
||||||
|
// this function.
|
||||||
|
func OnResize(newMsgFunc func() Msg) Cmd {
|
||||||
|
return func() Msg {
|
||||||
|
sig := make(chan os.Signal)
|
||||||
|
signal.Notify(sig, syscall.SIGWINCH)
|
||||||
|
<-sig
|
||||||
|
return newMsgFunc()
|
||||||
|
}
|
||||||
|
}
|
||||||
9
commands_windows.go
Normal file
9
commands_windows.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
// +build windows
|
||||||
|
|
||||||
|
package boba
|
||||||
|
|
||||||
|
// OnResize is not supported on Windows at this time as Windows does not
|
||||||
|
// support the SIGWINCH signal.
|
||||||
|
func OnResize(newMsgFunc func() Msg) Cmd {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user