* Handle text navigation with arrow keys left/right. * This defines where the caret will blink and the next character interaction will occur * @param keycode 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 */
| 361 | * @return Return true on successful change of Textbuf, or false otherwise |
| 362 | */ |
| 363 | bool Textbuf::MovePos(uint16_t keycode) |
| 364 | { |
| 365 | switch (keycode) { |
| 366 | case WKC_LEFT: |
| 367 | case WKC_CTRL | WKC_LEFT: { |
| 368 | auto move_type = (keycode & WKC_CTRL) != 0 ? StringIterator::ITER_WORD : StringIterator::ITER_CHARACTER; |
| 369 | return (_current_text_dir == TD_LTR) ? this->MovePrev(move_type) : this->MoveNext(move_type); |
| 370 | } |
| 371 | |
| 372 | case WKC_RIGHT: |
| 373 | case WKC_CTRL | WKC_RIGHT: { |
| 374 | auto move_type = (keycode & WKC_CTRL) != 0 ? StringIterator::ITER_WORD : StringIterator::ITER_CHARACTER; |
| 375 | return (_current_text_dir == TD_LTR) ? this->MoveNext(move_type) : this->MovePrev(move_type); |
| 376 | } |
| 377 | |
| 378 | case WKC_HOME: |
| 379 | this->caretpos = 0; |
| 380 | this->char_iter->SetCurPosition(this->caretpos); |
| 381 | this->UpdateCaretPosition(); |
| 382 | return true; |
| 383 | |
| 384 | case WKC_END: |
| 385 | this->caretpos = static_cast<uint16_t>(this->buf.size()); |
| 386 | this->char_iter->SetCurPosition(this->caretpos); |
| 387 | this->UpdateCaretPosition(); |
| 388 | return true; |
| 389 | |
| 390 | default: |
| 391 | break; |
| 392 | } |
| 393 | |
| 394 | return false; |
| 395 | } |
| 396 | |
| 397 | /** |
| 398 | * Initialize the textbuffer by supplying it the buffer to write into |
no test coverage detected