static_data.rs

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