summaryrefslogtreecommitdiff
path: root/src/value.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/value.cc')
-rw-r--r--src/value.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/value.cc b/src/value.cc
index 53e2bdeb..6f6e665d 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -573,6 +573,7 @@ value_t& value_t::operator*=(const value_t& val)
return *this;
case AMOUNT:
if (as_amount().commodity() == val.as_amount().commodity() ||
+ ! as_amount().has_commodity() ||
! val.as_amount().has_commodity()) {
as_amount_lval() *= val.as_amount();
return *this;
@@ -1423,10 +1424,12 @@ void value_t::print(std::ostream& out,
const int first_width,
const int latter_width,
const bool right_justify,
+ const bool colorize,
const optional<string>& date_format) const
{
if (first_width > 0 &&
- ! is_amount() && ! is_balance() && ! is_string()) {
+ (! is_amount() || as_amount().is_zero()) &&
+ ! is_balance() && ! is_string()) {
out.width(first_width);
if (right_justify)
@@ -1459,17 +1462,20 @@ void value_t::print(std::ostream& out,
break;
case INTEGER:
- out << std::right << as_long();
+ if (colorize && as_long() < 0)
+ justify(out, to_string(), first_width, right_justify, true);
+ else
+ out << as_long();
break;
case AMOUNT: {
if (as_amount().is_zero()) {
- out.width(first_width);
- out << (right_justify ? std::right : std::left) << 0;
+ out << 0;
} else {
std::ostringstream buf;
buf << as_amount();
- justify(out, buf.str(), first_width, right_justify);
+ justify(out, buf.str(), first_width, right_justify,
+ colorize && as_amount().sign() < 0);
}
break;
}
@@ -1492,14 +1498,15 @@ void value_t::print(std::ostream& out,
out << ", ";
value.print(out, first_width, latter_width, right_justify,
- date_format);
+ colorize, date_format);
}
out << ')';
break;
}
case BALANCE:
- as_balance().print(out, first_width, latter_width, right_justify);
+ as_balance().print(out, first_width, latter_width, right_justify,
+ colorize);
break;
case POINTER: