summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/misc_gui.cpp1
-rw-r--r--src/textbuf.cpp40
2 files changed, 40 insertions, 1 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 7dbb84ad0..7d21ad19e 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -744,6 +744,7 @@ HandleEditBoxResult QueryString::HandleEditBoxKey(Window *w, int wid, uint16 key
break;
case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
+ case WKC_CTRL | WKC_LEFT: case WKC_CTRL | WKC_RIGHT:
if (this->text.MovePos(keycode)) w->SetWidgetDirty(wid);
break;
diff --git a/src/textbuf.cpp b/src/textbuf.cpp
index 673e77e49..d9069755a 100644
--- a/src/textbuf.cpp
+++ b/src/textbuf.cpp
@@ -224,7 +224,7 @@ WChar Textbuf::MoveCaretRight()
/**
* Handle text navigation with arrow keys left/right.
* This defines where the caret will blink and the next characer interaction will occur
- * @param navmode Direction in which navigation occurs WKC_LEFT, WKC_RIGHT, WKC_END, WKC_HOME
+ * @param navmode Direction in which navigation occurs (WKC_CTRL |) WKC_LEFT, (WKC_CTRL |) WKC_RIGHT, WKC_END, WKC_HOME
* @return Return true on successful change of Textbuf, or false otherwise
*/
bool Textbuf::MovePos(int navmode)
@@ -237,6 +237,26 @@ bool Textbuf::MovePos(int navmode)
}
break;
+ case WKC_CTRL | WKC_LEFT: {
+ if (!this->CanMoveCaretLeft()) break;
+
+ /* Unconditionally move one char to the left. */
+ WChar c = this->MoveCaretLeft();
+ /* Consume left whitespaces. */
+ while (IsWhitespace(c)) {
+ if (!this->CanMoveCaretLeft()) return true;
+ c = this->MoveCaretLeft();
+ }
+ /* Consume left word. */
+ while (!IsWhitespace(c)) {
+ if (!this->CanMoveCaretLeft()) return true;
+ c = this->MoveCaretLeft();
+ }
+ /* Place caret at the begining of the left word. */
+ this->MoveCaretRight();
+ return true;
+ }
+
case WKC_RIGHT:
if (this->CanMoveCaretRight()) {
this->MoveCaretRight();
@@ -244,6 +264,24 @@ bool Textbuf::MovePos(int navmode)
}
break;
+ case WKC_CTRL | WKC_RIGHT: {
+ if (!this->CanMoveCaretRight()) break;
+
+ /* Unconditionally move one char to the right. */
+ WChar c = this->MoveCaretRight();
+ /* Continue to consume current word. */
+ while (!IsWhitespace(c)) {
+ if (!this->CanMoveCaretRight()) return true;
+ c = this->MoveCaretRight();
+ }
+ /* Consume right whitespaces. */
+ while (IsWhitespace(c)) {
+ if (!this->CanMoveCaretRight()) return true;
+ c = this->MoveCaretRight();
+ }
+ return true;
+ }
+
case WKC_HOME:
this->caretpos = 0;
this->caretxoffs = 0;