hledger-ui
Safe HaskellNone
LanguageGHC2021

Hledger.UI.Main

Description

hledger-ui - a hledger add-on providing an efficient TUI.

SPDX-License-Identifier: GPL-3.0-or-later Copyright (c) 2007-2025 (each year in this range) Simon Michael simon@joyful.com and contributors.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Synopsis

Documentation

newChan :: IO (BChan a) Source #

writeChan :: BChan a -> a -> IO () Source #

ttyVtyMaker :: IO (IO Vty) Source #

Make an action like mkVty mempty, but reading keyboard input from the controlling terminal's device rather than from stdin. Used when the journal data was read from stdin, which leaves that handle consumed and closed. The terminal is opened once, here; the returned action can be run repeatedly (eg when resuming after a suspend). Unix only; on Windows this is just mkVty.

openTerminal :: IO Fd Source #

Open the controlling terminal for reading, without making it our controlling terminal if we have none, and not inherited by child processes. Prefer the terminal's real device path (eg devttys003) over devtty: macOS's kqueue can't wait on the latter, so vty's input thread would block in read() and shutdown would hang until the next key press. Fall back to devtty if the device can't be opened (eg after su).

uiInitialState :: UIOpts -> Journal -> UIState Source #

Build hledger-ui's startup state: normalise the options, choose the initial screen, and set up the stack of previous screens as if the user had navigated down to it from the menu. Uses the startup report date (copts^.rsDay), so it is deterministic and reusable outside the brick app (eg from tests). Keep synced with msNew.

runBrickUi :: UIOpts -> Journal -> IO () Source #

brickApp :: Maybe String -> App UIState AppEvent Name Source #

uiHandle :: BrickEvent Name AppEvent -> EventM Name UIState () Source #

uiDraw :: UIState -> [Widget Name] Source #

warningOverlay :: String -> Int -> Widget Name Source #

An overlay layer showing the given (most recent) warning message, and how many more there are, on the screen's bottom line until the next keypress.