2024-11-20 22:12:36 +00:00
|
|
|
#include <blue/term/tty.h>
|
|
|
|
|
#include <blue/term/print.h>
|
2024-11-14 22:01:40 +00:00
|
|
|
#include <blue/object/string.h>
|
2024-11-20 22:12:36 +00:00
|
|
|
#include <stdio.h>
|
2024-10-24 21:31:22 +01:00
|
|
|
|
2024-11-14 22:01:40 +00:00
|
|
|
#define F_GREEN "[green]"
|
|
|
|
|
#define F_YELLOW "[yellow]"
|
|
|
|
|
#define F_RESET "[reset]"
|
2024-10-24 21:31:22 +01:00
|
|
|
|
|
|
|
|
static const char *text = F_YELLOW
|
|
|
|
|
"But I must " F_GREEN "explain " F_YELLOW "to you " F_GREEN
|
|
|
|
|
"how all this " F_YELLOW "mistaken idea of" F_RESET
|
|
|
|
|
" denouncing pleasure " F_GREEN "and praising pain was born " F_YELLOW
|
|
|
|
|
"and I will give you " F_RESET "a complete account of " F_YELLOW
|
|
|
|
|
"the system, and " F_RESET
|
|
|
|
|
"expound the actual teachings of the great explorer of the truth, the "
|
|
|
|
|
"master-builder of human happiness.\n"
|
|
|
|
|
"No one rejects, dislikes, or avoids pleasure itself, because it is "
|
|
|
|
|
"pleasure, but because those who do not know how to pursue pleasure "
|
|
|
|
|
"rationally encounter consequences that are extremely painful. Nor "
|
|
|
|
|
"again is there anyone who loves or pursues or desires to obtain pain "
|
|
|
|
|
"of itself, because it is pain, but because occasionally circumstances "
|
|
|
|
|
"occur in which toil and pain can procure him some great pleasure.\n"
|
|
|
|
|
"To take a trivial example, which of us ever undertakes laborious "
|
|
|
|
|
"physical exercise, except to obtain some advantage from it? But who "
|
|
|
|
|
"has any right to find fault with a man who chooses to enjoy a "
|
|
|
|
|
"pleasure that has no annoying consequences, or one who avoids a pain "
|
|
|
|
|
"that produces no resultant pleasure? On the other hand, we denounce "
|
|
|
|
|
"with righteous indignation and dislike men who are so beguiled and "
|
|
|
|
|
"demoralized by the charms of pleasure of the moment, so blinded by "
|
|
|
|
|
"desire, that they cannot foresee.";
|
|
|
|
|
|
|
|
|
|
static const char *text2
|
|
|
|
|
= "But I must explain to you how all this mistaken idea of denouncing "
|
|
|
|
|
"pleasure and praising pain was born and I will give you a complete "
|
|
|
|
|
"account of the system, and expound the actual teachings of the "
|
|
|
|
|
"great explorer of the truth, the master-builder of human "
|
|
|
|
|
"happiness.\n"
|
|
|
|
|
"No one rejects, dislikes, or avoids pleasure itself, because it is "
|
|
|
|
|
"pleasure, but because those who do not know how to pursue pleasure "
|
|
|
|
|
"rationally encounter consequences that are extremely painful. Nor "
|
|
|
|
|
"again is there anyone who loves or pursues or desires to obtain "
|
|
|
|
|
"pain of itself, because it is pain, but because occasionally "
|
|
|
|
|
"circumstances occur in which toil and pain can procure him some "
|
|
|
|
|
"great pleasure.\n"
|
|
|
|
|
"To take a trivial example, which of us ever undertakes laborious "
|
|
|
|
|
"physical exercise, except to obtain some advantage from it? But who "
|
|
|
|
|
"has any right to find fault with a man who chooses to enjoy a "
|
|
|
|
|
"pleasure that has no annoying consequences, or one who avoids a "
|
|
|
|
|
"pain that produces no resultant pleasure? On the other hand, we "
|
|
|
|
|
"denounce with righteous indignation and dislike men who are so "
|
|
|
|
|
"beguiled and demoralized by the charms of pleasure of the moment, "
|
|
|
|
|
"so blinded by desire, that they cannot foresee.";
|
|
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
|
{
|
2024-11-20 22:12:36 +00:00
|
|
|
const char *s = "[magenta,uline]Hello, [bright_magenta]world![reset]";
|
|
|
|
|
b_puts(s);
|
|
|
|
|
b_putc('\n');
|
2024-11-14 22:01:40 +00:00
|
|
|
|
|
|
|
|
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 };
|
2024-10-24 21:31:22 +01:00
|
|
|
format.p_left_margin = 5;
|
|
|
|
|
format.p_right_margin = 5;
|
|
|
|
|
format.p_flags = B_PARAGRAPH_DOUBLE_LINE_BREAK;
|
|
|
|
|
|
2024-11-20 22:12:36 +00:00
|
|
|
b_print_paragraph(text, b_stdtty, &format);
|
2024-10-24 21:31:22 +01:00
|
|
|
|
|
|
|
|
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");
|
2024-11-14 22:01:40 +00:00
|
|
|
|
2024-11-20 22:12:36 +00:00
|
|
|
b_printf("[red]formatting ignored: '%s'[reset]\n[dark_grey]dark text[reset]\n", "[blue]wow![reset]");
|
|
|
|
|
|
2024-10-24 21:31:22 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|