diff options
author | Jonatan Pettersson | 2023-03-14 02:53:38 +0000 |
---|---|---|
committer | GitHub | 2023-03-14 02:53:38 +0000 |
commit | d479adfdc672b266ae5755bc7f5ad224017747c5 (patch) | |
tree | 2cbe34cd0344b27ea60110d3ae993c03516a5a89 /helix-tui/src/backend | |
parent | 3e03a1a99bc66a9b04dc293b9aa277ca4b7becae (diff) |
Add undercurl config option #6196 (#6253)
If set to 'true' this option will force terminal undercurl support.
Diffstat (limited to 'helix-tui/src/backend')
-rw-r--r-- | helix-tui/src/backend/crossterm.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/helix-tui/src/backend/crossterm.rs b/helix-tui/src/backend/crossterm.rs index fba1f029..4b230f53 100644 --- a/helix-tui/src/backend/crossterm.rs +++ b/helix-tui/src/backend/crossterm.rs @@ -14,7 +14,10 @@ use crossterm::{ terminal::{self, Clear, ClearType}, Command, }; -use helix_view::graphics::{Color, CursorKind, Modifier, Rect, UnderlineStyle}; +use helix_view::{ + editor::Config as EditorConfig, + graphics::{Color, CursorKind, Modifier, Rect, UnderlineStyle}, +}; use once_cell::sync::OnceCell; use std::{ fmt, @@ -39,14 +42,15 @@ impl Capabilities { /// Detect capabilities from the terminfo database located based /// on the $TERM environment variable. If detection fails, returns /// a default value where no capability is supported. - pub fn from_env_or_default() -> Self { + pub fn from_env_or_default(config: &EditorConfig) -> Self { match termini::TermInfo::from_env() { Err(_) => Capabilities::default(), Ok(t) => Capabilities { // Smulx, VTE: https://unix.stackexchange.com/a/696253/246284 // Su (used by kitty): https://sw.kovidgoyal.net/kitty/underlines // WezTerm supports underlines but a lot of distros don't properly install it's terminfo - has_extended_underlines: t.extended_cap("Smulx").is_some() + has_extended_underlines: config.undercurl + || t.extended_cap("Smulx").is_some() || t.extended_cap("Su").is_some() || vte_version() >= Some(5102) || matches!(term_program().as_deref(), Some("WezTerm")), @@ -65,10 +69,10 @@ impl<W> CrosstermBackend<W> where W: Write, { - pub fn new(buffer: W) -> CrosstermBackend<W> { + pub fn new(buffer: W, config: &EditorConfig) -> CrosstermBackend<W> { CrosstermBackend { buffer, - capabilities: Capabilities::from_env_or_default(), + capabilities: Capabilities::from_env_or_default(config), supports_keyboard_enhancement_protocol: OnceCell::new(), } } |