aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Dahlberg <thezic@users.noreply.github.com>2019-01-17 22:42:12 +0200
committerChristian Duerr <chrisduerr@users.noreply.github.com>2019-01-17 20:42:12 +0000
commit8b155960708a0ff551c5fc8ec65d2c3c6d12e1da (patch)
treebe24c630e3e967ab9834202679d3de63559287e3
parent0d16478f5d997b6da5488885e15bfb09ca8e7f6d (diff)
downloadalacritty-8b155960708a0ff551c5fc8ec65d2c3c6d12e1da.tar.gz
alacritty-8b155960708a0ff551c5fc8ec65d2c3c6d12e1da.zip
Add config option to send or not send ESC when ALT-key is pressed
-rw-r--r--CHANGELOG.md4
-rw-r--r--alacritty.yml3
-rw-r--r--src/config/mod.rs10
-rw-r--r--src/event.rs4
-rw-r--r--src/input.rs8
5 files changed, 28 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ecba7bd6..cc247c79 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Added
+
+- New `alt_send_esc` option for controlling if alt key should send escape sequences
+
### Changed
- All options in the configuration file are now optional
diff --git a/alacritty.yml b/alacritty.yml
index 50d36b42..f31f0746 100644
--- a/alacritty.yml
+++ b/alacritty.yml
@@ -352,6 +352,9 @@ live_config_reload: true
# backend cannot be initialized.
enable_experimental_conpty_backend: false
+# Send ESC (\x1b) before characters when alt is pressed.
+alt_send_esc: true
+
# Key bindings
#
# Key bindings are specified as a list of objects. Each binding will specify a
diff --git a/src/config/mod.rs b/src/config/mod.rs
index fd40776d..836fe483 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -538,6 +538,10 @@ pub struct Config {
#[serde(default, deserialize_with = "failure_default")]
enable_experimental_conpty_backend: bool,
+ /// Send escape sequences using the alt key.
+ #[serde(default = "default_true_bool", deserialize_with = "deserialize_true_bool")]
+ alt_send_esc: bool,
+
// TODO: DEPRECATED
custom_cursor_colors: Option<bool>,
@@ -1819,6 +1823,12 @@ impl Config {
self.enable_experimental_conpty_backend
}
+ /// Send escape sequences using the alt key
+ #[inline]
+ pub fn alt_send_esc(&self) -> bool {
+ self.alt_send_esc
+ }
+
// Update the history size, used in ref tests
pub fn set_history(&mut self, history: u32) {
self.scrolling.history = history;
diff --git a/src/event.rs b/src/event.rs
index bada4f68..5c6b71d0 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -293,6 +293,7 @@ pub struct Processor<N> {
pending_events: Vec<Event>,
window_changes: WindowChanges,
save_to_clipboard: bool,
+ alt_send_esc: bool,
}
/// Notify that the terminal was resized
@@ -337,6 +338,7 @@ impl<N: Notify> Processor<N> {
pending_events: Vec::with_capacity(4),
window_changes: Default::default(),
save_to_clipboard: config.selection().save_to_clipboard,
+ alt_send_esc: config.alt_send_esc(),
}
}
@@ -518,6 +520,7 @@ impl<N: Notify> Processor<N> {
key_bindings: &self.key_bindings[..],
mouse_bindings: &self.mouse_bindings[..],
save_to_clipboard: self.save_to_clipboard,
+ alt_send_esc: self.alt_send_esc,
};
let mut window_is_focused = window.is_focused;
@@ -573,5 +576,6 @@ impl<N: Notify> Processor<N> {
self.mouse_bindings = config.mouse_bindings().to_vec();
self.mouse_config = config.mouse().to_owned();
self.save_to_clipboard = config.selection().save_to_clipboard;
+ self.alt_send_esc = config.alt_send_esc();
}
}
diff --git a/src/input.rs b/src/input.rs
index c2473448..65b7b6ce 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -49,6 +49,7 @@ pub struct Processor<'a, A: 'a> {
pub scrolling_config: &'a config::Scrolling,
pub ctx: A,
pub save_to_clipboard: bool,
+ pub alt_send_esc: bool,
}
pub trait ActionContext {
@@ -742,7 +743,11 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
c.encode_utf8(&mut bytes[..]);
}
- if *self.ctx.received_count() == 0 && self.ctx.last_modifiers().alt && utf8_len == 1 {
+ if self.alt_send_esc
+ && *self.ctx.received_count() == 0
+ && self.ctx.last_modifiers().alt
+ && utf8_len == 1
+ {
bytes.insert(0, b'\x1b');
}
@@ -977,6 +982,7 @@ mod tests {
key_bindings: &config.key_bindings()[..],
mouse_bindings: &config.mouse_bindings()[..],
save_to_clipboard: config.selection().save_to_clipboard,
+ alt_send_esc: config.alt_send_esc(),
};
if let Event::WindowEvent { event: WindowEvent::MouseInput { state, button, modifiers, .. }, .. } = $input {