MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / delete_at_cursor

Function delete_at_cursor

common/console.cpp:456–482  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected