mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-27 20:36:07 +03:00
ui: simplify & format screen titles
This commit is contained in:
parent
b38db8610f
commit
e5f00b3e05
@ -58,19 +58,19 @@ initAccountsScreen _ _ _ = error "init function called with wrong screen type, s
|
|||||||
drawAccountsScreen :: AppState -> [Widget]
|
drawAccountsScreen :: AppState -> [Widget]
|
||||||
drawAccountsScreen st@AppState{aopts=uopts, ajournal=j, aScreen=AccountsScreen{asState=is}} = [ui]
|
drawAccountsScreen st@AppState{aopts=uopts, ajournal=j, aScreen=AccountsScreen{asState=is}} = [ui]
|
||||||
where
|
where
|
||||||
label = str "Accounts in "
|
label = files
|
||||||
<+> withAttr ("border" <> "bold") files
|
<+> str " accounts"
|
||||||
<+> borderQuery querystr
|
<+> borderQuery querystr
|
||||||
<+> str " ("
|
<+> str " ("
|
||||||
<+> cur
|
<+> cur
|
||||||
<+> str " of "
|
<+> str " of "
|
||||||
<+> total
|
<+> total
|
||||||
<+> str ")"
|
<+> str ")"
|
||||||
files = str $ case journalFilePaths j of
|
files = case journalFilePaths j of
|
||||||
[] -> ""
|
[] -> str ""
|
||||||
[f] -> takeFileName f
|
[f] -> withAttr ("border" <> "bold") $ str $ takeFileName f
|
||||||
[f,_] -> takeFileName f ++ " (& 1 included file)"
|
[f,_] -> (withAttr ("border" <> "bold") $ str $ takeFileName f) <+> str " (& 1 included file)"
|
||||||
f:fs -> takeFileName f ++ " (& " ++ show (length fs) ++ " included files)"
|
f:fs -> (withAttr ("border" <> "bold") $ str $ takeFileName f) <+> str (" (& " ++ show (length fs) ++ " included files)")
|
||||||
querystr = query_ $ reportopts_ $ cliopts_ uopts
|
querystr = query_ $ reportopts_ $ cliopts_ uopts
|
||||||
cur = str (case is^.listSelectedL of
|
cur = str (case is^.listSelectedL of
|
||||||
Nothing -> "-"
|
Nothing -> "-"
|
||||||
|
@ -48,13 +48,19 @@ initRegisterScreen2 d args st@AppState{aopts=opts, ajournal=j, aScreen=s@Registe
|
|||||||
balancetype_=HistoricalBalance
|
balancetype_=HistoricalBalance
|
||||||
}
|
}
|
||||||
-- XXX temp
|
-- XXX temp
|
||||||
thisacctq = Acct $ accountNameToAccountRegex acct -- XXX why is this excluding subs: accountNameToAccountRegex curacct
|
thisacctq = Acct $ accountNameToAccountRegex acct -- includes subs
|
||||||
q = queryFromOpts d ropts
|
q = queryFromOpts d ropts
|
||||||
-- query_="cur:\\$"} -- XXX limit to one commodity to ensure one-line items
|
-- query_="cur:\\$"} -- XXX limit to one commodity to ensure one-line items
|
||||||
--{query_=unwords' $ locArgs l}
|
--{query_=unwords' $ locArgs l}
|
||||||
|
|
||||||
-- run a transactions report, most recent last
|
-- run a transactions report, most recent last
|
||||||
(_label,items') = accountTransactionsReport ropts j q thisacctq
|
q' =
|
||||||
|
-- ltrace "q"
|
||||||
|
q
|
||||||
|
thisacctq' =
|
||||||
|
-- ltrace "thisacctq"
|
||||||
|
thisacctq
|
||||||
|
(_label,items') = accountTransactionsReport ropts j q' thisacctq'
|
||||||
items = reverse items'
|
items = reverse items'
|
||||||
|
|
||||||
-- pre-render all items; these will be the List elements. This helps calculate column widths.
|
-- pre-render all items; these will be the List elements. This helps calculate column widths.
|
||||||
@ -82,8 +88,8 @@ drawRegisterScreen2 :: AppState -> [Widget]
|
|||||||
drawRegisterScreen2 AppState{aopts=_uopts@UIOpts{cliopts_=_copts@CliOpts{reportopts_=_ropts@ReportOpts{query_=querystr}}},
|
drawRegisterScreen2 AppState{aopts=_uopts@UIOpts{cliopts_=_copts@CliOpts{reportopts_=_ropts@ReportOpts{query_=querystr}}},
|
||||||
aargs=_args, aScreen=RegisterScreen2{rs2State=l,rs2Acct=acct}} = [ui]
|
aargs=_args, aScreen=RegisterScreen2{rs2State=l,rs2Acct=acct}} = [ui]
|
||||||
where
|
where
|
||||||
label = str "Transactions in "
|
label = withAttr ("border" <> "bold") (str acct)
|
||||||
<+> withAttr ("border" <> "bold") (str acct)
|
<+> str " transactions"
|
||||||
<+> borderQuery querystr
|
<+> borderQuery querystr
|
||||||
-- <+> str " and subs"
|
-- <+> str " and subs"
|
||||||
<+> str " ("
|
<+> str " ("
|
||||||
|
@ -125,4 +125,4 @@ withBorderAttr attr = updateAttrMap (applyAttrMappings [(borderAttr, attr)])
|
|||||||
|
|
||||||
borderQuery :: String -> Widget
|
borderQuery :: String -> Widget
|
||||||
borderQuery "" = str ""
|
borderQuery "" = str ""
|
||||||
borderQuery qry = str " filtered by: " <+> withAttr (borderAttr <> "query") (str qry)
|
borderQuery qry = str " matching " <+> withAttr (borderAttr <> "query") (str qry)
|
||||||
|
Loading…
Reference in New Issue
Block a user