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