diff --git a/confetti/confetti.go b/confetti/confetti.go index faf3a9a..8647f1a 100644 --- a/confetti/confetti.go +++ b/confetti/confetti.go @@ -10,7 +10,6 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" - "golang.org/x/term" ) const ( @@ -59,14 +58,6 @@ func Spawn(width, height int) []simulation.Particle { return particles } -func InitialModel() model { - width, height, err := term.GetSize(0) - if err != nil { - panic(err) - } - return InitialModelWithSize(width, height) -} - func InitialModelWithSize(width, height int) model { return model{system: &simulation.System{ Particles: Spawn(width, height), diff --git a/confetti/confetti_unix.go b/confetti/confetti_unix.go new file mode 100644 index 0000000..91e6cfd --- /dev/null +++ b/confetti/confetti_unix.go @@ -0,0 +1,16 @@ +//go:build !windows +// +build !windows + +package confetti + +import ( + "golang.org/x/term" +) + +func InitialModel() model { + width, height, err := term.GetSize(0) + if err != nil { + panic(err) + } + return InitialModelWithSize(width, height) +} diff --git a/confetti/confetti_windows.go b/confetti/confetti_windows.go new file mode 100644 index 0000000..6bc640a --- /dev/null +++ b/confetti/confetti_windows.go @@ -0,0 +1,22 @@ +//go:build windows +// +build windows + +package confetti + +import ( + "syscall" + + "golang.org/x/term" +) + +func InitialModel() model { + h, err := syscall.GetStdHandle(syscall.STD_OUTPUT_HANDLE) + if err != nil { + panic(err) + } + width, height, err := term.GetSize(int(h)) + if err != nil { + panic(err) + } + return InitialModelWithSize(width, height) +}