(svn r24520) -Feature [FS#5203]: Ctrl + Arrow keys to move entire words in text edit boxes (sbr)

pull/155/head
zuu 12 years ago
parent 6556e04234
commit 072fdc43a0

@ -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;

@ -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;

Loading…
Cancel
Save