brick-calendar-0.2.0.0: Calendar widget for the Brick TUI library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Brick.Widgets.Calendar

Description

This module provides a month calendar widget for Brick applications.

Usage

The widget provides:

  • A render function to display the calendar
  • A set of actions for navigation (moveUp, moveDown, etc.)
  • Configuration options

Applications should connect the provided actions to keyboard events in their event handlers. Common navigation patterns include:

  • Arrow keys: Use moveUp, moveDown, moveLeft, moveRight to navigate between days
  • Month navigation: Use setMonthBefore, setMonthAfter to change months
  • Year navigation: Use setYearBefore, setYearAfter to change years

When a navigation action is applied and no day is selected, the first day of the current month will be selected. When navigating between days, if moving to a date outside the current month, the view will automatically shift to that month.

Synopsis

Render

renderCalendar :: Ord n => CalendarState n -> Widget n Source #

Render a month calendar widget

data CalendarState n Source #

The state of the calendar widget. Make this part of your application state.

Constructors

CalendarState 

Fields

Actions

Pre-built event handler

Configuration

data CalendarConfig Source #

Configuration for the calendar widget.

Constructors

CalendarConfig 

Fields

data DayLabelStyle Source #

Style for displaying day labels.

Constructors

SingleChar

Use single characters: S M T W T F S

DoubleChar

Use two characters: Su Mo Tu We Th Fr Sa

DistinctInitials

Use single chars with Th for Thursday: S M T W Th F S

data OutsideMonthDisplay Source #

How to display days outside the current month.

Constructors

Hide

Don't show days outside current month

ShowDimmed

Show days outside month with dimmed styling

ShowNormal

Show days outside month with normal styling

defaultCalendarConfig :: CalendarConfig Source #

Default calendar configuration.

Lenses

Resource name

data CalendarResource Source #

Resource name for calendar widget elements.

Constructors

CalendarDay Int Int Int

Resource for a day (year, month, day)

CalendarMonth Int Int

Resource for month header (year, month)

CalendarPrev

Resource for previous month button

CalendarNext

Resource for next month button

Utilities

getFirstDayOfMonth :: Integer -> Int -> DayOfWeek Source #

Get the day of week for the first day of the given month

getDayLabel :: DayLabelStyle -> DayOfWeek -> Text Source #

Get the label for a day based on the day of week and label style

getMonthLabel :: CalendarConfig -> Integer -> Int -> Text Source #

Get the month label as text (e.g., "Apr 2025")

getWeekDayLabels :: CalendarConfig -> [Text] Source #

Get the labels for all days of the week based on configuration

formatDate :: CalendarConfig -> Day -> Text Source #

Format a date as text using the configured format

defaultCalendarAttrMap :: AttrMap Source #

Attribute map for calendar widgets.