| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Hledger.UI.UIState
Description
UIState operations.
Synopsis
- uiState :: UIOpts -> Journal -> [Screen] -> Screen -> UIState
- uiShowStatus :: CliOpts -> [Status] -> [String]
- setFilter :: String -> UIState -> Either String UIState
- setMode :: Mode -> UIState -> UIState
- setReportPeriod :: Period -> UIState -> UIState
- showMinibuffer :: Text -> Maybe String -> UIState -> UIState
- closeMinibuffer :: UIState -> UIState
- toggleCleared :: UIState -> UIState
- toggleConversionOp :: UIState -> UIState
- toggleIgnoreBalanceAssertions :: UIState -> UIState
- toggleEmpty :: UIState -> UIState
- toggleForecast :: Day -> UIState -> UIState
- toggleHistorical :: UIState -> UIState
- toggleLots :: UIState -> UIState
- uiDisplayJournal :: UIOpts -> Journal -> Journal
- togglePending :: UIState -> UIState
- toggleUnmarked :: UIState -> UIState
- toggleReal :: UIState -> UIState
- toggleTree :: UIState -> UIState
- setTree :: UIState -> UIState
- setList :: UIState -> UIState
- toggleValue :: UIState -> UIState
- reportPeriod :: UIState -> Period
- shrinkReportPeriod :: Day -> UIState -> UIState
- growReportPeriod :: Day -> UIState -> UIState
- nextReportPeriod :: DateSpan -> UIState -> UIState
- previousReportPeriod :: DateSpan -> UIState -> UIState
- resetReportPeriod :: UIState -> UIState
- moveReportPeriodToDate :: Day -> UIState -> UIState
- getDepth :: UIState -> Maybe Int
- setDepth :: Maybe Int -> UIState -> UIState
- decDepth :: UIState -> UIState
- incDepth :: UIState -> UIState
- resetDepth :: UIState -> UIState
- popScreen :: UIState -> UIState
- pushScreen :: Screen -> UIState -> UIState
- enableForecast :: UIOpts -> CliOpts -> CliOpts
- resetFilter :: UIState -> UIState
- resetScreens :: Day -> UIState -> UIState
- regenerateScreens :: Day -> UIState -> UIState
Documentation
uiState :: UIOpts -> Journal -> [Screen] -> Screen -> UIState Source #
Make an initial UI state with the given options, journal, parent screen stack if any, and starting screen. The provided journal should be the uncollapsed journal (with full lot detail); the display journal (ajournal) is derived from it according to the lots toggle.
uiShowStatus :: CliOpts -> [Status] -> [String] Source #
Generate zero or more indicators of the status filters currently active, which will be shown comma-separated as part of the indicators list.
setFilter :: String -> UIState -> Either String UIState Source #
Apply a new filter query, or return the failing query.
setReportPeriod :: Period -> UIState -> UIState Source #
Set the report period.
showMinibuffer :: Text -> Maybe String -> UIState -> UIState Source #
Open the minibuffer, setting its content to the current query with the cursor at the end.
closeMinibuffer :: UIState -> UIState Source #
Close the minibuffer, discarding any edit in progress.
toggleCleared :: UIState -> UIState Source #
Toggle between showing only cleared items or all items.
toggleConversionOp :: UIState -> UIState Source #
Toggle between showing the primary amounts or costs.
toggleIgnoreBalanceAssertions :: UIState -> UIState Source #
Toggle the ignoring of balance assertions.
toggleEmpty :: UIState -> UIState Source #
Toggle between showing all and showing only nonempty (more precisely, nonzero) items.
toggleForecast :: Day -> UIState -> UIState Source #
Toggle hledger-ui's "forecast/future mode". When this mode is enabled, hledger-shows regular transactions which have future dates, and "forecast" transactions generated by periodic transaction rules (which are usually but not necessarily future-dated). In normal mode, both of these are hidden.
toggleHistorical :: UIState -> UIState Source #
Toggle between historical balances and period balances.
toggleLots :: UIState -> UIState Source #
Toggle display of lot detail (lot subaccounts and synthetic lot postings), like the
CLI's --lots flag. This only flips the option; regenerateScreens then re-derives the
display journal from the stored uncollapsed journal, in memory, without reloading from disk.
uiDisplayJournal :: UIOpts -> Journal -> Journal Source #
Derive the display journal (what screens show) from the uncollapsed journal: prepare lot detail for the current options (converted to cost basis when B is on), collapsing it unless the lots toggle (--lots) is on. Mirrors the CLI's maybePrepareLotDetail, so UI and CLI agree (and --ignore-lots is honored).
togglePending :: UIState -> UIState Source #
Toggle between showing only pending items or all items.
toggleUnmarked :: UIState -> UIState Source #
Toggle between showing only unmarked items or all items.
toggleReal :: UIState -> UIState Source #
Toggle between showing all and showing only real (non-virtual) items.
toggleTree :: UIState -> UIState Source #
Toggle between flat and tree mode. If current mode is unspecified/default, assume it's flat.
setTree :: UIState -> UIState Source #
Set hierarchic account tree mode. Also sets no_elide, which hledger-ui wants in tree mode only (see uiInitialState).
setList :: UIState -> UIState Source #
Set flat account list mode. Also unsets no_elide, which hledger-ui wants in tree mode only (see uiInitialState).
toggleValue :: UIState -> UIState Source #
Toggle between showing primary amounts or values (using valuation specified at startup, or a default).
reportPeriod :: UIState -> Period Source #
Get the report period.
shrinkReportPeriod :: Day -> UIState -> UIState Source #
Step through smaller report periods, down to a day.
growReportPeriod :: Day -> UIState -> UIState Source #
Step through larger report periods, up to all.
nextReportPeriod :: DateSpan -> UIState -> UIState Source #
Step the report start/end dates to the next period of same duration, remaining inside the given enclosing span.
previousReportPeriod :: DateSpan -> UIState -> UIState Source #
Step the report start/end dates to the next period of same duration, remaining inside the given enclosing span.
resetReportPeriod :: UIState -> UIState Source #
Clear any report period limits.
moveReportPeriodToDate :: Day -> UIState -> UIState Source #
If a standard report period is set, step it forward/backward if needed so that it encloses the given date.
setDepth :: Maybe Int -> UIState -> UIState Source #
Set the current depth limit to the specified depth, or remove the depth limit. Also remove the depth limit if the specified depth is greater than the current maximum account depth. If the specified depth is negative, reset the depth limit to whatever was specified at uiartup.
decDepth :: UIState -> UIState Source #
Decrement the current depth limit towards 0. If there was no depth limit, set it to one less than the maximum account depth.
incDepth :: UIState -> UIState Source #
Increment the current depth limit. If this makes it equal to the the maximum account depth, remove the depth limit.
resetDepth :: UIState -> UIState Source #
popScreen :: UIState -> UIState Source #
Return to the parent screen, discarding the active one. At the root screen this is a no-op, since the stack always keeps at least one screen. The canonical way to pop the zipper.
pushScreen :: Screen -> UIState -> UIState Source #
Descend into a new screen, making it active and suspending the current one onto the navigation stack. The canonical way to push the zipper.
enableForecast :: UIOpts -> CliOpts -> CliOpts Source #
Enable forecasting in this CliOpts. If it previously specified a forecast period, or else if the given ui startup options did, preserve that as the forecast period.
resetFilter :: UIState -> UIState Source #
Reset some filters & toggles.
resetScreens :: Day -> UIState -> UIState Source #
Reset options to their startup values, discard screen navigation history, and return to the top screen, regenerating it with the startup options and the provided reporting date.
regenerateScreens :: Day -> UIState -> UIState Source #
Regenerate the content of all screens in the stack from the ui state's current options and stored journal, preserving the screen navigation history. Note, does not save the reporting date.
This is the single place that establishes the display journal (ajournal) from the stored uncollapsed journal and the current options, so the two journals can never drift out of sync. To change the journal (eg on reload), set auncollapsedjournal and then call this. To change the lots toggle, flip the option (toggleLots) and call this.
Every screen regenerates from its own stored parameters (plus the options, date and journal), not from any other screen, so the whole stack refreshes uniformly here.