aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-11-16 22:21:48 +0800
committercrupest <crupest@outlook.com>2021-11-16 22:21:48 +0800
commitce1a7264a3325ae56e341d7af22b0fee914f213b (patch)
tree391cff09e33137f2483c6a7b35cde22a79895f7b
parentf61cd0575f9f8b7be154073304795c22b0ec26ab (diff)
downloadcru-ce1a7264a3325ae56e341d7af22b0fee914f213b.tar.gz
cru-ce1a7264a3325ae56e341d7af22b0fee914f213b.tar.bz2
cru-ce1a7264a3325ae56e341d7af22b0fee914f213b.zip
...
-rw-r--r--include/cru/ui/controls/TextHostControlService.hpp2
-rw-r--r--src/ui/controls/TextHostControlService.cpp11
2 files changed, 13 insertions, 0 deletions
diff --git a/include/cru/ui/controls/TextHostControlService.hpp b/include/cru/ui/controls/TextHostControlService.hpp
index da9547ac..274d092b 100644
--- a/include/cru/ui/controls/TextHostControlService.hpp
+++ b/include/cru/ui/controls/TextHostControlService.hpp
@@ -36,6 +36,8 @@ class TextControlMovePattern : public Object {
static TextControlMovePattern kDown;
static TextControlMovePattern kHome;
static TextControlMovePattern kEnd;
+ static TextControlMovePattern kCtrlHome;
+ static TextControlMovePattern kCtrlEnd;
static TextControlMovePattern kPageUp;
static TextControlMovePattern kPageDown;
diff --git a/src/ui/controls/TextHostControlService.cpp b/src/ui/controls/TextHostControlService.cpp
index e3d25f14..3fb10a95 100644
--- a/src/ui/controls/TextHostControlService.cpp
+++ b/src/ui/controls/TextHostControlService.cpp
@@ -82,6 +82,16 @@ TextControlMovePattern TextControlMovePattern::kEnd(
return Utf16ForwardUntil(text, current_position,
[](char16_t c) { return c == u'\n'; });
});
+TextControlMovePattern TextControlMovePattern::kCtrlHome(
+ helper::ShortcutKeyBind(platform::gui::KeyCode::Home,
+ platform::gui::KeyModifiers::ctrl),
+ [](TextHostControlService* service, StringView text,
+ gsl::index current_position) { return 0; });
+TextControlMovePattern TextControlMovePattern::kCtrlEnd(
+ helper::ShortcutKeyBind(platform::gui::KeyCode::End,
+ platform::gui::KeyModifiers::ctrl),
+ [](TextHostControlService* service, StringView text,
+ gsl::index current_position) { return text.size(); });
TextControlMovePattern TextControlMovePattern::kPageUp(
helper::ShortcutKeyBind(platform::gui::KeyCode::PageUp),
[](TextHostControlService* service, StringView text,
@@ -96,6 +106,7 @@ std::vector<TextControlMovePattern> TextControlMovePattern::kDefaultPatterns = {
TextControlMovePattern::kCtrlLeft, TextControlMovePattern::kCtrlRight,
TextControlMovePattern::kUp, TextControlMovePattern::kDown,
TextControlMovePattern::kHome, TextControlMovePattern::kEnd,
+ TextControlMovePattern::kCtrlHome, TextControlMovePattern::kCtrlEnd,
TextControlMovePattern::kPageUp, TextControlMovePattern::kPageDown};
TextHostControlService::TextHostControlService(gsl::not_null<Control*> control)