|
@@ -28,7 +28,9 @@ pub fn show_table(cols: Vec<Column>, rows: impl Iterator<Item = Row>) {
|
|
|
for row in &table_data {
|
|
|
let Row::Data(row) = &row else { continue };
|
|
|
for (idx, rc) in row.iter().enumerate() {
|
|
|
- min_widths[idx] = min_widths[idx].max(console::measure_text_width(rc.as_str()));
|
|
|
+ use unicode_segmentation::UnicodeSegmentation;
|
|
|
+ let width = rc.graphemes(true).count();
|
|
|
+ min_widths[idx] = min_widths[idx].max(width);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -68,21 +70,22 @@ pub fn show_table(cols: Vec<Column>, rows: impl Iterator<Item = Row>) {
|
|
|
}
|
|
|
|
|
|
pub fn show_transaction(_root: Option<&Hoard>, txn: &Transaction) {
|
|
|
- let bluestyle = console::Style::new().blue();
|
|
|
- // let greenstyle = console::Style::new().green();
|
|
|
- let yellowstyle = console::Style::new().yellow();
|
|
|
- let graystyle = console::Style::new().white().dim();
|
|
|
+ let blue = termion::color::Fg(termion::color::Blue);
|
|
|
+ let yellow = termion::color::Fg(termion::color::Yellow);
|
|
|
+ let gray = termion::color::Fg(termion::color::LightBlack);
|
|
|
+ let reset = termion::color::Fg(termion::color::Reset);
|
|
|
+
|
|
|
println!(
|
|
|
- "{}: {}",
|
|
|
- bluestyle.apply_to(txn.datestamp),
|
|
|
- txn.title.as_deref().unwrap_or("")
|
|
|
+ "{blue}{}{reset}: {gray}{}{reset}",
|
|
|
+ txn.datestamp,
|
|
|
+ txn.title.as_deref().unwrap_or(""),
|
|
|
);
|
|
|
for change in &txn.changes {
|
|
|
println!(
|
|
|
- " - {}: {} {}",
|
|
|
- yellowstyle.apply_to(change.account),
|
|
|
+ " - {yellow}{}{reset}: {} {gray}{}{reset}",
|
|
|
+ change.account,
|
|
|
change.amount,
|
|
|
- graystyle.apply_to(change.unit)
|
|
|
+ change.unit
|
|
|
);
|
|
|
}
|
|
|
}
|