/***************************************************************************** Add a line of text to the output ("chatline") window, like puts() would do it in the console. *****************************************************************************/ void luaconsole_append(const struct ft_color color, const char *featured_text) { char plain_text[MAX_LEN_MSG]; struct text_tag_list *tags; /* Separate the text and the tags. */ featured_text_to_plain_text(featured_text, plain_text, sizeof(plain_text), &tags); if (ft_color_requested(color)) { /* A color is requested. */ struct text_tag *ptag = text_tag_new(TTT_COLOR, 0, FT_OFFSET_UNSET, color); if (ptag) { /* Prepends to the list, to avoid to overwrite inside colors. */ text_tag_list_prepend(tags, ptag); } else { log_error("Failed to create a color text tag (fg = %s, bg = %s).", (NULL != color.foreground ? color.foreground : "NULL"), (NULL != color.background ? color.background : "NULL")); } } real_luaconsole_append(plain_text, tags); text_tag_list_destroy(tags); }
/************************************************************************ Write to console and add line-break, and show prompt if required. ************************************************************************/ void con_write(enum rfc_status rfc_status, const char *message, ...) { /* First buffer contains featured text tags */ static char buf1[(MAX_LEN_CONSOLE_LINE * 3) / 2]; static char buf2[MAX_LEN_CONSOLE_LINE]; va_list args; va_start(args, message); my_vsnprintf(buf1, sizeof(buf1), message, args); va_end(args); /* remove all format tags */ featured_text_to_plain_text(buf1, buf2, sizeof(buf2), NULL); con_puts(rfc_status, buf2); }