mirror of
https://github.com/maaslalani/confetty.git
synced 2024-11-15 04:06:43 +00:00
Support Windows
This commit is contained in:
parent
eef558b980
commit
02c40b05f9
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
"golang.org/x/term"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -59,14 +58,6 @@ func Spawn(width, height int) []simulation.Particle {
|
|||||||
return particles
|
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 {
|
func InitialModelWithSize(width, height int) model {
|
||||||
return model{system: &simulation.System{
|
return model{system: &simulation.System{
|
||||||
Particles: Spawn(width, height),
|
Particles: Spawn(width, height),
|
||||||
|
16
confetti/confetti_unix.go
Normal file
16
confetti/confetti_unix.go
Normal file
@ -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)
|
||||||
|
}
|
22
confetti/confetti_windows.go
Normal file
22
confetti/confetti_windows.go
Normal file
@ -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)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user