Skip to content

Commit

Permalink
cli: Cli.Commands.Balance: use normal space for indentation in text o…
Browse files Browse the repository at this point in the history
…utput format
  • Loading branch information
thielema committed Oct 1, 2024
1 parent 3bbd12c commit c326e0c
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions hledger/Hledger/Cli/Commands/Balance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ balanceReportAsSpreadsheet opts (items, total) =
setAccountAnchor
(guard (rc==Value) >> balance_base_url_ opts)
(querystring_ opts) name $
cell $ renderBalanceAcct opts (name, dispName, dep) in
cell $ renderBalanceAcct opts nbsp (name, dispName, dep) in
addRowSpanHeader accountCell $
case layout_ opts of
LayoutBare ->
Expand Down Expand Up @@ -808,7 +808,7 @@ multiBalanceReportAsSpreadsheetHelper ishtml opts@ReportOpts{..} (PeriodicReport
where acctName = prrFullName row
anchorCell =
setAccountAnchor balance_base_url_ querystring_ acctName $
accountCell $ renderPeriodicAcct opts row
accountCell $ renderPeriodicAcct opts nbsp row
totalrows =
if no_total_
then []
Expand Down Expand Up @@ -1159,7 +1159,7 @@ budgetReportAsTable ropts@ReportOpts{..} (PeriodicReport spans items totrow) =
shownitems =
map (\i ->
let
addacctcolumn = map (\(cs, cvals) -> (renderPeriodicAcct ropts i, cs, cvals))
addacctcolumn = map (\(cs, cvals) -> (renderPeriodicAcct ropts " " i, cs, cvals))
isunbudgetedrow = displayFull (prrName i) == unbudgetedAccountName
in addacctcolumn $ showrow isunbudgetedrow $ rowToBudgetCells i)
items
Expand Down Expand Up @@ -1332,18 +1332,24 @@ budgetReportAsSpreadsheet
querystring_ name (cell name)


renderBalanceAcct :: ReportOpts -> (AccountName, AccountName, Int) -> Text
renderBalanceAcct opts (fullName, displayName, dep) =
nbsp :: Text
nbsp = "\160"

renderBalanceAcct ::
ReportOpts -> Text -> (AccountName, AccountName, Int) -> Text
renderBalanceAcct opts space (fullName, displayName, dep) =
case accountlistmode_ opts of
ALTree -> T.replicate ((dep - 1)*2) "\160" <> displayName
ALTree -> T.replicate ((dep - 1)*2) space <> displayName
ALFlat -> accountNameDrop (drop_ opts) fullName

-- FIXME. Have to check explicitly for which to render here, since
-- budgetReport sets accountlistmode to ALTree. Find a principled way to do
-- this.
renderPeriodicAcct :: ReportOpts -> PeriodicReportRow DisplayName a -> Text
renderPeriodicAcct opts row =
renderBalanceAcct opts (prrFullName row, prrDisplayName row, prrDepth row)
renderPeriodicAcct ::
ReportOpts -> Text -> PeriodicReportRow DisplayName a -> Text
renderPeriodicAcct opts space row =
renderBalanceAcct opts space
(prrFullName row, prrDisplayName row, prrDepth row)


-- tests
Expand Down

0 comments on commit c326e0c

Please sign in to comment.