diff options
Diffstat (limited to 'src/format.cc')
-rw-r--r-- | src/format.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/format.cc b/src/format.cc index 4066cabd..ecac1133 100644 --- a/src/format.cc +++ b/src/format.cc @@ -38,6 +38,9 @@ namespace ledger { +format_t::elision_style_t format_t::default_style = TRUNCATE_TRAILING; +bool format_t::default_style_changed = false; + void format_t::element_t::dump(std::ostream& out) const { out << "Element: "; @@ -342,7 +345,8 @@ void format_t::format(std::ostream& out_str, scope_t& scope) } DEBUG("format.expr", "value = (" << value << ")"); - value.print(out, elem->min_width); + value.print(out, elem->min_width, -1, + ! elem->has_flags(ELEMENT_ALIGN_LEFT)); } catch (const calc_error&) { add_error_context(_("While calculating format expression:")); @@ -386,22 +390,22 @@ string format_t::truncate(const unistring& ustr, std::size_t width, std::ostringstream buf; - elision_style_t style = TRUNCATE_TRAILING; - if (account_abbrev_length > 0) + elision_style_t style = default_style; + if (account_abbrev_length > 0 && ! default_style_changed) style = ABBREVIATE; switch (style) { case TRUNCATE_LEADING: // This method truncates at the beginning. - buf << ".." << ustr.extract(len - width, width); + buf << ".." << ustr.extract(len - (width - 2), width - 2); break; case TRUNCATE_MIDDLE: // This method truncates in the middle. - buf << ustr.extract(0, width / 2) + buf << ustr.extract(0, (width - 2) / 2) << ".." - << ustr.extract(len - (width / 2 + width % 2), - width / 2 + width % 2); + << ustr.extract(len - ((width - 2) / 2 + (width - 2) % 2), + (width - 2) / 2 + (width - 2) % 2); break; case ABBREVIATE: |