mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
Add config option to send or not send ESC when ALT-key is pressed
This commit is contained in:
parent
0d16478f5d
commit
8b15596070
5 changed files with 28 additions and 1 deletions
|
@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- New `alt_send_esc` option for controlling if alt key should send escape sequences
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- All options in the configuration file are now optional
|
- All options in the configuration file are now optional
|
||||||
|
|
|
@ -352,6 +352,9 @@ live_config_reload: true
|
||||||
# backend cannot be initialized.
|
# backend cannot be initialized.
|
||||||
enable_experimental_conpty_backend: false
|
enable_experimental_conpty_backend: false
|
||||||
|
|
||||||
|
# Send ESC (\x1b) before characters when alt is pressed.
|
||||||
|
alt_send_esc: true
|
||||||
|
|
||||||
# Key bindings
|
# Key bindings
|
||||||
#
|
#
|
||||||
# Key bindings are specified as a list of objects. Each binding will specify a
|
# Key bindings are specified as a list of objects. Each binding will specify a
|
||||||
|
|
|
@ -538,6 +538,10 @@ pub struct Config {
|
||||||
#[serde(default, deserialize_with = "failure_default")]
|
#[serde(default, deserialize_with = "failure_default")]
|
||||||
enable_experimental_conpty_backend: bool,
|
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
|
// TODO: DEPRECATED
|
||||||
custom_cursor_colors: Option<bool>,
|
custom_cursor_colors: Option<bool>,
|
||||||
|
|
||||||
|
@ -1819,6 +1823,12 @@ impl Config {
|
||||||
self.enable_experimental_conpty_backend
|
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
|
// Update the history size, used in ref tests
|
||||||
pub fn set_history(&mut self, history: u32) {
|
pub fn set_history(&mut self, history: u32) {
|
||||||
self.scrolling.history = history;
|
self.scrolling.history = history;
|
||||||
|
|
|
@ -293,6 +293,7 @@ pub struct Processor<N> {
|
||||||
pending_events: Vec<Event>,
|
pending_events: Vec<Event>,
|
||||||
window_changes: WindowChanges,
|
window_changes: WindowChanges,
|
||||||
save_to_clipboard: bool,
|
save_to_clipboard: bool,
|
||||||
|
alt_send_esc: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Notify that the terminal was resized
|
/// Notify that the terminal was resized
|
||||||
|
@ -337,6 +338,7 @@ impl<N: Notify> Processor<N> {
|
||||||
pending_events: Vec::with_capacity(4),
|
pending_events: Vec::with_capacity(4),
|
||||||
window_changes: Default::default(),
|
window_changes: Default::default(),
|
||||||
save_to_clipboard: config.selection().save_to_clipboard,
|
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[..],
|
key_bindings: &self.key_bindings[..],
|
||||||
mouse_bindings: &self.mouse_bindings[..],
|
mouse_bindings: &self.mouse_bindings[..],
|
||||||
save_to_clipboard: self.save_to_clipboard,
|
save_to_clipboard: self.save_to_clipboard,
|
||||||
|
alt_send_esc: self.alt_send_esc,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut window_is_focused = window.is_focused;
|
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_bindings = config.mouse_bindings().to_vec();
|
||||||
self.mouse_config = config.mouse().to_owned();
|
self.mouse_config = config.mouse().to_owned();
|
||||||
self.save_to_clipboard = config.selection().save_to_clipboard;
|
self.save_to_clipboard = config.selection().save_to_clipboard;
|
||||||
|
self.alt_send_esc = config.alt_send_esc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ pub struct Processor<'a, A: 'a> {
|
||||||
pub scrolling_config: &'a config::Scrolling,
|
pub scrolling_config: &'a config::Scrolling,
|
||||||
pub ctx: A,
|
pub ctx: A,
|
||||||
pub save_to_clipboard: bool,
|
pub save_to_clipboard: bool,
|
||||||
|
pub alt_send_esc: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ActionContext {
|
pub trait ActionContext {
|
||||||
|
@ -742,7 +743,11 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
|
||||||
c.encode_utf8(&mut bytes[..]);
|
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');
|
bytes.insert(0, b'\x1b');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -977,6 +982,7 @@ mod tests {
|
||||||
key_bindings: &config.key_bindings()[..],
|
key_bindings: &config.key_bindings()[..],
|
||||||
mouse_bindings: &config.mouse_bindings()[..],
|
mouse_bindings: &config.mouse_bindings()[..],
|
||||||
save_to_clipboard: config.selection().save_to_clipboard,
|
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 {
|
if let Event::WindowEvent { event: WindowEvent::MouseInput { state, button, modifiers, .. }, .. } = $input {
|
||||||
|
|
Loading…
Reference in a new issue