Another fix on Windows

This commit is contained in:
Yasuhiro Matsumoto 2021-11-03 10:03:47 +09:00 committed by Maas Lalani
parent 02c40b05f9
commit 4c38fa4038
3 changed files with 38 additions and 9 deletions

View File

@ -11,7 +11,6 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"golang.org/x/term"
)
const (
@ -60,14 +59,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),

View File

@ -0,0 +1,16 @@
//go:build !windows
// +build !windows
package fireworks
import (
"golang.org/x/term"
)
func InitialModel() model {
width, height, err := term.GetSize(0)
if err != nil {
panic(err)
}
return InitialModelWithSize(width, height)
}

View File

@ -0,0 +1,22 @@
//go:build windows
// +build windows
package fireworks
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)
}