register: refactor layout code
This commit is contained in:
parent
73bc81cd7e
commit
37f08a35c0
@ -106,9 +106,13 @@ showtxns (t:ts) tprev bal = this ++ showtxns ts t bal'
|
|||||||
showtxn :: Bool -> Transaction -> MixedAmount -> String
|
showtxn :: Bool -> Transaction -> MixedAmount -> String
|
||||||
showtxn omitdesc t b = concatBottomPadded [entrydesc ++ p ++ " ", bal] ++ "\n"
|
showtxn omitdesc t b = concatBottomPadded [entrydesc ++ p ++ " ", bal] ++ "\n"
|
||||||
where
|
where
|
||||||
entrydesc = if omitdesc then replicate 32 ' ' else printf "%s %s " date desc
|
ledger3ishlayout = False
|
||||||
|
datedescwidth = if ledger3ishlayout then 34 else 32
|
||||||
|
entrydesc = if omitdesc then replicate datedescwidth ' ' else printf "%s %s " date desc
|
||||||
date = showDate da
|
date = showDate da
|
||||||
desc = printf "%-20s" $ elideRight 20 de :: String
|
datewidth = 10
|
||||||
|
descwidth = datedescwidth - datewidth - 2
|
||||||
|
desc = printf ("%-"++(show descwidth)++"s") $ elideRight descwidth de :: String
|
||||||
p = showPostingWithoutPrice $ Posting s a amt "" tt
|
p = showPostingWithoutPrice $ Posting s a amt "" tt
|
||||||
bal = padleft 12 (showMixedAmountOrZeroWithoutPrice b)
|
bal = padleft 12 (showMixedAmountOrZeroWithoutPrice b)
|
||||||
Transaction{tstatus=s,tdate=da,tdescription=de,taccount=a,tamount=amt,ttype=tt} = t
|
Transaction{tstatus=s,tdate=da,tdescription=de,taccount=a,tamount=amt,ttype=tt} = t
|
||||||
|
|||||||
@ -25,11 +25,13 @@ showPosting :: Posting -> String
|
|||||||
showPosting (Posting _ a amt com ttype) =
|
showPosting (Posting _ a amt com ttype) =
|
||||||
concatTopPadded [showaccountname a ++ " ", showamount amt, comment]
|
concatTopPadded [showaccountname a ++ " ", showamount amt, comment]
|
||||||
where
|
where
|
||||||
showaccountname = printf "%-22s" . bracket . elideAccountName width
|
ledger3ishlayout = False
|
||||||
|
acctnamewidth = if ledger3ishlayout then 25 else 22
|
||||||
|
showaccountname = printf ("%-"++(show acctnamewidth)++"s") . bracket . elideAccountName width
|
||||||
(bracket,width) = case ttype of
|
(bracket,width) = case ttype of
|
||||||
BalancedVirtualPosting -> (\s -> "["++s++"]", 20)
|
BalancedVirtualPosting -> (\s -> "["++s++"]", acctnamewidth-2)
|
||||||
VirtualPosting -> (\s -> "("++s++")", 20)
|
VirtualPosting -> (\s -> "("++s++")", acctnamewidth-2)
|
||||||
_ -> (id,22)
|
_ -> (id,acctnamewidth)
|
||||||
showamount = padleft 12 . showMixedAmountOrZero
|
showamount = padleft 12 . showMixedAmountOrZero
|
||||||
comment = if null com then "" else " ; " ++ com
|
comment = if null com then "" else " ; " ++ com
|
||||||
-- XXX refactor
|
-- XXX refactor
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user