Fix some international keybindings
This adds primitive interaction with the IME system for keyboard shortcuts in zed. For zed-industries/community#1981 For zed-industroes/community#1913
This commit is contained in:
parent
e29ce489c8
commit
0a6e577e10
1 changed files with 26 additions and 1 deletions
|
@ -988,7 +988,32 @@ extern "C" fn handle_key_event(this: &Object, native_event: id, key_equivalent:
|
||||||
.flatten()
|
.flatten()
|
||||||
.is_some();
|
.is_some();
|
||||||
if !is_composing {
|
if !is_composing {
|
||||||
handled = callback(Event::KeyDown(event));
|
// if the IME has changed the key, we'll first emit an event with the character
|
||||||
|
// generated by the IME system; then fallback to the keystroke if that is not
|
||||||
|
// handled.
|
||||||
|
// (e.g. on a brazillian keyboard to type a quote you type quote then space)
|
||||||
|
// (e.g. on a czech keyboard typing a $ requires option+shift+4)
|
||||||
|
if ime_text.is_some() && ime_text.as_ref() != Some(&event.keystroke.key) {
|
||||||
|
let event_with_ime_text = KeyDownEvent {
|
||||||
|
is_held: false,
|
||||||
|
keystroke: Keystroke {
|
||||||
|
ctrl: false,
|
||||||
|
alt: false,
|
||||||
|
shift: false,
|
||||||
|
cmd: false,
|
||||||
|
function: false,
|
||||||
|
key: ime_text.clone().unwrap(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
handled = callback(Event::KeyDown(event_with_ime_text));
|
||||||
|
}
|
||||||
|
if !handled {
|
||||||
|
// empty key happens when you type a deadkey in input composition.
|
||||||
|
// (e.g. on a brazillian keyboard typing quote is a deadkey)
|
||||||
|
if !event.keystroke.key.is_empty() {
|
||||||
|
handled = callback(Event::KeyDown(event));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !handled {
|
if !handled {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue