brick-calendar: Calendar widget for the Brick TUI library

[ console, library, mit, program, tui, user-interfaces ] [ Propose Tags ] [ Report a vulnerability ]

A library providing a calendar widget for Brick-based terminal user interfaces. See the README file and demo programs.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.2.0.0
Dependencies base (>=4.11 && <5), brick (>=2.8.3 && <2.9), brick-calendar, microlens (>=0.4.14 && <0.5), microlens-platform (>=0.4.4 && <0.5), microlens-th (>=0.4.3 && <0.5), text (>=2.0.2 && <2.1), time (>=1.12.2 && <1.13), vector (>=0.13.2 && <0.14), vty (>=6.4 && <6.5) [details]
License MIT
Author Leo Orpilla III
Maintainer leo@ldgrp.me
Category User Interfaces, Console, TUI
Home page https://github.com/ldgrp/brick-calendar
Bug tracker https://github.com/ldgrp/brick-calendar/issues
Source repo head: git clone https://github.com/ldgrp/brick-calendar.git -b main
Uploaded by ldgrp at 2025-04-23T12:33:39Z
Distributions
Executables dual-calendar-demo, simple-demo, calendar-demo
Downloads 2 total (2 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for brick-calendar-0.2.0.0

[back to package description]

Brick Calendar

A screenshot of the brick calendar widget

A calendar widget for 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

-- 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.