static_data.rs

   1use std::path::PathBuf;
   2use std::str::FromStr;
   3use std::sync::Arc;
   4
   5use chrono::DateTime;
   6use gpui2::{AppContext, ViewContext};
   7use rand::Rng;
   8use theme2::ActiveTheme;
   9
  10use crate::{
  11    Buffer, BufferRow, BufferRows, Button, EditorPane, FileSystemStatus, GitStatus,
  12    HighlightedLine, Icon, Keybinding, Label, LabelColor, ListEntry, ListEntrySize, ListSubHeader,
  13    Livestream, MicStatus, ModifierKeys, Notification, PaletteItem, Player, PlayerCallStatus,
  14    PlayerWithCallStatus, PublicActor, ScreenShareStatus, Symbol, Tab, ToggleState, VideoStatus,
  15};
  16use crate::{HighlightedText, ListDetailsEntry};
  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            PublicActor::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            PublicActor::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            PublicActor::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            PublicActor::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            PublicActor::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_new_notification_items<V: 'static>() -> Vec<ListItem<V>> {
 482    vec![
 483        ListItem::Header(ListSubHeader::new("New")),
 484        ListItem::Details(
 485            ListDetailsEntry::new("maxdeviant invited you to join a stream in #design.")
 486                .meta("4 people in stream."),
 487        ),
 488        ListItem::Details(ListDetailsEntry::new(
 489            "nathansobo accepted your contact request.",
 490        )),
 491        ListItem::Header(ListSubHeader::new("Earlier")),
 492        ListItem::Details(
 493            ListDetailsEntry::new("mikaylamaki added you as a contact.").actions(vec![
 494                Button::new("Decline"),
 495                Button::new("Accept").variant(crate::ButtonVariant::Filled),
 496            ]),
 497        ),
 498        ListItem::Details(
 499            ListDetailsEntry::new("maxdeviant invited you to a stream in #design.")
 500                .seen(true)
 501                .meta("This stream has ended."),
 502        ),
 503        ListItem::Details(ListDetailsEntry::new(
 504            "as-cii accepted your contact request.",
 505        )),
 506        ListItem::Details(
 507            ListDetailsEntry::new("You were added as an admin on the #gpui2 channel.").seen(true),
 508        ),
 509        ListItem::Details(ListDetailsEntry::new(
 510            "osiewicz accepted your contact request.",
 511        )),
 512        ListItem::Details(ListDetailsEntry::new(
 513            "ConradIrwin accepted your contact request.",
 514        )),
 515        ListItem::Details(
 516            ListDetailsEntry::new("nathansobo invited you to a stream in #gpui2.")
 517                .seen(true)
 518                .meta("This stream has ended."),
 519        ),
 520        ListItem::Details(ListDetailsEntry::new(
 521            "nathansobo accepted your contact request.",
 522        )),
 523        ListItem::Header(ListSubHeader::new("Earlier")),
 524        ListItem::Details(
 525            ListDetailsEntry::new("mikaylamaki added you as a contact.").actions(vec![
 526                Button::new("Decline"),
 527                Button::new("Accept").variant(crate::ButtonVariant::Filled),
 528            ]),
 529        ),
 530        ListItem::Details(
 531            ListDetailsEntry::new("maxdeviant invited you to a stream in #design.")
 532                .seen(true)
 533                .meta("This stream has ended."),
 534        ),
 535        ListItem::Details(ListDetailsEntry::new(
 536            "as-cii accepted your contact request.",
 537        )),
 538        ListItem::Details(
 539            ListDetailsEntry::new("You were added as an admin on the #gpui2 channel.").seen(true),
 540        ),
 541        ListItem::Details(ListDetailsEntry::new(
 542            "osiewicz accepted your contact request.",
 543        )),
 544        ListItem::Details(ListDetailsEntry::new(
 545            "ConradIrwin accepted your contact request.",
 546        )),
 547        ListItem::Details(
 548            ListDetailsEntry::new("nathansobo invited you to a stream in #gpui2.")
 549                .seen(true)
 550                .meta("This stream has ended."),
 551        ),
 552    ]
 553    .into_iter()
 554    .map(From::from)
 555    .collect()
 556}
 557
 558pub fn static_project_panel_project_items<V: 'static>() -> Vec<ListItem<V>> {
 559    vec![
 560        ListEntry::new(Label::new("zed"))
 561            .left_icon(Icon::FolderOpen.into())
 562            .indent_level(0)
 563            .toggle(ToggleState::Toggled),
 564        ListEntry::new(Label::new(".cargo"))
 565            .left_icon(Icon::Folder.into())
 566            .indent_level(1),
 567        ListEntry::new(Label::new(".config"))
 568            .left_icon(Icon::Folder.into())
 569            .indent_level(1),
 570        ListEntry::new(Label::new(".git").color(LabelColor::Hidden))
 571            .left_icon(Icon::Folder.into())
 572            .indent_level(1),
 573        ListEntry::new(Label::new(".cargo"))
 574            .left_icon(Icon::Folder.into())
 575            .indent_level(1),
 576        ListEntry::new(Label::new(".idea").color(LabelColor::Hidden))
 577            .left_icon(Icon::Folder.into())
 578            .indent_level(1),
 579        ListEntry::new(Label::new("assets"))
 580            .left_icon(Icon::Folder.into())
 581            .indent_level(1)
 582            .toggle(ToggleState::Toggled),
 583        ListEntry::new(Label::new("cargo-target").color(LabelColor::Hidden))
 584            .left_icon(Icon::Folder.into())
 585            .indent_level(1),
 586        ListEntry::new(Label::new("crates"))
 587            .left_icon(Icon::FolderOpen.into())
 588            .indent_level(1)
 589            .toggle(ToggleState::Toggled),
 590        ListEntry::new(Label::new("activity_indicator"))
 591            .left_icon(Icon::Folder.into())
 592            .indent_level(2),
 593        ListEntry::new(Label::new("ai"))
 594            .left_icon(Icon::Folder.into())
 595            .indent_level(2),
 596        ListEntry::new(Label::new("audio"))
 597            .left_icon(Icon::Folder.into())
 598            .indent_level(2),
 599        ListEntry::new(Label::new("auto_update"))
 600            .left_icon(Icon::Folder.into())
 601            .indent_level(2),
 602        ListEntry::new(Label::new("breadcrumbs"))
 603            .left_icon(Icon::Folder.into())
 604            .indent_level(2),
 605        ListEntry::new(Label::new("call"))
 606            .left_icon(Icon::Folder.into())
 607            .indent_level(2),
 608        ListEntry::new(Label::new("sqlez").color(LabelColor::Modified))
 609            .left_icon(Icon::Folder.into())
 610            .indent_level(2)
 611            .toggle(ToggleState::NotToggled),
 612        ListEntry::new(Label::new("gpui2"))
 613            .left_icon(Icon::FolderOpen.into())
 614            .indent_level(2)
 615            .toggle(ToggleState::Toggled),
 616        ListEntry::new(Label::new("src"))
 617            .left_icon(Icon::FolderOpen.into())
 618            .indent_level(3)
 619            .toggle(ToggleState::Toggled),
 620        ListEntry::new(Label::new("derive_element.rs"))
 621            .left_icon(Icon::FileRust.into())
 622            .indent_level(4),
 623        ListEntry::new(Label::new("storybook").color(LabelColor::Modified))
 624            .left_icon(Icon::FolderOpen.into())
 625            .indent_level(1)
 626            .toggle(ToggleState::Toggled),
 627        ListEntry::new(Label::new("docs").color(LabelColor::Default))
 628            .left_icon(Icon::Folder.into())
 629            .indent_level(2)
 630            .toggle(ToggleState::Toggled),
 631        ListEntry::new(Label::new("src").color(LabelColor::Modified))
 632            .left_icon(Icon::FolderOpen.into())
 633            .indent_level(3)
 634            .toggle(ToggleState::Toggled),
 635        ListEntry::new(Label::new("ui").color(LabelColor::Modified))
 636            .left_icon(Icon::FolderOpen.into())
 637            .indent_level(4)
 638            .toggle(ToggleState::Toggled),
 639        ListEntry::new(Label::new("component").color(LabelColor::Created))
 640            .left_icon(Icon::FolderOpen.into())
 641            .indent_level(5)
 642            .toggle(ToggleState::Toggled),
 643        ListEntry::new(Label::new("facepile.rs").color(LabelColor::Default))
 644            .left_icon(Icon::FileRust.into())
 645            .indent_level(6),
 646        ListEntry::new(Label::new("follow_group.rs").color(LabelColor::Default))
 647            .left_icon(Icon::FileRust.into())
 648            .indent_level(6),
 649        ListEntry::new(Label::new("list_item.rs").color(LabelColor::Created))
 650            .left_icon(Icon::FileRust.into())
 651            .indent_level(6),
 652        ListEntry::new(Label::new("tab.rs").color(LabelColor::Default))
 653            .left_icon(Icon::FileRust.into())
 654            .indent_level(6),
 655        ListEntry::new(Label::new("target").color(LabelColor::Hidden))
 656            .left_icon(Icon::Folder.into())
 657            .indent_level(1),
 658        ListEntry::new(Label::new(".dockerignore"))
 659            .left_icon(Icon::FileGeneric.into())
 660            .indent_level(1),
 661        ListEntry::new(Label::new(".DS_Store").color(LabelColor::Hidden))
 662            .left_icon(Icon::FileGeneric.into())
 663            .indent_level(1),
 664        ListEntry::new(Label::new("Cargo.lock"))
 665            .left_icon(Icon::FileLock.into())
 666            .indent_level(1),
 667        ListEntry::new(Label::new("Cargo.toml"))
 668            .left_icon(Icon::FileToml.into())
 669            .indent_level(1),
 670        ListEntry::new(Label::new("Dockerfile"))
 671            .left_icon(Icon::FileGeneric.into())
 672            .indent_level(1),
 673        ListEntry::new(Label::new("Procfile"))
 674            .left_icon(Icon::FileGeneric.into())
 675            .indent_level(1),
 676        ListEntry::new(Label::new("README.md"))
 677            .left_icon(Icon::FileDoc.into())
 678            .indent_level(1),
 679    ]
 680    .into_iter()
 681    .map(From::from)
 682    .collect()
 683}
 684
 685pub fn static_project_panel_single_items<V: 'static>() -> Vec<ListItem<V>> {
 686    vec![
 687        ListEntry::new(Label::new("todo.md"))
 688            .left_icon(Icon::FileDoc.into())
 689            .indent_level(0),
 690        ListEntry::new(Label::new("README.md"))
 691            .left_icon(Icon::FileDoc.into())
 692            .indent_level(0),
 693        ListEntry::new(Label::new("config.json"))
 694            .left_icon(Icon::FileGeneric.into())
 695            .indent_level(0),
 696    ]
 697    .into_iter()
 698    .map(From::from)
 699    .collect()
 700}
 701
 702pub fn static_collab_panel_current_call<V: 'static>() -> Vec<ListItem<V>> {
 703    vec![
 704        ListEntry::new(Label::new("as-cii")).left_avatar("http://github.com/as-cii.png?s=50"),
 705        ListEntry::new(Label::new("nathansobo"))
 706            .left_avatar("http://github.com/nathansobo.png?s=50"),
 707        ListEntry::new(Label::new("maxbrunsfeld"))
 708            .left_avatar("http://github.com/maxbrunsfeld.png?s=50"),
 709    ]
 710    .into_iter()
 711    .map(From::from)
 712    .collect()
 713}
 714
 715pub fn static_collab_panel_channels<V: 'static>() -> Vec<ListItem<V>> {
 716    vec![
 717        ListEntry::new(Label::new("zed"))
 718            .left_icon(Icon::Hash.into())
 719            .size(ListEntrySize::Medium)
 720            .indent_level(0),
 721        ListEntry::new(Label::new("community"))
 722            .left_icon(Icon::Hash.into())
 723            .size(ListEntrySize::Medium)
 724            .indent_level(1),
 725        ListEntry::new(Label::new("dashboards"))
 726            .left_icon(Icon::Hash.into())
 727            .size(ListEntrySize::Medium)
 728            .indent_level(2),
 729        ListEntry::new(Label::new("feedback"))
 730            .left_icon(Icon::Hash.into())
 731            .size(ListEntrySize::Medium)
 732            .indent_level(2),
 733        ListEntry::new(Label::new("teams-in-channels-alpha"))
 734            .left_icon(Icon::Hash.into())
 735            .size(ListEntrySize::Medium)
 736            .indent_level(2),
 737        ListEntry::new(Label::new("current-projects"))
 738            .left_icon(Icon::Hash.into())
 739            .size(ListEntrySize::Medium)
 740            .indent_level(1),
 741        ListEntry::new(Label::new("codegen"))
 742            .left_icon(Icon::Hash.into())
 743            .size(ListEntrySize::Medium)
 744            .indent_level(2),
 745        ListEntry::new(Label::new("gpui2"))
 746            .left_icon(Icon::Hash.into())
 747            .size(ListEntrySize::Medium)
 748            .indent_level(2),
 749        ListEntry::new(Label::new("livestreaming"))
 750            .left_icon(Icon::Hash.into())
 751            .size(ListEntrySize::Medium)
 752            .indent_level(2),
 753        ListEntry::new(Label::new("open-source"))
 754            .left_icon(Icon::Hash.into())
 755            .size(ListEntrySize::Medium)
 756            .indent_level(2),
 757        ListEntry::new(Label::new("replace"))
 758            .left_icon(Icon::Hash.into())
 759            .size(ListEntrySize::Medium)
 760            .indent_level(2),
 761        ListEntry::new(Label::new("semantic-index"))
 762            .left_icon(Icon::Hash.into())
 763            .size(ListEntrySize::Medium)
 764            .indent_level(2),
 765        ListEntry::new(Label::new("vim"))
 766            .left_icon(Icon::Hash.into())
 767            .size(ListEntrySize::Medium)
 768            .indent_level(2),
 769        ListEntry::new(Label::new("web-tech"))
 770            .left_icon(Icon::Hash.into())
 771            .size(ListEntrySize::Medium)
 772            .indent_level(2),
 773    ]
 774    .into_iter()
 775    .map(From::from)
 776    .collect()
 777}
 778
 779pub fn example_editor_actions() -> Vec<PaletteItem> {
 780    vec![
 781        PaletteItem::new("New File").keybinding(Keybinding::new(
 782            "N".to_string(),
 783            ModifierKeys::new().command(true),
 784        )),
 785        PaletteItem::new("Open File").keybinding(Keybinding::new(
 786            "O".to_string(),
 787            ModifierKeys::new().command(true),
 788        )),
 789        PaletteItem::new("Save File").keybinding(Keybinding::new(
 790            "S".to_string(),
 791            ModifierKeys::new().command(true),
 792        )),
 793        PaletteItem::new("Cut").keybinding(Keybinding::new(
 794            "X".to_string(),
 795            ModifierKeys::new().command(true),
 796        )),
 797        PaletteItem::new("Copy").keybinding(Keybinding::new(
 798            "C".to_string(),
 799            ModifierKeys::new().command(true),
 800        )),
 801        PaletteItem::new("Paste").keybinding(Keybinding::new(
 802            "V".to_string(),
 803            ModifierKeys::new().command(true),
 804        )),
 805        PaletteItem::new("Undo").keybinding(Keybinding::new(
 806            "Z".to_string(),
 807            ModifierKeys::new().command(true),
 808        )),
 809        PaletteItem::new("Redo").keybinding(Keybinding::new(
 810            "Z".to_string(),
 811            ModifierKeys::new().command(true).shift(true),
 812        )),
 813        PaletteItem::new("Find").keybinding(Keybinding::new(
 814            "F".to_string(),
 815            ModifierKeys::new().command(true),
 816        )),
 817        PaletteItem::new("Replace").keybinding(Keybinding::new(
 818            "R".to_string(),
 819            ModifierKeys::new().command(true),
 820        )),
 821        PaletteItem::new("Jump to Line"),
 822        PaletteItem::new("Select All"),
 823        PaletteItem::new("Deselect All"),
 824        PaletteItem::new("Switch Document"),
 825        PaletteItem::new("Insert Line Below"),
 826        PaletteItem::new("Insert Line Above"),
 827        PaletteItem::new("Move Line Up"),
 828        PaletteItem::new("Move Line Down"),
 829        PaletteItem::new("Toggle Comment"),
 830        PaletteItem::new("Delete Line"),
 831    ]
 832}
 833
 834pub fn empty_editor_example(cx: &mut ViewContext<EditorPane>) -> EditorPane {
 835    EditorPane::new(
 836        cx,
 837        static_tabs_example(),
 838        PathBuf::from_str("crates/ui/src/static_data.rs").unwrap(),
 839        vec![],
 840        empty_buffer_example(),
 841    )
 842}
 843
 844pub fn empty_buffer_example() -> Buffer {
 845    Buffer::new("empty-buffer").set_rows(Some(BufferRows::default()))
 846}
 847
 848pub fn hello_world_rust_editor_example(cx: &mut ViewContext<EditorPane>) -> EditorPane {
 849    EditorPane::new(
 850        cx,
 851        static_tabs_example(),
 852        PathBuf::from_str("crates/ui/src/static_data.rs").unwrap(),
 853        vec![Symbol(vec![
 854            HighlightedText {
 855                text: "fn ".to_string(),
 856                color: cx.theme().syntax_color("keyword"),
 857            },
 858            HighlightedText {
 859                text: "main".to_string(),
 860                color: cx.theme().syntax_color("function"),
 861            },
 862        ])],
 863        hello_world_rust_buffer_example(cx),
 864    )
 865}
 866
 867pub fn hello_world_rust_buffer_example(cx: &AppContext) -> Buffer {
 868    Buffer::new("hello-world-rust-buffer")
 869        .set_title("hello_world.rs".to_string())
 870        .set_path("src/hello_world.rs".to_string())
 871        .set_language("rust".to_string())
 872        .set_rows(Some(BufferRows {
 873            show_line_numbers: true,
 874            rows: hello_world_rust_buffer_rows(cx),
 875        }))
 876}
 877
 878pub fn hello_world_rust_buffer_rows(cx: &AppContext) -> Vec<BufferRow> {
 879    let show_line_number = true;
 880
 881    vec![
 882        BufferRow {
 883            line_number: 1,
 884            code_action: false,
 885            current: true,
 886            line: Some(HighlightedLine {
 887                highlighted_texts: vec![
 888                    HighlightedText {
 889                        text: "fn ".to_string(),
 890                        color: cx.theme().syntax_color("keyword"),
 891                    },
 892                    HighlightedText {
 893                        text: "main".to_string(),
 894                        color: cx.theme().syntax_color("function"),
 895                    },
 896                    HighlightedText {
 897                        text: "() {".to_string(),
 898                        color: cx.theme().colors().text,
 899                    },
 900                ],
 901            }),
 902            cursors: None,
 903            status: GitStatus::None,
 904            show_line_number,
 905        },
 906        BufferRow {
 907            line_number: 2,
 908            code_action: false,
 909            current: false,
 910            line: Some(HighlightedLine {
 911                highlighted_texts: vec![HighlightedText {
 912                    text: "    // Statements here are executed when the compiled binary is called."
 913                        .to_string(),
 914                    color: cx.theme().syntax_color("comment"),
 915                }],
 916            }),
 917            cursors: None,
 918            status: GitStatus::None,
 919            show_line_number,
 920        },
 921        BufferRow {
 922            line_number: 3,
 923            code_action: false,
 924            current: false,
 925            line: None,
 926            cursors: None,
 927            status: GitStatus::None,
 928            show_line_number,
 929        },
 930        BufferRow {
 931            line_number: 4,
 932            code_action: false,
 933            current: false,
 934            line: Some(HighlightedLine {
 935                highlighted_texts: vec![HighlightedText {
 936                    text: "    // Print text to the console.".to_string(),
 937                    color: cx.theme().syntax_color("comment"),
 938                }],
 939            }),
 940            cursors: None,
 941            status: GitStatus::None,
 942            show_line_number,
 943        },
 944        BufferRow {
 945            line_number: 5,
 946            code_action: false,
 947            current: false,
 948            line: Some(HighlightedLine {
 949                highlighted_texts: vec![
 950                    HighlightedText {
 951                        text: "    println!(".to_string(),
 952                        color: cx.theme().colors().text,
 953                    },
 954                    HighlightedText {
 955                        text: "\"Hello, world!\"".to_string(),
 956                        color: cx.theme().syntax_color("string"),
 957                    },
 958                    HighlightedText {
 959                        text: ");".to_string(),
 960                        color: cx.theme().colors().text,
 961                    },
 962                ],
 963            }),
 964            cursors: None,
 965            status: GitStatus::None,
 966            show_line_number,
 967        },
 968        BufferRow {
 969            line_number: 6,
 970            code_action: false,
 971            current: false,
 972            line: Some(HighlightedLine {
 973                highlighted_texts: vec![HighlightedText {
 974                    text: "}".to_string(),
 975                    color: cx.theme().colors().text,
 976                }],
 977            }),
 978            cursors: None,
 979            status: GitStatus::None,
 980            show_line_number,
 981        },
 982    ]
 983}
 984
 985pub fn hello_world_rust_editor_with_status_example(cx: &mut ViewContext<EditorPane>) -> EditorPane {
 986    EditorPane::new(
 987        cx,
 988        static_tabs_example(),
 989        PathBuf::from_str("crates/ui/src/static_data.rs").unwrap(),
 990        vec![Symbol(vec![
 991            HighlightedText {
 992                text: "fn ".to_string(),
 993                color: cx.theme().syntax_color("keyword"),
 994            },
 995            HighlightedText {
 996                text: "main".to_string(),
 997                color: cx.theme().syntax_color("function"),
 998            },
 999        ])],
1000        hello_world_rust_buffer_with_status_example(cx),
1001    )
1002}
1003
1004pub fn hello_world_rust_buffer_with_status_example(cx: &AppContext) -> Buffer {
1005    Buffer::new("hello-world-rust-buffer-with-status")
1006        .set_title("hello_world.rs".to_string())
1007        .set_path("src/hello_world.rs".to_string())
1008        .set_language("rust".to_string())
1009        .set_rows(Some(BufferRows {
1010            show_line_numbers: true,
1011            rows: hello_world_rust_with_status_buffer_rows(cx),
1012        }))
1013}
1014
1015pub fn hello_world_rust_with_status_buffer_rows(cx: &AppContext) -> Vec<BufferRow> {
1016    let show_line_number = true;
1017
1018    vec![
1019        BufferRow {
1020            line_number: 1,
1021            code_action: false,
1022            current: true,
1023            line: Some(HighlightedLine {
1024                highlighted_texts: vec![
1025                    HighlightedText {
1026                        text: "fn ".to_string(),
1027                        color: cx.theme().syntax_color("keyword"),
1028                    },
1029                    HighlightedText {
1030                        text: "main".to_string(),
1031                        color: cx.theme().syntax_color("function"),
1032                    },
1033                    HighlightedText {
1034                        text: "() {".to_string(),
1035                        color: cx.theme().colors().text,
1036                    },
1037                ],
1038            }),
1039            cursors: None,
1040            status: GitStatus::None,
1041            show_line_number,
1042        },
1043        BufferRow {
1044            line_number: 2,
1045            code_action: false,
1046            current: false,
1047            line: Some(HighlightedLine {
1048                highlighted_texts: vec![HighlightedText {
1049                    text: "// Statements here are executed when the compiled binary is called."
1050                        .to_string(),
1051                    color: cx.theme().syntax_color("comment"),
1052                }],
1053            }),
1054            cursors: None,
1055            status: GitStatus::Modified,
1056            show_line_number,
1057        },
1058        BufferRow {
1059            line_number: 3,
1060            code_action: false,
1061            current: false,
1062            line: None,
1063            cursors: None,
1064            status: GitStatus::None,
1065            show_line_number,
1066        },
1067        BufferRow {
1068            line_number: 4,
1069            code_action: false,
1070            current: false,
1071            line: Some(HighlightedLine {
1072                highlighted_texts: vec![HighlightedText {
1073                    text: "    // Print text to the console.".to_string(),
1074                    color: cx.theme().syntax_color("comment"),
1075                }],
1076            }),
1077            cursors: None,
1078            status: GitStatus::None,
1079            show_line_number,
1080        },
1081        BufferRow {
1082            line_number: 5,
1083            code_action: false,
1084            current: false,
1085            line: Some(HighlightedLine {
1086                highlighted_texts: vec![
1087                    HighlightedText {
1088                        text: "    println!(".to_string(),
1089                        color: cx.theme().colors().text,
1090                    },
1091                    HighlightedText {
1092                        text: "\"Hello, world!\"".to_string(),
1093                        color: cx.theme().syntax_color("string"),
1094                    },
1095                    HighlightedText {
1096                        text: ");".to_string(),
1097                        color: cx.theme().colors().text,
1098                    },
1099                ],
1100            }),
1101            cursors: None,
1102            status: GitStatus::None,
1103            show_line_number,
1104        },
1105        BufferRow {
1106            line_number: 6,
1107            code_action: false,
1108            current: false,
1109            line: Some(HighlightedLine {
1110                highlighted_texts: vec![HighlightedText {
1111                    text: "}".to_string(),
1112                    color: cx.theme().colors().text,
1113                }],
1114            }),
1115            cursors: None,
1116            status: GitStatus::None,
1117            show_line_number,
1118        },
1119        BufferRow {
1120            line_number: 7,
1121            code_action: false,
1122            current: false,
1123            line: Some(HighlightedLine {
1124                highlighted_texts: vec![HighlightedText {
1125                    text: "".to_string(),
1126                    color: cx.theme().colors().text,
1127                }],
1128            }),
1129            cursors: None,
1130            status: GitStatus::Created,
1131            show_line_number,
1132        },
1133        BufferRow {
1134            line_number: 8,
1135            code_action: false,
1136            current: false,
1137            line: Some(HighlightedLine {
1138                highlighted_texts: vec![HighlightedText {
1139                    text: "// Marshall and Nate were here".to_string(),
1140                    color: cx.theme().syntax_color("comment"),
1141                }],
1142            }),
1143            cursors: None,
1144            status: GitStatus::Created,
1145            show_line_number,
1146        },
1147    ]
1148}
1149
1150pub fn terminal_buffer(cx: &AppContext) -> Buffer {
1151    Buffer::new("terminal")
1152        .set_title("zed — fish".to_string())
1153        .set_rows(Some(BufferRows {
1154            show_line_numbers: false,
1155            rows: terminal_buffer_rows(cx),
1156        }))
1157}
1158
1159pub fn terminal_buffer_rows(cx: &AppContext) -> Vec<BufferRow> {
1160    let show_line_number = false;
1161
1162    vec![
1163        BufferRow {
1164            line_number: 1,
1165            code_action: false,
1166            current: false,
1167            line: Some(HighlightedLine {
1168                highlighted_texts: vec![
1169                    HighlightedText {
1170                        text: "maxdeviant ".to_string(),
1171                        color: cx.theme().syntax_color("keyword"),
1172                    },
1173                    HighlightedText {
1174                        text: "in ".to_string(),
1175                        color: cx.theme().colors().text,
1176                    },
1177                    HighlightedText {
1178                        text: "profaned-capital ".to_string(),
1179                        color: cx.theme().syntax_color("function"),
1180                    },
1181                    HighlightedText {
1182                        text: "in ".to_string(),
1183                        color: cx.theme().colors().text,
1184                    },
1185                    HighlightedText {
1186                        text: "~/p/zed ".to_string(),
1187                        color: cx.theme().syntax_color("function"),
1188                    },
1189                    HighlightedText {
1190                        text: "on ".to_string(),
1191                        color: cx.theme().colors().text,
1192                    },
1193                    HighlightedText {
1194                        text: " gpui2-ui ".to_string(),
1195                        color: cx.theme().syntax_color("keyword"),
1196                    },
1197                ],
1198            }),
1199            cursors: None,
1200            status: GitStatus::None,
1201            show_line_number,
1202        },
1203        BufferRow {
1204            line_number: 2,
1205            code_action: false,
1206            current: false,
1207            line: Some(HighlightedLine {
1208                highlighted_texts: vec![HighlightedText {
1209                    text: "λ ".to_string(),
1210                    color: cx.theme().syntax_color("string"),
1211                }],
1212            }),
1213            cursors: None,
1214            status: GitStatus::None,
1215            show_line_number,
1216        },
1217    ]
1218}