doc: ui: note transaction screen's inability to update; code cleanup
This commit is contained in:
parent
056553e8a9
commit
0f4413f011
@ -30,7 +30,7 @@ import Hledger.UI.UIUtils
|
|||||||
import Hledger.UI.UIScreens
|
import Hledger.UI.UIScreens
|
||||||
import Hledger.UI.Editor
|
import Hledger.UI.Editor
|
||||||
import Brick.Widgets.Edit (editorText, renderEditor)
|
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 -> [Widget Name]
|
||||||
tsDraw UIState{aopts=UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}}
|
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
|
put' $ regenerateScreens j d $ setReportPeriod (DayPeriod d) ui
|
||||||
where
|
where
|
||||||
p = reportPeriod ui
|
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 ()
|
-- Reload. Warning, this updates parent screens but not the transaction screen itself (see tsUpdate).
|
||||||
ej <- liftIO . runExceptT $ journalReload copts
|
-- To see the updated transaction, one must exit and re-enter the transaction screen.
|
||||||
case ej of
|
e | e `elem` [VtyEvent (EvKey (KChar 'g') []), AppEvent FileChange] ->
|
||||||
Left err -> put' $ pushScreen (esNew err) ui
|
liftIO (uiReloadJournal copts d ui) >>= put'
|
||||||
Right j' -> put' $ regenerateScreens j' d ui
|
-- 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)
|
VtyEvent (EvKey (KChar 'I') []) -> put' $ uiCheckBalanceAssertions d (toggleIgnoreBalanceAssertions ui)
|
||||||
|
|
||||||
-- for toggles that may change the current/prev/next transactions,
|
-- for toggles that may change the current/prev/next transactions,
|
||||||
|
|||||||
@ -352,8 +352,10 @@ tsNew acct nts nt =
|
|||||||
,_tssTransaction = nt
|
,_tssTransaction = nt
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Update a transaction screen. Currently a no-op since transaction screen
|
-- | Update a transaction screen.
|
||||||
-- depends only on its screen-specific state.
|
-- 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 :: TransactionScreenState -> TransactionScreenState
|
||||||
tsUpdate = dbgui "tsUpdate"
|
tsUpdate = dbgui "tsUpdate"
|
||||||
|
|
||||||
|
|||||||
@ -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
|
unfiltered journal, which is a more stable id (at least until the next
|
||||||
reload).
|
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
|
## Error
|
||||||
|
|
||||||
This screen will appear if there is a problem, such as a parse error,
|
This screen will appear if there is a problem, such as a parse error,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user