1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 13:21:38 +03:00

window: add deadkeystatus event

Plumbs it for Windows.
Doesn't do anything useful with it yet.

refs: #688
This commit is contained in:
Wez Furlong 2022-01-02 17:00:18 -07:00
parent 2d62bffe41
commit 79ab6e8103
3 changed files with 27 additions and 3 deletions

View File

@ -809,6 +809,10 @@ impl TermWindow {
self.key_event_impl(event, window);
Ok(true)
}
WindowEvent::AdviseDeadKeyStatus(status) => {
log::warn!("DeadKeyStatus now: {:?}", status);
Ok(true)
}
WindowEvent::NeedRepaint => Ok(self.do_paint(window)),
WindowEvent::Notification(item) => {
if let Ok(notif) = item.downcast::<TermWindowNotif>() {

View File

@ -122,6 +122,14 @@ pub enum WindowKeyEvent {
KeyEvent(KeyEvent),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DeadKeyStatus {
/// Not in a dead key processing hold
None,
/// Holding input until a dead key is recognized
Holding,
}
#[derive(Debug)]
pub enum WindowEvent {
/// Called when the window close button is clicked.
@ -146,6 +154,8 @@ pub enum WindowEvent {
/// Called when the window gains/loses focus
FocusChanged(bool),
AdviseDeadKeyStatus(DeadKeyStatus),
/// Called to handle a raw key event, prior to any dead key,
/// keymap composition or other higher level treatment.
/// If you handle this key event, you must call

View File

@ -2,8 +2,8 @@ use super::*;
use crate::connection::ConnectionOps;
use crate::Appearance;
use crate::{
Clipboard, Dimensions, Handled, KeyCode, KeyEvent, Modifiers, MouseButtons, MouseCursor,
MouseEvent, MouseEventKind, MousePress, Point, RawKeyEvent, Rect, ScreenPoint,
Clipboard, DeadKeyStatus, Dimensions, Handled, KeyCode, KeyEvent, Modifiers, MouseButtons,
MouseCursor, MouseEvent, MouseEventKind, MousePress, Point, RawKeyEvent, Rect, ScreenPoint,
WindowDecorations, WindowEvent, WindowEventSender, WindowOps, WindowState,
};
use anyhow::{bail, Context};
@ -1840,7 +1840,11 @@ unsafe fn key(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) -> Option<L
.dispatch(WindowEvent::RawKeyEvent(raw_key_event));
if handled_raw.is_handled() {
// Cancel any pending dead key
inner.dead_pending.take();
if inner.dead_pending.take().is_some() {
inner
.events
.dispatch(WindowEvent::AdviseDeadKeyStatus(DeadKeyStatus::None));
}
log::trace!("raw key was handled; not processing further");
return Some(0);
}
@ -1861,6 +1865,9 @@ unsafe fn key(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) -> Option<L
// If we previously had the start of a dead key...
let dead = if let Some(leader) = inner.dead_pending.take() {
inner
.events
.dispatch(WindowEvent::AdviseDeadKeyStatus(DeadKeyStatus::None));
// look to see how the current event resolves it
match inner
.keyboard_info
@ -1923,6 +1930,9 @@ unsafe fn key(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) -> Option<L
// wait for a subsequent keypress.
if inner.config.use_dead_keys {
inner.dead_pending.replace((modifiers, vk));
inner
.events
.dispatch(WindowEvent::AdviseDeadKeyStatus(DeadKeyStatus::Holding));
return Some(0);
}
// They don't want dead keys; just return the base character