mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 02:46:43 +00:00
Added terminal::SendText command, for sending text to the terminal
This commit is contained in:
parent
2ae3fbd6b2
commit
24cc9859c7
3 changed files with 19 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -5489,6 +5489,7 @@ dependencies = [
|
||||||
"procinfo",
|
"procinfo",
|
||||||
"project",
|
"project",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
|
"serde",
|
||||||
"settings",
|
"settings",
|
||||||
"shellexpand",
|
"shellexpand",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
|
|
|
@ -30,6 +30,8 @@ libc = "0.2"
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,12 @@ use gpui::{
|
||||||
actions,
|
actions,
|
||||||
elements::{AnchorCorner, ChildView, ParentElement, Stack},
|
elements::{AnchorCorner, ChildView, ParentElement, Stack},
|
||||||
geometry::vector::Vector2F,
|
geometry::vector::Vector2F,
|
||||||
impl_internal_actions,
|
impl_actions, impl_internal_actions,
|
||||||
keymap::Keystroke,
|
keymap::Keystroke,
|
||||||
AnyViewHandle, AppContext, Element, ElementBox, Entity, ModelHandle, MutableAppContext, Task,
|
AnyViewHandle, AppContext, Element, ElementBox, Entity, ModelHandle, MutableAppContext, Task,
|
||||||
View, ViewContext, ViewHandle,
|
View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
|
use serde::Deserialize;
|
||||||
use settings::{Settings, TerminalBlink};
|
use settings::{Settings, TerminalBlink};
|
||||||
use smol::Timer;
|
use smol::Timer;
|
||||||
use workspace::pane;
|
use workspace::pane;
|
||||||
|
@ -28,6 +29,9 @@ pub struct DeployContextMenu {
|
||||||
pub position: Vector2F,
|
pub position: Vector2F,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Default, Deserialize, PartialEq)]
|
||||||
|
pub struct SendText(String);
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
terminal,
|
terminal,
|
||||||
[
|
[
|
||||||
|
@ -43,6 +47,9 @@ actions!(
|
||||||
SearchTest
|
SearchTest
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl_actions!(terminal, [SendText]);
|
||||||
|
|
||||||
impl_internal_actions!(project_panel, [DeployContextMenu]);
|
impl_internal_actions!(project_panel, [DeployContextMenu]);
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut MutableAppContext) {
|
||||||
|
@ -53,6 +60,7 @@ pub fn init(cx: &mut MutableAppContext) {
|
||||||
cx.add_action(TerminalView::escape);
|
cx.add_action(TerminalView::escape);
|
||||||
cx.add_action(TerminalView::enter);
|
cx.add_action(TerminalView::enter);
|
||||||
//Useful terminal views
|
//Useful terminal views
|
||||||
|
cx.add_action(TerminalView::send_text);
|
||||||
cx.add_action(TerminalView::deploy_context_menu);
|
cx.add_action(TerminalView::deploy_context_menu);
|
||||||
cx.add_action(TerminalView::copy);
|
cx.add_action(TerminalView::copy);
|
||||||
cx.add_action(TerminalView::paste);
|
cx.add_action(TerminalView::paste);
|
||||||
|
@ -283,6 +291,13 @@ impl TerminalView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn send_text(&mut self, text: &SendText, cx: &mut ViewContext<Self>) {
|
||||||
|
self.clear_bel(cx);
|
||||||
|
self.terminal.update(cx, |term, _| {
|
||||||
|
term.input(text.0.to_string());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
///Synthesize the keyboard event corresponding to 'up'
|
///Synthesize the keyboard event corresponding to 'up'
|
||||||
fn up(&mut self, _: &Up, cx: &mut ViewContext<Self>) {
|
fn up(&mut self, _: &Up, cx: &mut ViewContext<Self>) {
|
||||||
self.clear_bel(cx);
|
self.clear_bel(cx);
|
||||||
|
|
Loading…
Reference in a new issue