ui: basic manual integration
This commit is contained in:
parent
76519be8f9
commit
7a4c45aa4a
@ -8,17 +8,24 @@ where
|
|||||||
import Brick
|
import Brick
|
||||||
import Brick.Widgets.Border
|
import Brick.Widgets.Border
|
||||||
import Brick.Widgets.Border.Style
|
import Brick.Widgets.Border.Style
|
||||||
|
import Brick.Widgets.Center
|
||||||
import Brick.Widgets.Dialog
|
import Brick.Widgets.Dialog
|
||||||
import Brick.Widgets.Edit
|
import Brick.Widgets.Edit
|
||||||
import Data.List
|
import Data.List
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
import Graphics.Vty
|
import Graphics.Vty
|
||||||
import Lens.Micro.Platform
|
import Lens.Micro.Platform
|
||||||
|
import System.Process
|
||||||
|
|
||||||
import Hledger
|
import Hledger
|
||||||
import Hledger.UI.UITypes
|
import Hledger.UI.UITypes
|
||||||
import Hledger.UI.UIState
|
import Hledger.UI.UIState
|
||||||
|
|
||||||
|
|
||||||
|
runInfo = runCommand "hledger-ui --info" >>= waitForProcess
|
||||||
|
runMan = runCommand "hledger-ui --man" >>= waitForProcess
|
||||||
|
runHelp = runCommand "hledger-ui --help | less" >>= waitForProcess
|
||||||
|
|
||||||
-- ui
|
-- ui
|
||||||
|
|
||||||
-- | Draw the help dialog, called when help mode is active.
|
-- | Draw the help dialog, called when help mode is active.
|
||||||
@ -29,8 +36,9 @@ helpDialog =
|
|||||||
render $
|
render $
|
||||||
renderDialog (dialog "help" (Just "Help (h/ESC to close)") Nothing (c^.availWidthL - 2)) $ -- (Just (0,[("ok",())]))
|
renderDialog (dialog "help" (Just "Help (h/ESC to close)") Nothing (c^.availWidthL - 2)) $ -- (Just (0,[("ok",())]))
|
||||||
padTopBottom 1 $ padLeftRight 1 $
|
padTopBottom 1 $ padLeftRight 1 $
|
||||||
|
vBox [
|
||||||
hBox [
|
hBox [
|
||||||
(padLeftRight 1 $
|
padLeftRight 1 $
|
||||||
vBox [
|
vBox [
|
||||||
str "MISC"
|
str "MISC"
|
||||||
,renderKey ("h", "toggle help")
|
,renderKey ("h", "toggle help")
|
||||||
@ -46,8 +54,7 @@ helpDialog =
|
|||||||
,renderKey ("LEFT", "previous screen")
|
,renderKey ("LEFT", "previous screen")
|
||||||
,renderKey ("ESC", "cancel / reset")
|
,renderKey ("ESC", "cancel / reset")
|
||||||
]
|
]
|
||||||
)
|
,padLeftRight 1 $
|
||||||
,(padLeftRight 1 $
|
|
||||||
vBox [
|
vBox [
|
||||||
str "FILTERING"
|
str "FILTERING"
|
||||||
,renderKey ("/", "set a filter query")
|
,renderKey ("/", "set a filter query")
|
||||||
@ -60,7 +67,20 @@ helpDialog =
|
|||||||
,str "accounts screen:"
|
,str "accounts screen:"
|
||||||
,renderKey ("-+0123456789", "set depth limit")
|
,renderKey ("-+0123456789", "set depth limit")
|
||||||
]
|
]
|
||||||
)
|
]
|
||||||
|
,vBox [
|
||||||
|
str " "
|
||||||
|
,hCenter $ padLeftRight 1 $
|
||||||
|
hCenter (str "MANUAL")
|
||||||
|
<=>
|
||||||
|
hCenter (hBox [
|
||||||
|
renderKey ("t", "text")
|
||||||
|
,str " "
|
||||||
|
,renderKey ("m", "man page")
|
||||||
|
,str " "
|
||||||
|
,renderKey ("i", "info")
|
||||||
|
])
|
||||||
|
]
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
renderKey (key,desc) = withAttr (borderAttr <> "keys") (str key) <+> str " " <+> str desc
|
renderKey (key,desc) = withAttr (borderAttr <> "keys") (str key) <+> str " " <+> str desc
|
||||||
@ -69,7 +89,10 @@ helpDialog =
|
|||||||
helpHandle :: UIState -> Event -> EventM (Next UIState)
|
helpHandle :: UIState -> Event -> EventM (Next UIState)
|
||||||
helpHandle ui ev =
|
helpHandle ui ev =
|
||||||
case ev of
|
case ev of
|
||||||
EvKey k [] | k `elem` [KEsc, KChar 'h'] -> continue $ setMode Normal ui
|
EvKey k [] | k `elem` [KEsc, KChar 'h', KChar '?'] -> continue $ setMode Normal ui
|
||||||
|
EvKey (KChar 't') [] -> suspendAndResume $ runHelp >> return (setMode Normal ui)
|
||||||
|
EvKey (KChar 'm') [] -> suspendAndResume $ runMan >> return (setMode Normal ui)
|
||||||
|
EvKey (KChar 'i') [] -> suspendAndResume $ runInfo >> return (setMode Normal ui)
|
||||||
_ -> continue ui
|
_ -> continue ui
|
||||||
|
|
||||||
-- | Draw the minibuffer.
|
-- | Draw the minibuffer.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user