feat(helix-tui): add configuration to manually enable/disable KKP (#14398)

This commit is contained in:
Valentin Cocaud
2025-09-12 16:32:22 +02:00
committed by GitHub
parent 378b27cad9
commit 92b0a2f414
4 changed files with 27 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
use std::io::{self, Write as _};
use helix_view::{
editor::KittyKeyboardProtocolConfig,
graphics::{CursorKind, Rect, UnderlineStyle},
theme::{Color, Modifier},
};
@@ -147,6 +148,15 @@ impl TerminaBackend {
let mut capabilities = Capabilities::default();
let start = Instant::now();
capabilities.kitty_keyboard = match config.kitty_keyboard_protocol {
KittyKeyboardProtocolConfig::Disabled => KittyKeyboardSupport::None,
KittyKeyboardProtocolConfig::Enabled => KittyKeyboardSupport::Full,
KittyKeyboardProtocolConfig::Auto => {
write!(terminal, "{}", Csi::Keyboard(csi::Keyboard::QueryFlags))?;
KittyKeyboardSupport::None
}
};
// Many terminal extensions can be detected by querying the terminal for the state of the
// extension and then sending a request for the primary device attributes (which is
// consistently supported by all terminals). If we receive the status of the feature (for
@@ -154,9 +164,7 @@ impl TerminaBackend {
// If we only receive the device attributes then we know it is not.
write!(
terminal,
"{}{}{}{}{}{}{}",
// Kitty keyboard
Csi::Keyboard(csi::Keyboard::QueryFlags),
"{}{}{}{}{}{}",
// Synchronized output
Csi::Mode(csi::Mode::QueryDecPrivateMode(csi::DecPrivateMode::Code(
csi::DecPrivateModeCode::SynchronizedOutput

View File

@@ -2,7 +2,7 @@
//! Frontend for [Backend]
use crate::{backend::Backend, buffer::Buffer};
use helix_view::editor::Config as EditorConfig;
use helix_view::editor::{Config as EditorConfig, KittyKeyboardProtocolConfig};
use helix_view::graphics::{CursorKind, Rect};
use std::io;
@@ -25,6 +25,7 @@ pub struct Viewport {
pub struct Config {
pub enable_mouse_capture: bool,
pub force_enable_extended_underlines: bool,
pub kitty_keyboard_protocol: KittyKeyboardProtocolConfig,
}
impl From<&EditorConfig> for Config {
@@ -32,6 +33,7 @@ impl From<&EditorConfig> for Config {
Self {
enable_mouse_capture: config.mouse,
force_enable_extended_underlines: config.undercurl,
kitty_keyboard_protocol: config.kitty_keyboard_protocol,
}
}
}