Skip to content

Commit

Permalink
Add modal keyboard motion mode
Browse files Browse the repository at this point in the history
This implements a basic mode for navigating inside of Alacritty's
history with keyboard bindings. They're bound by default to vi's motion
shortcuts but are fully customizable. Since this relies on key bindings
only single key bindings are currently supported (so no `ge`, or
repetition).

Other than navigating the history and moving the viewport, this mode
should enable making use of all available selection modes to copy
content to the clipboard and launch URLs below the cursor.

This also changes the rendering of the block cursor at the side of
selections, since previously it could be inverted to be completely
invisible. Since that would have caused some troubles with this keyboard
selection mode, the block cursor now is no longer inverted when it is at
the edges of a selection.

Fixes #262.
  • Loading branch information
chrisduerr committed Mar 18, 2020
1 parent 64db7d3 commit 1a8cd17
Show file tree
Hide file tree
Showing 20 changed files with 1,893 additions and 516 deletions.
12 changes: 6 additions & 6 deletions .travis.yml
Expand Up @@ -16,7 +16,7 @@ os:
- osx

rust:
- 1.37.0
- 1.39.0
- stable
- nightly

Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -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
Expand Down
115 changes: 105 additions & 10 deletions alacritty.yml
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -435,6 +451,7 @@
#
# - `action`: Execute a predefined action
#
# - ToggleViMode
# - Copy
# - Paste
# - PasteSelection
Expand All @@ -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
#
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 1a8cd17

Please sign in to comment.