brick-calendar: Calendar widget for the Brick TUI library

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

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


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.2.0.0, 0.2.0.0
Change log None available
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:18:58Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


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

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.