static_data.rs

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