From 39c0b5ad6814db9e46ac2cb4ab64a37e0e19749b Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 16 Apr 2020 16:22:50 +0800 Subject: ... --- include/cru/platform/native/input_method.hpp | 42 ++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'include/cru/platform/native/input_method.hpp') diff --git a/include/cru/platform/native/input_method.hpp b/include/cru/platform/native/input_method.hpp index cce10d93..00017502 100644 --- a/include/cru/platform/native/input_method.hpp +++ b/include/cru/platform/native/input_method.hpp @@ -4,32 +4,50 @@ #include "cru/common/event.hpp" #include +#include namespace cru::platform::native { -// It is a reference, so there is a ref count, remember to destroy it to release -// the ref after use. -struct IInputMethodContextRef : virtual INativeResource { +struct CompositionUnderline { + int start; + int end; +}; + +struct CompositionText { + std::string text; + std::vector underlines; + int caret_position; +}; + +struct IInputMethodContext : virtual INativeResource { // Return true if you should draw composition text manually. Return false if // system will take care of that for you. virtual bool ShouldManuallyDrawCompositionText() = 0; - // Reset composition string. Use this method to prepare typing. - virtual void Reset() = 0; - // Get the composition string. - virtual std::string GetCompositionText() = 0; + + virtual void EnableIME() = 0; + + virtual void DisableIME() = 0; + + virtual void CompleteComposition() = 0; + + virtual void CancelComposition() = 0; + + virtual const CompositionText& GetCompositionText() = 0; + // Set the candidate window lefttop. Use this method to prepare typing. virtual void SetCandidateWindowPosition(const Point& point) = 0; + // Triggered when user starts composition. virtual IEvent* CompositionStartEvent() = 0; + // Triggered when user stops composition. virtual IEvent* CompositionEndEvent() = 0; - // Triggered every time composition text changes, event args is the new - // composition text. - virtual IEvent* CompositionTextChangeEvent() = 0; + + // Triggered every time composition text changes. + virtual IEvent* CompositionEvent() = 0; }; struct IInputMethodManager : virtual INativeResource { - // Get a reference of context of a window. - virtual std::unique_ptr GetContext( + virtual std::unique_ptr GetContext( INativeWindow* window) = 0; }; } // namespace cru::platform::native -- cgit v1.2.3