#ifndef DATA_H_ #define DATA_H_ #include #include #include #include "lisp.h" /** * \struct row_t * \brief Store one editor row * \param * */ typedef struct row { int size; /**< Size of the line */ int cap; /**< Size of the render line */ char *chars; /**< Characters of the line */ } row_t; /** * @brief Split modes for screen layout */ typedef enum { SPLIT_NONE = 0, // Single buffer fullscreen SPLIT_VERTICAL, // Left-right split SPLIT_HORIZONTAL // Top-bottom split } SplitMode; /** * @brief Represents an editor viewport/pane */ typedef struct { int buffer_id; // Which buffer this pane displays int start_row; // Starting row on screen int start_col; // Starting column on screen int height; // Height of this pane int width; // Width of this pane int cursor_x; // Local cursor x in this pane int cursor_y; // Local cursor y in this pane int rx, ry; int row_offset; // Scroll offset for rows int col_offset; // Scroll offset for columns int is_active; // Is this pane currently active } EditorPane; /** * @brief Screen layout manager */ typedef struct { SplitMode mode; EditorPane *panes; int num_panes; int active_pane; // Index of active pane } ScreenLayout; typedef struct theme { char *BACKGROUND_COLOR; char *COLOR_KEYWORD; char *COLOR_TYPE; char *COLOR_STRING; char *COLOR_COMMENT; char *COLOR_NUMBER; char *COLOR_DEFAULT; } theme_t; enum bufferStatus_e { IDLE, READ_ONLY, READ_AND_WRITE, }; struct const_t { int TAB_LENGTH; int QUIT_TIMES; char *THEME; }; struct prefix_t { char prefix_name[64]; int prefix_id; }; struct keyBind_t { char *key_sequence; int prefix_id; Lisp command; }; enum buffer_type { FILE_BUFF, TERMINAL_BUFF }; struct buffer_t { enum buffer_type type; int buffer_id; int width, height; int x, y; /**< Position in the buffer (cursor) */ frow *row; int numrows; char *filename; enum bufferStatus_e state; int dirty; /**< Has this buffer been modified since last save */ int row_offset; /**< Scroll offset for rows in this buffer */ int col_offset; /**< Scroll offset for columns in this buffer */ }; /** * \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*/ ScreenLayout layout; int numrows; /**< Number of rows contained */ row_t *rows; /**< Store all the rows printed */ int dirty; int prefix_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; char *init_file_path; 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 prefix_t *prefix; int number_of_prefix; struct buffer_t buffers[64]; int number_of_buffer; theme_t theme; }; /** * \struct abuf * \brief Contains text to add before writing to screen. * */ struct abuf { char *b; /**< Text that will be printed */ int len; /**< Length of the text */ }; extern struct editorConfig E; #endif