fix: negotiate modified Return keyboard reporting
This commit is contained in:
@@ -3854,6 +3854,7 @@ fn main() -> io::Result<()> {
|
||||
let config_path = config::config_path()?;
|
||||
let config = config::load(&config_path)?;
|
||||
ratatui::run(|terminal| {
|
||||
let _keyboard = ui::KeyboardProtocol::enable()?;
|
||||
if !options.miruro {
|
||||
let Some(miruro) = choose_provider(terminal, &config.keys, None)? else {
|
||||
return Ok(());
|
||||
|
||||
@@ -2,7 +2,13 @@ use std::time::Duration;
|
||||
|
||||
use ratatui::{
|
||||
Frame,
|
||||
crossterm::{clipboard::CopyToClipboard, execute},
|
||||
crossterm::{
|
||||
clipboard::CopyToClipboard,
|
||||
event::{
|
||||
KeyboardEnhancementFlags, PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags,
|
||||
},
|
||||
execute,
|
||||
},
|
||||
layout::{Constraint, Layout, Rect},
|
||||
style::{Color, Style},
|
||||
text::{Line, Span},
|
||||
@@ -13,6 +19,25 @@ pub const ACCENT: Style = Style::new().fg(Color::Cyan);
|
||||
pub const SELECTED: Style = Style::new().fg(Color::Black).bg(Color::Cyan);
|
||||
pub const SELECTION_MARKER: &str = "> ";
|
||||
|
||||
// Keep modified Return distinct from Return on terminals supporting the Kitty protocol.
|
||||
pub struct KeyboardProtocol;
|
||||
|
||||
impl KeyboardProtocol {
|
||||
pub fn enable() -> std::io::Result<Self> {
|
||||
execute!(
|
||||
std::io::stdout(),
|
||||
PushKeyboardEnhancementFlags(KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES)
|
||||
)?;
|
||||
Ok(Self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for KeyboardProtocol {
|
||||
fn drop(&mut self) {
|
||||
let _ = execute!(std::io::stdout(), PopKeyboardEnhancementFlags);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn copy_video_url(id: &str) -> String {
|
||||
let result = crate::youtube::video_url(id)
|
||||
.and_then(|url| execute!(std::io::stdout(), CopyToClipboard::to_clipboard_from(url)));
|
||||
|
||||
Reference in New Issue
Block a user