Don't use auto-widths for widths explicitly given
This commit is contained in:
parent
a181ac52d3
commit
e05f29bff0
2 changed files with 58 additions and 29 deletions
|
|
@ -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;
|
||||
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", "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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
30
src/report.h
30
src/report.h
|
|
@ -565,10 +565,15 @@ public:
|
|||
|
||||
OPTION_(report_t, wide, DO() { // -w
|
||||
parent->HANDLER(date_width_).on_with(9L);
|
||||
parent->HANDLER(date_width_).specified = true;
|
||||
parent->HANDLER(payee_width_).on_with(35L);
|
||||
parent->HANDLER(payee_width_).specified = true;
|
||||
parent->HANDLER(account_width_).on_with(39L);
|
||||
parent->HANDLER(account_width_).specified = true;
|
||||
parent->HANDLER(amount_width_).on_with(22L);
|
||||
parent->HANDLER(amount_width_).specified = true;
|
||||
parent->HANDLER(total_width_).on_with(22L);
|
||||
parent->HANDLER(total_width_).specified = true;
|
||||
});
|
||||
|
||||
OPTION_(report_t, yearly, DO() { // -Y
|
||||
|
|
@ -576,20 +581,25 @@ public:
|
|||
});
|
||||
|
||||
OPTION__(report_t, date_width_,
|
||||
CTOR(report_t, date_width_) { on_with(9L); }
|
||||
DO_(args) { value = args[0].to_long(); });
|
||||
bool specified;
|
||||
CTOR(report_t, date_width_) { on_with(9L); specified = false; }
|
||||
DO_(args) { value = args[0].to_long(); specified = true; });
|
||||
OPTION__(report_t, payee_width_,
|
||||
CTOR(report_t, payee_width_) { on_with(20L); }
|
||||
DO_(args) { value = args[0].to_long(); });
|
||||
bool specified;
|
||||
CTOR(report_t, payee_width_) { on_with(20L); specified = false; }
|
||||
DO_(args) { value = args[0].to_long(); specified = true; });
|
||||
OPTION__(report_t, account_width_,
|
||||
CTOR(report_t, account_width_) { on_with(23L); }
|
||||
DO_(args) { value = args[0].to_long(); });
|
||||
bool specified;
|
||||
CTOR(report_t, account_width_) { on_with(23L); specified = false; }
|
||||
DO_(args) { value = args[0].to_long(); specified = true; });
|
||||
OPTION__(report_t, amount_width_,
|
||||
CTOR(report_t, amount_width_) { on_with(12L); }
|
||||
DO_(args) { value = args[0].to_long(); });
|
||||
bool specified;
|
||||
CTOR(report_t, amount_width_) { on_with(12L); specified = false; }
|
||||
DO_(args) { value = args[0].to_long(); specified = true; });
|
||||
OPTION__(report_t, total_width_,
|
||||
CTOR(report_t, total_width_) { on_with(12L); }
|
||||
DO_(args) { value = args[0].to_long(); });
|
||||
bool specified;
|
||||
CTOR(report_t, total_width_) { on_with(12L); specified = false; }
|
||||
DO_(args) { value = args[0].to_long(); specified = true; });
|
||||
};
|
||||
|
||||
} // namespace ledger
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue