https://github.com/ldgrp/brick-calendar
Calendar widget for the Brick TUI library
https://github.com/ldgrp/brick-calendar
brick calendar haskell terminal terminal-based tui widget
Last synced: 5 months ago
JSON representation
Calendar widget for the Brick TUI library
- Host: GitHub
- URL: https://github.com/ldgrp/brick-calendar
- Owner: ldgrp
- License: mit
- Created: 2025-04-21T12:21:42.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-04-23T12:13:38.000Z (6 months ago)
- Last Synced: 2025-04-24T00:59:16.016Z (5 months ago)
- Topics: brick, calendar, haskell, terminal, terminal-based, tui, widget
- Language: Haskell
- Homepage: https://hackage.haskell.org/package/brick-calendar
- Size: 125 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Brick Calendar

A calendar widget for [Brick](https://github.com/jtdaugherty/brick) terminal user interfaces.
## Features
- Configurable first day of week (Sunday, Monday, etc.)
- Configurable day-of-week label
- Single char (S, M, T, W, T, F, S)
- Double char (Su, Mo, Tu, We, Th, Fr, Sa)
- Distinct initials (Su, M, T, W, Th, F, S)
- Hidden
- Option to show/hide/dim days outside the current month
- Easy integration with existing Brick applications## Installation
```
cabal install brick-calendar
```## Usage
```haskell
-- Define a resource name type
data AppName = CalName CalendarResource
deriving (Show, Eq, Ord)-- Create a calendar state from a date
mkCalendarState :: Day -> CalendarState AppName
mkCalendarState day =
let (year, month, _) = toGregorian day
config = defaultCalendarConfig
{ _weekStart = Monday
, _dayLabelStyle = DistinctInitials
, _showDayLabels = True
, _outsideMonthDisplay = ShowDimmed
}
in CalendarState year month (Just day) config CalName-- Render the calendar
drawUI :: AppState -> [Widget AppName]
drawUI s = [center $ border $ padAll 1 $ renderCalendar (calendar s)]-- Handle calendar navigation events
handleEvent :: BrickEvent AppName e -> EventM AppName AppState ()
handleEvent (VtyEvent (V.EvKey V.KEsc [])) = halt
handleEvent e =
zoom calendarL $ handleCalendarEvent e
```See `programs/SimpleDemo.hs` for a complete working example.