From a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 14 Nov 2021 22:27:08 +0800 Subject: ... --- src/ui/controls/TextHostControlService.cpp | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/ui') 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), text_host_control_(dynamic_cast(control.get())) { -- cgit v1.2.3