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