SJ6AFVZL5HEXG5ZUV5STIGGIGLU56WGAQCSZBFFHQOVHAILBOS2QC
// TODO consider reimplementation based on pretty.rs
#[derive(Clone, Copy, Debug)]
pub struct AmountConfig {
pub decimal_separator_column: usize,
pub commodity_column: usize,
}
impl Default for AmountConfig {
fn default() -> Self {
Self {
decimal_separator_column: 110,
commodity_column: 116,
}
}
}
pub struct PrettyPrinter<
W,
const FLAG_COLUMN: usize,
const ACCOUNT_COLUMN: usize,
const AMOUNT_COLUMN: usize,
> {
#[derive(Clone, Copy, Debug)]
pub struct Config {
pub account_column: usize,
pub amount: AmountConfig,
pub flag_column: usize,
}
impl Default for Config {
fn default() -> Self {
Self {
account_column: 2,
amount: Default::default(),
flag_column: 2,
}
}
}
pub struct PrettyPrinter<W> {
config: Config,
self.inner.write_all(&buffer[..total_width])?;
Ok(())
// We can ignore the part right of the decimal separator when aligning the amount on the decimal separator
let integral_digits = buffer.graphemes().count() - (decimals + 1);
self.inner
.ensure_column(decimal_separator_column - integral_digits)?;
self.inner.write_all(buffer)