2019-05-10 16:59:12 +00:00
|
|
|
crate mod entries;
|
|
|
|
crate mod generic;
|
|
|
|
crate mod list;
|
|
|
|
crate mod table;
|
|
|
|
|
2019-05-13 21:00:25 +00:00
|
|
|
use crate::prelude::*;
|
2019-05-10 16:59:12 +00:00
|
|
|
|
2019-05-15 22:58:44 +00:00
|
|
|
use crate::Context;
|
|
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
|
2019-05-15 16:12:38 +00:00
|
|
|
crate use entries::{EntriesListView, EntriesView};
|
2019-05-10 16:59:12 +00:00
|
|
|
crate use generic::GenericView;
|
|
|
|
crate use table::TableView;
|
|
|
|
|
|
|
|
crate trait RenderView {
|
|
|
|
fn render_view(&self, host: &dyn Host) -> Vec<String>;
|
|
|
|
}
|
2019-05-13 21:00:25 +00:00
|
|
|
|
2019-05-15 22:58:44 +00:00
|
|
|
fn print_rendered(lines: &[String], host: &mut dyn Host) {
|
2019-05-13 21:00:25 +00:00
|
|
|
for line in lines {
|
|
|
|
host.stdout(line);
|
|
|
|
}
|
|
|
|
}
|
2019-05-15 22:58:44 +00:00
|
|
|
|
|
|
|
crate fn print_view(view: &impl RenderView, context: Arc<Mutex<Context>>) {
|
|
|
|
let mut ctx = context.lock().unwrap();
|
|
|
|
crate::format::print_rendered(&view.render_view(&ctx.host), &mut ctx.host);
|
|
|
|
}
|