MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / move_word_right

Function move_word_right

subprojects/llama.cpp/common/console.cpp:609–654  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

607 }
608
609 static void move_word_right(size_t & char_pos, size_t & byte_pos, const std::vector<int> & widths, const std::string & line) {
610 if (char_pos >= widths.size()) {
611 return;
612 }
613
614 size_t new_char_pos = char_pos;
615 size_t new_byte_pos = byte_pos;
616 int move_width = 0;
617
618 while (new_char_pos < widths.size()) {
619 size_t advance = 0;
620 char32_t cp = decode_utf8(line, new_byte_pos, advance);
621 if (!is_space_codepoint(cp)) {
622 break;
623 }
624 move_width += widths[new_char_pos];
625 new_char_pos++;
626 new_byte_pos += advance;
627 }
628
629 while (new_char_pos < widths.size()) {
630 size_t advance = 0;
631 char32_t cp = decode_utf8(line, new_byte_pos, advance);
632 if (is_space_codepoint(cp)) {
633 break;
634 }
635 move_width += widths[new_char_pos];
636 new_char_pos++;
637 new_byte_pos += advance;
638 }
639
640 while (new_char_pos < widths.size()) {
641 size_t advance = 0;
642 char32_t cp = decode_utf8(line, new_byte_pos, advance);
643 if (!is_space_codepoint(cp)) {
644 break;
645 }
646 move_width += widths[new_char_pos];
647 new_char_pos++;
648 new_byte_pos += advance;
649 }
650
651 move_cursor(move_width);
652 char_pos = new_char_pos;
653 byte_pos = new_byte_pos;
654 }
655
656 static void move_cursor(int delta) {
657 if (delta == 0) return;

Callers 1

readline_advancedFunction · 0.85

Calls 4

is_space_codepointFunction · 0.85
move_cursorFunction · 0.85
decode_utf8Function · 0.70
sizeMethod · 0.65

Tested by

no test coverage detected