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,43 +1,10 @@
#ifndef BLUELIB_PRINT_H_
#define BLUELIB_PRINT_H_
#ifndef BLUELIB_TERM_H_
#define BLUELIB_TERM_H_
#include <blue/core/status.h>
#include <stdio.h>
#define b_i(...) b_print(B_PRINT_I, __VA_ARGS__)
#define b_warn(...) b_print(B_PRINT_WARN, __VA_ARGS__)
#define b_err(...) b_print(B_PRINT_ERR, __VA_ARGS__)
typedef enum b_paragraph_format_flags {
B_PARAGRAPH_DONT_INDENT_FIRST_LINE = 0x01u,
B_PARAGRAPH_HYPHENATE = 0x02u,
B_PARAGRAPH_DOUBLE_LINE_BREAK = 0x04u,
B_PARAGRAPH_MULTI_LINE_BREAK = 0x08u,
} b_paragraph_format_flags;
typedef struct b_paragraph_format {
b_paragraph_format_flags p_flags;
unsigned int p_left_margin;
unsigned int p_right_margin;
unsigned int p_line_length;
} b_paragraph_format;
typedef enum b_print_format {
B_PRINT_NORMAL = 0,
B_PRINT_I,
B_PRINT_WARN,
B_PRINT_ERR,
} b_print_format;
BLUE_API b_status b_term_get_dimensions(FILE *fp, unsigned int *w, unsigned int *h);
BLUE_API b_status b_print(b_print_format format, const char *str, ...);
BLUE_API b_status b_print_paragraph(
const char *str, FILE *fp, b_paragraph_format *format);
BLUE_API int b_fputs(const char *str, FILE *fp);
BLUE_API int b_printf(const char *format, ...);
BLUE_API int b_fprintf(FILE *fp, const char *format, ...);
#include <blue/term/tty.h>
#include <blue/term/print.h>
#endif