1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
//! Split widget demos
use crate::example::Example;
use crate::theme_colors;
use revue::prelude::*;
pub fn examples() -> Vec<Example> {
let (primary, _success, _warning, _error, _info, muted, text, _) = theme_colors();
vec![
Example::new(
"HSplit",
"Horizontal split with side-by-side panes",
Border::rounded().title(" HSplit ").child(
vstack()
.gap(1)
.child(Text::new("Horizontal split:").fg(primary))
.child(
hstack()
.gap(1)
.child(
Border::rounded()
.title("Left")
.child(Text::new("Pane 1").fg(text)),
)
.child(
Border::rounded()
.title("Right")
.child(Text::new("Pane 2").fg(text)),
),
)
.child(Text::new(""))
.child(Text::new("• Side by side").fg(muted))
.child(Text::new("• Resizable divider").fg(muted))
.child(Text::new("• Drag to resize").fg(muted)),
),
),
Example::new(
"VSplit",
"Vertical split with top and bottom panes",
Border::rounded().title(" VSplit ").child(
vstack()
.gap(1)
.child(Text::new("Vertical split:").fg(primary))
.child(
vstack()
.gap(1)
.child(
Border::rounded()
.title("Top")
.child(Text::new("Pane 1").fg(text)),
)
.child(
Border::rounded()
.title("Bottom")
.child(Text::new("Pane 2").fg(text)),
),
)
.child(Text::new(""))
.child(Text::new("• Top and bottom").fg(muted))
.child(Text::new("• Vertical divider").fg(muted))
.child(Text::new("• Ratio control").fg(muted)),
),
),
Example::new(
"Splitter",
"Resizable split with custom ratio",
Border::rounded().title(" Splitter ").child(
vstack()
.gap(1)
.child(Text::new("Resizable split:").fg(primary))
.child(
hstack()
.gap(1)
.child(
Border::rounded()
.title("30%")
.child(Text::new("Sidebar").fg(text)),
)
.child(
Border::rounded()
.title("70%")
.child(Text::new("Content").fg(text)),
),
)
.child(Text::new(""))
.child(Text::new("• Custom ratio").fg(muted))
.child(Text::new("• Interactive resize").fg(muted))
.child(Text::new("• Save/restore state").fg(muted)),
),
),
Example::new(
"Three Panel",
"Three-way split for IDE-style layouts",
Border::rounded().title(" Three Panel ").child(
vstack()
.gap(1)
.child(Text::new("Three-way split:").fg(primary))
.child(
hstack()
.gap(1)
.child(
Border::rounded()
.title("Files")
.child(Text::new("Tree").fg(text)),
)
.child(
Border::rounded()
.title("Editor")
.child(Text::new("Code").fg(text)),
)
.child(
Border::rounded()
.title("Terminal")
.child(Text::new("Shell").fg(text)),
),
)
.child(Text::new(""))
.child(Text::new("• Multiple panes").fg(muted))
.child(Text::new("• IDE layout").fg(muted))
.child(Text::new("• Flexible sizing").fg(muted)),
),
),
Example::new(
"Nested Split",
"Nested splits for complex layout composition",
Border::rounded().title(" Nested Split ").child(
vstack()
.gap(1)
.child(Text::new("Nested splits:").fg(primary))
.child(
hstack()
.gap(1)
.child(
Border::rounded()
.title("Nav")
.child(Text::new("Menu").fg(text)),
)
.child(
vstack()
.gap(1)
.child(
Border::rounded()
.title("Header")
.child(Text::new("Top").fg(text)),
)
.child(
Border::rounded()
.title("Content")
.child(Text::new("Main").fg(text)),
),
),
)
.child(Text::new(""))
.child(Text::new("• Complex layouts").fg(muted))
.child(Text::new("• Nested splits").fg(muted))
.child(Text::new("• Full flexibility").fg(muted)),
),
),
Example::new(
"App Layout",
"Standard application layout with header, sidebar, and content",
Border::rounded().title(" App Layout ").child(
vstack()
.gap(1)
.child(Text::new("Standard app layout:").fg(primary))
.child(
vstack()
.gap(1)
.child(
hstack()
.gap(2)
.child(Text::new("Header | Nav | Actions").fg(muted)),
)
.child(
hstack()
.gap(1)
.child(Text::new("Sidebar").fg(text))
.child(Text::new("Main Content Area").fg(text)),
),
)
.child(Text::new(""))
.child(Text::new("• Header").fg(muted))
.child(Text::new("• Sidebar + Main").fg(muted))
.child(Text::new("• Footer option").fg(muted)),
),
),
Example::new(
"Constrained Split",
"Split panes with min/max width constraints",
Border::rounded().title(" Constrained Split ").child(
vstack()
.gap(1)
.child(Text::new("Size limits on splits:").fg(primary))
.child(
hstack()
.gap(1)
.min_width(30)
.max_width(50)
.child(
Border::rounded()
.title("30-50w")
.child(Text::new("Min/Max").fg(text)),
)
.child(Border::rounded().child(Text::new("Width limited").fg(text))),
)
.child(Text::new(""))
.child(Text::new("• min_width() on container").fg(muted))
.child(Text::new("• max_width() on container").fg(muted))
.child(Text::new("• Responsive layouts").fg(muted)),
),
),
Example::new(
"Min Size Split",
"Split with minimum dimension guarantees",
Border::rounded().title(" Min Size Split ").child(
vstack()
.gap(1)
.child(Text::new("Minimum dimensions:").fg(primary))
.child(
vstack()
.gap(1)
.min_size(20, 3)
.child(Border::rounded().child(Text::new("At least 20x3").fg(text)))
.child(Border::rounded().child(Text::new("Guaranteed space").fg(text))),
)
.child(Text::new(""))
.child(Text::new("• .min_size(w, h)").fg(muted))
.child(Text::new("• Ensures minimum area").fg(muted))
.child(Text::new("• Good for small terms").fg(muted)),
),
),
Example::new(
"Max Size Split",
"Split with maximum dimension caps",
Border::rounded().title(" Max Size Split ").child(
vstack()
.gap(1)
.child(Text::new("Maximum dimensions:").fg(primary))
.child(
hstack()
.gap(1)
.max_size(40, 4)
.child(Border::rounded().child(Text::new("Max 40x4").fg(text)))
.child(
Border::rounded().child(Text::new("Prevents overflow").fg(text)),
),
)
.child(Text::new(""))
.child(Text::new("• .max_size(w, h)").fg(muted))
.child(Text::new("• Caps maximum size").fg(muted))
.child(Text::new("• Good for large terms").fg(muted)),
),
),
]
}