diff options
author | crupest <crupest@outlook.com> | 2021-03-24 19:14:19 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-03-24 19:14:19 +0800 |
commit | 7f15a1ff9a2007e119798053083a0a87d042990a (patch) | |
tree | cb35c01a7eaee867376d959b96c9bbd15df939e5 /include/cru/platform/native/InputMethod.hpp | |
parent | 74956951ee663012df0c3fe4ebe29799cb2f7732 (diff) | |
parent | 7703063a5816b089483e78ccd74bb9902ccfbea8 (diff) | |
download | cru-7f15a1ff9a2007e119798053083a0a87d042990a.tar.gz cru-7f15a1ff9a2007e119798053083a0a87d042990a.tar.bz2 cru-7f15a1ff9a2007e119798053083a0a87d042990a.zip |
Merge branch 'master' of https://github.com/crupest/CruUI
Diffstat (limited to 'include/cru/platform/native/InputMethod.hpp')
-rw-r--r-- | include/cru/platform/native/InputMethod.hpp | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/include/cru/platform/native/InputMethod.hpp b/include/cru/platform/native/InputMethod.hpp deleted file mode 100644 index 6f222a43..00000000 --- a/include/cru/platform/native/InputMethod.hpp +++ /dev/null @@ -1,86 +0,0 @@ -#pragma once -#include "../Resource.hpp" -#include "Base.hpp" - -#include "cru/common/Event.hpp" - -#include <fmt/format.h> -#include <memory> -#include <vector> - -namespace cru::platform::native { -struct CompositionClause { - int start; - int end; - bool target; -}; - -using CompositionClauses = std::vector<CompositionClause>; - -struct CompositionText { - std::u16string text; - CompositionClauses clauses; - TextRange selection; -}; - -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; - - virtual void EnableIME() = 0; - - virtual void DisableIME() = 0; - - virtual void CompleteComposition() = 0; - - virtual void CancelComposition() = 0; - - virtual 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<std::nullptr_t>* CompositionStartEvent() = 0; - - // Triggered when user stops composition. - virtual IEvent<std::nullptr_t>* CompositionEndEvent() = 0; - - // Triggered every time composition text changes. - virtual IEvent<std::nullptr_t>* CompositionEvent() = 0; - - virtual IEvent<std::u16string_view>* TextEvent() = 0; -}; - -struct IInputMethodManager : virtual INativeResource { - virtual std::unique_ptr<IInputMethodContext> GetContext( - INativeWindow* window) = 0; -}; -} // namespace cru::platform::native - -template <> -struct fmt::formatter<cru::platform::native::CompositionText, char16_t> - : fmt::formatter<std::u16string_view, char16_t> { - auto parse(fmt::basic_format_parse_context<char16_t>& ctx) { - return fmt::formatter<std::u16string_view, char16_t>::parse(ctx); - } - - template <typename FormatContext> - auto format(const cru::platform::native::CompositionText& ct, - FormatContext& ctx) { - auto output = ctx.out(); - output = format_to(output, u"text: {}\n", ct.text); - output = format_to(output, u"clauses:\n"); - for (gsl::index i = 0; i < static_cast<gsl::index>(ct.clauses.size()); - i++) { - const auto& clause = ct.clauses[i]; - output = - format_to(output, u"\t{}. start: {} end: {}{}\n", i, clause.start, - clause.end, clause.target ? u" target" : u""); - } - output = format_to(output, u"selection: position: {} count: {}", - ct.selection.position, ct.selection.count); - return output; - } -}; |