From d479adfdc672b266ae5755bc7f5ad224017747c5 Mon Sep 17 00:00:00 2001 From: Jonatan Pettersson Date: Tue, 14 Mar 2023 03:53:38 +0100 Subject: Add undercurl config option #6196 (#6253) If set to 'true' this option will force terminal undercurl support.--- helix-tui/src/backend/crossterm.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'helix-tui/src/backend/crossterm.rs') 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 CrosstermBackend where W: Write, { - pub fn new(buffer: W) -> CrosstermBackend { + pub fn new(buffer: W, config: &EditorConfig) -> CrosstermBackend { CrosstermBackend { buffer, - capabilities: Capabilities::from_env_or_default(), + capabilities: Capabilities::from_env_or_default(config), supports_keyboard_enhancement_protocol: OnceCell::new(), } } -- cgit v1.2.3-70-g09d2