on master help sign in
Add undercurl config option #6196 (#6253)

If set to 'true' this option will force terminal undercurl support.

commitd479adfdc672b266ae5755bc7f5ad224017747c5 authorJonatan Pettersson <jonatan.pettersson@proton.me> dateTue 14 Mar 2023, 03:53 (4 years ago) parent3e03a1a
5 files changed+23−9
book/src/configuration.md+1 helix-term/src/application.rs+1−1 helix-tui/src/backend/crossterm.rs+9−5 helix-tui/src/lib.rs+9−3 helix-view/src/editor.rs+3
book/src/configuration.md+1
@@ -53,6 +53,7 @@ signal to the Helix process on Unix operating systems, such as by using the comm
5353| `completion-replace` | Set to `true` to make completions always replace the entire word and not just the part before the cursor | `false` |
5454| `auto-info` | Whether to display info boxes | `true` |
5555| `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative | `false` |
56+| `undercurl` | Set to `true` to override automatic detection of terminal undercurl support in the event of a false negative | `false` |
5657| `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file | `[]` |
5758| `bufferline` | Renders a line at the top of the editor displaying open buffers. Can be `always`, `never` or `multiple` (only shown if more than one buffer is in use) | `never` |
5859| `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` |
helix-term/src/application.rs+1−1
@@ -134,7 +134,7 @@ impl Application {
134134 let syn_loader = std::sync::Arc::new(syntax::Loader::new(syn_loader_conf));
135135
136136 #[cfg(not(feature = "integration"))]
137− let backend = CrosstermBackend::new(stdout());
137+ let backend = CrosstermBackend::new(stdout(), &config.editor);
138138
139139 #[cfg(feature = "integration")]
140140 let backend = TestBackend::new(120, 150);
helix-tui/src/backend/crossterm.rs+9−5
@@ -14,7 +14,10 @@ use crossterm::{
1414 terminal::{self, Clear, ClearType},
1515 Command,
1616};
17−use helix_view::graphics::{Color, CursorKind, Modifier, Rect, UnderlineStyle};
17+use helix_view::{
18+ editor::Config as EditorConfig,
19+ graphics::{Color, CursorKind, Modifier, Rect, UnderlineStyle},
20+};
1821use once_cell::sync::OnceCell;
1922use std::{
2023 fmt,
@@ -39,14 +42,15 @@ impl Capabilities {
3942 /// Detect capabilities from the terminfo database located based
4043 /// on the $TERM environment variable. If detection fails, returns
4144 /// a default value where no capability is supported.
42− pub fn from_env_or_default() -> Self {
45+ pub fn from_env_or_default(config: &EditorConfig) -> Self {
4346 match termini::TermInfo::from_env() {
4447 Err(_) => Capabilities::default(),
4548 Ok(t) => Capabilities {
4649 // Smulx, VTE: https://unix.stackexchange.com/a/696253/246284
4750 // Su (used by kitty): https://sw.kovidgoyal.net/kitty/underlines
4851 // WezTerm supports underlines but a lot of distros don't properly install it's terminfo
49− has_extended_underlines: t.extended_cap("Smulx").is_some()
52+ has_extended_underlines: config.undercurl
53+ || t.extended_cap("Smulx").is_some()
5054 || t.extended_cap("Su").is_some()
5155 || vte_version() >= Some(5102)
5256 || matches!(term_program().as_deref(), Some("WezTerm")),
@@ -65,10 +69,10 @@ impl<W> CrosstermBackend<W>
6569where
6670 W: Write,
6771{
68− pub fn new(buffer: W) -> CrosstermBackend<W> {
72+ pub fn new(buffer: W, config: &EditorConfig) -> CrosstermBackend<W> {
6973 CrosstermBackend {
7074 buffer,
71− capabilities: Capabilities::from_env_or_default(),
75+ capabilities: Capabilities::from_env_or_default(config),
7276 supports_keyboard_enhancement_protocol: OnceCell::new(),
7377 }
7478 }
helix-tui/src/lib.rs+9−3
@@ -25,10 +25,12 @@
2525//! use std::io;
2626//! use helix_tui::Terminal;
2727//! use helix_tui::backend::CrosstermBackend;
28+//! use helix_view::editor::Config;
2829//!
2930//! fn main() -> Result<(), io::Error> {
3031//! let stdout = io::stdout();
31−//! let backend = CrosstermBackend::new(stdout);
32+//! let config = Config::default();
33+//! let backend = CrosstermBackend::new(stdout, &config);
3234//! let mut terminal = Terminal::new(backend)?;
3335//! Ok(())
3436//! }
@@ -56,11 +58,13 @@
5658//! use helix_tui::backend::CrosstermBackend;
5759//! use helix_tui::widgets::{Widget, Block, Borders};
5860//! use helix_tui::layout::{Layout, Constraint, Direction};
61+//! use helix_view::editor::Config;
5962//!
6063//! fn main() -> Result<(), io::Error> {
6164//! terminal::enable_raw_mode().unwrap();
6265//! let stdout = io::stdout();
63−//! let backend = CrosstermBackend::new(stdout);
66+//! let config = Config::default();
67+//! let backend = CrosstermBackend::new(stdout, &config);
6468//! let mut terminal = Terminal::new(backend)?;
6569//! // terminal.draw(|f| {
6670//! // let size = f.size();
@@ -86,11 +90,13 @@
8690//! use helix_tui::backend::CrosstermBackend;
8791//! use helix_tui::widgets::{Widget, Block, Borders};
8892//! use helix_tui::layout::{Layout, Constraint, Direction};
93+//! use helix_view::editor::Config;
8994//!
9095//! fn main() -> Result<(), io::Error> {
9196//! terminal::enable_raw_mode().unwrap();
9297//! let stdout = io::stdout();
93−//! let backend = CrosstermBackend::new(stdout);
98+//! let config = Config::default();
99+//! let backend = CrosstermBackend::new(stdout, &config);
94100//! let mut terminal = Terminal::new(backend)?;
95101//! // terminal.draw(|f| {
96102//! // let chunks = Layout::default()
helix-view/src/editor.rs+3
@@ -263,6 +263,8 @@ pub struct Config {
263263 pub cursor_shape: CursorShapeConfig,
264264 /// Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative. Defaults to `false`.
265265 pub true_color: bool,
266+ /// Set to `true` to override automatic detection of terminal undercurl support in the event of a false negative. Defaults to `false`.
267+ pub undercurl: bool,
266268 /// Search configuration.
267269 #[serde(default)]
268270 pub search: SearchConfig,
@@ -737,6 +739,7 @@ impl Default for Config {
737739 statusline: StatusLineConfig::default(),
738740 cursor_shape: CursorShapeConfig::default(),
739741 true_color: false,
742+ undercurl: false,
740743 search: SearchConfig::default(),
741744 lsp: LspConfig::default(),
742745 terminal: get_terminal_provider(),