mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-27 04:13:11 +03:00
ui: drop unneeded args field, use opts instead
This commit is contained in:
parent
898b0ec82a
commit
d1467d7967
@ -40,7 +40,7 @@ screen = AccountsScreen{
|
||||
}
|
||||
|
||||
initAccountsScreen :: Maybe AccountName -> Day -> AppState -> AppState
|
||||
initAccountsScreen mselacct d st@AppState{aopts=opts, aargs=args, ajournal=j, aScreen=s@AccountsScreen{}} =
|
||||
initAccountsScreen mselacct d st@AppState{aopts=opts, ajournal=j, aScreen=s@AccountsScreen{}} =
|
||||
st{aScreen=s{asState=is''}}
|
||||
where
|
||||
is' = list (Name "accounts") (V.fromList items) 1
|
||||
@ -60,7 +60,6 @@ initAccountsScreen mselacct d st@AppState{aopts=opts, aargs=args, ajournal=j, aS
|
||||
--{query_=unwords' $ locArgs l}
|
||||
ropts = (reportopts_ cliopts)
|
||||
{
|
||||
query_=unwords' args,
|
||||
balancetype_=HistoricalBalance -- XXX balanceReport doesn't respect this yet
|
||||
}
|
||||
cliopts = cliopts_ opts
|
||||
@ -131,7 +130,7 @@ drawAccountsItem fmt _sel item =
|
||||
render $ str $ showitem item
|
||||
|
||||
handleAccountsScreen :: AppState -> Vty.Event -> EventM (Next AppState)
|
||||
handleAccountsScreen st@AppState{aargs=args, aScreen=scr@AccountsScreen{asState=is}} e = do
|
||||
handleAccountsScreen st@AppState{aScreen=scr@AccountsScreen{asState=is}} e = do
|
||||
d <- liftIO getCurrentDay
|
||||
-- c <- getContext
|
||||
-- let h = c^.availHeightL
|
||||
@ -155,7 +154,7 @@ handleAccountsScreen st@AppState{aargs=args, aScreen=scr@AccountsScreen{asState=
|
||||
Vty.EvKey (Vty.KChar '9') [] -> continue $ initAccountsScreen (Just acct) d $ setDepth 9 st
|
||||
Vty.EvKey (Vty.KLeft) [] -> continue $ popScreen st
|
||||
Vty.EvKey (Vty.KRight) [] -> do
|
||||
let st' = screenEnter d args RS.screen{rsAcct=acct} st
|
||||
let st' = screenEnter d RS.screen{rsAcct=acct} st
|
||||
vScrollToBeginning $ viewportScroll "register"
|
||||
continue st'
|
||||
|
||||
|
@ -62,12 +62,10 @@ runBrickUi opts j = do
|
||||
let
|
||||
theme = maybe defaultTheme (fromMaybe defaultTheme . getTheme) $
|
||||
maybestringopt "theme" $ rawopts_ $ cliopts_ opts
|
||||
args = words' $ query_ $ reportopts_ $ cliopts_ opts
|
||||
scr = AS.screen
|
||||
st = (sInitFn scr) d
|
||||
AppState{
|
||||
aopts=opts
|
||||
,aargs=args
|
||||
,ajournal=j
|
||||
,aScreen=scr
|
||||
,aPrevScreens=[]
|
||||
|
@ -38,14 +38,13 @@ screen = RegisterScreen{
|
||||
}
|
||||
|
||||
initRegisterScreen :: Day -> AppState -> AppState
|
||||
initRegisterScreen d st@AppState{aargs=args, aopts=opts, ajournal=j, aScreen=s@RegisterScreen{rsAcct=acct}} =
|
||||
initRegisterScreen d st@AppState{aopts=opts, ajournal=j, aScreen=s@RegisterScreen{rsAcct=acct}} =
|
||||
st{aScreen=s{rsState=l}}
|
||||
where
|
||||
-- gather arguments and queries
|
||||
ropts = (reportopts_ $ cliopts_ opts)
|
||||
{
|
||||
depth_=Nothing,
|
||||
query_=unwords' args,
|
||||
balancetype_=HistoricalBalance
|
||||
}
|
||||
-- XXX temp
|
||||
|
@ -14,7 +14,7 @@ import Hledger.UI.Options
|
||||
-- from, brick's App.
|
||||
data AppState = AppState {
|
||||
aopts :: UIOpts -- ^ command-line options at startup
|
||||
,aargs :: [String] -- ^ command-line arguments at startup
|
||||
-- ,aargs :: [String] -- ^ command-line arguments at startup
|
||||
,ajournal :: Journal -- ^ the parsed journal
|
||||
,aScreen :: Screen -- ^ the currently active screen
|
||||
,aPrevScreens :: [Screen] -- ^ previously visited screens
|
||||
|
@ -45,12 +45,10 @@ popScreen st = st
|
||||
|
||||
-- | Enter a new screen, saving the old screen & state in the
|
||||
-- navigation history and initialising the new screen's state.
|
||||
-- Extra args can be passed to the new screen's init function,
|
||||
-- these can be eg query arguments.
|
||||
screenEnter :: Day -> [String] -> Screen -> AppState -> AppState
|
||||
screenEnter d args scr st = (sInitFn scr) d $
|
||||
pushScreen scr
|
||||
st{aargs=args}
|
||||
screenEnter :: Day -> Screen -> AppState -> AppState
|
||||
screenEnter d scr st = (sInitFn scr) d $
|
||||
pushScreen scr
|
||||
st
|
||||
|
||||
-- | In the EventM monad, get the named current viewport's width and height,
|
||||
-- or (0,0) if the named viewport is not found.
|
||||
|
Loading…
Reference in New Issue
Block a user