use std::io::{stdout, Write};
use pad::{Alignment, PadStr};
use crate::{terminal_width, Entry, Message};
pub fn prompt() {
print!(
"{}\r> ",
"".pad_to_width_with_alignment(terminal_width(), Alignment::Left)
);
let _ = stdout().flush();
}
pub fn entry(index: usize, entry: &Entry) {
if let Some(ref msg) = entry.message {
for msg in msg.unroll() {
message(index, entry.color, msg);
}
}
}
pub fn message(index: usize, color: bool, message: &Message) {
if let Some(report) = message.report(color, terminal_width() - 4) {
println!(
"{} {}",
index
.to_string()
.pad_to_width_with_alignment(3, Alignment::Right),
report
)
}
}
pub fn headers(color: bool) {
println!(
"{}",
format!(" {}", Message::report_headers(color))
.pad_to_width_with_alignment(terminal_width(), Alignment::Left)
);
}