mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-07 20:39:04 +03:00
WIP
This commit is contained in:
parent
e3465fbcf9
commit
fd61683c46
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -11567,6 +11567,7 @@ dependencies = [
|
||||
"smol",
|
||||
"sum_tree",
|
||||
"tempdir",
|
||||
"terminal_view2",
|
||||
"text2",
|
||||
"theme2",
|
||||
"thiserror",
|
||||
|
@ -426,7 +426,7 @@ impl Editor {
|
||||
|
||||
pub fn read_scroll_position_from_db(
|
||||
&mut self,
|
||||
item_id: usize,
|
||||
item_id: u64,
|
||||
workspace_id: WorkspaceId,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) {
|
||||
|
@ -1830,8 +1830,8 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
||||
self.view
|
||||
}
|
||||
|
||||
pub fn model(&self) -> Model<V> {
|
||||
self.view.model.clone()
|
||||
pub fn model(&self) -> &Model<V> {
|
||||
&self.view.model
|
||||
}
|
||||
|
||||
/// Access the underlying window context.
|
||||
@ -2163,7 +2163,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
||||
|
||||
pub fn observe_global<G: 'static>(
|
||||
&mut self,
|
||||
f: impl Fn(&mut V, &mut ViewContext<'_, V>) + 'static,
|
||||
mut f: impl FnMut(&mut V, &mut ViewContext<'_, V>) + 'static,
|
||||
) -> Subscription {
|
||||
let window_handle = self.window.handle;
|
||||
let view = self.view().downgrade();
|
||||
|
@ -164,6 +164,23 @@ impl Column for i64 {
|
||||
}
|
||||
}
|
||||
|
||||
impl StaticColumnCount for u64 {}
|
||||
impl Bind for u64 {
|
||||
fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {
|
||||
statement
|
||||
.bind_int64(start_index, (*self) as i64)
|
||||
.with_context(|| format!("Failed to bind i64 at index {start_index}"))?;
|
||||
Ok(start_index + 1)
|
||||
}
|
||||
}
|
||||
|
||||
impl Column for u64 {
|
||||
fn column(statement: &mut Statement, start_index: i32) -> Result<(Self, i32)> {
|
||||
let result = statement.column_int64(start_index)? as u64;
|
||||
Ok((result, start_index + 1))
|
||||
}
|
||||
}
|
||||
|
||||
impl StaticColumnCount for u32 {}
|
||||
impl Bind for u32 {
|
||||
fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {
|
||||
|
@ -1,7 +1,6 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use db::{define_connection, query, sqlez_macros::sql};
|
||||
use gpui::EntityId;
|
||||
use workspace::{ItemId, WorkspaceDb, WorkspaceId};
|
||||
|
||||
define_connection! {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,8 +3,9 @@ use std::{path::PathBuf, sync::Arc};
|
||||
use crate::TerminalView;
|
||||
use db::kvp::KEY_VALUE_STORE;
|
||||
use gpui::{
|
||||
actions, serde_json, Action, AppContext, AsyncAppContext, Entity, EventEmitter, Render,
|
||||
Subscription, Task, View, ViewContext, VisualContext, WeakView, WindowContext,
|
||||
actions, div, serde_json, AppContext, AsyncWindowContext, Div, Entity, EventEmitter,
|
||||
FocusHandle, FocusableView, ParentComponent, Render, Subscription, Task, View, ViewContext,
|
||||
VisualContext, WeakView, WindowContext,
|
||||
};
|
||||
use project::Fs;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -14,7 +15,9 @@ use util::{ResultExt, TryFutureExt};
|
||||
use workspace::{
|
||||
dock::{DockPosition, Panel, PanelEvent},
|
||||
item::Item,
|
||||
pane, Pane, Workspace,
|
||||
pane,
|
||||
ui::Icon,
|
||||
Pane, Workspace,
|
||||
};
|
||||
|
||||
use anyhow::Result;
|
||||
@ -28,20 +31,14 @@ pub fn init(cx: &mut AppContext) {
|
||||
|workspace: &mut Workspace, _: &mut ViewContext<Workspace>| {
|
||||
workspace.register_action(TerminalPanel::new_terminal);
|
||||
workspace.register_action(TerminalPanel::open_terminal);
|
||||
workspace.register_action(|workspace, _: &ToggleFocus, cx| {
|
||||
workspace.toggle_panel_focus::<TerminalPanel>(cx);
|
||||
});
|
||||
},
|
||||
)
|
||||
.detach();
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Event {
|
||||
Close,
|
||||
DockPositionChanged,
|
||||
ZoomIn,
|
||||
ZoomOut,
|
||||
Focus,
|
||||
}
|
||||
|
||||
pub struct TerminalPanel {
|
||||
pane: View<Pane>,
|
||||
fs: Arc<dyn Fs>,
|
||||
@ -54,9 +51,9 @@ pub struct TerminalPanel {
|
||||
|
||||
impl TerminalPanel {
|
||||
fn new(workspace: &Workspace, cx: &mut ViewContext<Self>) -> Self {
|
||||
let weak_self = cx.weak_handle();
|
||||
let _weak_self = cx.view().downgrade();
|
||||
let pane = cx.build_view(|cx| {
|
||||
let window = cx.window_handle();
|
||||
let _window = cx.window_handle();
|
||||
let mut pane = Pane::new(
|
||||
workspace.weak_handle(),
|
||||
workspace.project().clone(),
|
||||
@ -65,54 +62,55 @@ impl TerminalPanel {
|
||||
);
|
||||
pane.set_can_split(false, cx);
|
||||
pane.set_can_navigate(false, cx);
|
||||
pane.on_can_drop(move |drag_and_drop, cx| {
|
||||
drag_and_drop
|
||||
.currently_dragged::<DraggedItem>(window)
|
||||
.map_or(false, |(_, item)| {
|
||||
item.handle.act_as::<TerminalView>(cx).is_some()
|
||||
})
|
||||
});
|
||||
pane.set_render_tab_bar_buttons(cx, move |pane, cx| {
|
||||
let this = weak_self.clone();
|
||||
Flex::row()
|
||||
.with_child(Pane::render_tab_bar_button(
|
||||
0,
|
||||
"icons/plus.svg",
|
||||
false,
|
||||
Some(("New Terminal", Some(Box::new(workspace::NewTerminal)))),
|
||||
cx,
|
||||
move |_, cx| {
|
||||
let this = this.clone();
|
||||
cx.window_context().defer(move |cx| {
|
||||
if let Some(this) = this.upgrade() {
|
||||
this.update(cx, |this, cx| {
|
||||
this.add_terminal(None, cx);
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
|_, _| {},
|
||||
None,
|
||||
))
|
||||
.with_child(Pane::render_tab_bar_button(
|
||||
1,
|
||||
if pane.is_zoomed() {
|
||||
"icons/minimize.svg"
|
||||
} else {
|
||||
"icons/maximize.svg"
|
||||
},
|
||||
pane.is_zoomed(),
|
||||
Some(("Toggle Zoom".into(), Some(Box::new(workspace::ToggleZoom)))),
|
||||
cx,
|
||||
move |pane, cx| pane.toggle_zoom(&Default::default(), cx),
|
||||
|_, _| {},
|
||||
None,
|
||||
))
|
||||
.into_any()
|
||||
});
|
||||
let buffer_search_bar = cx.build_view(search::BufferSearchBar::new);
|
||||
pane.toolbar()
|
||||
.update(cx, |toolbar, cx| toolbar.add_item(buffer_search_bar, cx));
|
||||
// todo!()
|
||||
// pane.on_can_drop(move |drag_and_drop, cx| {
|
||||
// drag_and_drop
|
||||
// .currently_dragged::<DraggedItem>(window)
|
||||
// .map_or(false, |(_, item)| {
|
||||
// item.handle.act_as::<TerminalView>(cx).is_some()
|
||||
// })
|
||||
// });
|
||||
// pane.set_render_tab_bar_buttons(cx, move |pane, cx| {
|
||||
// let this = weak_self.clone();
|
||||
// Flex::row()
|
||||
// .with_child(Pane::render_tab_bar_button(
|
||||
// 0,
|
||||
// "icons/plus.svg",
|
||||
// false,
|
||||
// Some(("New Terminal", Some(Box::new(workspace::NewTerminal)))),
|
||||
// cx,
|
||||
// move |_, cx| {
|
||||
// let this = this.clone();
|
||||
// cx.window_context().defer(move |cx| {
|
||||
// if let Some(this) = this.upgrade() {
|
||||
// this.update(cx, |this, cx| {
|
||||
// this.add_terminal(None, cx);
|
||||
// });
|
||||
// }
|
||||
// })
|
||||
// },
|
||||
// |_, _| {},
|
||||
// None,
|
||||
// ))
|
||||
// .with_child(Pane::render_tab_bar_button(
|
||||
// 1,
|
||||
// if pane.is_zoomed() {
|
||||
// "icons/minimize.svg"
|
||||
// } else {
|
||||
// "icons/maximize.svg"
|
||||
// },
|
||||
// pane.is_zoomed(),
|
||||
// Some(("Toggle Zoom".into(), Some(Box::new(workspace::ToggleZoom)))),
|
||||
// cx,
|
||||
// move |pane, cx| pane.toggle_zoom(&Default::default(), cx),
|
||||
// |_, _| {},
|
||||
// None,
|
||||
// ))
|
||||
// .into_any()
|
||||
// });
|
||||
// let buffer_search_bar = cx.build_view(search::BufferSearchBar::new);
|
||||
// pane.toolbar()
|
||||
// .update(cx, |toolbar, cx| toolbar.add_item(buffer_search_bar, cx));
|
||||
pane
|
||||
});
|
||||
let subscriptions = vec![
|
||||
@ -133,80 +131,81 @@ impl TerminalPanel {
|
||||
let new_dock_position = this.position(cx);
|
||||
if new_dock_position != old_dock_position {
|
||||
old_dock_position = new_dock_position;
|
||||
cx.emit(Event::DockPositionChanged);
|
||||
cx.emit(PanelEvent::ChangePosition);
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
this
|
||||
}
|
||||
|
||||
pub fn load(workspace: WeakView<Workspace>, cx: AsyncAppContext) -> Task<Result<View<Self>>> {
|
||||
cx.spawn(|mut cx| async move {
|
||||
let serialized_panel = if let Some(panel) = cx
|
||||
.background_executor()
|
||||
.spawn(async move { KEY_VALUE_STORE.read_kvp(TERMINAL_PANEL_KEY) })
|
||||
.await
|
||||
.log_err()
|
||||
.flatten()
|
||||
{
|
||||
Some(serde_json::from_str::<SerializedTerminalPanel>(&panel)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let (panel, pane, items) = workspace.update(&mut cx, |workspace, cx| {
|
||||
let panel = cx.build_view(|cx| TerminalPanel::new(workspace, cx));
|
||||
let items = if let Some(serialized_panel) = serialized_panel.as_ref() {
|
||||
panel.update(cx, |panel, cx| {
|
||||
cx.notify();
|
||||
panel.height = serialized_panel.height;
|
||||
panel.width = serialized_panel.width;
|
||||
panel.pane.update(cx, |_, cx| {
|
||||
serialized_panel
|
||||
.items
|
||||
.iter()
|
||||
.map(|item_id| {
|
||||
TerminalView::deserialize(
|
||||
workspace.project().clone(),
|
||||
workspace.weak_handle(),
|
||||
workspace.database_id(),
|
||||
*item_id,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
})
|
||||
} else {
|
||||
Default::default()
|
||||
};
|
||||
let pane = panel.read(cx).pane.clone();
|
||||
(panel, pane, items)
|
||||
})?;
|
||||
pub async fn load(
|
||||
workspace: WeakView<Workspace>,
|
||||
mut cx: AsyncWindowContext,
|
||||
) -> Result<View<Self>> {
|
||||
let serialized_panel = cx
|
||||
.background_executor()
|
||||
.spawn(async move { KEY_VALUE_STORE.read_kvp(TERMINAL_PANEL_KEY) })
|
||||
.await
|
||||
.log_err()
|
||||
.flatten()
|
||||
.map(|panel| serde_json::from_str::<SerializedTerminalPanel>(&panel))
|
||||
.transpose()
|
||||
.log_err()
|
||||
.flatten();
|
||||
|
||||
let pane = pane.downgrade();
|
||||
let items = futures::future::join_all(items).await;
|
||||
pane.update(&mut cx, |pane, cx| {
|
||||
let active_item_id = serialized_panel
|
||||
.as_ref()
|
||||
.and_then(|panel| panel.active_item_id);
|
||||
let mut active_ix = None;
|
||||
for item in items {
|
||||
if let Some(item) = item.log_err() {
|
||||
let item_id = item.entity_id().as_u64();
|
||||
pane.add_item(Box::new(item), false, false, None, cx);
|
||||
if Some(item_id) == active_item_id {
|
||||
active_ix = Some(pane.items_len() - 1);
|
||||
}
|
||||
let (panel, pane, items) = workspace.update(&mut cx, |workspace, cx| {
|
||||
let panel = cx.build_view(|cx| TerminalPanel::new(workspace, cx));
|
||||
let items = if let Some(serialized_panel) = serialized_panel.as_ref() {
|
||||
panel.update(cx, |panel, cx| {
|
||||
cx.notify();
|
||||
panel.height = serialized_panel.height;
|
||||
panel.width = serialized_panel.width;
|
||||
panel.pane.update(cx, |_, cx| {
|
||||
serialized_panel
|
||||
.items
|
||||
.iter()
|
||||
.map(|item_id| {
|
||||
TerminalView::deserialize(
|
||||
workspace.project().clone(),
|
||||
workspace.weak_handle(),
|
||||
workspace.database_id(),
|
||||
*item_id,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
})
|
||||
} else {
|
||||
Default::default()
|
||||
};
|
||||
let pane = panel.read(cx).pane.clone();
|
||||
(panel, pane, items)
|
||||
})?;
|
||||
|
||||
let pane = pane.downgrade();
|
||||
let items = futures::future::join_all(items).await;
|
||||
pane.update(&mut cx, |pane, cx| {
|
||||
let active_item_id = serialized_panel
|
||||
.as_ref()
|
||||
.and_then(|panel| panel.active_item_id);
|
||||
let mut active_ix = None;
|
||||
for item in items {
|
||||
if let Some(item) = item.log_err() {
|
||||
let item_id = item.entity_id().as_u64();
|
||||
pane.add_item(Box::new(item), false, false, None, cx);
|
||||
if Some(item_id) == active_item_id {
|
||||
active_ix = Some(pane.items_len() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(active_ix) = active_ix {
|
||||
pane.activate_item(active_ix, false, false, cx)
|
||||
}
|
||||
})?;
|
||||
if let Some(active_ix) = active_ix {
|
||||
pane.activate_item(active_ix, false, false, cx)
|
||||
}
|
||||
})?;
|
||||
|
||||
Ok(panel)
|
||||
})
|
||||
Ok(panel)
|
||||
}
|
||||
|
||||
fn handle_pane_event(
|
||||
@ -218,10 +217,10 @@ impl TerminalPanel {
|
||||
match event {
|
||||
pane::Event::ActivateItem { .. } => self.serialize(cx),
|
||||
pane::Event::RemoveItem { .. } => self.serialize(cx),
|
||||
pane::Event::Remove => cx.emit(Event::Close),
|
||||
pane::Event::ZoomIn => cx.emit(Event::ZoomIn),
|
||||
pane::Event::ZoomOut => cx.emit(Event::ZoomOut),
|
||||
pane::Event::Focus => cx.emit(Event::Focus),
|
||||
pane::Event::Remove => cx.emit(PanelEvent::Close),
|
||||
pane::Event::ZoomIn => cx.emit(PanelEvent::ZoomIn),
|
||||
pane::Event::ZoomOut => cx.emit(PanelEvent::ZoomOut),
|
||||
pane::Event::Focus => cx.emit(PanelEvent::Focus),
|
||||
|
||||
pane::Event::AddItem { item } => {
|
||||
if let Some(workspace) = self.workspace.upgrade() {
|
||||
@ -334,20 +333,20 @@ impl TerminalPanel {
|
||||
}
|
||||
}
|
||||
|
||||
impl EventEmitter<Event> for TerminalPanel {}
|
||||
impl EventEmitter<PanelEvent> for TerminalPanel {}
|
||||
|
||||
impl Render for TerminalPanel {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> gpui::AnyElement<Self> {
|
||||
ChildView::new(&self.pane, cx).into_any()
|
||||
}
|
||||
type Element = Div<Self>;
|
||||
|
||||
// todo!()
|
||||
// fn focus_in(&mut self, _: gpui::AnyView, cx: &mut ViewContext<Self>) {
|
||||
// if cx.is_self_focused() {
|
||||
// cx.focus(&self.pane);
|
||||
// }
|
||||
// }
|
||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
div().child(self.pane.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl FocusableView for TerminalPanel {
|
||||
fn focus_handle(&self, cx: &AppContext) -> FocusHandle {
|
||||
self.pane.focus_handle(cx)
|
||||
}
|
||||
}
|
||||
|
||||
impl Panel for TerminalPanel {
|
||||
@ -407,14 +406,6 @@ impl Panel for TerminalPanel {
|
||||
}
|
||||
}
|
||||
|
||||
fn icon_path(&self, _: &WindowContext) -> Option<&'static str> {
|
||||
Some("icons/terminal.svg")
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self) -> (String, Option<Box<dyn Action>>) {
|
||||
("Terminal Panel".into(), Some(Box::new(ToggleFocus)))
|
||||
}
|
||||
|
||||
fn icon_label(&self, cx: &WindowContext) -> Option<String> {
|
||||
let count = self.pane.read(cx).items_len();
|
||||
if count == 0 {
|
||||
@ -428,34 +419,22 @@ impl Panel for TerminalPanel {
|
||||
self.pane.read(cx).has_focus(cx)
|
||||
}
|
||||
|
||||
fn persistent_name(&self) -> &'static str {
|
||||
todo!()
|
||||
fn persistent_name() -> &'static str {
|
||||
"TerminalPanel"
|
||||
}
|
||||
|
||||
// todo!() is it needed?
|
||||
// fn should_change_position_on_event(event: &Self::Event) -> bool {
|
||||
// matches!(event, Event::DockPositionChanged)
|
||||
// todo!()
|
||||
// fn icon_tooltip(&self) -> (String, Option<Box<dyn Action>>) {
|
||||
// ("Terminal Panel".into(), Some(Box::new(ToggleFocus)))
|
||||
// }
|
||||
|
||||
// fn should_activate_on_event(_: &Self::Event) -> bool {
|
||||
// false
|
||||
// }
|
||||
fn icon(&self, _cx: &WindowContext) -> Option<Icon> {
|
||||
Some(Icon::Terminal)
|
||||
}
|
||||
|
||||
// fn should_close_on_event(event: &Event) -> bool {
|
||||
// matches!(event, Event::Close)
|
||||
// }
|
||||
|
||||
// fn is_focus_event(event: &Self::Event) -> bool {
|
||||
// matches!(event, Event::Focus)
|
||||
// }
|
||||
|
||||
// fn should_zoom_in_on_event(event: &Event) -> bool {
|
||||
// matches!(event, Event::ZoomIn)
|
||||
// }
|
||||
|
||||
// fn should_zoom_out_on_event(event: &Event) -> bool {
|
||||
// matches!(event, Event::ZoomOut)
|
||||
// }
|
||||
fn toggle_action(&self) -> Box<dyn gpui::Action> {
|
||||
Box::new(ToggleFocus)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
|
@ -1,22 +1,23 @@
|
||||
#![allow(unused_variables)]
|
||||
//todo!(remove)
|
||||
|
||||
// mod persistence;
|
||||
mod persistence;
|
||||
pub mod terminal_element;
|
||||
pub mod terminal_panel;
|
||||
|
||||
use crate::terminal_element::TerminalElement;
|
||||
// todo!()
|
||||
// use crate::terminal_element::TerminalElement;
|
||||
use anyhow::Context;
|
||||
use dirs::home_dir;
|
||||
use editor::{scroll::autoscroll::Autoscroll, Editor};
|
||||
use gpui::{
|
||||
actions, div, img, red, register_action, AnyElement, AppContext, Component, DispatchPhase, Div,
|
||||
EventEmitter, FocusEvent, FocusHandle, Focusable, FocusableKeyDispatch, InputHandler,
|
||||
KeyDownEvent, Keystroke, Model, ParentElement, Pixels, Render, SharedString,
|
||||
StatefulInteractivity, StatelessInteractive, Styled, Task, View, ViewContext, VisualContext,
|
||||
WeakView,
|
||||
EventEmitter, FocusEvent, FocusHandle, Focusable, FocusableComponent, FocusableView,
|
||||
InputHandler, InteractiveComponent, KeyDownEvent, Keystroke, Model, ParentComponent, Pixels,
|
||||
Render, SharedString, Styled, Task, View, ViewContext, VisualContext, WeakView,
|
||||
};
|
||||
use language::Bias;
|
||||
use persistence::TERMINAL_DB;
|
||||
use project::{search::SearchQuery, LocalWorktree, Project};
|
||||
use serde::Deserialize;
|
||||
use settings::Settings;
|
||||
@ -68,7 +69,7 @@ pub fn init(cx: &mut AppContext) {
|
||||
|
||||
cx.observe_new_views(
|
||||
|workspace: &mut Workspace, cx: &mut ViewContext<Workspace>| {
|
||||
workspace.register_action(TerminalView::deploy)
|
||||
workspace.register_action(TerminalView::deploy);
|
||||
},
|
||||
)
|
||||
.detach();
|
||||
@ -94,6 +95,12 @@ impl EventEmitter<Event> for TerminalView {}
|
||||
impl EventEmitter<ItemEvent> for TerminalView {}
|
||||
impl EventEmitter<SearchEvent> for TerminalView {}
|
||||
|
||||
impl FocusableView for TerminalView {
|
||||
fn focus_handle(&self, _cx: &AppContext) -> FocusHandle {
|
||||
self.focus_handle.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl TerminalView {
|
||||
///Create a new Terminal in the current working directory or the user's home directory
|
||||
pub fn deploy(
|
||||
@ -159,15 +166,14 @@ impl TerminalView {
|
||||
|
||||
let item_id = cx.entity_id();
|
||||
let workspace_id = this.workspace_id;
|
||||
// todo!(persistence)
|
||||
// cx.background_executor()
|
||||
// .spawn(async move {
|
||||
// TERMINAL_DB
|
||||
// .save_working_directory(item_id, workspace_id, cwd)
|
||||
// .await
|
||||
// .log_err();
|
||||
// })
|
||||
// .detach();
|
||||
cx.background_executor()
|
||||
.spawn(async move {
|
||||
TERMINAL_DB
|
||||
.save_working_directory(item_id.as_u64(), workspace_id, cwd)
|
||||
.await
|
||||
.log_err();
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
}
|
||||
|
||||
@ -526,7 +532,7 @@ impl TerminalView {
|
||||
}
|
||||
|
||||
impl Render for TerminalView {
|
||||
type Element = Div<Self, StatefulInteractivity<Self>, FocusableKeyDispatch<Self>>;
|
||||
type Element = Focusable<Self, Div<Self>>;
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
let terminal_handle = self.terminal.clone().downgrade();
|
||||
@ -536,7 +542,7 @@ impl Render for TerminalView {
|
||||
|
||||
div()
|
||||
.track_focus(&self.focus_handle)
|
||||
.on_focus_in(Self::focus_out)
|
||||
.on_focus_in(Self::focus_in)
|
||||
.on_focus_out(Self::focus_out)
|
||||
.on_key_down(Self::key_down)
|
||||
.on_action(TerminalView::send_text)
|
||||
@ -828,10 +834,6 @@ impl Item for TerminalView {
|
||||
// .detach();
|
||||
self.workspace_id = workspace.database_id();
|
||||
}
|
||||
|
||||
fn focus_handle(&self) -> FocusHandle {
|
||||
self.focus_handle.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl SearchableItem for TerminalView {
|
||||
|
@ -277,7 +277,7 @@ impl SerializedPane {
|
||||
|
||||
pub type GroupId = i64;
|
||||
pub type PaneId = i64;
|
||||
pub type ItemId = usize;
|
||||
pub type ItemId = u64;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub struct SerializedItem {
|
||||
|
@ -15,13 +15,6 @@ mod status_bar;
|
||||
mod toolbar;
|
||||
mod workspace_settings;
|
||||
|
||||
pub use crate::persistence::{
|
||||
model::{
|
||||
DockData, DockStructure, ItemId, SerializedItem, SerializedPane, SerializedPaneGroup,
|
||||
SerializedWorkspace,
|
||||
},
|
||||
WorkspaceDb,
|
||||
};
|
||||
use anyhow::{anyhow, Context as _, Result};
|
||||
use call2::ActiveCall;
|
||||
use client2::{
|
||||
@ -37,11 +30,10 @@ use futures::{
|
||||
};
|
||||
use gpui::{
|
||||
actions, div, point, register_action, size, Action, AnyModel, AnyView, AnyWeakView, AppContext,
|
||||
AsyncAppContext, AsyncWindowContext, Bounds, Div, Entity, EntityId, EventEmitter, FocusHandle,
|
||||
FocusableView, GlobalPixels, KeyContext, Model, ModelContext, ParentElement, Point, Render,
|
||||
Size, StatefulInteractive, StatelessInteractive, StatelessInteractivity, Styled, Subscription,
|
||||
Task, View, ViewContext, VisualContext, WeakView, WindowBounds, WindowContext, WindowHandle,
|
||||
WindowOptions,
|
||||
AsyncAppContext, AsyncWindowContext, Bounds, Context, Div, Entity, EntityId, EventEmitter,
|
||||
FocusHandle, FocusableView, GlobalPixels, InteractiveComponent, KeyContext, Model,
|
||||
ModelContext, ParentComponent, Point, Render, Size, Styled, Subscription, Task, View,
|
||||
ViewContext, VisualContext, WeakView, WindowBounds, WindowContext, WindowHandle, WindowOptions,
|
||||
};
|
||||
use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ItemSettings, ProjectItem};
|
||||
use itertools::Itertools;
|
||||
@ -52,7 +44,10 @@ use node_runtime::NodeRuntime;
|
||||
use notifications::{simple_message_notification::MessageNotification, NotificationHandle};
|
||||
pub use pane::*;
|
||||
pub use pane_group::*;
|
||||
use persistence::{model::WorkspaceLocation, DB};
|
||||
pub use persistence::{
|
||||
model::{ItemId, SerializedWorkspace, WorkspaceLocation},
|
||||
WorkspaceDb, DB,
|
||||
};
|
||||
use postage::stream::Stream;
|
||||
use project2::{Project, ProjectEntryId, ProjectPath, Worktree};
|
||||
use serde::Deserialize;
|
||||
@ -69,10 +64,15 @@ use std::{
|
||||
};
|
||||
use theme2::{ActiveTheme, ThemeSettings};
|
||||
pub use toolbar::{ToolbarItemLocation, ToolbarItemView};
|
||||
pub use ui;
|
||||
use util::ResultExt;
|
||||
use uuid::Uuid;
|
||||
pub use workspace_settings::{AutosaveSetting, WorkspaceSettings};
|
||||
|
||||
use crate::persistence::model::{
|
||||
DockData, DockStructure, SerializedItem, SerializedPane, SerializedPaneGroup,
|
||||
};
|
||||
|
||||
lazy_static! {
|
||||
static ref ZED_WINDOW_SIZE: Option<Size<GlobalPixels>> = env::var("ZED_WINDOW_SIZE")
|
||||
.ok()
|
||||
@ -1582,13 +1582,11 @@ impl Workspace {
|
||||
self.serialize_workspace(cx);
|
||||
}
|
||||
|
||||
// /// Transfer focus to the panel of the given type.
|
||||
// pub fn focus_panel<T: Panel>(&mut self, cx: &mut ViewContext<Self>) -> Option<View<T>> {
|
||||
// self.focus_or_unfocus_panel::<T>(cx, |_, _| true)?
|
||||
// .as_any()
|
||||
// .clone()
|
||||
// .downcast()
|
||||
// }
|
||||
/// Transfer focus to the panel of the given type.
|
||||
pub fn focus_panel<T: Panel>(&mut self, cx: &mut ViewContext<Self>) -> Option<View<T>> {
|
||||
let panel = self.focus_or_unfocus_panel::<T>(cx, |_, _| true)?;
|
||||
panel.to_any().downcast().ok()
|
||||
}
|
||||
|
||||
/// Focus the panel of the given type if it isn't already focused. If it is
|
||||
/// already focused, then transfer focus back to the workspace center.
|
||||
@ -2981,7 +2979,7 @@ impl Workspace {
|
||||
.filter_map(|item_handle| {
|
||||
Some(SerializedItem {
|
||||
kind: Arc::from(item_handle.serialized_item_kind()?),
|
||||
item_id: item_handle.id().as_u64() as usize,
|
||||
item_id: item_handle.id().as_u64(),
|
||||
active: Some(item_handle.id()) == active_item_id,
|
||||
})
|
||||
})
|
||||
|
@ -66,7 +66,7 @@ feature_flags = { package = "feature_flags2", path = "../feature_flags2" }
|
||||
sum_tree = { path = "../sum_tree" }
|
||||
shellexpand = "2.1.0"
|
||||
text = { package = "text2", path = "../text2" }
|
||||
# terminal_view = { path = "../terminal_view" }
|
||||
terminal_view = { package = "terminal_view2", path = "../terminal_view2" }
|
||||
theme = { package = "theme2", path = "../theme2" }
|
||||
# theme_selector = { path = "../theme_selector" }
|
||||
util = { path = "../util" }
|
||||
|
@ -198,7 +198,7 @@ fn main() {
|
||||
// search::init(cx);
|
||||
// semantic_index::init(fs.clone(), http.clone(), languages.clone(), cx);
|
||||
// vim::init(cx);
|
||||
// terminal_view::init(cx);
|
||||
terminal_view::init(cx);
|
||||
|
||||
// journal2::init(app_state.clone(), cx);
|
||||
// language_selector::init(cx);
|
||||
|
@ -20,6 +20,7 @@ use anyhow::{anyhow, Context as _};
|
||||
use project_panel::ProjectPanel;
|
||||
use settings::{initial_local_settings_content, Settings};
|
||||
use std::{borrow::Cow, ops::Deref, sync::Arc};
|
||||
use terminal_view::terminal_panel::TerminalPanel;
|
||||
use util::{
|
||||
asset_str,
|
||||
channel::ReleaseChannel,
|
||||
@ -174,7 +175,7 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||
|
||||
cx.spawn(|workspace_handle, mut cx| async move {
|
||||
let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone());
|
||||
// let terminal_panel = TerminalPanel::load(workspace_handle.clone(), cx.clone());
|
||||
let terminal_panel = TerminalPanel::load(workspace_handle.clone(), cx.clone());
|
||||
// let assistant_panel = AssistantPanel::load(workspace_handle.clone(), cx.clone());
|
||||
let channels_panel =
|
||||
collab_ui::collab_panel::CollabPanel::load(workspace_handle.clone(), cx.clone());
|
||||
@ -186,14 +187,14 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||
// );
|
||||
let (
|
||||
project_panel,
|
||||
// terminal_panel,
|
||||
terminal_panel,
|
||||
// assistant_panel,
|
||||
channels_panel,
|
||||
// chat_panel,
|
||||
// notification_panel,
|
||||
) = futures::try_join!(
|
||||
project_panel,
|
||||
// terminal_panel,
|
||||
terminal_panel,
|
||||
// assistant_panel,
|
||||
channels_panel,
|
||||
// chat_panel,
|
||||
@ -203,7 +204,7 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||
workspace_handle.update(&mut cx, |workspace, cx| {
|
||||
let project_panel_position = project_panel.position(cx);
|
||||
workspace.add_panel(project_panel, cx);
|
||||
// workspace.add_panel(terminal_panel, cx);
|
||||
workspace.add_panel(terminal_panel, cx);
|
||||
// workspace.add_panel(assistant_panel, cx);
|
||||
workspace.add_panel(channels_panel, cx);
|
||||
// workspace.add_panel(chat_panel, cx);
|
||||
|
Loading…
Reference in New Issue
Block a user