WIP
This commit is contained in:
parent
c42da5c9b9
commit
da100a09fb
5 changed files with 23 additions and 14 deletions
|
@ -1194,7 +1194,7 @@ impl Project {
|
||||||
!self.is_local()
|
!self.is_local()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_terminal_connection(
|
pub fn create_terminal(
|
||||||
&mut self,
|
&mut self,
|
||||||
working_directory: Option<PathBuf>,
|
working_directory: Option<PathBuf>,
|
||||||
window_id: usize,
|
window_id: usize,
|
||||||
|
|
|
@ -82,21 +82,22 @@ impl TerminalContainer {
|
||||||
let working_directory = get_working_directory(workspace, cx, strategy);
|
let working_directory = get_working_directory(workspace, cx, strategy);
|
||||||
|
|
||||||
let window_id = cx.window_id();
|
let window_id = cx.window_id();
|
||||||
|
let project = workspace.project().clone();
|
||||||
let terminal = workspace.project().update(cx, |project, cx| {
|
let terminal = workspace.project().update(cx, |project, cx| {
|
||||||
project.create_terminal_connection(working_directory, window_id, cx)
|
project.create_terminal(working_directory, window_id, cx)
|
||||||
});
|
});
|
||||||
|
|
||||||
let view = cx.add_view(|cx| TerminalContainer::new(terminal, workspace.database_id(), cx));
|
let view = cx.add_view(|cx| TerminalContainer::new(terminal, workspace.database_id(), cx));
|
||||||
workspace.add_item(Box::new(view), cx);
|
workspace.add_item(Box::new(view), cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
///Create a new Terminal view. This spawns a task, a thread, and opens the TTY devices
|
///Create a new Terminal view.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
model: anyhow::Result<ModelHandle<Terminal>>,
|
maybe_terminal: anyhow::Result<ModelHandle<Terminal>>,
|
||||||
workspace_id: WorkspaceId,
|
workspace_id: WorkspaceId,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let content = match model {
|
let content = match maybe_terminal {
|
||||||
Ok(terminal) => {
|
Ok(terminal) => {
|
||||||
let item_id = cx.view_id();
|
let item_id = cx.view_id();
|
||||||
let view = cx.add_view(|cx| {
|
let view = cx.add_view(|cx| {
|
||||||
|
@ -251,8 +252,7 @@ impl Item for TerminalContainer {
|
||||||
//Directory of the terminal from outside the shell. There might be
|
//Directory of the terminal from outside the shell. There might be
|
||||||
//solutions to this, but they are non-trivial and require more IPC
|
//solutions to this, but they are non-trivial and require more IPC
|
||||||
Some(TerminalContainer::new(
|
Some(TerminalContainer::new(
|
||||||
self.associated_directory.clone(),
|
Err(anyhow::anyhow!("failed to instantiate terminal")),
|
||||||
false,
|
|
||||||
workspace_id,
|
workspace_id,
|
||||||
cx,
|
cx,
|
||||||
))
|
))
|
||||||
|
@ -354,12 +354,13 @@ impl Item for TerminalContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize(
|
fn deserialize(
|
||||||
_project: ModelHandle<Project>,
|
project: ModelHandle<Project>,
|
||||||
_workspace: WeakViewHandle<Workspace>,
|
_workspace: WeakViewHandle<Workspace>,
|
||||||
workspace_id: workspace::WorkspaceId,
|
workspace_id: workspace::WorkspaceId,
|
||||||
item_id: workspace::ItemId,
|
item_id: workspace::ItemId,
|
||||||
cx: &mut ViewContext<Pane>,
|
cx: &mut ViewContext<Pane>,
|
||||||
) -> Task<anyhow::Result<ViewHandle<Self>>> {
|
) -> Task<anyhow::Result<ViewHandle<Self>>> {
|
||||||
|
let window_id = cx.window_id();
|
||||||
cx.spawn(|pane, mut cx| async move {
|
cx.spawn(|pane, mut cx| async move {
|
||||||
let cwd = TERMINAL_DB
|
let cwd = TERMINAL_DB
|
||||||
.take_working_directory(item_id, workspace_id)
|
.take_working_directory(item_id, workspace_id)
|
||||||
|
@ -368,8 +369,12 @@ impl Item for TerminalContainer {
|
||||||
.flatten();
|
.flatten();
|
||||||
|
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
|
let terminal = project.update(cx, |project, cx| {
|
||||||
|
project.create_terminal(cwd, window_id, cx)
|
||||||
|
});
|
||||||
|
|
||||||
Ok(cx.add_view(pane, |cx| {
|
Ok(cx.add_view(pane, |cx| {
|
||||||
TerminalContainer::new(cwd, false, workspace_id, cx)
|
TerminalContainer::new(terminal, workspace_id, cx)
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -32,7 +32,7 @@ use util::ResultExt;
|
||||||
use std::{fmt::Debug, ops::RangeInclusive};
|
use std::{fmt::Debug, ops::RangeInclusive};
|
||||||
use std::{mem, ops::Range};
|
use std::{mem, ops::Range};
|
||||||
|
|
||||||
use crate::terminal_view::{DeployContextMenu, TerminalView};
|
use crate::{DeployContextMenu, TerminalView};
|
||||||
|
|
||||||
///The information generated during layout that is nescessary for painting
|
///The information generated during layout that is nescessary for painting
|
||||||
pub struct LayoutState {
|
pub struct LayoutState {
|
||||||
|
|
|
@ -22,12 +22,12 @@ use terminal::{
|
||||||
index::Point,
|
index::Point,
|
||||||
term::{search::RegexSearch, TermMode},
|
term::{search::RegexSearch, TermMode},
|
||||||
},
|
},
|
||||||
Terminal,
|
Event, Terminal,
|
||||||
};
|
};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::{pane, ItemId, WorkspaceId};
|
use workspace::{pane, ItemId, WorkspaceId};
|
||||||
|
|
||||||
use crate::{persistence::TERMINAL_DB, terminal_element::TerminalElement, Event};
|
use crate::{persistence::TERMINAL_DB, terminal_element::TerminalElement};
|
||||||
|
|
||||||
const CURSOR_BLINK_INTERVAL: Duration = Duration::from_millis(500);
|
const CURSOR_BLINK_INTERVAL: Duration = Duration::from_millis(500);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ use settings::{
|
||||||
use smol::process::Command;
|
use smol::process::Command;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::{env, ffi::OsStr, panic, path::PathBuf, sync::Arc, thread, time::Duration};
|
use std::{env, ffi::OsStr, panic, path::PathBuf, sync::Arc, thread, time::Duration};
|
||||||
use terminal_view::{get_working_directory, TerminalContainer};
|
use terminal_view::terminal_container_view::{get_working_directory, TerminalContainer};
|
||||||
|
|
||||||
use fs::RealFs;
|
use fs::RealFs;
|
||||||
use settings::watched_json::{watch_keymap_file, watch_settings_file, WatchedJsonFile};
|
use settings::watched_json::{watch_keymap_file, watch_settings_file, WatchedJsonFile};
|
||||||
|
@ -595,7 +595,11 @@ pub fn default_item_factory(
|
||||||
let working_directory = get_working_directory(workspace, cx, strategy);
|
let working_directory = get_working_directory(workspace, cx, strategy);
|
||||||
|
|
||||||
let terminal_handle = cx.add_view(|cx| {
|
let terminal_handle = cx.add_view(|cx| {
|
||||||
TerminalContainer::new(working_directory, false, workspace.database_id(), cx)
|
TerminalContainer::new(
|
||||||
|
Err(anyhow!("Don't have a project to open a terminal")),
|
||||||
|
workspace.database_id(),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
});
|
});
|
||||||
Box::new(terminal_handle)
|
Box::new(terminal_handle)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue