term: implement platform-independent console text colour/formatting

This commit is contained in:
2024-11-14 22:01:40 +00:00
parent b260159fae
commit 9ac204e84e
5 changed files with 347 additions and 25 deletions

View File

@@ -1,8 +1,9 @@
#include <blue/term.h>
#include <blue/object/string.h>
#define F_GREEN "\033[92m"
#define F_YELLOW "\033[93m"
#define F_RESET "\033[0m"
#define F_GREEN "[green]"
#define F_YELLOW "[yellow]"
#define F_RESET "[reset]"
static const char *text = F_YELLOW
"But I must " F_GREEN "explain " F_YELLOW "to you " F_GREEN
@@ -51,7 +52,15 @@ static const char *text2
int main(void)
{
b_paragraph_format format = {};
const char *s = "[magenta,uline]Hello, [bright]world![reset]";
b_fputs(s, stdout);
fputc('\n', stdout);
b_string *str = b_string_create_from_cstr(s);
size_t len = b_string_get_size(str, B_STRLEN_IGNORE_MOD);
printf("length = %zu\n", len);
b_paragraph_format format = { 0 };
format.p_left_margin = 5;
format.p_right_margin = 5;
format.p_flags = B_PARAGRAPH_DOUBLE_LINE_BREAK;
@@ -61,5 +70,6 @@ int main(void)
b_i("An informational message\n\nWith multiple lines");
b_warn("A warning message\nWith multiple lines");
b_err("An error message\nWith multiple lines");
return 0;
}