1use std::path::PathBuf;
2use std::str::FromStr;
3use std::sync::Arc;
4
5use gpui2::{AppContext, ViewContext};
6use rand::Rng;
7use theme2::ActiveTheme;
8
9use crate::{
10 Buffer, BufferRow, BufferRows, Button, EditorPane, FileSystemStatus, GitStatus,
11 HighlightedLine, Icon, Keybinding, Label, LabelColor, ListEntry, ListEntrySize, ListSubHeader,
12 Livestream, MicStatus, ModifierKeys, Notification, PaletteItem, Player, PlayerCallStatus,
13 PlayerWithCallStatus, PublicActor, ScreenShareStatus, Symbol, Tab, ToggleState, VideoStatus,
14};
15use crate::{HighlightedText, ListDetailsEntry};
16use crate::{ListItem, NotificationAction};
17
18pub fn static_tabs_example() -> Vec<Tab> {
19 vec![
20 Tab::new("wip.rs")
21 .title("wip.rs".to_string())
22 .icon(Icon::FileRust)
23 .current(false)
24 .fs_status(FileSystemStatus::Deleted),
25 Tab::new("Cargo.toml")
26 .title("Cargo.toml".to_string())
27 .icon(Icon::FileToml)
28 .current(false)
29 .git_status(GitStatus::Modified),
30 Tab::new("Channels Panel")
31 .title("Channels Panel".to_string())
32 .icon(Icon::Hash)
33 .current(false),
34 Tab::new("channels_panel.rs")
35 .title("channels_panel.rs".to_string())
36 .icon(Icon::FileRust)
37 .current(true)
38 .git_status(GitStatus::Modified),
39 Tab::new("workspace.rs")
40 .title("workspace.rs".to_string())
41 .current(false)
42 .icon(Icon::FileRust)
43 .git_status(GitStatus::Modified),
44 Tab::new("icon_button.rs")
45 .title("icon_button.rs".to_string())
46 .icon(Icon::FileRust)
47 .current(false),
48 Tab::new("storybook.rs")
49 .title("storybook.rs".to_string())
50 .icon(Icon::FileRust)
51 .current(false)
52 .git_status(GitStatus::Created),
53 Tab::new("theme.rs")
54 .title("theme.rs".to_string())
55 .icon(Icon::FileRust)
56 .current(false),
57 Tab::new("theme_registry.rs")
58 .title("theme_registry.rs".to_string())
59 .icon(Icon::FileRust)
60 .current(false),
61 Tab::new("styleable_helpers.rs")
62 .title("styleable_helpers.rs".to_string())
63 .icon(Icon::FileRust)
64 .current(false),
65 ]
66}
67
68pub fn static_tabs_1() -> Vec<Tab> {
69 vec![
70 Tab::new("project_panel.rs")
71 .title("project_panel.rs".to_string())
72 .icon(Icon::FileRust)
73 .current(false)
74 .fs_status(FileSystemStatus::Deleted),
75 Tab::new("tab_bar.rs")
76 .title("tab_bar.rs".to_string())
77 .icon(Icon::FileRust)
78 .current(false)
79 .git_status(GitStatus::Modified),
80 Tab::new("workspace.rs")
81 .title("workspace.rs".to_string())
82 .icon(Icon::FileRust)
83 .current(false),
84 Tab::new("tab.rs")
85 .title("tab.rs".to_string())
86 .icon(Icon::FileRust)
87 .current(true)
88 .git_status(GitStatus::Modified),
89 ]
90}
91
92pub fn static_tabs_2() -> Vec<Tab> {
93 vec![
94 Tab::new("tab_bar.rs")
95 .title("tab_bar.rs".to_string())
96 .icon(Icon::FileRust)
97 .current(false)
98 .fs_status(FileSystemStatus::Deleted),
99 Tab::new("static_data.rs")
100 .title("static_data.rs".to_string())
101 .icon(Icon::FileRust)
102 .current(true)
103 .git_status(GitStatus::Modified),
104 ]
105}
106
107pub fn static_tabs_3() -> Vec<Tab> {
108 vec![Tab::new("static_tabs_3")
109 .git_status(GitStatus::Created)
110 .current(true)]
111}
112
113pub fn static_players() -> Vec<Player> {
114 vec![
115 Player::new(
116 0,
117 "https://avatars.githubusercontent.com/u/1714999?v=4".into(),
118 "nathansobo".into(),
119 ),
120 Player::new(
121 1,
122 "https://avatars.githubusercontent.com/u/326587?v=4".into(),
123 "maxbrunsfeld".into(),
124 ),
125 Player::new(
126 2,
127 "https://avatars.githubusercontent.com/u/482957?v=4".into(),
128 "as-cii".into(),
129 ),
130 Player::new(
131 3,
132 "https://avatars.githubusercontent.com/u/1714999?v=4".into(),
133 "iamnbutler".into(),
134 ),
135 Player::new(
136 4,
137 "https://avatars.githubusercontent.com/u/1486634?v=4".into(),
138 "maxdeviant".into(),
139 ),
140 ]
141}
142
143#[derive(Debug)]
144pub struct PlayerData {
145 pub url: String,
146 pub name: String,
147}
148
149pub fn static_player_data() -> Vec<PlayerData> {
150 vec![
151 PlayerData {
152 url: "https://avatars.githubusercontent.com/u/1714999?v=4".into(),
153 name: "iamnbutler".into(),
154 },
155 PlayerData {
156 url: "https://avatars.githubusercontent.com/u/326587?v=4".into(),
157 name: "maxbrunsfeld".into(),
158 },
159 PlayerData {
160 url: "https://avatars.githubusercontent.com/u/482957?v=4".into(),
161 name: "as-cii".into(),
162 },
163 PlayerData {
164 url: "https://avatars.githubusercontent.com/u/1789?v=4".into(),
165 name: "nathansobo".into(),
166 },
167 PlayerData {
168 url: "https://avatars.githubusercontent.com/u/1486634?v=4".into(),
169 name: "ForLoveOfCats".into(),
170 },
171 PlayerData {
172 url: "https://avatars.githubusercontent.com/u/2690773?v=4".into(),
173 name: "SomeoneToIgnore".into(),
174 },
175 PlayerData {
176 url: "https://avatars.githubusercontent.com/u/19867440?v=4".into(),
177 name: "JosephTLyons".into(),
178 },
179 PlayerData {
180 url: "https://avatars.githubusercontent.com/u/24362066?v=4".into(),
181 name: "osiewicz".into(),
182 },
183 PlayerData {
184 url: "https://avatars.githubusercontent.com/u/22121886?v=4".into(),
185 name: "KCaverly".into(),
186 },
187 PlayerData {
188 url: "https://avatars.githubusercontent.com/u/1486634?v=4".into(),
189 name: "maxdeviant".into(),
190 },
191 ]
192}
193
194pub fn create_static_players(player_data: Vec<PlayerData>) -> Vec<Player> {
195 let mut players = Vec::new();
196 for data in player_data {
197 players.push(Player::new(players.len(), data.url, data.name));
198 }
199 players
200}
201
202pub fn static_player_1(data: &Vec<PlayerData>) -> Player {
203 Player::new(1, data[0].url.clone(), data[0].name.clone())
204}
205
206pub fn static_player_2(data: &Vec<PlayerData>) -> Player {
207 Player::new(2, data[1].url.clone(), data[1].name.clone())
208}
209
210pub fn static_player_3(data: &Vec<PlayerData>) -> Player {
211 Player::new(3, data[2].url.clone(), data[2].name.clone())
212}
213
214pub fn static_player_4(data: &Vec<PlayerData>) -> Player {
215 Player::new(4, data[3].url.clone(), data[3].name.clone())
216}
217
218pub fn static_player_5(data: &Vec<PlayerData>) -> Player {
219 Player::new(5, data[4].url.clone(), data[4].name.clone())
220}
221
222pub fn static_player_6(data: &Vec<PlayerData>) -> Player {
223 Player::new(6, data[5].url.clone(), data[5].name.clone())
224}
225
226pub fn static_player_7(data: &Vec<PlayerData>) -> Player {
227 Player::new(7, data[6].url.clone(), data[6].name.clone())
228}
229
230pub fn static_player_8(data: &Vec<PlayerData>) -> Player {
231 Player::new(8, data[7].url.clone(), data[7].name.clone())
232}
233
234pub fn static_player_9(data: &Vec<PlayerData>) -> Player {
235 Player::new(9, data[8].url.clone(), data[8].name.clone())
236}
237
238pub fn static_player_10(data: &Vec<PlayerData>) -> Player {
239 Player::new(10, data[9].url.clone(), data[9].name.clone())
240}
241
242pub fn static_livestream() -> Livestream {
243 Livestream {
244 players: random_players_with_call_status(7),
245 channel: Some("gpui2-ui".to_string()),
246 }
247}
248
249pub fn populate_player_call_status(
250 player: Player,
251 followers: Option<Vec<Player>>,
252) -> PlayerCallStatus {
253 let mut rng = rand::thread_rng();
254 let in_current_project: bool = rng.gen();
255 let disconnected: bool = rng.gen();
256 let voice_activity: f32 = rng.gen();
257 let mic_status = if rng.gen_bool(0.5) {
258 MicStatus::Muted
259 } else {
260 MicStatus::Unmuted
261 };
262 let video_status = if rng.gen_bool(0.5) {
263 VideoStatus::On
264 } else {
265 VideoStatus::Off
266 };
267 let screen_share_status = if rng.gen_bool(0.5) {
268 ScreenShareStatus::Shared
269 } else {
270 ScreenShareStatus::NotShared
271 };
272 PlayerCallStatus {
273 mic_status,
274 voice_activity,
275 video_status,
276 screen_share_status,
277 in_current_project,
278 disconnected,
279 following: None,
280 followers,
281 }
282}
283
284pub fn random_players_with_call_status(number_of_players: usize) -> Vec<PlayerWithCallStatus> {
285 let players = create_static_players(static_player_data());
286 let mut player_status = vec![];
287 for i in 0..number_of_players {
288 let followers = if i == 0 {
289 Some(vec![
290 players[1].clone(),
291 players[3].clone(),
292 players[5].clone(),
293 players[6].clone(),
294 ])
295 } else if i == 1 {
296 Some(vec![players[2].clone(), players[6].clone()])
297 } else {
298 None
299 };
300 let call_status = populate_player_call_status(players[i].clone(), followers);
301 player_status.push(PlayerWithCallStatus::new(players[i].clone(), call_status));
302 }
303 player_status
304}
305
306pub fn static_players_with_call_status() -> Vec<PlayerWithCallStatus> {
307 let players = static_players();
308 let mut player_0_status = PlayerCallStatus::new();
309 let player_1_status = PlayerCallStatus::new();
310 let player_2_status = PlayerCallStatus::new();
311 let mut player_3_status = PlayerCallStatus::new();
312 let mut player_4_status = PlayerCallStatus::new();
313
314 player_0_status.screen_share_status = ScreenShareStatus::Shared;
315 player_0_status.followers = Some(vec![players[1].clone(), players[3].clone()]);
316
317 player_3_status.voice_activity = 0.5;
318 player_4_status.mic_status = MicStatus::Muted;
319 player_4_status.in_current_project = false;
320
321 vec![
322 PlayerWithCallStatus::new(players[0].clone(), player_0_status),
323 PlayerWithCallStatus::new(players[1].clone(), player_1_status),
324 PlayerWithCallStatus::new(players[2].clone(), player_2_status),
325 PlayerWithCallStatus::new(players[3].clone(), player_3_status),
326 PlayerWithCallStatus::new(players[4].clone(), player_4_status),
327 ]
328}
329
330pub fn static_new_notification_items_2<V: 'static>() -> Vec<Notification<V>> {
331 vec![
332 Notification::new_icon_message(
333 "notif-1",
334 "You were mentioned in a note.",
335 Icon::AtSign,
336 Arc::new(|_, _| {}),
337 ),
338 Notification::new_actor_with_actions(
339 "notif-2",
340 "as-cii sent you a contact request.",
341 PublicActor::new("as-cii", "http://github.com/as-cii.png?s=50"),
342 [
343 NotificationAction::new(
344 Button::new("Decline"),
345 "Decline Request",
346 (Some(Icon::XCircle), "Declined"),
347 ),
348 NotificationAction::new(
349 Button::new("Accept").variant(crate::ButtonVariant::Filled),
350 "Accept Request",
351 (Some(Icon::Check), "Accepted"),
352 ),
353 ],
354 ),
355 Notification::new_icon_message(
356 "notif-3",
357 "You were mentioned #design.",
358 Icon::MessageBubbles,
359 Arc::new(|_, _| {}),
360 ),
361 Notification::new_actor_with_actions(
362 "notif-4",
363 "as-cii sent you a contact request.",
364 PublicActor::new("as-cii", "http://github.com/as-cii.png?s=50"),
365 [
366 NotificationAction::new(
367 Button::new("Decline"),
368 "Decline Request",
369 (Some(Icon::XCircle), "Declined"),
370 ),
371 NotificationAction::new(
372 Button::new("Accept").variant(crate::ButtonVariant::Filled),
373 "Accept Request",
374 (Some(Icon::Check), "Accepted"),
375 ),
376 ],
377 ),
378 Notification::new_icon_message(
379 "notif-5",
380 "You were mentioned in a note.",
381 Icon::AtSign,
382 Arc::new(|_, _| {}),
383 ),
384 Notification::new_actor_with_actions(
385 "notif-6",
386 "as-cii sent you a contact request.",
387 PublicActor::new("as-cii", "http://github.com/as-cii.png?s=50"),
388 [
389 NotificationAction::new(
390 Button::new("Decline"),
391 "Decline Request",
392 (Some(Icon::XCircle), "Declined"),
393 ),
394 NotificationAction::new(
395 Button::new("Accept").variant(crate::ButtonVariant::Filled),
396 "Accept Request",
397 (Some(Icon::Check), "Accepted"),
398 ),
399 ],
400 ),
401 Notification::new_icon_message(
402 "notif-7",
403 "You were mentioned in a note.",
404 Icon::AtSign,
405 Arc::new(|_, _| {}),
406 ),
407 Notification::new_actor_with_actions(
408 "notif-8",
409 "as-cii sent you a contact request.",
410 PublicActor::new("as-cii", "http://github.com/as-cii.png?s=50"),
411 [
412 NotificationAction::new(
413 Button::new("Decline"),
414 "Decline Request",
415 (Some(Icon::XCircle), "Declined"),
416 ),
417 NotificationAction::new(
418 Button::new("Accept").variant(crate::ButtonVariant::Filled),
419 "Accept Request",
420 (Some(Icon::Check), "Accepted"),
421 ),
422 ],
423 ),
424 Notification::new_icon_message(
425 "notif-9",
426 "You were mentioned in a note.",
427 Icon::AtSign,
428 Arc::new(|_, _| {}),
429 ),
430 Notification::new_actor_with_actions(
431 "notif-10",
432 "as-cii sent you a contact request.",
433 PublicActor::new("as-cii", "http://github.com/as-cii.png?s=50"),
434 [
435 NotificationAction::new(
436 Button::new("Decline"),
437 "Decline Request",
438 (Some(Icon::XCircle), "Declined"),
439 ),
440 NotificationAction::new(
441 Button::new("Accept").variant(crate::ButtonVariant::Filled),
442 "Accept Request",
443 (Some(Icon::Check), "Accepted"),
444 ),
445 ],
446 ),
447 ]
448}
449
450pub fn static_new_notification_items<V: 'static>() -> Vec<ListItem<V>> {
451 vec![
452 ListItem::Header(ListSubHeader::new("New")),
453 ListItem::Details(
454 ListDetailsEntry::new("maxdeviant invited you to join a stream in #design.")
455 .meta("4 people in stream."),
456 ),
457 ListItem::Details(ListDetailsEntry::new(
458 "nathansobo accepted your contact request.",
459 )),
460 ListItem::Header(ListSubHeader::new("Earlier")),
461 ListItem::Details(
462 ListDetailsEntry::new("mikaylamaki added you as a contact.").actions(vec![
463 Button::new("Decline"),
464 Button::new("Accept").variant(crate::ButtonVariant::Filled),
465 ]),
466 ),
467 ListItem::Details(
468 ListDetailsEntry::new("maxdeviant invited you to a stream in #design.")
469 .seen(true)
470 .meta("This stream has ended."),
471 ),
472 ListItem::Details(ListDetailsEntry::new(
473 "as-cii accepted your contact request.",
474 )),
475 ListItem::Details(
476 ListDetailsEntry::new("You were added as an admin on the #gpui2 channel.").seen(true),
477 ),
478 ListItem::Details(ListDetailsEntry::new(
479 "osiewicz accepted your contact request.",
480 )),
481 ListItem::Details(ListDetailsEntry::new(
482 "ConradIrwin accepted your contact request.",
483 )),
484 ListItem::Details(
485 ListDetailsEntry::new("nathansobo invited you to a stream in #gpui2.")
486 .seen(true)
487 .meta("This stream has ended."),
488 ),
489 ListItem::Details(ListDetailsEntry::new(
490 "nathansobo accepted your contact request.",
491 )),
492 ListItem::Header(ListSubHeader::new("Earlier")),
493 ListItem::Details(
494 ListDetailsEntry::new("mikaylamaki added you as a contact.").actions(vec![
495 Button::new("Decline"),
496 Button::new("Accept").variant(crate::ButtonVariant::Filled),
497 ]),
498 ),
499 ListItem::Details(
500 ListDetailsEntry::new("maxdeviant invited you to a stream in #design.")
501 .seen(true)
502 .meta("This stream has ended."),
503 ),
504 ListItem::Details(ListDetailsEntry::new(
505 "as-cii accepted your contact request.",
506 )),
507 ListItem::Details(
508 ListDetailsEntry::new("You were added as an admin on the #gpui2 channel.").seen(true),
509 ),
510 ListItem::Details(ListDetailsEntry::new(
511 "osiewicz accepted your contact request.",
512 )),
513 ListItem::Details(ListDetailsEntry::new(
514 "ConradIrwin accepted your contact request.",
515 )),
516 ListItem::Details(
517 ListDetailsEntry::new("nathansobo invited you to a stream in #gpui2.")
518 .seen(true)
519 .meta("This stream has ended."),
520 ),
521 ]
522 .into_iter()
523 .map(From::from)
524 .collect()
525}
526
527pub fn static_project_panel_project_items<V: 'static>() -> Vec<ListItem<V>> {
528 vec![
529 ListEntry::new(Label::new("zed"))
530 .left_icon(Icon::FolderOpen.into())
531 .indent_level(0)
532 .toggle(ToggleState::Toggled),
533 ListEntry::new(Label::new(".cargo"))
534 .left_icon(Icon::Folder.into())
535 .indent_level(1),
536 ListEntry::new(Label::new(".config"))
537 .left_icon(Icon::Folder.into())
538 .indent_level(1),
539 ListEntry::new(Label::new(".git").color(LabelColor::Hidden))
540 .left_icon(Icon::Folder.into())
541 .indent_level(1),
542 ListEntry::new(Label::new(".cargo"))
543 .left_icon(Icon::Folder.into())
544 .indent_level(1),
545 ListEntry::new(Label::new(".idea").color(LabelColor::Hidden))
546 .left_icon(Icon::Folder.into())
547 .indent_level(1),
548 ListEntry::new(Label::new("assets"))
549 .left_icon(Icon::Folder.into())
550 .indent_level(1)
551 .toggle(ToggleState::Toggled),
552 ListEntry::new(Label::new("cargo-target").color(LabelColor::Hidden))
553 .left_icon(Icon::Folder.into())
554 .indent_level(1),
555 ListEntry::new(Label::new("crates"))
556 .left_icon(Icon::FolderOpen.into())
557 .indent_level(1)
558 .toggle(ToggleState::Toggled),
559 ListEntry::new(Label::new("activity_indicator"))
560 .left_icon(Icon::Folder.into())
561 .indent_level(2),
562 ListEntry::new(Label::new("ai"))
563 .left_icon(Icon::Folder.into())
564 .indent_level(2),
565 ListEntry::new(Label::new("audio"))
566 .left_icon(Icon::Folder.into())
567 .indent_level(2),
568 ListEntry::new(Label::new("auto_update"))
569 .left_icon(Icon::Folder.into())
570 .indent_level(2),
571 ListEntry::new(Label::new("breadcrumbs"))
572 .left_icon(Icon::Folder.into())
573 .indent_level(2),
574 ListEntry::new(Label::new("call"))
575 .left_icon(Icon::Folder.into())
576 .indent_level(2),
577 ListEntry::new(Label::new("sqlez").color(LabelColor::Modified))
578 .left_icon(Icon::Folder.into())
579 .indent_level(2)
580 .toggle(ToggleState::NotToggled),
581 ListEntry::new(Label::new("gpui2"))
582 .left_icon(Icon::FolderOpen.into())
583 .indent_level(2)
584 .toggle(ToggleState::Toggled),
585 ListEntry::new(Label::new("src"))
586 .left_icon(Icon::FolderOpen.into())
587 .indent_level(3)
588 .toggle(ToggleState::Toggled),
589 ListEntry::new(Label::new("derive_element.rs"))
590 .left_icon(Icon::FileRust.into())
591 .indent_level(4),
592 ListEntry::new(Label::new("storybook").color(LabelColor::Modified))
593 .left_icon(Icon::FolderOpen.into())
594 .indent_level(1)
595 .toggle(ToggleState::Toggled),
596 ListEntry::new(Label::new("docs").color(LabelColor::Default))
597 .left_icon(Icon::Folder.into())
598 .indent_level(2)
599 .toggle(ToggleState::Toggled),
600 ListEntry::new(Label::new("src").color(LabelColor::Modified))
601 .left_icon(Icon::FolderOpen.into())
602 .indent_level(3)
603 .toggle(ToggleState::Toggled),
604 ListEntry::new(Label::new("ui").color(LabelColor::Modified))
605 .left_icon(Icon::FolderOpen.into())
606 .indent_level(4)
607 .toggle(ToggleState::Toggled),
608 ListEntry::new(Label::new("component").color(LabelColor::Created))
609 .left_icon(Icon::FolderOpen.into())
610 .indent_level(5)
611 .toggle(ToggleState::Toggled),
612 ListEntry::new(Label::new("facepile.rs").color(LabelColor::Default))
613 .left_icon(Icon::FileRust.into())
614 .indent_level(6),
615 ListEntry::new(Label::new("follow_group.rs").color(LabelColor::Default))
616 .left_icon(Icon::FileRust.into())
617 .indent_level(6),
618 ListEntry::new(Label::new("list_item.rs").color(LabelColor::Created))
619 .left_icon(Icon::FileRust.into())
620 .indent_level(6),
621 ListEntry::new(Label::new("tab.rs").color(LabelColor::Default))
622 .left_icon(Icon::FileRust.into())
623 .indent_level(6),
624 ListEntry::new(Label::new("target").color(LabelColor::Hidden))
625 .left_icon(Icon::Folder.into())
626 .indent_level(1),
627 ListEntry::new(Label::new(".dockerignore"))
628 .left_icon(Icon::FileGeneric.into())
629 .indent_level(1),
630 ListEntry::new(Label::new(".DS_Store").color(LabelColor::Hidden))
631 .left_icon(Icon::FileGeneric.into())
632 .indent_level(1),
633 ListEntry::new(Label::new("Cargo.lock"))
634 .left_icon(Icon::FileLock.into())
635 .indent_level(1),
636 ListEntry::new(Label::new("Cargo.toml"))
637 .left_icon(Icon::FileToml.into())
638 .indent_level(1),
639 ListEntry::new(Label::new("Dockerfile"))
640 .left_icon(Icon::FileGeneric.into())
641 .indent_level(1),
642 ListEntry::new(Label::new("Procfile"))
643 .left_icon(Icon::FileGeneric.into())
644 .indent_level(1),
645 ListEntry::new(Label::new("README.md"))
646 .left_icon(Icon::FileDoc.into())
647 .indent_level(1),
648 ]
649 .into_iter()
650 .map(From::from)
651 .collect()
652}
653
654pub fn static_project_panel_single_items<V: 'static>() -> Vec<ListItem<V>> {
655 vec![
656 ListEntry::new(Label::new("todo.md"))
657 .left_icon(Icon::FileDoc.into())
658 .indent_level(0),
659 ListEntry::new(Label::new("README.md"))
660 .left_icon(Icon::FileDoc.into())
661 .indent_level(0),
662 ListEntry::new(Label::new("config.json"))
663 .left_icon(Icon::FileGeneric.into())
664 .indent_level(0),
665 ]
666 .into_iter()
667 .map(From::from)
668 .collect()
669}
670
671pub fn static_collab_panel_current_call<V: 'static>() -> Vec<ListItem<V>> {
672 vec![
673 ListEntry::new(Label::new("as-cii")).left_avatar("http://github.com/as-cii.png?s=50"),
674 ListEntry::new(Label::new("nathansobo"))
675 .left_avatar("http://github.com/nathansobo.png?s=50"),
676 ListEntry::new(Label::new("maxbrunsfeld"))
677 .left_avatar("http://github.com/maxbrunsfeld.png?s=50"),
678 ]
679 .into_iter()
680 .map(From::from)
681 .collect()
682}
683
684pub fn static_collab_panel_channels<V: 'static>() -> Vec<ListItem<V>> {
685 vec![
686 ListEntry::new(Label::new("zed"))
687 .left_icon(Icon::Hash.into())
688 .size(ListEntrySize::Medium)
689 .indent_level(0),
690 ListEntry::new(Label::new("community"))
691 .left_icon(Icon::Hash.into())
692 .size(ListEntrySize::Medium)
693 .indent_level(1),
694 ListEntry::new(Label::new("dashboards"))
695 .left_icon(Icon::Hash.into())
696 .size(ListEntrySize::Medium)
697 .indent_level(2),
698 ListEntry::new(Label::new("feedback"))
699 .left_icon(Icon::Hash.into())
700 .size(ListEntrySize::Medium)
701 .indent_level(2),
702 ListEntry::new(Label::new("teams-in-channels-alpha"))
703 .left_icon(Icon::Hash.into())
704 .size(ListEntrySize::Medium)
705 .indent_level(2),
706 ListEntry::new(Label::new("current-projects"))
707 .left_icon(Icon::Hash.into())
708 .size(ListEntrySize::Medium)
709 .indent_level(1),
710 ListEntry::new(Label::new("codegen"))
711 .left_icon(Icon::Hash.into())
712 .size(ListEntrySize::Medium)
713 .indent_level(2),
714 ListEntry::new(Label::new("gpui2"))
715 .left_icon(Icon::Hash.into())
716 .size(ListEntrySize::Medium)
717 .indent_level(2),
718 ListEntry::new(Label::new("livestreaming"))
719 .left_icon(Icon::Hash.into())
720 .size(ListEntrySize::Medium)
721 .indent_level(2),
722 ListEntry::new(Label::new("open-source"))
723 .left_icon(Icon::Hash.into())
724 .size(ListEntrySize::Medium)
725 .indent_level(2),
726 ListEntry::new(Label::new("replace"))
727 .left_icon(Icon::Hash.into())
728 .size(ListEntrySize::Medium)
729 .indent_level(2),
730 ListEntry::new(Label::new("semantic-index"))
731 .left_icon(Icon::Hash.into())
732 .size(ListEntrySize::Medium)
733 .indent_level(2),
734 ListEntry::new(Label::new("vim"))
735 .left_icon(Icon::Hash.into())
736 .size(ListEntrySize::Medium)
737 .indent_level(2),
738 ListEntry::new(Label::new("web-tech"))
739 .left_icon(Icon::Hash.into())
740 .size(ListEntrySize::Medium)
741 .indent_level(2),
742 ]
743 .into_iter()
744 .map(From::from)
745 .collect()
746}
747
748pub fn example_editor_actions() -> Vec<PaletteItem> {
749 vec![
750 PaletteItem::new("New File").keybinding(Keybinding::new(
751 "N".to_string(),
752 ModifierKeys::new().command(true),
753 )),
754 PaletteItem::new("Open File").keybinding(Keybinding::new(
755 "O".to_string(),
756 ModifierKeys::new().command(true),
757 )),
758 PaletteItem::new("Save File").keybinding(Keybinding::new(
759 "S".to_string(),
760 ModifierKeys::new().command(true),
761 )),
762 PaletteItem::new("Cut").keybinding(Keybinding::new(
763 "X".to_string(),
764 ModifierKeys::new().command(true),
765 )),
766 PaletteItem::new("Copy").keybinding(Keybinding::new(
767 "C".to_string(),
768 ModifierKeys::new().command(true),
769 )),
770 PaletteItem::new("Paste").keybinding(Keybinding::new(
771 "V".to_string(),
772 ModifierKeys::new().command(true),
773 )),
774 PaletteItem::new("Undo").keybinding(Keybinding::new(
775 "Z".to_string(),
776 ModifierKeys::new().command(true),
777 )),
778 PaletteItem::new("Redo").keybinding(Keybinding::new(
779 "Z".to_string(),
780 ModifierKeys::new().command(true).shift(true),
781 )),
782 PaletteItem::new("Find").keybinding(Keybinding::new(
783 "F".to_string(),
784 ModifierKeys::new().command(true),
785 )),
786 PaletteItem::new("Replace").keybinding(Keybinding::new(
787 "R".to_string(),
788 ModifierKeys::new().command(true),
789 )),
790 PaletteItem::new("Jump to Line"),
791 PaletteItem::new("Select All"),
792 PaletteItem::new("Deselect All"),
793 PaletteItem::new("Switch Document"),
794 PaletteItem::new("Insert Line Below"),
795 PaletteItem::new("Insert Line Above"),
796 PaletteItem::new("Move Line Up"),
797 PaletteItem::new("Move Line Down"),
798 PaletteItem::new("Toggle Comment"),
799 PaletteItem::new("Delete Line"),
800 ]
801}
802
803pub fn empty_editor_example(cx: &mut ViewContext<EditorPane>) -> EditorPane {
804 EditorPane::new(
805 cx,
806 static_tabs_example(),
807 PathBuf::from_str("crates/ui/src/static_data.rs").unwrap(),
808 vec![],
809 empty_buffer_example(),
810 )
811}
812
813pub fn empty_buffer_example() -> Buffer {
814 Buffer::new("empty-buffer").set_rows(Some(BufferRows::default()))
815}
816
817pub fn hello_world_rust_editor_example(cx: &mut ViewContext<EditorPane>) -> EditorPane {
818 EditorPane::new(
819 cx,
820 static_tabs_example(),
821 PathBuf::from_str("crates/ui/src/static_data.rs").unwrap(),
822 vec![Symbol(vec![
823 HighlightedText {
824 text: "fn ".to_string(),
825 color: cx.theme().syntax_color("keyword"),
826 },
827 HighlightedText {
828 text: "main".to_string(),
829 color: cx.theme().syntax_color("function"),
830 },
831 ])],
832 hello_world_rust_buffer_example(cx),
833 )
834}
835
836pub fn hello_world_rust_buffer_example(cx: &AppContext) -> Buffer {
837 Buffer::new("hello-world-rust-buffer")
838 .set_title("hello_world.rs".to_string())
839 .set_path("src/hello_world.rs".to_string())
840 .set_language("rust".to_string())
841 .set_rows(Some(BufferRows {
842 show_line_numbers: true,
843 rows: hello_world_rust_buffer_rows(cx),
844 }))
845}
846
847pub fn hello_world_rust_buffer_rows(cx: &AppContext) -> Vec<BufferRow> {
848 let show_line_number = true;
849
850 vec![
851 BufferRow {
852 line_number: 1,
853 code_action: false,
854 current: true,
855 line: Some(HighlightedLine {
856 highlighted_texts: vec![
857 HighlightedText {
858 text: "fn ".to_string(),
859 color: cx.theme().syntax_color("keyword"),
860 },
861 HighlightedText {
862 text: "main".to_string(),
863 color: cx.theme().syntax_color("function"),
864 },
865 HighlightedText {
866 text: "() {".to_string(),
867 color: cx.theme().colors().text,
868 },
869 ],
870 }),
871 cursors: None,
872 status: GitStatus::None,
873 show_line_number,
874 },
875 BufferRow {
876 line_number: 2,
877 code_action: false,
878 current: false,
879 line: Some(HighlightedLine {
880 highlighted_texts: vec![HighlightedText {
881 text: " // Statements here are executed when the compiled binary is called."
882 .to_string(),
883 color: cx.theme().syntax_color("comment"),
884 }],
885 }),
886 cursors: None,
887 status: GitStatus::None,
888 show_line_number,
889 },
890 BufferRow {
891 line_number: 3,
892 code_action: false,
893 current: false,
894 line: None,
895 cursors: None,
896 status: GitStatus::None,
897 show_line_number,
898 },
899 BufferRow {
900 line_number: 4,
901 code_action: false,
902 current: false,
903 line: Some(HighlightedLine {
904 highlighted_texts: vec![HighlightedText {
905 text: " // Print text to the console.".to_string(),
906 color: cx.theme().syntax_color("comment"),
907 }],
908 }),
909 cursors: None,
910 status: GitStatus::None,
911 show_line_number,
912 },
913 BufferRow {
914 line_number: 5,
915 code_action: false,
916 current: false,
917 line: Some(HighlightedLine {
918 highlighted_texts: vec![
919 HighlightedText {
920 text: " println!(".to_string(),
921 color: cx.theme().colors().text,
922 },
923 HighlightedText {
924 text: "\"Hello, world!\"".to_string(),
925 color: cx.theme().syntax_color("string"),
926 },
927 HighlightedText {
928 text: ");".to_string(),
929 color: cx.theme().colors().text,
930 },
931 ],
932 }),
933 cursors: None,
934 status: GitStatus::None,
935 show_line_number,
936 },
937 BufferRow {
938 line_number: 6,
939 code_action: false,
940 current: false,
941 line: Some(HighlightedLine {
942 highlighted_texts: vec![HighlightedText {
943 text: "}".to_string(),
944 color: cx.theme().colors().text,
945 }],
946 }),
947 cursors: None,
948 status: GitStatus::None,
949 show_line_number,
950 },
951 ]
952}
953
954pub fn hello_world_rust_editor_with_status_example(cx: &mut ViewContext<EditorPane>) -> EditorPane {
955 EditorPane::new(
956 cx,
957 static_tabs_example(),
958 PathBuf::from_str("crates/ui/src/static_data.rs").unwrap(),
959 vec![Symbol(vec![
960 HighlightedText {
961 text: "fn ".to_string(),
962 color: cx.theme().syntax_color("keyword"),
963 },
964 HighlightedText {
965 text: "main".to_string(),
966 color: cx.theme().syntax_color("function"),
967 },
968 ])],
969 hello_world_rust_buffer_with_status_example(cx),
970 )
971}
972
973pub fn hello_world_rust_buffer_with_status_example(cx: &AppContext) -> Buffer {
974 Buffer::new("hello-world-rust-buffer-with-status")
975 .set_title("hello_world.rs".to_string())
976 .set_path("src/hello_world.rs".to_string())
977 .set_language("rust".to_string())
978 .set_rows(Some(BufferRows {
979 show_line_numbers: true,
980 rows: hello_world_rust_with_status_buffer_rows(cx),
981 }))
982}
983
984pub fn hello_world_rust_with_status_buffer_rows(cx: &AppContext) -> Vec<BufferRow> {
985 let show_line_number = true;
986
987 vec![
988 BufferRow {
989 line_number: 1,
990 code_action: false,
991 current: true,
992 line: Some(HighlightedLine {
993 highlighted_texts: vec![
994 HighlightedText {
995 text: "fn ".to_string(),
996 color: cx.theme().syntax_color("keyword"),
997 },
998 HighlightedText {
999 text: "main".to_string(),
1000 color: cx.theme().syntax_color("function"),
1001 },
1002 HighlightedText {
1003 text: "() {".to_string(),
1004 color: cx.theme().colors().text,
1005 },
1006 ],
1007 }),
1008 cursors: None,
1009 status: GitStatus::None,
1010 show_line_number,
1011 },
1012 BufferRow {
1013 line_number: 2,
1014 code_action: false,
1015 current: false,
1016 line: Some(HighlightedLine {
1017 highlighted_texts: vec![HighlightedText {
1018 text: "// Statements here are executed when the compiled binary is called."
1019 .to_string(),
1020 color: cx.theme().syntax_color("comment"),
1021 }],
1022 }),
1023 cursors: None,
1024 status: GitStatus::Modified,
1025 show_line_number,
1026 },
1027 BufferRow {
1028 line_number: 3,
1029 code_action: false,
1030 current: false,
1031 line: None,
1032 cursors: None,
1033 status: GitStatus::None,
1034 show_line_number,
1035 },
1036 BufferRow {
1037 line_number: 4,
1038 code_action: false,
1039 current: false,
1040 line: Some(HighlightedLine {
1041 highlighted_texts: vec![HighlightedText {
1042 text: " // Print text to the console.".to_string(),
1043 color: cx.theme().syntax_color("comment"),
1044 }],
1045 }),
1046 cursors: None,
1047 status: GitStatus::None,
1048 show_line_number,
1049 },
1050 BufferRow {
1051 line_number: 5,
1052 code_action: false,
1053 current: false,
1054 line: Some(HighlightedLine {
1055 highlighted_texts: vec![
1056 HighlightedText {
1057 text: " println!(".to_string(),
1058 color: cx.theme().colors().text,
1059 },
1060 HighlightedText {
1061 text: "\"Hello, world!\"".to_string(),
1062 color: cx.theme().syntax_color("string"),
1063 },
1064 HighlightedText {
1065 text: ");".to_string(),
1066 color: cx.theme().colors().text,
1067 },
1068 ],
1069 }),
1070 cursors: None,
1071 status: GitStatus::None,
1072 show_line_number,
1073 },
1074 BufferRow {
1075 line_number: 6,
1076 code_action: false,
1077 current: false,
1078 line: Some(HighlightedLine {
1079 highlighted_texts: vec![HighlightedText {
1080 text: "}".to_string(),
1081 color: cx.theme().colors().text,
1082 }],
1083 }),
1084 cursors: None,
1085 status: GitStatus::None,
1086 show_line_number,
1087 },
1088 BufferRow {
1089 line_number: 7,
1090 code_action: false,
1091 current: false,
1092 line: Some(HighlightedLine {
1093 highlighted_texts: vec![HighlightedText {
1094 text: "".to_string(),
1095 color: cx.theme().colors().text,
1096 }],
1097 }),
1098 cursors: None,
1099 status: GitStatus::Created,
1100 show_line_number,
1101 },
1102 BufferRow {
1103 line_number: 8,
1104 code_action: false,
1105 current: false,
1106 line: Some(HighlightedLine {
1107 highlighted_texts: vec![HighlightedText {
1108 text: "// Marshall and Nate were here".to_string(),
1109 color: cx.theme().syntax_color("comment"),
1110 }],
1111 }),
1112 cursors: None,
1113 status: GitStatus::Created,
1114 show_line_number,
1115 },
1116 ]
1117}
1118
1119pub fn terminal_buffer(cx: &AppContext) -> Buffer {
1120 Buffer::new("terminal")
1121 .set_title("zed — fish".to_string())
1122 .set_rows(Some(BufferRows {
1123 show_line_numbers: false,
1124 rows: terminal_buffer_rows(cx),
1125 }))
1126}
1127
1128pub fn terminal_buffer_rows(cx: &AppContext) -> Vec<BufferRow> {
1129 let show_line_number = false;
1130
1131 vec![
1132 BufferRow {
1133 line_number: 1,
1134 code_action: false,
1135 current: false,
1136 line: Some(HighlightedLine {
1137 highlighted_texts: vec![
1138 HighlightedText {
1139 text: "maxdeviant ".to_string(),
1140 color: cx.theme().syntax_color("keyword"),
1141 },
1142 HighlightedText {
1143 text: "in ".to_string(),
1144 color: cx.theme().colors().text,
1145 },
1146 HighlightedText {
1147 text: "profaned-capital ".to_string(),
1148 color: cx.theme().syntax_color("function"),
1149 },
1150 HighlightedText {
1151 text: "in ".to_string(),
1152 color: cx.theme().colors().text,
1153 },
1154 HighlightedText {
1155 text: "~/p/zed ".to_string(),
1156 color: cx.theme().syntax_color("function"),
1157 },
1158 HighlightedText {
1159 text: "on ".to_string(),
1160 color: cx.theme().colors().text,
1161 },
1162 HighlightedText {
1163 text: " gpui2-ui ".to_string(),
1164 color: cx.theme().syntax_color("keyword"),
1165 },
1166 ],
1167 }),
1168 cursors: None,
1169 status: GitStatus::None,
1170 show_line_number,
1171 },
1172 BufferRow {
1173 line_number: 2,
1174 code_action: false,
1175 current: false,
1176 line: Some(HighlightedLine {
1177 highlighted_texts: vec![HighlightedText {
1178 text: "λ ".to_string(),
1179 color: cx.theme().syntax_color("string"),
1180 }],
1181 }),
1182 cursors: None,
1183 status: GitStatus::None,
1184 show_line_number,
1185 },
1186 ]
1187}