MCPcopy Create free account
hub / github.com/antirez/ds4 / tui_start

Function tui_start

ds4_eval.c:2288–2337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2286 if (!finish && cur[0] == '<' &&
2287 (bytes_is_partial_prefix(cur, rem, open) ||
2288 bytes_is_partial_prefix(cur, rem, close)))
2289 {
2290 if (rem < sizeof(ui->pending_tag)) {
2291 memcpy(ui->pending_tag, cur, rem);
2292 ui->pending_tag_len = rem;
2293 }
2294 break;
2295 }
2296 stream_append_visible(ui, cur, 1);
2297 i++;
2298 }
2299 free(tmp);
2300}
2301
2302typedef struct {
2303 size_t start;
2304 size_t end;
2305} line_span;
2306
2307static void tui_draw_stream(eval_ui *ui) {
2308 if (!ui->enabled) return;
2309 const int width = tui_right_text_w(ui);
2310
2311 line_span *lines = NULL;
2312 int line_len = 0;
2313 int line_cap = 0;
2314 size_t line_start = 0;
2315 int col = 0;
2316
2317 for (size_t i = 0; i < ui->stream.len; i++) {
2318 char c = ui->stream.v[i];
2319 bool end_line = false;
2320 size_t end = i;
2321 if (c == '\n') {
2322 end_line = true;
2323 end = i;
2324 } else {
2325 col++;
2326 if (col >= width) {
2327 end_line = true;
2328 end = i + 1;
2329 }
2330 }
2331 if (end_line) {
2332 if (line_len == line_cap) {
2333 line_cap = line_cap ? line_cap * 2 : 64;
2334 line_span *v = realloc(lines, (size_t)line_cap * sizeof(*lines));
2335 if (!v) {
2336 fprintf(stderr, "ds4-eval: out of memory\n");
2337 exit(1);
2338 }
2339 lines = v;
2340 }

Callers 1

mainFunction · 0.85

Calls 4

terminal_sizeFunction · 0.85
tui_start_inputFunction · 0.85
tui_draw_frameFunction · 0.85
tui_refreshFunction · 0.85

Tested by

no test coverage detected