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::{
11 binding, Buffer, BufferRow, BufferRows, Button, EditorPane, FileSystemStatus, GitStatus,
12 HighlightedLine, HighlightedText, Icon, KeyBinding, Label, ListEntry, ListEntrySize,
13 Livestream, MicStatus, Notification, NotificationAction, PaletteItem, Player, PlayerCallStatus,
14 PlayerWithCallStatus, PublicPlayer, ScreenShareStatus, Symbol, Tab, TextColor, Toggle,
15 VideoStatus,
16};
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 DateTime::parse_from_rfc3339("2023-11-02T11:59:57Z")
336 .unwrap()
337 .naive_local(),
338 Icon::AtSign,
339 Arc::new(|_, _| {}),
340 ),
341 Notification::new_actor_with_actions(
342 "notif-2",
343 "as-cii sent you a contact request.",
344 DateTime::parse_from_rfc3339("2023-11-02T12:09:07Z")
345 .unwrap()
346 .naive_local(),
347 PublicPlayer::new("as-cii", "http://github.com/as-cii.png?s=50"),
348 [
349 NotificationAction::new(
350 Button::new("Decline"),
351 "Decline Request",
352 (Some(Icon::XCircle), "Declined"),
353 ),
354 NotificationAction::new(
355 Button::new("Accept").variant(crate::ButtonVariant::Filled),
356 "Accept Request",
357 (Some(Icon::Check), "Accepted"),
358 ),
359 ],
360 ),
361 Notification::new_icon_message(
362 "notif-3",
363 "You were mentioned #design.",
364 DateTime::parse_from_rfc3339("2023-11-02T12:09:07Z")
365 .unwrap()
366 .naive_local(),
367 Icon::MessageBubbles,
368 Arc::new(|_, _| {}),
369 ),
370 Notification::new_actor_with_actions(
371 "notif-4",
372 "as-cii sent you a contact request.",
373 DateTime::parse_from_rfc3339("2023-11-01T12:09:07Z")
374 .unwrap()
375 .naive_local(),
376 PublicPlayer::new("as-cii", "http://github.com/as-cii.png?s=50"),
377 [
378 NotificationAction::new(
379 Button::new("Decline"),
380 "Decline Request",
381 (Some(Icon::XCircle), "Declined"),
382 ),
383 NotificationAction::new(
384 Button::new("Accept").variant(crate::ButtonVariant::Filled),
385 "Accept Request",
386 (Some(Icon::Check), "Accepted"),
387 ),
388 ],
389 ),
390 Notification::new_icon_message(
391 "notif-5",
392 "You were mentioned in a note.",
393 DateTime::parse_from_rfc3339("2023-10-28T12:09:07Z")
394 .unwrap()
395 .naive_local(),
396 Icon::AtSign,
397 Arc::new(|_, _| {}),
398 ),
399 Notification::new_actor_with_actions(
400 "notif-6",
401 "as-cii sent you a contact request.",
402 DateTime::parse_from_rfc3339("2022-10-25T12:09:07Z")
403 .unwrap()
404 .naive_local(),
405 PublicPlayer::new("as-cii", "http://github.com/as-cii.png?s=50"),
406 [
407 NotificationAction::new(
408 Button::new("Decline"),
409 "Decline Request",
410 (Some(Icon::XCircle), "Declined"),
411 ),
412 NotificationAction::new(
413 Button::new("Accept").variant(crate::ButtonVariant::Filled),
414 "Accept Request",
415 (Some(Icon::Check), "Accepted"),
416 ),
417 ],
418 ),
419 Notification::new_icon_message(
420 "notif-7",
421 "You were mentioned in a note.",
422 DateTime::parse_from_rfc3339("2022-10-14T12:09:07Z")
423 .unwrap()
424 .naive_local(),
425 Icon::AtSign,
426 Arc::new(|_, _| {}),
427 ),
428 Notification::new_actor_with_actions(
429 "notif-8",
430 "as-cii sent you a contact request.",
431 DateTime::parse_from_rfc3339("2021-10-12T12:09:07Z")
432 .unwrap()
433 .naive_local(),
434 PublicPlayer::new("as-cii", "http://github.com/as-cii.png?s=50"),
435 [
436 NotificationAction::new(
437 Button::new("Decline"),
438 "Decline Request",
439 (Some(Icon::XCircle), "Declined"),
440 ),
441 NotificationAction::new(
442 Button::new("Accept").variant(crate::ButtonVariant::Filled),
443 "Accept Request",
444 (Some(Icon::Check), "Accepted"),
445 ),
446 ],
447 ),
448 Notification::new_icon_message(
449 "notif-9",
450 "You were mentioned in a note.",
451 DateTime::parse_from_rfc3339("2021-02-02T12:09:07Z")
452 .unwrap()
453 .naive_local(),
454 Icon::AtSign,
455 Arc::new(|_, _| {}),
456 ),
457 Notification::new_actor_with_actions(
458 "notif-10",
459 "as-cii sent you a contact request.",
460 DateTime::parse_from_rfc3339("1969-07-20T00:00:00Z")
461 .unwrap()
462 .naive_local(),
463 PublicPlayer::new("as-cii", "http://github.com/as-cii.png?s=50"),
464 [
465 NotificationAction::new(
466 Button::new("Decline"),
467 "Decline Request",
468 (Some(Icon::XCircle), "Declined"),
469 ),
470 NotificationAction::new(
471 Button::new("Accept").variant(crate::ButtonVariant::Filled),
472 "Accept Request",
473 (Some(Icon::Check), "Accepted"),
474 ),
475 ],
476 ),
477 ]
478}
479
480pub fn static_project_panel_project_items<V>() -> Vec<ListEntry<V>> {
481 vec![
482 ListEntry::new("zed", Label::new("zed"))
483 .left_icon(Icon::FolderOpen.into())
484 .indent_level(0)
485 .toggle(Toggle::Toggled(true)),
486 ListEntry::new(".cargo", Label::new(".cargo"))
487 .left_icon(Icon::Folder.into())
488 .indent_level(1),
489 ListEntry::new(".config", Label::new(".config"))
490 .left_icon(Icon::Folder.into())
491 .indent_level(1),
492 ListEntry::new(".git", Label::new(".git").color(TextColor::Hidden))
493 .left_icon(Icon::Folder.into())
494 .indent_level(1),
495 ListEntry::new(".cargo", Label::new(".cargo"))
496 .left_icon(Icon::Folder.into())
497 .indent_level(1),
498 ListEntry::new(".idea", Label::new(".idea").color(TextColor::Hidden))
499 .left_icon(Icon::Folder.into())
500 .indent_level(1),
501 ListEntry::new("assets", Label::new("assets"))
502 .left_icon(Icon::Folder.into())
503 .indent_level(1)
504 .toggle(Toggle::Toggled(true)),
505 ListEntry::new(
506 "cargo-target",
507 Label::new("cargo-target").color(TextColor::Hidden),
508 )
509 .left_icon(Icon::Folder.into())
510 .indent_level(1),
511 ListEntry::new("crates", Label::new("crates"))
512 .left_icon(Icon::FolderOpen.into())
513 .indent_level(1)
514 .toggle(Toggle::Toggled(true)),
515 ListEntry::new("activity_indicator", Label::new("activity_indicator"))
516 .left_icon(Icon::Folder.into())
517 .indent_level(2),
518 ListEntry::new("ai", Label::new("ai"))
519 .left_icon(Icon::Folder.into())
520 .indent_level(2),
521 ListEntry::new("audio", Label::new("audio"))
522 .left_icon(Icon::Folder.into())
523 .indent_level(2),
524 ListEntry::new("auto_update", Label::new("auto_update"))
525 .left_icon(Icon::Folder.into())
526 .indent_level(2),
527 ListEntry::new("breadcrumbs", Label::new("breadcrumbs"))
528 .left_icon(Icon::Folder.into())
529 .indent_level(2),
530 ListEntry::new("call", Label::new("call"))
531 .left_icon(Icon::Folder.into())
532 .indent_level(2),
533 ListEntry::new("sqlez", Label::new("sqlez").color(TextColor::Modified))
534 .left_icon(Icon::Folder.into())
535 .indent_level(2)
536 .toggle(Toggle::Toggled(false)),
537 ListEntry::new("gpui2", Label::new("gpui2"))
538 .left_icon(Icon::FolderOpen.into())
539 .indent_level(2)
540 .toggle(Toggle::Toggled(true)),
541 ListEntry::new("src", Label::new("src"))
542 .left_icon(Icon::FolderOpen.into())
543 .indent_level(3)
544 .toggle(Toggle::Toggled(true)),
545 ListEntry::new("derive_element.rs", Label::new("derive_element.rs"))
546 .left_icon(Icon::FileRust.into())
547 .indent_level(4),
548 ListEntry::new(
549 "storybook",
550 Label::new("storybook").color(TextColor::Modified),
551 )
552 .left_icon(Icon::FolderOpen.into())
553 .indent_level(1)
554 .toggle(Toggle::Toggled(true)),
555 ListEntry::new("docs", Label::new("docs").color(TextColor::Default))
556 .left_icon(Icon::Folder.into())
557 .indent_level(2)
558 .toggle(Toggle::Toggled(true)),
559 ListEntry::new("src", Label::new("src").color(TextColor::Modified))
560 .left_icon(Icon::FolderOpen.into())
561 .indent_level(3)
562 .toggle(Toggle::Toggled(true)),
563 ListEntry::new("ui", Label::new("ui").color(TextColor::Modified))
564 .left_icon(Icon::FolderOpen.into())
565 .indent_level(4)
566 .toggle(Toggle::Toggled(true)),
567 ListEntry::new(
568 "component",
569 Label::new("component").color(TextColor::Created),
570 )
571 .left_icon(Icon::FolderOpen.into())
572 .indent_level(5)
573 .toggle(Toggle::Toggled(true)),
574 ListEntry::new(
575 "facepile.rs",
576 Label::new("facepile.rs").color(TextColor::Default),
577 )
578 .left_icon(Icon::FileRust.into())
579 .indent_level(6),
580 ListEntry::new(
581 "follow_group.rs",
582 Label::new("follow_group.rs").color(TextColor::Default),
583 )
584 .left_icon(Icon::FileRust.into())
585 .indent_level(6),
586 ListEntry::new(
587 "list_item.rs",
588 Label::new("list_item.rs").color(TextColor::Created),
589 )
590 .left_icon(Icon::FileRust.into())
591 .indent_level(6),
592 ListEntry::new("tab.rs", Label::new("tab.rs").color(TextColor::Default))
593 .left_icon(Icon::FileRust.into())
594 .indent_level(6),
595 ListEntry::new("target", Label::new("target").color(TextColor::Hidden))
596 .left_icon(Icon::Folder.into())
597 .indent_level(1),
598 ListEntry::new(".dockerignore", Label::new(".dockerignore"))
599 .left_icon(Icon::FileGeneric.into())
600 .indent_level(1),
601 ListEntry::new(
602 ".DS_Store",
603 Label::new(".DS_Store").color(TextColor::Hidden),
604 )
605 .left_icon(Icon::FileGeneric.into())
606 .indent_level(1),
607 ListEntry::new("Cargo.lock", Label::new("Cargo.lock"))
608 .left_icon(Icon::FileLock.into())
609 .indent_level(1),
610 ListEntry::new("Cargo.toml", Label::new("Cargo.toml"))
611 .left_icon(Icon::FileToml.into())
612 .indent_level(1),
613 ListEntry::new("Dockerfile", Label::new("Dockerfile"))
614 .left_icon(Icon::FileGeneric.into())
615 .indent_level(1),
616 ListEntry::new("Procfile", Label::new("Procfile"))
617 .left_icon(Icon::FileGeneric.into())
618 .indent_level(1),
619 ListEntry::new("README.md", Label::new("README.md"))
620 .left_icon(Icon::FileDoc.into())
621 .indent_level(1),
622 ]
623}
624
625pub fn static_project_panel_single_items<V>() -> Vec<ListEntry<V>> {
626 vec![
627 ListEntry::new("todo.md", Label::new("todo.md"))
628 .left_icon(Icon::FileDoc.into())
629 .indent_level(0),
630 ListEntry::new("README.md", Label::new("README.md"))
631 .left_icon(Icon::FileDoc.into())
632 .indent_level(0),
633 ListEntry::new("config.json", Label::new("config.json"))
634 .left_icon(Icon::FileGeneric.into())
635 .indent_level(0),
636 ]
637}
638
639pub fn static_collab_panel_current_call<V>() -> Vec<ListEntry<V>> {
640 vec![
641 ListEntry::new("as-cii", Label::new("as-cii"))
642 .left_avatar("http://github.com/as-cii.png?s=50"),
643 ListEntry::new("nathansobo", Label::new("nathansobo"))
644 .left_avatar("http://github.com/nathansobo.png?s=50"),
645 ListEntry::new("maxbrunsfeld", Label::new("maxbrunsfeld"))
646 .left_avatar("http://github.com/maxbrunsfeld.png?s=50"),
647 ]
648}
649
650pub fn static_collab_panel_channels<V>() -> Vec<ListEntry<V>> {
651 vec![
652 ListEntry::new("zed", Label::new("zed"))
653 .left_icon(Icon::Hash.into())
654 .size(ListEntrySize::Medium)
655 .indent_level(0),
656 ListEntry::new("community", Label::new("community"))
657 .left_icon(Icon::Hash.into())
658 .size(ListEntrySize::Medium)
659 .indent_level(1),
660 ListEntry::new("dashboards", Label::new("dashboards"))
661 .left_icon(Icon::Hash.into())
662 .size(ListEntrySize::Medium)
663 .indent_level(2),
664 ListEntry::new("feedback", Label::new("feedback"))
665 .left_icon(Icon::Hash.into())
666 .size(ListEntrySize::Medium)
667 .indent_level(2),
668 ListEntry::new(
669 "teams-in-channels-alpha",
670 Label::new("teams-in-channels-alpha"),
671 )
672 .left_icon(Icon::Hash.into())
673 .size(ListEntrySize::Medium)
674 .indent_level(2),
675 ListEntry::new("current-projects", Label::new("current-projects"))
676 .left_icon(Icon::Hash.into())
677 .size(ListEntrySize::Medium)
678 .indent_level(1),
679 ListEntry::new("codegen", Label::new("codegen"))
680 .left_icon(Icon::Hash.into())
681 .size(ListEntrySize::Medium)
682 .indent_level(2),
683 ListEntry::new("gpui2", Label::new("gpui2"))
684 .left_icon(Icon::Hash.into())
685 .size(ListEntrySize::Medium)
686 .indent_level(2),
687 ListEntry::new("livestreaming", Label::new("livestreaming"))
688 .left_icon(Icon::Hash.into())
689 .size(ListEntrySize::Medium)
690 .indent_level(2),
691 ListEntry::new("open-source", Label::new("open-source"))
692 .left_icon(Icon::Hash.into())
693 .size(ListEntrySize::Medium)
694 .indent_level(2),
695 ListEntry::new("replace", Label::new("replace"))
696 .left_icon(Icon::Hash.into())
697 .size(ListEntrySize::Medium)
698 .indent_level(2),
699 ListEntry::new("semantic-index", Label::new("semantic-index"))
700 .left_icon(Icon::Hash.into())
701 .size(ListEntrySize::Medium)
702 .indent_level(2),
703 ListEntry::new("vim", Label::new("vim"))
704 .left_icon(Icon::Hash.into())
705 .size(ListEntrySize::Medium)
706 .indent_level(2),
707 ListEntry::new("web-tech", Label::new("web-tech"))
708 .left_icon(Icon::Hash.into())
709 .size(ListEntrySize::Medium)
710 .indent_level(2),
711 ]
712}
713
714pub fn example_editor_actions() -> Vec<PaletteItem> {
715 vec![
716 PaletteItem::new("New File").key_binding(KeyBinding::new(binding("cmd-n"))),
717 PaletteItem::new("Open File").key_binding(KeyBinding::new(binding("cmd-o"))),
718 PaletteItem::new("Save File").key_binding(KeyBinding::new(binding("cmd-s"))),
719 PaletteItem::new("Cut").key_binding(KeyBinding::new(binding("cmd-x"))),
720 PaletteItem::new("Copy").key_binding(KeyBinding::new(binding("cmd-c"))),
721 PaletteItem::new("Paste").key_binding(KeyBinding::new(binding("cmd-v"))),
722 PaletteItem::new("Undo").key_binding(KeyBinding::new(binding("cmd-z"))),
723 PaletteItem::new("Redo").key_binding(KeyBinding::new(binding("cmd-shift-z"))),
724 PaletteItem::new("Find").key_binding(KeyBinding::new(binding("cmd-f"))),
725 PaletteItem::new("Replace").key_binding(KeyBinding::new(binding("cmd-r"))),
726 PaletteItem::new("Jump to Line"),
727 PaletteItem::new("Select All"),
728 PaletteItem::new("Deselect All"),
729 PaletteItem::new("Switch Document"),
730 PaletteItem::new("Insert Line Below"),
731 PaletteItem::new("Insert Line Above"),
732 PaletteItem::new("Move Line Up"),
733 PaletteItem::new("Move Line Down"),
734 PaletteItem::new("Toggle Comment"),
735 PaletteItem::new("Delete Line"),
736 ]
737}
738
739pub fn empty_editor_example(cx: &mut ViewContext<EditorPane>) -> EditorPane {
740 EditorPane::new(
741 cx,
742 static_tabs_example(),
743 PathBuf::from_str("crates/ui/src/static_data.rs").unwrap(),
744 vec![],
745 empty_buffer_example(),
746 )
747}
748
749pub fn empty_buffer_example() -> Buffer {
750 Buffer::new("empty-buffer").set_rows(Some(BufferRows::default()))
751}
752
753pub fn hello_world_rust_editor_example(cx: &mut ViewContext<EditorPane>) -> EditorPane {
754 EditorPane::new(
755 cx,
756 static_tabs_example(),
757 PathBuf::from_str("crates/ui/src/static_data.rs").unwrap(),
758 vec![Symbol(vec![
759 HighlightedText {
760 text: "fn ".into(),
761 color: cx.theme().syntax_color("keyword"),
762 },
763 HighlightedText {
764 text: "main".into(),
765 color: cx.theme().syntax_color("function"),
766 },
767 ])],
768 hello_world_rust_buffer_example(cx),
769 )
770}
771
772pub fn hello_world_rust_buffer_example(cx: &AppContext) -> Buffer {
773 Buffer::new("hello-world-rust-buffer")
774 .set_title("hello_world.rs".to_string())
775 .set_path("src/hello_world.rs".to_string())
776 .set_language("rust".to_string())
777 .set_rows(Some(BufferRows {
778 show_line_numbers: true,
779 rows: hello_world_rust_buffer_rows(cx),
780 }))
781}
782
783pub fn hello_world_rust_buffer_rows(cx: &AppContext) -> Vec<BufferRow> {
784 let show_line_number = true;
785
786 vec![
787 BufferRow {
788 line_number: 1,
789 code_action: false,
790 current: true,
791 line: Some(HighlightedLine {
792 highlighted_texts: vec![
793 HighlightedText {
794 text: "fn ".into(),
795 color: cx.theme().syntax_color("keyword"),
796 },
797 HighlightedText {
798 text: "main".into(),
799 color: cx.theme().syntax_color("function"),
800 },
801 HighlightedText {
802 text: "() {".into(),
803 color: cx.theme().colors().text,
804 },
805 ],
806 }),
807 cursors: None,
808 status: GitStatus::None,
809 show_line_number,
810 },
811 BufferRow {
812 line_number: 2,
813 code_action: false,
814 current: false,
815 line: Some(HighlightedLine {
816 highlighted_texts: vec![HighlightedText {
817 text: " // Statements here are executed when the compiled binary is called."
818 .into(),
819 color: cx.theme().syntax_color("comment"),
820 }],
821 }),
822 cursors: None,
823 status: GitStatus::None,
824 show_line_number,
825 },
826 BufferRow {
827 line_number: 3,
828 code_action: false,
829 current: false,
830 line: None,
831 cursors: None,
832 status: GitStatus::None,
833 show_line_number,
834 },
835 BufferRow {
836 line_number: 4,
837 code_action: false,
838 current: false,
839 line: Some(HighlightedLine {
840 highlighted_texts: vec![HighlightedText {
841 text: " // Print text to the console.".into(),
842 color: cx.theme().syntax_color("comment"),
843 }],
844 }),
845 cursors: None,
846 status: GitStatus::None,
847 show_line_number,
848 },
849 BufferRow {
850 line_number: 5,
851 code_action: false,
852 current: false,
853 line: Some(HighlightedLine {
854 highlighted_texts: vec![
855 HighlightedText {
856 text: " println!(".into(),
857 color: cx.theme().colors().text,
858 },
859 HighlightedText {
860 text: "\"Hello, world!\"".into(),
861 color: cx.theme().syntax_color("string"),
862 },
863 HighlightedText {
864 text: ");".into(),
865 color: cx.theme().colors().text,
866 },
867 ],
868 }),
869 cursors: None,
870 status: GitStatus::None,
871 show_line_number,
872 },
873 BufferRow {
874 line_number: 6,
875 code_action: false,
876 current: false,
877 line: Some(HighlightedLine {
878 highlighted_texts: vec![HighlightedText {
879 text: "}".into(),
880 color: cx.theme().colors().text,
881 }],
882 }),
883 cursors: None,
884 status: GitStatus::None,
885 show_line_number,
886 },
887 ]
888}
889
890pub fn hello_world_rust_editor_with_status_example(cx: &mut ViewContext<EditorPane>) -> EditorPane {
891 EditorPane::new(
892 cx,
893 static_tabs_example(),
894 PathBuf::from_str("crates/ui/src/static_data.rs").unwrap(),
895 vec![Symbol(vec![
896 HighlightedText {
897 text: "fn ".into(),
898 color: cx.theme().syntax_color("keyword"),
899 },
900 HighlightedText {
901 text: "main".into(),
902 color: cx.theme().syntax_color("function"),
903 },
904 ])],
905 hello_world_rust_buffer_with_status_example(cx),
906 )
907}
908
909pub fn hello_world_rust_buffer_with_status_example(cx: &AppContext) -> Buffer {
910 Buffer::new("hello-world-rust-buffer-with-status")
911 .set_title("hello_world.rs".to_string())
912 .set_path("src/hello_world.rs".to_string())
913 .set_language("rust".to_string())
914 .set_rows(Some(BufferRows {
915 show_line_numbers: true,
916 rows: hello_world_rust_with_status_buffer_rows(cx),
917 }))
918}
919
920pub fn hello_world_rust_with_status_buffer_rows(cx: &AppContext) -> Vec<BufferRow> {
921 let show_line_number = true;
922
923 vec![
924 BufferRow {
925 line_number: 1,
926 code_action: false,
927 current: true,
928 line: Some(HighlightedLine {
929 highlighted_texts: vec![
930 HighlightedText {
931 text: "fn ".into(),
932 color: cx.theme().syntax_color("keyword"),
933 },
934 HighlightedText {
935 text: "main".into(),
936 color: cx.theme().syntax_color("function"),
937 },
938 HighlightedText {
939 text: "() {".into(),
940 color: cx.theme().colors().text,
941 },
942 ],
943 }),
944 cursors: None,
945 status: GitStatus::None,
946 show_line_number,
947 },
948 BufferRow {
949 line_number: 2,
950 code_action: false,
951 current: false,
952 line: Some(HighlightedLine {
953 highlighted_texts: vec![HighlightedText {
954 text: "// Statements here are executed when the compiled binary is called."
955 .into(),
956 color: cx.theme().syntax_color("comment"),
957 }],
958 }),
959 cursors: None,
960 status: GitStatus::Modified,
961 show_line_number,
962 },
963 BufferRow {
964 line_number: 3,
965 code_action: false,
966 current: false,
967 line: None,
968 cursors: None,
969 status: GitStatus::None,
970 show_line_number,
971 },
972 BufferRow {
973 line_number: 4,
974 code_action: false,
975 current: false,
976 line: Some(HighlightedLine {
977 highlighted_texts: vec![HighlightedText {
978 text: " // Print text to the console.".into(),
979 color: cx.theme().syntax_color("comment"),
980 }],
981 }),
982 cursors: None,
983 status: GitStatus::None,
984 show_line_number,
985 },
986 BufferRow {
987 line_number: 5,
988 code_action: false,
989 current: false,
990 line: Some(HighlightedLine {
991 highlighted_texts: vec![
992 HighlightedText {
993 text: " println!(".into(),
994 color: cx.theme().colors().text,
995 },
996 HighlightedText {
997 text: "\"Hello, world!\"".into(),
998 color: cx.theme().syntax_color("string"),
999 },
1000 HighlightedText {
1001 text: ");".into(),
1002 color: cx.theme().colors().text,
1003 },
1004 ],
1005 }),
1006 cursors: None,
1007 status: GitStatus::None,
1008 show_line_number,
1009 },
1010 BufferRow {
1011 line_number: 6,
1012 code_action: false,
1013 current: false,
1014 line: Some(HighlightedLine {
1015 highlighted_texts: vec![HighlightedText {
1016 text: "}".into(),
1017 color: cx.theme().colors().text,
1018 }],
1019 }),
1020 cursors: None,
1021 status: GitStatus::None,
1022 show_line_number,
1023 },
1024 BufferRow {
1025 line_number: 7,
1026 code_action: false,
1027 current: false,
1028 line: Some(HighlightedLine {
1029 highlighted_texts: vec![HighlightedText {
1030 text: "".into(),
1031 color: cx.theme().colors().text,
1032 }],
1033 }),
1034 cursors: None,
1035 status: GitStatus::Created,
1036 show_line_number,
1037 },
1038 BufferRow {
1039 line_number: 8,
1040 code_action: false,
1041 current: false,
1042 line: Some(HighlightedLine {
1043 highlighted_texts: vec![HighlightedText {
1044 text: "// Marshall and Nate were here".into(),
1045 color: cx.theme().syntax_color("comment"),
1046 }],
1047 }),
1048 cursors: None,
1049 status: GitStatus::Created,
1050 show_line_number,
1051 },
1052 ]
1053}
1054
1055pub fn terminal_buffer(cx: &AppContext) -> Buffer {
1056 Buffer::new("terminal")
1057 .set_title(Some("zed — fish".into()))
1058 .set_rows(Some(BufferRows {
1059 show_line_numbers: false,
1060 rows: terminal_buffer_rows(cx),
1061 }))
1062}
1063
1064pub fn terminal_buffer_rows(cx: &AppContext) -> Vec<BufferRow> {
1065 let show_line_number = false;
1066
1067 vec![
1068 BufferRow {
1069 line_number: 1,
1070 code_action: false,
1071 current: false,
1072 line: Some(HighlightedLine {
1073 highlighted_texts: vec![
1074 HighlightedText {
1075 text: "maxdeviant ".into(),
1076 color: cx.theme().syntax_color("keyword"),
1077 },
1078 HighlightedText {
1079 text: "in ".into(),
1080 color: cx.theme().colors().text,
1081 },
1082 HighlightedText {
1083 text: "profaned-capital ".into(),
1084 color: cx.theme().syntax_color("function"),
1085 },
1086 HighlightedText {
1087 text: "in ".into(),
1088 color: cx.theme().colors().text,
1089 },
1090 HighlightedText {
1091 text: "~/p/zed ".into(),
1092 color: cx.theme().syntax_color("function"),
1093 },
1094 HighlightedText {
1095 text: "on ".into(),
1096 color: cx.theme().colors().text,
1097 },
1098 HighlightedText {
1099 text: " gpui2-ui ".into(),
1100 color: cx.theme().syntax_color("keyword"),
1101 },
1102 ],
1103 }),
1104 cursors: None,
1105 status: GitStatus::None,
1106 show_line_number,
1107 },
1108 BufferRow {
1109 line_number: 2,
1110 code_action: false,
1111 current: false,
1112 line: Some(HighlightedLine {
1113 highlighted_texts: vec![HighlightedText {
1114 text: "λ ".into(),
1115 color: cx.theme().syntax_color("string"),
1116 }],
1117 }),
1118 cursors: None,
1119 status: GitStatus::None,
1120 show_line_number,
1121 },
1122 ]
1123}