feat: add support for macOS modifier keys#159
Conversation
dddec1c to
261f0ea
Compare
|
@TomasWeisss Thanks for the PR. This looks like a useful improvement. Since I am working on Windows, I didnt catch that. I would just ask for two focused changes tied to the Command-key behavior added here:
use crossterm::event::{KeyboardEnhancementFlags, PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags};
execute!(
stdout,
PushKeyboardEnhancementFlags(KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES)
)?;
// during terminal restore/shutdown
execute!(stdout, PopKeyboardEnhancementFlags)?;crossterm documents that |
|
That's a good recommendation, definitely should follow system shortcuts. I've run into some issues however. The updated shortcuts did not work without the keyboard enhancement as you predicted. However, the location you mention ( What would you advise- I finish this feature on |
|
Sorry for that. I was fully focused on the refactor and pointed you at a file from my refactor branch. On main branch, the keyboard enhancement setup already lives in For this PR, I think the only change I would still ask for is the macOS redo shortcut: please support After that, we can merge the PR. I will handle any refactor-branch integration later. Thank you for your help |
|
Modified to use the standard |
|
Looks good, but we need to handle macOS, Windows and Linux so we can not just replace CTRL with the macOS native command. We need to make the command key OS-aware. Here is my idea for that: #[cfg(target_os = "macos")]
const CMD_MOD: KeyModifiers = KeyModifiers::SUPER;
#[cfg(not(target_os = "macos"))]
const CMD_MOD: KeyModifiers = KeyModifiers::CONTROL; |
|
My apologies, I accidentally changed the key for the Windows branch. I used the opportunity to centralize the handling into a few constants at the top of |
|
Great! Is there anything more I need to do or will you merge it? |
Summary
Changed the modifier key handling for text navigation, deleting, and history to work on MacOS.
Why
MacOS uses
Optionfor skipping/deleting by words, andCommandfor undo/redo. The current setup didn't account for this, so the navigation didn't work on MacOS.Validation
Notes