diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-07 00:07:24 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-07 16:29:44 +0300 |
| commit | 3c2b46d24aa6c8011a1e198143752f2aa414d585 (patch) | |
| tree | a52280bccc824ca656f8bc986a756f30901974e4 /src/main.rs | |
| parent | 5d7e56737ef30d9de5802b0684a9428c40131dda (diff) | |
feat: add native windows beta support
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs index 053ecf26..ffd11140 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,9 +2,10 @@ use std::io; use crossterm::event::{ DisableBracketedPaste, DisableFocusChange, DisableMouseCapture, EnableBracketedPaste, - EnableFocusChange, EnableMouseCapture, PopKeyboardEnhancementFlags, - PushKeyboardEnhancementFlags, + EnableFocusChange, EnableMouseCapture, }; +#[cfg(not(windows))] +use crossterm::event::{PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags}; use crossterm::execute; pub(crate) const HERDR_ENV_VAR: &str = "HERDR_ENV"; @@ -18,6 +19,29 @@ const NESTED_HERDR_MESSAGES: [&str; 6] = [ "recursion detected. base case not found. aborting.", ]; +#[cfg(not(windows))] +fn push_keyboard_enhancement_flags() -> io::Result<()> { + execute!( + io::stdout(), + PushKeyboardEnhancementFlags(crate::input::ime_compatible_keyboard_enhancement_flags()) + ) +} + +#[cfg(windows)] +fn push_keyboard_enhancement_flags() -> io::Result<()> { + Ok(()) +} + +#[cfg(not(windows))] +fn pop_keyboard_enhancement_flags() -> io::Result<()> { + execute!(io::stdout(), PopKeyboardEnhancementFlags) +} + +#[cfg(windows)] +fn pop_keyboard_enhancement_flags() -> io::Result<()> { + Ok(()) +} + mod agent_resume; mod api; mod app; @@ -632,11 +656,11 @@ fn main() -> io::Result<()> { } let _ = execute!( io::stdout(), - PopKeyboardEnhancementFlags, DisableFocusChange, DisableBracketedPaste, DisableMouseCapture ); + let _ = pop_keyboard_enhancement_flags(); ratatui::restore(); original_hook(info); })); @@ -661,12 +685,8 @@ fn main() -> io::Result<()> { } else { execute!(io::stdout(), DisableMouseCapture)?; } - execute!( - io::stdout(), - EnableBracketedPaste, - EnableFocusChange, - PushKeyboardEnhancementFlags(crate::input::ime_compatible_keyboard_enhancement_flags()) - )?; + execute!(io::stdout(), EnableBracketedPaste, EnableFocusChange)?; + push_keyboard_enhancement_flags()?; // Some hosts do not honor Kitty keyboard enhancement pushes for // Shift+Enter. Enable xterm modifyOtherKeys only on hosts where we @@ -696,9 +716,9 @@ fn main() -> io::Result<()> { if crate::kitty_graphics::is_enabled() { crate::kitty_graphics::clear_all_host_graphics()?; } + pop_keyboard_enhancement_flags()?; execute!( io::stdout(), - PopKeyboardEnhancementFlags, DisableFocusChange, DisableBracketedPaste, DisableMouseCapture |
