doc: ui: note transaction screen's inability to update; code cleanup

This commit is contained in:
Simon Michael 2023-03-24 12:44:53 -10:00
parent 056553e8a9
commit 0f4413f011
3 changed files with 24 additions and 9 deletions

View File

@ -30,7 +30,7 @@ import Hledger.UI.UIUtils
import Hledger.UI.UIScreens
import Hledger.UI.Editor
import Brick.Widgets.Edit (editorText, renderEditor)
import Hledger.UI.ErrorScreen (uiReloadJournalIfChanged, uiCheckBalanceAssertions)
import Hledger.UI.ErrorScreen (uiReloadJournalIfChanged, uiCheckBalanceAssertions, uiReloadJournal)
tsDraw :: UIState -> [Widget Name]
tsDraw UIState{aopts=UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}}
@ -145,12 +145,15 @@ tsHandle ev = do
put' $ regenerateScreens j d $ setReportPeriod (DayPeriod d) ui
where
p = reportPeriod ui
e | e `elem` [VtyEvent (EvKey (KChar 'g') []), AppEvent FileChange] -> do
-- plog (if e == AppEvent FileChange then "file change" else "manual reload") "" `seq` return ()
ej <- liftIO . runExceptT $ journalReload copts
case ej of
Left err -> put' $ pushScreen (esNew err) ui
Right j' -> put' $ regenerateScreens j' d ui
-- Reload. Warning, this updates parent screens but not the transaction screen itself (see tsUpdate).
-- To see the updated transaction, one must exit and re-enter the transaction screen.
e | e `elem` [VtyEvent (EvKey (KChar 'g') []), AppEvent FileChange] ->
liftIO (uiReloadJournal copts d ui) >>= put'
-- debugging.. leaving these here because they were hard to find
-- \u -> dbguiEv (pshow u) >> put' u -- doesn't log
-- \UIState{aScreen=TS tss} -> error $ pshow $ _tssTransaction tss
VtyEvent (EvKey (KChar 'I') []) -> put' $ uiCheckBalanceAssertions d (toggleIgnoreBalanceAssertions ui)
-- for toggles that may change the current/prev/next transactions,

View File

@ -352,8 +352,10 @@ tsNew acct nts nt =
,_tssTransaction = nt
}
-- | Update a transaction screen. Currently a no-op since transaction screen
-- depends only on its screen-specific state.
-- | Update a transaction screen.
-- This currently does nothing because the initialisation in rsHandle is not so easy to extract.
-- To see the updated transaction, one must exit and re-enter the transaction screen.
-- See also tsHandle.
tsUpdate :: TransactionScreenState -> TransactionScreenState
tsUpdate = dbgui "tsUpdate"

View File

@ -307,6 +307,16 @@ preceding them is the transaction's position within the complete
unfiltered journal, which is a more stable id (at least until the next
reload).
On this screen (and the register screen), the `E` key will open your text editor
with the cursor positioned at the current transaction if possible.
This screen has a limitation with showing file updates:
it will not show them until you exit and re-enter it.
So eg to see the effect of using the `E` key, currently you must:
- press `E`, edit and save the file, then exit the editor, returning to hledger-ui
- press `g` to reload the file (or use `-w/--watch` mode)
- press `LEFT` then `RIGHT` to exit and re-enter the transaction screen.
## Error
This screen will appear if there is a problem, such as a parse error,