diff options
author | Michael Davis | 2023-03-07 16:33:46 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2023-03-08 01:49:32 +0000 |
commit | 563ac1a3cb7e909b345cf5c892c3bcf39b2e32a4 (patch) | |
tree | 5ead0bc5abdc17d38289e213f776a00e0456ad46 /helix-tui | |
parent | 611701c36290b81c3c51ed30c49245f341a580e8 (diff) |
tui: Log keyboard enhancement query time
In my testing this takes around 3-4ms in terminals that support the
enhanced keyboard protocol (Kitty, WezTerm) and a few hundred
microseconds in terminals that don't (st, Alacritty).
Diffstat (limited to 'helix-tui')
-rw-r--r-- | helix-tui/src/backend/crossterm.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/helix-tui/src/backend/crossterm.rs b/helix-tui/src/backend/crossterm.rs index 7c512ce3..fba1f029 100644 --- a/helix-tui/src/backend/crossterm.rs +++ b/helix-tui/src/backend/crossterm.rs @@ -76,7 +76,18 @@ where #[inline] fn supports_keyboard_enhancement_protocol(&self) -> io::Result<bool> { self.supports_keyboard_enhancement_protocol - .get_or_try_init(terminal::supports_keyboard_enhancement) + .get_or_try_init(|| { + use std::time::Instant; + + let now = Instant::now(); + let support = terminal::supports_keyboard_enhancement(); + log::debug!( + "The keyboard enhancement protocol is {}supported in this terminal (checked in {:?})", + if matches!(support, Ok(true)) { "" } else { "not " }, + Instant::now().duration_since(now) + ); + support + }) .copied() } } @@ -111,7 +122,6 @@ where execute!(self.buffer, EnableMouseCapture)?; } if self.supports_keyboard_enhancement_protocol()? { - log::debug!("The enhanced keyboard protocol is supported on this terminal"); execute!( self.buffer, PushKeyboardEnhancementFlags( @@ -119,8 +129,6 @@ where | KeyboardEnhancementFlags::REPORT_ALTERNATE_KEYS ) )?; - } else { - log::debug!("The enhanced keyboard protocol is not supported on this terminal"); } Ok(()) } |