Documentation ¶
Index ¶
- Variables
- func CalendarRowsInMonth(year int, month time.Month, startOfWeek time.Weekday) int
- func DaysInMonth(year int, month time.Month) int
- func FirstWeekdayOfMonth(year int, month time.Month) time.Weekday
- type ActiveDateMsg
- type DateStyles
- type DayContentMsg
- type KeyMap
- type MonthModel
- func (m MonthModel) Init() tea.Cmd
- func (m MonthModel) StartOfFirstFullWeek() time.Time
- func (m MonthModel) StartOfWeek(weekday time.Weekday) MonthModel
- func (m MonthModel) Styles(styles MonthStyles) MonthModel
- func (m MonthModel) Title(includeYear bool) string
- func (m MonthModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m MonthModel) View() string
- func (m MonthModel) ViewDay(weekday time.Weekday, day int, body string, lastRow bool) string
- func (m MonthModel) ViewHeaders() string
- func (m MonthModel) ViewWeeks() string
- func (m MonthModel) Weekdays(weekdays Weekdays) MonthModel
- type MonthStyles
- type WeekModel
- func (m WeekModel) Init() tea.Cmd
- func (m WeekModel) NextDate() WeekModel
- func (m WeekModel) PreviousDate() WeekModel
- func (m WeekModel) StartOfWeek(weekday time.Weekday) WeekModel
- func (m WeekModel) Styles(styles WeekStyles) WeekModel
- func (m WeekModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m WeekModel) View() string
- func (m WeekModel) ViewDates() string
- func (m WeekModel) ViewHeaders() string
- func (m WeekModel) Weekdays(weekdays Weekdays) WeekModel
- type WeekStyles
- type Weekdays
- func (w Weekdays) First(startDate time.Time) time.Weekday
- func (w Weekdays) Get(day time.Weekday) (string, bool)
- func (w Weekdays) IsVisible(weekday time.Weekday) bool
- func (w Weekdays) Last(startDate time.Time) time.Weekday
- func (w Weekdays) Next(startDate time.Time) time.Weekday
- func (w Weekdays) Previous(startDate time.Time) time.Weekday
Constants ¶
This section is empty.
Variables ¶
var ( DefaultActiveColor = gloss.AdaptiveColor{Light: "#3E5AFA", Dark: "#7DD6FA"} // ╭───┬ // │Sun│ // ├───┼ DefaultLeftHeaderBorder = gloss.Border{ Top: "─", Bottom: "─", Left: "│", Right: "│", TopLeft: "╭", TopRight: "┬", BottomLeft: "├", BottomRight: "┼", } // ┬───┬ // │Mon│ // ┼───┼ DefaultMiddleHeaderBorder = gloss.Border{ Top: "─", Bottom: "─", Left: "│", Right: "│", TopLeft: "┬", TopRight: "┬", BottomLeft: "┼", BottomRight: "┼", } // ┬───╮ // │Sat│ // ┼───┤ DefaultRightHeaderBorder = gloss.Border{ Top: "─", Bottom: "─", Left: "│", Right: "│", TopLeft: "┬", TopRight: "╮", BottomLeft: "┼", BottomRight: "┤", } // ├───┼ // │12 │ // ├───┼ DefaultMiddleLeftDayBorder = gloss.Border{ Top: "─", Bottom: "─", Left: "│", Right: "│", TopLeft: "├", TopRight: "┼", BottomLeft: "├", BottomRight: "┼", } // ┼───┼ // │12 │ // ┼───┼ DefaultMiddleDayBorder = gloss.Border{ Top: "─", Bottom: "─", Left: "│", Right: "│", TopLeft: "┼", TopRight: "┼", BottomLeft: "┼", BottomRight: "┼", } // ┼───┤ // │12 │ // ┼───┤ DefaultMiddleRightDayBorder = gloss.Border{ Top: "─", Bottom: "─", Left: "│", Right: "│", TopLeft: "┼", TopRight: "┤", BottomLeft: "┼", BottomRight: "┤", } // ├───┼ // │12 │ // ╰───┴ DefaultBottomLeftDayBorder = gloss.Border{ Top: "─", Bottom: "─", Left: "│", Right: "│", TopLeft: "├", TopRight: "┼", BottomLeft: "╰", BottomRight: "┴", } // ┼───┼ // │12 │ // ┴───┴ DefaultBottomDayBorder = gloss.Border{ Top: "─", Bottom: "─", Left: "│", Right: "│", TopLeft: "┼", TopRight: "┼", BottomLeft: "┴", BottomRight: "┴", } // ┼───┤ // │12 │ // ┴───╯ DefaultBottomRightDayBorder = gloss.Border{ Top: "─", Bottom: "─", Left: "│", Right: "│", TopLeft: "┼", TopRight: "┤", BottomLeft: "┴", BottomRight: "╯", } )
Functions ¶
func CalendarRowsInMonth ¶
CalendarRowsInMonth calculates the number of calendar rows for a month.
func DaysInMonth ¶
DaysInMonth calculates the number of days in a given month and year.
Types ¶
type ActiveDateMsg ¶
ActiveDateMsg notifies to other models which date is set as the active date.
type DateStyles ¶
type DateStyles struct { // Width of the date block Width int // Height of the date block Height int // Date number style NumberStyle gloss.Style ActiveNumberStyle gloss.Style // Contents style BodyStyle gloss.Style }
Styles for date block rendering.
func DefaultDateStyles ¶
func DefaultDateStyles() DateStyles
DefaultStyles provides default styles for the date block.
type DayContentMsg ¶
type DayContentMsg struct { // The day to update Date time.Time // The day model Content tea.Model }
DayContentMsg enables updates for the content of a single day.
type KeyMap ¶
KeyMap contains relevant keys for tab navigation.
func DefaultMonthKeyMap ¶
func DefaultMonthKeyMap() KeyMap
DefaultMonthKeyMap contains default key mappings for monthly navigation.
func DefaultWeekKeyMap ¶
func DefaultWeekKeyMap() KeyMap
DefaultWeekKeyMap contains default key mappings for weekly navigation.
type MonthModel ¶
type MonthModel struct {
// contains filtered or unexported fields
}
MonthModel represents a full calendar month.
func NewMonth ¶
func NewMonth(year int, month time.Month) MonthModel
NewMonth creates a new MonthModel.
func (MonthModel) StartOfFirstFullWeek ¶
func (m MonthModel) StartOfFirstFullWeek() time.Time
StartOfFirstFullWeek calculates the first day of the first full week of the month.
func (MonthModel) StartOfWeek ¶
func (m MonthModel) StartOfWeek(weekday time.Weekday) MonthModel
StartOfWeek sets the first day of a week.
func (MonthModel) Styles ¶
func (m MonthModel) Styles(styles MonthStyles) MonthModel
Styles sets custom styling.
func (MonthModel) Title ¶
func (m MonthModel) Title(includeYear bool) string
Title generates a title for the calendar that may be used during rendering.
func (MonthModel) ViewDay ¶
ViewDay renders a single day.
If zero is passed in for the day, an empty date block will be rendered.
func (MonthModel) ViewHeaders ¶
func (m MonthModel) ViewHeaders() string
ViewHeaders renders the weekday headers.
func (MonthModel) ViewWeeks ¶
func (m MonthModel) ViewWeeks() string
ViewWeeks renders the calendar main block.
func (MonthModel) Weekdays ¶
func (m MonthModel) Weekdays(weekdays Weekdays) MonthModel
Weekdays sets custom weekday labels.
type MonthStyles ¶
type MonthStyles struct { // Days-of-the-week header LeftHeaderStyle gloss.Style MiddleHeaderStyle gloss.Style RightHeaderStyle gloss.Style // Month block interior MiddleLeftDayStyle gloss.Style MiddleDayStyle gloss.Style MiddleRightDayStyle gloss.Style // Month block bottom row BottomLeftDayStyle gloss.Style BottomDayStyle gloss.Style BottomRightDayStyle gloss.Style // Date interior DateStyles DateStyles }
Styles for rendering the calendar.
func DefaultMonthStyles ¶
func DefaultMonthStyles() MonthStyles
DefaultMonthStyles provides default month styles.
type WeekModel ¶
type WeekModel struct {
// contains filtered or unexported fields
}
WeekModel represents a calendar week.
func (WeekModel) NextDate ¶
NextDate sets the activeDate to the next visible date.
Notes:
- The Weekdays map is used to determine the next date that has a day label and should therefore be visible.
- If moving forwards from the last visible day, the method rolls over to the first visible day of the week.
- If the active date is unset (initial state), this method will set the first visible weekday as the "next" date.
func (WeekModel) PreviousDate ¶
PreviousDate sets the activeDate to the previous visible date.
Notes:
- The Weekdays map is used to determine the previous date that has a day label and should therefore be visible.
- If moving backwards from the first visible day, the method rolls over to the last visible day of the week.
- If the active date is unset (initial state), this method will set the last visible weekday as the "previous" date.
func (WeekModel) StartOfWeek ¶
StartOfWeek sets the first day of the week.
func (WeekModel) Styles ¶
func (m WeekModel) Styles(styles WeekStyles) WeekModel
Styles sets custom styling.
func (WeekModel) ViewHeaders ¶
ViewHeaders renders the weekday headers.
type WeekStyles ¶
type WeekStyles struct { // Days-of-the-week header LeftHeaderStyle gloss.Style MiddleHeaderStyle gloss.Style RightHeaderStyle gloss.Style // Style to indicate a day is the active day from the header ActiveHeaderStyle gloss.Style // Month block bottom row LeftDayStyle gloss.Style MiddleDayStyle gloss.Style RightDayStyle gloss.Style // Date interior // // Note: NumberStyle and ActiveNumber styles are ignored for WeekModel. DateStyles DateStyles DateFormat string }
Styles for rendering the calendar.
func DefaultWeekStyles ¶
func DefaultWeekStyles() WeekStyles
type Weekdays ¶
Weekdays maps weekdays to their labels.
func DefaultWeekdays ¶
func DefaultWeekdays() Weekdays
DefaultWeekdays returns default weekday labels.
func DefaultWeekdaysShort ¶
func DefaultWeekdaysShort() Weekdays
DefaultWeekdaysShort returns default short weekday labels.
func (Weekdays) IsVisible ¶
IsVisible determines whether the weekday has a label, and should therefore be visible.