@@ -1,5 +1,21 @@
use gpui::KeyDownEvent;
-fn to_esc_str(event: &KeyDownEvent) -> &str {
- "Test"
+pub fn to_esc_str(event: &KeyDownEvent) -> String {
+ let key = event.keystroke.key.clone();
+ let modifiers = (
+ event.keystroke.alt,
+ event.keystroke.cmd,
+ event.keystroke.ctrl,
+ event.keystroke.shift,
+ );
+ match (key.as_str(), modifiers) {
+ //ctrl-l
+ //shift-tab
+ //alt-back
+ //shift-back
+ //shift + Home, end, page up, page down + NOT alt screen => We handle those
+ //shift + Home, end, page up, page down + alt screen => Send escape sequence
+ ("l", (false, false, true, false)) => "\x0c".to_string(),
+ _ => event.input.clone().unwrap().clone(),
+ }
}
@@ -31,7 +31,10 @@ 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, ScrollTerminal, Terminal, ZedListener};
+use crate::{
+ color_translation::convert_color, keyboard_to_esc::to_esc_str, ScrollTerminal, Terminal,
+ 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
@@ -368,7 +371,7 @@ impl Element for TerminalEl {
dbg!(e);
cx.is_parent_view_focused()
.then(|| {
- cx.dispatch_action(Input(input.to_string()));
+ cx.dispatch_action(Input(to_esc_str(e)));
})
.is_some()
}