ui: accounts: wide-char-aware layout
This commit is contained in:
parent
deea422dc1
commit
7808c502ad
@ -138,12 +138,12 @@ drawAccountsScreen _st@AppState{aopts=uopts, ajournal=j, aScreen=AccountsScreen{
|
|||||||
maxacctwidthseen =
|
maxacctwidthseen =
|
||||||
-- ltrace "maxacctwidthseen" $
|
-- ltrace "maxacctwidthseen" $
|
||||||
V.maximum $
|
V.maximum $
|
||||||
V.map (\(indent,_,displayacct,_) -> indent*2 + length displayacct) $
|
V.map (\(indent,_,displayacct,_) -> indent*2 + strWidth displayacct) $
|
||||||
-- V.filter (\(indent,_,_,_) -> (indent-1) <= fromMaybe 99999 mdepth) $
|
-- V.filter (\(indent,_,_,_) -> (indent-1) <= fromMaybe 99999 mdepth) $
|
||||||
displayitems
|
displayitems
|
||||||
maxbalwidthseen =
|
maxbalwidthseen =
|
||||||
-- ltrace "maxbalwidthseen" $
|
-- ltrace "maxbalwidthseen" $
|
||||||
V.maximum $ V.map (\(_,_,_,amts) -> sum (map length amts) + 2 * (length amts-1)) displayitems
|
V.maximum $ V.map (\(_,_,_,amts) -> sum (map strWidth amts) + 2 * (length amts-1)) displayitems
|
||||||
maxbalwidth =
|
maxbalwidth =
|
||||||
-- ltrace "maxbalwidth" $
|
-- ltrace "maxbalwidth" $
|
||||||
max 0 (availwidth - 2 - 4) -- leave 2 whitespace plus least 4 for accts
|
max 0 (availwidth - 2 - 4) -- leave 2 whitespace plus least 4 for accts
|
||||||
@ -173,12 +173,12 @@ drawAccountsItem (acctwidth, balwidth) selected (indent, _fullacct, displayacct,
|
|||||||
-- let showitem = intercalate "\n" . balanceReportItemAsText defreportopts fmt
|
-- let showitem = intercalate "\n" . balanceReportItemAsText defreportopts fmt
|
||||||
render $
|
render $
|
||||||
addamts balamts $
|
addamts balamts $
|
||||||
str (padright acctwidth $ elideRight acctwidth $ replicate (2*indent) ' ' ++ displayacct) <+>
|
str (fitString (Just acctwidth) (Just acctwidth) True True $ replicate (2*indent) ' ' ++ displayacct) <+>
|
||||||
str " " <+>
|
str " " <+>
|
||||||
str (balspace balamts)
|
str (balspace balamts)
|
||||||
where
|
where
|
||||||
balspace as = replicate n ' '
|
balspace as = replicate n ' '
|
||||||
where n = max 0 (balwidth - (sum (map length as) + 2 * (length as - 1)))
|
where n = max 0 (balwidth - (sum (map strWidth as) + 2 * (length as - 1)))
|
||||||
addamts :: [String] -> Widget -> Widget
|
addamts :: [String] -> Widget -> Widget
|
||||||
addamts [] w = w
|
addamts [] w = w
|
||||||
addamts [a] w = (<+> renderamt a) w
|
addamts [a] w = (<+> renderamt a) w
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user