From 2898b68fc4f7ff40844ddf5a1d0b59f76b06290f Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 21 Apr 2020 17:08:43 +0800 Subject: ... --- include/cru/platform/native/input_method.hpp | 2 ++ include/cru/platform/native/window.hpp | 1 - include/cru/win/native/input_method.hpp | 3 +++ include/cru/win/native/window.hpp | 8 -------- include/cru/win/string.hpp | 2 ++ 5 files changed, 7 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/cru/platform/native/input_method.hpp b/include/cru/platform/native/input_method.hpp index 4034be4e..c6413a7e 100644 --- a/include/cru/platform/native/input_method.hpp +++ b/include/cru/platform/native/input_method.hpp @@ -66,6 +66,8 @@ struct IInputMethodContext : virtual INativeResource { // Triggered every time composition text changes. virtual IEvent* CompositionEvent() = 0; + + virtual IEvent* TextEvent() = 0; }; struct IInputMethodManager : virtual INativeResource { diff --git a/include/cru/platform/native/window.hpp b/include/cru/platform/native/window.hpp index 49b00023..57363a3b 100644 --- a/include/cru/platform/native/window.hpp +++ b/include/cru/platform/native/window.hpp @@ -57,7 +57,6 @@ struct INativeWindow : virtual INativeResource { virtual IEvent* MouseUpEvent() = 0; virtual IEvent* KeyDownEvent() = 0; virtual IEvent* KeyUpEvent() = 0; - virtual IEvent* CharEvent() = 0; }; // See INativeWindow for more info. diff --git a/include/cru/win/native/input_method.hpp b/include/cru/win/native/input_method.hpp index 8e17abd5..ff867f3f 100644 --- a/include/cru/win/native/input_method.hpp +++ b/include/cru/win/native/input_method.hpp @@ -61,6 +61,8 @@ class WinInputMethodContext : public WinNativeResource, IEvent* CompositionEvent() override; + IEvent* TextEvent() override; + private: void OnWindowNativeMessage(WindowNativeMessageEventArgs& args); @@ -76,6 +78,7 @@ class WinInputMethodContext : public WinNativeResource, Event composition_start_event_; Event composition_end_event_; Event composition_event_; + Event text_event_; }; class WinInputMethodManager : public WinNativeResource, diff --git a/include/cru/win/native/window.hpp b/include/cru/win/native/window.hpp index 83497fa6..59b38ab5 100644 --- a/include/cru/win/native/window.hpp +++ b/include/cru/win/native/window.hpp @@ -72,7 +72,6 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { IEvent* KeyUpEvent() override { return &key_up_event_; } - IEvent* CharEvent() override { return &char_event_; }; IEvent* NativeMessageEvent() { return &native_message_event_; @@ -109,7 +108,6 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { void OnMouseWheelInternal(short delta, POINT point); void OnKeyDownInternal(int virtual_code); void OnKeyUpInternal(int virtual_code); - void OnCharInternal(wchar_t c); void OnActivatedInternal(); void OnDeactivatedInternal(); @@ -146,14 +144,8 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { Event mouse_up_event_; Event key_down_event_; Event key_up_event_; - Event char_event_; Event native_message_event_; - - // WM_CHAR may be sent twice successively with two utf-16 code units of - // surrogate pair when character is from supplementary planes. This field is - // used to save the previous one. - wchar_t last_wm_char_event_wparam_; }; class WinNativeWindowResolver : public WinNativeResource, diff --git a/include/cru/win/string.hpp b/include/cru/win/string.hpp index b2bfd245..aec0e3d9 100644 --- a/include/cru/win/string.hpp +++ b/include/cru/win/string.hpp @@ -27,6 +27,8 @@ namespace cru::platform::win { std::string ToUtf8String(const std::wstring_view& string); std::wstring ToUtf16String(const std::string_view& string); +inline bool IsSurrogatePair(wchar_t c) { return c >= 0xD800 && c <= 0xDFFF; } + inline bool IsSurrogatePairLeading(wchar_t c) { return c >= 0xD800 && c <= 0xDBFF; } -- cgit v1.2.3