static_data.rs

  1use gpui2::WindowContext;
  2
  3use crate::{
  4    Buffer, BufferRow, BufferRows, GitStatus, HighlightColor, HighlightedLine, HighlightedText,
  5    Icon, Keybinding, Label, LabelColor, ListEntry, ListEntrySize, ListItem, MicStatus,
  6    ModifierKeys, PaletteItem, Player, PlayerCallStatus, PlayerWithCallStatus, ScreenShareStatus,
  7    ToggleState,
  8};
  9
 10pub fn static_players() -> Vec<Player> {
 11    vec![
 12        Player::new(
 13            0,
 14            "https://avatars.githubusercontent.com/u/1714999?v=4".into(),
 15            "nathansobo".into(),
 16        ),
 17        Player::new(
 18            1,
 19            "https://avatars.githubusercontent.com/u/326587?v=4".into(),
 20            "maxbrunsfeld".into(),
 21        ),
 22        Player::new(
 23            2,
 24            "https://avatars.githubusercontent.com/u/482957?v=4".into(),
 25            "as-cii".into(),
 26        ),
 27        Player::new(
 28            3,
 29            "https://avatars.githubusercontent.com/u/1714999?v=4".into(),
 30            "iamnbutler".into(),
 31        ),
 32        Player::new(
 33            4,
 34            "https://avatars.githubusercontent.com/u/1486634?v=4".into(),
 35            "maxdeviant".into(),
 36        ),
 37    ]
 38}
 39
 40pub fn static_players_with_call_status() -> Vec<PlayerWithCallStatus> {
 41    let players = static_players();
 42    let mut player_0_status = PlayerCallStatus::new();
 43    let player_1_status = PlayerCallStatus::new();
 44    let player_2_status = PlayerCallStatus::new();
 45    let mut player_3_status = PlayerCallStatus::new();
 46    let mut player_4_status = PlayerCallStatus::new();
 47
 48    player_0_status.screen_share_status = ScreenShareStatus::Shared;
 49    player_0_status.followers = Some(vec![players[1].clone(), players[3].clone()]);
 50
 51    player_3_status.voice_activity = 0.5;
 52    player_4_status.mic_status = MicStatus::Muted;
 53    player_4_status.in_current_project = false;
 54
 55    vec![
 56        PlayerWithCallStatus::new(players[0].clone(), player_0_status),
 57        PlayerWithCallStatus::new(players[1].clone(), player_1_status),
 58        PlayerWithCallStatus::new(players[2].clone(), player_2_status),
 59        PlayerWithCallStatus::new(players[3].clone(), player_3_status),
 60        PlayerWithCallStatus::new(players[4].clone(), player_4_status),
 61    ]
 62}
 63
 64pub fn static_project_panel_project_items() -> Vec<ListItem> {
 65    vec![
 66        ListEntry::new(Label::new("zed"))
 67            .left_icon(Icon::FolderOpen.into())
 68            .indent_level(0)
 69            .set_toggle(ToggleState::Toggled),
 70        ListEntry::new(Label::new(".cargo"))
 71            .left_icon(Icon::Folder.into())
 72            .indent_level(1),
 73        ListEntry::new(Label::new(".config"))
 74            .left_icon(Icon::Folder.into())
 75            .indent_level(1),
 76        ListEntry::new(Label::new(".git").color(LabelColor::Hidden))
 77            .left_icon(Icon::Folder.into())
 78            .indent_level(1),
 79        ListEntry::new(Label::new(".cargo"))
 80            .left_icon(Icon::Folder.into())
 81            .indent_level(1),
 82        ListEntry::new(Label::new(".idea").color(LabelColor::Hidden))
 83            .left_icon(Icon::Folder.into())
 84            .indent_level(1),
 85        ListEntry::new(Label::new("assets"))
 86            .left_icon(Icon::Folder.into())
 87            .indent_level(1)
 88            .set_toggle(ToggleState::Toggled),
 89        ListEntry::new(Label::new("cargo-target").color(LabelColor::Hidden))
 90            .left_icon(Icon::Folder.into())
 91            .indent_level(1),
 92        ListEntry::new(Label::new("crates"))
 93            .left_icon(Icon::FolderOpen.into())
 94            .indent_level(1)
 95            .set_toggle(ToggleState::Toggled),
 96        ListEntry::new(Label::new("activity_indicator"))
 97            .left_icon(Icon::Folder.into())
 98            .indent_level(2),
 99        ListEntry::new(Label::new("ai"))
100            .left_icon(Icon::Folder.into())
101            .indent_level(2),
102        ListEntry::new(Label::new("audio"))
103            .left_icon(Icon::Folder.into())
104            .indent_level(2),
105        ListEntry::new(Label::new("auto_update"))
106            .left_icon(Icon::Folder.into())
107            .indent_level(2),
108        ListEntry::new(Label::new("breadcrumbs"))
109            .left_icon(Icon::Folder.into())
110            .indent_level(2),
111        ListEntry::new(Label::new("call"))
112            .left_icon(Icon::Folder.into())
113            .indent_level(2),
114        ListEntry::new(Label::new("sqlez").color(LabelColor::Modified))
115            .left_icon(Icon::Folder.into())
116            .indent_level(2)
117            .set_toggle(ToggleState::NotToggled),
118        ListEntry::new(Label::new("gpui2"))
119            .left_icon(Icon::FolderOpen.into())
120            .indent_level(2)
121            .set_toggle(ToggleState::Toggled),
122        ListEntry::new(Label::new("src"))
123            .left_icon(Icon::FolderOpen.into())
124            .indent_level(3)
125            .set_toggle(ToggleState::Toggled),
126        ListEntry::new(Label::new("derrive_element.rs"))
127            .left_icon(Icon::FileRust.into())
128            .indent_level(4),
129        ListEntry::new(Label::new("storybook").color(LabelColor::Modified))
130            .left_icon(Icon::FolderOpen.into())
131            .indent_level(1)
132            .set_toggle(ToggleState::Toggled),
133        ListEntry::new(Label::new("docs").color(LabelColor::Default))
134            .left_icon(Icon::Folder.into())
135            .indent_level(2)
136            .set_toggle(ToggleState::Toggled),
137        ListEntry::new(Label::new("src").color(LabelColor::Modified))
138            .left_icon(Icon::FolderOpen.into())
139            .indent_level(3)
140            .set_toggle(ToggleState::Toggled),
141        ListEntry::new(Label::new("ui").color(LabelColor::Modified))
142            .left_icon(Icon::FolderOpen.into())
143            .indent_level(4)
144            .set_toggle(ToggleState::Toggled),
145        ListEntry::new(Label::new("component").color(LabelColor::Created))
146            .left_icon(Icon::FolderOpen.into())
147            .indent_level(5)
148            .set_toggle(ToggleState::Toggled),
149        ListEntry::new(Label::new("facepile.rs").color(LabelColor::Default))
150            .left_icon(Icon::FileRust.into())
151            .indent_level(6),
152        ListEntry::new(Label::new("follow_group.rs").color(LabelColor::Default))
153            .left_icon(Icon::FileRust.into())
154            .indent_level(6),
155        ListEntry::new(Label::new("list_item.rs").color(LabelColor::Created))
156            .left_icon(Icon::FileRust.into())
157            .indent_level(6),
158        ListEntry::new(Label::new("tab.rs").color(LabelColor::Default))
159            .left_icon(Icon::FileRust.into())
160            .indent_level(6),
161        ListEntry::new(Label::new("target").color(LabelColor::Hidden))
162            .left_icon(Icon::Folder.into())
163            .indent_level(1),
164        ListEntry::new(Label::new(".dockerignore"))
165            .left_icon(Icon::FileGeneric.into())
166            .indent_level(1),
167        ListEntry::new(Label::new(".DS_Store").color(LabelColor::Hidden))
168            .left_icon(Icon::FileGeneric.into())
169            .indent_level(1),
170        ListEntry::new(Label::new("Cargo.lock"))
171            .left_icon(Icon::FileLock.into())
172            .indent_level(1),
173        ListEntry::new(Label::new("Cargo.toml"))
174            .left_icon(Icon::FileToml.into())
175            .indent_level(1),
176        ListEntry::new(Label::new("Dockerfile"))
177            .left_icon(Icon::FileGeneric.into())
178            .indent_level(1),
179        ListEntry::new(Label::new("Procfile"))
180            .left_icon(Icon::FileGeneric.into())
181            .indent_level(1),
182        ListEntry::new(Label::new("README.md"))
183            .left_icon(Icon::FileDoc.into())
184            .indent_level(1),
185    ]
186    .into_iter()
187    .map(From::from)
188    .collect()
189}
190
191pub fn static_project_panel_single_items() -> Vec<ListItem> {
192    vec![
193        ListEntry::new(Label::new("todo.md"))
194            .left_icon(Icon::FileDoc.into())
195            .indent_level(0),
196        ListEntry::new(Label::new("README.md"))
197            .left_icon(Icon::FileDoc.into())
198            .indent_level(0),
199        ListEntry::new(Label::new("config.json"))
200            .left_icon(Icon::FileGeneric.into())
201            .indent_level(0),
202    ]
203    .into_iter()
204    .map(From::from)
205    .collect()
206}
207
208pub fn static_collab_panel_current_call() -> Vec<ListItem> {
209    vec![
210        ListEntry::new(Label::new("as-cii")).left_avatar("http://github.com/as-cii.png?s=50"),
211        ListEntry::new(Label::new("nathansobo"))
212            .left_avatar("http://github.com/nathansobo.png?s=50"),
213        ListEntry::new(Label::new("maxbrunsfeld"))
214            .left_avatar("http://github.com/maxbrunsfeld.png?s=50"),
215    ]
216    .into_iter()
217    .map(From::from)
218    .collect()
219}
220
221pub fn static_collab_panel_channels() -> Vec<ListItem> {
222    vec![
223        ListEntry::new(Label::new("zed"))
224            .left_icon(Icon::Hash.into())
225            .size(ListEntrySize::Medium)
226            .indent_level(0),
227        ListEntry::new(Label::new("community"))
228            .left_icon(Icon::Hash.into())
229            .size(ListEntrySize::Medium)
230            .indent_level(1),
231        ListEntry::new(Label::new("dashboards"))
232            .left_icon(Icon::Hash.into())
233            .size(ListEntrySize::Medium)
234            .indent_level(2),
235        ListEntry::new(Label::new("feedback"))
236            .left_icon(Icon::Hash.into())
237            .size(ListEntrySize::Medium)
238            .indent_level(2),
239        ListEntry::new(Label::new("teams-in-channels-alpha"))
240            .left_icon(Icon::Hash.into())
241            .size(ListEntrySize::Medium)
242            .indent_level(2),
243        ListEntry::new(Label::new("current-projects"))
244            .left_icon(Icon::Hash.into())
245            .size(ListEntrySize::Medium)
246            .indent_level(1),
247        ListEntry::new(Label::new("codegen"))
248            .left_icon(Icon::Hash.into())
249            .size(ListEntrySize::Medium)
250            .indent_level(2),
251        ListEntry::new(Label::new("gpui2"))
252            .left_icon(Icon::Hash.into())
253            .size(ListEntrySize::Medium)
254            .indent_level(2),
255        ListEntry::new(Label::new("livestreaming"))
256            .left_icon(Icon::Hash.into())
257            .size(ListEntrySize::Medium)
258            .indent_level(2),
259        ListEntry::new(Label::new("open-source"))
260            .left_icon(Icon::Hash.into())
261            .size(ListEntrySize::Medium)
262            .indent_level(2),
263        ListEntry::new(Label::new("replace"))
264            .left_icon(Icon::Hash.into())
265            .size(ListEntrySize::Medium)
266            .indent_level(2),
267        ListEntry::new(Label::new("semantic-index"))
268            .left_icon(Icon::Hash.into())
269            .size(ListEntrySize::Medium)
270            .indent_level(2),
271        ListEntry::new(Label::new("vim"))
272            .left_icon(Icon::Hash.into())
273            .size(ListEntrySize::Medium)
274            .indent_level(2),
275        ListEntry::new(Label::new("web-tech"))
276            .left_icon(Icon::Hash.into())
277            .size(ListEntrySize::Medium)
278            .indent_level(2),
279    ]
280    .into_iter()
281    .map(From::from)
282    .collect()
283}
284
285pub fn example_editor_actions() -> Vec<PaletteItem> {
286    vec![
287        PaletteItem::new("New File").keybinding(Keybinding::new(
288            "N".to_string(),
289            ModifierKeys::new().control(true),
290        )),
291        PaletteItem::new("Open File").keybinding(Keybinding::new(
292            "O".to_string(),
293            ModifierKeys::new().control(true),
294        )),
295        PaletteItem::new("Save File").keybinding(Keybinding::new(
296            "S".to_string(),
297            ModifierKeys::new().control(true),
298        )),
299        PaletteItem::new("Cut").keybinding(Keybinding::new(
300            "X".to_string(),
301            ModifierKeys::new().control(true),
302        )),
303        PaletteItem::new("Copy").keybinding(Keybinding::new(
304            "C".to_string(),
305            ModifierKeys::new().control(true),
306        )),
307        PaletteItem::new("Paste").keybinding(Keybinding::new(
308            "V".to_string(),
309            ModifierKeys::new().control(true),
310        )),
311        PaletteItem::new("Undo").keybinding(Keybinding::new(
312            "Z".to_string(),
313            ModifierKeys::new().control(true),
314        )),
315        PaletteItem::new("Redo").keybinding(Keybinding::new(
316            "Z".to_string(),
317            ModifierKeys::new().control(true).shift(true),
318        )),
319        PaletteItem::new("Find").keybinding(Keybinding::new(
320            "F".to_string(),
321            ModifierKeys::new().control(true),
322        )),
323        PaletteItem::new("Replace").keybinding(Keybinding::new(
324            "R".to_string(),
325            ModifierKeys::new().control(true),
326        )),
327        PaletteItem::new("Jump to Line"),
328        PaletteItem::new("Select All"),
329        PaletteItem::new("Deselect All"),
330        PaletteItem::new("Switch Document"),
331        PaletteItem::new("Insert Line Below"),
332        PaletteItem::new("Insert Line Above"),
333        PaletteItem::new("Move Line Up"),
334        PaletteItem::new("Move Line Down"),
335        PaletteItem::new("Toggle Comment"),
336        PaletteItem::new("Delete Line"),
337    ]
338}
339
340pub fn empty_buffer_example<V: 'static>() -> Buffer<V> {
341    Buffer::new().set_rows(Some(BufferRows::default()))
342}
343
344pub fn hello_world_rust_buffer_example<V: 'static>(cx: &WindowContext) -> Buffer<V> {
345    Buffer::new()
346        .set_title("hello_world.rs".to_string())
347        .set_path("src/hello_world.rs".to_string())
348        .set_language("rust".to_string())
349        .set_rows(Some(BufferRows {
350            show_line_numbers: true,
351            rows: hello_world_rust_buffer_rows(cx),
352        }))
353}
354
355pub fn hello_world_rust_buffer_with_status_example<V: 'static>(cx: &WindowContext) -> Buffer<V> {
356    Buffer::new()
357        .set_title("hello_world.rs".to_string())
358        .set_path("src/hello_world.rs".to_string())
359        .set_language("rust".to_string())
360        .set_rows(Some(BufferRows {
361            show_line_numbers: true,
362            rows: hello_world_rust_with_status_buffer_rows(cx),
363        }))
364}
365
366pub fn hello_world_rust_buffer_rows(cx: &WindowContext) -> Vec<BufferRow> {
367    let show_line_number = true;
368
369    vec![
370        BufferRow {
371            line_number: 1,
372            code_action: false,
373            current: true,
374            line: Some(HighlightedLine {
375                highlighted_texts: vec![
376                    HighlightedText {
377                        text: "fn ".to_string(),
378                        color: HighlightColor::Keyword.hsla(cx),
379                    },
380                    HighlightedText {
381                        text: "main".to_string(),
382                        color: HighlightColor::Function.hsla(cx),
383                    },
384                    HighlightedText {
385                        text: "() {".to_string(),
386                        color: HighlightColor::Default.hsla(cx),
387                    },
388                ],
389            }),
390            cursors: None,
391            status: GitStatus::None,
392            show_line_number,
393        },
394        BufferRow {
395            line_number: 2,
396            code_action: false,
397            current: false,
398            line: Some(HighlightedLine {
399                highlighted_texts: vec![HighlightedText {
400                    text: "    // Statements here are executed when the compiled binary is called."
401                        .to_string(),
402                    color: HighlightColor::Comment.hsla(cx),
403                }],
404            }),
405            cursors: None,
406            status: GitStatus::None,
407            show_line_number,
408        },
409        BufferRow {
410            line_number: 3,
411            code_action: false,
412            current: false,
413            line: None,
414            cursors: None,
415            status: GitStatus::None,
416            show_line_number,
417        },
418        BufferRow {
419            line_number: 4,
420            code_action: false,
421            current: false,
422            line: Some(HighlightedLine {
423                highlighted_texts: vec![HighlightedText {
424                    text: "    // Print text to the console.".to_string(),
425                    color: HighlightColor::Comment.hsla(cx),
426                }],
427            }),
428            cursors: None,
429            status: GitStatus::None,
430            show_line_number,
431        },
432        BufferRow {
433            line_number: 5,
434            code_action: false,
435            current: false,
436            line: Some(HighlightedLine {
437                highlighted_texts: vec![HighlightedText {
438                    text: "}".to_string(),
439                    color: HighlightColor::Default.hsla(cx),
440                }],
441            }),
442            cursors: None,
443            status: GitStatus::None,
444            show_line_number,
445        },
446    ]
447}
448
449pub fn hello_world_rust_with_status_buffer_rows(cx: &WindowContext) -> Vec<BufferRow> {
450    let show_line_number = true;
451
452    vec![
453        BufferRow {
454            line_number: 1,
455            code_action: false,
456            current: true,
457            line: Some(HighlightedLine {
458                highlighted_texts: vec![
459                    HighlightedText {
460                        text: "fn ".to_string(),
461                        color: HighlightColor::Keyword.hsla(cx),
462                    },
463                    HighlightedText {
464                        text: "main".to_string(),
465                        color: HighlightColor::Function.hsla(cx),
466                    },
467                    HighlightedText {
468                        text: "() {".to_string(),
469                        color: HighlightColor::Default.hsla(cx),
470                    },
471                ],
472            }),
473            cursors: None,
474            status: GitStatus::None,
475            show_line_number,
476        },
477        BufferRow {
478            line_number: 2,
479            code_action: false,
480            current: false,
481            line: Some(HighlightedLine {
482                highlighted_texts: vec![HighlightedText {
483                    text: "// Statements here are executed when the compiled binary is called."
484                        .to_string(),
485                    color: HighlightColor::Comment.hsla(cx),
486                }],
487            }),
488            cursors: None,
489            status: GitStatus::Modified,
490            show_line_number,
491        },
492        BufferRow {
493            line_number: 3,
494            code_action: false,
495            current: false,
496            line: None,
497            cursors: None,
498            status: GitStatus::None,
499            show_line_number,
500        },
501        BufferRow {
502            line_number: 4,
503            code_action: false,
504            current: false,
505            line: Some(HighlightedLine {
506                highlighted_texts: vec![HighlightedText {
507                    text: "    // Print text to the console.".to_string(),
508                    color: HighlightColor::Comment.hsla(cx),
509                }],
510            }),
511            cursors: None,
512            status: GitStatus::None,
513            show_line_number,
514        },
515        BufferRow {
516            line_number: 5,
517            code_action: false,
518            current: false,
519            line: Some(HighlightedLine {
520                highlighted_texts: vec![HighlightedText {
521                    text: "}".to_string(),
522                    color: HighlightColor::Default.hsla(cx),
523                }],
524            }),
525            cursors: None,
526            status: GitStatus::None,
527            show_line_number,
528        },
529        BufferRow {
530            line_number: 6,
531            code_action: false,
532            current: false,
533            line: Some(HighlightedLine {
534                highlighted_texts: vec![HighlightedText {
535                    text: "".to_string(),
536                    color: HighlightColor::Default.hsla(cx),
537                }],
538            }),
539            cursors: None,
540            status: GitStatus::Created,
541            show_line_number,
542        },
543        BufferRow {
544            line_number: 7,
545            code_action: false,
546            current: false,
547            line: Some(HighlightedLine {
548                highlighted_texts: vec![HighlightedText {
549                    text: "Marshall and Nate were here".to_string(),
550                    color: HighlightColor::Default.hsla(cx),
551                }],
552            }),
553            cursors: None,
554            status: GitStatus::Created,
555            show_line_number,
556        },
557    ]
558}