ui: the A key runs hledger-iadd (if available)

This commit is contained in:
Simon Michael 2016-12-08 13:18:56 -08:00
parent 7483be02fa
commit 31e4f538c0
4 changed files with 9 additions and 1 deletions

View File

@ -299,6 +299,7 @@ asHandle ui0@UIState{
liftIO (uiReloadJournal copts d ui) >>= continue
VtyEvent (EvKey (KChar 'I') []) -> continue $ uiCheckBalanceAssertions d (toggleIgnoreBalanceAssertions ui)
VtyEvent (EvKey (KChar 'a') []) -> suspendAndResume $ clearScreen >> setCursorPosition 0 0 >> add copts j >> uiReloadJournalIfChanged copts d j ui
VtyEvent (EvKey (KChar 'A') []) -> suspendAndResume $ void (runIadd (journalFilePath j)) >> uiReloadJournalIfChanged copts d j ui
VtyEvent (EvKey (KChar 'E') []) -> suspendAndResume $ void (runEditor endPos (journalFilePath j)) >> uiReloadJournalIfChanged copts d j ui
VtyEvent (EvKey (KChar '0') []) -> continue $ regenerateScreens j d $ setDepth (Just 0) ui
VtyEvent (EvKey (KChar '1') []) -> continue $ regenerateScreens j d $ setDepth (Just 1) ui

View File

@ -26,6 +26,11 @@ type TextPosition = (Int, Maybe Int)
endPos :: Maybe TextPosition
endPos = Just (-1,Nothing)
-- | Run the hledger-iadd executable (an alternative to the built-in add command),
-- or raise an error.
runIadd :: FilePath -> IO ExitCode
runIadd f = runCommand ("hledger-iadd -f " ++ f) >>= waitForProcess
-- | Try running the user's preferred text editor, or a default edit command,
-- on the main journal file, blocking until it exits, and returning the exit code;
-- or raise an error.

View File

@ -275,6 +275,7 @@ rsHandle ui@UIState{
liftIO (uiReloadJournal copts d ui) >>= continue
VtyEvent (EvKey (KChar 'I') []) -> continue $ uiCheckBalanceAssertions d (toggleIgnoreBalanceAssertions ui)
VtyEvent (EvKey (KChar 'a') []) -> suspendAndResume $ clearScreen >> setCursorPosition 0 0 >> add copts j >> uiReloadJournalIfChanged copts d j ui
VtyEvent (EvKey (KChar 'A') []) -> suspendAndResume $ void (runIadd (journalFilePath j)) >> uiReloadJournalIfChanged copts d j ui
VtyEvent (EvKey (KChar 't') []) -> continue $ regenerateScreens j d $ setReportPeriod (DayPeriod d) ui
VtyEvent (EvKey (KChar 'E') []) -> suspendAndResume $ void (runEditor pos f) >> uiReloadJournalIfChanged copts d j ui
where

View File

@ -56,7 +56,8 @@ helpDialog =
,str " "
,str "MISC"
,renderKey ("?", "toggle help")
,renderKey ("a", "add transaction")
,renderKey ("a", "add transaction (hledger add)")
,renderKey ("A", "add transaction (hledger-iadd)")
,renderKey ("E", "open editor")
,renderKey ("g", "reload data")
,renderKey ("I", "toggle balance assertions")