From e6392b3d469acbddde95272b566949062c703c2e Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 5 Jan 2019 18:41:00 +0000 Subject: [PATCH] ui: streamline top status info --- hledger-ui/Hledger/UI/AccountsScreen.hs | 39 ++++++++++--------------- hledger-ui/Hledger/UI/UIUtils.hs | 2 +- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/hledger-ui/Hledger/UI/AccountsScreen.hs b/hledger-ui/Hledger/UI/AccountsScreen.hs index 2ea5f74e9..f86169ab1 100644 --- a/hledger-ui/Hledger/UI/AccountsScreen.hs +++ b/hledger-ui/Hledger/UI/AccountsScreen.hs @@ -173,19 +173,12 @@ asDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} toplabel = withAttr ("border" <> "filename") files - -- <+> withAttr ("border" <> "query") (str (if flat_ ropts then " flat" else "")) - <+> nonzero - <+> str (if ishistorical then " accounts" else " account changes") - -- <+> str (if ishistorical then " balances" else " changes") + <+> toggles + <+> str (" account " ++ if ishistorical then "balances" else "changes") <+> borderPeriodStr (if ishistorical then "at end of" else "in") (period_ ropts) <+> borderQueryStr querystr - <+> togglefilters <+> borderDepthStr mdepth - <+> str " (" - <+> cur - <+> str "/" - <+> total - <+> str ")" + <+> str (" ("++curidx++"/"++totidx++")") <+> (if ignore_assertions_ $ inputopts_ copts then withAttr ("border" <> "query") (str " ignoring balance assertions") else str "") @@ -195,22 +188,20 @@ asDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} f:_ -> str $ takeFileName f -- [f,_:[]] -> (withAttr ("border" <> "bold") $ str $ takeFileName f) <+> str " (& 1 included file)" -- f:fs -> (withAttr ("border" <> "bold") $ str $ takeFileName f) <+> str (" (& " ++ show (length fs) ++ " included files)") + toggles = withAttr ("border" <> "query") $ str $ unwords $ concat [ + [""] + ,if empty_ ropts then [] else ["nonzero"] + ,uiShowStatus copts $ statuses_ ropts + ,if real_ ropts then ["real"] else [] + ] querystr = query_ ropts mdepth = depth_ ropts - togglefilters = - case concat [ - uiShowStatus copts $ statuses_ ropts - ,if real_ ropts then ["real"] else [] - ] of - [] -> str "" - fs -> str " from " <+> withAttr ("border" <> "query") (str $ intercalate ", " fs) <+> str " txns" - nonzero | empty_ ropts = str "" - | otherwise = withAttr ("border" <> "query") (str " nonzero") - cur = str (case _asList s ^. listSelectedL of - Nothing -> "-" - Just i -> show (i + 1)) - total = str $ show $ V.length nonblanks - nonblanks = V.takeWhile (not . T.null . asItemAccountName) $ s ^. asList . listElementsL + curidx = case _asList s ^. listSelectedL of + Nothing -> "-" + Just i -> show (i + 1) + totidx = show $ V.length nonblanks + where + nonblanks = V.takeWhile (not . T.null . asItemAccountName) $ s ^. asList . listElementsL bottomlabel = case mode of Minibuffer ed -> minibuffer ed diff --git a/hledger-ui/Hledger/UI/UIUtils.hs b/hledger-ui/Hledger/UI/UIUtils.hs index e8f3a5126..b458f4d88 100644 --- a/hledger-ui/Hledger/UI/UIUtils.hs +++ b/hledger-ui/Hledger/UI/UIUtils.hs @@ -165,7 +165,7 @@ borderQueryStr qry = str " matching " <+> withAttr ("border" <> "query") (str qr borderDepthStr :: Maybe Int -> Widget Name borderDepthStr Nothing = str "" -borderDepthStr (Just d) = str " to " <+> withAttr ("border" <> "query") (str $ "depth "++show d) +borderDepthStr (Just d) = str " to depth " <+> withAttr ("border" <> "query") (str $ show d) borderPeriodStr :: String -> Period -> Widget Name borderPeriodStr _ PeriodAll = str ""