summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Bütow <1224732+snonux@users.noreply.github.com>2025-06-20 22:11:52 +0300
committerPaul Bütow <1224732+snonux@users.noreply.github.com>2025-06-20 22:11:52 +0300
commit30b5b6287b3c183f15cd92de6a46db097c05f45a (patch)
tree455472c249a5ead31743f5fc57cdb864c4d63711
parentd4bf9ac060c6d64f00a06e7a54f01c61091131b5 (diff)
Remove fireworks and reset default colors
-rw-r--r--cmd/tasksamurai/main.go3
-rw-r--r--internal/atable/table.go5
-rw-r--r--internal/ui/fireworks.go128
3 files changed, 1 insertions, 135 deletions
diff --git a/cmd/tasksamurai/main.go b/cmd/tasksamurai/main.go
index 3e2f3ef..52263de 100644
--- a/cmd/tasksamurai/main.go
+++ b/cmd/tasksamurai/main.go
@@ -26,9 +26,6 @@ func main() {
os.Exit(1)
}
- // Show some fireworks on startup.
- ui.Fireworks()
-
// Clear the screen before starting the TUI to avoid leaving any
// previous command line artefacts behind.
fmt.Print("\033[H\033[2J")
diff --git a/internal/atable/table.go b/internal/atable/table.go
index 615666b..d6ea99d 100644
--- a/internal/atable/table.go
+++ b/internal/atable/table.go
@@ -128,10 +128,7 @@ func DefaultStyles() Styles {
return Styles{
Selected: lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("212")),
Header: lipgloss.NewStyle().Bold(true).Padding(0, 1),
- Cell: lipgloss.NewStyle().
- Padding(0, 1).
- Foreground(lipgloss.Color("226")).
- Background(lipgloss.Color("21")),
+ Cell: lipgloss.NewStyle().Padding(0, 1),
}
}
diff --git a/internal/ui/fireworks.go b/internal/ui/fireworks.go
deleted file mode 100644
index b3ed063..0000000
--- a/internal/ui/fireworks.go
+++ /dev/null
@@ -1,128 +0,0 @@
-package ui
-
-import (
- "math/rand"
- "strings"
- "time"
-
- tea "github.com/charmbracelet/bubbletea"
-)
-
-type fwModel struct {
- width int
- height int
- start time.Time
- fws []firework
- ignoreFirstKey bool
-}
-
-type firework struct {
- x, y int
- frame int
-}
-
-type tickMsg struct{}
-
-func tick() tea.Cmd {
- return tea.Tick(150*time.Millisecond, func(time.Time) tea.Msg { return tickMsg{} })
-}
-
-func (m fwModel) Init() tea.Cmd {
- m.start = time.Now()
- // Ignore the first key in case the exit key from the previous program
- // is still buffered when the fireworks start.
- m.ignoreFirstKey = true
- return tick()
-}
-
-var frames = [][]string{
- {"*"},
- {" * ", "* *", " * "},
- {" * ", " * * ", "* *", " * * ", " * "},
-}
-
-func (m fwModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
- switch msg := msg.(type) {
- case tea.WindowSizeMsg:
- m.width = msg.Width
- m.height = msg.Height
- return m, nil
- case tickMsg:
- if time.Since(m.start) > 3*time.Second {
- return m, tea.Quit
- }
- // advance frames
- for i := 0; i < len(m.fws); {
- m.fws[i].frame++
- if m.fws[i].frame >= len(frames) {
- m.fws = append(m.fws[:i], m.fws[i+1:]...)
- } else {
- i++
- }
- }
- // maybe create new firework
- if m.width > 0 && m.height > 0 {
- if rand.Float64() < 0.4 {
- x := rand.Intn(m.width)
- y := rand.Intn(m.height)
- m.fws = append(m.fws, firework{x: x, y: y})
- }
- }
- return m, tick()
- case tea.KeyMsg:
- if !m.ignoreFirstKey {
- m.ignoreFirstKey = true
- return m, nil
- }
- return m, tea.Quit
- }
- return m, nil
-}
-
-func (m fwModel) View() string {
- if m.width == 0 || m.height == 0 {
- return ""
- }
- grid := make([][]rune, m.height)
- for i := range grid {
- row := make([]rune, m.width)
- for j := range row {
- row[j] = ' '
- }
- grid[i] = row
- }
- for _, fw := range m.fws {
- fr := frames[fw.frame]
- oy := fw.y - len(fr)/2
- for dy, line := range fr {
- y := oy + dy
- if y < 0 || y >= m.height {
- continue
- }
- ox := fw.x - len([]rune(line))/2
- for dx, r := range line {
- x := ox + dx
- if x < 0 || x >= m.width {
- continue
- }
- if r != ' ' {
- grid[y][x] = r
- }
- }
- }
- }
- var b strings.Builder
- for _, row := range grid {
- b.WriteString(string(row))
- b.WriteByte('\n')
- }
- return b.String()
-}
-
-// Fireworks runs a short fireworks animation. It stops after three seconds or
-// when a key is pressed.
-func Fireworks() {
- rand.Seed(time.Now().UnixNano())
- p := tea.NewProgram(fwModel{}, tea.WithAltScreen())
- p.Run()
-}