lib,cli,ui: Elide amounts to a width of 32 characters, rather than 22 characters.

This commit is contained in:
Stephen Morgan 2020-11-02 14:20:19 +11:00
parent 7e47c11fda
commit 0bebda7313
5 changed files with 17 additions and 15 deletions

View File

@ -239,7 +239,7 @@ budgetReportAsText ropts@ReportOpts{..} budgetr =
where
actual' = fromMaybe 0 actual
budgetAndPerc b = (showamt b, showper <$> percentage actual' b)
showamt = showMixedOneLine showAmountWithoutPrice Nothing (Just 22) color_
showamt = showMixedOneLine showAmountWithoutPrice Nothing (Just 32) color_
showper p = let str = show (roundTo 0 p) in (str, length str)
cellWidth ((_,wa), Nothing) = (wa, 0, 0)
cellWidth ((_,wa), Just ((_,wb), Nothing)) = (wa, wb, 0)

View File

@ -93,8 +93,8 @@ rsInit d reset ui@UIState{aopts=_uopts@UIOpts{cliopts_=CliOpts{reportspec_=rspec
[s] -> s
ss -> intercalate ", " ss
-- _ -> "<split>" -- should do this if accounts field width < 30
,rsItemChangeAmount = showMixed showAmountWithoutPrice Nothing (Just 22) False change
,rsItemBalanceAmount = showMixed showAmountWithoutPrice Nothing (Just 22) False bal
,rsItemChangeAmount = showMixed showAmountWithoutPrice Nothing (Just 32) False change
,rsItemBalanceAmount = showMixed showAmountWithoutPrice Nothing (Just 32) False bal
,rsItemTransaction = t
}
-- blank items are added to allow more control of scroll position; we won't allow movement over these

View File

@ -150,7 +150,7 @@ accountTransactionsReportAsText
amtwidth = maximumStrict $ 12 : map (snd . showamt . itemamt) items
balwidth = maximumStrict $ 12 : map (snd . showamt . itembal) items
showamt = showMixedOneLine showAmountWithoutPrice (Just 12) mmax False -- color_
where mmax = if no_elide_ then Nothing else Just 22
where mmax = if no_elide_ then Nothing else Just 32
itemamt (_,_,_,_,a,_) = a
itembal (_,_,_,_,_,a) = a
-- show a title indicating which account was picked, which can be confusing otherwise

View File

@ -612,7 +612,7 @@ balanceReportTableAsText ReportOpts{..} =
where
showamt a = CellSpec str AlignRight w
where (str, w) = showMixedOneLine showAmountWithoutPrice Nothing mmax color_ a
mmax = if no_elide_ then Nothing else Just 22
mmax = if no_elide_ then Nothing else Just 32
tests_Balance = tests "Balance" [

View File

@ -5,22 +5,24 @@
(a) 1.00B
(a) 1.00C
(a) 1.00D
(a) 1.00E
(a) 1.00F
$ hledger -f- bal -Y
Balance changes in 2020:
|| 2020
===++========================
a || 1.00A, 1.00B, 2 more..
---++------------------------
|| 1.00A, 1.00B, 2 more..
|| 2020
===++===============================
a || 1.00A, 1.00B, 1.00C, 3 more..
---++-------------------------------
|| 1.00A, 1.00B, 1.00C, 3 more..
# 2. Unless --no-elide is used.
$ hledger -f- bal -Y --no-elide
Balance changes in 2020:
|| 2020
===++============================
a || 1.00A, 1.00B, 1.00C, 1.00D
---++----------------------------
|| 1.00A, 1.00B, 1.00C, 1.00D
|| 2020
===++==========================================
a || 1.00A, 1.00B, 1.00C, 1.00D, 1.00E, 1.00F
---++------------------------------------------
|| 1.00A, 1.00B, 1.00C, 1.00D, 1.00E, 1.00F