1use crate::{
2 Buffer, BufferRow, BufferRows, GitStatus, HighlightColor, HighlightedLine, HighlightedText,
3 Icon, Label, LabelColor, ListEntry, ListItem, Theme, ToggleState,
4};
5
6pub fn static_project_panel_project_items<S: 'static + Send + Sync + Clone>() -> Vec<ListItem<S>> {
7 vec![
8 ListEntry::new(Label::new("zed"))
9 .left_icon(Icon::FolderOpen.into())
10 .indent_level(0)
11 .set_toggle(ToggleState::Toggled),
12 ListEntry::new(Label::new(".cargo"))
13 .left_icon(Icon::Folder.into())
14 .indent_level(1),
15 ListEntry::new(Label::new(".config"))
16 .left_icon(Icon::Folder.into())
17 .indent_level(1),
18 ListEntry::new(Label::new(".git").color(LabelColor::Hidden))
19 .left_icon(Icon::Folder.into())
20 .indent_level(1),
21 ListEntry::new(Label::new(".cargo"))
22 .left_icon(Icon::Folder.into())
23 .indent_level(1),
24 ListEntry::new(Label::new(".idea").color(LabelColor::Hidden))
25 .left_icon(Icon::Folder.into())
26 .indent_level(1),
27 ListEntry::new(Label::new("assets"))
28 .left_icon(Icon::Folder.into())
29 .indent_level(1)
30 .set_toggle(ToggleState::Toggled),
31 ListEntry::new(Label::new("cargo-target").color(LabelColor::Hidden))
32 .left_icon(Icon::Folder.into())
33 .indent_level(1),
34 ListEntry::new(Label::new("crates"))
35 .left_icon(Icon::FolderOpen.into())
36 .indent_level(1)
37 .set_toggle(ToggleState::Toggled),
38 ListEntry::new(Label::new("activity_indicator"))
39 .left_icon(Icon::Folder.into())
40 .indent_level(2),
41 ListEntry::new(Label::new("ai"))
42 .left_icon(Icon::Folder.into())
43 .indent_level(2),
44 ListEntry::new(Label::new("audio"))
45 .left_icon(Icon::Folder.into())
46 .indent_level(2),
47 ListEntry::new(Label::new("auto_update"))
48 .left_icon(Icon::Folder.into())
49 .indent_level(2),
50 ListEntry::new(Label::new("breadcrumbs"))
51 .left_icon(Icon::Folder.into())
52 .indent_level(2),
53 ListEntry::new(Label::new("call"))
54 .left_icon(Icon::Folder.into())
55 .indent_level(2),
56 ListEntry::new(Label::new("sqlez").color(LabelColor::Modified))
57 .left_icon(Icon::Folder.into())
58 .indent_level(2)
59 .set_toggle(ToggleState::NotToggled),
60 ListEntry::new(Label::new("gpui2"))
61 .left_icon(Icon::FolderOpen.into())
62 .indent_level(2)
63 .set_toggle(ToggleState::Toggled),
64 ListEntry::new(Label::new("src"))
65 .left_icon(Icon::FolderOpen.into())
66 .indent_level(3)
67 .set_toggle(ToggleState::Toggled),
68 ListEntry::new(Label::new("derive_element.rs"))
69 .left_icon(Icon::FileRust.into())
70 .indent_level(4),
71 ListEntry::new(Label::new("storybook").color(LabelColor::Modified))
72 .left_icon(Icon::FolderOpen.into())
73 .indent_level(1)
74 .set_toggle(ToggleState::Toggled),
75 ListEntry::new(Label::new("docs").color(LabelColor::Default))
76 .left_icon(Icon::Folder.into())
77 .indent_level(2)
78 .set_toggle(ToggleState::Toggled),
79 ListEntry::new(Label::new("src").color(LabelColor::Modified))
80 .left_icon(Icon::FolderOpen.into())
81 .indent_level(3)
82 .set_toggle(ToggleState::Toggled),
83 ListEntry::new(Label::new("ui").color(LabelColor::Modified))
84 .left_icon(Icon::FolderOpen.into())
85 .indent_level(4)
86 .set_toggle(ToggleState::Toggled),
87 ListEntry::new(Label::new("component").color(LabelColor::Created))
88 .left_icon(Icon::FolderOpen.into())
89 .indent_level(5)
90 .set_toggle(ToggleState::Toggled),
91 ListEntry::new(Label::new("facepile.rs").color(LabelColor::Default))
92 .left_icon(Icon::FileRust.into())
93 .indent_level(6),
94 ListEntry::new(Label::new("follow_group.rs").color(LabelColor::Default))
95 .left_icon(Icon::FileRust.into())
96 .indent_level(6),
97 ListEntry::new(Label::new("list_item.rs").color(LabelColor::Created))
98 .left_icon(Icon::FileRust.into())
99 .indent_level(6),
100 ListEntry::new(Label::new("tab.rs").color(LabelColor::Default))
101 .left_icon(Icon::FileRust.into())
102 .indent_level(6),
103 ListEntry::new(Label::new("target").color(LabelColor::Hidden))
104 .left_icon(Icon::Folder.into())
105 .indent_level(1),
106 ListEntry::new(Label::new(".dockerignore"))
107 .left_icon(Icon::FileGeneric.into())
108 .indent_level(1),
109 ListEntry::new(Label::new(".DS_Store").color(LabelColor::Hidden))
110 .left_icon(Icon::FileGeneric.into())
111 .indent_level(1),
112 ListEntry::new(Label::new("Cargo.lock"))
113 .left_icon(Icon::FileLock.into())
114 .indent_level(1),
115 ListEntry::new(Label::new("Cargo.toml"))
116 .left_icon(Icon::FileToml.into())
117 .indent_level(1),
118 ListEntry::new(Label::new("Dockerfile"))
119 .left_icon(Icon::FileGeneric.into())
120 .indent_level(1),
121 ListEntry::new(Label::new("Procfile"))
122 .left_icon(Icon::FileGeneric.into())
123 .indent_level(1),
124 ListEntry::new(Label::new("README.md"))
125 .left_icon(Icon::FileDoc.into())
126 .indent_level(1),
127 ]
128 .into_iter()
129 .map(From::from)
130 .collect()
131}
132
133pub fn static_project_panel_single_items<S: 'static + Send + Sync + Clone>() -> Vec<ListItem<S>> {
134 vec![
135 ListEntry::new(Label::new("todo.md"))
136 .left_icon(Icon::FileDoc.into())
137 .indent_level(0),
138 ListEntry::new(Label::new("README.md"))
139 .left_icon(Icon::FileDoc.into())
140 .indent_level(0),
141 ListEntry::new(Label::new("config.json"))
142 .left_icon(Icon::FileGeneric.into())
143 .indent_level(0),
144 ]
145 .into_iter()
146 .map(From::from)
147 .collect()
148}
149
150pub fn empty_buffer_example<S: 'static + Send + Sync + Clone>() -> Buffer<S> {
151 Buffer::new().set_rows(Some(BufferRows::default()))
152}
153
154pub fn hello_world_rust_buffer_example<S: 'static + Send + Sync + Clone>(
155 theme: &Theme,
156) -> Buffer<S> {
157 Buffer::new()
158 .set_title("hello_world.rs".to_string())
159 .set_path("src/hello_world.rs".to_string())
160 .set_language("rust".to_string())
161 .set_rows(Some(BufferRows {
162 show_line_numbers: true,
163 rows: hello_world_rust_buffer_rows(theme),
164 }))
165}
166
167pub fn hello_world_rust_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
168 let show_line_number = true;
169
170 vec![
171 BufferRow {
172 line_number: 1,
173 code_action: false,
174 current: true,
175 line: Some(HighlightedLine {
176 highlighted_texts: vec![
177 HighlightedText {
178 text: "fn ".to_string(),
179 color: HighlightColor::Keyword.hsla(&theme),
180 },
181 HighlightedText {
182 text: "main".to_string(),
183 color: HighlightColor::Function.hsla(&theme),
184 },
185 HighlightedText {
186 text: "() {".to_string(),
187 color: HighlightColor::Default.hsla(&theme),
188 },
189 ],
190 }),
191 cursors: None,
192 status: GitStatus::None,
193 show_line_number,
194 },
195 BufferRow {
196 line_number: 2,
197 code_action: false,
198 current: false,
199 line: Some(HighlightedLine {
200 highlighted_texts: vec![HighlightedText {
201 text: " // Statements here are executed when the compiled binary is called."
202 .to_string(),
203 color: HighlightColor::Comment.hsla(&theme),
204 }],
205 }),
206 cursors: None,
207 status: GitStatus::None,
208 show_line_number,
209 },
210 BufferRow {
211 line_number: 3,
212 code_action: false,
213 current: false,
214 line: None,
215 cursors: None,
216 status: GitStatus::None,
217 show_line_number,
218 },
219 BufferRow {
220 line_number: 4,
221 code_action: false,
222 current: false,
223 line: Some(HighlightedLine {
224 highlighted_texts: vec![HighlightedText {
225 text: " // Print text to the console.".to_string(),
226 color: HighlightColor::Comment.hsla(&theme),
227 }],
228 }),
229 cursors: None,
230 status: GitStatus::None,
231 show_line_number,
232 },
233 BufferRow {
234 line_number: 5,
235 code_action: false,
236 current: false,
237 line: Some(HighlightedLine {
238 highlighted_texts: vec![
239 HighlightedText {
240 text: " println!(".to_string(),
241 color: HighlightColor::Default.hsla(&theme),
242 },
243 HighlightedText {
244 text: "\"Hello, world!\"".to_string(),
245 color: HighlightColor::String.hsla(&theme),
246 },
247 HighlightedText {
248 text: ");".to_string(),
249 color: HighlightColor::Default.hsla(&theme),
250 },
251 ],
252 }),
253 cursors: None,
254 status: GitStatus::None,
255 show_line_number,
256 },
257 BufferRow {
258 line_number: 6,
259 code_action: false,
260 current: false,
261 line: Some(HighlightedLine {
262 highlighted_texts: vec![HighlightedText {
263 text: "}".to_string(),
264 color: HighlightColor::Default.hsla(&theme),
265 }],
266 }),
267 cursors: None,
268 status: GitStatus::None,
269 show_line_number,
270 },
271 ]
272}
273
274pub fn hello_world_rust_buffer_with_status_example<S: 'static + Send + Sync + Clone>(
275 theme: &Theme,
276) -> Buffer<S> {
277 Buffer::new()
278 .set_title("hello_world.rs".to_string())
279 .set_path("src/hello_world.rs".to_string())
280 .set_language("rust".to_string())
281 .set_rows(Some(BufferRows {
282 show_line_numbers: true,
283 rows: hello_world_rust_with_status_buffer_rows(theme),
284 }))
285}
286
287pub fn hello_world_rust_with_status_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
288 let show_line_number = true;
289
290 vec![
291 BufferRow {
292 line_number: 1,
293 code_action: false,
294 current: true,
295 line: Some(HighlightedLine {
296 highlighted_texts: vec![
297 HighlightedText {
298 text: "fn ".to_string(),
299 color: HighlightColor::Keyword.hsla(&theme),
300 },
301 HighlightedText {
302 text: "main".to_string(),
303 color: HighlightColor::Function.hsla(&theme),
304 },
305 HighlightedText {
306 text: "() {".to_string(),
307 color: HighlightColor::Default.hsla(&theme),
308 },
309 ],
310 }),
311 cursors: None,
312 status: GitStatus::None,
313 show_line_number,
314 },
315 BufferRow {
316 line_number: 2,
317 code_action: false,
318 current: false,
319 line: Some(HighlightedLine {
320 highlighted_texts: vec![HighlightedText {
321 text: "// Statements here are executed when the compiled binary is called."
322 .to_string(),
323 color: HighlightColor::Comment.hsla(&theme),
324 }],
325 }),
326 cursors: None,
327 status: GitStatus::Modified,
328 show_line_number,
329 },
330 BufferRow {
331 line_number: 3,
332 code_action: false,
333 current: false,
334 line: None,
335 cursors: None,
336 status: GitStatus::None,
337 show_line_number,
338 },
339 BufferRow {
340 line_number: 4,
341 code_action: false,
342 current: false,
343 line: Some(HighlightedLine {
344 highlighted_texts: vec![HighlightedText {
345 text: " // Print text to the console.".to_string(),
346 color: HighlightColor::Comment.hsla(&theme),
347 }],
348 }),
349 cursors: None,
350 status: GitStatus::None,
351 show_line_number,
352 },
353 BufferRow {
354 line_number: 5,
355 code_action: false,
356 current: false,
357 line: Some(HighlightedLine {
358 highlighted_texts: vec![
359 HighlightedText {
360 text: " println!(".to_string(),
361 color: HighlightColor::Default.hsla(&theme),
362 },
363 HighlightedText {
364 text: "\"Hello, world!\"".to_string(),
365 color: HighlightColor::String.hsla(&theme),
366 },
367 HighlightedText {
368 text: ");".to_string(),
369 color: HighlightColor::Default.hsla(&theme),
370 },
371 ],
372 }),
373 cursors: None,
374 status: GitStatus::None,
375 show_line_number,
376 },
377 BufferRow {
378 line_number: 6,
379 code_action: false,
380 current: false,
381 line: Some(HighlightedLine {
382 highlighted_texts: vec![HighlightedText {
383 text: "}".to_string(),
384 color: HighlightColor::Default.hsla(&theme),
385 }],
386 }),
387 cursors: None,
388 status: GitStatus::None,
389 show_line_number,
390 },
391 BufferRow {
392 line_number: 7,
393 code_action: false,
394 current: false,
395 line: Some(HighlightedLine {
396 highlighted_texts: vec![HighlightedText {
397 text: "".to_string(),
398 color: HighlightColor::Default.hsla(&theme),
399 }],
400 }),
401 cursors: None,
402 status: GitStatus::Created,
403 show_line_number,
404 },
405 BufferRow {
406 line_number: 8,
407 code_action: false,
408 current: false,
409 line: Some(HighlightedLine {
410 highlighted_texts: vec![HighlightedText {
411 text: "// Marshall and Nate were here".to_string(),
412 color: HighlightColor::Comment.hsla(&theme),
413 }],
414 }),
415 cursors: None,
416 status: GitStatus::Created,
417 show_line_number,
418 },
419 ]
420}
421
422pub fn terminal_buffer<S: 'static + Send + Sync + Clone>(theme: &Theme) -> Buffer<S> {
423 Buffer::new()
424 .set_title("zed — fish".to_string())
425 .set_rows(Some(BufferRows {
426 show_line_numbers: false,
427 rows: terminal_buffer_rows(theme),
428 }))
429}
430
431pub fn terminal_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
432 let show_line_number = false;
433
434 vec![
435 BufferRow {
436 line_number: 1,
437 code_action: false,
438 current: false,
439 line: Some(HighlightedLine {
440 highlighted_texts: vec![
441 HighlightedText {
442 text: "maxdeviant ".to_string(),
443 color: HighlightColor::Keyword.hsla(&theme),
444 },
445 HighlightedText {
446 text: "in ".to_string(),
447 color: HighlightColor::Default.hsla(&theme),
448 },
449 HighlightedText {
450 text: "profaned-capital ".to_string(),
451 color: HighlightColor::Function.hsla(&theme),
452 },
453 HighlightedText {
454 text: "in ".to_string(),
455 color: HighlightColor::Default.hsla(&theme),
456 },
457 HighlightedText {
458 text: "~/p/zed ".to_string(),
459 color: HighlightColor::Function.hsla(&theme),
460 },
461 HighlightedText {
462 text: "on ".to_string(),
463 color: HighlightColor::Default.hsla(&theme),
464 },
465 HighlightedText {
466 text: " gpui2-ui ".to_string(),
467 color: HighlightColor::Keyword.hsla(&theme),
468 },
469 ],
470 }),
471 cursors: None,
472 status: GitStatus::None,
473 show_line_number,
474 },
475 BufferRow {
476 line_number: 2,
477 code_action: false,
478 current: false,
479 line: Some(HighlightedLine {
480 highlighted_texts: vec![HighlightedText {
481 text: "λ ".to_string(),
482 color: HighlightColor::String.hsla(&theme),
483 }],
484 }),
485 cursors: None,
486 status: GitStatus::None,
487 show_line_number,
488 },
489 ]
490}