1use std::path::PathBuf;
2use std::str::FromStr;
3
4use crate::{
5 Buffer, BufferRow, BufferRows, Editor, FileSystemStatus, GitStatus, HighlightColor,
6 HighlightedLine, HighlightedText, Icon, Label, LabelColor, ListEntry, ListItem, Player, Symbol,
7 Tab, Theme, ToggleState,
8};
9
10pub fn static_tabs_example<S: 'static + Send + Sync + Clone>() -> Vec<Tab<S>> {
11 vec![
12 Tab::new()
13 .title("wip.rs".to_string())
14 .icon(Icon::FileRust)
15 .current(false)
16 .fs_status(FileSystemStatus::Deleted),
17 Tab::new()
18 .title("Cargo.toml".to_string())
19 .icon(Icon::FileToml)
20 .current(false)
21 .git_status(GitStatus::Modified),
22 Tab::new()
23 .title("Channels Panel".to_string())
24 .icon(Icon::Hash)
25 .current(false),
26 Tab::new()
27 .title("channels_panel.rs".to_string())
28 .icon(Icon::FileRust)
29 .current(true)
30 .git_status(GitStatus::Modified),
31 Tab::new()
32 .title("workspace.rs".to_string())
33 .current(false)
34 .icon(Icon::FileRust)
35 .git_status(GitStatus::Modified),
36 Tab::new()
37 .title("icon_button.rs".to_string())
38 .icon(Icon::FileRust)
39 .current(false),
40 Tab::new()
41 .title("storybook.rs".to_string())
42 .icon(Icon::FileRust)
43 .current(false)
44 .git_status(GitStatus::Created),
45 Tab::new()
46 .title("theme.rs".to_string())
47 .icon(Icon::FileRust)
48 .current(false),
49 Tab::new()
50 .title("theme_registry.rs".to_string())
51 .icon(Icon::FileRust)
52 .current(false),
53 Tab::new()
54 .title("styleable_helpers.rs".to_string())
55 .icon(Icon::FileRust)
56 .current(false),
57 ]
58}
59
60pub fn static_tabs_1<S: 'static + Send + Sync + Clone>() -> Vec<Tab<S>> {
61 vec![
62 Tab::new()
63 .title("project_panel.rs".to_string())
64 .icon(Icon::FileRust)
65 .current(false)
66 .fs_status(FileSystemStatus::Deleted),
67 Tab::new()
68 .title("tab_bar.rs".to_string())
69 .icon(Icon::FileRust)
70 .current(false)
71 .git_status(GitStatus::Modified),
72 Tab::new()
73 .title("workspace.rs".to_string())
74 .icon(Icon::FileRust)
75 .current(false),
76 Tab::new()
77 .title("tab.rs".to_string())
78 .icon(Icon::FileRust)
79 .current(true)
80 .git_status(GitStatus::Modified),
81 ]
82}
83
84pub fn static_tabs_2<S: 'static + Send + Sync + Clone>() -> Vec<Tab<S>> {
85 vec![
86 Tab::new()
87 .title("tab_bar.rs".to_string())
88 .icon(Icon::FileRust)
89 .current(false)
90 .fs_status(FileSystemStatus::Deleted),
91 Tab::new()
92 .title("static_data.rs".to_string())
93 .icon(Icon::FileRust)
94 .current(true)
95 .git_status(GitStatus::Modified),
96 ]
97}
98
99pub fn static_tabs_3<S: 'static + Send + Sync + Clone>() -> Vec<Tab<S>> {
100 vec![Tab::new().git_status(GitStatus::Created).current(true)]
101}
102
103pub fn static_players() -> Vec<Player> {
104 vec![
105 Player::new(
106 0,
107 "https://avatars.githubusercontent.com/u/1714999?v=4".into(),
108 "nathansobo".into(),
109 ),
110 Player::new(
111 1,
112 "https://avatars.githubusercontent.com/u/326587?v=4".into(),
113 "maxbrunsfeld".into(),
114 ),
115 Player::new(
116 2,
117 "https://avatars.githubusercontent.com/u/482957?v=4".into(),
118 "as-cii".into(),
119 ),
120 Player::new(
121 3,
122 "https://avatars.githubusercontent.com/u/1714999?v=4".into(),
123 "iamnbutler".into(),
124 ),
125 Player::new(
126 4,
127 "https://avatars.githubusercontent.com/u/1486634?v=4".into(),
128 "maxdeviant".into(),
129 ),
130 ]
131}
132
133pub fn static_project_panel_project_items<S: 'static + Send + Sync + Clone>() -> Vec<ListItem<S>> {
134 vec![
135 ListEntry::new(Label::new("zed"))
136 .left_icon(Icon::FolderOpen.into())
137 .indent_level(0)
138 .set_toggle(ToggleState::Toggled),
139 ListEntry::new(Label::new(".cargo"))
140 .left_icon(Icon::Folder.into())
141 .indent_level(1),
142 ListEntry::new(Label::new(".config"))
143 .left_icon(Icon::Folder.into())
144 .indent_level(1),
145 ListEntry::new(Label::new(".git").color(LabelColor::Hidden))
146 .left_icon(Icon::Folder.into())
147 .indent_level(1),
148 ListEntry::new(Label::new(".cargo"))
149 .left_icon(Icon::Folder.into())
150 .indent_level(1),
151 ListEntry::new(Label::new(".idea").color(LabelColor::Hidden))
152 .left_icon(Icon::Folder.into())
153 .indent_level(1),
154 ListEntry::new(Label::new("assets"))
155 .left_icon(Icon::Folder.into())
156 .indent_level(1)
157 .set_toggle(ToggleState::Toggled),
158 ListEntry::new(Label::new("cargo-target").color(LabelColor::Hidden))
159 .left_icon(Icon::Folder.into())
160 .indent_level(1),
161 ListEntry::new(Label::new("crates"))
162 .left_icon(Icon::FolderOpen.into())
163 .indent_level(1)
164 .set_toggle(ToggleState::Toggled),
165 ListEntry::new(Label::new("activity_indicator"))
166 .left_icon(Icon::Folder.into())
167 .indent_level(2),
168 ListEntry::new(Label::new("ai"))
169 .left_icon(Icon::Folder.into())
170 .indent_level(2),
171 ListEntry::new(Label::new("audio"))
172 .left_icon(Icon::Folder.into())
173 .indent_level(2),
174 ListEntry::new(Label::new("auto_update"))
175 .left_icon(Icon::Folder.into())
176 .indent_level(2),
177 ListEntry::new(Label::new("breadcrumbs"))
178 .left_icon(Icon::Folder.into())
179 .indent_level(2),
180 ListEntry::new(Label::new("call"))
181 .left_icon(Icon::Folder.into())
182 .indent_level(2),
183 ListEntry::new(Label::new("sqlez").color(LabelColor::Modified))
184 .left_icon(Icon::Folder.into())
185 .indent_level(2)
186 .set_toggle(ToggleState::NotToggled),
187 ListEntry::new(Label::new("gpui2"))
188 .left_icon(Icon::FolderOpen.into())
189 .indent_level(2)
190 .set_toggle(ToggleState::Toggled),
191 ListEntry::new(Label::new("src"))
192 .left_icon(Icon::FolderOpen.into())
193 .indent_level(3)
194 .set_toggle(ToggleState::Toggled),
195 ListEntry::new(Label::new("derive_element.rs"))
196 .left_icon(Icon::FileRust.into())
197 .indent_level(4),
198 ListEntry::new(Label::new("storybook").color(LabelColor::Modified))
199 .left_icon(Icon::FolderOpen.into())
200 .indent_level(1)
201 .set_toggle(ToggleState::Toggled),
202 ListEntry::new(Label::new("docs").color(LabelColor::Default))
203 .left_icon(Icon::Folder.into())
204 .indent_level(2)
205 .set_toggle(ToggleState::Toggled),
206 ListEntry::new(Label::new("src").color(LabelColor::Modified))
207 .left_icon(Icon::FolderOpen.into())
208 .indent_level(3)
209 .set_toggle(ToggleState::Toggled),
210 ListEntry::new(Label::new("ui").color(LabelColor::Modified))
211 .left_icon(Icon::FolderOpen.into())
212 .indent_level(4)
213 .set_toggle(ToggleState::Toggled),
214 ListEntry::new(Label::new("component").color(LabelColor::Created))
215 .left_icon(Icon::FolderOpen.into())
216 .indent_level(5)
217 .set_toggle(ToggleState::Toggled),
218 ListEntry::new(Label::new("facepile.rs").color(LabelColor::Default))
219 .left_icon(Icon::FileRust.into())
220 .indent_level(6),
221 ListEntry::new(Label::new("follow_group.rs").color(LabelColor::Default))
222 .left_icon(Icon::FileRust.into())
223 .indent_level(6),
224 ListEntry::new(Label::new("list_item.rs").color(LabelColor::Created))
225 .left_icon(Icon::FileRust.into())
226 .indent_level(6),
227 ListEntry::new(Label::new("tab.rs").color(LabelColor::Default))
228 .left_icon(Icon::FileRust.into())
229 .indent_level(6),
230 ListEntry::new(Label::new("target").color(LabelColor::Hidden))
231 .left_icon(Icon::Folder.into())
232 .indent_level(1),
233 ListEntry::new(Label::new(".dockerignore"))
234 .left_icon(Icon::FileGeneric.into())
235 .indent_level(1),
236 ListEntry::new(Label::new(".DS_Store").color(LabelColor::Hidden))
237 .left_icon(Icon::FileGeneric.into())
238 .indent_level(1),
239 ListEntry::new(Label::new("Cargo.lock"))
240 .left_icon(Icon::FileLock.into())
241 .indent_level(1),
242 ListEntry::new(Label::new("Cargo.toml"))
243 .left_icon(Icon::FileToml.into())
244 .indent_level(1),
245 ListEntry::new(Label::new("Dockerfile"))
246 .left_icon(Icon::FileGeneric.into())
247 .indent_level(1),
248 ListEntry::new(Label::new("Procfile"))
249 .left_icon(Icon::FileGeneric.into())
250 .indent_level(1),
251 ListEntry::new(Label::new("README.md"))
252 .left_icon(Icon::FileDoc.into())
253 .indent_level(1),
254 ]
255 .into_iter()
256 .map(From::from)
257 .collect()
258}
259
260pub fn static_project_panel_single_items<S: 'static + Send + Sync + Clone>() -> Vec<ListItem<S>> {
261 vec![
262 ListEntry::new(Label::new("todo.md"))
263 .left_icon(Icon::FileDoc.into())
264 .indent_level(0),
265 ListEntry::new(Label::new("README.md"))
266 .left_icon(Icon::FileDoc.into())
267 .indent_level(0),
268 ListEntry::new(Label::new("config.json"))
269 .left_icon(Icon::FileGeneric.into())
270 .indent_level(0),
271 ]
272 .into_iter()
273 .map(From::from)
274 .collect()
275}
276
277pub fn empty_editor_example<S: 'static + Send + Sync + Clone>() -> Editor<S> {
278 Editor {
279 tabs: static_tabs_example(),
280 path: PathBuf::from_str("crates/ui/src/static_data.rs").unwrap(),
281 symbols: vec![],
282 buffer: empty_buffer_example(),
283 }
284}
285
286pub fn empty_buffer_example<S: 'static + Send + Sync + Clone>() -> Buffer<S> {
287 Buffer::new().set_rows(Some(BufferRows::default()))
288}
289
290pub fn hello_world_rust_editor_example<S: 'static + Send + Sync + Clone>(
291 theme: &Theme,
292) -> Editor<S> {
293 Editor {
294 tabs: static_tabs_example(),
295 path: PathBuf::from_str("crates/ui/src/static_data.rs").unwrap(),
296 symbols: vec![Symbol(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 ])],
306 buffer: hello_world_rust_buffer_example(theme),
307 }
308}
309
310pub fn hello_world_rust_buffer_example<S: 'static + Send + Sync + Clone>(
311 theme: &Theme,
312) -> Buffer<S> {
313 Buffer::new()
314 .set_title("hello_world.rs".to_string())
315 .set_path("src/hello_world.rs".to_string())
316 .set_language("rust".to_string())
317 .set_rows(Some(BufferRows {
318 show_line_numbers: true,
319 rows: hello_world_rust_buffer_rows(theme),
320 }))
321}
322
323pub fn hello_world_rust_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
324 let show_line_number = true;
325
326 vec![
327 BufferRow {
328 line_number: 1,
329 code_action: false,
330 current: true,
331 line: Some(HighlightedLine {
332 highlighted_texts: vec![
333 HighlightedText {
334 text: "fn ".to_string(),
335 color: HighlightColor::Keyword.hsla(&theme),
336 },
337 HighlightedText {
338 text: "main".to_string(),
339 color: HighlightColor::Function.hsla(&theme),
340 },
341 HighlightedText {
342 text: "() {".to_string(),
343 color: HighlightColor::Default.hsla(&theme),
344 },
345 ],
346 }),
347 cursors: None,
348 status: GitStatus::None,
349 show_line_number,
350 },
351 BufferRow {
352 line_number: 2,
353 code_action: false,
354 current: false,
355 line: Some(HighlightedLine {
356 highlighted_texts: vec![HighlightedText {
357 text: " // Statements here are executed when the compiled binary is called."
358 .to_string(),
359 color: HighlightColor::Comment.hsla(&theme),
360 }],
361 }),
362 cursors: None,
363 status: GitStatus::None,
364 show_line_number,
365 },
366 BufferRow {
367 line_number: 3,
368 code_action: false,
369 current: false,
370 line: None,
371 cursors: None,
372 status: GitStatus::None,
373 show_line_number,
374 },
375 BufferRow {
376 line_number: 4,
377 code_action: false,
378 current: false,
379 line: Some(HighlightedLine {
380 highlighted_texts: vec![HighlightedText {
381 text: " // Print text to the console.".to_string(),
382 color: HighlightColor::Comment.hsla(&theme),
383 }],
384 }),
385 cursors: None,
386 status: GitStatus::None,
387 show_line_number,
388 },
389 BufferRow {
390 line_number: 5,
391 code_action: false,
392 current: false,
393 line: Some(HighlightedLine {
394 highlighted_texts: vec![
395 HighlightedText {
396 text: " println!(".to_string(),
397 color: HighlightColor::Default.hsla(&theme),
398 },
399 HighlightedText {
400 text: "\"Hello, world!\"".to_string(),
401 color: HighlightColor::String.hsla(&theme),
402 },
403 HighlightedText {
404 text: ");".to_string(),
405 color: HighlightColor::Default.hsla(&theme),
406 },
407 ],
408 }),
409 cursors: None,
410 status: GitStatus::None,
411 show_line_number,
412 },
413 BufferRow {
414 line_number: 6,
415 code_action: false,
416 current: false,
417 line: Some(HighlightedLine {
418 highlighted_texts: vec![HighlightedText {
419 text: "}".to_string(),
420 color: HighlightColor::Default.hsla(&theme),
421 }],
422 }),
423 cursors: None,
424 status: GitStatus::None,
425 show_line_number,
426 },
427 ]
428}
429
430pub fn hello_world_rust_editor_with_status_example<S: 'static + Send + Sync + Clone>(
431 theme: &Theme,
432) -> Editor<S> {
433 Editor {
434 tabs: static_tabs_example(),
435 path: PathBuf::from_str("crates/ui/src/static_data.rs").unwrap(),
436 symbols: vec![Symbol(vec![
437 HighlightedText {
438 text: "fn ".to_string(),
439 color: HighlightColor::Keyword.hsla(&theme),
440 },
441 HighlightedText {
442 text: "main".to_string(),
443 color: HighlightColor::Function.hsla(&theme),
444 },
445 ])],
446 buffer: hello_world_rust_buffer_with_status_example(theme),
447 }
448}
449
450pub fn hello_world_rust_buffer_with_status_example<S: 'static + Send + Sync + Clone>(
451 theme: &Theme,
452) -> Buffer<S> {
453 Buffer::new()
454 .set_title("hello_world.rs".to_string())
455 .set_path("src/hello_world.rs".to_string())
456 .set_language("rust".to_string())
457 .set_rows(Some(BufferRows {
458 show_line_numbers: true,
459 rows: hello_world_rust_with_status_buffer_rows(theme),
460 }))
461}
462
463pub fn hello_world_rust_with_status_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
464 let show_line_number = true;
465
466 vec![
467 BufferRow {
468 line_number: 1,
469 code_action: false,
470 current: true,
471 line: Some(HighlightedLine {
472 highlighted_texts: vec![
473 HighlightedText {
474 text: "fn ".to_string(),
475 color: HighlightColor::Keyword.hsla(&theme),
476 },
477 HighlightedText {
478 text: "main".to_string(),
479 color: HighlightColor::Function.hsla(&theme),
480 },
481 HighlightedText {
482 text: "() {".to_string(),
483 color: HighlightColor::Default.hsla(&theme),
484 },
485 ],
486 }),
487 cursors: None,
488 status: GitStatus::None,
489 show_line_number,
490 },
491 BufferRow {
492 line_number: 2,
493 code_action: false,
494 current: false,
495 line: Some(HighlightedLine {
496 highlighted_texts: vec![HighlightedText {
497 text: "// Statements here are executed when the compiled binary is called."
498 .to_string(),
499 color: HighlightColor::Comment.hsla(&theme),
500 }],
501 }),
502 cursors: None,
503 status: GitStatus::Modified,
504 show_line_number,
505 },
506 BufferRow {
507 line_number: 3,
508 code_action: false,
509 current: false,
510 line: None,
511 cursors: None,
512 status: GitStatus::None,
513 show_line_number,
514 },
515 BufferRow {
516 line_number: 4,
517 code_action: false,
518 current: false,
519 line: Some(HighlightedLine {
520 highlighted_texts: vec![HighlightedText {
521 text: " // Print text to the console.".to_string(),
522 color: HighlightColor::Comment.hsla(&theme),
523 }],
524 }),
525 cursors: None,
526 status: GitStatus::None,
527 show_line_number,
528 },
529 BufferRow {
530 line_number: 5,
531 code_action: false,
532 current: false,
533 line: Some(HighlightedLine {
534 highlighted_texts: vec![
535 HighlightedText {
536 text: " println!(".to_string(),
537 color: HighlightColor::Default.hsla(&theme),
538 },
539 HighlightedText {
540 text: "\"Hello, world!\"".to_string(),
541 color: HighlightColor::String.hsla(&theme),
542 },
543 HighlightedText {
544 text: ");".to_string(),
545 color: HighlightColor::Default.hsla(&theme),
546 },
547 ],
548 }),
549 cursors: None,
550 status: GitStatus::None,
551 show_line_number,
552 },
553 BufferRow {
554 line_number: 6,
555 code_action: false,
556 current: false,
557 line: Some(HighlightedLine {
558 highlighted_texts: vec![HighlightedText {
559 text: "}".to_string(),
560 color: HighlightColor::Default.hsla(&theme),
561 }],
562 }),
563 cursors: None,
564 status: GitStatus::None,
565 show_line_number,
566 },
567 BufferRow {
568 line_number: 7,
569 code_action: false,
570 current: false,
571 line: Some(HighlightedLine {
572 highlighted_texts: vec![HighlightedText {
573 text: "".to_string(),
574 color: HighlightColor::Default.hsla(&theme),
575 }],
576 }),
577 cursors: None,
578 status: GitStatus::Created,
579 show_line_number,
580 },
581 BufferRow {
582 line_number: 8,
583 code_action: false,
584 current: false,
585 line: Some(HighlightedLine {
586 highlighted_texts: vec![HighlightedText {
587 text: "// Marshall and Nate were here".to_string(),
588 color: HighlightColor::Comment.hsla(&theme),
589 }],
590 }),
591 cursors: None,
592 status: GitStatus::Created,
593 show_line_number,
594 },
595 ]
596}
597
598pub fn terminal_buffer<S: 'static + Send + Sync + Clone>(theme: &Theme) -> Buffer<S> {
599 Buffer::new()
600 .set_title("zed — fish".to_string())
601 .set_rows(Some(BufferRows {
602 show_line_numbers: false,
603 rows: terminal_buffer_rows(theme),
604 }))
605}
606
607pub fn terminal_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
608 let show_line_number = false;
609
610 vec![
611 BufferRow {
612 line_number: 1,
613 code_action: false,
614 current: false,
615 line: Some(HighlightedLine {
616 highlighted_texts: vec![
617 HighlightedText {
618 text: "maxdeviant ".to_string(),
619 color: HighlightColor::Keyword.hsla(&theme),
620 },
621 HighlightedText {
622 text: "in ".to_string(),
623 color: HighlightColor::Default.hsla(&theme),
624 },
625 HighlightedText {
626 text: "profaned-capital ".to_string(),
627 color: HighlightColor::Function.hsla(&theme),
628 },
629 HighlightedText {
630 text: "in ".to_string(),
631 color: HighlightColor::Default.hsla(&theme),
632 },
633 HighlightedText {
634 text: "~/p/zed ".to_string(),
635 color: HighlightColor::Function.hsla(&theme),
636 },
637 HighlightedText {
638 text: "on ".to_string(),
639 color: HighlightColor::Default.hsla(&theme),
640 },
641 HighlightedText {
642 text: " gpui2-ui ".to_string(),
643 color: HighlightColor::Keyword.hsla(&theme),
644 },
645 ],
646 }),
647 cursors: None,
648 status: GitStatus::None,
649 show_line_number,
650 },
651 BufferRow {
652 line_number: 2,
653 code_action: false,
654 current: false,
655 line: Some(HighlightedLine {
656 highlighted_texts: vec![HighlightedText {
657 text: "λ ".to_string(),
658 color: HighlightColor::String.hsla(&theme),
659 }],
660 }),
661 cursors: None,
662 status: GitStatus::None,
663 show_line_number,
664 },
665 ]
666}