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 /src/ui/controls/TextHostControlService.cpp | |
parent | 7045737332f742cec36c3d35f48fad82cd41a04b (diff) | |
download | cru-a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0.tar.gz cru-a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0.tar.bz2 cru-a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0.zip |
...
Diffstat (limited to 'src/ui/controls/TextHostControlService.cpp')
-rw-r--r-- | src/ui/controls/TextHostControlService.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/ui/controls/TextHostControlService.cpp b/src/ui/controls/TextHostControlService.cpp index 2233d1e6..9f5098db 100644 --- a/src/ui/controls/TextHostControlService.cpp +++ b/src/ui/controls/TextHostControlService.cpp @@ -18,6 +18,45 @@ #include "cru/ui/render/TextRenderObject.hpp" namespace cru::ui::controls { +TextControlMovePattern TextControlMovePattern::kLeft( + helper::ShortcutKeyBind(platform::gui::KeyCode::Left), + [](TextHostControlService* service, StringView text, + gsl::index current_position) { + Utf16PreviousCodePoint(text, current_position, ¤t_position); + return current_position; + }); +TextControlMovePattern TextControlMovePattern::kRight( + helper::ShortcutKeyBind(platform::gui::KeyCode::Right), + [](TextHostControlService* service, StringView text, + gsl::index current_position) { + Utf16NextCodePoint(text, current_position, ¤t_position); + return current_position; + }); +TextControlMovePattern TextControlMovePattern::kUp( + helper::ShortcutKeyBind(platform::gui::KeyCode::Up), + [](TextHostControlService* service, StringView text, + gsl::index current_position) { return current_position; }); +TextControlMovePattern TextControlMovePattern::kDown( + helper::ShortcutKeyBind(platform::gui::KeyCode::Down), + [](TextHostControlService* service, StringView text, + gsl::index current_position) { return current_position; }); +TextControlMovePattern TextControlMovePattern::kHome( + helper::ShortcutKeyBind(platform::gui::KeyCode::Home), + [](TextHostControlService* service, StringView text, + gsl::index current_position) { return current_position; }); +TextControlMovePattern TextControlMovePattern::kEnd( + helper::ShortcutKeyBind(platform::gui::KeyCode::End), + [](TextHostControlService* service, StringView text, + gsl::index current_position) { return current_position; }); +TextControlMovePattern TextControlMovePattern::kPageUp( + helper::ShortcutKeyBind(platform::gui::KeyCode::PageUp), + [](TextHostControlService* service, StringView text, + gsl::index current_position) { return current_position; }); +TextControlMovePattern TextControlMovePattern::kPageDown( + helper::ShortcutKeyBind(platform::gui::KeyCode::PageDown), + [](TextHostControlService* service, StringView text, + gsl::index current_position) { return current_position; }); + TextHostControlService::TextHostControlService(gsl::not_null<Control*> control) : control_(control), text_host_control_(dynamic_cast<ITextHostControl*>(control.get())) { |