From 84e9e8fdea5d2da93740ffe1e410f0f0b1e6f03c Mon Sep 17 00:00:00 2001 From: Crony Akatsuki Date: Mon, 3 Mar 2025 22:28:42 +0100 Subject: [PATCH] feat: add step counter. Based on discussions on bubbletea github for when I got into issues with view. https://github.com/charmbracelet/bubbletea/discussions/1343#discussioncomment-12376381 --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 98cee72..87e8bb1 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,7 @@ const ( type gol struct { grid [ROW][COL]int buffer [ROW][COL]int + step int } // Create array that holds field's to check for neighbours @@ -75,6 +76,7 @@ func (g gol) Life() tea.Model { } } g.grid = g.buffer + g.step++ return g } @@ -95,7 +97,7 @@ func (g gol) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // Let's draw this all simply func (g gol) View() string { - var s string + s := fmt.Sprintf("Step: %d\n", g.step) // Making sure to not draw the empty field around the array for i := 1; i < ROW-1; i++ { for j := 1; j < COL-1; j++ {