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

Function renderer_process

ds4_agent.c:2611–2652  ·  view source on GitHub ↗

Render assistant text while hiding tags and dimming thinking text. * The function is also responsible for not prematurely emitting a partial * control tag split across model tokens. */

Source from the content-addressed store, hash-verified

2609 }
2610 r->utf8_pending[0] = c;
2611 r->utf8_pending_len = 1;
2612 r->utf8_pending_need = need;
2613}
2614
2615static void renderer_write_plain_byte(agent_token_renderer *r, char c) {
2616 bool old_bold = r->md_bold;
2617 bool old_italic = r->md_italic;
2618 bool old_inline_code = r->md_inline_code;
2619 bool old_code_block = r->md_code_block;
2620
2621 /* Code blocks are streamed immediately in plain text, then repainted with
2622 * syntax colors when a complete terminal-safe line is available. Disable
2623 * markdown attributes only for this byte; renderer_write_char_raw() will
2624 * reset any tracked manual color once if needed. */
2625 r->md_bold = false;
2626 r->md_italic = false;
2627 r->md_inline_code = false;
2628 r->md_code_block = false;
2629 renderer_write_char_raw(r, c);
2630 r->md_bold = old_bold;
2631 r->md_italic = old_italic;
2632 r->md_inline_code = old_inline_code;
2633 r->md_code_block = old_code_block;
2634}
2635
2636/* Poor man's code highlighter inspired by antirez/kilo: a tiny language table
2637 * plus one line-oriented tokenizer for comments, strings, numbers, and
2638 * separator-bounded keywords. This is deliberately not a full parser; it is
2639 * only for making fenced Markdown code readable in the terminal. */
2640#define AGENT_HL_NORMAL 0
2641#define AGENT_HL_COMMENT 1
2642#define AGENT_HL_KEYWORD1 2
2643#define AGENT_HL_KEYWORD2 3
2644#define AGENT_HL_STRING 4
2645#define AGENT_HL_NUMBER 5
2646
2647#define AGENT_SYNTAX_NUMBERS (1u<<0)
2648#define AGENT_SYNTAX_STRINGS (1u<<1)
2649#define AGENT_SYNTAX_BACKTICK_STRINGS (1u<<2)
2650#define AGENT_SYNTAX_CASE_INSENSITIVE (1u<<3)
2651
2652struct agent_syntax {
2653 const char *name;
2654 const char *aliases;
2655 const char **keywords;

Callers 1

renderer_finishFunction · 0.85

Calls 6

renderer_reset_colorFunction · 0.85
renderer_writeFunction · 0.85
renderer_write_charFunction · 0.85
xmallocFunction · 0.70
bytes_has_prefixFunction · 0.70
bytes_is_partial_prefixFunction · 0.70

Tested by

no test coverage detected