1use serde_json::Value;
2
3use crate::ui::style::StyleToken;
4
5#[derive(Debug, Clone, Default)]
6pub struct Document {
7 pub blocks: Vec<Block>,
8}
9
10#[derive(Debug, Clone)]
11pub enum Block {
12 Line(LineBlock),
13 Panel(PanelBlock),
14 Code(CodeBlock),
15 Json(JsonBlock),
16 Table(TableBlock),
17 Value(ValueBlock),
18 Mreg(MregBlock),
19}
20
21#[derive(Debug, Clone)]
22pub struct LineBlock {
23 pub parts: Vec<LinePart>,
24}
25
26#[derive(Debug, Clone)]
27pub struct LinePart {
28 pub text: String,
29 pub token: Option<StyleToken>,
30}
31
32#[derive(Debug, Clone)]
33pub struct PanelBlock {
34 pub title: Option<String>,
35 pub body: Document,
36 pub rules: PanelRules,
37 pub kind: Option<String>,
38 pub border_token: Option<StyleToken>,
39 pub title_token: Option<StyleToken>,
40}
41
42#[derive(Debug, Clone, Copy, PartialEq, Eq)]
43pub enum PanelRules {
44 None,
45 Top,
46 Bottom,
47 Both,
48}
49
50#[derive(Debug, Clone)]
51pub struct CodeBlock {
52 pub code: String,
53 pub language: Option<String>,
54}
55
56#[derive(Debug, Clone)]
57pub struct JsonBlock {
58 pub payload: Value,
59}
60
61#[derive(Debug, Clone)]
62pub struct TableBlock {
63 pub block_id: u64,
64 pub style: TableStyle,
65 pub headers: Vec<String>,
66 pub rows: Vec<Vec<Value>>,
67 pub header_pairs: Vec<(String, Value)>,
68 pub align: Option<Vec<TableAlign>>,
69 pub shrink_to_fit: bool,
70 pub depth: usize,
71}
72
73#[derive(Debug, Clone, Copy, PartialEq, Eq)]
74pub enum TableStyle {
75 Grid,
76 Markdown,
77}
78
79#[derive(Debug, Clone, Copy, PartialEq, Eq)]
80pub enum TableAlign {
81 Default,
82 Left,
83 Center,
84 Right,
85}
86
87#[derive(Debug, Clone)]
88pub struct ValueBlock {
89 pub values: Vec<String>,
90}
91
92#[derive(Debug, Clone)]
93pub struct MregBlock {
94 pub block_id: u64,
95 pub rows: Vec<MregRow>,
96}
97
98#[derive(Debug, Clone)]
99pub struct MregRow {
100 pub entries: Vec<MregEntry>,
101}
102
103#[derive(Debug, Clone)]
104pub struct MregEntry {
105 pub key: String,
106 pub depth: usize,
107 pub value: MregValue,
108}
109
110#[derive(Debug, Clone)]
111pub enum MregValue {
112 Group,
113 Separator,
114 Scalar(Value),
115 VerticalList(Vec<Value>),
116 Grid(Vec<Value>),
117}