Skip to content

Commit 8c62a31

Browse files
author
Pierre POLLET
committed
refactor: use crossterm supports_keyboard_enhancement once when KittyProtocolGuard is initialized
1 parent ca76213 commit 8c62a31

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl Reedline {
240240
buffer_editor: None,
241241
cursor_shapes: None,
242242
bracketed_paste: BracketedPasteGuard::default(),
243-
kitty_protocol: KittyProtocolGuard::default(),
243+
kitty_protocol: KittyProtocolGuard::new(),
244244
immediately_accept: false,
245245
#[cfg(feature = "external_printer")]
246246
external_printer: None,

src/terminal_extensions/kitty.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,23 @@ use crossterm::{event, execute};
1212
/// * [dte text editor](https://gitlab.com/craigbarnes/dte/-/issues/138)
1313
///
1414
/// Refer to <https://sw.kovidgoyal.net/kitty/keyboard-protocol/> if you're curious.
15-
#[derive(Default)]
1615
pub(crate) struct KittyProtocolGuard {
1716
enabled: bool,
1817
active: bool,
18+
support_kitty_protocol: bool,
1919
}
2020

2121
impl KittyProtocolGuard {
22+
pub fn new() -> Self {
23+
Self {
24+
support_kitty_protocol: super::kitty_protocol_available(),
25+
enabled: false,
26+
active: false,
27+
}
28+
}
29+
2230
pub fn set(&mut self, enable: bool) {
23-
self.enabled = enable && super::kitty_protocol_available();
31+
self.enabled = enable && self.support_kitty_protocol;
2432
}
2533
pub fn enter(&mut self) {
2634
if self.enabled && !self.active {

0 commit comments

Comments
 (0)