108 lines
2.2 KiB
C
108 lines
2.2 KiB
C
#ifndef DATA_H_
|
|
#define DATA_H_
|
|
|
|
#include <stdio.h>
|
|
#include <termios.h>
|
|
#include <time.h>
|
|
|
|
#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;
|
|
|
|
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;
|
|
|
|
|
|
struct keyBind_t {
|
|
char *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 */
|
|
row_t *rows; /**< 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 {
|
|
char *b; /**< Text that will be printed */
|
|
int len; /**< Length of the text */
|
|
};
|
|
|
|
extern struct editorConfig E;
|
|
|
|
|
|
#endif
|