types

package
v0.0.0-...-57c9f0f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package types provides core type definitions, constants, and structures used throughout the Chronos calendar application.

Index

Constants

View Source
const (
	// TimeColumnBorder is the width of the right border for the time column
	TimeColumnBorder = 1
	// DayColumnBorders is the total width of borders for all day columns
	DayColumnBorders = 7
	// TotalBorders is the combined width of all column borders
	TotalBorders = TimeColumnBorder + DayColumnBorders

	// MinVisibleCellsPerDay is the minimum number of time cells visible per day
	MinVisibleCellsPerDay = 1

	// CellPaddingLeft is the left padding for calendar cells
	CellPaddingLeft = 0
	// CellPaddingRight is the right padding for calendar cells
	CellPaddingRight = 0
	// TimeColumnLeftPadding is the left padding for the time column
	TimeColumnLeftPadding = 1
	// TimeColumnRightPadding is the right padding for the time column
	TimeColumnRightPadding = 1

	// Calendar time types
	DaysPerWeek = 7
	MaxDayIndex = 6 // 0-indexed days (0=Sunday, 6=Saturday)
	MinsPerHour = 60
	HoursPerDay = 24
	MinsPerDay  = MinsPerHour * HoursPerDay

	// UI Reserved Lines
	// TODO: build these using lipgloss get height methods?
	AllDayCells      = 3
	AllDayCountRow   = 1 // New count row showing "X all-day events"
	AllDaySeperator  = 1 //
	MonthHeaderLines = 1
	DayTitleLines    = 1

	HeaderLines = MonthHeaderLines + DayTitleLines + AllDayCountRow + AllDayCells
	FooterLines = 1

	// Color types
	HeaderBackgroundColor = "240" // Background color for headers and count rows
	DefaultEventLength    = 60    // Default event duration in minutes

	TimeFormat = "%02d:%02d" // displayed in week mode for example

	// UI Colors
	CurrentTimeRowColor       = "#e0af68"
	TimeCellCursorRowColor    = "#9ece6a"
	BrightenBackgroundPercent = 270
	BrightenEventsPercent     = 80
	EventTextBlackColor       = "#000000" // Black color for toggled event text

	DefaultEventColor = "#FF2968" // Fallback color when no calendar or event color specified

	// Time duration types
	ErrorDisplayDuration = 5 * time.Second // How long to show error messages
	ErrorDisplaySeconds  = 5               // How long to show error messages (in seconds)

	// UI interaction types
	KeyHintTimeoutSeconds = 3 // Seconds before showing key hints
	TwoDigitLength        = 2 // Expected length for two-digit inputs
	FourDigitLength       = 4 // Expected length for four-digit inputs

	// Undo system
	MaxUndoOperations = 50

	// Color manipulation types
	ColorDarkenPercent = 0.3   // For darkening colors
	LightnessScale     = 100.0 // Scale for lightness calculations

	// Layout and positioning types
	DefaultMarginTop    = 2  // Default top margin
	DefaultMarginBottom = 2  // Default bottom margin
	HeaderSpacing       = 3  // Spacing in headers
	FormSpacing         = 3  // Spacing in forms
	MinimumWidth        = 10 // Minimum widget width
	StandardWidth       = 20 // Standard widget width
	WideWidth           = 30 // Wide widget width
	ExtraWideWidth      = 40 // Extra wide widget width
	VeryWideWidth       = 45 // Very wide widget width
	MaxWidth            = 50 // Maximum widget width
	LargeWidth          = 55 // Large widget width
	ExtendedWidth       = 60 // Extended widget width

	// Alpha/transparency types
	ReducedOpacity = 0.8 // Reduced opacity for visual effects
	CellOpacity    = 1.8 // Cell opacity multiplier

	// Hash types for event manager
	HashShift16  = 16   // Bit shift for 16-bit operations
	HashMask0x40 = 0x40 // Hash mask for 0x40
	HashMask0x80 = 0x80 // Hash mask for 0x80

	// Picker types
	PickerMinItems = 6 // Minimum items to show picker

	// Time interval types
	DefaultMinutesInterval = 30 // Default interval in minutes
	SecondsPerMinute       = 60 // Seconds in a minute
	HalfDivisor            = 2  // Divisor for half calculations

	// Form validation types
	WeekdayIntervalDivisor = 7 // Divisor for weekday intervals

	// Return codes for form operations
	FormReturnCodeTwo   = 2 // Return code 2
	FormReturnCodeThree = 3 // Return code 3
	FormReturnCodeFour  = 4 // Return code 4

	// Calendar display types
	HourDisplayDivisor = 24 // Divisor for hour display calculations
	MaxRetryAttempts   = 5  // Maximum retry attempts for operations
)
View Source
const (
	// ICalComponentEvent represents the VEVENT component type in iCal
	ICalComponentEvent = "VEVENT"

	// ICalValueTypeDate represents the DATE value type in iCal
	ICalValueTypeDate = "DATE"

	// UnknownCalendar is the default name for calendars without a name
	UnknownCalendar = "Unknown Calendar"
)

Calendar component and property types (external protocol values)

View Source
const (
	// Key names for UI navigation
	KeyDown  = "down"
	KeyEnter = "enter"
	KeyEsc   = "esc"

	// Default event title
	UntitledEvent = "Untitled Event"

	// Color constants
	ColorBlack = "#000000"

	// Time search constants
	DaysInYear = 365

	// UI popup width constants
	PopupWidthLarge = 60

	// UI padding constants
	PaddingHorizontalStandard = 2
	PaddingVerticalStandard   = 1
)

UI Interaction strings

Variables

View Source
var (
	TimeColumnAndPaddingWidth          = len(fmt.Sprintf(TimeFormat, 0, 0)) + TimeColumnLeftPadding + TimeColumnRightPadding
	TimeColumnAndPaddingAndBorderWidth = TimeColumnAndPaddingWidth + 1
)

Const but a var

View Source
var ModeInfoMap = map[VimMode]ModeInfo{
	ModeNormal: {
		Name:            "NORMAL",
		BackgroundColor: "#98be65",
		ForegroundColor: "#ffffff",
	},
	ModeVisual: {
		Name:            "VISUAL",
		BackgroundColor: "#c678dd",
		ForegroundColor: "#ffffff",
	},
	ModeSearch: {
		Name:            "SEARCH",
		BackgroundColor: "#e06c75",
		ForegroundColor: "#ffffff",
	},
}

Mode definitions with their associated colors (lualine-style)

ZoomLevels defines the canonical ordering of zoom levels for grid arrays

Functions

This section is empty.

Types

type AllDayEventGrid

type AllDayEventGrid struct {
	StartDate     time.Time
	EventRows     [AllDayCells][]AllDaySpanningEvent
	OverflowCount int  // Number of events that couldn't fit
	HasOverflow   bool // Whether there are more events than can be displayed
}

AllDayEventGrid stores all-day events for a week with proper row assignment

type AllDaySpanningEvent

type AllDaySpanningEvent struct {
	Event         *ical.Event    // For display/legacy compatibility
	EventInstance *EventInstance // For computed times and recurring events
	StartDay      int            // 0-6 (Sunday-Saturday)
	EndDay        int            // 0-6 (Sunday-Saturday)
	CalendarColor string         // calendar's color for consistency
}

AllDaySpanningEvent represents an all-day event with spanning information

type BackgroundSyncMsg

type BackgroundSyncMsg struct{}

BackgroundSyncMsg is sent periodically to sync calendars from CalDAV server

type CalendarInfo

type CalendarInfo struct {
	ID    string
	Name  string
	Color string
}

CalendarInfo holds calendar information for forms

type CellLayout

type CellLayout []PositionedEvent

type CollisionGroup

type CollisionGroup []PositionedEvent

CollisionGroup represents events that overlap and need column assignment

type CursorPositionInWeek

type CursorPositionInWeek struct {
	Day         int // 0 to 6 (Sunday to Saturday)
	Cell        int // cell number based on zoom level
	EventColumn int // which event column within the cell (0 = leftmost)
}

type DayLayout

type DayLayout struct {
	Date        time.Time
	CellLayouts map[int]CellLayout
}

type EventInstance

type EventInstance struct {
	// Original event data (never modified)
	OriginalEvent *ical.Event    // The original iCal event
	Calendar      *ical.Calendar // Source calendar

	// Computed time information (may differ from original for recurring instances)
	ComputedStart timezone.LocalTime
	ComputedEnd   timezone.LocalTime

	// Instance metadata
	IsOriginal  bool   // True for regular events, false for recurring instances
	MasterUID   string // UID of master event
	InstanceUID string // Unique UID for this specific instance
}

EventInstance represents a unified view of either a regular event or a recurring event instance This abstraction provides computed start/end times while preserving the original iCal event

type EventManagerInterface

type EventManagerInterface interface {
	GetAllEventsForWeek(weekModel *WeekModel) ([]*EventInstance, error)
	GetTimedEventsForWeek(weekModel *WeekModel) ([]*EventInstance, error)
	GetAllDayEventsForWeek(weekModel *WeekModel) ([]*EventInstance, error)
	GetEventsForDayUnderCursor(weekModel *WeekModel) ([]*EventInstance, error)
	GetAllDayEventsForDayUnderCursor(weekModel *WeekModel) ([]*EventInstance, error)
	GetCalendarsForDisplay() []*ical.Calendar
	DeleteEvent(event *ical.Event) (error, tea.Cmd)
}

EventManagerInterface defines the interface for event operations to avoid circular imports

type EventRecurrence

type EventRecurrence string

EventRecurrence represents whether an event is recurring

const (
	// EventRecurrenceRecurring represents a recurring event
	EventRecurrenceRecurring EventRecurrence = "recurring"
	// EventRecurrenceOnce represents a one-time event
	EventRecurrenceOnce EventRecurrence = "once"
)

type EventType

type EventType string

EventType represents the type of event

const (
	// EventTypeAllDay represents an all-day event type
	EventTypeAllDay EventType = "allday"
	// EventTypeNormal represents a normal timed event
	EventTypeNormal EventType = "normal"
)

type ModeInfo

type ModeInfo struct {
	Name            string
	BackgroundColor string
	ForegroundColor string
}

ModeInfo contains display information for vim modes

type PositionedEvent

type PositionedEvent struct {
	Instance      *EventInstance // EventInstance with computed times
	Column        int            // assigned column (0, 1, 2, etc.)
	IsStartCell   bool           // need to display title
	IsEndCell     bool           // handles edge cases of 2 adjacent events with same colors
	CalendarColor string         // calendar's X-APPLE-CALENDAR-COLOR for color hierarchy
}

type RecurrenceEndType

type RecurrenceEndType string

RecurrenceEndType represents how a recurrence ends

const (
	// RecurrenceEndCount represents ending by count
	RecurrenceEndCount RecurrenceEndType = "count"

	// RecurrenceEndUntil represents ending by date
	RecurrenceEndUntil RecurrenceEndType = "until"
)

type RecurrencePattern

type RecurrencePattern string

RecurrencePattern represents the pattern of recurrence

const (
	// RecurrencePatternWeekday represents weekday recurrence
	RecurrencePatternWeekday RecurrencePattern = "weekday"

	// RecurrencePatternMonthly represents monthly recurrence
	RecurrencePatternMonthly RecurrencePattern = "monthly"

	// RecurrencePatternYearly represents yearly recurrence
	RecurrencePatternYearly RecurrencePattern = "yearly"
)

type RecurringDialogChoiceMsg

type RecurringDialogChoiceMsg struct {
	Event         *ical.Event
	Scope         RecurringEventOperationScope // This/Future/All
	OperationType RecurringEventOperationType  // Edit/Delete
	Cancelled     bool                         // True if user cancelled
}

RecurringDialogChoiceMsg is sent when user makes a choice in the recurring dialog

type RecurringEventDialog

type RecurringEventDialog struct {
	IsActive  bool
	Operation RecurringEventOperation
}

RecurringEventDialog represents the state of the "This/Future/All" dialog

type RecurringEventOperation

type RecurringEventOperation struct {
	OperationType RecurringEventOperationType  // Edit or delete
	TargetEvent   *ical.Event                  // The event being operated on
	InstanceDate  time.Time                    // The specific occurrence date
	IsRecurring   bool                         // Whether the event is actually recurring
	Scope         RecurringEventOperationScope // The selected scope (this/future/all) - set after dialog
}

RecurringEventOperation contains info about a pending recurring event operation

type RecurringEventOperationScope

type RecurringEventOperationScope int

RecurringEventOperationScope defines what scope of a recurring event operation (this/future/all)

const (
	OperationScopeThisOnly      RecurringEventOperationScope = iota // Edit/delete this occurrence only
	OperationScopeThisAndFuture                                     // Edit/delete this and all future occurrences
	OperationScopeAll                                               // Edit/delete all occurrences in the series
)

type RecurringEventOperationType

type RecurringEventOperationType int

RecurringEventOperationType defines the type of operation (edit vs delete)

const (
	OperationTypeEdit   RecurringEventOperationType = iota // Edit operation
	OperationTypeDelete                                    // Delete operation
)

type RefreshMsg

type RefreshMsg struct{}

RefreshMsg is sent when the display needs to be refreshed

type ShowRecurringEditFormMsg

type ShowRecurringEditFormMsg struct {
	Scope RecurringEventOperationScope
}

ShowRecurringEditFormMsg is sent when recurring dialog completes and needs to show edit form

type VimActionMsg

type VimActionMsg struct {
	Action   string
	Argument int // Could be repeat count (5j) or numeric parameter (gh14, gt1430)
}

VimActionMsg is sent when a vim command needs to trigger an action

type VimCommandBinding

type VimCommandBinding struct {
	Key         string
	Description string
	Modes       []VimMode
}

VimCommandBinding represents a vim command binding for keyhints

type VimCommandFolder

type VimCommandFolder struct {
	Prefix      string
	Description string
}

VimCommandFolder represents a vim command folder for keyhints

type VimErrorMsg

type VimErrorMsg struct {
	Error string
}

VimErrorMsg is sent when a vim command encounters an error

type VimMode

type VimMode int

VimMode represents different vim modes with associated display information

const (
	// ModeNormal represents normal navigation mode
	ModeNormal VimMode = iota
	// ModeVisual represents visual selection mode
	ModeVisual
	// ModeSearch represents search/filter mode
	ModeSearch
)

func (VimMode) GetModeInfo

func (mode VimMode) GetModeInfo() ModeInfo

GetModeInfo returns the mode info for a given vim mode

func (VimMode) GetModeStyle

func (mode VimMode) GetModeStyle() lipgloss.Style

GetModeStyle returns a lipgloss style for the given mode

type VimStateInterface

type VimStateInterface interface {
	SetMode(mode VimMode)
	GetMode() VimMode
	SetVisualAnchor(cursor CursorPositionInWeek)
	GetStatusText() string
}

VimStateInterface defines the interface for vim state operations to avoid circular imports

type WeekEventGrid

type WeekEventGrid struct {
	StartDate  time.Time
	DayLayouts [DaysPerWeek]DayLayout
}

type WeekModel

type WeekModel struct {
	CurrentlyViewedWeek           time.Time
	Cursor                        CursorPositionInWeek
	Width                         int
	Height                        int
	CurrentZoom                   ZoomLevel
	CachedCellWidth               int
	CachedContentWidth            int
	CachedBackgroundColor         string
	CachedBackgroundSelectedColor string

	WeekEventGrids    [4]WeekEventGrid // one for each zoomlevel
	AllDayEventGrid   AllDayEventGrid  // all-day events with row assignments
	AllDayEventCounts []int            // accurate count of all-day events per day

	// Visual mode selection
	IsVisualMode     bool
	VisualAnchor     CursorPositionInWeek
	VisualAnchorWeek time.Time // Week the visual anchor belongs to

	// Search functionality
	SearchActive      bool
	SearchInput       string
	SearchLocked      bool   // true when search is "locked in" after Enter
	LockedSearchInput string // the locked search input
	CurrentSearchIdx  int    // current position in search results (-1 = no position)

	// Error display
	ErrorMessage string
	ErrorExpiry  time.Time

	// All-day events layer
	ShowAllDayEventsLayer   bool
	AllDayEventsTargetDay   int         // 0-6 (Sunday to Saturday)
	AllDayEventsPickerIndex int         // currently selected event index in the picker (automatically in picker mode when overlay is open)
	SelectedAllDayEvent     *ical.Event // temporarily stores selected all-day event for form operations

	// Agenda layer
	ShowAgendaLayer   bool
	AgendaTargetDay   int         // 0-6 (Sunday to Saturday)
	AgendaPickerIndex int         // currently selected event index in the picker (automatically in picker mode when overlay is open)
	SelectedEvent     *ical.Event // temporarily stores selected event for form operations

	// Recurring event instance tracking for picker operations
	RecurringInstanceDate time.Time // stores the specific instance date when operating on recurring events from pickers

	// All-day grid visibility
	ShowAllDayGrid bool // controls whether the all-day event grid section is visible

	// Event text color toggle
	EventTextBlack bool // Toggle for event text color (default: true, black: true)
}

type ZoomLevel

type ZoomLevel int

ZoomLevel represents different time granularities for the calendar view

const (
	// Zoom30Min represents 30-minute time slots
	Zoom30Min ZoomLevel = 30
	// Zoom15Min represents 15-minute time slots
	Zoom15Min ZoomLevel = 15
	// Zoom5Min represents 5-minute time slots
	Zoom5Min ZoomLevel = 5
	// Zoom1Min represents 1-minute time slots
	Zoom1Min ZoomLevel = 1
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL