Use new API for input handling in Terminal
This commit is contained in:
parent
f985515141
commit
f712dec4c0
1 changed files with 12 additions and 7 deletions
|
@ -10,22 +10,19 @@ use alacritty_terminal::{
|
||||||
|
|
||||||
use connection::{Event, TerminalConnection};
|
use connection::{Event, TerminalConnection};
|
||||||
use dirs::home_dir;
|
use dirs::home_dir;
|
||||||
use editor::Input;
|
|
||||||
use futures::channel::mpsc::UnboundedSender;
|
use futures::channel::mpsc::UnboundedSender;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, elements::*, keymap::Keystroke, AppContext, ClipboardItem, Entity, ModelHandle,
|
actions, elements::*, keymap::Keystroke, AppContext, ClipboardItem, Entity, ModelHandle,
|
||||||
MutableAppContext, View, ViewContext,
|
MutableAppContext, View, ViewContext,
|
||||||
};
|
};
|
||||||
use modal::deploy_modal;
|
use modal::deploy_modal;
|
||||||
|
|
||||||
use project::{LocalWorktree, Project, ProjectPath};
|
use project::{LocalWorktree, Project, ProjectPath};
|
||||||
use settings::{Settings, WorkingDirectory};
|
use settings::{Settings, WorkingDirectory};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
use terminal_element::TerminalEl;
|
||||||
use workspace::{Item, Workspace};
|
use workspace::{Item, Workspace};
|
||||||
|
|
||||||
use crate::terminal_element::TerminalEl;
|
|
||||||
|
|
||||||
const DEBUG_TERMINAL_WIDTH: f32 = 1000.; //This needs to be wide enough that the prompt can fill the whole space.
|
const DEBUG_TERMINAL_WIDTH: f32 = 1000.; //This needs to be wide enough that the prompt can fill the whole space.
|
||||||
const DEBUG_TERMINAL_HEIGHT: f32 = 200.;
|
const DEBUG_TERMINAL_HEIGHT: f32 = 200.;
|
||||||
const DEBUG_CELL_WIDTH: f32 = 5.;
|
const DEBUG_CELL_WIDTH: f32 = 5.;
|
||||||
|
@ -67,7 +64,6 @@ pub fn init(cx: &mut MutableAppContext) {
|
||||||
cx.add_action(deploy_modal);
|
cx.add_action(deploy_modal);
|
||||||
cx.add_action(Terminal::copy);
|
cx.add_action(Terminal::copy);
|
||||||
cx.add_action(Terminal::paste);
|
cx.add_action(Terminal::paste);
|
||||||
cx.add_action(Terminal::input);
|
|
||||||
cx.add_action(Terminal::clear);
|
cx.add_action(Terminal::clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,10 +150,10 @@ impl Terminal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn input(&mut self, Input(text): &Input, cx: &mut ViewContext<Self>) {
|
fn input(&mut self, text: &str, cx: &mut ViewContext<Self>) {
|
||||||
self.connection.update(cx, |connection, _| {
|
self.connection.update(cx, |connection, _| {
|
||||||
//TODO: This is probably not encoding UTF8 correctly (see alacritty/src/input.rs:L825-837)
|
//TODO: This is probably not encoding UTF8 correctly (see alacritty/src/input.rs:L825-837)
|
||||||
connection.write_to_pty(text.clone());
|
connection.write_to_pty(text.to_string());
|
||||||
});
|
});
|
||||||
|
|
||||||
if self.has_bell {
|
if self.has_bell {
|
||||||
|
@ -265,6 +261,15 @@ impl View for Terminal {
|
||||||
}
|
}
|
||||||
context
|
context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn replace_text_in_range(
|
||||||
|
&mut self,
|
||||||
|
_: Option<std::ops::Range<usize>>,
|
||||||
|
text: &str,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) {
|
||||||
|
self.input(text, cx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Item for Terminal {
|
impl Item for Terminal {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue