Centered monthly view

This commit is contained in:
steven carpenter 2025-07-28 22:33:42 -04:00
parent 0cb41d9cdf
commit 2476af323f
3 changed files with 11 additions and 2 deletions

View file

@ -14,6 +14,8 @@ const (
type model struct { type model struct {
width int
height int
cursorRow int // which row the cursor is sitting on used for cursor highlight 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 cursorCol int // which col the cursor is sitiing on used for cursor highlight
monthIndex int // what month 1-12 that is being displayed monthIndex int // what month 1-12 that is being displayed

View file

@ -25,6 +25,10 @@ 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() m.daysInMonth = time.Date(m.year, time.Month(m.monthIndex+2), 0, 0, 0, 0, 0, time.UTC).Day()
switch msg := msg.(type) { switch msg := msg.(type) {
case tea.WindowSizeMsg:
m.width = msg.Width
m.height = msg.Height
case tea.KeyMsg: case tea.KeyMsg:
switch msg.String() { switch msg.String() {
case "ctrl+c", "q": case "ctrl+c", "q":
@ -78,6 +82,8 @@ func (m model) updateMonthView(msg tea.Msg) (tea.Model, tea.Cmd) {
default: default:
return m, nil return m, nil
} }
return m, nil // ← This is the missing line
} }
func (m model) updateHourlyView(msg tea.Msg) (tea.Model, tea.Cmd) { func (m model) updateHourlyView(msg tea.Msg) (tea.Model, tea.Cmd) {

View file

@ -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." 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)
} }