diff options
-rw-r--r-- | .travis.yml | 12 | ||||
-rw-r--r-- | CHANGELOG.md | 5 | ||||
-rw-r--r-- | CONTRIBUTING.md | 2 | ||||
-rw-r--r-- | alacritty.yml | 115 | ||||
-rw-r--r-- | alacritty/src/config/bindings.rs | 417 | ||||
-rw-r--r-- | alacritty/src/config/mod.rs | 2 | ||||
-rw-r--r-- | alacritty/src/config/ui_config.rs | 16 | ||||
-rw-r--r-- | alacritty/src/display.rs | 13 | ||||
-rw-r--r-- | alacritty/src/event.rs | 88 | ||||
-rw-r--r-- | alacritty/src/input.rs | 279 | ||||
-rw-r--r-- | alacritty/src/url.rs | 9 | ||||
-rw-r--r-- | alacritty_terminal/src/config/colors.rs | 2 | ||||
-rw-r--r-- | alacritty_terminal/src/config/mod.rs | 32 | ||||
-rw-r--r-- | alacritty_terminal/src/grid/mod.rs | 12 | ||||
-rw-r--r-- | alacritty_terminal/src/index.rs | 41 | ||||
-rw-r--r-- | alacritty_terminal/src/lib.rs | 1 | ||||
-rw-r--r-- | alacritty_terminal/src/selection.rs | 106 | ||||
-rw-r--r-- | alacritty_terminal/src/term/mod.rs | 456 | ||||
-rw-r--r-- | alacritty_terminal/src/vi_mode.rs | 799 | ||||
-rw-r--r-- | extra/linux/redhat/alacritty.spec | 2 |
20 files changed, 1893 insertions, 516 deletions
diff --git a/.travis.yml b/.travis.yml index f6454507..71100b10 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ os: - osx rust: - - 1.37.0 + - 1.39.0 - stable - nightly @@ -30,22 +30,22 @@ matrix: - name: "Clippy Linux" os: linux env: CLIPPY=true - rust: 1.37.0 + rust: 1.39.0 - name: "Clippy OSX" os: osx env: CLIPPY=true - rust: 1.37.0 + rust: 1.39.0 - name: "Clippy Windows" os: windows env: CLIPPY=true - rust: 1.37.0-x86_64-pc-windows-msvc + rust: 1.39.0-x86_64-pc-windows-msvc - name: "Rustfmt" os: linux env: RUSTFMT=true rust: nightly - - name: "Windows 1.37.0" + - name: "Windows 1.39.0" os: windows - rust: 1.37.0-x86_64-pc-windows-msvc + rust: 1.39.0-x86_64-pc-windows-msvc - name: "Windows Stable" os: windows rust: stable-x86_64-pc-windows-msvc diff --git a/CHANGELOG.md b/CHANGELOG.md index 009faadf..be8b62f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Default Command+N keybinding for SpawnNewInstance on macOS +- Vi mode for copying text and opening links + +### Changed + +- Block cursor is no longer inverted at the start/end of a selection ## 0.4.2-dev diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7b977432..1ffb8802 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,7 +42,7 @@ and [easy](https://github.com/alacritty/alacritty/issues?q=is%3Aopen+is%3Aissue+label%3A%22D+-+easy%22) issues. -Please note that the minimum supported version of Alacritty is Rust 1.37.0. All patches are expected +Please note that the minimum supported version of Alacritty is Rust 1.39.0. All patches are expected to work with the minimum supported version. ### Testing diff --git a/alacritty.yml b/alacritty.yml index 1fcf46b8..744fd111 100644 --- a/alacritty.yml +++ b/alacritty.yml @@ -187,12 +187,20 @@ # Cursor colors # - # Colors which should be used to draw the terminal cursor. If these are unset, - # the cursor color will be the inverse of the cell color. + # Colors which should be used to draw the terminal cursor. If these are + # unset, the cursor color will be the inverse of the cell color. #cursor: # text: '#000000' # cursor: '#ffffff' + # Vi mode cursor colors + # + # Colors for the cursor when the vi mode is active. If these are unset, the + # cursor color will be the inverse of the cell color. + #vi_mode_cursor: + # text: '#000000' + # cursor: '#ffffff' + # Selection colors # # Colors which should be used to draw the selection area. If selection @@ -298,6 +306,14 @@ # - | Beam #style: Block + # Vi mode cursor style + # + # If the vi mode cursor style is `None` or not specified, it will fall back to + # the style of the active value of the normal cursor. + # + # See `cursor.style` for available options. + #vi_mode_style: None + # If this is `true`, the cursor will be rendered as a hollow box when the # window is not focused. #unfocused_hollow: true @@ -435,6 +451,7 @@ # # - `action`: Execute a predefined action # +# - ToggleViMode # - Copy # - Paste # - PasteSelection @@ -454,9 +471,36 @@ # - ToggleFullscreen # - SpawnNewInstance # - ClearLogNotice +# - ClearSelection # - ReceiveChar # - None # +# (`mode: Vi` only): +# - Open +# - Up +# - Down +# - Left +# - Right +# - First +# - Last +# - FirstOccupied +# - High +# - Middle +# - Low +# - SemanticLeft +# - SemanticRight +# - SemanticLeftEnd +# - SemanticRightEnd +# - WordRight +# - WordLeft +# - WordRightEnd +# - WordLeftEnd +# - Bracket +# - ToggleNormalSelection +# - ToggleLineSelection +# - ToggleBlockSelection +# - ToggleSemanticSelection +# # (macOS only): # - ToggleSimpleFullscreen: Enters fullscreen without occupying another space # @@ -501,6 +545,57 @@ # If the same trigger is assigned to multiple actions, all of them are executed # at once. #key_bindings: + #- { key: Paste, action: Paste } + #- { key: Copy, action: Copy } + #- { key: L, mods: Control, action: ClearLogNotice } + #- { key: L, mods: Control, chars: "\x0c" } + #- { key: PageUp, mods: Shift, action: ScrollPageUp, mode: ~Alt } + #- { key: PageDown, mods: Shift, action: ScrollPageDown, mode: ~Alt } + #- { key: Home, mods: Shift, action: ScrollToTop, mode: ~Alt } + #- { key: End, mods: Shift, action: ScrollToBottom, mode: ~Alt } + + # Vi Mode + #- { key: Space, mods: Shift|Control, mode: Vi, action: ScrollToBottom } + #- { key: Space, mods: Shift|Control, action: ToggleViMode } + #- { key: Escape, mode: Vi, action: ClearSelection } + #- { key: I, mode: Vi, action: ScrollToBottom } + #- { key: I, mode: Vi, action: ToggleViMode } + #- { key: Y, mods: Control, mode: Vi, action: ScrollLineUp } + #- { key: E, mods: Control, mode: Vi, action: ScrollLineDown } + #- { key: G, mode: Vi, action: ScrollToTop } + #- { key: G, mods: Shift, mode: Vi, action: ScrollToBottom } + #- { key: B, mods: Control, mode: Vi, action: ScrollPageUp } + #- { key: F, mods: Control, mode: Vi, action: ScrollPageDown } + #- { key: U, mods: Control, mode: Vi, action: ScrollHalfPageUp } + #- { key: D, mods: Control, mode: Vi, action: ScrollHalfPageDown } + #- { key: Y, mode: Vi, action: Copy } + #- { key: V, mode: Vi, action: ToggleNormalSelection } + #- { key: V, mods: Shift, mode: Vi, action: ToggleLineSelection } + #- { key: V, mods: Control, mode: Vi, action: ToggleBlockSelection } + #- { key: V, mods: Alt, mode: Vi, action: ToggleSemanticSelection } + #- { key: Return, mode: Vi, action: Open } + #- { key: K, mode: Vi, action: Up } + #- { key: J, mode: Vi, action: Down } + #- { key: H, mode: Vi, action: Left } + #- { key: L, mode: Vi, action: Right } + #- { key: Up, mode: Vi, action: Up } + #- { key: Down, mode: Vi, action: Down } + #- { key: Left, mode: Vi, action: Left } + #- { key: Right, mode: Vi, action: Right } + #- { key: Key0, mode: Vi, action: First } + #- { key: Key4, mods: Shift, mode: Vi, action: Last } + #- { key: Key6, mods: Shift, mode: Vi, action: FirstOccupied } + #- { key: H, mods: Shift, mode: Vi, action: High } + #- { key: M, mods: Shift, mode: Vi, action: Middle } + #- { key: L, mods: Shift, mode: Vi, action: Low } + #- { key: B, mode: Vi, action: SemanticLeft } + #- { key: W, mode: Vi, action: SemanticRight } + #- { key: E, mode: Vi, action: SemanticRightEnd } + #- { key: B, mods: Shift, mode: Vi, action: WordLeft } + #- { key: W, mods: Shift, mode: Vi, action: WordRight } + #- { key: E, mods: Shift, mode: Vi, action: WordRightEnd } + #- { key: Key5, mods: Shift, mode: Vi, action: Bracket } + # (Windows, Linux, and BSD only) #- { key: V, mods: Control|Shift, action: Paste } #- { key: C, mods: Control|Shift, action: Copy } @@ -530,14 +625,14 @@ #- { key: N, mods: Command, action: SpawnNewInstance } #- { key: F, mods: Command|Control, action: ToggleFullscreen } - #- { key: Paste, action: Paste } - #- { key: Copy, action: Copy } - #- { key: L, mods: Control, action: ClearLogNotice } - #- { key: L, mods: Control, chars: "\x0c" } - #- { key: PageUp, mods: Shift, action: ScrollPageUp, mode: ~Alt } - #- { key: PageDown, mods: Shift, action: ScrollPageDown, mode: ~Alt } - #- { key: Home, mods: Shift, action: ScrollToTop, mode: ~Alt } - #- { key: End, mods: Shift, action: ScrollToBottom, mode: ~Alt } + #- { key: Paste, action: Paste } + #- { key: Copy, action: Copy } + #- { key: L, mods: Control, action: ClearLogNotice } + #- { key: L, mods: Control, chars: "\x0c" } + #- { key: PageUp, mods: Shift, action: ScrollPageUp, mode: ~Alt } + #- { key: PageDown, mods: Shift, action: ScrollPageDown, mode: ~Alt } + #- { key: Home, mods: Shift, action: ScrollToTop, mode: ~Alt } + #- { key: End, mods: Shift, action: ScrollToBottom, mode: ~Alt } #debug: # Display the time it takes to redraw each frame. diff --git a/alacritty/src/config/bindings.rs b/alacritty/src/config/bindings.rs index 48a1b9fb..7485cd54 100644 --- a/alacritty/src/config/bindings.rs +++ b/alacritty/src/config/bindings.rs @@ -13,18 +13,18 @@ // limitations under the License. #![allow(clippy::enum_glob_use)] -use std::fmt; +use std::fmt::{self, Debug, Display}; use std::str::FromStr; use glutin::event::VirtualKeyCode::*; use glutin::event::{ModifiersState, MouseButton, VirtualKeyCode}; -use log::error; use serde::de::Error as SerdeError; use serde::de::{self, MapAccess, Unexpected, Visitor}; use serde::{Deserialize, Deserializer}; +use serde_yaml::Value as SerdeValue; -use alacritty_terminal::config::LOG_TARGET_CONFIG; use alacritty_terminal::term::TermMode; +use alacritty_terminal::vi_mode::ViMotion; /// Describes a state and action to take in that state /// @@ -55,30 +55,6 @@ pub type KeyBinding = Binding<Key>; /// Bindings that are triggered by a mouse button pub type MouseBinding = Binding<MouseButton>; -impl Default for KeyBinding { - fn default() -> KeyBinding { - KeyBinding { - mods: Default::default(), - action: Action::Esc(String::new()), - mode: TermMode::NONE, - notmode: TermMode::NONE, - trigger: Key::Keycode(A), - } - } -} - -impl Default for MouseBinding { - fn default() -> MouseBinding { - MouseBinding { - mods: Default::default(), - action: Action::Esc(String::new()), - mode: TermMode::NONE, - notmode: TermMode::NONE, - trigger: MouseButton::Left, - } - } -} - impl<T: Eq> Binding<T> { #[inline] pub fn is_triggered_by(&self, mode: TermMode, mods: ModifiersState, input: &T) -> bool { @@ -117,6 +93,18 @@ pub enum Action { #[serde(skip)] Esc(String), + /// Run given command. + #[serde(skip)] + Command(String, Vec<String>), + + /// Move vi mode cursor. + #[serde(skip)] + ViMotion(ViMotion), + + /// Perform vi mode action. + #[serde(skip)] + ViAction(ViAction), + /// Paste contents of system clipboard. Paste, @@ -141,6 +129,12 @@ pub enum Action { /// Scroll exactly one page down. ScrollPageDown, + /// Scroll half a page up. + ScrollHalfPageUp, + + /// Scroll half a page down. + ScrollHalfPageDown, + /// Scroll one line up. ScrollLineUp, @@ -156,10 +150,6 @@ pub enum Action { /// Clear the display buffer(s) to remove history. ClearHistory, - /// Run given command. - #[serde(skip)] - Command(String, Vec<String>), - /// Hide the Alacritty window. Hide, @@ -182,6 +172,12 @@ pub enum Action { #[cfg(target_os = "macos")] ToggleSimpleFullscreen, + /// Clear active selection. + ClearSelection, + + /// Toggle vi mode. + ToggleViMode, + /// Allow receiving char input. ReceiveChar, @@ -189,18 +185,50 @@ pub enum Action { None, } -impl Default for Action { - fn default() -> Action { - Action::None - } -} - impl From<&'static str> for Action { fn from(s: &'static str) -> Action { Action::Esc(s.into()) } } +/// Display trait used for error logging. +impl Display for Action { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Action::ViMotion(motion) => motion.fmt(f), + Action::ViAction(action) => action.fmt(f), + _ => write!(f, "{:?}", self), + } + } +} + +/// Vi mode specific actions. +#[derive(Deserialize, Debug, Copy, Clone, PartialEq, Eq)] +pub enum ViAction { + /// Toggle normal vi selection. + ToggleNormalSelection, + /// Toggle line vi selection. + ToggleLineSelection, + /// Toggle block vi selection. + ToggleBlockSelection, + /// Toggle semantic vi selection. + ToggleSemanticSelection, + /// Launch the URL below the vi mode cursor. + Open, +} + +impl From<ViAction> for Action { + fn from(action: ViAction) -> Self { + Self::ViAction(action) + } +} + +impl From<ViMotion> for Action { + fn from(motion: ViMotion) -> Self { + Self::ViMotion(motion) + } +} + macro_rules! bindings { ( KeyBinding; @@ -241,16 +269,16 @@ macro_rules! bindings { let mut _mods = ModifiersState::empty(); $(_mods = $mods;)* let mut _mode = TermMode::empty(); - $(_mode = $mode;)* + $(_mode.insert($mode);)* let mut _notmode = TermMode::empty(); - $(_notmode = $notmode;)* + $(_notmode.insert($notmode);)* v.push($ty { trigger: $key, mods: _mods, mode: _mode, notmode: _notmode, - action: $action, + action: $action.into(), }); )* @@ -261,65 +289,109 @@ macro_rules! bindings { pub fn default_mouse_bindings() -> Vec<MouseBinding> { bindings!( MouseBinding; - MouseButton::Middle; Action::PasteSelection; + MouseButton::Middle, ~TermMode::VI; Action::PasteSelection; ) } pub fn default_key_bindings() -> Vec<KeyBinding> { let mut bindings = bindings!( KeyBinding; - Paste; Action::Paste; Copy; Action::Copy; + Paste, ~TermMode::VI; Action::Paste; L, ModifiersState::CTRL; Action::ClearLogNotice; - L, ModifiersState::CTRL; Action::Esc("\x0c".into()); - PageUp, ModifiersState::SHIFT, ~TermMode::ALT_SCREEN; Action::ScrollPageUp; - PageDown, ModifiersState::SHIFT, ~TermMode::ALT_SCREEN; Action::ScrollPageDown; + L, ModifiersState::CTRL, ~TermMode::VI; Action::Esc("\x0c".into()); + Tab, ModifiersState::SHIFT, ~TermMode::VI; Action::Esc("\x1b[Z".into()); + Back, ModifiersState::ALT, ~TermMode::VI; Action::Esc("\x1b\x7f".into()); Home, ModifiersState::SHIFT, ~TermMode::ALT_SCREEN; Action::ScrollToTop; End, ModifiersState::SHIFT, ~TermMode::ALT_SCREEN; Action::ScrollToBottom; - Home, +TermMode::APP_CURSOR; Action::Esc("\x1bOH".into()); - Home, ~TermMode::APP_CURSOR; Action::Esc("\x1b[H".into()); - Home, ModifiersState::SHIFT, +TermMode::ALT_SCREEN; Action::Esc("\x1b[1;2H".into()); - End, +TermMode::APP_CURSOR; Action::Esc("\x1bOF".into()); - End, ~TermMode::APP_CURSOR; Action::Esc("\x1b[F".into()); - End, ModifiersState::SHIFT, +TermMode::ALT_SCREEN; Action::Esc("\x1b[1;2F".into()); - PageUp; Action::Esc("\x1b[5~".into()); - PageUp, ModifiersState::SHIFT, +TermMode::ALT_SCREEN; Action::Esc("\x1b[5;2~".into()); - PageDown; Action::Esc("\x1b[6~".into()); - PageDown, ModifiersState::SHIFT, +TermMode::ALT_SCREEN; Action::Esc("\x1b[6;2~".into()); - Tab, ModifiersState::SHIFT; Action::Esc("\x1b[Z".into()); - Back; Action::Esc("\x7f".into()); - Back, ModifiersState::ALT; Action::Esc("\x1b\x7f".into()); - Insert; Action::Esc("\x1b[2~".into()); - Delete; Action::Esc("\x1b[3~".into()); - Up, +TermMode::APP_CURSOR; Action::Esc("\x1bOA".into()); - Up, ~TermMode::APP_CURSOR; Action::Esc("\x1b[A".into()); - Down, +TermMode::APP_CURSOR; Action::Esc("\x1bOB".into()); - Down, ~TermMode::APP_CURSOR; Action::Esc("\x1b[B".into()); - Right, +TermMode::APP_CURSOR; Action::Esc("\x1bOC".into()); - Right, ~TermMode::APP_CURSOR; Action::Esc("\x1b[C".into()); - Left, +TermMode::APP_CURSOR; Action::Esc("\x1bOD".into()); - Left, ~TermMode::APP_CURSOR; Action::Esc("\x1b[D".into()); - F1; Action::Esc("\x1bOP".into()); - F2; Action::Esc("\x1bOQ".into()); - F3; Action::Esc("\x1bOR".into()); - F4; Action::Esc("\x1bOS".into()); - F5; Action::Esc("\x1b[15~".into()); - F6; Action::Esc("\x1b[17~".into()); - F7; Action::Esc("\x1b[18~".into()); - F8; Action::Esc("\x1b[19~".into()); - F9; Action::Esc("\x1b[20~".into()); - F10; Action::Esc("\x1b[21~".into()); - F11; Action::Esc("\x1b[23~".into()); - F12; Action::Esc("\x1b[24~".into()); - F13; Action::Esc("\x1b[25~".into()); - F14; Action::Esc("\x1b[26~".into()); - F15; Action::Esc("\x1b[28~".into()); - F16; Action::Esc("\x1b[29~".into()); - F17; Action::Esc("\x1b[31~".into()); - F18; Action::Esc("\x1b[32~".into()); - F19; Action::Esc("\x1b[33~".into()); - F20; Action::Esc("\x1b[34~".into()); - NumpadEnter; Action::Esc("\n".into()); + PageUp, ModifiersState::SHIFT, ~TermMode::ALT_SCREEN; Action::ScrollPageUp; + PageDown, ModifiersState::SHIFT, ~TermMode::ALT_SCREEN; Action::ScrollPageDown; + Home, ModifiersState::SHIFT, +TermMode::ALT_SCREEN, ~TermMode::VI; + Action::Esc("\x1b[1;2H".into()); + End, ModifiersState::SHIFT, +TermMode::ALT_SCREEN, ~TermMode::VI; + Action::Esc("\x1b[1;2F".into()); + PageUp, ModifiersState::SHIFT, +TermMode::ALT_SCREEN, ~TermMode::VI; + Action::Esc("\x1b[5;2~".into()); + PageDown, ModifiersState::SHIFT, +TermMode::ALT_SCREEN, ~TermMode::VI; + Action::Esc("\x1b[6;2~".into()); + Home, +TermMode::APP_CURSOR, ~TermMode::VI; Action::Esc("\x1bOH".into()); + Home, ~TermMode::APP_CURSOR, ~TermMode::VI; Action::Esc("\x1b[H".into()); + End, +TermMode::APP_CURSOR, ~TermMode::VI; Action::Esc("\x1bOF".into()); + End, ~TermMode::APP_CURSOR, ~TermMode::VI; Action::Esc("\x1b[F".into()); + Up, +TermMode::APP_CURSOR, ~TermMode::VI; Action::Esc("\x1bOA".into()); + Up, ~TermMode::APP_CURSOR, ~TermMode::VI; Action::Esc("\x1b[A".into()); + Down, +TermMode::APP_CURSOR, ~TermMode::VI; Action::Esc("\x1bOB".into()); + Down, ~TermMode::APP_CURSOR, ~TermMode::VI; Action::Esc("\x1b[B".into()); + Right, +TermMode::APP_CURSOR, ~TermMode::VI; Action::Esc("\x1bOC".into()); + Right, ~TermMode::APP_CURSOR, ~TermMode::VI; Action::Esc("\x1b[C".into()); + Left, +TermMode::APP_CURSOR, ~TermMode::VI; Action::Esc("\x1bOD".into()); + Left, ~TermMode::APP_CURSOR, ~TermMode::VI; Action::Esc("\x1b[D".into()); + Back, ~TermMode::VI; Action::Esc("\x7f".into()); + Insert, ~TermMode::VI; Action::Esc("\x1b[2~".into()); + Delete, ~TermMode::VI; Action::Esc("\x1b[3~".into()); + PageUp, ~TermMode::VI; Action::Esc("\x1b[5~".into()); + PageDown, ~TermMode::VI; Action::Esc("\x1b[6~".into()); + F1, ~TermMode::VI; Action::Esc("\x1bOP".into()); + F2, ~TermMode::VI; Action::Esc("\x1bOQ".into()); + F3, ~TermMode::VI; Action::Esc("\x1bOR".into()); + F4, ~TermMode::VI; Action::Esc("\x1bOS".into()); + F5, ~TermMode::VI; Action::Esc("\x1b[15~".into()); + F6, ~TermMode::VI; Action::Esc("\x1b[17~".into()); + F7, ~TermMode::VI; Action::Esc("\x1b[18~".into()); + F8, ~TermMode::VI; Action::Esc("\x1b[19~".into()); + F9, ~TermMode::VI; Action::Esc("\x1b[20~".into()); + F10, ~TermMode::VI; Action::Esc("\x1b[21~".into()); + F11, ~TermMode::VI; Action::Esc("\x1b[23~".into()); + F12, ~TermMode::VI; Action::Esc("\x1b[24~".into()); + F13, ~TermMode::VI; Action::Esc("\x1b[25~".into()); + F14, ~TermMode::VI; Action::Esc("\x1b[26~".into()); + F15, ~TermMode::VI; Action::Esc("\x1b[28~".into()); + F16, ~TermMode::VI; Action::Esc("\x1b[29~".into()); + F17, ~TermMode::VI; Action::Esc("\x1b[31~".into()); + F18, ~TermMode::VI; Action::Esc("\x1b[32~".into()); + F19, ~TermMode::VI; Action::Esc("\x1b[33~".into()); + F20, ~TermMode::VI; Action::Esc("\x1b[34~".into()); + NumpadEnter, ~TermMode::VI; Action::Esc("\n".into()); + Space, ModifiersState::SHIFT | ModifiersState::CTRL, +TermMode::VI; Action::ScrollToBottom; + Space, ModifiersState::SHIFT | ModifiersState::CTRL; Action::ToggleViMode; + Escape, +TermMode::VI; Action::ClearSelection; + I, +TermMode::VI; Action::ScrollToBottom; + I, +TermMode::VI; Action::ToggleViMode; + Y, ModifiersState::CTRL, +TermMode::VI; Action::ScrollLineUp; + E, ModifiersState::CTRL, +TermMode::VI; Action::ScrollLineDown; + G, +TermMode::VI; Action::ScrollToTop; + G, ModifiersState::SHIFT, +TermMode::VI; Action::ScrollToBottom; + B, ModifiersState::CTRL, +TermMode::VI; Action::ScrollPageUp; + F, ModifiersState::CTRL, +TermMode::VI; Action::ScrollPageDown; + U, ModifiersState::CTRL, +TermMode::VI; Action::ScrollHalfPageUp; + D, ModifiersState::CTRL, +TermMode::VI; Action::ScrollHalfPageDown; + Y, +TermMode::VI; Action::Copy; + V, +TermMode::VI; ViAction::ToggleNormalSelection; + V, ModifiersState::SHIFT, +TermMode::VI; ViAction::ToggleLineSelection; + V, ModifiersState::CTRL, +TermMode::VI; ViAction::ToggleBlockSelection; + V, ModifiersState::ALT, +TermMode::VI; ViAction::ToggleSemanticSelection; + Return, +TermMode::VI; ViAction::Open; + K, +TermMode::VI; ViMotion::Up; + J, +TermMode::VI; ViMotion::Down; + H, +TermMode::VI; ViMotion::Left; + L, +TermMode::VI; ViMotion::Right; + Up, +TermMode::VI; ViMotion::Up; + Down, +TermMode::VI; ViMotion::Down; + Left, +TermMode::VI; ViMotion::Left; + Right, +TermMode::VI; ViMotion::Right; + Key0, +TermMode::VI; ViMotion::First; + Key4, ModifiersState::SHIFT, +TermMode::VI; ViMotion::Last; + Key6, ModifiersState::SHIFT, +TermMode::VI; ViMotion::FirstOccupied; + H, ModifiersState::SHIFT, +TermMode::VI; ViMotion::High; + M, ModifiersState::SHIFT, +TermMode::VI; ViMotion::Middle; + L, ModifiersState::SHIFT, +TermMode::VI; ViMotion::Low; + B, +TermMode::VI; ViMotion::SemanticLeft; + W, +TermMode::VI; ViMotion::SemanticRight; + E, +TermMode::VI; ViMotion::SemanticRightEnd; + B, ModifiersState::SHIFT, +TermMode::VI; ViMotion::WordLeft; + W, ModifiersState::SHIFT, +TermMode::VI; ViMotion::WordRight; + E, ModifiersState::SHIFT, +TermMode::VI; ViMotion::WordRightEnd; + Key5, ModifiersState::SHIFT, +TermMode::VI; ViMotion::Bracket; ); // Code Modifiers @@ -348,31 +420,31 @@ pub fn default_key_bindings() -> Vec<KeyBinding> { let modifiers_code = index + 2; bindings.extend(bindings!( KeyBinding; - Delete, mods; Action::Esc(format!("\x1b[3;{}~", modifiers_code)); - Up, mods; Action::Esc(format!("\x1b[1;{}A", modifiers_code)); - Down, mods; Action::Esc(format!("\x1b[1;{}B", modifiers_code)); - Right, mods; Action::Esc(format!("\x1b[1;{}C", modifiers_code)); - Left, mods; Action::Esc(format!("\x1b[1;{}D", modifiers_code)); - F1, mods; Action::Esc(format!("\x1b[1;{}P", modifiers_code)); - F2, mods; Action::Esc(format!("\x1b[1;{}Q", modifiers_code)); - F3, mods; Action::Esc(format!("\x1b[1;{}R", modifiers_code)); - F4, mods; Action::Esc(format!("\x1b[1;{}S", modifiers_code)); - F5, mods; Action::Esc(format!("\x1b[15;{}~", modifiers_code)); - F6, mods; Action::Esc(format!("\x1b[17;{}~", modifiers_code)); - F7, mods; Action::Esc(format!("\x1b[18;{}~", modifiers_code)); - F8, mods; Action::Esc(format!("\x1b[19;{}~", modifiers_code)); - F9, mods; Action::Esc(format!("\x1b[20;{}~", modifiers_code)); - F10, mods; Action::Esc(format!("\x1b[21;{}~", modifiers_code)); - F11, mods; Action::Esc(format!("\x1b[23;{}~", modifiers_code)); - F12, mods; Action::Esc(format!("\x1b[24;{}~", modifiers_code)); - F13, mods; Action::Esc(format!("\x1b[25;{}~", modifiers_code)); - F14, mods; Action::Esc(format!("\x1b[26;{}~", modifiers_code)); - F15, mods; Action::Esc(format!("\x1b[28;{}~", modifiers_code)); - F16, mods; Action::Esc(format!("\x1b[29;{}~", modifiers_code)); - F17, mods; Action::Esc(format!("\x1b[31;{}~", modifiers_code)); - F18, mods; Action::Esc(format!("\x1b[32;{}~", modifiers_code)); - F19, mods; Action::Esc(format!("\x1b[33;{}~", modifiers_code)); - F20, mods; Action::Esc(format!("\x1b[34;{}~", modifiers_code)); + Delete, mods, ~TermMode::VI; Action::Esc(format!("\x1b[3;{}~", modifiers_code)); + Up, mods, ~TermMode::VI; Action::Esc(format!("\x1b[1;{}A", modifiers_code)); + Down, mods, ~TermMode::VI; Action::Esc(format!("\x1b[1;{}B", modifiers_code)); + Right, mods, ~TermMode::VI; Action::Esc(format!("\x1b[1;{}C", modifiers_code)); + Left, mods, ~TermMode::VI; Action::Esc(format!("\x1b[1;{}D", modifiers_code)); + F1, mods, ~TermMode::VI; Action::Esc(format!("\x1b[1;{}P", modifiers_code)); + F2, mods, ~TermMode::VI; Action::Esc(format!("\x1b[1;{}Q", modifiers_code)); + F3, mods, ~TermMode::VI; Action::Esc(format!("\x1b[1;{}R", modifiers_code)); + F4, mods, ~TermMode::VI; Action::Esc(format!("\x1b[1;{}S", modifiers_code)); + F5, mods, ~TermMode::VI; Action::Esc(format!("\x1b[15;{}~", modifiers_code)); + F6, mods, ~TermMode::VI; Action::Esc(format!("\x1b[17;{}~", modifiers_code)); + F7, mods, ~TermMode::VI; Action::Esc(format!("\x1b[18;{}~", modifiers_code)); + F8, mods, ~TermMode::VI; Action::Esc(format!("\x1b[19;{}~", modifiers_code)); + F9, mods, ~TermMode::VI; Action::Esc(format!("\x1b[20;{}~", modifiers_code)); + F10, mods, ~TermMode::VI; Action::Esc(format!("\x1b[21;{}~", modifiers_code)); + F11, mods, ~TermMode::VI; Action::Esc(format!("\x1b[23;{}~", modifiers_code)); + F12, mods, ~TermMode::VI; Action::Esc(format!("\x1b[24;{}~", modifiers_code)); + F13, mods, ~TermMode::VI; Action::Esc(format!("\x1b[25;{}~", modifiers_code)); + F14, mods, ~TermMode::VI; Action::Esc(format!("\x1b[26;{}~", modifiers_code)); + F15, mods, ~TermMode::VI; Action::Esc(format!("\x1b[28;{}~", modifiers_code)); + F16, mods, ~TermMode::VI; Action::Esc(format!("\x1b[29;{}~", modifiers_code)); + F17, mods, ~TermMode::VI; Action::Esc(format!("\x1b[31;{}~", modifiers_code)); + F18, mods, ~TermMode::VI; Action::Esc(format!("\x1b[32;{}~", modifiers_code)); + F19, mods, ~TermMode::VI; Action::Esc(format!("\x1b[33;{}~", modifiers_code)); + F20, mods, ~TermMode::VI; Action::Esc(format!("\x1b[34;{}~", modifiers_code)); )); // We're adding the following bindings with `Shift` manually above, so skipping them here @@ -380,11 +452,11 @@ pub fn default_key_bindings() -> Vec<KeyBinding> { if modifiers_code != 2 { bindings.extend(bindings!( KeyBinding; - Insert, mods; Action::Esc(format!("\x1b[2;{}~", modifiers_code)); - PageUp, mods; Action::Esc(format!("\x1b[5;{}~", modifiers_code)); - PageDown, mods; Action::Esc(format!("\x1b[6;{}~", modifiers_code)); - End, mods; Action::Esc(format!("\x1b[1;{}F", modifiers_code)); - Home, mods; Action::Esc(format!("\x1b[1;{}H", modifiers_code)); + Insert, mods, ~TermMode::VI; Action::Esc(format!("\x1b[2;{}~", modifiers_code)); + PageUp, mods, ~TermMode::VI; Action::Esc(format!("\x1b[5;{}~", modifiers_code)); + PageDown, mods, ~TermMode::VI; Action::Esc(format!("\x1b[6;{}~", modifiers_code)); + End, mods, ~TermMode::VI; Action::Esc(format!("\x1b[1;{}F", modifiers_code)); + Home, mods, ~TermMode::VI; Action::Esc(format!("\x1b[1;{}H", modifiers_code)); )); } } @@ -398,9 +470,9 @@ pub fn default_key_bindings() -> Vec<KeyBinding> { fn common_keybindings() -> Vec<KeyBinding> { bindings!( KeyBinding; - V, ModifiersState::CTRL | ModifiersState::SHIFT; Action::Paste; + V, ModifiersState::CTRL | ModifiersState::SHIFT, ~TermMode::VI; Action::Paste; C, ModifiersState::CTRL | ModifiersState::SHIFT; Action::Copy; - Insert, ModifiersState::SHIFT; Action::PasteSelection; + Insert, ModifiersState::SHIFT, ~TermMode::VI; Action::PasteSelection; Key0, ModifiersState::CTRL; Action::ResetFontSize; Equals, ModifiersState::CTRL; Action::IncreaseFontSize; Add, ModifiersState::CTRL; Action::IncreaseFontSize; @@ -428,16 +500,16 @@ pub fn platform_key_bindings() -> Vec<KeyBinding> { pub fn platform_key_bindings() -> Vec<KeyBinding> { bindings!( KeyBinding; - Key0, ModifiersState::LOGO; Action::ResetFontSize; - Equals, ModifiersState::LOGO; Action::IncreaseFontSize; - Add, ModifiersState::LOGO; Action::IncreaseFontSize; - Minus, ModifiersState::LOGO; Action::DecreaseFontSize; - Insert, ModifiersState::SHIFT; Action::Esc("\x1b[2;2~".into()); + Key0, ModifiersState::LOGO; Action::ResetFontSize; + Equals, ModifiersState::LOGO; Action::IncreaseFontSize; + Add, ModifiersState::LOGO; Action::IncreaseFontSize; + Minus, ModifiersState::LOGO; Action::DecreaseFontSize; + Insert, ModifiersState::SHIFT, ~TermMode::VI; Action::Esc("\x1b[2;2~".into()); + K, ModifiersState::LOGO, ~TermMode::VI; Action::Esc("\x0c".into()); + V, ModifiersState::LOGO, ~TermMode::VI; Action::Paste; N, ModifiersState::LOGO; Action::SpawnNewInstance; F, ModifiersState::CTRL | ModifiersState::LOGO; Action::ToggleFullscreen; K, ModifiersState::LOGO; Action::ClearHistory; - K, ModifiersState::LOGO; Action::Esc("\x0c".into()); - V, ModifiersState::LOGO; Action::Paste; C, ModifiersState::LOGO; Action::Copy; H, ModifiersState::LOGO; Action::Hide; M, ModifiersState::LOGO; Action::Minimize; @@ -463,7 +535,7 @@ impl<'a> Deserialize<'a> for Key { where D: Deserializer<'a>, { - let value = serde_yaml::Value::deserialize(deserializer)?; + let value = SerdeValue::deserialize(deserializer)?; match u32::deserialize(value.clone()) { Ok(scancode) => Ok(Key::Scancode(scancode)), |