;cli, ui: fixes for yesterday's 4330427f

This commit is contained in:
Simon Michael 2020-12-27 12:20:50 -08:00
parent b66d8f0f3c
commit 06675bfec4
2 changed files with 4 additions and 7 deletions

View File

@ -64,7 +64,7 @@ m4_define({{_helpoptions_}}, {{
: show general or COMMAND user manual with info : show general or COMMAND user manual with info
`--version` `--version`
: show general or ADDONCOMMAND version : show general or ADDONCMD version
`--debug[=N]` `--debug[=N]`
: show debug output (levels 1-9, default: 1) : show debug output (levels 1-9, default: 1)

View File

@ -35,7 +35,6 @@ import Brick.Widgets.Edit
import Brick.Widgets.List (List, listSelectedL, listNameL, listItemHeightL) import Brick.Widgets.List (List, listSelectedL, listNameL, listItemHeightL)
import Control.Monad.IO.Class import Control.Monad.IO.Class
import Data.List import Data.List
import Data.Maybe
#if !(MIN_VERSION_base(4,11,0)) #if !(MIN_VERSION_base(4,11,0))
import Data.Monoid import Data.Monoid
#endif #endif
@ -44,7 +43,6 @@ import Graphics.Vty
-- ,Output(displayBounds,mkDisplayContext),DisplayContext(..) -- ,Output(displayBounds,mkDisplayContext),DisplayContext(..)
) )
import Lens.Micro.Platform import Lens.Micro.Platform
import System.Environment
import Hledger hiding (Color) import Hledger hiding (Color)
import Hledger.Cli (CliOpts) import Hledger.Cli (CliOpts)
@ -165,12 +163,11 @@ helpDialog _copts =
-- May invoke $PAGER, less, man or info, which is likely to fail on MS Windows, TODO. -- May invoke $PAGER, less, man or info, which is likely to fail on MS Windows, TODO.
helpHandle :: UIState -> BrickEvent Name AppEvent -> EventM Name (Next UIState) helpHandle :: UIState -> BrickEvent Name AppEvent -> EventM Name (Next UIState)
helpHandle ui ev = do helpHandle ui ev = do
pagerprog <- liftIO $ fromMaybe "less" <$> lookupEnv "PAGER"
case ev of case ev of
VtyEvent e | e `elem` closeHelpEvents -> continue $ setMode Normal ui VtyEvent e | e `elem` closeHelpEvents -> continue $ setMode Normal ui
VtyEvent (EvKey (KChar 'p') []) -> suspendAndResume $ runPagerForTopic pagerprog "hledger-ui" >> return ui' VtyEvent (EvKey (KChar 'p') []) -> suspendAndResume $ runPagerForTopic "hledger-ui" Nothing >> return ui'
VtyEvent (EvKey (KChar 'm') []) -> suspendAndResume $ runManForTopic "hledger-ui" >> return ui' VtyEvent (EvKey (KChar 'm') []) -> suspendAndResume $ runManForTopic "hledger-ui" Nothing >> return ui'
VtyEvent (EvKey (KChar 'i') []) -> suspendAndResume $ runInfoForTopic "hledger-ui" >> return ui' VtyEvent (EvKey (KChar 'i') []) -> suspendAndResume $ runInfoForTopic "hledger-ui" Nothing >> return ui'
_ -> continue ui _ -> continue ui
where where
ui' = setMode Normal ui ui' = setMode Normal ui