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