* Moves off of draining between filters. Instead, the sink will pull on the stream, and will drain element-wise. This moves the whole stream to being lazy. * Adds ctrl-c support and connects it into some of the key points where we pull on the stream. If a ctrl-c is detect, we immediately halt pulling on the stream and return to the prompt. * Moves away from having a SourceMap where anchor locations are stored. Now AnchorLocation is kept directly in the Tag. * To make this possible, split tag and span. Span is largely used in the parser and is copyable. Tag is now no longer copyable.
43 lines
1.2 KiB
Rust
43 lines
1.2 KiB
Rust
use crate::data::Value;
|
|
use crate::format::{EntriesView, RenderView, TableView};
|
|
use crate::prelude::*;
|
|
use derive_new::new;
|
|
|
|
// A list is printed one line at a time with an optional separator between groups
|
|
#[derive(new)]
|
|
pub struct GenericView<'value> {
|
|
value: &'value Value,
|
|
}
|
|
|
|
impl RenderView for GenericView<'_> {
|
|
fn render_view(&self, host: &mut dyn Host) -> Result<(), ShellError> {
|
|
match self.value {
|
|
Value::Primitive(p) => Ok(host.stdout(&p.format(None))),
|
|
Value::Table(l) => {
|
|
let view = TableView::from_list(l, 0);
|
|
|
|
if let Some(view) = view {
|
|
view.render_view(host)?;
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
o @ Value::Row(_) => {
|
|
let view = EntriesView::from_value(o);
|
|
view.render_view(host)?;
|
|
Ok(())
|
|
}
|
|
|
|
b @ Value::Block(_) => {
|
|
let printed = b.format_leaf(None);
|
|
let view = EntriesView::from_value(&Value::string(printed));
|
|
view.render_view(host)?;
|
|
Ok(())
|
|
}
|
|
|
|
Value::Error(e) => Err(e.clone()),
|
|
}
|
|
}
|
|
}
|