Documentation
¶
Overview ¶
Package color provides color utilities and conversions for the application.
Index ¶
- func AllDayEventOccursOnDay(event *ical.Event, targetDate time.Time) (bool, error)
- func ApplyBlueTint(hexColor string, tintStrength float64) string
- func BrightenColor(hexColor string, percentage float64) string
- func CellRangesOverlap(startCellA, endCellA, startCellB, endCellB int) bool
- func CellToTime(cell int, zoomLevel types.ZoomLevel, weekStart time.Time, day int) time.Time
- func CreateEndOfDayDate(t time.Time) time.Time
- func CreateMidnightDate(t time.Time) time.Time
- func DeepCopyComponent(original *ical.Component) *ical.Component
- func DeepCopyEvent(original *ical.Event) *ical.Event
- func EventInstanceOverlapsTimeRange(instance *types.EventInstance, rangeStart, rangeEnd time.Time) bool
- func ExpandRecurringEventIntoInstances(component *ical.Component, calendar *ical.Calendar, ...) []*types.EventInstance
- func ExtractRRuleStringFromRule(rule *rrule.RRule) string
- func FindEventByUIDInCalendar(calendar *ical.Calendar, uid string) (*ical.Component, int)
- func ForEachEventInCalendar(calendar *ical.Calendar, fn func(*ical.Component) bool)
- func GenerateUUID() (string, error)
- func GetBackgroundColorHex() string
- func GetCalendarColor(cal *ical.Calendar) string
- func GetCalendarName(cal *ical.Calendar) string
- func GetCellsPerDay(zoom types.ZoomLevel) int
- func GetComponentUID(component *ical.Component) string
- func GetDayOfWeek(eventTime time.Time, weekStart time.Time) time.Weekday
- func GetDayOfWeekFromLocalTime(eventTime timezone.LocalTime, weekStart time.Time) time.Weekday
- func GetEventColor(event *ical.Event, calendarColor string) string
- func GetEventDescription(event *ical.Event) string
- func GetEventDuration(event *ical.Event, defaultLocation *time.Location) time.Duration
- func GetEventLink(event *ical.Event) string
- func GetEventLocation(event *ical.Event) string
- func GetEventTitle(event *ical.Event) string
- func GetEventUID(event *ical.Event) string
- func GetWeekStartingOn(t time.Time, startDay time.Weekday) time.Time
- func IsAllDayEvent(event *ical.Event) bool
- func IsRecurring(event *ical.Event) bool
- func IsValidEndTime(dtend string) bool
- func IsValidStartTime(dtstart string) bool
- func IsValidTimeRange(dtstart, dtend string) bool
- func IsValidUID(uid string) bool
- func NewEventInstanceFromRegular(event *ical.Event, calendar *ical.Calendar) (*types.EventInstance, error)
- func ParseColor(input string) string
- func ParseExistingExdates(exdateStr string, timezone *time.Location) ([]time.Time, error)
- func ParseRRuleFromComponent(component *ical.Component) (*rrule.RRule, error)
- func ParseRRuleString(rruleStr string) (*rrule.RRule, error)
- func RemoveEventFromCalendar(calendar *ical.Calendar, index int) bool
- func RewriteRRuleUntilToFloating(rruleValue string) string
- func ShowIfError(weekModel *types.WeekModel, seconds int, err error, errorMessage string)
- func SortEventInstancesChronologically(allInstances []*types.EventInstance)
- func StandardizeHex(hexColor string) string
- func TimeIsWithinRange(t, minTime, maxTime time.Time) bool
- func TimeRangesOverlapExclusive(start1, end1, start2, end2 time.Time) bool
- func TimeToCell(currentTime time.Time, zoomLevel types.ZoomLevel) int
- func ToHex(c color.Color) string
- func TruncateContent(content string, maxWidth int) string
- func UnescapeRRuleString(rruleStr string) string
- func ValidateRecurringOperation(event *ical.Event, operation string) (bool, string)
- type BatchChange
- type Change
- type ChangeTracker
- func (ct *ChangeTracker[T]) CanRedo() bool
- func (ct *ChangeTracker[T]) CanUndo() bool
- func (ct *ChangeTracker[T]) CommitBatch(description string)
- func (ct *ChangeTracker[T]) RecordChange(change Change[T])
- func (ct *ChangeTracker[T]) Redo() *BatchChange[T]
- func (ct *ChangeTracker[T]) Undo() *BatchChange[T]
- type ChangeType
- type RecurringEventExpander
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllDayEventOccursOnDay ¶
AllDayEventOccursOnDay checks if an all-day event occurs on a specific date. Much simpler implementation using existing utilities instead of manual parsing.
func ApplyBlueTint ¶
ApplyBlueTint shifts a hex color toward blue hue while preserving brightness
func BrightenColor ¶
BrightenColor increases the brightness of a hex color by the given percentage For very dark colors or edge cases, this blends with white instead of pure brightening
func CellRangesOverlap ¶
CellRangesOverlap checks if two cell ranges overlap within a day This is the core collision detection for visual grid rendering
func CellToTime ¶
CellToTime converts a cell index to the corresponding time
func CreateEndOfDayDate ¶
CreateEndOfDayDate creates a time.Time at end of day (23:59:59) for the given date
func CreateMidnightDate ¶
CreateMidnightDate creates a time.Time at midnight (00:00:00) for the given date
func DeepCopyComponent ¶
DeepCopyComponent creates a complete standalone copy of an ical.Component
func DeepCopyEvent ¶
DeepCopyEvent creates a complete standalone copy of an ical.Event This is used for undo functionality and event manipulation
func EventInstanceOverlapsTimeRange ¶
func EventInstanceOverlapsTimeRange(instance *types.EventInstance, rangeStart, rangeEnd time.Time) bool
EventInstanceOverlapsTimeRange checks if an EventInstance overlaps with a specific time range
func ExpandRecurringEventIntoInstances ¶
func ExpandRecurringEventIntoInstances(component *ical.Component, calendar *ical.Calendar, viewStart, viewEnd time.Time) []*types.EventInstance
ExpandRecurringEventIntoInstances expands a single recurring event into event instances within the time range
func ExtractRRuleStringFromRule ¶
ExtractRRuleStringFromRule gets just the RRULE part from a rule's string representation
func FindEventByUIDInCalendar ¶
FindEventByUIDInCalendar finds an event by UID within a specific calendar
func ForEachEventInCalendar ¶
ForEachEventInCalendar iterates over all VEVENT components in a calendar
func GenerateUUID ¶
GenerateUUID creates an RFC4122-compliant UUID v4 See: https://icalendar.org/New-Properties-for-iCalendar-RFC-7986/5-3-uid-property.html
func GetBackgroundColorHex ¶
func GetBackgroundColorHex() string
func GetCalendarColor ¶
GetCalendarColor extracts the color from a calendar
func GetCalendarName ¶
GetCalendarName extracts the display name from a calendar
func GetCellsPerDay ¶
func GetComponentUID ¶
GetComponentUID gets the UID from an iCal component
func GetDayOfWeek ¶
GetDayOfWeek calculates which day of the week (0-6) an event time falls on relative to week start
func GetDayOfWeekFromLocalTime ¶
GetDayOfWeekFromLocalTime calculates which day of the week a LocalTime falls on relative to week start
func GetEventColor ¶
GetEventColor determines the color for an event with fallback hierarchy:
func GetEventDescription ¶
func GetEventDuration ¶
GetEventDuration calculates the duration of an event using timezone-safe methods
func GetEventLink ¶
func GetEventLocation ¶
func GetEventTitle ¶
func GetEventUID ¶
func GetWeekStartingOn ¶
GetWeekStartingOn calculates the start of the week containing the given time
func IsAllDayEvent ¶
func IsRecurring ¶
func IsValidEndTime ¶
IsValidEndTime validates a DTEND time string (supports both timed and all-day formats)
func IsValidStartTime ¶
IsValidStartTime validates a DTSTART time string (supports both timed and all-day formats)
func IsValidTimeRange ¶
IsValidTimeRange validates that start time is before end time
func NewEventInstanceFromRegular ¶
func NewEventInstanceFromRegular(event *ical.Event, calendar *ical.Calendar) (*types.EventInstance, error)
NewEventInstanceFromRegular creates an EventInstance from a regular (non-recurring) event
func ParseColor ¶
ParseColor converts color input (hex, name, or letter) to hex value Returns empty string if input is invalid
func ParseExistingExdates ¶
ParseExistingExdates parses a comma-separated EXDATE string into time slice
func ParseRRuleFromComponent ¶
ParseRRuleFromComponent extracts and parses RRULE from an iCal component
func ParseRRuleString ¶
ParseRRuleString parses an RRULE string with proper unescaping
func RemoveEventFromCalendar ¶
RemoveEventFromCalendar removes an event by index from calendar.Children
func RewriteRRuleUntilToFloating ¶
RewriteRRuleUntilToFloating converts a UTC UNTIL token inside an RRULE value ("UNTIL=YYYYMMDDTHHMMSSZ") into floating local time ("UNTIL=YYYYMMDDTHHMMSS"), leaving every other token untouched. Values that aren't UTC datetimes (already floating, VALUE=DATE, etc.) pass through unchanged.
func ShowIfError ¶
ShowIfError displays an error message in the status bar if err is not nil seconds: how long to show the error (in seconds) err: the potential error to check errorMessage: the message to display (err.Error() will be appended) weekModel: the model to update with error information
func SortEventInstancesChronologically ¶
func SortEventInstancesChronologically(allInstances []*types.EventInstance)
SortEventInstancesChronologically sorts event instances in canonical chronological order This ensures every consumer gets consistently sorted events, eliminating picker ordering bugs
func StandardizeHex ¶
StandardizeHex ensures a hex color always has exactly one # prefix Handles cases: "FF0000", "#FF0000", "##FF0000" -> "#FF0000"
func TimeIsWithinRange ¶
TimeIsWithinRange checks if a time falls within a given time range (inclusive)
func TimeRangesOverlapExclusive ¶
TimeRangesOverlapExclusive checks if two time ranges overlap with exclusive end times This is useful for events where DTEND is non-inclusive (RFC 5545 standard)
func TruncateContent ¶
TruncateContent truncates content to fit within the specified maximum width
func UnescapeRRuleString ¶
UnescapeRRuleString handles iCal text unescaping
func ValidateRecurringOperation ¶
ValidateRecurringOperation checks if an operation is allowed on a recurring event Returns (allowed=true, errorMsg="") for non-recurring events or allowed operations Returns (allowed=false, errorMsg="...") for blocked operations on recurring events
Types ¶
type BatchChange ¶
type BatchChange[T any] struct { Changes []Change[T] Description string // Description of the batch operation (e.g., "Paste 3 events") Timestamp time.Time }
BatchChange represents a group of changes that should be undone/redone together
type Change ¶
type Change[T any] struct { Type ChangeType Data T // The data that was added/deleted/modified Context T // Additional context (e.g., which container it belongs to) Timestamp time.Time // When the change was made // For edit changes, store the before state PreviousData T // Only used for edits }
Change represents a single change that can be undone/redone This is generic and can hold any type of data for any domain
type ChangeTracker ¶
type ChangeTracker[T any] struct { // contains filtered or unexported fields }
ChangeTracker manages undo/redo history for any type of data All operations are treated as batches internally for consistency
func NewChangeTracker ¶
func NewChangeTracker[T any](maxHistory int) *ChangeTracker[T]
NewChangeTracker creates a new generic change tracker
func (*ChangeTracker[T]) CanRedo ¶
func (ct *ChangeTracker[T]) CanRedo() bool
CanRedo returns true if there are changes to redo
func (*ChangeTracker[T]) CanUndo ¶
func (ct *ChangeTracker[T]) CanUndo() bool
CanUndo returns true if there are changes to undo
func (*ChangeTracker[T]) CommitBatch ¶
func (ct *ChangeTracker[T]) CommitBatch(description string)
CommitBatch completes the current batch and commits all changes as a single undo unit
func (*ChangeTracker[T]) RecordChange ¶
func (ct *ChangeTracker[T]) RecordChange(change Change[T])
RecordChange adds a change to the current batch
func (*ChangeTracker[T]) Redo ¶
func (ct *ChangeTracker[T]) Redo() *BatchChange[T]
Redo removes and returns the most recent batch change from redo stack
func (*ChangeTracker[T]) Undo ¶
func (ct *ChangeTracker[T]) Undo() *BatchChange[T]
Undo removes and returns the most recent batch change from undo stack
type ChangeType ¶
type ChangeType int
ChangeType represents the type of change made
const ( ChangeTypeAdd ChangeType = iota ChangeTypeDelete ChangeTypeEdit )
type RecurringEventExpander ¶
type RecurringEventExpander struct {
// contains filtered or unexported fields
}
RecurringEventExpander handles the expansion of recurring events into individual occurrences
func NewRecurringEventExpander ¶
func NewRecurringEventExpander(eventComponent *ical.Component, viewStart, viewEnd time.Time) (*RecurringEventExpander, error)
NewRecurringEventExpander creates a new expander for a recurring event
func (*RecurringEventExpander) GenerateOccurrences ¶
func (r *RecurringEventExpander) GenerateOccurrences() []*types.EventInstance
GenerateOccurrences returns all occurrences within the view timeframe