hledger-ui
Safe HaskellNone
LanguageGHC2021

Hledger.UI.UIScreens

Description

Constructors and updaters for all hledger-ui screens.

Constructors (*New) create and initialise a new screen with valid state, based on the provided options, reporting date, journal, and screen-specific parameters.

Updaters (*Update) recalculate an existing screen's state, based on new options, reporting date, journal, and the old screen state.

These are gathered in this low-level module so that any screen's handler can create or regenerate all other screens. Drawing and event-handling code is elsewhere, in per-screen modules.

Synopsis

Documentation

screenUpdate :: UIOpts -> Day -> Journal -> Screen -> Screen Source #

Regenerate the content of any screen from new options, reporting date and journal.

esNew :: String -> Screen Source #

Construct an error screen. Screen-specific arguments: the error message to show.

esUpdate :: ErrorScreenState -> ErrorScreenState Source #

Update an error screen. Currently a no-op since error screen depends only on its screen-specific state.

msNew :: Screen Source #

Construct a menu screen, with the first item selected. Screen-specific arguments: none.

msUpdate :: MenuScreenState -> MenuScreenState Source #

Update a menu screen. Currently a no-op since menu screen has unchanging content.

asNew :: AccountsScreenKind -> UIOpts -> Day -> Journal -> Maybe AccountName -> Screen Source #

Construct an accounts-like screen (all accounts, cash, balance sheet or income statement, selected by the AccountsScreenKind), listing the appropriate set of accounts, with the appropriate one selected. Screen-specific arguments: the kind of screen, and the account to select if any.

asUpdate :: UIOpts -> Day -> Journal -> AccountsScreenState -> AccountsScreenState Source #

Update an accounts-like screen's state from these options, reporting date, and journal. The report is restricted and accumulated according to the screen's kind (_assKind).

csItemIndex :: Int Source #

Positions of menu screen items, so we can move selection to them.

accountsScreenRoptsMod :: AccountsScreenKind -> ReportOpts -> ReportOpts Source #

The report-options modifier for an accounts-like screen of the given kind: which balance accumulation it forces, if any.

accountsScreenQuery :: AccountsScreenKind -> Query Source #

The extra query restricting an accounts-like screen of the given kind to its account types.

rsNew :: UIOpts -> Day -> Journal -> AccountName -> Bool -> Screen Source #

Construct a register screen listing the appropriate set of transactions, with the appropriate one selected. Screen-specific arguments: the account whose register this is, whether to force inclusive balances.

rsUpdate :: UIOpts -> Day -> Journal -> RegisterScreenState -> RegisterScreenState Source #

Update a register screen from these options, reporting date, and journal.

tsNew :: AccountName -> Bool -> [NumberedTransaction] -> NumberedTransaction -> Screen Source #

Construct a transaction screen showing one of a given list of transactions, with the ability to step back and forth through the list. Screen-specific arguments: the account whose transactions are being shown, whether that register included subaccounts, the list of showable transactions, the currently shown transaction.

tsUpdate :: UIOpts -> Day -> Journal -> TransactionScreenState -> TransactionScreenState Source #

Update a transaction screen: rebuild its transaction list from the (possibly reloaded) journal, and reselect the same transaction by its journal index, so the screen refreshes in place on reload. If that transaction is gone, fall back to the one at the same position, else the last, else a blank.

listMoveToIfDisplayItems :: Int -> [item] -> GenericList Name Vector item -> GenericList Name Vector item Source #

Set selected index of a list if there are displayitems. If there are no displayitems, remove the selected index of the list.

uiDisplayAccount :: UIOpts -> AccountName -> AccountName Source #

The account a register-like screen should display: normally the screen's stored account, but when that is a lot subaccount and lot detail is collapsed (so the account doesn't exist in the display journal), its base account, where the collapsed postings now appear. Keep the collapse condition synced with uiDisplayJournal.