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

Function set_line_contents

subprojects/llama.cpp/common/console.cpp:495–517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

493 }
494
495 static void set_line_contents(std::string new_line, std::string & line, std::vector<int> & widths, size_t & char_pos,
496 size_t & byte_pos) {
497 move_to_line_start(char_pos, byte_pos, widths);
498 clear_current_line(widths);
499
500 line = std::move(new_line);
501 widths.clear();
502 byte_pos = 0;
503 char_pos = 0;
504
505 size_t idx = 0;
506 while (idx < line.size()) {
507 size_t advance = 0;
508 char32_t cp = decode_utf8(line, idx, advance);
509 int expected_width = estimateWidth(cp);
510 int real_width = put_codepoint(line.c_str() + idx, advance, expected_width);
511 if (real_width < 0) real_width = 0;
512 widths.push_back(real_width);
513 idx += advance;
514 ++char_pos;
515 byte_pos = idx;
516 }
517 }
518
519 static void move_to_line_start(size_t & char_pos, size_t & byte_pos, const std::vector<int> & widths) {
520 int back_width = 0;

Callers 1

readline_advancedFunction · 0.85

Calls 8

move_to_line_startFunction · 0.85
clear_current_lineFunction · 0.85
estimateWidthFunction · 0.85
put_codepointFunction · 0.85
decode_utf8Function · 0.70
clearMethod · 0.65
sizeMethod · 0.65
push_backMethod · 0.45

Tested by

no test coverage detected