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