diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-20 14:18:41 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-20 15:41:48 -0400 |
commit | e05f29bff0c8c566845c06089aa5416a5166914f (patch) | |
tree | 1dd519067b9498658ae5be0208191a7ee671fe97 /src/global.cc | |
parent | a181ac52d37b339ccc6723e8b74655bba338e5ef (diff) | |
download | fork-ledger-e05f29bff0c8c566845c06089aa5416a5166914f.tar.gz fork-ledger-e05f29bff0c8c566845c06089aa5416a5166914f.tar.bz2 fork-ledger-e05f29bff0c8c566845c06089aa5416a5166914f.zip |
Don't use auto-widths for widths explicitly given
Diffstat (limited to 'src/global.cc')
-rw-r--r-- | src/global.cc | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/src/global.cc b/src/global.cc index f967d3e9..e3cfc853 100644 --- a/src/global.cc +++ b/src/global.cc @@ -407,30 +407,49 @@ void global_scope_t::normalize_report_options(const string& verb) DEBUG("auto.columns", "cols = " << cols); long date_width = rep.HANDLER(date_width_).value.to_long(); - long payee_width = int(double(cols) * 0.263157); - long account_width = int(double(cols) * 0.302631); - long amount_width = int(double(cols) * 0.157894); - long total_width = amount_width; - - DEBUG("auto.columns", "date_width = " << date_width); - DEBUG("auto.columns", "payee_width = " << payee_width); + long payee_width = (rep.HANDLER(payee_width_).specified ? + rep.HANDLER(payee_width_).value.to_long() : + int(double(cols) * 0.263157)); + long account_width = (rep.HANDLER(account_width_).specified ? + rep.HANDLER(account_width_).value.to_long() : + int(double(cols) * 0.302631)); + long amount_width = (rep.HANDLER(amount_width_).specified ? + rep.HANDLER(amount_width_).value.to_long() : + int(double(cols) * 0.157894)); + long total_width = (rep.HANDLER(total_width_).specified ? + rep.HANDLER(total_width_).value.to_long() : + amount_width); + + DEBUG("auto.columns", "date_width = " << date_width); + DEBUG("auto.columns", "payee_width = " << payee_width); DEBUG("auto.columns", "account_width = " << account_width); - DEBUG("auto.columns", "amount_width = " << amount_width); - DEBUG("auto.columns", "total_width = " << total_width); - - long total = (4 /* the spaces between */ + date_width + payee_width + - account_width + amount_width + total_width); - if (total > cols) { - DEBUG("auto.columns", "adjusting account down"); - account_width -= total - cols; - DEBUG("auto.columns", "account_width now = " << account_width); + DEBUG("auto.columns", "amount_width = " << amount_width); + DEBUG("auto.columns", "total_width = " << total_width); + + if (! rep.HANDLER(date_width_).specified && + ! rep.HANDLER(payee_width_).specified && + ! rep.HANDLER(account_width_).specified && + ! rep.HANDLER(amount_width_).specified && + ! rep.HANDLER(total_width_).specified) { + long total = (4 /* the spaces between */ + date_width + payee_width + + account_width + amount_width + total_width); + if (total > cols) { + DEBUG("auto.columns", "adjusting account down"); + account_width -= total - cols; + DEBUG("auto.columns", "account_width now = " << account_width); + } } - rep.HANDLER(date_width_).on_with(date_width); - rep.HANDLER(payee_width_).on_with(payee_width); - rep.HANDLER(account_width_).on_with(account_width); - rep.HANDLER(amount_width_).on_with(amount_width); - rep.HANDLER(total_width_).on_with(total_width); + if (! rep.HANDLER(date_width_).specified) + rep.HANDLER(date_width_).on_with(date_width); + if (! rep.HANDLER(payee_width_).specified) + rep.HANDLER(payee_width_).on_with(payee_width); + if (! rep.HANDLER(account_width_).specified) + rep.HANDLER(account_width_).on_with(account_width); + if (! rep.HANDLER(amount_width_).specified) + rep.HANDLER(amount_width_).on_with(amount_width); + if (! rep.HANDLER(total_width_).specified) + rep.HANDLER(total_width_).on_with(total_width); } } |