aboutsummaryrefslogtreecommitdiff
path: root/helix-tui
diff options
context:
space:
mode:
authorJonatan Pettersson2023-03-14 02:53:38 +0000
committerGitHub2023-03-14 02:53:38 +0000
commitd479adfdc672b266ae5755bc7f5ad224017747c5 (patch)
tree2cbe34cd0344b27ea60110d3ae993c03516a5a89 /helix-tui
parent3e03a1a99bc66a9b04dc293b9aa277ca4b7becae (diff)
Add undercurl config option #6196 (#6253)
If set to 'true' this option will force terminal undercurl support.
Diffstat (limited to 'helix-tui')
-rw-r--r--helix-tui/src/backend/crossterm.rs14
-rw-r--r--helix-tui/src/lib.rs12
2 files changed, 18 insertions, 8 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(),
}
}
diff --git a/helix-tui/src/lib.rs b/helix-tui/src/lib.rs
index 2636b268..59327d7c 100644
--- a/helix-tui/src/lib.rs
+++ b/helix-tui/src/lib.rs
@@ -25,10 +25,12 @@
//! use std::io;
//! use helix_tui::Terminal;
//! use helix_tui::backend::CrosstermBackend;
+//! use helix_view::editor::Config;
//!
//! fn main() -> Result<(), io::Error> {
//! let stdout = io::stdout();
-//! let backend = CrosstermBackend::new(stdout);
+//! let config = Config::default();
+//! let backend = CrosstermBackend::new(stdout, &config);
//! let mut terminal = Terminal::new(backend)?;
//! Ok(())
//! }
@@ -56,11 +58,13 @@
//! use helix_tui::backend::CrosstermBackend;
//! use helix_tui::widgets::{Widget, Block, Borders};
//! use helix_tui::layout::{Layout, Constraint, Direction};
+//! use helix_view::editor::Config;
//!
//! fn main() -> Result<(), io::Error> {
//! terminal::enable_raw_mode().unwrap();
//! let stdout = io::stdout();
-//! let backend = CrosstermBackend::new(stdout);
+//! let config = Config::default();
+//! let backend = CrosstermBackend::new(stdout, &config);
//! let mut terminal = Terminal::new(backend)?;
//! // terminal.draw(|f| {
//! // let size = f.size();
@@ -86,11 +90,13 @@
//! use helix_tui::backend::CrosstermBackend;
//! use helix_tui::widgets::{Widget, Block, Borders};
//! use helix_tui::layout::{Layout, Constraint, Direction};
+//! use helix_view::editor::Config;
//!
//! fn main() -> Result<(), io::Error> {
//! terminal::enable_raw_mode().unwrap();
//! let stdout = io::stdout();
-//! let backend = CrosstermBackend::new(stdout);
+//! let config = Config::default();
+//! let backend = CrosstermBackend::new(stdout, &config);
//! let mut terminal = Terminal::new(backend)?;
//! // terminal.draw(|f| {
//! // let chunks = Layout::default()