From f712dec4c04433dd9e6c3a1f910927199d7f7377 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 20 Jul 2022 17:33:37 -0700 Subject: [PATCH] Use new API for input handling in Terminal --- crates/terminal/src/terminal.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index 26880258daff3a2bc3e94d35d297a817038b7a9d..a41b8f5ad3994e587ed6eab216b93b59f080bf14 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -10,22 +10,19 @@ use alacritty_terminal::{ use connection::{Event, TerminalConnection}; use dirs::home_dir; -use editor::Input; use futures::channel::mpsc::UnboundedSender; use gpui::{ actions, elements::*, keymap::Keystroke, AppContext, ClipboardItem, Entity, ModelHandle, MutableAppContext, View, ViewContext, }; use modal::deploy_modal; - use project::{LocalWorktree, Project, ProjectPath}; use settings::{Settings, WorkingDirectory}; use smallvec::SmallVec; use std::path::{Path, PathBuf}; +use terminal_element::TerminalEl; 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_HEIGHT: f32 = 200.; const DEBUG_CELL_WIDTH: f32 = 5.; @@ -67,7 +64,6 @@ pub fn init(cx: &mut MutableAppContext) { cx.add_action(deploy_modal); cx.add_action(Terminal::copy); cx.add_action(Terminal::paste); - cx.add_action(Terminal::input); cx.add_action(Terminal::clear); } @@ -154,10 +150,10 @@ impl Terminal { } } - fn input(&mut self, Input(text): &Input, cx: &mut ViewContext) { + fn input(&mut self, text: &str, cx: &mut ViewContext) { self.connection.update(cx, |connection, _| { //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 { @@ -265,6 +261,15 @@ impl View for Terminal { } context } + + fn replace_text_in_range( + &mut self, + _: Option>, + text: &str, + cx: &mut ViewContext, + ) { + self.input(text, cx); + } } impl Item for Terminal {