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