Files
Tart/includes/tart.h

199 lines
4.6 KiB
C

#ifndef TART_H
#define TART_H
#include <string.h>
#define TART_UTF8
#ifdef __cplusplus
extern "C" {
#endif
typedef char tart_display;
typedef unsigned int TART_FLAGS;
typedef unsigned char tart_byte;
typedef unsigned short tart_id;
#ifdef TART_UTF8
#include <wchar.h>
#undef t_char
typedef wchar_t t_char;
#else
typedef char t_char;
#endif
typedef struct {
tart_byte r;
tart_byte g;
tart_byte b;
} tart_color;
#ifndef TART_PALET_SIZE
#define TART_PALET_SIZE 32
#endif
typedef struct {
tart_color forground;
tart_color background;
} tart_pallet;
typedef struct {
int x;
int y;
} tart_vec2;
#ifdef TART_UTF8
#define TART_CELL_SIZE 36 * 2
#else
#define TART_CELL_SIZE 26 + 19
#endif
typedef unsigned int tart_uint;
typedef unsigned int tart_style;
typedef char tart_cell[TART_CELL_SIZE];
typedef struct {
tart_cell** buffer;
tart_vec2 curser;
tart_vec2 jump;
tart_uint bufferSize;
int fd;
}tart_buffer;
/* Tart Window
*
* The tart window will have the window size and all of the buffers.
**/
typedef struct {
tart_pallet pallet[TART_PALET_SIZE];
tart_vec2 homePosition;
tart_vec2 windowSize;
tart_vec2 terminalSize;
tart_buffer buffer;
const char* name;
}tart_window ;
#define TART_OK 0
#define TART_NG -1
#define TART_SET_FLAG(f,x) f |= (x)
#define TART_STYLE_NONE 0
#define TART_STYLE_BOLD 1 << 0
#define TART_STYLE_DIM 1 << 1
#define TART_STYLE_ITALIC 1 << 2
#define TART_STYLE_UNDERLINE 1 << 3
#define TART_STYLE_BLINKING 1 << 4
#define TART_STYLE_INVERSE 1 << 5
#define TART_STYLE_HIDDEN 1 << 6
#define TART_STYLE_STRIKETHROUGH 1 << 7
#define TART_STYLE_DRAW_BOLD 1
#define TART_STYLE_DRAW_DIM 2
#define TART_STYLE_DRAW_ITALIC 3
#define TART_STYLE_DRAW_UNDERLINE 4
#define TART_STYLE_DRAW_BLINKING 5
#define TART_STYLE_DRAW_INVERSE 7
#define TART_STYLE_DRAW_HIDDEN 8
#define TART_STYLE_DRAW_STRIKETHROUGH 9
#define TART_COLOR_BLACK_FOREGROUND 30
#define TART_COLOR_RED_FOREGROUND 31
#define TART_COLOR_GREEN_FOREGROUND 32
#define TART_COLOR_YELLOW_FOREGROUND 33
#define TART_COLOR_BLUE_FOREGROUND 34
#define TART_COLOR_MAGENTA_FOREGROUND 35
#define TART_COLOR_CYAN_FOREGROUND 36
#define TART_COLOR_WHITE_FOREGROUND 37
#define TART_COLOR_DEFAULT_FOREGROUND 39
#define TART_COLOR_BLACK_BACKGROUND 40
#define TART_COLOR_RED_BACKGROUND 41
#define TART_COLOR_GREEN_BACKGROUND 42
#define TART_COLOR_YELLOW_BACKGROUND 43
#define TART_COLOR_BLUE_BACKGROUND 44
#define TART_COLOR_MAGENTA_BACKGROUND 55
#define TART_COLOR_CYAN_BACKGROUND 46
#define TART_COLOR_WHITE_BACKGROUND 47
#define TART_COLOR_DEFAULT_BACKGROUND 49
#define TART_COLOR_BRIGHT_BLACK_FOREGROUND 90
#define TART_COLOR_BRIGHT_RED_FOREGROUND 91
#define TART_COLOR_BRIGHT_GREEN_FOREGROUND 92
#define TART_COLOR_BRIGHT_YELLOW_FOREGROUND 93
#define TART_COLOR_BRIGHT_BLUE_FOREGROUND 94
#define TART_COLOR_BRIGHT_MAGENTA_FOREGROUND 95
#define TART_COLOR_BRIGHT_CYAN_FOREGROUND 96
#define TART_COLOR_BRIGHT_WHITE_FOREGROUND 97
#define TART_COLOR_BRIGHT_BLACK_BACKGROUND 100
#define TART_COLOR_BRIGHT_RED_BACKGROUND 101
#define TART_COLOR_BRIGHT_GREEN_BACKGROUND 102
#define TART_COLOR_BRIGHT_YELLOW_BACKGROUND 103
#define TART_COLOR_BRIGHT_BLUE_BACKGROUND 104
#define TART_COLOR_BRIGHT_MAGENTA_BACKGROUND 105
#define TART_COLOR_BRIGHT_CYAN_BACKGROUND 106
#define TART_COLOR_BRIGHT_WHITE_BACKGROUND 107
#define T ""
#define TC(x) x
#define t_strlen strlen
#define t_strcmp strcmp
#define t_strcpy strcpy
#define t_strncpy strncpy
#define t_snprintf snprintf
#define t_sprintf sprintf
#define t_vsprintf vsprintf
#define t_vsnprintf vsnprintf
#ifdef TART_UTF8
#undef T
#define T L""
#undef TC
#define TC(x) L##x
#undef t_strlen
#define t_strlen wcslen
#undef t_strcmp
#define t_strcmp wcscmp
#undef t_snprintf
#define t_snprintf swprintf
#undef t_sprintf
#define t_sprintf wprintf
#undef t_vsprintf
#define t_vsprintf vswprintf
#undef t_vsnprintf
#define t_vsnprintf vswprintf
#undef t_strcpy
#define t_strcpy wcscpy
#undef t_strncpy
#define t_strncpy wcncpy
#endif
int tart_create_window(tart_window* w, tart_vec2 ws, const char* title);
int tart_init(tart_window* w);
int tart_close(tart_window* w);
void tart_disable_cusor();
void tart_enable_cusor();
int tart_draw(tart_window* w);
int tart_jump(tart_window* w, tart_vec2 pos);
int tart_move_cursor(tart_window* w, tart_vec2 pos);
int tart_insert_cell(tart_window* w, tart_byte p, t_char c);
int tart_printf(tart_window* w,tart_byte p, const t_char* c, ...);
int tart_box(tart_window* w, tart_byte bp, tart_byte fp, const t_char* c,
tart_vec2 fpos,
tart_vec2 spos);
int tart_line(tart_window* w, tart_byte p, const t_char* c, tart_vec2 fpos,
tart_vec2 spos);
#ifdef __cplusplus
}
#endif
#endif