for_each_string_list_item(item, &table->rows) {
struct stats_table_entry *entry = item->util;
const char *value = "";
+ const char *unit = "";
if (entry) {
- struct stats_table_entry *entry = item->util;
value = entry->value;
+ if (entry->unit)
+ unit = entry->unit;
}
- printf("| %-*s | %*s |\n", name_col_width, item->string,
- value_col_width, value);
+ strbuf_reset(&buf);
+ strbuf_addstr(&buf, "| ");
+ strbuf_utf8_align(&buf, ALIGN_LEFT, name_col_width, item->string);
+ strbuf_addstr(&buf, " | ");
+ strbuf_utf8_align(&buf, ALIGN_RIGHT, value_col_width, value);
+ strbuf_addch(&buf, ' ');
+ strbuf_utf8_align(&buf, ALIGN_LEFT, unit_col_width, unit);
+ strbuf_addstr(&buf, " |");
+ printf("%s\n", buf.buf);
}
+
+ strbuf_release(&buf);
}
static void stats_table_clear(struct stats_table *table)