#ifndef ECEX_TYPES_H #define ECEX_TYPES_H #include typedef struct ecex ecex_t; typedef struct buffer buffer_t; typedef struct ecex_window ecex_window_t; typedef struct ecex_draw_context ecex_draw_context_t; typedef struct ecex_plugin_runtime ecex_plugin_runtime_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 int (*ecex_buffer_render_fn)(ecex_t *ed, buffer_t *buffer, ecex_draw_context_t *ctx, void *userdata); typedef int (*ecex_buffer_tick_fn)(ecex_t *ed, buffer_t *buffer, double now_seconds, void *userdata); typedef int (*ecex_buffer_tick_ms_fn)(ecex_t *ed, buffer_t *buffer, int now_ms, void *userdata); typedef int (*ecex_buffer_mouse_fn)(ecex_t *ed, buffer_t *buffer, int event, int x, int y, int button, void *userdata); typedef int (*ecex_file_handler_fn)(ecex_t *ed, buffer_t *buffer); typedef void (*ecex_buffer_userdata_free_fn)(void *userdata); typedef void (*ecex_hook_free_fn)(void *userdata); typedef void (*ecex_command_hook_fn)(ecex_t *ed, const char *command, int event, int result, void *userdata); typedef void (*ecex_prefix_hook_fn)(ecex_t *ed, const char *prefix, int event, void *userdata); typedef void (*ecex_buffer_hook_fn)(ecex_t *ed, buffer_t *buffer, int event, void *userdata); typedef void (*ecex_log_sink_fn)(const char *line, int depth, void *userdata); typedef int (*ecex_completion_provider_fn)(ecex_t *ed, buffer_t *buffer, const char *prefix, char *out, size_t out_size, void *userdata); typedef enum ecex_command_hook_event { ECEX_COMMAND_HOOK_BEFORE = 1, ECEX_COMMAND_HOOK_AFTER = 2, } ecex_command_hook_event_t; typedef enum ecex_prefix_hook_event { ECEX_PREFIX_HOOK_BEGIN = 1, ECEX_PREFIX_HOOK_UPDATE = 2, ECEX_PREFIX_HOOK_CANCEL = 3, ECEX_PREFIX_HOOK_FINISH = 4, ECEX_PREFIX_HOOK_UNDEFINED = 5, } ecex_prefix_hook_event_t; typedef enum ecex_buffer_hook_event { ECEX_BUFFER_HOOK_CREATE = 1, ECEX_BUFFER_HOOK_SWITCH = 2, ECEX_BUFFER_HOOK_SAVE = 3, ECEX_BUFFER_HOOK_KILL = 4, ECEX_BUFFER_HOOK_MODE_CHANGE = 5, } ecex_buffer_hook_event_t; 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_FORCE_KILL_BUFFER, ECEX_PROMPT_COMPILE, ECEX_PROMPT_GREP, ECEX_PROMPT_ISEARCH_FORWARD, ECEX_PROMPT_ISEARCH_BACKWARD, } ecex_prompt_request_t; #define ECEX_RENDER_OVERLAY 0 #define ECEX_RENDER_REPLACE_CONTENT 1 #define ECEX_MOUSE_MOVE 0 #define ECEX_MOUSE_PRESS 1 #define ECEX_MOUSE_RELEASE 2 #define ECEX_MOUSE_DRAG 3 #define ECEX_MOUSE_BUTTON_LEFT 0 #define ECEX_MOUSE_BUTTON_RIGHT 1 #define ECEX_MOUSE_BUTTON_MIDDLE 2 typedef enum ecex_draw_text_align { ECEX_TEXT_ALIGN_LEFT = 0, ECEX_TEXT_ALIGN_CENTER = 1, ECEX_TEXT_ALIGN_RIGHT = 2, } ecex_draw_text_align_t; struct ecex_draw_context { float x; float y; float w; float h; float content_x; float content_y; float content_w; float content_h; float font_size; float line_height; float char_width; size_t window_index; int active; void *internal; }; 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; int media_kind; char *media_path; int media_width; int media_height; unsigned char *media_pixels; int media_dirty; unsigned int media_texture; int media_texture_width; int media_texture_height; void *media_pipe; double media_last_frame_time; int media_playing; int media_audio_pid; char media_status[256]; ecex_buffer_render_fn render_fn; void *render_userdata; ecex_buffer_userdata_free_fn render_userdata_free; int render_flags; ecex_buffer_mouse_fn mouse_fn; void *mouse_userdata; ecex_buffer_userdata_free_fn mouse_userdata_free; ecex_buffer_tick_fn tick_fn; ecex_buffer_tick_ms_fn tick_ms_fn; void *tick_userdata; ecex_buffer_userdata_free_fn tick_userdata_free; double tick_interval; double tick_last_time; int tick_enabled; int tick_uses_ms; }; 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_command_hook { char *name; ecex_command_hook_fn fn; void *userdata; ecex_hook_free_fn free_fn; } ecex_command_hook_t; typedef struct ecex_prefix_hook { char *name; ecex_prefix_hook_fn fn; void *userdata; ecex_hook_free_fn free_fn; } ecex_prefix_hook_t; typedef struct ecex_buffer_hook { char *name; ecex_buffer_hook_fn fn; void *userdata; ecex_hook_free_fn free_fn; } ecex_buffer_hook_t; typedef struct ecex_completion_provider { char *name; int mode; ecex_completion_provider_fn fn; void *userdata; ecex_hook_free_fn free_fn; char *detail; char **words; char **word_details; size_t word_count; int flags; } ecex_completion_provider_t; typedef struct ecex_major_mode { int id; char *name; } ecex_major_mode_t; typedef struct ecex_eval_module { char *key; void *module; } ecex_eval_module_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; buffer_t *previous_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_command_hook_t *command_hooks; size_t command_hook_cap; size_t command_hook_count; ecex_prefix_hook_t *prefix_hooks; size_t prefix_hook_cap; size_t prefix_hook_count; ecex_buffer_hook_t *buffer_hooks; size_t buffer_hook_cap; size_t buffer_hook_count; ecex_completion_provider_t *completion_providers; size_t completion_provider_cap; size_t completion_provider_count; int completion_cycle_active; buffer_t *completion_cycle_buffer; size_t completion_cycle_start; size_t completion_cycle_index; char completion_cycle_prefix[256]; char completion_cycle_current[256]; ecex_major_mode_t *major_modes; size_t major_mode_cap; size_t major_mode_count; int next_major_mode_id; ecex_plugin_runtime_t *plugins; buffer_t *messages_buffer; int messages_append_active; char *last_eval_source; char *last_eval_filename; int last_eval_wrap_as_statements; ecex_eval_module_t *eval_modules; size_t eval_module_cap; size_t eval_module_count; char *last_compile_command; char *last_grep_command; ecex_prompt_request_t prompt_request; char prompt_message[128]; char *config_path; char message[1024]; unsigned long message_revision; ecex_clipboard_get_fn clipboard_get; ecex_clipboard_set_fn clipboard_set; void *clipboard_userdata; char *clipboard_text; int should_quit; unsigned long ui_revision; unsigned long font_revision; ecex_theme_t theme; }; #endif