diff options
author | Christian Duerr <contact@christianduerr.com> | 2021-03-01 19:50:39 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-01 19:50:39 +0000 |
commit | a954e076ca0b1ee9c1f272c2b119c67df3935fd4 (patch) | |
tree | f233f8622ac6ab33519bfcb70b480f23697198b1 /alacritty/src/display/mod.rs | |
parent | 772afc6a8aa9db6f89de4b23df27b571a40c9118 (diff) | |
download | r-alacritty-a954e076ca0b1ee9c1f272c2b119c67df3935fd4.tar.gz r-alacritty-a954e076ca0b1ee9c1f272c2b119c67df3935fd4.tar.bz2 r-alacritty-a954e076ca0b1ee9c1f272c2b119c67df3935fd4.zip |
Add regex terminal hints
This adds support for hints, which allow opening parts of the visual
buffer with external programs if they match a certain regex.
This is done using a visual overlay triggered on a specified key
binding, which then instructs the user which keys they need to press to
pass the text to the application.
In the future it should be possible to supply some built-in actions for
Copy/Pasting the action and using this to launch text when clicking on
it with the mouse. But the current implementation should already be
useful as-is.
Fixes #2792.
Fixes #2536.
Diffstat (limited to 'alacritty/src/display/mod.rs')
-rw-r--r-- | alacritty/src/display/mod.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/alacritty/src/display/mod.rs b/alacritty/src/display/mod.rs index 9c37bd0e..d44013c4 100644 --- a/alacritty/src/display/mod.rs +++ b/alacritty/src/display/mod.rs @@ -38,6 +38,7 @@ use crate::display::bell::VisualBell; use crate::display::color::List; use crate::display::content::RenderableContent; use crate::display::cursor::IntoRects; +use crate::display::hint::HintState; use crate::display::meter::Meter; use crate::display::window::Window; use crate::event::{Mouse, SearchState}; @@ -48,6 +49,7 @@ use crate::url::{Url, Urls}; pub mod content; pub mod cursor; +pub mod hint; pub mod window; mod bell; @@ -181,6 +183,9 @@ pub struct Display { /// Mapped RGB values for each terminal color. pub colors: List, + /// State of the keyboard hints. + pub hint_state: HintState, + renderer: QuadRenderer, glyph_cache: GlyphCache, meter: Meter, @@ -317,10 +322,13 @@ impl Display { _ => (), } + let hint_state = HintState::new(config.ui_config.hints.alphabet()); + Ok(Self { window, renderer, glyph_cache, + hint_state, meter: Meter::new(), size_info, urls: Urls::new(), @@ -474,12 +482,10 @@ impl Display { let viewport_match = search_state .focused_match() .and_then(|focused_match| terminal.grid().clamp_buffer_range_to_visible(focused_match)); - let cursor_hidden = self.cursor_hidden || search_state.regex().is_some(); // Collect renderable content before the terminal is dropped. - let dfas = search_state.dfas(); - let colors = &self.colors; - let mut content = RenderableContent::new(&terminal, dfas, config, colors, !cursor_hidden); + let search_dfas = search_state.dfas(); + let mut content = RenderableContent::new(config, self, &terminal, search_dfas); let mut grid_cells = Vec::new(); while let Some(cell) = content.next() { grid_cells.push(cell); |