diff --git a/tui/model.go b/tui/model.go index 0c69531..342d877 100644 --- a/tui/model.go +++ b/tui/model.go @@ -14,6 +14,8 @@ const ( type model struct { + width int + height int cursorRow int // which row the cursor is sitting on used for cursor highlight cursorCol int // which col the cursor is sitiing on used for cursor highlight monthIndex int // what month 1-12 that is being displayed diff --git a/tui/update.go b/tui/update.go index 62a2f3d..33f8dd6 100644 --- a/tui/update.go +++ b/tui/update.go @@ -25,7 +25,11 @@ func (m model) updateMonthView(msg tea.Msg) (tea.Model, tea.Cmd) { m.daysInMonth = time.Date(m.year, time.Month(m.monthIndex+2), 0, 0, 0, 0, 0, time.UTC).Day() switch msg := msg.(type) { - case tea.KeyMsg: + + case tea.WindowSizeMsg: + m.width = msg.Width + m.height = msg.Height + case tea.KeyMsg: switch msg.String() { case "ctrl+c", "q": return m, tea.Quit @@ -78,6 +82,8 @@ func (m model) updateMonthView(msg tea.Msg) (tea.Model, tea.Cmd) { default: return m, nil } + return m, nil // ← This is the missing line + } func (m model) updateHourlyView(msg tea.Msg) (tea.Model, tea.Cmd) { diff --git a/tui/view.go b/tui/view.go index a585f2c..3696065 100644 --- a/tui/view.go +++ b/tui/view.go @@ -72,7 +72,8 @@ func (m model) viewMonth() string { } out += "\n[a]/[d] to change month, [up]/[down]/[left]/[right] keys to move, [enter] to select a day, [q] to quit." - return out + + return lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center, out) }