From 3071ce425045ee70059faffdddee4e3796ee8e6a Mon Sep 17 00:00:00 2001 From: steven carpenter Date: Sat, 28 Jun 2025 23:08:27 -0400 Subject: [PATCH] annotated main --- constants.go | 1 + main.go | 3 +++ model.go | 15 ++++++++------- readme.md | 2 ++ styles.go | 15 ++++++++++++--- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/constants.go b/constants.go index 12cf83a..90239d0 100644 --- a/constants.go +++ b/constants.go @@ -1,5 +1,6 @@ package main +//Table definition constants const ( numRows = 6 numCols = 7 diff --git a/main.go b/main.go index 6c9c9b1..08217df 100644 --- a/main.go +++ b/main.go @@ -9,8 +9,11 @@ import ( ) func main() { + // Get the current datetime now := time.Now() + // Set the start date used for opening the current month instead of 1/1/1970 start := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, time.UTC) + // This gets the weekday of the first of the month so that we have the correct day with the correct date offset := int(start.Weekday()) p := tea.NewProgram(model{ year: now.Year(), diff --git a/model.go b/model.go index f0c78b7..eadacba 100644 --- a/model.go +++ b/model.go @@ -1,7 +1,7 @@ package main import tea "github.com/charmbracelet/bubbletea" - +// viewMode is used to store which view is being currently seen (i.e. month or hour) type viewMode int const ( @@ -10,20 +10,21 @@ const ( ) type model struct { - cursorRow int - cursorCol int - monthIndex int - year 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 + year int // the current year being displayed startOffset int // weekday offset where day 1 starts - daysInMonth int + daysInMonth int // a count of how many days there are in the month to account for 30,31,or 28 mode viewMode // For hourly view - selectedDay int + selectedDay int // which day we are looking at in hourly view hourCursor int // which hour (0-23) is selected in hourly view } +//No init state func (m model) Init() tea.Cmd { return nil } diff --git a/readme.md b/readme.md index 7cc29c4..0f260ff 100644 --- a/readme.md +++ b/readme.md @@ -46,3 +46,5 @@ Controls: - [Esc]: Return to month view. - [q] / Ctrl+C: Quit. + +## TODO: anotate the update and view files diff --git a/styles.go b/styles.go index 22b219a..85d4a10 100644 --- a/styles.go +++ b/styles.go @@ -4,16 +4,25 @@ import "github.com/charmbracelet/lipgloss" // Styles for calendar cells and headers var ( + // this is the style thats used as the default style for the month view cellStyle = lipgloss.NewStyle().Width(cellW).Height(cellH).Align(lipgloss.Center) - selectedStyle = cellStyle.Copy().Bold(true).Background(lipgloss.Color("12")).Foreground(lipgloss.Color("15")) // Blue bg + // this is the style that sets the current selected hours bg to orange and text to white + selectedStyle = cellStyle.Copy().Bold(true).Background(lipgloss.Color("12")).Foreground(lipgloss.Color("15")) + // this is the style that sets the color of cells that are not in use for a given month unselectedStyle = cellStyle.Copy().Background(lipgloss.Color("236")).Foreground(lipgloss.Color("250")) - todayStyle = cellStyle.Copy().Background(lipgloss.Color("99")).Foreground(lipgloss.Color("15")).Bold(true) // Purple bg + white text + // this is the style that sets the color of todays cell to purple bg white text + todayStyle = cellStyle.Copy().Background(lipgloss.Color("99")).Foreground(lipgloss.Color("15")).Bold(true) + // this is the style that defines the header where the current months name goes headerStyle = lipgloss.NewStyle().Width(numCols * cellW).Align(lipgloss.Center).Bold(true) + // this is the style that defines the DoW header where mon-sun go daysOfWeekStyle = lipgloss.NewStyle().Width(cellW).Align(lipgloss.Center).Bold(true) // Styles for hourly view cells + // this is the style thats used as the default for the hours view hourCellStyle = lipgloss.NewStyle().Width(cellW * 3).Height(cellH).Align(lipgloss.Left).PaddingLeft(1) + // This is the style that sets the current selected hours style to orange bg white text hourSelectedStyle = hourCellStyle.Copy().Bold(true).Background(lipgloss.Color("12")).Foreground(lipgloss.Color("15")) - currentHourStyle = hourCellStyle.Copy().Background(lipgloss.Color("99")).Foreground(lipgloss.Color("15")).Bold(true) // Purple bg + white text + // this is the style that sets the current hour to purple bg and white text + currentHourStyle = hourCellStyle.Copy().Background(lipgloss.Color("99")).Foreground(lipgloss.Color("15")).Bold(true) )