promkit_widgets/
jsonstream.rs1use promkit_core::{Pane, PaneFactory};
2
3#[path = "jsonstream/jsonstream.rs"]
4mod inner;
5pub use inner::JsonStream;
6pub mod config;
7pub use config::Config;
8pub mod jsonz;
9
10#[derive(Clone)]
17pub struct State {
18 pub stream: JsonStream,
20
21 pub config: Config,
23}
24
25impl PaneFactory for State {
26 fn create_pane(&self, width: u16, height: u16) -> Pane {
27 let height = match self.config.lines {
28 Some(lines) => lines.min(height as usize),
29 None => height as usize,
30 };
31
32 let rows = self.stream.extract_rows_from_current(height);
33 let formatted_rows = self.config.format_for_terminal_display(&rows, width);
34
35 Pane::new(formatted_rows, 0)
36 }
37}