From a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 14 Nov 2021 22:27:08 +0800 Subject: ... --- include/cru/ui/controls/TextHostControlService.hpp | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'include/cru/ui/controls/TextHostControlService.hpp') diff --git a/include/cru/ui/controls/TextHostControlService.hpp b/include/cru/ui/controls/TextHostControlService.hpp index b56374dc..adf72d69 100644 --- a/include/cru/ui/controls/TextHostControlService.hpp +++ b/include/cru/ui/controls/TextHostControlService.hpp @@ -23,6 +23,44 @@ struct ITextHostControl : virtual Interface { virtual render::ScrollRenderObject* GetScrollRenderObject() = 0; }; +class TextHostControlService; + +class TextControlMovePattern : public Object { + public: + static TextControlMovePattern kLeft; + static TextControlMovePattern kRight; + static TextControlMovePattern kUp; + static TextControlMovePattern kDown; + static TextControlMovePattern kHome; + static TextControlMovePattern kEnd; + static TextControlMovePattern kPageUp; + static TextControlMovePattern kPageDown; + + using MoveFunction = + std::function; + + TextControlMovePattern(helper::ShortcutKeyBind key_bind, + MoveFunction move_function) + : key_bind_(key_bind), move_function_(move_function) {} + + CRU_DELETE_COPY(TextControlMovePattern) + CRU_DELETE_MOVE(TextControlMovePattern) + + ~TextControlMovePattern() override = default; + + public: + helper::ShortcutKeyBind GetKeyBind() const { return key_bind_; } + gsl::index Move(TextHostControlService* service, StringView text, + gsl::index current_position) { + return move_function_(service, text, current_position); + } + + private: + helper::ShortcutKeyBind key_bind_; + MoveFunction move_function_; +}; + class TextHostControlService : public Object { CRU_DEFINE_CLASS_LOG_TAG(u"cru::ui::controls::TextControlService") -- cgit v1.2.3