#ifndef __TERM_H #define __TERM_H #include #define TERM_MAX_PARAMS 2 enum term_state { TERM_STATE_GROUND, TERM_STATE_ESC, TERM_STATE_ESC_INTERMEDIATE, TERM_STATE_CSI_ENTRY, TERM_STATE_CSI_PARAM, TERM_STATE_CSI_INTERMEDIATE, TERM_STATE_CSI_IGNORE, }; struct term_cursor { int x; int y; }; struct sgr_attrs { int normal; uint8_t bg; uint8_t fg; int bold; }; struct cell { // No unicode support >:( char c; struct sgr_attrs sgra; }; struct row { struct cell *cells; }; struct term { enum term_state state; int num_rows; int num_cols; int params[TERM_MAX_PARAMS]; int param_idx; struct term_cursor cursor; struct row *rows; struct sgr_attrs sgra; int pango; }; void term_init(struct term *t, int rows, int cols, int pango); void term_put(struct term *t, char c); void term_put_string(struct term *t, char *str); char *term_to_string(struct term *t); #endif