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

Function move_word_left

subprojects/llama.cpp/common/console.cpp:571–607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

569 }
570
571 static void move_word_left(size_t & char_pos, size_t & byte_pos, const std::vector<int> & widths, const std::string & line) {
572 if (char_pos == 0) {
573 return;
574 }
575
576 size_t new_char_pos = char_pos;
577 size_t new_byte_pos = byte_pos;
578 int move_width = 0;
579
580 while (new_char_pos > 0) {
581 size_t prev_byte = prev_utf8_char_pos(line, new_byte_pos);
582 size_t advance = 0;
583 char32_t cp = decode_utf8(line, prev_byte, advance);
584 if (!is_space_codepoint(cp)) {
585 break;
586 }
587 move_width += widths[new_char_pos - 1];
588 new_char_pos--;
589 new_byte_pos = prev_byte;
590 }
591
592 while (new_char_pos > 0) {
593 size_t prev_byte = prev_utf8_char_pos(line, new_byte_pos);
594 size_t advance = 0;
595 char32_t cp = decode_utf8(line, prev_byte, advance);
596 if (is_space_codepoint(cp)) {
597 break;
598 }
599 move_width += widths[new_char_pos - 1];
600 new_char_pos--;
601 new_byte_pos = prev_byte;
602 }
603
604 move_cursor(-move_width);
605 char_pos = new_char_pos;
606 byte_pos = new_byte_pos;
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()) {

Callers 1

readline_advancedFunction · 0.85

Calls 4

prev_utf8_char_posFunction · 0.85
is_space_codepointFunction · 0.85
move_cursorFunction · 0.85
decode_utf8Function · 0.70

Tested by

no test coverage detected