|
/* retoor <retoor@molodetz.nl> */
|
|
#ifndef TERMINAL_H
|
|
#define TERMINAL_H
|
|
|
|
#include <termios.h>
|
|
|
|
#define COLOR_RESET "\033[0m"
|
|
#define COLOR_BOLD "\033[1m"
|
|
#define COLOR_RED "\033[31m"
|
|
#define COLOR_GREEN "\033[32m"
|
|
#define COLOR_YELLOW "\033[33m"
|
|
#define COLOR_BLUE "\033[34m"
|
|
#define COLOR_MAGENTA "\033[35m"
|
|
#define COLOR_CYAN "\033[36m"
|
|
#define COLOR_WHITE "\033[37m"
|
|
#define COLOR_BOLD_RED "\033[1;31m"
|
|
#define COLOR_BOLD_GREEN "\033[1;32m"
|
|
#define COLOR_BOLD_YELLOW "\033[1;33m"
|
|
#define COLOR_BOLD_BLUE "\033[1;34m"
|
|
#define COLOR_BOLD_CYAN "\033[1;36m"
|
|
#define COLOR_BOLD_WHITE "\033[1;37m"
|
|
#define COLOR_BG_RED "\033[41m"
|
|
#define COLOR_BG_GREEN "\033[42m"
|
|
#define COLOR_BG_BLUE "\033[44m"
|
|
|
|
typedef struct {
|
|
int rows;
|
|
int cols;
|
|
struct termios orig_termios;
|
|
char *buffer;
|
|
size_t buffer_size;
|
|
size_t buffer_pos;
|
|
} Terminal;
|
|
|
|
int terminal_init(Terminal *term);
|
|
void terminal_cleanup(Terminal *term);
|
|
void terminal_get_size(Terminal *term);
|
|
void terminal_clear(Terminal *term);
|
|
void terminal_move_cursor(Terminal *term, int row, int col);
|
|
void terminal_hide_cursor(Terminal *term);
|
|
void terminal_show_cursor(Terminal *term);
|
|
void terminal_buffer_clear(Terminal *term);
|
|
void terminal_buffer_append(Terminal *term, const char *str);
|
|
void terminal_buffer_flush(Terminal *term);
|
|
void terminal_set_raw_mode(Terminal *term);
|
|
void terminal_restore_mode(Terminal *term);
|
|
|
|
#endif
|