term: extend tty interface with more features

This commit is contained in:
2024-11-20 22:12:36 +00:00
parent 7e440f213c
commit dafa74b1b9
13 changed files with 3163 additions and 317 deletions

View File

@@ -1,5 +1,7 @@
#include <blue/term.h>
#include <blue/term/tty.h>
#include <blue/term/print.h>
#include <blue/object/string.h>
#include <stdio.h>
#define F_GREEN "[green]"
#define F_YELLOW "[yellow]"
@@ -52,9 +54,9 @@ static const char *text2
int main(void)
{
const char *s = "[magenta,uline]Hello, [bright]world![reset]";
b_fputs(s, stdout);
fputc('\n', stdout);
const char *s = "[magenta,uline]Hello, [bright_magenta]world![reset]";
b_puts(s);
b_putc('\n');
b_string *str = b_string_create_from_cstr(s);
size_t len = b_string_get_size(str, B_STRLEN_IGNORE_MOD);
@@ -65,11 +67,13 @@ int main(void)
format.p_right_margin = 5;
format.p_flags = B_PARAGRAPH_DOUBLE_LINE_BREAK;
b_print_paragraph(text, stdout, &format);
b_print_paragraph(text, b_stdtty, &format);
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");
b_printf("[red]formatting ignored: '%s'[reset]\n[dark_grey]dark text[reset]\n", "[blue]wow![reset]");
return 0;
}