aboutsummaryrefslogtreecommitdiff
path: root/include/types.h
diff options
context:
space:
mode:
authorDavid Moc <personal@cdatgoose.org>2026-05-30 21:53:05 +0200
committerDavid Moc <personal@cdatgoose.org>2026-05-30 21:53:05 +0200
commite930cc6bdc7f62befac063d7d9d016ffb0a64f1a (patch)
tree52118a1e990ae88f5f0410c8caea129609e22e19 /include/types.h
Added the old repo, refactored it, added the C jit.
Diffstat (limited to 'include/types.h')
-rw-r--r--include/types.h194
1 files changed, 194 insertions, 0 deletions
diff --git a/include/types.h b/include/types.h
new file mode 100644
index 0000000..1dc2158
--- /dev/null
+++ b/include/types.h
@@ -0,0 +1,194 @@
+#ifndef ECEX_TYPES_H
+#define ECEX_TYPES_H
+
+#include <stddef.h>
+
+typedef struct ecex ecex_t;
+typedef struct buffer buffer_t;
+typedef struct ecex_window ecex_window_t;
+
+typedef int (*ecex_command_fn)(ecex_t *ed);
+typedef int (*ecex_interactive_line_fn)(ecex_t *ed, buffer_t *buffer, size_t line, const char *payload, void *userdata);
+typedef const char *(*ecex_clipboard_get_fn)(void *userdata);
+typedef void (*ecex_clipboard_set_fn)(void *userdata, const char *text);
+
+typedef enum ecex_prompt_request {
+ ECEX_PROMPT_NONE = 0,
+ ECEX_PROMPT_FIND_FILE,
+ ECEX_PROMPT_WRITE_FILE,
+ ECEX_PROMPT_EVAL_FILE,
+ ECEX_PROMPT_SWITCH_BUFFER,
+ ECEX_PROMPT_KILL_BUFFER,
+ ECEX_PROMPT_COMPILE,
+ ECEX_PROMPT_GREP,
+ ECEX_PROMPT_ISEARCH_FORWARD,
+ ECEX_PROMPT_ISEARCH_BACKWARD,
+} ecex_prompt_request_t;
+
+typedef struct ecex_undo_entry {
+ char *data;
+ size_t len;
+ size_t point;
+ size_t mark;
+ int mark_active;
+} ecex_undo_entry_t;
+
+typedef struct ecex_color {
+ float r;
+ float g;
+ float b;
+} ecex_color_t;
+
+typedef struct ecex_theme {
+ char *font_path;
+ float font_size;
+
+ ecex_color_t bg;
+ ecex_color_t fg;
+
+ ecex_color_t status_bg;
+ ecex_color_t status_fg;
+ ecex_color_t status_border;
+
+ ecex_color_t cursor;
+ ecex_color_t region_bg;
+ ecex_color_t minibuffer_bg;
+ ecex_color_t minibuffer_fg;
+
+ ecex_color_t completion_fg;
+ int completion_enabled;
+
+ ecex_color_t interactive_highlight_bg;
+ ecex_color_t interactive_highlight_fg;
+ ecex_color_t current_line_bg;
+ ecex_color_t search_bg;
+ int line_numbers_enabled;
+ int current_line_enabled;
+} ecex_theme_t;
+
+struct buffer {
+ char *name;
+ char *path;
+
+ char *data;
+ size_t len;
+ size_t cap;
+
+ size_t point;
+ size_t mark;
+ int mark_active;
+
+ size_t scroll_line;
+ size_t scroll_col;
+
+ int modified;
+ int read_only;
+
+ int major_mode;
+
+ ecex_undo_entry_t *undo_stack;
+ size_t undo_count;
+ size_t undo_cap;
+ ecex_undo_entry_t *redo_stack;
+ size_t redo_count;
+ size_t redo_cap;
+ int undo_disabled;
+
+ int interactive;
+ struct ecex_interactive_line_action *interactive_actions;
+ size_t interactive_action_cap;
+ size_t interactive_action_count;
+};
+
+typedef struct ecex_interactive_line_action {
+ size_t line;
+ ecex_interactive_line_fn fn;
+ char *payload;
+ void *userdata;
+} ecex_interactive_line_action_t;
+
+typedef struct ecex_command {
+ char *name;
+ ecex_command_fn fn;
+} ecex_command_t;
+
+typedef struct ecex_keybind {
+ char *key;
+ char *command;
+} ecex_keybind_t;
+
+typedef struct ecex_mode_keybind {
+ int mode;
+ char *key;
+ char *command;
+} ecex_mode_keybind_t;
+
+typedef struct ecex_major_mode {
+ int id;
+ char *name;
+} ecex_major_mode_t;
+
+struct ecex_window {
+ buffer_t *buffer;
+ float x;
+ float y;
+ float w;
+ float h;
+};
+
+struct ecex {
+ buffer_t **buffers;
+ size_t buffer_cap;
+ size_t buffer_count;
+
+ size_t current_buffer_index;
+ buffer_t *current_buffer;
+
+ ecex_window_t *windows;
+ size_t window_cap;
+ size_t window_count;
+ size_t current_window_index;
+
+ void **jit_modules;
+ size_t jit_module_cap;
+ size_t jit_module_count;
+
+ ecex_command_t *commands;
+ size_t command_cap;
+ size_t command_count;
+
+ ecex_keybind_t *keybinds;
+ size_t keybind_cap;
+ size_t keybind_count;
+
+ ecex_mode_keybind_t *mode_keybinds;
+ size_t mode_keybind_cap;
+ size_t mode_keybind_count;
+
+ ecex_major_mode_t *major_modes;
+ size_t major_mode_cap;
+ size_t major_mode_count;
+ int next_major_mode_id;
+
+ char *last_eval_source;
+ char *last_eval_filename;
+ int last_eval_wrap_as_statements;
+
+ char *last_compile_command;
+ char *last_grep_command;
+
+ ecex_prompt_request_t prompt_request;
+ char prompt_message[128];
+
+ char *config_path;
+
+ ecex_clipboard_get_fn clipboard_get;
+ ecex_clipboard_set_fn clipboard_set;
+ void *clipboard_userdata;
+
+ int should_quit;
+
+ ecex_theme_t theme;
+};
+
+#endif