dev: AmountFormat: add displayQuotes property to control enclosing quotes
This commit is contained in:
parent
4b1b97a6aa
commit
cbdbe0a855
@ -242,6 +242,7 @@ data AmountFormat = AmountFormat
|
|||||||
, displayMaxWidth :: Maybe Int -- ^ Maximum width to clip to
|
, displayMaxWidth :: Maybe Int -- ^ Maximum width to clip to
|
||||||
, displayCost :: Bool -- ^ Whether to display Amounts' costs.
|
, displayCost :: Bool -- ^ Whether to display Amounts' costs.
|
||||||
, displayColour :: Bool -- ^ Whether to ansi-colourise negative Amounts.
|
, displayColour :: Bool -- ^ Whether to ansi-colourise negative Amounts.
|
||||||
|
, displayQuotes :: Bool -- ^ Whether to enclose complex symbols in quotes (normally true)
|
||||||
} deriving (Show)
|
} deriving (Show)
|
||||||
|
|
||||||
-- | By default, display amounts using @defaultFmt@ amount display options.
|
-- | By default, display amounts using @defaultFmt@ amount display options.
|
||||||
@ -260,6 +261,7 @@ defaultFmt = AmountFormat {
|
|||||||
, displayMaxWidth = Nothing
|
, displayMaxWidth = Nothing
|
||||||
, displayCost = True
|
, displayCost = True
|
||||||
, displayColour = False
|
, displayColour = False
|
||||||
|
, displayQuotes = True
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Like defaultFmt but show zero amounts with commodity symbol and styling, like non-zero amounts.
|
-- | Like defaultFmt but show zero amounts with commodity symbol and styling, like non-zero amounts.
|
||||||
@ -655,7 +657,7 @@ showAmountB :: AmountFormat -> Amount -> WideBuilder
|
|||||||
showAmountB _ Amount{acommodity="AUTO"} = mempty
|
showAmountB _ Amount{acommodity="AUTO"} = mempty
|
||||||
showAmountB
|
showAmountB
|
||||||
afmt@AmountFormat{displayCommodity, displayZeroCommodity, displayDigitGroups
|
afmt@AmountFormat{displayCommodity, displayZeroCommodity, displayDigitGroups
|
||||||
,displayForceDecimalMark, displayCost, displayColour}
|
,displayForceDecimalMark, displayCost, displayColour, displayQuotes}
|
||||||
a@Amount{astyle=style} =
|
a@Amount{astyle=style} =
|
||||||
color $ case ascommodityside style of
|
color $ case ascommodityside style of
|
||||||
L -> (if displayCommodity then wbFromText comm <> space else mempty) <> quantity' <> cost
|
L -> (if displayCommodity then wbFromText comm <> space else mempty) <> quantity' <> cost
|
||||||
@ -666,7 +668,7 @@ showAmountB
|
|||||||
if displayDigitGroups then a else a{astyle=(astyle a){asdigitgroups=Nothing}}
|
if displayDigitGroups then a else a{astyle=(astyle a){asdigitgroups=Nothing}}
|
||||||
(quantity', comm)
|
(quantity', comm)
|
||||||
| amountLooksZero a && not displayZeroCommodity = (WideBuilder (TB.singleton '0') 1, "")
|
| amountLooksZero a && not displayZeroCommodity = (WideBuilder (TB.singleton '0') 1, "")
|
||||||
| otherwise = (quantity, quoteCommoditySymbolIfNeeded $ acommodity a)
|
| otherwise = (quantity, (if displayQuotes then quoteCommoditySymbolIfNeeded else id) $ acommodity a)
|
||||||
space = if not (T.null comm) && ascommodityspaced style then WideBuilder (TB.singleton ' ') 1 else mempty
|
space = if not (T.null comm) && ascommodityspaced style then WideBuilder (TB.singleton ' ') 1 else mempty
|
||||||
cost = if displayCost then showAmountCostB afmt a else mempty
|
cost = if displayCost then showAmountCostB afmt a else mempty
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user