#ifndef DATA_H_ #define DATA_H_ #include #include #include #include "lisp.h" typedef struct{ unsigned char c[4]; char len; } utf_8_char_t; /** * \struct erow * \brief Store one editor row * \param * */ typedef struct erow { int size; /**< Size of the line */ int rsize; /**< Size of the render line */ utf_8_char_t *chars; /**< Characters of the line */ utf_8_char_t *render; /**< The actual line we will print */ } erow; enum editorStatus_e { IDLE, READ_ONLY, READ_AND_WRITE, }; struct const_t { int TAB_LENGTH; int QUIT_TIMES; }; // Key types typedef enum { KEY_CHAR, // Regular character or UTF-8 KEY_CTRL, // Ctrl+letter KEY_ALT, // Alt+letter KEY_ARROW, // Arrow keys KEY_FUNCTION, // Function keys KEY_SPECIAL, // Tab, Enter, ESC, Backspace, etc. KEY_NAVIGATION, // Home, End, PgUp, PgDn, Insert, Delete KEY_UNKNOWN } KeyType; // Modifiers typedef enum { MOD_NONE = 0, MOD_SHIFT = 1, MOD_ALT = 2, MOD_CTRL = 4 } KeyModifier; // Key information structure typedef struct { KeyType type; int modifiers; // Bitmask of KeyModifier union { unsigned int codepoint; // For KEY_CHAR char ctrl_char; // For KEY_CTRL (A-Z) char alt_char; // For KEY_ALT char arrow; // For KEY_ARROW (U/D/L/R) int function_num; // For KEY_FUNCTION (1-12) char special; // For KEY_SPECIAL and KEY_NAVIGATION } data; utf_8_char_t c; // Raw bytes } KeyInfo; struct keyBind_t { KeyInfo *key_sequence; Lisp command; }; /** * \struct editorConfig * \brief Containing our editor state. */ struct editorConfig { int cursor_x, cursor_y; /**< Cursor position */ int rx; /**< Position in the render*/ int row_offset; /**< Position scroll of lines */ int col_offset; /**< Position scroll of colomns*/ int screenrows; /**< Terminal height*/ int screencols; /**< Terminal width*/ int numrows; /**< Number of rows contained */ erow *row; /**< Store all the rows printed */ int dirty; char *filename; enum editorStatus_e state; char status_msg[80]; time_t status_msg_time; struct termios orig_termios; /**< Terminal communication interface */ struct const_t constantes; int quit_times_buffer; FILE *fd_init_file; Lisp env; LispContext ctx; /** Lisp context */ Lisp ctx_data; /** Lisp data context */ LispError ctx_error; /** Lisp ctx error */ struct keyBind_t* key_binds; int number_of_keybinds; }; /** * \struct abuf * \brief Contains text to add before writing to screen. * */ struct abuf { unsigned char *b; /**< Text that will be printed */ int len; /**< Length of the text */ }; extern struct editorConfig E; #endif