mirror of
https://github.com/maaslalani/confetty.git
synced 2024-12-22 06:06:39 +00:00
Another fix on Windows
This commit is contained in:
parent
02c40b05f9
commit
4c38fa4038
@ -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),
|
||||
|
16
fireworks/fireworks_unix.go
Normal file
16
fireworks/fireworks_unix.go
Normal 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)
|
||||
}
|
22
fireworks/fireworks_windows.go
Normal file
22
fireworks/fireworks_windows.go
Normal 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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user