diff options
author | crupest <crupest@outlook.com> | 2021-11-14 22:27:08 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-11-14 22:27:08 +0800 |
commit | a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0 (patch) | |
tree | 7f22783f8e0c7f61362ef64e879b50729536fea3 /include/cru/ui/controls | |
parent | 7045737332f742cec36c3d35f48fad82cd41a04b (diff) | |
download | cru-a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0.tar.gz cru-a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0.tar.bz2 cru-a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0.zip |
...
Diffstat (limited to 'include/cru/ui/controls')
-rw-r--r-- | include/cru/ui/controls/TextHostControlService.hpp | 38 |
1 files changed, 38 insertions, 0 deletions
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<gsl::index(TextHostControlService* service, StringView text, + gsl::index current_position)>; + + 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") |