Merge branch 'main' into callback-handles

This commit is contained in:
Conrad Irwin 2023-11-20 16:28:35 -07:00
commit 3e2dba36b4
15 changed files with 386 additions and 245 deletions

6
Cargo.lock generated
View file

@ -1387,7 +1387,7 @@ dependencies = [
"smol",
"sum_tree",
"tempfile",
"text",
"text2",
"thiserror",
"time",
"tiny_http",
@ -1858,7 +1858,7 @@ dependencies = [
"editor2",
"feature_flags2",
"futures 0.3.28",
"fuzzy",
"fuzzy2",
"gpui2",
"language2",
"lazy_static",
@ -6739,7 +6739,6 @@ dependencies = [
"anyhow",
"client2",
"collections",
"context_menu",
"db2",
"editor2",
"futures 0.3.28",
@ -11571,7 +11570,6 @@ dependencies = [
"fs2",
"fsevent",
"futures 0.3.28",
"fuzzy",
"go_to_line2",
"gpui2",
"ignore",

View file

@ -18,7 +18,7 @@ db = { package = "db2", path = "../db2" }
gpui = { package = "gpui2", path = "../gpui2" }
util = { path = "../util" }
rpc = { package = "rpc2", path = "../rpc2" }
text = { path = "../text" }
text = { package = "text2", path = "../text2" }
language = { package = "language2", path = "../language2" }
settings = { package = "settings2", path = "../settings2" }
feature_flags = { package = "feature_flags2", path = "../feature_flags2" }

View file

@ -33,7 +33,7 @@ collections = { path = "../collections" }
# drag_and_drop = { path = "../drag_and_drop" }
editor = { package="editor2", path = "../editor2" }
#feedback = { path = "../feedback" }
fuzzy = { path = "../fuzzy" }
fuzzy = { package = "fuzzy2", path = "../fuzzy2" }
gpui = { package = "gpui2", path = "../gpui2" }
language = { package = "language2", path = "../language2" }
menu = { package = "menu2", path = "../menu2" }

View file

@ -61,12 +61,14 @@ fn build_bridge(swift_target: &SwiftTarget) {
let swift_package_root = swift_package_root();
let swift_target_folder = swift_target_folder();
let swift_cache_folder = swift_cache_folder();
if !Command::new("swift")
.arg("build")
.arg("--disable-automatic-resolution")
.args(["--configuration", &env::var("PROFILE").unwrap()])
.args(["--triple", &swift_target.target.triple])
.args(["--build-path".into(), swift_target_folder])
.args(["--cache-path".into(), swift_cache_folder])
.current_dir(&swift_package_root)
.status()
.unwrap()
@ -133,9 +135,17 @@ fn swift_package_root() -> PathBuf {
}
fn swift_target_folder() -> PathBuf {
let target = env::var("TARGET").unwrap();
env::current_dir()
.unwrap()
.join(format!("../../target/{SWIFT_PACKAGE_NAME}"))
.join(format!("../../target/{target}/{SWIFT_PACKAGE_NAME}_target"))
}
fn swift_cache_folder() -> PathBuf {
let target = env::var("TARGET").unwrap();
env::current_dir()
.unwrap()
.join(format!("../../target/{target}/{SWIFT_PACKAGE_NAME}_cache"))
}
fn copy_dir(source: &Path, destination: &Path) {

View file

@ -9,7 +9,6 @@ path = "src/project_panel.rs"
doctest = false
[dependencies]
context_menu = { path = "../context_menu" }
collections = { path = "../collections" }
db = { path = "../db2", package = "db2" }
editor = { path = "../editor2", package = "editor2" }

View file

@ -31,7 +31,7 @@ use workspace::{
notifications::NotifyResultExt,
register_deserializable_item,
searchable::{SearchEvent, SearchOptions, SearchableItem},
ui::{ContextMenu, Icon, IconElement, Label, ListEntry},
ui::{ContextMenu, Icon, IconElement, Label, ListItem},
CloseActiveItem, NewCenterTerminal, Pane, ToolbarItemLocation, Workspace, WorkspaceId,
};
@ -300,9 +300,9 @@ impl TerminalView {
cx: &mut ViewContext<Self>,
) {
self.context_menu = Some(ContextMenu::build(cx, |menu, _| {
menu.action(ListEntry::new(Label::new("Clear")), Box::new(Clear))
menu.action(ListItem::new("clear", Label::new("Clear")), Box::new(Clear))
.action(
ListEntry::new(Label::new("Close")),
ListItem::new("close", Label::new("Close")),
Box::new(CloseActiveItem { save_intent: None }),
)
}));

View file

@ -1,8 +1,8 @@
use std::cell::RefCell;
use std::rc::Rc;
use crate::{prelude::*, v_stack, List, ListItem};
use crate::{ListEntry, ListSeparator, ListSubHeader};
use crate::{prelude::*, v_stack, List};
use crate::{ListItem, ListSeparator, ListSubHeader};
use gpui::{
overlay, px, Action, AnchorCorner, AnyElement, AppContext, Bounds, ClickEvent, DispatchPhase,
Div, EventEmitter, FocusHandle, FocusableView, LayoutId, ManagedView, Manager, MouseButton,
@ -12,7 +12,7 @@ use gpui::{
pub enum ContextMenuItem {
Separator(ListSeparator),
Header(ListSubHeader),
Entry(ListEntry, Rc<dyn Fn(&ClickEvent, &mut WindowContext)>),
Entry(ListItem, Rc<dyn Fn(&ClickEvent, &mut WindowContext)>),
}
pub struct ContextMenu {
@ -58,7 +58,7 @@ impl ContextMenu {
pub fn entry(
mut self,
view: ListEntry,
view: ListItem,
on_click: impl Fn(&ClickEvent, &mut WindowContext) + 'static,
) -> Self {
self.items
@ -66,7 +66,7 @@ impl ContextMenu {
self
}
pub fn action(self, view: ListEntry, action: Box<dyn Action>) -> Self {
pub fn action(self, view: ListItem, action: Box<dyn Action>) -> Self {
// todo: add the keybindings to the list entry
self.entry(view, move |_, cx| cx.dispatch_action(action.boxed_clone()))
}
@ -102,26 +102,26 @@ impl Render for ContextMenu {
// .bg(cx.theme().colors().elevated_surface_background)
// .border()
// .border_color(cx.theme().colors().border)
.child(List::new(
self.items
.iter()
.map(|item| match item {
.child(
List::new().children(self.items.iter().map(|item| match item {
ContextMenuItem::Separator(separator) => {
ListItem::Separator(separator.clone())
separator.clone().render_into_any()
}
ContextMenuItem::Header(header) => ListItem::Header(header.clone()),
ContextMenuItem::Header(header) => header.clone().render_into_any(),
ContextMenuItem::Entry(entry, callback) => {
let callback = callback.clone();
let dismiss = cx.listener(|_, _, cx| cx.emit(Manager::Dismiss));
ListItem::Entry(entry.clone().on_click(move |event, cx| {
entry
.clone()
.on_click(move |event, cx| {
callback(event, cx);
dismiss(event, cx)
}))
}
})
.collect(),
)),
.render_into_any()
}
})),
),
)
}
}
@ -316,13 +316,17 @@ mod stories {
ContextMenu::build(cx, |menu, _| {
menu.header(header)
.separator()
.entry(ListEntry::new(Label::new("Print current time")), |v, cx| {
.entry(
ListItem::new("Print current time", Label::new("Print current time")),
|v, cx| {
println!("dispatching PrintCurrentTime action");
cx.dispatch_action(PrintCurrentDate.boxed_clone())
})
.entry(ListEntry::new(Label::new("Print best food")), |v, cx| {
cx.dispatch_action(PrintBestFood.boxed_clone())
})
},
)
.entry(
ListItem::new("Print best food", Label::new("Print best food")),
|v, cx| cx.dispatch_action(PrintBestFood.boxed_clone()),
)
})
}

View file

@ -1,4 +1,5 @@
use gpui::{div, ClickEvent, Div, RenderOnce, Stateful, StatefulInteractiveElement};
use gpui::{div, AnyElement, ClickEvent, Div, RenderOnce, Stateful, StatefulInteractiveElement};
use smallvec::SmallVec;
use std::rc::Rc;
use crate::settings::user_settings;
@ -117,7 +118,7 @@ impl ListHeader {
}
// before_ship!("delete")
// fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Element<V> {
// fn render<V: 'static>(self, cx: &mut WindowContext) -> impl Element<V> {
// let disclosure_control = disclosure_control(self.toggle);
// let meta = match self.meta {
@ -177,7 +178,7 @@ impl ListHeader {
// }
}
#[derive(Clone)]
#[derive(RenderOnce, Clone)]
pub struct ListSubHeader {
label: SharedString,
left_icon: Option<Icon>,
@ -197,8 +198,12 @@ impl ListSubHeader {
self.left_icon = left_icon;
self
}
}
fn render(self, cx: &mut WindowContext) -> impl Element {
impl Component for ListSubHeader {
type Rendered = Div;
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
h_stack().flex_1().w_full().relative().py_1().child(
div()
.h_6()
@ -232,55 +237,9 @@ pub enum ListEntrySize {
Medium,
}
#[derive(Clone)]
pub enum ListItem {
Entry(ListEntry),
Separator(ListSeparator),
Header(ListSubHeader),
}
impl From<ListEntry> for ListItem {
fn from(entry: ListEntry) -> Self {
Self::Entry(entry)
}
}
impl From<ListSeparator> for ListItem {
fn from(entry: ListSeparator) -> Self {
Self::Separator(entry)
}
}
impl From<ListSubHeader> for ListItem {
fn from(entry: ListSubHeader) -> Self {
Self::Header(entry)
}
}
impl ListItem {
pub fn new(label: Label) -> Self {
Self::Entry(ListEntry::new(label))
}
pub fn as_entry(&mut self) -> Option<&mut ListEntry> {
if let Self::Entry(entry) = self {
Some(entry)
} else {
None
}
}
fn render(self, ix: usize, cx: &mut WindowContext) -> Div {
match self {
ListItem::Entry(entry) => div().child(entry.render(ix, cx)),
ListItem::Separator(separator) => div().child(separator.render(cx)),
ListItem::Header(header) => div().child(header.render(cx)),
}
}
}
// #[derive(RenderOnce)]
pub struct ListEntry {
#[derive(RenderOnce)]
pub struct ListItem {
id: ElementId,
disabled: bool,
// TODO: Reintroduce this
// disclosure_control_style: DisclosureControlVisibility,
@ -294,9 +253,10 @@ pub struct ListEntry {
on_click: Option<Rc<dyn Fn(&ClickEvent, &mut WindowContext) + 'static>>,
}
impl Clone for ListEntry {
impl Clone for ListItem {
fn clone(&self) -> Self {
Self {
id: self.id.clone(),
disabled: self.disabled,
indent_level: self.indent_level,
label: self.label.clone(),
@ -310,9 +270,10 @@ impl Clone for ListEntry {
}
}
impl ListEntry {
pub fn new(label: Label) -> Self {
impl ListItem {
pub fn new(id: impl Into<ElementId>, label: Label) -> Self {
Self {
id: id.into(),
disabled: false,
indent_level: 0,
label,
@ -364,8 +325,12 @@ impl ListEntry {
self.size = size;
self
}
}
fn render(self, ix: usize, cx: &mut WindowContext) -> Stateful<Div> {
impl Component for ListItem {
type Rendered = Stateful<Div>;
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
let settings = user_settings(cx);
let left_content = match self.left_slot.clone() {
@ -386,17 +351,18 @@ impl ListEntry {
ListEntrySize::Medium => div().h_7(),
};
div()
.id(ix)
.id(self.id)
.relative()
.hover(|mut style| {
style.background = Some(cx.theme().colors().editor_background.into());
style
})
.map(|div| {
if let Some(on_click) = self.on_click.clone() {
div.on_click(move |e, cx| on_click(e, cx))
} else {
div
.on_click({
let on_click = self.on_click.clone();
move |event, cx| {
if let Some(on_click) = &on_click {
(on_click)(event, cx)
}
}
})
.bg(cx.theme().colors().surface_background)
@ -452,25 +418,20 @@ impl Component for ListSeparator {
#[derive(RenderOnce)]
pub struct List {
items: Vec<ListItem>,
/// Message to display when the list is empty
/// Defaults to "No items"
empty_message: SharedString,
header: Option<ListHeader>,
toggle: Toggle,
children: SmallVec<[AnyElement; 2]>,
}
impl Component for List {
type Rendered = Div;
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
let list_content = match (self.items.is_empty(), self.toggle) {
(false, _) => div().children(
self.items
.into_iter()
.enumerate()
.map(|(ix, item)| item.render(ix, cx)),
),
let list_content = match (self.children.is_empty(), self.toggle) {
(false, _) => div().children(self.children),
(true, Toggle::Toggled(false)) => div(),
(true, _) => {
div().child(Label::new(self.empty_message.clone()).color(TextColor::Muted))
@ -486,12 +447,12 @@ impl Component for List {
}
impl List {
pub fn new(items: Vec<ListItem>) -> Self {
pub fn new() -> Self {
Self {
items,
empty_message: "No items".into(),
header: None,
toggle: Toggle::NotToggleable,
children: SmallVec::new(),
}
}
@ -509,25 +470,10 @@ impl List {
self.toggle = toggle;
self
}
}
fn render(self, cx: &mut WindowContext) -> impl Element {
let list_content = match (self.items.is_empty(), self.toggle) {
(false, _) => div().children(
self.items
.into_iter()
.enumerate()
.map(|(ix, item)| item.render(ix, cx)),
),
(true, Toggle::Toggled(false)) => div(),
(true, _) => {
div().child(Label::new(self.empty_message.clone()).color(TextColor::Muted))
}
};
v_stack()
.w_full()
.py_1()
.children(self.header.map(|header| header))
.child(list_content)
impl ParentElement for List {
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]> {
&mut self.children
}
}

View file

@ -28,41 +28,45 @@ impl Component for CollabPanel {
.border_color(cx.theme().colors().border)
.border_b()
.child(
List::new(static_collab_panel_current_call())
List::new()
.header(
ListHeader::new("CRDB")
.left_icon(Icon::Hash.into())
.toggle(Toggle::Toggled(true)),
)
.toggle(Toggle::Toggled(true)),
.toggle(Toggle::Toggled(true))
.children(static_collab_panel_current_call()),
),
)
.child(
v_stack().id("channels").py_1().child(
List::new(static_collab_panel_channels())
List::new()
.header(ListHeader::new("CHANNELS").toggle(Toggle::Toggled(true)))
.empty_message("No channels yet. Add a channel to get started.")
.toggle(Toggle::Toggled(true)),
.toggle(Toggle::Toggled(true))
.children(static_collab_panel_channels()),
),
)
.child(
v_stack().id("contacts-online").py_1().child(
List::new(static_collab_panel_current_call())
List::new()
.header(
ListHeader::new("CONTACTS ONLINE")
.toggle(Toggle::Toggled(true)),
)
.toggle(Toggle::Toggled(true)),
.toggle(Toggle::Toggled(true))
.children(static_collab_panel_current_call()),
),
)
.child(
v_stack().id("contacts-offline").py_1().child(
List::new(static_collab_panel_current_call())
List::new()
.header(
ListHeader::new("CONTACTS OFFLINE")
.toggle(Toggle::Toggled(false)),
)
.toggle(Toggle::Toggled(false)),
.toggle(Toggle::Toggled(false))
.children(static_collab_panel_current_call()),
),
),
)

View file

@ -29,14 +29,16 @@ impl Component for ProjectPanel {
.flex_col()
.overflow_y_scroll()
.child(
List::new(static_project_panel_single_items())
List::new()
.header(ListHeader::new("FILES"))
.empty_message("No files in directory"),
.empty_message("No files in directory")
.children(static_project_panel_single_items()),
)
.child(
List::new(static_project_panel_project_items())
List::new()
.header(ListHeader::new("PROJECT"))
.empty_message("No folders in directory"),
.empty_message("No folders in directory")
.children(static_project_panel_project_items()),
),
)
.child(
@ -67,14 +69,16 @@ impl ProjectPanel {
.flex_col()
.overflow_y_scroll()
.child(
List::new(static_project_panel_single_items())
List::new()
.header(ListHeader::new("FILES"))
.empty_message("No files in directory"),
.empty_message("No files in directory")
.children(static_project_panel_single_items()),
)
.child(
List::new(static_project_panel_project_items())
List::new()
.header(ListHeader::new("PROJECT"))
.empty_message("No folders in directory"),
.empty_message("No folders in directory")
.children(static_project_panel_project_items()),
),
)
.child(

View file

@ -7,14 +7,13 @@ use gpui::{AppContext, ViewContext};
use rand::Rng;
use theme2::ActiveTheme;
use crate::{binding, HighlightedText};
use crate::{
Buffer, BufferRow, BufferRows, Button, EditorPane, FileSystemStatus, GitStatus,
HighlightedLine, Icon, KeyBinding, Label, ListEntry, ListEntrySize, Livestream, MicStatus,
Notification, PaletteItem, Player, PlayerCallStatus, PlayerWithCallStatus, PublicPlayer,
ScreenShareStatus, Symbol, Tab, TextColor, Toggle, VideoStatus,
binding, Buffer, BufferRow, BufferRows, Button, EditorPane, FileSystemStatus, GitStatus,
HighlightedLine, HighlightedText, Icon, KeyBinding, Label, ListEntrySize, ListItem, Livestream,
MicStatus, Notification, NotificationAction, PaletteItem, Player, PlayerCallStatus,
PlayerWithCallStatus, PublicPlayer, ScreenShareStatus, Symbol, Tab, TextColor, Toggle,
VideoStatus,
};
use crate::{ListItem, NotificationAction};
pub fn static_tabs_example() -> Vec<Tab> {
vec![
@ -480,223 +479,236 @@ pub fn static_new_notification_items_2() -> Vec<Notification> {
pub fn static_project_panel_project_items() -> Vec<ListItem> {
vec![
ListEntry::new(Label::new("zed"))
ListItem::new("zed", Label::new("zed"))
.left_icon(Icon::FolderOpen.into())
.indent_level(0)
.toggle(Toggle::Toggled(true)),
ListEntry::new(Label::new(".cargo"))
ListItem::new(".cargo", Label::new(".cargo"))
.left_icon(Icon::Folder.into())
.indent_level(1),
ListEntry::new(Label::new(".config"))
ListItem::new(".config", Label::new(".config"))
.left_icon(Icon::Folder.into())
.indent_level(1),
ListEntry::new(Label::new(".git").color(TextColor::Hidden))
ListItem::new(".git", Label::new(".git").color(TextColor::Hidden))
.left_icon(Icon::Folder.into())
.indent_level(1),
ListEntry::new(Label::new(".cargo"))
ListItem::new(".cargo", Label::new(".cargo"))
.left_icon(Icon::Folder.into())
.indent_level(1),
ListEntry::new(Label::new(".idea").color(TextColor::Hidden))
ListItem::new(".idea", Label::new(".idea").color(TextColor::Hidden))
.left_icon(Icon::Folder.into())
.indent_level(1),
ListEntry::new(Label::new("assets"))
ListItem::new("assets", Label::new("assets"))
.left_icon(Icon::Folder.into())
.indent_level(1)
.toggle(Toggle::Toggled(true)),
ListEntry::new(Label::new("cargo-target").color(TextColor::Hidden))
ListItem::new(
"cargo-target",
Label::new("cargo-target").color(TextColor::Hidden),
)
.left_icon(Icon::Folder.into())
.indent_level(1),
ListEntry::new(Label::new("crates"))
ListItem::new("crates", Label::new("crates"))
.left_icon(Icon::FolderOpen.into())
.indent_level(1)
.toggle(Toggle::Toggled(true)),
ListEntry::new(Label::new("activity_indicator"))
ListItem::new("activity_indicator", Label::new("activity_indicator"))
.left_icon(Icon::Folder.into())
.indent_level(2),
ListEntry::new(Label::new("ai"))
ListItem::new("ai", Label::new("ai"))
.left_icon(Icon::Folder.into())
.indent_level(2),
ListEntry::new(Label::new("audio"))
ListItem::new("audio", Label::new("audio"))
.left_icon(Icon::Folder.into())
.indent_level(2),
ListEntry::new(Label::new("auto_update"))
ListItem::new("auto_update", Label::new("auto_update"))
.left_icon(Icon::Folder.into())
.indent_level(2),
ListEntry::new(Label::new("breadcrumbs"))
ListItem::new("breadcrumbs", Label::new("breadcrumbs"))
.left_icon(Icon::Folder.into())
.indent_level(2),
ListEntry::new(Label::new("call"))
ListItem::new("call", Label::new("call"))
.left_icon(Icon::Folder.into())
.indent_level(2),
ListEntry::new(Label::new("sqlez").color(TextColor::Modified))
ListItem::new("sqlez", Label::new("sqlez").color(TextColor::Modified))
.left_icon(Icon::Folder.into())
.indent_level(2)
.toggle(Toggle::Toggled(false)),
ListEntry::new(Label::new("gpui2"))
ListItem::new("gpui2", Label::new("gpui2"))
.left_icon(Icon::FolderOpen.into())
.indent_level(2)
.toggle(Toggle::Toggled(true)),
ListEntry::new(Label::new("src"))
ListItem::new("src", Label::new("src"))
.left_icon(Icon::FolderOpen.into())
.indent_level(3)
.toggle(Toggle::Toggled(true)),
ListEntry::new(Label::new("derive_element.rs"))
ListItem::new("derive_element.rs", Label::new("derive_element.rs"))
.left_icon(Icon::FileRust.into())
.indent_level(4),
ListEntry::new(Label::new("storybook").color(TextColor::Modified))
ListItem::new(
"storybook",
Label::new("storybook").color(TextColor::Modified),
)
.left_icon(Icon::FolderOpen.into())
.indent_level(1)
.toggle(Toggle::Toggled(true)),
ListEntry::new(Label::new("docs").color(TextColor::Default))
ListItem::new("docs", Label::new("docs").color(TextColor::Default))
.left_icon(Icon::Folder.into())
.indent_level(2)
.toggle(Toggle::Toggled(true)),
ListEntry::new(Label::new("src").color(TextColor::Modified))
ListItem::new("src", Label::new("src").color(TextColor::Modified))
.left_icon(Icon::FolderOpen.into())
.indent_level(3)
.toggle(Toggle::Toggled(true)),
ListEntry::new(Label::new("ui").color(TextColor::Modified))
ListItem::new("ui", Label::new("ui").color(TextColor::Modified))
.left_icon(Icon::FolderOpen.into())
.indent_level(4)
.toggle(Toggle::Toggled(true)),
ListEntry::new(Label::new("component").color(TextColor::Created))
ListItem::new(
"component",
Label::new("component").color(TextColor::Created),
)
.left_icon(Icon::FolderOpen.into())
.indent_level(5)
.toggle(Toggle::Toggled(true)),
ListEntry::new(Label::new("facepile.rs").color(TextColor::Default))
ListItem::new(
"facepile.rs",
Label::new("facepile.rs").color(TextColor::Default),
)
.left_icon(Icon::FileRust.into())
.indent_level(6),
ListEntry::new(Label::new("follow_group.rs").color(TextColor::Default))
ListItem::new(
"follow_group.rs",
Label::new("follow_group.rs").color(TextColor::Default),
)
.left_icon(Icon::FileRust.into())
.indent_level(6),
ListEntry::new(Label::new("list_item.rs").color(TextColor::Created))
ListItem::new(
"list_item.rs",
Label::new("list_item.rs").color(TextColor::Created),
)
.left_icon(Icon::FileRust.into())
.indent_level(6),
ListEntry::new(Label::new("tab.rs").color(TextColor::Default))
ListItem::new("tab.rs", Label::new("tab.rs").color(TextColor::Default))
.left_icon(Icon::FileRust.into())
.indent_level(6),
ListEntry::new(Label::new("target").color(TextColor::Hidden))
ListItem::new("target", Label::new("target").color(TextColor::Hidden))
.left_icon(Icon::Folder.into())
.indent_level(1),
ListEntry::new(Label::new(".dockerignore"))
ListItem::new(".dockerignore", Label::new(".dockerignore"))
.left_icon(Icon::FileGeneric.into())
.indent_level(1),
ListEntry::new(Label::new(".DS_Store").color(TextColor::Hidden))
ListItem::new(
".DS_Store",
Label::new(".DS_Store").color(TextColor::Hidden),
)
.left_icon(Icon::FileGeneric.into())
.indent_level(1),
ListEntry::new(Label::new("Cargo.lock"))
ListItem::new("Cargo.lock", Label::new("Cargo.lock"))
.left_icon(Icon::FileLock.into())
.indent_level(1),
ListEntry::new(Label::new("Cargo.toml"))
ListItem::new("Cargo.toml", Label::new("Cargo.toml"))
.left_icon(Icon::FileToml.into())
.indent_level(1),
ListEntry::new(Label::new("Dockerfile"))
ListItem::new("Dockerfile", Label::new("Dockerfile"))
.left_icon(Icon::FileGeneric.into())
.indent_level(1),
ListEntry::new(Label::new("Procfile"))
ListItem::new("Procfile", Label::new("Procfile"))
.left_icon(Icon::FileGeneric.into())
.indent_level(1),
ListEntry::new(Label::new("README.md"))
ListItem::new("README.md", Label::new("README.md"))
.left_icon(Icon::FileDoc.into())
.indent_level(1),
]
.into_iter()
.map(From::from)
.collect()
}
pub fn static_project_panel_single_items() -> Vec<ListItem> {
vec![
ListEntry::new(Label::new("todo.md"))
ListItem::new("todo.md", Label::new("todo.md"))
.left_icon(Icon::FileDoc.into())
.indent_level(0),
ListEntry::new(Label::new("README.md"))
ListItem::new("README.md", Label::new("README.md"))
.left_icon(Icon::FileDoc.into())
.indent_level(0),
ListEntry::new(Label::new("config.json"))
ListItem::new("config.json", Label::new("config.json"))
.left_icon(Icon::FileGeneric.into())
.indent_level(0),
]
.into_iter()
.map(From::from)
.collect()
}
pub fn static_collab_panel_current_call() -> Vec<ListItem> {
vec![
ListEntry::new(Label::new("as-cii")).left_avatar("http://github.com/as-cii.png?s=50"),
ListEntry::new(Label::new("nathansobo"))
ListItem::new("as-cii", Label::new("as-cii"))
.left_avatar("http://github.com/as-cii.png?s=50"),
ListItem::new("nathansobo", Label::new("nathansobo"))
.left_avatar("http://github.com/nathansobo.png?s=50"),
ListEntry::new(Label::new("maxbrunsfeld"))
ListItem::new("maxbrunsfeld", Label::new("maxbrunsfeld"))
.left_avatar("http://github.com/maxbrunsfeld.png?s=50"),
]
.into_iter()
.map(From::from)
.collect()
}
pub fn static_collab_panel_channels<V>() -> Vec<ListItem> {
vec![
ListEntry::new(Label::new("zed"))
ListItem::new("zed", Label::new("zed"))
.left_icon(Icon::Hash.into())
.size(ListEntrySize::Medium)
.indent_level(0),
ListEntry::new(Label::new("community"))
ListItem::new("community", Label::new("community"))
.left_icon(Icon::Hash.into())
.size(ListEntrySize::Medium)
.indent_level(1),
ListEntry::new(Label::new("dashboards"))
ListItem::new("dashboards", Label::new("dashboards"))
.left_icon(Icon::Hash.into())
.size(ListEntrySize::Medium)
.indent_level(2),
ListEntry::new(Label::new("feedback"))
ListItem::new("feedback", Label::new("feedback"))
.left_icon(Icon::Hash.into())
.size(ListEntrySize::Medium)
.indent_level(2),
ListEntry::new(Label::new("teams-in-channels-alpha"))
ListItem::new(
"teams-in-channels-alpha",
Label::new("teams-in-channels-alpha"),
)
.left_icon(Icon::Hash.into())
.size(ListEntrySize::Medium)
.indent_level(2),
ListEntry::new(Label::new("current-projects"))
ListItem::new("current-projects", Label::new("current-projects"))
.left_icon(Icon::Hash.into())
.size(ListEntrySize::Medium)
.indent_level(1),
ListEntry::new(Label::new("codegen"))
ListItem::new("codegen", Label::new("codegen"))
.left_icon(Icon::Hash.into())
.size(ListEntrySize::Medium)
.indent_level(2),
ListEntry::new(Label::new("gpui2"))
ListItem::new("gpui2", Label::new("gpui2"))
.left_icon(Icon::Hash.into())
.size(ListEntrySize::Medium)
.indent_level(2),
ListEntry::new(Label::new("livestreaming"))
ListItem::new("livestreaming", Label::new("livestreaming"))
.left_icon(Icon::Hash.into())
.size(ListEntrySize::Medium)
.indent_level(2),
ListEntry::new(Label::new("open-source"))
ListItem::new("open-source", Label::new("open-source"))
.left_icon(Icon::Hash.into())
.size(ListEntrySize::Medium)
.indent_level(2),
ListEntry::new(Label::new("replace"))
ListItem::new("replace", Label::new("replace"))
.left_icon(Icon::Hash.into())
.size(ListEntrySize::Medium)
.indent_level(2),
ListEntry::new(Label::new("semantic-index"))
ListItem::new("semantic-index", Label::new("semantic-index"))
.left_icon(Icon::Hash.into())
.size(ListEntrySize::Medium)
.indent_level(2),
ListEntry::new(Label::new("vim"))
ListItem::new("vim", Label::new("vim"))
.left_icon(Icon::Hash.into())
.size(ListEntrySize::Medium)
.indent_level(2),
ListEntry::new(Label::new("web-tech"))
ListItem::new("web-tech", Label::new("web-tech"))
.left_icon(Icon::Hash.into())
.size(ListEntrySize::Medium)
.indent_level(2),
]
.into_iter()
.map(From::from)
.collect()
}
pub fn example_editor_actions() -> Vec<PaletteItem> {

View file

@ -39,7 +39,6 @@ file_finder = { package="file_finder2", path = "../file_finder2" }
# search = { path = "../search" }
fs = { package = "fs2", path = "../fs2" }
fsevent = { path = "../fsevent" }
fuzzy = { path = "../fuzzy" }
go_to_line = { package = "go_to_line2", path = "../go_to_line2" }
gpui = { package = "gpui2", path = "../gpui2" }
install_cli = { package = "install_cli2", path = "../install_cli2" }

View file

@ -1,5 +1,7 @@
#!/bin/bash
set -e
branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$branch" != "main" ]; then
echo "You must be on main to run this script"

View file

@ -10,6 +10,7 @@ local_only=false
overwrite_local_app=false
bundle_name=""
zed_crate="zed"
binary_name="Zed"
# This must match the team in the provsiioning profile.
APPLE_NOTORIZATION_TEAM="MQ55VZLNZQ"
@ -38,7 +39,6 @@ do
export CARGO_INCREMENTAL=true
export CARGO_BUNDLE_SKIP_BUILD=true
build_flag="";
local_arch=true
target_dir="debug"
;;
l)
@ -50,7 +50,10 @@ do
target_dir="debug"
;;
f) overwrite_local_app=true;;
2) zed_crate="zed2";;
2)
zed_crate="zed2"
binary_name="Zed2"
;;
h)
help_info
exit 0
@ -116,7 +119,7 @@ if [ "$local_arch" = false ]; then
echo "Creating fat binaries"
lipo \
-create \
target/{x86_64-apple-darwin,aarch64-apple-darwin}/${target_dir}/Zed \
target/{x86_64-apple-darwin,aarch64-apple-darwin}/${target_dir}/${binary_name} \
-output \
"${app_path}/Contents/MacOS/${zed_crate}"
lipo \

160
script/deploy-docs Executable file
View file

@ -0,0 +1,160 @@
#!/bin/bash
# Check if the script is run from the root of the repository
if [ ! -f "Cargo.toml" ] || [ ! -d "crates/zed" ]; then
echo "Please run the script from the root of the repository."
exit 1
fi
# Set the environment variables
TARGET_DIR="../zed-docs"
PUSH_CHANGES=false
CLEAN_FOLDERS=false
# Parse command line arguments
while getopts "pc" opt; do
case ${opt} in
p )
PUSH_CHANGES=true
;;
c )
CLEAN_FOLDERS=true
;;
\? )
echo "Invalid option: $OPTARG" 1>&2
exit 1
;;
esac
done
# Check if the target documentation directory exists
if [ ! -d "$TARGET_DIR" ]; then
# Prompt the user for input
read -p "Can't find ../zed-docs. Do you want to clone the repository (y/n)?" -n 1 -r
echo # Move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
# Clone the repo if the user agrees
git clone https://github.com/zed-industries/zed-docs.git "$TARGET_DIR"
else
# Exit if the user does not agree to clone the repo
echo "Exiting without cloning the repository."
exit 1
fi
else
# If the directory exists, pull the latest changes
pushd "$TARGET_DIR" > /dev/null
git pull
popd > /dev/null
fi
if "$CLEAN_FOLDERS"; then
echo "Cleaning ./doc and ./debug folders..."
rm -rf "$TARGET_DIR/doc"
rm -rf "$TARGET_DIR/debug"
fi
# Build the documentation
CARGO_TARGET_DIR="$TARGET_DIR" cargo doc --workspace --no-deps --open \
--exclude activity_indicator \
--exclude ai \
--exclude assistant \
--exclude audio \
--exclude auto_update \
--exclude breadcrumbs \
--exclude call \
--exclude channel \
--exclude cli \
--exclude client \
--exclude clock \
--exclude collab \
--exclude collab_ui \
--exclude collections \
--exclude command_palette \
--exclude component_test \
--exclude context_menu \
--exclude copilot \
--exclude copilot_button \
--exclude db \
--exclude diagnostics \
--exclude drag_and_drop \
--exclude editor \
--exclude feature_flags \
--exclude feedback \
--exclude file_finder \
--exclude fs \
--exclude fsevent \
--exclude fuzzy \
--exclude git \
--exclude go_to_line \
--exclude gpui \
--exclude gpui_macros \
--exclude install_cli \
--exclude journal \
--exclude language \
--exclude language_selector \
--exclude language_tools \
--exclude live_kit_client \
--exclude live_kit_server \
--exclude lsp \
--exclude media \
--exclude menu \
--exclude multi_buffer \
--exclude node_runtime \
--exclude notifications \
--exclude outline \
--exclude picker \
--exclude plugin \
--exclude plugin_macros \
--exclude plugin_runtime \
--exclude prettier \
--exclude project \
--exclude project_panel \
--exclude project_symbols \
--exclude quick_action_bar \
--exclude recent_projects \
--exclude refineable \
--exclude rich_text \
--exclude rope \
--exclude rpc \
--exclude search \
--exclude semantic_index \
--exclude settings \
--exclude snippet \
--exclude sqlez \
--exclude sqlez_macros \
--exclude storybook3 \
--exclude sum_tree \
--exclude terminal \
--exclude terminal_view \
--exclude text \
--exclude theme \
--exclude theme_importer \
--exclude theme_selector \
--exclude util \
--exclude vcs_menu \
--exclude vim \
--exclude welcome \
--exclude xtask \
--exclude zed \
--exclude zed-actions
if "$PUSH_CHANGES"; then
# Commit the changes and push
pushd "$TARGET_DIR" > /dev/null
# Check if there are any changes to commit
if git diff --quiet && git diff --staged --quiet; then
echo "No changes to the documentation."
else
# Staging the changes
git add .
# Creating a commit with the current datetime
DATETIME=$(date +"%Y-%m-%d %H:%M:%S")
git commit -m "Update docs $DATETIME"
# Pushing the changes
git push
fi
popd > /dev/null
fi