From 79b7dcb596ce4c826b40eda75663f5c06d67db0b Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 13 Jul 2022 16:32:25 -0700 Subject: [PATCH 1/8] Basic keybindings infra done --- assets/keymaps/default.json | 10 +- crates/terminal/Cargo.toml | 4 +- crates/terminal/src/connection.rs | 19 +- crates/terminal/src/connection/events.rs | 260 +++++++++++++++++++++++ crates/terminal/src/terminal_element.rs | 22 +- 5 files changed, 299 insertions(+), 16 deletions(-) create mode 100644 crates/terminal/src/connection/events.rs diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index 0e13bae79487d7d972de09fe007567c33b6a358c..ae9eb3c57a6be627566382a67d4db17d23bcf590 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -409,7 +409,6 @@ "bindings": { "ctrl-c": "terminal::Sigint", "escape": "terminal::Escape", - "shift-escape": "terminal::DeployModal", "ctrl-d": "terminal::Quit", "backspace": "terminal::Del", "enter": "terminal::Return", @@ -419,8 +418,13 @@ "down": "terminal::Down", "tab": "terminal::Tab", "cmd-v": "terminal::Paste", - "cmd-c": "terminal::Copy", - "ctrl-l": "terminal::Clear" + "cmd-c": "terminal::Copy" + } + }, + { + "context": "ModalTerminal", + "bindings": { + "shift-escape": "terminal::DeployModal" } } ] \ No newline at end of file diff --git a/crates/terminal/Cargo.toml b/crates/terminal/Cargo.toml index e3a458327d4b5b323fff6e29edcc010edd986832..876c28a273dcec88b2b14817c2b6646b03db7c46 100644 --- a/crates/terminal/Cargo.toml +++ b/crates/terminal/Cargo.toml @@ -27,6 +27,4 @@ dirs = "4.0.0" gpui = { path = "../gpui", features = ["test-support"] } client = { path = "../client", features = ["test-support"]} project = { path = "../project", features = ["test-support"]} -workspace = { path = "../workspace", features = ["test-support"] } - - +workspace = { path = "../workspace", features = ["test-support"] } \ No newline at end of file diff --git a/crates/terminal/src/connection.rs b/crates/terminal/src/connection.rs index 800791370cdf63efee8be8ae7b5095b87da7a7aa..a1326162f7167eb82a064351a1461012b08c5ab7 100644 --- a/crates/terminal/src/connection.rs +++ b/crates/terminal/src/connection.rs @@ -1,3 +1,5 @@ +mod events; + use alacritty_terminal::{ ansi::{ClearMode, Handler}, config::{Config, PtyConfig}, @@ -13,13 +15,15 @@ use futures::{channel::mpsc::unbounded, StreamExt}; use settings::Settings; use std::{collections::HashMap, path::PathBuf, sync::Arc}; -use gpui::{ClipboardItem, CursorStyle, Entity, ModelContext}; +use gpui::{ClipboardItem, CursorStyle, Entity, KeyDownEvent, ModelContext}; use crate::{ color_translation::{get_color_at_index, to_alac_rgb}, ZedListener, }; +use self::events::to_esc_str; + const DEFAULT_TITLE: &str = "Terminal"; ///Upward flowing events, for changing the title and such @@ -182,6 +186,19 @@ impl TerminalConnection { self.write_to_pty("\x0c".into()); self.term.lock().clear_screen(ClearMode::Saved); } + + pub fn try_keystroke(&mut self, key_down: &KeyDownEvent) -> bool { + let guard = self.term.lock(); + let mode = guard.mode(); + let esc = to_esc_str(key_down, mode); + drop(guard); + if esc.is_some() { + self.write_to_pty(esc.unwrap()); + true + } else { + false + } + } } impl Drop for TerminalConnection { diff --git a/crates/terminal/src/connection/events.rs b/crates/terminal/src/connection/events.rs new file mode 100644 index 0000000000000000000000000000000000000000..ee61d69d5416fb5167f28953bdbd4ff3d2a11eb4 --- /dev/null +++ b/crates/terminal/src/connection/events.rs @@ -0,0 +1,260 @@ +use alacritty_terminal::term::TermMode; +use gpui::{keymap::Keystroke, KeyDownEvent}; + +pub enum ModifierCombinations { + None, + Alt, + Ctrl, + Shift, + Other, +} + +impl ModifierCombinations { + fn new(ks: &Keystroke) -> Self { + match (ks.alt, ks.ctrl, ks.shift, ks.cmd) { + (false, false, false, false) => ModifierCombinations::None, + (true, false, false, false) => ModifierCombinations::Alt, + (false, true, false, false) => ModifierCombinations::Ctrl, + (false, false, true, false) => ModifierCombinations::Shift, + _ => ModifierCombinations::Other, + } + } +} + +pub fn to_esc_str(event: &KeyDownEvent, mode: &TermMode) -> Option { + let modifiers = ModifierCombinations::new(&event.keystroke); + + // Manual Bindings including modifiers + let manual_esc_str = match (event.keystroke.key.as_ref(), modifiers) { + ("l", ModifierCombinations::Ctrl) => Some("\x0c".to_string()), + ("tab", ModifierCombinations::Shift) => Some("\x1b[Z".to_string()), + ("backspace", ModifierCombinations::Alt) => Some("\x1b\x7f".to_string()), + ("backspace", ModifierCombinations::Shift) => Some("\x7f".to_string()), + ("home", ModifierCombinations::Shift) if mode.contains(TermMode::ALT_SCREEN) => { + Some("\x1b[1;2H".to_string()) + } + ("end", ModifierCombinations::Shift) if mode.contains(TermMode::ALT_SCREEN) => { + Some("\x1b[1;2F".to_string()) + } + ("pageup", ModifierCombinations::Shift) if mode.contains(TermMode::ALT_SCREEN) => { + Some("\x1b[5;2~".to_string()) + } + ("pagedown", ModifierCombinations::Shift) if mode.contains(TermMode::ALT_SCREEN) => { + Some("\x1b[6;2~".to_string()) + } + ("home", ModifierCombinations::None) if mode.contains(TermMode::APP_CURSOR) => { + Some("\x1bOH".to_string()) + } + ("home", ModifierCombinations::None) if !mode.contains(TermMode::APP_CURSOR) => { + Some("\x1b[H".to_string()) + } + ("end", ModifierCombinations::None) if mode.contains(TermMode::APP_CURSOR) => { + Some("\x1bOF".to_string()) + } + ("end", ModifierCombinations::None) if !mode.contains(TermMode::APP_CURSOR) => { + Some("\x1b[F".to_string()) + } + ("up", ModifierCombinations::None) if mode.contains(TermMode::APP_CURSOR) => { + Some("\x1bOA".to_string()) + } + ("up", ModifierCombinations::None) if !mode.contains(TermMode::APP_CURSOR) => { + Some("\x1b[A".to_string()) + } + ("down", ModifierCombinations::None) if mode.contains(TermMode::APP_CURSOR) => { + Some("\x1bOB".to_string()) + } + ("down", ModifierCombinations::None) if !mode.contains(TermMode::APP_CURSOR) => { + Some("\x1b[B".to_string()) + } + ("right", ModifierCombinations::None) if mode.contains(TermMode::APP_CURSOR) => { + Some("\x1bOC".to_string()) + } + ("right", ModifierCombinations::None) if !mode.contains(TermMode::APP_CURSOR) => { + Some("\x1b[C".to_string()) + } + ("left", ModifierCombinations::None) if mode.contains(TermMode::APP_CURSOR) => { + Some("\x1bOD".to_string()) + } + ("left", ModifierCombinations::None) if !mode.contains(TermMode::APP_CURSOR) => { + Some("\x1b[D".to_string()) + } + ("back", ModifierCombinations::None) => Some("\x7f".to_string()), + ("insert", ModifierCombinations::None) => Some("\x1b[2~".to_string()), + ("delete", ModifierCombinations::None) => Some("\x1b[3~".to_string()), + ("pageup", ModifierCombinations::None) => Some("\x1b[5~".to_string()), + ("pagedown", ModifierCombinations::None) => Some("\x1b[6~".to_string()), + ("f1", ModifierCombinations::None) => Some("\x1bOP".to_string()), + ("f2", ModifierCombinations::None) => Some("\x1bOQ".to_string()), + ("f3", ModifierCombinations::None) => Some("\x1bOR".to_string()), + ("f4", ModifierCombinations::None) => Some("\x1bOS".to_string()), + ("f5", ModifierCombinations::None) => Some("\x1b[15~".to_string()), + ("f6", ModifierCombinations::None) => Some("\x1b[17~".to_string()), + ("f7", ModifierCombinations::None) => Some("\x1b[18~".to_string()), + ("f8", ModifierCombinations::None) => Some("\x1b[19~".to_string()), + ("f9", ModifierCombinations::None) => Some("\x1b[20~".to_string()), + ("f10", ModifierCombinations::None) => Some("\x1b[21~".to_string()), + ("f11", ModifierCombinations::None) => Some("\x1b[23~".to_string()), + ("f12", ModifierCombinations::None) => Some("\x1b[24~".to_string()), + ("f13", ModifierCombinations::None) => Some("\x1b[25~".to_string()), + ("f14", ModifierCombinations::None) => Some("\x1b[26~".to_string()), + ("f15", ModifierCombinations::None) => Some("\x1b[28~".to_string()), + ("f16", ModifierCombinations::None) => Some("\x1b[29~".to_string()), + ("f17", ModifierCombinations::None) => Some("\x1b[31~".to_string()), + ("f18", ModifierCombinations::None) => Some("\x1b[32~".to_string()), + ("f19", ModifierCombinations::None) => Some("\x1b[33~".to_string()), + ("f20", ModifierCombinations::None) => Some("\x1b[34~".to_string()), + // NumpadEnter, Action::Esc("\n".into()); + _ => None, + }; + if manual_esc_str.is_some() { + return manual_esc_str; + } + + // Automated bindings applying modifiers + let modifier_code = modifier_code(&event.keystroke); + let modified_esc_str = match event.keystroke.key.as_ref() { + "up" => Some(format!("\x1b[1;{}A", modifier_code)), + "down" => Some(format!("\x1b[1;{}B", modifier_code)), + "right" => Some(format!("\x1b[1;{}C", modifier_code)), + "left" => Some(format!("\x1b[1;{}D", modifier_code)), + "f1" => Some(format!("\x1b[1;{}P", modifier_code)), + "f2" => Some(format!("\x1b[1;{}Q", modifier_code)), + "f3" => Some(format!("\x1b[1;{}R", modifier_code)), + "f4" => Some(format!("\x1b[1;{}S", modifier_code)), + "F5" => Some(format!("\x1b[15;{}~", modifier_code)), + "f6" => Some(format!("\x1b[17;{}~", modifier_code)), + "f7" => Some(format!("\x1b[18;{}~", modifier_code)), + "f8" => Some(format!("\x1b[19;{}~", modifier_code)), + "f9" => Some(format!("\x1b[20;{}~", modifier_code)), + "f10" => Some(format!("\x1b[21;{}~", modifier_code)), + "f11" => Some(format!("\x1b[23;{}~", modifier_code)), + "f12" => Some(format!("\x1b[24;{}~", modifier_code)), + "f13" => Some(format!("\x1b[25;{}~", modifier_code)), + "f14" => Some(format!("\x1b[26;{}~", modifier_code)), + "f15" => Some(format!("\x1b[28;{}~", modifier_code)), + "f16" => Some(format!("\x1b[29;{}~", modifier_code)), + "f17" => Some(format!("\x1b[31;{}~", modifier_code)), + "f18" => Some(format!("\x1b[32;{}~", modifier_code)), + "f19" => Some(format!("\x1b[33;{}~", modifier_code)), + "f20" => Some(format!("\x1b[34;{}~", modifier_code)), + _ if modifier_code == 2 => None, + "insert" => Some(format!("\x1b[2;{}~", modifier_code)), + "pageup" => Some(format!("\x1b[5;{}~", modifier_code)), + "pagedown" => Some(format!("\x1b[6;{}~", modifier_code)), + "end" => Some(format!("\x1b[1;{}F", modifier_code)), + "home" => Some(format!("\x1b[1;{}H", modifier_code)), + _ => None, + }; + if modified_esc_str.is_some() { + return modified_esc_str; + } + + // Fallback to keystroke input sent directly + return event.input.clone(); +} + +/* +So, to match alacritty keyboard handling, we need to check APP_CURSOR, and ALT_SCREEN + +And we need to convert the strings that GPUI returns to keys + +And we need a way of easily declaring and matching a modifier pattern on those keys + +And we need to block writing the input to the pty if any of these match + +And I need to figure out how to express this in a cross platform way + +And a way of optionally interfacing this with actions for rebinding in defaults.json + +Design notes: +I would like terminal mode checking to be concealed behind the TerminalConnection in as many ways as possible. +Alacritty has a lot of stuff intermixed for it's input handling. TerminalConnection should be in charge +of anything that needs to conform to a standard that isn't handled by Term, e.g.: +- Reporting mouse events correctly. +- Reporting scrolls -> Depends on MOUSE_MODE, ALT_SCREEN, and ALTERNATE_SCROLL, etc. +- Correctly bracketing a paste +- Storing changed colors +- Focus change sequence + +Scrolling might be handled internally or externally, need a way to ask. Everything else should probably happen internally. + +Standards/OS compliance is in connection.rs. +This takes GPUI events and translates them to the correct terminal stuff +This means that standards compliance outside of connection should be kept to a minimum. Yes, this feels good. +Connection needs to be split up then, into a bunch of event handlers + +Punting on these by pushing them up to a scrolling element +(either on dispatch_event directly or a seperate scrollbar) + Home, ModifiersState::SHIFT, ~BindingMode::ALT_SCREEN; Action::ScrollToTop; + End, ModifiersState::SHIFT, ~BindingMode::ALT_SCREEN; Action::ScrollToBottom; + PageUp, ModifiersState::SHIFT, ~BindingMode::ALT_SCREEN; Action::ScrollPageUp; + PageDown, ModifiersState::SHIFT, ~BindingMode::ALT_SCREEN; Action::ScrollPageDown; + + + +NOTE, THE FOLLOWING HAS 2 BINDINGS: +K, ModifiersState::LOGO, Action::Esc("\x0c".into()); +K, ModifiersState::LOGO, Action::ClearHistory; => ctx.terminal_mut().clear_screen(ClearMode::Saved), + +*/ + +/// Code Modifiers +/// ---------+--------------------------- +/// 2 | Shift +/// 3 | Alt +/// 4 | Shift + Alt +/// 5 | Control +/// 6 | Shift + Control +/// 7 | Alt + Control +/// 8 | Shift + Alt + Control +/// ---------+--------------------------- +/// from: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-PC-Style-Function-Keys +fn modifier_code(keystroke: &Keystroke) -> u32 { + let mut modifier_code = 0; + if keystroke.shift { + modifier_code |= 1; + } + if keystroke.alt { + modifier_code |= 1 << 1; + } + if keystroke.ctrl { + modifier_code |= 1 << 2; + } + modifier_code + 1 +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_match_alacritty_keybindings() { + // let bindings = alacritty::config::bindings::default_key_bindings(); + //TODO + } + + #[test] + fn test_modifier_code_calc() { + // Code Modifiers + // ---------+--------------------------- + // 2 | Shift + // 3 | Alt + // 4 | Shift + Alt + // 5 | Control + // 6 | Shift + Control + // 7 | Alt + Control + // 8 | Shift + Alt + Control + // ---------+--------------------------- + // from: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-PC-Style-Function-Keys + // assert_eq!(2, modifier_code(Keystroke::parse("shift-A").unwrap())); + assert_eq!(3, modifier_code(&Keystroke::parse("alt-A").unwrap())); + assert_eq!(4, modifier_code(&Keystroke::parse("shift-alt-A").unwrap())); + assert_eq!(5, modifier_code(&Keystroke::parse("ctrl-A").unwrap())); + assert_eq!(6, modifier_code(&Keystroke::parse("shift-ctrl-A").unwrap())); + assert_eq!(7, modifier_code(&Keystroke::parse("alt-ctrl-A").unwrap())); + assert_eq!( + 8, + modifier_code(&Keystroke::parse("shift-ctrl-alt-A").unwrap()) + ); + } +} diff --git a/crates/terminal/src/terminal_element.rs b/crates/terminal/src/terminal_element.rs index 09dce20f97d10af3d9e8d3a082485435eb1aa156..e93a68fcb71215784d1274bda07d9f76d1cd6c1c 100644 --- a/crates/terminal/src/terminal_element.rs +++ b/crates/terminal/src/terminal_element.rs @@ -9,7 +9,7 @@ use alacritty_terminal::{ }, Term, }; -use editor::{Cursor, CursorShape, HighlightedRange, HighlightedRangeLine, Input}; +use editor::{Cursor, CursorShape, HighlightedRange, HighlightedRangeLine}; use gpui::{ color::Color, elements::*, @@ -389,14 +389,18 @@ impl Element for TerminalEl { cx.dispatch_action(ScrollTerminal(vertical_scroll.round() as i32)); }) .is_some(), - Event::KeyDown(KeyDownEvent { - input: Some(input), .. - }) => cx - .is_parent_view_focused() - .then(|| { - cx.dispatch_action(Input(input.to_string())); - }) - .is_some(), + Event::KeyDown(e @ KeyDownEvent { .. }) => { + if !cx.is_parent_view_focused() { + return false; + } + + self.connection + .upgrade(cx.app) + .map(|connection| { + connection.update(cx.app, |connection, _| connection.try_keystroke(e)) + }) + .unwrap_or(false) + } _ => false, } } From 2e749631fea33f2afdafc310efb389d7dc78c90c Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 14 Jul 2022 16:27:02 -0700 Subject: [PATCH 2/8] Checkpoint, have caret notation implemented --- crates/terminal/src/connection/events.rs | 69 +++++++++++++++++++++++- crates/terminal/src/terminal.rs | 2 +- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/crates/terminal/src/connection/events.rs b/crates/terminal/src/connection/events.rs index ee61d69d5416fb5167f28953bdbd4ff3d2a11eb4..49e5770ea36d22e9aab356a50b20175ef89b3b5f 100644 --- a/crates/terminal/src/connection/events.rs +++ b/crates/terminal/src/connection/events.rs @@ -6,6 +6,10 @@ pub enum ModifierCombinations { Alt, Ctrl, Shift, + AltCtrl, + AltShift, + CtrlShift, + AltCtrlShift, Other, } @@ -16,6 +20,10 @@ impl ModifierCombinations { (true, false, false, false) => ModifierCombinations::Alt, (false, true, false, false) => ModifierCombinations::Ctrl, (false, false, true, false) => ModifierCombinations::Shift, + (true, true, false, false) => ModifierCombinations::AltCtrl, + (true, false, true, false) => ModifierCombinations::AltShift, + (false, true, true, false) => ModifierCombinations::CtrlShift, + (true, true, true, false) => ModifierCombinations::AltCtrlShift, _ => ModifierCombinations::Other, } } @@ -26,7 +34,6 @@ pub fn to_esc_str(event: &KeyDownEvent, mode: &TermMode) -> Option { // Manual Bindings including modifiers let manual_esc_str = match (event.keystroke.key.as_ref(), modifiers) { - ("l", ModifierCombinations::Ctrl) => Some("\x0c".to_string()), ("tab", ModifierCombinations::Shift) => Some("\x1b[Z".to_string()), ("backspace", ModifierCombinations::Alt) => Some("\x1b\x7f".to_string()), ("backspace", ModifierCombinations::Shift) => Some("\x7f".to_string()), @@ -104,6 +111,66 @@ pub fn to_esc_str(event: &KeyDownEvent, mode: &TermMode) -> Option { ("f19", ModifierCombinations::None) => Some("\x1b[33~".to_string()), ("f20", ModifierCombinations::None) => Some("\x1b[34~".to_string()), // NumpadEnter, Action::Esc("\n".into()); + //Make all mappings for caret notation keys! + ("a", ModifierCombinations::Ctrl) => Some("\x01".to_string()), //1 + ("A", ModifierCombinations::CtrlShift) => Some("\x01".to_string()), //1 + ("b", ModifierCombinations::Ctrl) => Some("\x02".to_string()), //2 + ("B", ModifierCombinations::CtrlShift) => Some("\x02".to_string()), //2 + ("c", ModifierCombinations::Ctrl) => Some("\x03".to_string()), //3 + ("C", ModifierCombinations::CtrlShift) => Some("\x03".to_string()), //3 + ("d", ModifierCombinations::Ctrl) => Some("\x04".to_string()), //4 + ("D", ModifierCombinations::CtrlShift) => Some("\x04".to_string()), //4 + ("e", ModifierCombinations::Ctrl) => Some("\x05".to_string()), //5 + ("E", ModifierCombinations::CtrlShift) => Some("\x05".to_string()), //5 + ("f", ModifierCombinations::Ctrl) => Some("\x06".to_string()), //6 + ("F", ModifierCombinations::CtrlShift) => Some("\x06".to_string()), //6 + ("g", ModifierCombinations::Ctrl) => Some("\x07".to_string()), //7 + ("G", ModifierCombinations::CtrlShift) => Some("\x07".to_string()), //7 + ("h", ModifierCombinations::Ctrl) => Some("\x08".to_string()), //8 + ("H", ModifierCombinations::CtrlShift) => Some("\x08".to_string()), //8 + ("i", ModifierCombinations::Ctrl) => Some("\x09".to_string()), //9 + ("I", ModifierCombinations::CtrlShift) => Some("\x09".to_string()), //9 + ("j", ModifierCombinations::Ctrl) => Some("\x0a".to_string()), //10 + ("J", ModifierCombinations::CtrlShift) => Some("\x0a".to_string()), //10 + ("k", ModifierCombinations::Ctrl) => Some("\x0b".to_string()), //11 + ("K", ModifierCombinations::CtrlShift) => Some("\x0b".to_string()), //11 + ("l", ModifierCombinations::Ctrl) => Some("\x0c".to_string()), //12 + ("L", ModifierCombinations::CtrlShift) => Some("\x0c".to_string()), //12 + ("m", ModifierCombinations::Ctrl) => Some("\x0d".to_string()), //13 + ("M", ModifierCombinations::CtrlShift) => Some("\x0d".to_string()), //13 + ("n", ModifierCombinations::Ctrl) => Some("\x0e".to_string()), //14 + ("N", ModifierCombinations::CtrlShift) => Some("\x0e".to_string()), //14 + ("o", ModifierCombinations::Ctrl) => Some("\x0f".to_string()), //15 + ("O", ModifierCombinations::CtrlShift) => Some("\x0f".to_string()), //15 + ("p", ModifierCombinations::Ctrl) => Some("\x10".to_string()), //16 + ("P", ModifierCombinations::CtrlShift) => Some("\x10".to_string()), //16 + ("q", ModifierCombinations::Ctrl) => Some("\x11".to_string()), //17 + ("Q", ModifierCombinations::CtrlShift) => Some("\x11".to_string()), //17 + ("r", ModifierCombinations::Ctrl) => Some("\x12".to_string()), //18 + ("R", ModifierCombinations::CtrlShift) => Some("\x12".to_string()), //18 + ("s", ModifierCombinations::Ctrl) => Some("\x13".to_string()), //19 + ("S", ModifierCombinations::CtrlShift) => Some("\x13".to_string()), //19 + ("t", ModifierCombinations::Ctrl) => Some("\x14".to_string()), //20 + ("T", ModifierCombinations::CtrlShift) => Some("\x14".to_string()), //20 + ("u", ModifierCombinations::Ctrl) => Some("\x15".to_string()), //21 + ("U", ModifierCombinations::CtrlShift) => Some("\x15".to_string()), //21 + ("v", ModifierCombinations::Ctrl) => Some("\x16".to_string()), //22 + ("V", ModifierCombinations::CtrlShift) => Some("\x16".to_string()), //22 + ("w", ModifierCombinations::Ctrl) => Some("\x17".to_string()), //23 + ("W", ModifierCombinations::CtrlShift) => Some("\x17".to_string()), //23 + ("x", ModifierCombinations::Ctrl) => Some("\x18".to_string()), //24 + ("X", ModifierCombinations::CtrlShift) => Some("\x18".to_string()), //24 + ("y", ModifierCombinations::Ctrl) => Some("\x19".to_string()), //25 + ("Y", ModifierCombinations::CtrlShift) => Some("\x19".to_string()), //25 + ("z", ModifierCombinations::Ctrl) => Some("\x1a".to_string()), //26 + ("Z", ModifierCombinations::CtrlShift) => Some("\x1a".to_string()), //26 + ("@", ModifierCombinations::Ctrl) => Some("\x00".to_string()), //0 + ("[", ModifierCombinations::Ctrl) => Some("\x1b".to_string()), //27 + ("\\", ModifierCombinations::Ctrl) => Some("\x1c".to_string()), //28 + ("]", ModifierCombinations::Ctrl) => Some("\x1d".to_string()), //29 + ("^", ModifierCombinations::Ctrl) => Some("\x1e".to_string()), //30 + ("_", ModifierCombinations::Ctrl) => Some("\x1f".to_string()), //31 + ("?", ModifierCombinations::Ctrl) => Some("\x7f".to_string()), //127 _ => None, }; if manual_esc_str.is_some() { diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index 12c092d6e6ffd78fb326aa1eb5e79f534fb41f38..fcf1e7db30770002a65b1f8c0d421b7776411483 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -66,7 +66,7 @@ actions!( Paste, Deploy, Quit, - DeployModal, + DeployModal ] ); impl_internal_actions!(terminal, [ScrollTerminal]); From 98651c4b866986096a86b867532f8fa294b01bfe Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 14 Jul 2022 17:21:30 -0700 Subject: [PATCH 3/8] New key mapping system in place and working --- assets/keymaps/default.json | 16 ++-- crates/terminal/src/connection.rs | 7 +- crates/terminal/src/connection/events.rs | 45 ++++++--- crates/terminal/src/terminal.rs | 116 ++++++----------------- crates/terminal/src/terminal_element.rs | 41 +++----- 5 files changed, 84 insertions(+), 141 deletions(-) diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index ae9eb3c57a6be627566382a67d4db17d23bcf590..11893847ade8d51398974e557bb7052927d004b1 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -407,18 +407,16 @@ { "context": "Terminal", "bindings": { - "ctrl-c": "terminal::Sigint", - "escape": "terminal::Escape", - "ctrl-d": "terminal::Quit", - "backspace": "terminal::Del", - "enter": "terminal::Return", - "left": "terminal::Left", - "right": "terminal::Right", + // Overrides for global bindings, remove at your own risk: "up": "terminal::Up", "down": "terminal::Down", - "tab": "terminal::Tab", + "escape": "terminal::Escape", + "enter": "terminal::Enter", + "ctrl-c": "terminal::CtrlC", + // Useful terminal actions: + "cmd-c": "terminal::Copy", "cmd-v": "terminal::Paste", - "cmd-c": "terminal::Copy" + "cmd-k": "terminal::Clear" } }, { diff --git a/crates/terminal/src/connection.rs b/crates/terminal/src/connection.rs index a1326162f7167eb82a064351a1461012b08c5ab7..7babe45d93cc3659dbd459a835374449d1ac46b0 100644 --- a/crates/terminal/src/connection.rs +++ b/crates/terminal/src/connection.rs @@ -15,7 +15,7 @@ use futures::{channel::mpsc::unbounded, StreamExt}; use settings::Settings; use std::{collections::HashMap, path::PathBuf, sync::Arc}; -use gpui::{ClipboardItem, CursorStyle, Entity, KeyDownEvent, ModelContext}; +use gpui::{keymap::Keystroke, ClipboardItem, CursorStyle, Entity, ModelContext}; use crate::{ color_translation::{get_color_at_index, to_alac_rgb}, @@ -187,10 +187,11 @@ impl TerminalConnection { self.term.lock().clear_screen(ClearMode::Saved); } - pub fn try_keystroke(&mut self, key_down: &KeyDownEvent) -> bool { + pub fn try_keystroke(&mut self, keystroke: &Keystroke) -> bool { let guard = self.term.lock(); let mode = guard.mode(); - let esc = to_esc_str(key_down, mode); + let esc = to_esc_str(keystroke, mode); + dbg!(&esc); drop(guard); if esc.is_some() { self.write_to_pty(esc.unwrap()); diff --git a/crates/terminal/src/connection/events.rs b/crates/terminal/src/connection/events.rs index 49e5770ea36d22e9aab356a50b20175ef89b3b5f..cf0163e558dd24a9233cec692b004cd1d901a8f7 100644 --- a/crates/terminal/src/connection/events.rs +++ b/crates/terminal/src/connection/events.rs @@ -1,15 +1,12 @@ use alacritty_terminal::term::TermMode; -use gpui::{keymap::Keystroke, KeyDownEvent}; +use gpui::keymap::Keystroke; pub enum ModifierCombinations { None, Alt, Ctrl, Shift, - AltCtrl, - AltShift, CtrlShift, - AltCtrlShift, Other, } @@ -20,20 +17,24 @@ impl ModifierCombinations { (true, false, false, false) => ModifierCombinations::Alt, (false, true, false, false) => ModifierCombinations::Ctrl, (false, false, true, false) => ModifierCombinations::Shift, - (true, true, false, false) => ModifierCombinations::AltCtrl, - (true, false, true, false) => ModifierCombinations::AltShift, (false, true, true, false) => ModifierCombinations::CtrlShift, - (true, true, true, false) => ModifierCombinations::AltCtrlShift, _ => ModifierCombinations::Other, } } } -pub fn to_esc_str(event: &KeyDownEvent, mode: &TermMode) -> Option { - let modifiers = ModifierCombinations::new(&event.keystroke); +pub fn to_esc_str(keystroke: &Keystroke, mode: &TermMode) -> Option { + let modifiers = ModifierCombinations::new(&keystroke); // Manual Bindings including modifiers - let manual_esc_str = match (event.keystroke.key.as_ref(), modifiers) { + let manual_esc_str = match (keystroke.key.as_ref(), modifiers) { + //Basic special keys + ("space", ModifierCombinations::None) => Some(" ".to_string()), + ("tab", ModifierCombinations::None) => Some("\x09".to_string()), + ("escape", ModifierCombinations::None) => Some("\x1b".to_string()), + ("enter", ModifierCombinations::None) => Some("\x0d".to_string()), + ("backspace", ModifierCombinations::None) => Some("\x7f".to_string()), + //Interesting escape codes ("tab", ModifierCombinations::Shift) => Some("\x1b[Z".to_string()), ("backspace", ModifierCombinations::Alt) => Some("\x1b\x7f".to_string()), ("backspace", ModifierCombinations::Shift) => Some("\x7f".to_string()), @@ -111,7 +112,7 @@ pub fn to_esc_str(event: &KeyDownEvent, mode: &TermMode) -> Option { ("f19", ModifierCombinations::None) => Some("\x1b[33~".to_string()), ("f20", ModifierCombinations::None) => Some("\x1b[34~".to_string()), // NumpadEnter, Action::Esc("\n".into()); - //Make all mappings for caret notation keys! + //Mappings for caret notation keys ("a", ModifierCombinations::Ctrl) => Some("\x01".to_string()), //1 ("A", ModifierCombinations::CtrlShift) => Some("\x01".to_string()), //1 ("b", ModifierCombinations::Ctrl) => Some("\x02".to_string()), //2 @@ -178,8 +179,8 @@ pub fn to_esc_str(event: &KeyDownEvent, mode: &TermMode) -> Option { } // Automated bindings applying modifiers - let modifier_code = modifier_code(&event.keystroke); - let modified_esc_str = match event.keystroke.key.as_ref() { + let modifier_code = modifier_code(&keystroke); + let modified_esc_str = match keystroke.key.as_ref() { "up" => Some(format!("\x1b[1;{}A", modifier_code)), "down" => Some(format!("\x1b[1;{}B", modifier_code)), "right" => Some(format!("\x1b[1;{}C", modifier_code)), @@ -217,10 +218,26 @@ pub fn to_esc_str(event: &KeyDownEvent, mode: &TermMode) -> Option { } // Fallback to keystroke input sent directly - return event.input.clone(); + if keystroke.key.chars().count() == 1 { + dbg!("This should catch space", &keystroke.key); + return Some(keystroke.key.clone()); + } else { + None + } } /* +New keybindings test plan: + +Is the terminal still usable? YES! +Do ctrl-shift-[X] and ctrl-[x] do the same thing? I THINK SO +Does ctrl-l work? YES +Does tab work? YES +Do all the global overrides (up, down, enter, escape, ctrl-c) work? => YES +Space also doesn't work YES! + + + So, to match alacritty keyboard handling, we need to check APP_CURSOR, and ALT_SCREEN And we need to convert the strings that GPUI returns to keys diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index fcf1e7db30770002a65b1f8c0d421b7776411483..96db9aa03445da42f269f74388fdeac292ed5fdf 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -5,7 +5,6 @@ pub mod terminal_element; use alacritty_terminal::{ event::{Event as AlacTermEvent, EventListener}, - grid::Scroll, term::SizeInfo, }; @@ -14,7 +13,7 @@ use dirs::home_dir; use editor::Input; use futures::channel::mpsc::UnboundedSender; use gpui::{ - actions, elements::*, impl_internal_actions, AppContext, ClipboardItem, Entity, ModelHandle, + actions, elements::*, keymap::Keystroke, AppContext, ClipboardItem, Entity, ModelHandle, MutableAppContext, View, ViewContext, }; use modal::deploy_modal; @@ -27,16 +26,6 @@ use workspace::{Item, Workspace}; use crate::terminal_element::TerminalEl; -//ASCII Control characters on a keyboard -const ETX_CHAR: char = 3_u8 as char; //'End of text', the control code for 'ctrl-c' -const TAB_CHAR: char = 9_u8 as char; -const CARRIAGE_RETURN_CHAR: char = 13_u8 as char; -const ESC_CHAR: char = 27_u8 as char; // == \x1b -const DEL_CHAR: char = 127_u8 as char; -const LEFT_SEQ: &str = "\x1b[D"; -const RIGHT_SEQ: &str = "\x1b[C"; -const UP_SEQ: &str = "\x1b[A"; -const DOWN_SEQ: &str = "\x1b[B"; 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.; @@ -52,44 +41,34 @@ pub struct ScrollTerminal(pub i32); actions!( terminal, [ - Sigint, - Escape, - Del, - Return, - Left, - Right, + Deploy, Up, Down, - Tab, + CtrlC, + Escape, + Enter, Clear, Copy, Paste, - Deploy, - Quit, DeployModal ] ); -impl_internal_actions!(terminal, [ScrollTerminal]); ///Initialize and register all of our action handlers pub fn init(cx: &mut MutableAppContext) { - cx.add_action(Terminal::deploy); - cx.add_action(Terminal::send_sigint); - cx.add_action(Terminal::escape); - cx.add_action(Terminal::quit); - cx.add_action(Terminal::del); - cx.add_action(Terminal::carriage_return); - cx.add_action(Terminal::left); - cx.add_action(Terminal::right); + //Global binding overrrides + cx.add_action(Terminal::send_ctrl_c); cx.add_action(Terminal::up); cx.add_action(Terminal::down); - cx.add_action(Terminal::tab); + cx.add_action(Terminal::escape); + cx.add_action(Terminal::enter); + //Useful terminal actions + cx.add_action(Terminal::deploy); + cx.add_action(deploy_modal); cx.add_action(Terminal::copy); cx.add_action(Terminal::paste); - cx.add_action(Terminal::scroll_terminal); cx.add_action(Terminal::input); cx.add_action(Terminal::clear); - cx.add_action(deploy_modal); } ///A translation struct for Alacritty to communicate with us from their event loop @@ -168,15 +147,6 @@ impl Terminal { } } - ///Scroll the terminal. This locks the terminal - fn scroll_terminal(&mut self, scroll: &ScrollTerminal, cx: &mut ViewContext) { - self.connection - .read(cx) - .term - .lock() - .scroll_display(Scroll::Delta(scroll.0)); - } - fn input(&mut self, Input(text): &Input, cx: &mut ViewContext) { self.connection.update(cx, |connection, _| { //TODO: This is probably not encoding UTF8 correctly (see alacritty/src/input.rs:L825-837) @@ -200,11 +170,6 @@ impl Terminal { workspace.add_item(Box::new(cx.add_view(|cx| Terminal::new(wd, false, cx))), cx); } - ///Tell Zed to close us - fn quit(&mut self, _: &Quit, cx: &mut ViewContext) { - cx.emit(Event::CloseTerminal); - } - ///Attempt to paste the clipboard into the terminal fn copy(&mut self, _: &Copy, cx: &mut ViewContext) { let term = self.connection.read(cx).term.lock(); @@ -224,66 +189,39 @@ impl Terminal { } } - ///Send the `up` key + ///Synthesize the keyboard event corresponding to 'up' fn up(&mut self, _: &Up, cx: &mut ViewContext) { self.connection.update(cx, |connection, _| { - connection.write_to_pty(UP_SEQ.to_string()); + connection.try_keystroke(&Keystroke::parse("up").unwrap()); }); } - ///Send the `down` key + ///Synthesize the keyboard event corresponding to 'down' fn down(&mut self, _: &Down, cx: &mut ViewContext) { self.connection.update(cx, |connection, _| { - connection.write_to_pty(DOWN_SEQ.to_string()); + connection.try_keystroke(&Keystroke::parse("down").unwrap()); }); } - ///Send the `tab` key - fn tab(&mut self, _: &Tab, cx: &mut ViewContext) { + ///Synthesize the keyboard event corresponding to 'ctrl-c' + fn send_ctrl_c(&mut self, _: &CtrlC, cx: &mut ViewContext) { self.connection.update(cx, |connection, _| { - connection.write_to_pty(TAB_CHAR.to_string()); + connection.try_keystroke(&Keystroke::parse("ctrl-c").unwrap()); }); } - ///Send `SIGINT` (`ctrl-c`) - fn send_sigint(&mut self, _: &Sigint, cx: &mut ViewContext) { - self.connection.update(cx, |connection, _| { - connection.write_to_pty(ETX_CHAR.to_string()); - }); - } - - ///Send the `escape` key + ///Synthesize the keyboard event corresponding to 'escape' fn escape(&mut self, _: &Escape, cx: &mut ViewContext) { self.connection.update(cx, |connection, _| { - connection.write_to_pty(ESC_CHAR.to_string()); - }); - } - - ///Send the `delete` key. TODO: Difference between this and backspace? - fn del(&mut self, _: &Del, cx: &mut ViewContext) { - self.connection.update(cx, |connection, _| { - connection.write_to_pty(DEL_CHAR.to_string()); - }); - } - - ///Send a carriage return. TODO: May need to check the terminal mode. - fn carriage_return(&mut self, _: &Return, cx: &mut ViewContext) { - self.connection.update(cx, |connection, _| { - connection.write_to_pty(CARRIAGE_RETURN_CHAR.to_string()); - }); - } - - //Send the `left` key - fn left(&mut self, _: &Left, cx: &mut ViewContext) { - self.connection.update(cx, |connection, _| { - connection.write_to_pty(LEFT_SEQ.to_string()); + connection.try_keystroke(&Keystroke::parse("escape").unwrap()); }); } - //Send the `right` key - fn right(&mut self, _: &Right, cx: &mut ViewContext) { + ///Synthesize the keyboard event corresponding to 'enter' + fn enter(&mut self, _: &Enter, cx: &mut ViewContext) { + dbg!("Here!"); self.connection.update(cx, |connection, _| { - connection.write_to_pty(RIGHT_SEQ.to_string()); + connection.try_keystroke(&Keystroke::parse("enter").unwrap()); }); } } @@ -476,7 +414,7 @@ mod tests { terminal.connection.update(cx, |connection, _| { connection.write_to_pty("expr 3 + 4".to_string()); }); - terminal.carriage_return(&Return, cx); + terminal.enter(&Enter, cx); }); cx.set_condition_duration(Some(Duration::from_secs(2))); @@ -501,7 +439,7 @@ mod tests { terminal.connection.update(cx, |connection, _| { connection.write_to_pty("expr 3 + 4".to_string()); }); - terminal.carriage_return(&Return, cx); + terminal.enter(&Enter, cx); }); terminal diff --git a/crates/terminal/src/terminal_element.rs b/crates/terminal/src/terminal_element.rs index e93a68fcb71215784d1274bda07d9f76d1cd6c1c..d4d2492bb85e5021b9c7b9af19dff95ead911297 100644 --- a/crates/terminal/src/terminal_element.rs +++ b/crates/terminal/src/terminal_element.rs @@ -1,5 +1,5 @@ use alacritty_terminal::{ - grid::{Dimensions, GridIterator, Indexed}, + grid::{Dimensions, GridIterator, Indexed, Scroll}, index::{Column as GridCol, Line as GridLine, Point, Side}, selection::{Selection, SelectionRange, SelectionType}, sync::FairMutex, @@ -31,9 +31,7 @@ use theme::TerminalStyle; use std::{cmp::min, ops::Range, rc::Rc, sync::Arc}; use std::{fmt::Debug, ops::Sub}; -use crate::{ - color_translation::convert_color, connection::TerminalConnection, ScrollTerminal, ZedListener, -}; +use crate::{color_translation::convert_color, connection::TerminalConnection, ZedListener}; ///Scrolling is unbearably sluggish by default. Alacritty supports a configurable ///Scroll multiplier that is set to 3 by default. This will be removed when I @@ -359,25 +357,6 @@ impl Element for TerminalEl { _paint: &mut Self::PaintState, cx: &mut gpui::EventContext, ) -> bool { - //The problem: - //Depending on the terminal mode, we either send an escape sequence - //OR update our own data structures. - //e.g. scrolling. If we do smooth scrolling, then we need to check if - //we own scrolling and then if so, do our scrolling thing. - //Ok, so the terminal connection should have APIs for querying it semantically - //something like `should_handle_scroll()`. This means we need a handle to the connection. - //Actually, this is the only time that this app needs to talk to the outer world. - //TODO for scrolling rework: need a way of intercepting Home/End/PageUp etc. - //Sometimes going to scroll our own internal buffer, sometimes going to send ESC - // - //Same goes for key events - //Actually, we don't use the terminal at all in dispatch_event code, the view - //Handles it all. Check how the editor implements scrolling, is it view-level - //or element level? - - //Question: Can we continue dispatching to the view, so it can talk to the connection - //Or should we instead add a connection into here? - match event { Event::ScrollWheel(ScrollWheelEvent { delta, position, .. @@ -386,10 +365,18 @@ impl Element for TerminalEl { .then(|| { let vertical_scroll = (delta.y() / layout.line_height.0) * ALACRITTY_SCROLL_MULTIPLIER; - cx.dispatch_action(ScrollTerminal(vertical_scroll.round() as i32)); + + if let Some(connection) = self.connection.upgrade(cx.app) { + connection.update(cx.app, |connection, _| { + connection + .term + .lock() + .scroll_display(Scroll::Delta(vertical_scroll.round() as i32)); + }) + } }) .is_some(), - Event::KeyDown(e @ KeyDownEvent { .. }) => { + Event::KeyDown(KeyDownEvent { keystroke, .. }) => { if !cx.is_parent_view_focused() { return false; } @@ -397,7 +384,9 @@ impl Element for TerminalEl { self.connection .upgrade(cx.app) .map(|connection| { - connection.update(cx.app, |connection, _| connection.try_keystroke(e)) + connection.update(cx.app, |connection, _| { + connection.try_keystroke(dbg!(keystroke)) + }) }) .unwrap_or(false) } From 1935208de6d11ea21139f83628fae94037326922 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 14 Jul 2022 17:23:43 -0700 Subject: [PATCH 4/8] Clean up prints --- crates/terminal/src/connection.rs | 1 - crates/terminal/src/connection/events.rs | 2 +- crates/terminal/src/terminal.rs | 1 - crates/terminal/src/terminal_element.rs | 5 ++--- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/terminal/src/connection.rs b/crates/terminal/src/connection.rs index 7babe45d93cc3659dbd459a835374449d1ac46b0..d17752d3957420491f7f5dd1cf4b60a5e14b97cd 100644 --- a/crates/terminal/src/connection.rs +++ b/crates/terminal/src/connection.rs @@ -191,7 +191,6 @@ impl TerminalConnection { let guard = self.term.lock(); let mode = guard.mode(); let esc = to_esc_str(keystroke, mode); - dbg!(&esc); drop(guard); if esc.is_some() { self.write_to_pty(esc.unwrap()); diff --git a/crates/terminal/src/connection/events.rs b/crates/terminal/src/connection/events.rs index cf0163e558dd24a9233cec692b004cd1d901a8f7..0adff38f8686b9b0774fad2bcf8660c84fcfa69e 100644 --- a/crates/terminal/src/connection/events.rs +++ b/crates/terminal/src/connection/events.rs @@ -219,7 +219,7 @@ pub fn to_esc_str(keystroke: &Keystroke, mode: &TermMode) -> Option { // Fallback to keystroke input sent directly if keystroke.key.chars().count() == 1 { - dbg!("This should catch space", &keystroke.key); + //TODO this might fail on unicode during internationalization return Some(keystroke.key.clone()); } else { None diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index 96db9aa03445da42f269f74388fdeac292ed5fdf..7963c407927db8e4210e4854d73fd345dac5e323 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -219,7 +219,6 @@ impl Terminal { ///Synthesize the keyboard event corresponding to 'enter' fn enter(&mut self, _: &Enter, cx: &mut ViewContext) { - dbg!("Here!"); self.connection.update(cx, |connection, _| { connection.try_keystroke(&Keystroke::parse("enter").unwrap()); }); diff --git a/crates/terminal/src/terminal_element.rs b/crates/terminal/src/terminal_element.rs index d4d2492bb85e5021b9c7b9af19dff95ead911297..cfb881feb22fffe594a31de3783616775eb1a5d1 100644 --- a/crates/terminal/src/terminal_element.rs +++ b/crates/terminal/src/terminal_element.rs @@ -384,9 +384,8 @@ impl Element for TerminalEl { self.connection .upgrade(cx.app) .map(|connection| { - connection.update(cx.app, |connection, _| { - connection.try_keystroke(dbg!(keystroke)) - }) + connection + .update(cx.app, |connection, _| connection.try_keystroke(keystroke)) }) .unwrap_or(false) } From 8220b37c4fabc3d146097743aaf58f889c5419b8 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 14 Jul 2022 17:25:17 -0700 Subject: [PATCH 5/8] Method rename --- crates/terminal/src/terminal.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index 7963c407927db8e4210e4854d73fd345dac5e323..2ed456770680cb27e30686546bddc32f0ee935d3 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -57,7 +57,7 @@ actions!( ///Initialize and register all of our action handlers pub fn init(cx: &mut MutableAppContext) { //Global binding overrrides - cx.add_action(Terminal::send_ctrl_c); + cx.add_action(Terminal::ctrl_c); cx.add_action(Terminal::up); cx.add_action(Terminal::down); cx.add_action(Terminal::escape); @@ -204,7 +204,7 @@ impl Terminal { } ///Synthesize the keyboard event corresponding to 'ctrl-c' - fn send_ctrl_c(&mut self, _: &CtrlC, cx: &mut ViewContext) { + fn ctrl_c(&mut self, _: &CtrlC, cx: &mut ViewContext) { self.connection.update(cx, |connection, _| { connection.try_keystroke(&Keystroke::parse("ctrl-c").unwrap()); }); From f9995e1fcd0742c19241c3cc3807eda6c8ed308f Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 15 Jul 2022 00:26:04 -0700 Subject: [PATCH 6/8] Starting on tests --- Cargo.lock | 957 ++++++++++++++++++++++- crates/terminal/Cargo.toml | 3 +- crates/terminal/src/connection/events.rs | 2 +- 3 files changed, 926 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c87bb055f7fcbbbffaa3cbd0f5daa818d32f038..02403aa49bc495479436e9b7e3c1bd643a016b95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,6 +59,41 @@ dependencies = [ "memchr", ] +[[package]] +name = "alacritty" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f293c6549baebc7f1ad0d39006bf12b7b0225cfb38687d6bd431e840b1b9f19" +dependencies = [ + "alacritty_config_derive", + "alacritty_terminal", + "bitflags", + "cocoa", + "copypasta", + "crossfont", + "dirs 3.0.2", + "embed-resource", + "fnv", + "gl_generator", + "glutin", + "libc", + "log", + "notify", + "objc", + "parking_lot 0.11.2", + "png", + "raw-window-handle", + "serde", + "serde_json", + "serde_yaml", + "structopt", + "unicode-width", + "wayland-client", + "winapi 0.3.9", + "x11-dl", + "xdg", +] + [[package]] name = "alacritty_config_derive" version = "0.1.0" @@ -86,7 +121,7 @@ dependencies = [ "mio-anonymous-pipes", "mio-extras", "miow 0.3.7", - "nix", + "nix 0.22.3", "parking_lot 0.11.2", "regex-automata", "serde", @@ -104,6 +139,12 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec8ad6edb4840b78c5c3d88de606b22252d552b55f3a4699fbb10fc070ec3049" +[[package]] +name = "android_glue" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407" + [[package]] name = "ansi_term" version = "0.12.1" @@ -680,6 +721,16 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" +[[package]] +name = "calloop" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf2eec61efe56aa1e813f5126959296933cf0700030e4314786c48779a66ab82" +dependencies = [ + "log", + "nix 0.22.3", +] + [[package]] name = "cap-fs-ext" version = "0.24.4" @@ -782,6 +833,15 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cgl" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff" +dependencies = [ + "libc", +] + [[package]] name = "chat_panel" version = "0.1.0" @@ -897,7 +957,7 @@ version = "0.1.0" dependencies = [ "anyhow", "clap 3.2.8", - "core-foundation", + "core-foundation 0.9.3", "core-services", "dirs 3.0.2", "ipc-channel", @@ -932,6 +992,16 @@ dependencies = [ "util", ] +[[package]] +name = "clipboard-win" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fdf5e01086b6be750428ba4a40619f847eb2e95756eee84b18e06e5f0b50342" +dependencies = [ + "lazy-bytes-cast", + "winapi 0.3.9", +] + [[package]] name = "clock" version = "0.1.0" @@ -956,9 +1026,9 @@ dependencies = [ "bitflags", "block", "cocoa-foundation", - "core-foundation", - "core-graphics", - "foreign-types", + "core-foundation 0.9.3", + "core-graphics 0.22.3", + "foreign-types 0.3.2", "libc", "objc", ] @@ -970,9 +1040,9 @@ source = "git+https://github.com/servo/core-foundation-rs?rev=079665882507dd5e2f dependencies = [ "bitflags", "block", - "core-foundation", + "core-foundation 0.9.3", "core-graphics-types", - "foreign-types", + "foreign-types 0.3.2", "libc", "objc", ] @@ -1105,29 +1175,71 @@ dependencies = [ "theme", ] +[[package]] +name = "copypasta" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4423d79fed83ebd9ab81ec21fa97144300a961782158287dc9bf7eddac37ff0b" +dependencies = [ + "clipboard-win", + "objc", + "objc-foundation", + "objc_id", + "smithay-clipboard", + "x11-clipboard", +] + +[[package]] +name = "core-foundation" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" +dependencies = [ + "core-foundation-sys 0.7.0", + "libc", +] + [[package]] name = "core-foundation" version = "0.9.3" source = "git+https://github.com/servo/core-foundation-rs?rev=079665882507dd5e2ff77db3de5070c1f6c0fb85#079665882507dd5e2ff77db3de5070c1f6c0fb85" dependencies = [ - "core-foundation-sys", + "core-foundation-sys 0.8.3", "libc", ] +[[package]] +name = "core-foundation-sys" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" + [[package]] name = "core-foundation-sys" version = "0.8.3" source = "git+https://github.com/servo/core-foundation-rs?rev=079665882507dd5e2ff77db3de5070c1f6c0fb85#079665882507dd5e2ff77db3de5070c1f6c0fb85" +[[package]] +name = "core-graphics" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923" +dependencies = [ + "bitflags", + "core-foundation 0.7.0", + "foreign-types 0.3.2", + "libc", +] + [[package]] name = "core-graphics" version = "0.22.3" source = "git+https://github.com/servo/core-foundation-rs?rev=079665882507dd5e2ff77db3de5070c1f6c0fb85#079665882507dd5e2ff77db3de5070c1f6c0fb85" dependencies = [ "bitflags", - "core-foundation", + "core-foundation 0.9.3", "core-graphics-types", - "foreign-types", + "foreign-types 0.3.2", "libc", ] @@ -1137,8 +1249,8 @@ version = "0.1.1" source = "git+https://github.com/servo/core-foundation-rs?rev=079665882507dd5e2ff77db3de5070c1f6c0fb85#079665882507dd5e2ff77db3de5070c1f6c0fb85" dependencies = [ "bitflags", - "core-foundation", - "foreign-types", + "core-foundation 0.9.3", + "foreign-types 0.3.2", "libc", ] @@ -1148,7 +1260,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b344b958cae90858bf6086f49599ecc5ec8698eacad0ea155509ba11fab347" dependencies = [ - "core-foundation", + "core-foundation 0.9.3", ] [[package]] @@ -1157,12 +1269,25 @@ version = "19.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d74ada66e07c1cefa18f8abfba765b486f250de2e4a999e5727fc0dd4b4a25" dependencies = [ - "core-foundation", - "core-graphics", - "foreign-types", + "core-foundation 0.9.3", + "core-graphics 0.22.3", + "foreign-types 0.3.2", "libc", ] +[[package]] +name = "core-video-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828" +dependencies = [ + "cfg-if 0.1.10", + "core-foundation-sys 0.7.0", + "core-graphics 0.19.2", + "libc", + "objc", +] + [[package]] name = "cpp_demangle" version = "0.3.5" @@ -1377,6 +1502,27 @@ dependencies = [ "once_cell", ] +[[package]] +name = "crossfont" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1299695a4c6417b7e4a6957bd963478406e148b7b0351e2f2ce31296b0518251" +dependencies = [ + "cocoa", + "core-foundation 0.9.3", + "core-foundation-sys 0.8.3", + "core-graphics 0.22.3", + "core-text", + "dwrote", + "foreign-types 0.5.0", + "freetype-rs", + "libc", + "log", + "pkg-config", + "servo-fontconfig", + "winapi 0.3.9", +] + [[package]] name = "crypto-common" version = "0.1.4" @@ -1407,6 +1553,12 @@ dependencies = [ "syn", ] +[[package]] +name = "cty" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" + [[package]] name = "curl" version = "0.4.43" @@ -1438,6 +1590,41 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "darling" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +dependencies = [ + "darling_core", + "quote", + "syn", +] + [[package]] name = "data-url" version = "0.1.1" @@ -1573,12 +1760,33 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + +[[package]] +name = "dlib" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1b7517328c04c2aa68422fc60a41b92208182142ed04a25879c26c8f878794" +dependencies = [ + "libloading", +] + [[package]] name = "dotenv" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" +[[package]] +name = "downcast-rs" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" + [[package]] name = "dwrote" version = "0.11.0" @@ -1587,6 +1795,8 @@ checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b" dependencies = [ "lazy_static", "libc", + "serde", + "serde_derive", "winapi 0.3.9", "wio", ] @@ -1649,6 +1859,19 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" +[[package]] +name = "embed-resource" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc24ff8d764818e9ab17963b0593c535f077a513f565e75e4352d758bc4d8c0" +dependencies = [ + "cc", + "rustc_version 0.4.0", + "toml", + "vswhom", + "winreg", +] + [[package]] name = "encoding_rs" version = "0.8.31" @@ -1790,6 +2013,18 @@ dependencies = [ "workspace", ] +[[package]] +name = "filetime" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94a7bbaa59354bc20dd75b67f23e2797b4490e9d6928203fb105c79e448c86c" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "windows-sys", +] + [[package]] name = "fixedbitset" version = "0.4.2" @@ -1831,8 +2066,8 @@ source = "git+https://github.com/zed-industries/font-kit?rev=8eaf7a918eafa28b0a3 dependencies = [ "bitflags", "byteorder", - "core-foundation", - "core-graphics", + "core-foundation 0.9.3", + "core-graphics 0.22.3", "core-text", "dirs-next", "dwrote", @@ -1855,7 +2090,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e58903f4f8d5b58c7d300908e4ebe5289c1bfdf5587964330f12023b8ff17fd1" dependencies = [ "log", - "memmap2", + "memmap2 0.2.3", "ttf-parser 0.12.3", ] @@ -1865,7 +2100,28 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" dependencies = [ - "foreign-types-shared", + "foreign-types-shared 0.1.1", +] + +[[package]] +name = "foreign-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" +dependencies = [ + "foreign-types-macros", + "foreign-types-shared 0.3.1", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8469d0d40519bc608ec6863f1cc88f3f1deee15913f2f3b3e573d81ed38cccc" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1874,6 +2130,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + [[package]] name = "form_urlencoded" version = "1.0.1" @@ -1894,6 +2156,17 @@ dependencies = [ "libc", ] +[[package]] +name = "freetype-rs" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74eadec9d0a5c28c54bb9882e54787275152a4e36ce206b45d7451384e5bf5fb" +dependencies = [ + "bitflags", + "freetype-sys", + "libc", +] + [[package]] name = "freetype-sys" version = "0.13.1" @@ -1916,16 +2189,35 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "fsevent" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6" +dependencies = [ + "bitflags", + "fsevent-sys 2.0.1", +] + [[package]] name = "fsevent" version = "2.0.2" dependencies = [ "bitflags", - "fsevent-sys", + "fsevent-sys 3.1.0", "parking_lot 0.11.2", "tempdir", ] +[[package]] +name = "fsevent-sys" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0" +dependencies = [ + "libc", +] + [[package]] name = "fsevent-sys" version = "3.1.0" @@ -2142,6 +2434,17 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + [[package]] name = "glob" version = "0.3.0" @@ -2161,6 +2464,78 @@ dependencies = [ "regex", ] +[[package]] +name = "glutin" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00ea9dbe544bc8a657c4c4a798c2d16cd01b549820e47657297549d28371f6d2" +dependencies = [ + "android_glue", + "cgl", + "cocoa", + "core-foundation 0.9.3", + "glutin_egl_sys", + "glutin_emscripten_sys", + "glutin_gles2_sys", + "glutin_glx_sys", + "glutin_wgl_sys", + "lazy_static", + "libloading", + "log", + "objc", + "osmesa-sys", + "parking_lot 0.11.2", + "wayland-client", + "wayland-egl", + "winapi 0.3.9", + "winit", +] + +[[package]] +name = "glutin_egl_sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2abb6aa55523480c4adc5a56bbaa249992e2dddb2fc63dc96e04a3355364c211" +dependencies = [ + "gl_generator", + "winapi 0.3.9", +] + +[[package]] +name = "glutin_emscripten_sys" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80de4146df76e8a6c32b03007bc764ff3249dcaeb4f675d68a06caf1bac363f1" + +[[package]] +name = "glutin_gles2_sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8094e708b730a7c8a1954f4f8a31880af00eb8a1c5b5bf85d28a0a3c6d69103" +dependencies = [ + "gl_generator", + "objc", +] + +[[package]] +name = "glutin_glx_sys" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e393c8fc02b807459410429150e9c4faffdb312d59b8c038566173c81991351" +dependencies = [ + "gl_generator", + "x11-dl", +] + +[[package]] +name = "glutin_wgl_sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3da5951a1569dbab865c6f2a863efafff193a93caf05538d193e9e3816d21696" +dependencies = [ + "gl_generator", +] + [[package]] name = "go_to_line" version = "0.1.0" @@ -2186,15 +2561,15 @@ dependencies = [ "cc", "cocoa", "collections", - "core-foundation", - "core-graphics", + "core-foundation 0.9.3", + "core-graphics 0.22.3", "core-text", "ctor", "dhat", "env_logger", "etagere", "font-kit", - "foreign-types", + "foreign-types 0.3.2", "futures", "gpui_macros", "image", @@ -2481,6 +2856,12 @@ dependencies = [ "tokio-native-tls", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.2.3" @@ -2546,6 +2927,26 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05a0bd019339e5d968b37855180087b7b9d512c5046fbd244cf8c95687927d6e" +[[package]] +name = "inotify" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4816c66d2c8ae673df83366c18341538f234a26d65a9ecea5c348b453ac1d02f" +dependencies = [ + "bitflags", + "inotify-sys", + "libc", +] + +[[package]] +name = "inotify-sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" +dependencies = [ + "libc", +] + [[package]] name = "instant" version = "0.1.12" @@ -2553,6 +2954,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ "cfg-if 1.0.0", + "js-sys", + "wasm-bindgen", + "web-sys", ] [[package]] @@ -2672,6 +3076,12 @@ dependencies = [ "cc", ] +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + [[package]] name = "jobserver" version = "0.1.24" @@ -2728,6 +3138,12 @@ dependencies = [ "winapi-build", ] +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + [[package]] name = "kurbo" version = "0.8.3" @@ -2777,6 +3193,12 @@ dependencies = [ "util", ] +[[package]] +name = "lazy-bytes-cast" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10257499f089cd156ad82d0a9cd57d9501fa2c989068992a97eb3c27836f206b" + [[package]] name = "lazy_static" version = "1.4.0" @@ -3027,6 +3449,24 @@ dependencies = [ "libc", ] +[[package]] +name = "memmap2" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b6c2ebff6180198788f5db08d7ce3bc1d0b617176678831a7510825973e357" +dependencies = [ + "libc", +] + +[[package]] +name = "memmap2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a79b39c93a7a5a27eeaf9a23b5ff43f1b9e0ad6b1cdd441140ae53c35613fc7" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.6.5" @@ -3052,7 +3492,7 @@ dependencies = [ "bitflags", "block", "cocoa-foundation", - "foreign-types", + "foreign-types 0.3.2", "log", "objc", ] @@ -3224,6 +3664,59 @@ dependencies = [ "tempfile", ] +[[package]] +name = "ndk" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d868f654c72e75f8687572699cdabe755f03effbb62542768e995d5b8d699d" +dependencies = [ + "bitflags", + "jni-sys", + "ndk-sys", + "num_enum", + "thiserror", +] + +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "ndk-glue" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71bee8ea72d685477e28bd004cfe1bf99c754d688cd78cad139eae4089484d4" +dependencies = [ + "lazy_static", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-macro", + "ndk-sys", +] + +[[package]] +name = "ndk-macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0df7ac00c4672f9d5aece54ee3347520b7e20f158656c7db2e6de01902eb7a6c" +dependencies = [ + "darling", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ndk-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1bcdd74c20ad5d95aacd60ef9ba40fdf77f767051040541df557b7a9b2a2121" + [[package]] name = "net2" version = "0.2.37" @@ -3248,6 +3741,17 @@ dependencies = [ "memoffset", ] +[[package]] +name = "nix" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f17df307904acd05aa8e32e97bb20f2a0df1728bbc2d771ae8f9a90463441e9" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "libc", +] + [[package]] name = "nom" version = "7.1.1" @@ -3258,6 +3762,24 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "notify" +version = "4.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae03c8c853dba7bfd23e571ff0cff7bc9dceb40a4cd684cd1681824183f45257" +dependencies = [ + "bitflags", + "filetime", + "fsevent 0.4.0", + "fsevent-sys 2.0.1", + "inotify", + "libc", + "mio 0.6.23", + "mio-extras", + "walkdir", + "winapi 0.3.9", +] + [[package]] name = "num-bigint" version = "0.4.3" @@ -3339,6 +3861,27 @@ dependencies = [ "libc", ] +[[package]] +name = "num_enum" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "num_threads" version = "0.1.6" @@ -3358,6 +3901,17 @@ dependencies = [ "objc_exception", ] +[[package]] +name = "objc-foundation" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" +dependencies = [ + "block", + "objc", + "objc_id", +] + [[package]] name = "objc_exception" version = "0.1.2" @@ -3367,6 +3921,15 @@ dependencies = [ "cc", ] +[[package]] +name = "objc_id" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" +dependencies = [ + "objc", +] + [[package]] name = "object" version = "0.28.4" @@ -3399,7 +3962,7 @@ checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e" dependencies = [ "bitflags", "cfg-if 1.0.0", - "foreign-types", + "foreign-types 0.3.2", "libc", "once_cell", "openssl-macros", @@ -3451,6 +4014,15 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" +[[package]] +name = "osmesa-sys" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b" +dependencies = [ + "shared_library", +] + [[package]] name = "outline" version = "0.1.0" @@ -3564,7 +4136,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39fe46acc5503595e5949c17b818714d26fdf9b4920eacf3b2947f0199f4a6ff" dependencies = [ - "rustc_version", + "rustc_version 0.3.3", ] [[package]] @@ -3786,6 +4358,16 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +[[package]] +name = "proc-macro-crate" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +dependencies = [ + "thiserror", + "toml", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -3829,7 +4411,7 @@ dependencies = [ "client", "clock", "collections", - "fsevent", + "fsevent 2.0.2", "futures", "fuzzy", "gpui", @@ -4019,6 +4601,15 @@ dependencies = [ "unicase", ] +[[package]] +name = "quick-xml" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8533f14c8382aaad0d592c812ac3b826162128b65662331e1127b45c3d18536b" +dependencies = [ + "memchr", +] + [[package]] name = "quote" version = "1.0.20" @@ -4127,6 +4718,15 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "raw-window-handle" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41" +dependencies = [ + "cty", +] + [[package]] name = "rayon" version = "1.5.3" @@ -4441,7 +5041,16 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" dependencies = [ - "semver", + "semver 0.11.0", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver 1.0.12", ] [[package]] @@ -4583,6 +5192,12 @@ dependencies = [ "syn", ] +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + [[package]] name = "scoped_threadpool" version = "0.1.9" @@ -4665,8 +5280,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dc14f172faf8a0194a3aded622712b0de276821addc574fa54fc0a1167e10dc" dependencies = [ "bitflags", - "core-foundation", - "core-foundation-sys", + "core-foundation 0.9.3", + "core-foundation-sys 0.8.3", "libc", "security-framework-sys", ] @@ -4677,7 +5292,7 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" dependencies = [ - "core-foundation-sys", + "core-foundation-sys 0.8.3", "libc", ] @@ -4690,6 +5305,12 @@ dependencies = [ "semver-parser", ] +[[package]] +name = "semver" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1" + [[package]] name = "semver-parser" version = "0.10.2" @@ -4897,6 +5518,16 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shared_library" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" +dependencies = [ + "lazy_static", + "libc", +] + [[package]] name = "shellexpand" version = "2.1.0" @@ -5016,6 +5647,53 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" +[[package]] +name = "smithay-client-toolkit" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a28f16a97fa0e8ce563b2774d1e732dd5d4025d2772c5dba0a41a0f90a29da3" +dependencies = [ + "bitflags", + "calloop", + "dlib", + "lazy_static", + "log", + "memmap2 0.3.1", + "nix 0.22.3", + "pkg-config", + "wayland-client", + "wayland-cursor", + "wayland-protocols", +] + +[[package]] +name = "smithay-client-toolkit" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f307c47d32d2715eb2e0ece5589057820e0e5e70d07c247d1063e844e107f454" +dependencies = [ + "bitflags", + "dlib", + "lazy_static", + "log", + "memmap2 0.5.5", + "nix 0.24.1", + "pkg-config", + "wayland-client", + "wayland-cursor", + "wayland-protocols", +] + +[[package]] +name = "smithay-clipboard" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a345c870a1fae0b1b779085e81b51e614767c239e93503588e54c5b17f4b0e8" +dependencies = [ + "smithay-client-toolkit 0.16.0", + "wayland-client", +] + [[package]] name = "smol" version = "1.2.5" @@ -5213,6 +5891,30 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "structopt" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" +dependencies = [ + "clap 2.34.0", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" +dependencies = [ + "heck 0.3.3", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "subtle" version = "2.4.1" @@ -5353,6 +6055,7 @@ dependencies = [ name = "terminal" version = "0.1.0" dependencies = [ + "alacritty", "alacritty_terminal", "client", "dirs 4.0.0", @@ -6142,7 +6845,7 @@ dependencies = [ "fontdb", "kurbo", "log", - "memmap2", + "memmap2 0.2.3", "pico-args", "rctree", "roxmltree", @@ -6255,6 +6958,26 @@ dependencies = [ "workspace", ] +[[package]] +name = "vswhom" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b" +dependencies = [ + "libc", + "vswhom-sys", +] + +[[package]] +name = "vswhom-sys" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22025f6d8eb903ebf920ea6933b70b1e495be37e2cb4099e62c80454aaf57c39" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "vte" version = "0.10.1" @@ -6673,6 +7396,89 @@ dependencies = [ "wast 43.0.0", ] +[[package]] +name = "wayland-client" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91223460e73257f697d9e23d401279123d36039a3f7a449e983f123292d4458f" +dependencies = [ + "bitflags", + "downcast-rs", + "libc", + "nix 0.22.3", + "scoped-tls", + "wayland-commons", + "wayland-scanner", + "wayland-sys", +] + +[[package]] +name = "wayland-commons" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94f6e5e340d7c13490eca867898c4cec5af56c27a5ffe5c80c6fc4708e22d33e" +dependencies = [ + "nix 0.22.3", + "once_cell", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-cursor" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c52758f13d5e7861fc83d942d3d99bf270c83269575e52ac29e5b73cb956a6bd" +dependencies = [ + "nix 0.22.3", + "wayland-client", + "xcursor", +] + +[[package]] +name = "wayland-egl" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83281d69ee162b59031c666385e93bde4039ec553b90c4191cdb128ceea29a3a" +dependencies = [ + "wayland-client", + "wayland-sys", +] + +[[package]] +name = "wayland-protocols" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60147ae23303402e41fe034f74fb2c35ad0780ee88a1c40ac09a3be1e7465741" +dependencies = [ + "bitflags", + "wayland-client", + "wayland-commons", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39a1ed3143f7a143187156a2ab52742e89dac33245ba505c17224df48939f9e0" +dependencies = [ + "proc-macro2", + "quote", + "xml-rs", +] + +[[package]] +name = "wayland-sys" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9341df79a8975679188e37dab3889bfa57c44ac2cb6da166f519a81cbe452d4" +dependencies = [ + "dlib", + "lazy_static", + "pkg-config", +] + [[package]] name = "web-sys" version = "0.3.58" @@ -6885,6 +7691,40 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +[[package]] +name = "winit" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b43cc931d58b99461188607efd7acb2a093e65fc621f54cad78517a6063e73a" +dependencies = [ + "bitflags", + "cocoa", + "core-foundation 0.9.3", + "core-graphics 0.22.3", + "core-video-sys", + "dispatch", + "instant", + "lazy_static", + "libc", + "log", + "mio 0.8.4", + "ndk", + "ndk-glue", + "ndk-sys", + "objc", + "parking_lot 0.11.2", + "percent-encoding", + "raw-window-handle", + "serde", + "smithay-client-toolkit 0.15.4", + "wasm-bindgen", + "wayland-client", + "wayland-protocols", + "web-sys", + "winapi 0.3.9", + "x11-dl", +] + [[package]] name = "winreg" version = "0.10.1" @@ -6961,6 +7801,55 @@ dependencies = [ "winapi-build", ] +[[package]] +name = "x11-clipboard" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "473068b7b80ac86a18328824f1054e5e007898c47b5bbc281bd7abe32bc3653c" +dependencies = [ + "xcb", +] + +[[package]] +name = "x11-dl" +version = "2.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea26926b4ce81a6f5d9d0f3a0bc401e5a37c6ae14a1bfaa8ff6099ca80038c59" +dependencies = [ + "lazy_static", + "libc", + "pkg-config", +] + +[[package]] +name = "xcb" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771e2b996df720cd1c6dd9ff90f62d91698fd3610cc078388d0564bdd6622a9c" +dependencies = [ + "libc", + "log", + "quick-xml", +] + +[[package]] +name = "xcursor" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "463705a63313cd4301184381c5e8042f0a7e9b4bb63653f216311d4ae74690b7" +dependencies = [ + "nom", +] + +[[package]] +name = "xdg" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4583db5cbd4c4c0303df2d15af80f0539db703fa1c68802d4cbbd2dd0f88f6" +dependencies = [ + "dirs 4.0.0", +] + [[package]] name = "xml-rs" version = "0.8.4" @@ -7017,7 +7906,7 @@ dependencies = [ "editor", "env_logger", "file_finder", - "fsevent", + "fsevent 2.0.2", "futures", "fuzzy", "go_to_line", diff --git a/crates/terminal/Cargo.toml b/crates/terminal/Cargo.toml index 876c28a273dcec88b2b14817c2b6646b03db7c46..63894b57f08d448cab8221e20b0aaac0dfc50ef4 100644 --- a/crates/terminal/Cargo.toml +++ b/crates/terminal/Cargo.toml @@ -27,4 +27,5 @@ dirs = "4.0.0" gpui = { path = "../gpui", features = ["test-support"] } client = { path = "../client", features = ["test-support"]} project = { path = "../project", features = ["test-support"]} -workspace = { path = "../workspace", features = ["test-support"] } \ No newline at end of file +workspace = { path = "../workspace", features = ["test-support"] } +alacritty = "0.10.1" \ No newline at end of file diff --git a/crates/terminal/src/connection/events.rs b/crates/terminal/src/connection/events.rs index 0adff38f8686b9b0774fad2bcf8660c84fcfa69e..14a3b873c70719365780c4320cae821f4bdb6cdd 100644 --- a/crates/terminal/src/connection/events.rs +++ b/crates/terminal/src/connection/events.rs @@ -313,7 +313,7 @@ mod test { #[test] fn test_match_alacritty_keybindings() { - // let bindings = alacritty::config::bindings::default_key_bindings(); + let bindings = alacritty::config::bindings::default_key_bindings(); //TODO } From 90428255d92f4671197d3d34f9fa33116a4557da Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 15 Jul 2022 10:36:37 -0700 Subject: [PATCH 7/8] Added some simple tests for the new keybindings --- Cargo.lock | 957 +---------------------- crates/terminal/Cargo.toml | 1 - crates/terminal/src/connection/events.rs | 347 ++++---- 3 files changed, 205 insertions(+), 1100 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02403aa49bc495479436e9b7e3c1bd643a016b95..6c87bb055f7fcbbbffaa3cbd0f5daa818d32f038 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,41 +59,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "alacritty" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f293c6549baebc7f1ad0d39006bf12b7b0225cfb38687d6bd431e840b1b9f19" -dependencies = [ - "alacritty_config_derive", - "alacritty_terminal", - "bitflags", - "cocoa", - "copypasta", - "crossfont", - "dirs 3.0.2", - "embed-resource", - "fnv", - "gl_generator", - "glutin", - "libc", - "log", - "notify", - "objc", - "parking_lot 0.11.2", - "png", - "raw-window-handle", - "serde", - "serde_json", - "serde_yaml", - "structopt", - "unicode-width", - "wayland-client", - "winapi 0.3.9", - "x11-dl", - "xdg", -] - [[package]] name = "alacritty_config_derive" version = "0.1.0" @@ -121,7 +86,7 @@ dependencies = [ "mio-anonymous-pipes", "mio-extras", "miow 0.3.7", - "nix 0.22.3", + "nix", "parking_lot 0.11.2", "regex-automata", "serde", @@ -139,12 +104,6 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec8ad6edb4840b78c5c3d88de606b22252d552b55f3a4699fbb10fc070ec3049" -[[package]] -name = "android_glue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407" - [[package]] name = "ansi_term" version = "0.12.1" @@ -721,16 +680,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" -[[package]] -name = "calloop" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf2eec61efe56aa1e813f5126959296933cf0700030e4314786c48779a66ab82" -dependencies = [ - "log", - "nix 0.22.3", -] - [[package]] name = "cap-fs-ext" version = "0.24.4" @@ -833,15 +782,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cgl" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff" -dependencies = [ - "libc", -] - [[package]] name = "chat_panel" version = "0.1.0" @@ -957,7 +897,7 @@ version = "0.1.0" dependencies = [ "anyhow", "clap 3.2.8", - "core-foundation 0.9.3", + "core-foundation", "core-services", "dirs 3.0.2", "ipc-channel", @@ -992,16 +932,6 @@ dependencies = [ "util", ] -[[package]] -name = "clipboard-win" -version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fdf5e01086b6be750428ba4a40619f847eb2e95756eee84b18e06e5f0b50342" -dependencies = [ - "lazy-bytes-cast", - "winapi 0.3.9", -] - [[package]] name = "clock" version = "0.1.0" @@ -1026,9 +956,9 @@ dependencies = [ "bitflags", "block", "cocoa-foundation", - "core-foundation 0.9.3", - "core-graphics 0.22.3", - "foreign-types 0.3.2", + "core-foundation", + "core-graphics", + "foreign-types", "libc", "objc", ] @@ -1040,9 +970,9 @@ source = "git+https://github.com/servo/core-foundation-rs?rev=079665882507dd5e2f dependencies = [ "bitflags", "block", - "core-foundation 0.9.3", + "core-foundation", "core-graphics-types", - "foreign-types 0.3.2", + "foreign-types", "libc", "objc", ] @@ -1175,71 +1105,29 @@ dependencies = [ "theme", ] -[[package]] -name = "copypasta" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4423d79fed83ebd9ab81ec21fa97144300a961782158287dc9bf7eddac37ff0b" -dependencies = [ - "clipboard-win", - "objc", - "objc-foundation", - "objc_id", - "smithay-clipboard", - "x11-clipboard", -] - -[[package]] -name = "core-foundation" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" -dependencies = [ - "core-foundation-sys 0.7.0", - "libc", -] - [[package]] name = "core-foundation" version = "0.9.3" source = "git+https://github.com/servo/core-foundation-rs?rev=079665882507dd5e2ff77db3de5070c1f6c0fb85#079665882507dd5e2ff77db3de5070c1f6c0fb85" dependencies = [ - "core-foundation-sys 0.8.3", + "core-foundation-sys", "libc", ] -[[package]] -name = "core-foundation-sys" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" - [[package]] name = "core-foundation-sys" version = "0.8.3" source = "git+https://github.com/servo/core-foundation-rs?rev=079665882507dd5e2ff77db3de5070c1f6c0fb85#079665882507dd5e2ff77db3de5070c1f6c0fb85" -[[package]] -name = "core-graphics" -version = "0.19.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923" -dependencies = [ - "bitflags", - "core-foundation 0.7.0", - "foreign-types 0.3.2", - "libc", -] - [[package]] name = "core-graphics" version = "0.22.3" source = "git+https://github.com/servo/core-foundation-rs?rev=079665882507dd5e2ff77db3de5070c1f6c0fb85#079665882507dd5e2ff77db3de5070c1f6c0fb85" dependencies = [ "bitflags", - "core-foundation 0.9.3", + "core-foundation", "core-graphics-types", - "foreign-types 0.3.2", + "foreign-types", "libc", ] @@ -1249,8 +1137,8 @@ version = "0.1.1" source = "git+https://github.com/servo/core-foundation-rs?rev=079665882507dd5e2ff77db3de5070c1f6c0fb85#079665882507dd5e2ff77db3de5070c1f6c0fb85" dependencies = [ "bitflags", - "core-foundation 0.9.3", - "foreign-types 0.3.2", + "core-foundation", + "foreign-types", "libc", ] @@ -1260,7 +1148,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b344b958cae90858bf6086f49599ecc5ec8698eacad0ea155509ba11fab347" dependencies = [ - "core-foundation 0.9.3", + "core-foundation", ] [[package]] @@ -1269,25 +1157,12 @@ version = "19.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d74ada66e07c1cefa18f8abfba765b486f250de2e4a999e5727fc0dd4b4a25" dependencies = [ - "core-foundation 0.9.3", - "core-graphics 0.22.3", - "foreign-types 0.3.2", + "core-foundation", + "core-graphics", + "foreign-types", "libc", ] -[[package]] -name = "core-video-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828" -dependencies = [ - "cfg-if 0.1.10", - "core-foundation-sys 0.7.0", - "core-graphics 0.19.2", - "libc", - "objc", -] - [[package]] name = "cpp_demangle" version = "0.3.5" @@ -1502,27 +1377,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "crossfont" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1299695a4c6417b7e4a6957bd963478406e148b7b0351e2f2ce31296b0518251" -dependencies = [ - "cocoa", - "core-foundation 0.9.3", - "core-foundation-sys 0.8.3", - "core-graphics 0.22.3", - "core-text", - "dwrote", - "foreign-types 0.5.0", - "freetype-rs", - "libc", - "log", - "pkg-config", - "servo-fontconfig", - "winapi 0.3.9", -] - [[package]] name = "crypto-common" version = "0.1.4" @@ -1553,12 +1407,6 @@ dependencies = [ "syn", ] -[[package]] -name = "cty" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" - [[package]] name = "curl" version = "0.4.43" @@ -1590,41 +1438,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "darling" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim 0.10.0", - "syn", -] - -[[package]] -name = "darling_macro" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" -dependencies = [ - "darling_core", - "quote", - "syn", -] - [[package]] name = "data-url" version = "0.1.1" @@ -1760,33 +1573,12 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "dispatch" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" - -[[package]] -name = "dlib" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1b7517328c04c2aa68422fc60a41b92208182142ed04a25879c26c8f878794" -dependencies = [ - "libloading", -] - [[package]] name = "dotenv" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" -[[package]] -name = "downcast-rs" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" - [[package]] name = "dwrote" version = "0.11.0" @@ -1795,8 +1587,6 @@ checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b" dependencies = [ "lazy_static", "libc", - "serde", - "serde_derive", "winapi 0.3.9", "wio", ] @@ -1859,19 +1649,6 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" -[[package]] -name = "embed-resource" -version = "1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc24ff8d764818e9ab17963b0593c535f077a513f565e75e4352d758bc4d8c0" -dependencies = [ - "cc", - "rustc_version 0.4.0", - "toml", - "vswhom", - "winreg", -] - [[package]] name = "encoding_rs" version = "0.8.31" @@ -2013,18 +1790,6 @@ dependencies = [ "workspace", ] -[[package]] -name = "filetime" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94a7bbaa59354bc20dd75b67f23e2797b4490e9d6928203fb105c79e448c86c" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "redox_syscall", - "windows-sys", -] - [[package]] name = "fixedbitset" version = "0.4.2" @@ -2066,8 +1831,8 @@ source = "git+https://github.com/zed-industries/font-kit?rev=8eaf7a918eafa28b0a3 dependencies = [ "bitflags", "byteorder", - "core-foundation 0.9.3", - "core-graphics 0.22.3", + "core-foundation", + "core-graphics", "core-text", "dirs-next", "dwrote", @@ -2090,7 +1855,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e58903f4f8d5b58c7d300908e4ebe5289c1bfdf5587964330f12023b8ff17fd1" dependencies = [ "log", - "memmap2 0.2.3", + "memmap2", "ttf-parser 0.12.3", ] @@ -2100,28 +1865,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" dependencies = [ - "foreign-types-shared 0.1.1", -] - -[[package]] -name = "foreign-types" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" -dependencies = [ - "foreign-types-macros", - "foreign-types-shared 0.3.1", -] - -[[package]] -name = "foreign-types-macros" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8469d0d40519bc608ec6863f1cc88f3f1deee15913f2f3b3e573d81ed38cccc" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "foreign-types-shared", ] [[package]] @@ -2130,12 +1874,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" -[[package]] -name = "foreign-types-shared" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" - [[package]] name = "form_urlencoded" version = "1.0.1" @@ -2156,17 +1894,6 @@ dependencies = [ "libc", ] -[[package]] -name = "freetype-rs" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74eadec9d0a5c28c54bb9882e54787275152a4e36ce206b45d7451384e5bf5fb" -dependencies = [ - "bitflags", - "freetype-sys", - "libc", -] - [[package]] name = "freetype-sys" version = "0.13.1" @@ -2189,35 +1916,16 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "fsevent" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6" -dependencies = [ - "bitflags", - "fsevent-sys 2.0.1", -] - [[package]] name = "fsevent" version = "2.0.2" dependencies = [ "bitflags", - "fsevent-sys 3.1.0", + "fsevent-sys", "parking_lot 0.11.2", "tempdir", ] -[[package]] -name = "fsevent-sys" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0" -dependencies = [ - "libc", -] - [[package]] name = "fsevent-sys" version = "3.1.0" @@ -2434,17 +2142,6 @@ dependencies = [ "stable_deref_trait", ] -[[package]] -name = "gl_generator" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" -dependencies = [ - "khronos_api", - "log", - "xml-rs", -] - [[package]] name = "glob" version = "0.3.0" @@ -2464,78 +2161,6 @@ dependencies = [ "regex", ] -[[package]] -name = "glutin" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00ea9dbe544bc8a657c4c4a798c2d16cd01b549820e47657297549d28371f6d2" -dependencies = [ - "android_glue", - "cgl", - "cocoa", - "core-foundation 0.9.3", - "glutin_egl_sys", - "glutin_emscripten_sys", - "glutin_gles2_sys", - "glutin_glx_sys", - "glutin_wgl_sys", - "lazy_static", - "libloading", - "log", - "objc", - "osmesa-sys", - "parking_lot 0.11.2", - "wayland-client", - "wayland-egl", - "winapi 0.3.9", - "winit", -] - -[[package]] -name = "glutin_egl_sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2abb6aa55523480c4adc5a56bbaa249992e2dddb2fc63dc96e04a3355364c211" -dependencies = [ - "gl_generator", - "winapi 0.3.9", -] - -[[package]] -name = "glutin_emscripten_sys" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80de4146df76e8a6c32b03007bc764ff3249dcaeb4f675d68a06caf1bac363f1" - -[[package]] -name = "glutin_gles2_sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8094e708b730a7c8a1954f4f8a31880af00eb8a1c5b5bf85d28a0a3c6d69103" -dependencies = [ - "gl_generator", - "objc", -] - -[[package]] -name = "glutin_glx_sys" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e393c8fc02b807459410429150e9c4faffdb312d59b8c038566173c81991351" -dependencies = [ - "gl_generator", - "x11-dl", -] - -[[package]] -name = "glutin_wgl_sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3da5951a1569dbab865c6f2a863efafff193a93caf05538d193e9e3816d21696" -dependencies = [ - "gl_generator", -] - [[package]] name = "go_to_line" version = "0.1.0" @@ -2561,15 +2186,15 @@ dependencies = [ "cc", "cocoa", "collections", - "core-foundation 0.9.3", - "core-graphics 0.22.3", + "core-foundation", + "core-graphics", "core-text", "ctor", "dhat", "env_logger", "etagere", "font-kit", - "foreign-types 0.3.2", + "foreign-types", "futures", "gpui_macros", "image", @@ -2856,12 +2481,6 @@ dependencies = [ "tokio-native-tls", ] -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - [[package]] name = "idna" version = "0.2.3" @@ -2927,26 +2546,6 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05a0bd019339e5d968b37855180087b7b9d512c5046fbd244cf8c95687927d6e" -[[package]] -name = "inotify" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4816c66d2c8ae673df83366c18341538f234a26d65a9ecea5c348b453ac1d02f" -dependencies = [ - "bitflags", - "inotify-sys", - "libc", -] - -[[package]] -name = "inotify-sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" -dependencies = [ - "libc", -] - [[package]] name = "instant" version = "0.1.12" @@ -2954,9 +2553,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ "cfg-if 1.0.0", - "js-sys", - "wasm-bindgen", - "web-sys", ] [[package]] @@ -3076,12 +2672,6 @@ dependencies = [ "cc", ] -[[package]] -name = "jni-sys" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" - [[package]] name = "jobserver" version = "0.1.24" @@ -3138,12 +2728,6 @@ dependencies = [ "winapi-build", ] -[[package]] -name = "khronos_api" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" - [[package]] name = "kurbo" version = "0.8.3" @@ -3193,12 +2777,6 @@ dependencies = [ "util", ] -[[package]] -name = "lazy-bytes-cast" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10257499f089cd156ad82d0a9cd57d9501fa2c989068992a97eb3c27836f206b" - [[package]] name = "lazy_static" version = "1.4.0" @@ -3449,24 +3027,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memmap2" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b6c2ebff6180198788f5db08d7ce3bc1d0b617176678831a7510825973e357" -dependencies = [ - "libc", -] - -[[package]] -name = "memmap2" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a79b39c93a7a5a27eeaf9a23b5ff43f1b9e0ad6b1cdd441140ae53c35613fc7" -dependencies = [ - "libc", -] - [[package]] name = "memoffset" version = "0.6.5" @@ -3492,7 +3052,7 @@ dependencies = [ "bitflags", "block", "cocoa-foundation", - "foreign-types 0.3.2", + "foreign-types", "log", "objc", ] @@ -3664,59 +3224,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "ndk" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d868f654c72e75f8687572699cdabe755f03effbb62542768e995d5b8d699d" -dependencies = [ - "bitflags", - "jni-sys", - "ndk-sys", - "num_enum", - "thiserror", -] - -[[package]] -name = "ndk-context" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" - -[[package]] -name = "ndk-glue" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71bee8ea72d685477e28bd004cfe1bf99c754d688cd78cad139eae4089484d4" -dependencies = [ - "lazy_static", - "libc", - "log", - "ndk", - "ndk-context", - "ndk-macro", - "ndk-sys", -] - -[[package]] -name = "ndk-macro" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df7ac00c4672f9d5aece54ee3347520b7e20f158656c7db2e6de01902eb7a6c" -dependencies = [ - "darling", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ndk-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1bcdd74c20ad5d95aacd60ef9ba40fdf77f767051040541df557b7a9b2a2121" - [[package]] name = "net2" version = "0.2.37" @@ -3741,17 +3248,6 @@ dependencies = [ "memoffset", ] -[[package]] -name = "nix" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f17df307904acd05aa8e32e97bb20f2a0df1728bbc2d771ae8f9a90463441e9" -dependencies = [ - "bitflags", - "cfg-if 1.0.0", - "libc", -] - [[package]] name = "nom" version = "7.1.1" @@ -3762,24 +3258,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "notify" -version = "4.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae03c8c853dba7bfd23e571ff0cff7bc9dceb40a4cd684cd1681824183f45257" -dependencies = [ - "bitflags", - "filetime", - "fsevent 0.4.0", - "fsevent-sys 2.0.1", - "inotify", - "libc", - "mio 0.6.23", - "mio-extras", - "walkdir", - "winapi 0.3.9", -] - [[package]] name = "num-bigint" version = "0.4.3" @@ -3861,27 +3339,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num_enum" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9" -dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "num_threads" version = "0.1.6" @@ -3901,17 +3358,6 @@ dependencies = [ "objc_exception", ] -[[package]] -name = "objc-foundation" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" -dependencies = [ - "block", - "objc", - "objc_id", -] - [[package]] name = "objc_exception" version = "0.1.2" @@ -3921,15 +3367,6 @@ dependencies = [ "cc", ] -[[package]] -name = "objc_id" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" -dependencies = [ - "objc", -] - [[package]] name = "object" version = "0.28.4" @@ -3962,7 +3399,7 @@ checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e" dependencies = [ "bitflags", "cfg-if 1.0.0", - "foreign-types 0.3.2", + "foreign-types", "libc", "once_cell", "openssl-macros", @@ -4014,15 +3451,6 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" -[[package]] -name = "osmesa-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b" -dependencies = [ - "shared_library", -] - [[package]] name = "outline" version = "0.1.0" @@ -4136,7 +3564,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39fe46acc5503595e5949c17b818714d26fdf9b4920eacf3b2947f0199f4a6ff" dependencies = [ - "rustc_version 0.3.3", + "rustc_version", ] [[package]] @@ -4358,16 +3786,6 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" -[[package]] -name = "proc-macro-crate" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" -dependencies = [ - "thiserror", - "toml", -] - [[package]] name = "proc-macro-error" version = "1.0.4" @@ -4411,7 +3829,7 @@ dependencies = [ "client", "clock", "collections", - "fsevent 2.0.2", + "fsevent", "futures", "fuzzy", "gpui", @@ -4601,15 +4019,6 @@ dependencies = [ "unicase", ] -[[package]] -name = "quick-xml" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8533f14c8382aaad0d592c812ac3b826162128b65662331e1127b45c3d18536b" -dependencies = [ - "memchr", -] - [[package]] name = "quote" version = "1.0.20" @@ -4718,15 +4127,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "raw-window-handle" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41" -dependencies = [ - "cty", -] - [[package]] name = "rayon" version = "1.5.3" @@ -5041,16 +4441,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" dependencies = [ - "semver 0.11.0", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver 1.0.12", + "semver", ] [[package]] @@ -5192,12 +4583,6 @@ dependencies = [ "syn", ] -[[package]] -name = "scoped-tls" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" - [[package]] name = "scoped_threadpool" version = "0.1.9" @@ -5280,8 +4665,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dc14f172faf8a0194a3aded622712b0de276821addc574fa54fc0a1167e10dc" dependencies = [ "bitflags", - "core-foundation 0.9.3", - "core-foundation-sys 0.8.3", + "core-foundation", + "core-foundation-sys", "libc", "security-framework-sys", ] @@ -5292,7 +4677,7 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" dependencies = [ - "core-foundation-sys 0.8.3", + "core-foundation-sys", "libc", ] @@ -5305,12 +4690,6 @@ dependencies = [ "semver-parser", ] -[[package]] -name = "semver" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1" - [[package]] name = "semver-parser" version = "0.10.2" @@ -5518,16 +4897,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "shared_library" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" -dependencies = [ - "lazy_static", - "libc", -] - [[package]] name = "shellexpand" version = "2.1.0" @@ -5647,53 +5016,6 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" -[[package]] -name = "smithay-client-toolkit" -version = "0.15.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a28f16a97fa0e8ce563b2774d1e732dd5d4025d2772c5dba0a41a0f90a29da3" -dependencies = [ - "bitflags", - "calloop", - "dlib", - "lazy_static", - "log", - "memmap2 0.3.1", - "nix 0.22.3", - "pkg-config", - "wayland-client", - "wayland-cursor", - "wayland-protocols", -] - -[[package]] -name = "smithay-client-toolkit" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f307c47d32d2715eb2e0ece5589057820e0e5e70d07c247d1063e844e107f454" -dependencies = [ - "bitflags", - "dlib", - "lazy_static", - "log", - "memmap2 0.5.5", - "nix 0.24.1", - "pkg-config", - "wayland-client", - "wayland-cursor", - "wayland-protocols", -] - -[[package]] -name = "smithay-clipboard" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a345c870a1fae0b1b779085e81b51e614767c239e93503588e54c5b17f4b0e8" -dependencies = [ - "smithay-client-toolkit 0.16.0", - "wayland-client", -] - [[package]] name = "smol" version = "1.2.5" @@ -5891,30 +5213,6 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "structopt" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" -dependencies = [ - "clap 2.34.0", - "lazy_static", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" -dependencies = [ - "heck 0.3.3", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "subtle" version = "2.4.1" @@ -6055,7 +5353,6 @@ dependencies = [ name = "terminal" version = "0.1.0" dependencies = [ - "alacritty", "alacritty_terminal", "client", "dirs 4.0.0", @@ -6845,7 +6142,7 @@ dependencies = [ "fontdb", "kurbo", "log", - "memmap2 0.2.3", + "memmap2", "pico-args", "rctree", "roxmltree", @@ -6958,26 +6255,6 @@ dependencies = [ "workspace", ] -[[package]] -name = "vswhom" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b" -dependencies = [ - "libc", - "vswhom-sys", -] - -[[package]] -name = "vswhom-sys" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22025f6d8eb903ebf920ea6933b70b1e495be37e2cb4099e62c80454aaf57c39" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "vte" version = "0.10.1" @@ -7396,89 +6673,6 @@ dependencies = [ "wast 43.0.0", ] -[[package]] -name = "wayland-client" -version = "0.29.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91223460e73257f697d9e23d401279123d36039a3f7a449e983f123292d4458f" -dependencies = [ - "bitflags", - "downcast-rs", - "libc", - "nix 0.22.3", - "scoped-tls", - "wayland-commons", - "wayland-scanner", - "wayland-sys", -] - -[[package]] -name = "wayland-commons" -version = "0.29.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94f6e5e340d7c13490eca867898c4cec5af56c27a5ffe5c80c6fc4708e22d33e" -dependencies = [ - "nix 0.22.3", - "once_cell", - "smallvec", - "wayland-sys", -] - -[[package]] -name = "wayland-cursor" -version = "0.29.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c52758f13d5e7861fc83d942d3d99bf270c83269575e52ac29e5b73cb956a6bd" -dependencies = [ - "nix 0.22.3", - "wayland-client", - "xcursor", -] - -[[package]] -name = "wayland-egl" -version = "0.29.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83281d69ee162b59031c666385e93bde4039ec553b90c4191cdb128ceea29a3a" -dependencies = [ - "wayland-client", - "wayland-sys", -] - -[[package]] -name = "wayland-protocols" -version = "0.29.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60147ae23303402e41fe034f74fb2c35ad0780ee88a1c40ac09a3be1e7465741" -dependencies = [ - "bitflags", - "wayland-client", - "wayland-commons", - "wayland-scanner", -] - -[[package]] -name = "wayland-scanner" -version = "0.29.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39a1ed3143f7a143187156a2ab52742e89dac33245ba505c17224df48939f9e0" -dependencies = [ - "proc-macro2", - "quote", - "xml-rs", -] - -[[package]] -name = "wayland-sys" -version = "0.29.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9341df79a8975679188e37dab3889bfa57c44ac2cb6da166f519a81cbe452d4" -dependencies = [ - "dlib", - "lazy_static", - "pkg-config", -] - [[package]] name = "web-sys" version = "0.3.58" @@ -7691,40 +6885,6 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" -[[package]] -name = "winit" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b43cc931d58b99461188607efd7acb2a093e65fc621f54cad78517a6063e73a" -dependencies = [ - "bitflags", - "cocoa", - "core-foundation 0.9.3", - "core-graphics 0.22.3", - "core-video-sys", - "dispatch", - "instant", - "lazy_static", - "libc", - "log", - "mio 0.8.4", - "ndk", - "ndk-glue", - "ndk-sys", - "objc", - "parking_lot 0.11.2", - "percent-encoding", - "raw-window-handle", - "serde", - "smithay-client-toolkit 0.15.4", - "wasm-bindgen", - "wayland-client", - "wayland-protocols", - "web-sys", - "winapi 0.3.9", - "x11-dl", -] - [[package]] name = "winreg" version = "0.10.1" @@ -7801,55 +6961,6 @@ dependencies = [ "winapi-build", ] -[[package]] -name = "x11-clipboard" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473068b7b80ac86a18328824f1054e5e007898c47b5bbc281bd7abe32bc3653c" -dependencies = [ - "xcb", -] - -[[package]] -name = "x11-dl" -version = "2.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea26926b4ce81a6f5d9d0f3a0bc401e5a37c6ae14a1bfaa8ff6099ca80038c59" -dependencies = [ - "lazy_static", - "libc", - "pkg-config", -] - -[[package]] -name = "xcb" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771e2b996df720cd1c6dd9ff90f62d91698fd3610cc078388d0564bdd6622a9c" -dependencies = [ - "libc", - "log", - "quick-xml", -] - -[[package]] -name = "xcursor" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "463705a63313cd4301184381c5e8042f0a7e9b4bb63653f216311d4ae74690b7" -dependencies = [ - "nom", -] - -[[package]] -name = "xdg" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4583db5cbd4c4c0303df2d15af80f0539db703fa1c68802d4cbbd2dd0f88f6" -dependencies = [ - "dirs 4.0.0", -] - [[package]] name = "xml-rs" version = "0.8.4" @@ -7906,7 +7017,7 @@ dependencies = [ "editor", "env_logger", "file_finder", - "fsevent 2.0.2", + "fsevent", "futures", "fuzzy", "go_to_line", diff --git a/crates/terminal/Cargo.toml b/crates/terminal/Cargo.toml index 63894b57f08d448cab8221e20b0aaac0dfc50ef4..ee67e644b0bcc3b4e6c6f5434d6382b36ccd588d 100644 --- a/crates/terminal/Cargo.toml +++ b/crates/terminal/Cargo.toml @@ -28,4 +28,3 @@ gpui = { path = "../gpui", features = ["test-support"] } client = { path = "../client", features = ["test-support"]} project = { path = "../project", features = ["test-support"]} workspace = { path = "../workspace", features = ["test-support"] } -alacritty = "0.10.1" \ No newline at end of file diff --git a/crates/terminal/src/connection/events.rs b/crates/terminal/src/connection/events.rs index 14a3b873c70719365780c4320cae821f4bdb6cdd..ae14e296b5f7be9aa7dde35c8c67d884e9609837 100644 --- a/crates/terminal/src/connection/events.rs +++ b/crates/terminal/src/connection/events.rs @@ -1,7 +1,20 @@ use alacritty_terminal::term::TermMode; use gpui::keymap::Keystroke; -pub enum ModifierCombinations { +/* +Design notes: +I would like terminal mode checking to be concealed behind the TerminalConnection in as many ways as possible. +Alacritty has a lot of stuff intermixed for it's input handling. TerminalConnection should be in charge +of anything that needs to conform to a standard that isn't handled by Term, e.g.: +- Reporting mouse events correctly. +- Reporting scrolls -> Depends on MOUSE_MODE, ALT_SCREEN, and ALTERNATE_SCROLL, etc. +- Correctly bracketing a paste +- Storing changed colors +- Focus change sequence +*/ + +#[derive(Debug)] +pub enum Modifiers { None, Alt, Ctrl, @@ -10,168 +23,168 @@ pub enum ModifierCombinations { Other, } -impl ModifierCombinations { +impl Modifiers { fn new(ks: &Keystroke) -> Self { match (ks.alt, ks.ctrl, ks.shift, ks.cmd) { - (false, false, false, false) => ModifierCombinations::None, - (true, false, false, false) => ModifierCombinations::Alt, - (false, true, false, false) => ModifierCombinations::Ctrl, - (false, false, true, false) => ModifierCombinations::Shift, - (false, true, true, false) => ModifierCombinations::CtrlShift, - _ => ModifierCombinations::Other, + (false, false, false, false) => Modifiers::None, + (true, false, false, false) => Modifiers::Alt, + (false, true, false, false) => Modifiers::Ctrl, + (false, false, true, false) => Modifiers::Shift, + (false, true, true, false) => Modifiers::CtrlShift, + _ => Modifiers::Other, } } } pub fn to_esc_str(keystroke: &Keystroke, mode: &TermMode) -> Option { - let modifiers = ModifierCombinations::new(&keystroke); + let modifiers = Modifiers::new(&keystroke); // Manual Bindings including modifiers let manual_esc_str = match (keystroke.key.as_ref(), modifiers) { //Basic special keys - ("space", ModifierCombinations::None) => Some(" ".to_string()), - ("tab", ModifierCombinations::None) => Some("\x09".to_string()), - ("escape", ModifierCombinations::None) => Some("\x1b".to_string()), - ("enter", ModifierCombinations::None) => Some("\x0d".to_string()), - ("backspace", ModifierCombinations::None) => Some("\x7f".to_string()), + ("space", Modifiers::None) => Some(" ".to_string()), + ("tab", Modifiers::None) => Some("\x09".to_string()), + ("escape", Modifiers::None) => Some("\x1b".to_string()), + ("enter", Modifiers::None) => Some("\x0d".to_string()), + ("backspace", Modifiers::None) => Some("\x7f".to_string()), //Interesting escape codes - ("tab", ModifierCombinations::Shift) => Some("\x1b[Z".to_string()), - ("backspace", ModifierCombinations::Alt) => Some("\x1b\x7f".to_string()), - ("backspace", ModifierCombinations::Shift) => Some("\x7f".to_string()), - ("home", ModifierCombinations::Shift) if mode.contains(TermMode::ALT_SCREEN) => { + ("tab", Modifiers::Shift) => Some("\x1b[Z".to_string()), + ("backspace", Modifiers::Alt) => Some("\x1b\x7f".to_string()), + ("backspace", Modifiers::Shift) => Some("\x7f".to_string()), + ("home", Modifiers::Shift) if mode.contains(TermMode::ALT_SCREEN) => { Some("\x1b[1;2H".to_string()) } - ("end", ModifierCombinations::Shift) if mode.contains(TermMode::ALT_SCREEN) => { + ("end", Modifiers::Shift) if mode.contains(TermMode::ALT_SCREEN) => { Some("\x1b[1;2F".to_string()) } - ("pageup", ModifierCombinations::Shift) if mode.contains(TermMode::ALT_SCREEN) => { + ("pageup", Modifiers::Shift) if mode.contains(TermMode::ALT_SCREEN) => { Some("\x1b[5;2~".to_string()) } - ("pagedown", ModifierCombinations::Shift) if mode.contains(TermMode::ALT_SCREEN) => { + ("pagedown", Modifiers::Shift) if mode.contains(TermMode::ALT_SCREEN) => { Some("\x1b[6;2~".to_string()) } - ("home", ModifierCombinations::None) if mode.contains(TermMode::APP_CURSOR) => { + ("home", Modifiers::None) if mode.contains(TermMode::APP_CURSOR) => { Some("\x1bOH".to_string()) } - ("home", ModifierCombinations::None) if !mode.contains(TermMode::APP_CURSOR) => { + ("home", Modifiers::None) if !mode.contains(TermMode::APP_CURSOR) => { Some("\x1b[H".to_string()) } - ("end", ModifierCombinations::None) if mode.contains(TermMode::APP_CURSOR) => { + ("end", Modifiers::None) if mode.contains(TermMode::APP_CURSOR) => { Some("\x1bOF".to_string()) } - ("end", ModifierCombinations::None) if !mode.contains(TermMode::APP_CURSOR) => { + ("end", Modifiers::None) if !mode.contains(TermMode::APP_CURSOR) => { Some("\x1b[F".to_string()) } - ("up", ModifierCombinations::None) if mode.contains(TermMode::APP_CURSOR) => { + ("up", Modifiers::None) if mode.contains(TermMode::APP_CURSOR) => { Some("\x1bOA".to_string()) } - ("up", ModifierCombinations::None) if !mode.contains(TermMode::APP_CURSOR) => { + ("up", Modifiers::None) if !mode.contains(TermMode::APP_CURSOR) => { Some("\x1b[A".to_string()) } - ("down", ModifierCombinations::None) if mode.contains(TermMode::APP_CURSOR) => { + ("down", Modifiers::None) if mode.contains(TermMode::APP_CURSOR) => { Some("\x1bOB".to_string()) } - ("down", ModifierCombinations::None) if !mode.contains(TermMode::APP_CURSOR) => { + ("down", Modifiers::None) if !mode.contains(TermMode::APP_CURSOR) => { Some("\x1b[B".to_string()) } - ("right", ModifierCombinations::None) if mode.contains(TermMode::APP_CURSOR) => { + ("right", Modifiers::None) if mode.contains(TermMode::APP_CURSOR) => { Some("\x1bOC".to_string()) } - ("right", ModifierCombinations::None) if !mode.contains(TermMode::APP_CURSOR) => { + ("right", Modifiers::None) if !mode.contains(TermMode::APP_CURSOR) => { Some("\x1b[C".to_string()) } - ("left", ModifierCombinations::None) if mode.contains(TermMode::APP_CURSOR) => { + ("left", Modifiers::None) if mode.contains(TermMode::APP_CURSOR) => { Some("\x1bOD".to_string()) } - ("left", ModifierCombinations::None) if !mode.contains(TermMode::APP_CURSOR) => { + ("left", Modifiers::None) if !mode.contains(TermMode::APP_CURSOR) => { Some("\x1b[D".to_string()) } - ("back", ModifierCombinations::None) => Some("\x7f".to_string()), - ("insert", ModifierCombinations::None) => Some("\x1b[2~".to_string()), - ("delete", ModifierCombinations::None) => Some("\x1b[3~".to_string()), - ("pageup", ModifierCombinations::None) => Some("\x1b[5~".to_string()), - ("pagedown", ModifierCombinations::None) => Some("\x1b[6~".to_string()), - ("f1", ModifierCombinations::None) => Some("\x1bOP".to_string()), - ("f2", ModifierCombinations::None) => Some("\x1bOQ".to_string()), - ("f3", ModifierCombinations::None) => Some("\x1bOR".to_string()), - ("f4", ModifierCombinations::None) => Some("\x1bOS".to_string()), - ("f5", ModifierCombinations::None) => Some("\x1b[15~".to_string()), - ("f6", ModifierCombinations::None) => Some("\x1b[17~".to_string()), - ("f7", ModifierCombinations::None) => Some("\x1b[18~".to_string()), - ("f8", ModifierCombinations::None) => Some("\x1b[19~".to_string()), - ("f9", ModifierCombinations::None) => Some("\x1b[20~".to_string()), - ("f10", ModifierCombinations::None) => Some("\x1b[21~".to_string()), - ("f11", ModifierCombinations::None) => Some("\x1b[23~".to_string()), - ("f12", ModifierCombinations::None) => Some("\x1b[24~".to_string()), - ("f13", ModifierCombinations::None) => Some("\x1b[25~".to_string()), - ("f14", ModifierCombinations::None) => Some("\x1b[26~".to_string()), - ("f15", ModifierCombinations::None) => Some("\x1b[28~".to_string()), - ("f16", ModifierCombinations::None) => Some("\x1b[29~".to_string()), - ("f17", ModifierCombinations::None) => Some("\x1b[31~".to_string()), - ("f18", ModifierCombinations::None) => Some("\x1b[32~".to_string()), - ("f19", ModifierCombinations::None) => Some("\x1b[33~".to_string()), - ("f20", ModifierCombinations::None) => Some("\x1b[34~".to_string()), + ("back", Modifiers::None) => Some("\x7f".to_string()), + ("insert", Modifiers::None) => Some("\x1b[2~".to_string()), + ("delete", Modifiers::None) => Some("\x1b[3~".to_string()), + ("pageup", Modifiers::None) => Some("\x1b[5~".to_string()), + ("pagedown", Modifiers::None) => Some("\x1b[6~".to_string()), + ("f1", Modifiers::None) => Some("\x1bOP".to_string()), + ("f2", Modifiers::None) => Some("\x1bOQ".to_string()), + ("f3", Modifiers::None) => Some("\x1bOR".to_string()), + ("f4", Modifiers::None) => Some("\x1bOS".to_string()), + ("f5", Modifiers::None) => Some("\x1b[15~".to_string()), + ("f6", Modifiers::None) => Some("\x1b[17~".to_string()), + ("f7", Modifiers::None) => Some("\x1b[18~".to_string()), + ("f8", Modifiers::None) => Some("\x1b[19~".to_string()), + ("f9", Modifiers::None) => Some("\x1b[20~".to_string()), + ("f10", Modifiers::None) => Some("\x1b[21~".to_string()), + ("f11", Modifiers::None) => Some("\x1b[23~".to_string()), + ("f12", Modifiers::None) => Some("\x1b[24~".to_string()), + ("f13", Modifiers::None) => Some("\x1b[25~".to_string()), + ("f14", Modifiers::None) => Some("\x1b[26~".to_string()), + ("f15", Modifiers::None) => Some("\x1b[28~".to_string()), + ("f16", Modifiers::None) => Some("\x1b[29~".to_string()), + ("f17", Modifiers::None) => Some("\x1b[31~".to_string()), + ("f18", Modifiers::None) => Some("\x1b[32~".to_string()), + ("f19", Modifiers::None) => Some("\x1b[33~".to_string()), + ("f20", Modifiers::None) => Some("\x1b[34~".to_string()), // NumpadEnter, Action::Esc("\n".into()); //Mappings for caret notation keys - ("a", ModifierCombinations::Ctrl) => Some("\x01".to_string()), //1 - ("A", ModifierCombinations::CtrlShift) => Some("\x01".to_string()), //1 - ("b", ModifierCombinations::Ctrl) => Some("\x02".to_string()), //2 - ("B", ModifierCombinations::CtrlShift) => Some("\x02".to_string()), //2 - ("c", ModifierCombinations::Ctrl) => Some("\x03".to_string()), //3 - ("C", ModifierCombinations::CtrlShift) => Some("\x03".to_string()), //3 - ("d", ModifierCombinations::Ctrl) => Some("\x04".to_string()), //4 - ("D", ModifierCombinations::CtrlShift) => Some("\x04".to_string()), //4 - ("e", ModifierCombinations::Ctrl) => Some("\x05".to_string()), //5 - ("E", ModifierCombinations::CtrlShift) => Some("\x05".to_string()), //5 - ("f", ModifierCombinations::Ctrl) => Some("\x06".to_string()), //6 - ("F", ModifierCombinations::CtrlShift) => Some("\x06".to_string()), //6 - ("g", ModifierCombinations::Ctrl) => Some("\x07".to_string()), //7 - ("G", ModifierCombinations::CtrlShift) => Some("\x07".to_string()), //7 - ("h", ModifierCombinations::Ctrl) => Some("\x08".to_string()), //8 - ("H", ModifierCombinations::CtrlShift) => Some("\x08".to_string()), //8 - ("i", ModifierCombinations::Ctrl) => Some("\x09".to_string()), //9 - ("I", ModifierCombinations::CtrlShift) => Some("\x09".to_string()), //9 - ("j", ModifierCombinations::Ctrl) => Some("\x0a".to_string()), //10 - ("J", ModifierCombinations::CtrlShift) => Some("\x0a".to_string()), //10 - ("k", ModifierCombinations::Ctrl) => Some("\x0b".to_string()), //11 - ("K", ModifierCombinations::CtrlShift) => Some("\x0b".to_string()), //11 - ("l", ModifierCombinations::Ctrl) => Some("\x0c".to_string()), //12 - ("L", ModifierCombinations::CtrlShift) => Some("\x0c".to_string()), //12 - ("m", ModifierCombinations::Ctrl) => Some("\x0d".to_string()), //13 - ("M", ModifierCombinations::CtrlShift) => Some("\x0d".to_string()), //13 - ("n", ModifierCombinations::Ctrl) => Some("\x0e".to_string()), //14 - ("N", ModifierCombinations::CtrlShift) => Some("\x0e".to_string()), //14 - ("o", ModifierCombinations::Ctrl) => Some("\x0f".to_string()), //15 - ("O", ModifierCombinations::CtrlShift) => Some("\x0f".to_string()), //15 - ("p", ModifierCombinations::Ctrl) => Some("\x10".to_string()), //16 - ("P", ModifierCombinations::CtrlShift) => Some("\x10".to_string()), //16 - ("q", ModifierCombinations::Ctrl) => Some("\x11".to_string()), //17 - ("Q", ModifierCombinations::CtrlShift) => Some("\x11".to_string()), //17 - ("r", ModifierCombinations::Ctrl) => Some("\x12".to_string()), //18 - ("R", ModifierCombinations::CtrlShift) => Some("\x12".to_string()), //18 - ("s", ModifierCombinations::Ctrl) => Some("\x13".to_string()), //19 - ("S", ModifierCombinations::CtrlShift) => Some("\x13".to_string()), //19 - ("t", ModifierCombinations::Ctrl) => Some("\x14".to_string()), //20 - ("T", ModifierCombinations::CtrlShift) => Some("\x14".to_string()), //20 - ("u", ModifierCombinations::Ctrl) => Some("\x15".to_string()), //21 - ("U", ModifierCombinations::CtrlShift) => Some("\x15".to_string()), //21 - ("v", ModifierCombinations::Ctrl) => Some("\x16".to_string()), //22 - ("V", ModifierCombinations::CtrlShift) => Some("\x16".to_string()), //22 - ("w", ModifierCombinations::Ctrl) => Some("\x17".to_string()), //23 - ("W", ModifierCombinations::CtrlShift) => Some("\x17".to_string()), //23 - ("x", ModifierCombinations::Ctrl) => Some("\x18".to_string()), //24 - ("X", ModifierCombinations::CtrlShift) => Some("\x18".to_string()), //24 - ("y", ModifierCombinations::Ctrl) => Some("\x19".to_string()), //25 - ("Y", ModifierCombinations::CtrlShift) => Some("\x19".to_string()), //25 - ("z", ModifierCombinations::Ctrl) => Some("\x1a".to_string()), //26 - ("Z", ModifierCombinations::CtrlShift) => Some("\x1a".to_string()), //26 - ("@", ModifierCombinations::Ctrl) => Some("\x00".to_string()), //0 - ("[", ModifierCombinations::Ctrl) => Some("\x1b".to_string()), //27 - ("\\", ModifierCombinations::Ctrl) => Some("\x1c".to_string()), //28 - ("]", ModifierCombinations::Ctrl) => Some("\x1d".to_string()), //29 - ("^", ModifierCombinations::Ctrl) => Some("\x1e".to_string()), //30 - ("_", ModifierCombinations::Ctrl) => Some("\x1f".to_string()), //31 - ("?", ModifierCombinations::Ctrl) => Some("\x7f".to_string()), //127 + ("a", Modifiers::Ctrl) => Some("\x01".to_string()), //1 + ("A", Modifiers::CtrlShift) => Some("\x01".to_string()), //1 + ("b", Modifiers::Ctrl) => Some("\x02".to_string()), //2 + ("B", Modifiers::CtrlShift) => Some("\x02".to_string()), //2 + ("c", Modifiers::Ctrl) => Some("\x03".to_string()), //3 + ("C", Modifiers::CtrlShift) => Some("\x03".to_string()), //3 + ("d", Modifiers::Ctrl) => Some("\x04".to_string()), //4 + ("D", Modifiers::CtrlShift) => Some("\x04".to_string()), //4 + ("e", Modifiers::Ctrl) => Some("\x05".to_string()), //5 + ("E", Modifiers::CtrlShift) => Some("\x05".to_string()), //5 + ("f", Modifiers::Ctrl) => Some("\x06".to_string()), //6 + ("F", Modifiers::CtrlShift) => Some("\x06".to_string()), //6 + ("g", Modifiers::Ctrl) => Some("\x07".to_string()), //7 + ("G", Modifiers::CtrlShift) => Some("\x07".to_string()), //7 + ("h", Modifiers::Ctrl) => Some("\x08".to_string()), //8 + ("H", Modifiers::CtrlShift) => Some("\x08".to_string()), //8 + ("i", Modifiers::Ctrl) => Some("\x09".to_string()), //9 + ("I", Modifiers::CtrlShift) => Some("\x09".to_string()), //9 + ("j", Modifiers::Ctrl) => Some("\x0a".to_string()), //10 + ("J", Modifiers::CtrlShift) => Some("\x0a".to_string()), //10 + ("k", Modifiers::Ctrl) => Some("\x0b".to_string()), //11 + ("K", Modifiers::CtrlShift) => Some("\x0b".to_string()), //11 + ("l", Modifiers::Ctrl) => Some("\x0c".to_string()), //12 + ("L", Modifiers::CtrlShift) => Some("\x0c".to_string()), //12 + ("m", Modifiers::Ctrl) => Some("\x0d".to_string()), //13 + ("M", Modifiers::CtrlShift) => Some("\x0d".to_string()), //13 + ("n", Modifiers::Ctrl) => Some("\x0e".to_string()), //14 + ("N", Modifiers::CtrlShift) => Some("\x0e".to_string()), //14 + ("o", Modifiers::Ctrl) => Some("\x0f".to_string()), //15 + ("O", Modifiers::CtrlShift) => Some("\x0f".to_string()), //15 + ("p", Modifiers::Ctrl) => Some("\x10".to_string()), //16 + ("P", Modifiers::CtrlShift) => Some("\x10".to_string()), //16 + ("q", Modifiers::Ctrl) => Some("\x11".to_string()), //17 + ("Q", Modifiers::CtrlShift) => Some("\x11".to_string()), //17 + ("r", Modifiers::Ctrl) => Some("\x12".to_string()), //18 + ("R", Modifiers::CtrlShift) => Some("\x12".to_string()), //18 + ("s", Modifiers::Ctrl) => Some("\x13".to_string()), //19 + ("S", Modifiers::CtrlShift) => Some("\x13".to_string()), //19 + ("t", Modifiers::Ctrl) => Some("\x14".to_string()), //20 + ("T", Modifiers::CtrlShift) => Some("\x14".to_string()), //20 + ("u", Modifiers::Ctrl) => Some("\x15".to_string()), //21 + ("U", Modifiers::CtrlShift) => Some("\x15".to_string()), //21 + ("v", Modifiers::Ctrl) => Some("\x16".to_string()), //22 + ("V", Modifiers::CtrlShift) => Some("\x16".to_string()), //22 + ("w", Modifiers::Ctrl) => Some("\x17".to_string()), //23 + ("W", Modifiers::CtrlShift) => Some("\x17".to_string()), //23 + ("x", Modifiers::Ctrl) => Some("\x18".to_string()), //24 + ("X", Modifiers::CtrlShift) => Some("\x18".to_string()), //24 + ("y", Modifiers::Ctrl) => Some("\x19".to_string()), //25 + ("Y", Modifiers::CtrlShift) => Some("\x19".to_string()), //25 + ("z", Modifiers::Ctrl) => Some("\x1a".to_string()), //26 + ("Z", Modifiers::CtrlShift) => Some("\x1a".to_string()), //26 + ("@", Modifiers::Ctrl) => Some("\x00".to_string()), //0 + ("[", Modifiers::Ctrl) => Some("\x1b".to_string()), //27 + ("\\", Modifiers::Ctrl) => Some("\x1c".to_string()), //28 + ("]", Modifiers::Ctrl) => Some("\x1d".to_string()), //29 + ("^", Modifiers::Ctrl) => Some("\x1e".to_string()), //30 + ("_", Modifiers::Ctrl) => Some("\x1f".to_string()), //31 + ("?", Modifiers::Ctrl) => Some("\x7f".to_string()), //127 _ => None, }; if manual_esc_str.is_some() { @@ -226,62 +239,6 @@ pub fn to_esc_str(keystroke: &Keystroke, mode: &TermMode) -> Option { } } -/* -New keybindings test plan: - -Is the terminal still usable? YES! -Do ctrl-shift-[X] and ctrl-[x] do the same thing? I THINK SO -Does ctrl-l work? YES -Does tab work? YES -Do all the global overrides (up, down, enter, escape, ctrl-c) work? => YES -Space also doesn't work YES! - - - -So, to match alacritty keyboard handling, we need to check APP_CURSOR, and ALT_SCREEN - -And we need to convert the strings that GPUI returns to keys - -And we need a way of easily declaring and matching a modifier pattern on those keys - -And we need to block writing the input to the pty if any of these match - -And I need to figure out how to express this in a cross platform way - -And a way of optionally interfacing this with actions for rebinding in defaults.json - -Design notes: -I would like terminal mode checking to be concealed behind the TerminalConnection in as many ways as possible. -Alacritty has a lot of stuff intermixed for it's input handling. TerminalConnection should be in charge -of anything that needs to conform to a standard that isn't handled by Term, e.g.: -- Reporting mouse events correctly. -- Reporting scrolls -> Depends on MOUSE_MODE, ALT_SCREEN, and ALTERNATE_SCROLL, etc. -- Correctly bracketing a paste -- Storing changed colors -- Focus change sequence - -Scrolling might be handled internally or externally, need a way to ask. Everything else should probably happen internally. - -Standards/OS compliance is in connection.rs. -This takes GPUI events and translates them to the correct terminal stuff -This means that standards compliance outside of connection should be kept to a minimum. Yes, this feels good. -Connection needs to be split up then, into a bunch of event handlers - -Punting on these by pushing them up to a scrolling element -(either on dispatch_event directly or a seperate scrollbar) - Home, ModifiersState::SHIFT, ~BindingMode::ALT_SCREEN; Action::ScrollToTop; - End, ModifiersState::SHIFT, ~BindingMode::ALT_SCREEN; Action::ScrollToBottom; - PageUp, ModifiersState::SHIFT, ~BindingMode::ALT_SCREEN; Action::ScrollPageUp; - PageDown, ModifiersState::SHIFT, ~BindingMode::ALT_SCREEN; Action::ScrollPageDown; - - - -NOTE, THE FOLLOWING HAS 2 BINDINGS: -K, ModifiersState::LOGO, Action::Esc("\x0c".into()); -K, ModifiersState::LOGO, Action::ClearHistory; => ctx.terminal_mut().clear_screen(ClearMode::Saved), - -*/ - /// Code Modifiers /// ---------+--------------------------- /// 2 | Shift @@ -312,9 +269,47 @@ mod test { use super::*; #[test] - fn test_match_alacritty_keybindings() { - let bindings = alacritty::config::bindings::default_key_bindings(); - //TODO + fn test_application_mode() { + let app_cursor = TermMode::APP_CURSOR; + let none = TermMode::NONE; + + let up = Keystroke::parse("up").unwrap(); + let down = Keystroke::parse("down").unwrap(); + let left = Keystroke::parse("left").unwrap(); + let right = Keystroke::parse("right").unwrap(); + + assert_eq!(to_esc_str(&up, &none), Some("\x1b[A".to_string())); + assert_eq!(to_esc_str(&down, &none), Some("\x1b[B".to_string())); + assert_eq!(to_esc_str(&right, &none), Some("\x1b[C".to_string())); + assert_eq!(to_esc_str(&left, &none), Some("\x1b[D".to_string())); + + assert_eq!(to_esc_str(&up, &app_cursor), Some("\x1bOA".to_string())); + assert_eq!(to_esc_str(&down, &app_cursor), Some("\x1bOB".to_string())); + assert_eq!(to_esc_str(&right, &app_cursor), Some("\x1bOC".to_string())); + assert_eq!(to_esc_str(&left, &app_cursor), Some("\x1bOD".to_string())); + } + + #[test] + fn test_ctrl_codes() { + let letters_lower = 'a'..='z'; + let letters_upper = 'A'..='Z'; + let mode = TermMode::ANY; + + for (lower, upper) in letters_lower.zip(letters_upper) { + assert_eq!( + to_esc_str( + &Keystroke::parse(&format!("ctrl-{}", lower)).unwrap(), + &mode + ), + to_esc_str( + &Keystroke::parse(&format!("ctrl-shift-{}", upper)).unwrap(), + &mode + ), + "On letter: {}/{}", + lower, + upper + ) + } } #[test] From 3e864116277dc2bccc55e359aaef17a84f230774 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 15 Jul 2022 11:20:54 -0700 Subject: [PATCH 8/8] Finished new keybindings system for now --- crates/terminal/src/connection.rs | 4 +- .../connection/{events.rs => keymappings.rs} | 197 ++++++++++++++---- 2 files changed, 153 insertions(+), 48 deletions(-) rename crates/terminal/src/connection/{events.rs => keymappings.rs} (67%) diff --git a/crates/terminal/src/connection.rs b/crates/terminal/src/connection.rs index d17752d3957420491f7f5dd1cf4b60a5e14b97cd..8f48e4ba8b4c73ffeb8d10abd39e86e678ec02bb 100644 --- a/crates/terminal/src/connection.rs +++ b/crates/terminal/src/connection.rs @@ -1,4 +1,4 @@ -mod events; +mod keymappings; use alacritty_terminal::{ ansi::{ClearMode, Handler}, @@ -22,7 +22,7 @@ use crate::{ ZedListener, }; -use self::events::to_esc_str; +use self::keymappings::to_esc_str; const DEFAULT_TITLE: &str = "Terminal"; diff --git a/crates/terminal/src/connection/events.rs b/crates/terminal/src/connection/keymappings.rs similarity index 67% rename from crates/terminal/src/connection/events.rs rename to crates/terminal/src/connection/keymappings.rs index ae14e296b5f7be9aa7dde35c8c67d884e9609837..a4d429843bf17aa51760b69e3b00f8317b681d15 100644 --- a/crates/terminal/src/connection/events.rs +++ b/crates/terminal/src/connection/keymappings.rs @@ -2,12 +2,9 @@ use alacritty_terminal::term::TermMode; use gpui::keymap::Keystroke; /* -Design notes: -I would like terminal mode checking to be concealed behind the TerminalConnection in as many ways as possible. -Alacritty has a lot of stuff intermixed for it's input handling. TerminalConnection should be in charge -of anything that needs to conform to a standard that isn't handled by Term, e.g.: +Connection events still to do: - Reporting mouse events correctly. -- Reporting scrolls -> Depends on MOUSE_MODE, ALT_SCREEN, and ALTERNATE_SCROLL, etc. +- Reporting scrolls - Correctly bracketing a paste - Storing changed colors - Focus change sequence @@ -34,13 +31,24 @@ impl Modifiers { _ => Modifiers::Other, } } + + fn any(&self) -> bool { + match &self { + Modifiers::None => false, + Modifiers::Alt => true, + Modifiers::Ctrl => true, + Modifiers::Shift => true, + Modifiers::CtrlShift => true, + Modifiers::Other => true, + } + } } pub fn to_esc_str(keystroke: &Keystroke, mode: &TermMode) -> Option { let modifiers = Modifiers::new(&keystroke); // Manual Bindings including modifiers - let manual_esc_str = match (keystroke.key.as_ref(), modifiers) { + let manual_esc_str = match (keystroke.key.as_ref(), &modifiers) { //Basic special keys ("space", Modifiers::None) => Some(" ".to_string()), ("tab", Modifiers::None) => Some("\x09".to_string()), @@ -192,53 +200,95 @@ pub fn to_esc_str(keystroke: &Keystroke, mode: &TermMode) -> Option { } // Automated bindings applying modifiers - let modifier_code = modifier_code(&keystroke); - let modified_esc_str = match keystroke.key.as_ref() { - "up" => Some(format!("\x1b[1;{}A", modifier_code)), - "down" => Some(format!("\x1b[1;{}B", modifier_code)), - "right" => Some(format!("\x1b[1;{}C", modifier_code)), - "left" => Some(format!("\x1b[1;{}D", modifier_code)), - "f1" => Some(format!("\x1b[1;{}P", modifier_code)), - "f2" => Some(format!("\x1b[1;{}Q", modifier_code)), - "f3" => Some(format!("\x1b[1;{}R", modifier_code)), - "f4" => Some(format!("\x1b[1;{}S", modifier_code)), - "F5" => Some(format!("\x1b[15;{}~", modifier_code)), - "f6" => Some(format!("\x1b[17;{}~", modifier_code)), - "f7" => Some(format!("\x1b[18;{}~", modifier_code)), - "f8" => Some(format!("\x1b[19;{}~", modifier_code)), - "f9" => Some(format!("\x1b[20;{}~", modifier_code)), - "f10" => Some(format!("\x1b[21;{}~", modifier_code)), - "f11" => Some(format!("\x1b[23;{}~", modifier_code)), - "f12" => Some(format!("\x1b[24;{}~", modifier_code)), - "f13" => Some(format!("\x1b[25;{}~", modifier_code)), - "f14" => Some(format!("\x1b[26;{}~", modifier_code)), - "f15" => Some(format!("\x1b[28;{}~", modifier_code)), - "f16" => Some(format!("\x1b[29;{}~", modifier_code)), - "f17" => Some(format!("\x1b[31;{}~", modifier_code)), - "f18" => Some(format!("\x1b[32;{}~", modifier_code)), - "f19" => Some(format!("\x1b[33;{}~", modifier_code)), - "f20" => Some(format!("\x1b[34;{}~", modifier_code)), - _ if modifier_code == 2 => None, - "insert" => Some(format!("\x1b[2;{}~", modifier_code)), - "pageup" => Some(format!("\x1b[5;{}~", modifier_code)), - "pagedown" => Some(format!("\x1b[6;{}~", modifier_code)), - "end" => Some(format!("\x1b[1;{}F", modifier_code)), - "home" => Some(format!("\x1b[1;{}H", modifier_code)), - _ => None, - }; - if modified_esc_str.is_some() { - return modified_esc_str; + if modifiers.any() { + let modifier_code = modifier_code(&keystroke); + let modified_esc_str = match keystroke.key.as_ref() { + "up" => Some(format!("\x1b[1;{}A", modifier_code)), + "down" => Some(format!("\x1b[1;{}B", modifier_code)), + "right" => Some(format!("\x1b[1;{}C", modifier_code)), + "left" => Some(format!("\x1b[1;{}D", modifier_code)), + "f1" => Some(format!("\x1b[1;{}P", modifier_code)), + "f2" => Some(format!("\x1b[1;{}Q", modifier_code)), + "f3" => Some(format!("\x1b[1;{}R", modifier_code)), + "f4" => Some(format!("\x1b[1;{}S", modifier_code)), + "F5" => Some(format!("\x1b[15;{}~", modifier_code)), + "f6" => Some(format!("\x1b[17;{}~", modifier_code)), + "f7" => Some(format!("\x1b[18;{}~", modifier_code)), + "f8" => Some(format!("\x1b[19;{}~", modifier_code)), + "f9" => Some(format!("\x1b[20;{}~", modifier_code)), + "f10" => Some(format!("\x1b[21;{}~", modifier_code)), + "f11" => Some(format!("\x1b[23;{}~", modifier_code)), + "f12" => Some(format!("\x1b[24;{}~", modifier_code)), + "f13" => Some(format!("\x1b[25;{}~", modifier_code)), + "f14" => Some(format!("\x1b[26;{}~", modifier_code)), + "f15" => Some(format!("\x1b[28;{}~", modifier_code)), + "f16" => Some(format!("\x1b[29;{}~", modifier_code)), + "f17" => Some(format!("\x1b[31;{}~", modifier_code)), + "f18" => Some(format!("\x1b[32;{}~", modifier_code)), + "f19" => Some(format!("\x1b[33;{}~", modifier_code)), + "f20" => Some(format!("\x1b[34;{}~", modifier_code)), + _ if modifier_code == 2 => None, + "insert" => Some(format!("\x1b[2;{}~", modifier_code)), + "pageup" => Some(format!("\x1b[5;{}~", modifier_code)), + "pagedown" => Some(format!("\x1b[6;{}~", modifier_code)), + "end" => Some(format!("\x1b[1;{}F", modifier_code)), + "home" => Some(format!("\x1b[1;{}H", modifier_code)), + _ => None, + }; + if modified_esc_str.is_some() { + return modified_esc_str; + } } - // Fallback to keystroke input sent directly - if keystroke.key.chars().count() == 1 { - //TODO this might fail on unicode during internationalization + //Fallback to sending the keystroke input directly + //Skin colors in utf8 are implemented as a seperate, invisible character + //that modifies the associated emoji. Some languages may have similarly + //implemented modifiers, e.g. certain diacritics that can be typed as a single character. + //This means that we need to assume some user input can result in multi-byte, + //multi-char strings. This is somewhat difficult, as GPUI normalizes all + //keys into a string representation. Hence, the check here to filter out GPUI + //keys that weren't captured above. + if !matches_gpui_key_str(&keystroke.key) { return Some(keystroke.key.clone()); } else { None } } +///Checks if the given string matches a GPUI key string. +///Table made from reading the source at gpui/src/platform/mac/event.rs +fn matches_gpui_key_str(str: &str) -> bool { + match str { + "backspace" => true, + "up" => true, + "down" => true, + "left" => true, + "right" => true, + "pageup" => true, + "pagedown" => true, + "home" => true, + "end" => true, + "delete" => true, + "enter" => true, + "escape" => true, + "tab" => true, + "f1" => true, + "f2" => true, + "f3" => true, + "f4" => true, + "f5" => true, + "f6" => true, + "f7" => true, + "f8" => true, + "f9" => true, + "f10" => true, + "f11" => true, + "f12" => true, + "space" => true, + _ => false, + } +} + /// Code Modifiers /// ---------+--------------------------- /// 2 | Shift @@ -268,6 +318,61 @@ fn modifier_code(keystroke: &Keystroke) -> u32 { mod test { use super::*; + #[test] + fn test_scroll_keys() { + //These keys should be handled by the scrolling element directly + //Need to signify this by returning 'None' + let shift_pageup = Keystroke::parse("shift-pageup").unwrap(); + let shift_pagedown = Keystroke::parse("shift-pagedown").unwrap(); + let shift_home = Keystroke::parse("shift-home").unwrap(); + let shift_end = Keystroke::parse("shift-end").unwrap(); + + let none = TermMode::NONE; + assert_eq!(to_esc_str(&shift_pageup, &none), None); + assert_eq!(to_esc_str(&shift_pagedown, &none), None); + assert_eq!(to_esc_str(&shift_home, &none), None); + assert_eq!(to_esc_str(&shift_end, &none), None); + + let alt_screen = TermMode::ALT_SCREEN; + assert_eq!( + to_esc_str(&shift_pageup, &alt_screen), + Some("\x1b[5;2~".to_string()) + ); + assert_eq!( + to_esc_str(&shift_pagedown, &alt_screen), + Some("\x1b[6;2~".to_string()) + ); + assert_eq!( + to_esc_str(&shift_home, &alt_screen), + Some("\x1b[1;2H".to_string()) + ); + assert_eq!( + to_esc_str(&shift_end, &alt_screen), + Some("\x1b[1;2F".to_string()) + ); + + let pageup = Keystroke::parse("pageup").unwrap(); + let pagedown = Keystroke::parse("pagedown").unwrap(); + let any = TermMode::ANY; + + assert_eq!(to_esc_str(&pageup, &any), Some("\x1b[5~".to_string())); + assert_eq!(to_esc_str(&pagedown, &any), Some("\x1b[6~".to_string())); + } + + #[test] + fn test_multi_char_fallthrough() { + let ks = Keystroke { + ctrl: false, + alt: false, + shift: false, + cmd: false, + + key: "🖖🏻".to_string(), //2 char string + }; + + assert_eq!(to_esc_str(&ks, &TermMode::NONE), Some("🖖🏻".to_string())); + } + #[test] fn test_application_mode() { let app_cursor = TermMode::APP_CURSOR; @@ -325,7 +430,7 @@ mod test { // 8 | Shift + Alt + Control // ---------+--------------------------- // from: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-PC-Style-Function-Keys - // assert_eq!(2, modifier_code(Keystroke::parse("shift-A").unwrap())); + assert_eq!(2, modifier_code(&Keystroke::parse("shift-A").unwrap())); assert_eq!(3, modifier_code(&Keystroke::parse("alt-A").unwrap())); assert_eq!(4, modifier_code(&Keystroke::parse("shift-alt-A").unwrap())); assert_eq!(5, modifier_code(&Keystroke::parse("ctrl-A").unwrap()));