nui/events/redraw/
multigrid.rs1use rmpv::Value;
2
3use super::ParseError;
4
5#[derive(Debug)]
6pub struct HighlightAttributeDefine {
7 pub id: i64,
8 pub rgb: Option<Vec<(String, String)>>,
9 pub cterm: Option<Vec<(String, String)>>,
10 pub info: Option<i64>,
11}
12
13impl TryFrom<&Vec<Value>> for HighlightAttributeDefine {
14 type Error = ParseError;
15
16 fn try_from(values: &Vec<Value>) -> Result<Self, Self::Error> {
17 dbg!(&values);
18
19 Ok(Self {
20 id: 1,
21 rgb: None,
22 cterm: None,
23 info: None,
24 })
25 }
26}
27
28#[derive(Debug)]
29pub struct HighlightGroupSet {
30 pub name: String,
31 pub hl_id: i64,
32}
33
34impl TryFrom<&Vec<Value>> for HighlightGroupSet {
35 type Error = ParseError;
36
37 fn try_from(values: &Vec<Value>) -> Result<Self, Self::Error> {
38 dbg!(&values);
39
40 Ok(Self {
41 name: String::from("test"),
42 hl_id: 1,
43 })
44 }
45}
46
47#[derive(Debug)]
48pub struct GridLineCell {
49 pub text: String,
50 pub hl_id: Option<i64>,
51 pub repeat: Option<i64>,
52}
53
54impl TryFrom<&Value> for GridLineCell {
55 type Error = ParseError;
56
57 fn try_from(value: &Value) -> Result<Self, Self::Error> {
58 let cell = value.as_array().unwrap();
59 let text = cell.get(0).unwrap().as_str().unwrap().to_owned();
60 let hl_id = match cell.get(1) {
61 Some(value) => Some(value.as_i64().unwrap()),
62 None => None,
63 };
64 let repeat = match cell.get(2) {
65 Some(value) => Some(value.as_i64().unwrap()),
66 None => None,
67 };
68
69 Ok(Self {
70 text,
71 hl_id,
72 repeat,
73 })
74 }
75}
76
77#[derive(Debug)]
78pub struct GridLine {
79 pub grid: i64,
80 pub row: i64,
81 pub column_start: i64,
82 pub cells: Vec<GridLineCell>,
83}
84
85impl TryFrom<&Vec<Value>> for GridLine {
86 type Error = ParseError;
87
88 fn try_from(value: &Vec<Value>) -> Result<Self, Self::Error> {
89 let grid = value.get(0).unwrap().as_i64().unwrap();
90 let row = value.get(1).unwrap().as_i64().unwrap();
91 let column_start = value.get(2).unwrap().as_i64().unwrap();
92 let cells = value.get(3).unwrap().as_array().unwrap().into_iter();
93
94 let mut parsed_cells = Vec::<GridLineCell>::with_capacity(cells.len());
95 for cell in cells {
96 if let Ok(cell) = GridLineCell::try_from(cell) {
97 parsed_cells.push(cell);
98 }
99 }
100
101 Ok(GridLine {
102 grid,
103 row,
104 column_start,
105 cells: parsed_cells,
106 })
107 }
108}
109
110#[derive(Debug)]
111pub struct GridClear {
112 pub grid: i64,
113}
114
115impl TryFrom<&Vec<Value>> for GridClear {
116 type Error = ParseError;
117
118 fn try_from(values: &Vec<Value>) -> Result<Self, Self::Error> {
119 todo!();
120 }
121}
122
123#[derive(Debug)]
124pub struct GridDestroy {
125 pub grid: i64,
126}
127
128impl TryFrom<&Vec<Value>> for GridDestroy {
129 type Error = ParseError;
130
131 fn try_from(values: &Vec<Value>) -> Result<Self, Self::Error> {
132 todo!();
133 }
134}
135
136#[derive(Debug)]
137pub struct GridResize {
138 pub grid: i64,
139 pub width: i64,
140 pub height: i64,
141}
142
143impl TryFrom<&Vec<Value>> for GridResize {
144 type Error = ParseError;
145
146 fn try_from(value: &Vec<Value>) -> Result<Self, Self::Error> {
147 todo!()
148 }
149}
150
151#[derive(Debug)]
152pub struct GridCursorGoto {
153 pub grid: i64,
154 pub row: i64,
155 pub column: i64,
156}
157
158impl TryFrom<&Vec<Value>> for GridCursorGoto {
159 type Error = ParseError;
160
161 fn try_from(value: &Vec<Value>) -> Result<Self, Self::Error> {
162 todo!()
163 }
164}
165
166#[derive(Debug)]
167pub struct GridScroll {
168 pub grid: i64,
169 pub top: i64,
170 pub bottom: i64,
171 pub left: i64,
172 pub right: i64,
173 pub rows: i64,
174 pub columns: i64,
175}
176
177impl TryFrom<&Vec<Value>> for GridScroll {
178 type Error = ParseError;
179
180 fn try_from(value: &Vec<Value>) -> Result<Self, Self::Error> {
181 todo!()
182 }
183}