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

Function delete_at_cursor

subprojects/llama.cpp/common/console.cpp:454–480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

452 static void move_to_line_end(size_t & char_pos, size_t & byte_pos, const std::vector<int> & widths, const std::string & line);
453
454 static void delete_at_cursor(std::string & line, std::vector<int> & widths, size_t & char_pos, size_t & byte_pos) {
455 if (char_pos >= widths.size()) {
456 return;
457 }
458
459 size_t next_pos = next_utf8_char_pos(line, byte_pos);
460 int w = widths[char_pos];
461 size_t char_len = next_pos - byte_pos;
462
463 line.erase(byte_pos, char_len);
464 widths.erase(widths.begin() + char_pos);
465
466 size_t p = byte_pos;
467 int tail_width = 0;
468 for (size_t i = char_pos; i < widths.size(); ++i) {
469 size_t following = next_utf8_char_pos(line, p);
470 put_codepoint(line.c_str() + p, following - p, widths[i]);
471 tail_width += widths[i];
472 p = following;
473 }
474
475 for (int i = 0; i < w; ++i) {
476 fputc(' ', out);
477 }
478
479 move_cursor(-(tail_width + w));
480 }
481
482 static void clear_current_line(const std::vector<int> & widths) {
483 int total_width = 0;

Callers 1

readline_advancedFunction · 0.85

Calls 5

next_utf8_char_posFunction · 0.85
put_codepointFunction · 0.85
move_cursorFunction · 0.85
sizeMethod · 0.65
beginMethod · 0.45

Tested by

no test coverage detected