aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-04-21 17:08:43 +0800
committercrupest <crupest@outlook.com>2020-04-21 17:08:43 +0800
commit2898b68fc4f7ff40844ddf5a1d0b59f76b06290f (patch)
tree167ba0bff2d995a6f68337bb83cc9e3648dc720a /include
parent857adcb7ee2d45b2e29d4250fa4246bb8861a8f9 (diff)
downloadcru-2898b68fc4f7ff40844ddf5a1d0b59f76b06290f.tar.gz
cru-2898b68fc4f7ff40844ddf5a1d0b59f76b06290f.tar.bz2
cru-2898b68fc4f7ff40844ddf5a1d0b59f76b06290f.zip
...
Diffstat (limited to 'include')
-rw-r--r--include/cru/platform/native/input_method.hpp2
-rw-r--r--include/cru/platform/native/window.hpp1
-rw-r--r--include/cru/win/native/input_method.hpp3
-rw-r--r--include/cru/win/native/window.hpp8
-rw-r--r--include/cru/win/string.hpp2
5 files changed, 7 insertions, 9 deletions
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<std::nullptr_t>* CompositionEvent() = 0;
+
+ virtual IEvent<std::string_view>* 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<NativeMouseButtonEventArgs>* MouseUpEvent() = 0;
virtual IEvent<NativeKeyEventArgs>* KeyDownEvent() = 0;
virtual IEvent<NativeKeyEventArgs>* KeyUpEvent() = 0;
- virtual IEvent<std::string_view>* 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<std::nullptr_t>* CompositionEvent() override;
+ IEvent<std::string_view>* TextEvent() override;
+
private:
void OnWindowNativeMessage(WindowNativeMessageEventArgs& args);
@@ -76,6 +78,7 @@ class WinInputMethodContext : public WinNativeResource,
Event<std::nullptr_t> composition_start_event_;
Event<std::nullptr_t> composition_end_event_;
Event<std::nullptr_t> composition_event_;
+ Event<std::string_view> 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<platform::native::NativeKeyEventArgs>* KeyUpEvent() override {
return &key_up_event_;
}
- IEvent<std::string_view>* CharEvent() override { return &char_event_; };
IEvent<WindowNativeMessageEventArgs&>* 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<platform::native::NativeMouseButtonEventArgs> mouse_up_event_;
Event<platform::native::NativeKeyEventArgs> key_down_event_;
Event<platform::native::NativeKeyEventArgs> key_up_event_;
- Event<std::string_view> char_event_;
Event<WindowNativeMessageEventArgs&> 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;
}