diff options
| author | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2026-05-11 15:07:55 -0500 |
|---|---|---|
| committer | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2026-05-11 15:07:55 -0500 |
| commit | cebb280fe546190e55e071b6adbf37cd47950f34 (patch) | |
| tree | 6e7a7605f8832b1c1bd7e467884a8792a5e1fab4 /src/core/editor.h | |
initial commit
Diffstat (limited to 'src/core/editor.h')
| -rw-r--r-- | src/core/editor.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/core/editor.h b/src/core/editor.h new file mode 100644 index 0000000..5388197 --- /dev/null +++ b/src/core/editor.h @@ -0,0 +1,96 @@ +#ifndef LEMACS_EDITOR_H +#define LEMACS_EDITOR_H + +#include <stdbool.h> +#include <stdint.h> + +#include "core/buffer.h" + +#define LEMACS_MAX_AUX_BUFFERS 8 +#define LEMACS_MAX_VIEWS 16 +#define LEMACS_MAX_BUFFERS 32 + +#define LEMACS_CURSOR_BAR 0 +#define LEMACS_CURSOR_BLOCK 1 +#define LEMACS_CURSOR_UNDERLINE 2 + +typedef struct { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; +} EditorColor; + +typedef struct { + int x; + int y; + int width; + int height; + int source_type; + int source_index; + bool show_cursor; + EditorColor bg; + EditorColor fg; +} EditorView; + +typedef struct { + Buffer buffers[LEMACS_MAX_BUFFERS]; + int buffer_count; + int current_buffer; + Buffer aux_buffers[LEMACS_MAX_AUX_BUFFERS]; + int aux_buffer_count; + int desired_col; + int scroll_line; + char font_query[256]; + bool font_dirty; + EditorView views[LEMACS_MAX_VIEWS]; + int view_count; + EditorColor bg_top; + EditorColor bg_bottom; + EditorColor text; + EditorColor cursor; + int cursor_shape; + int cursor_thickness; + bool should_quit; +} Editor; + +bool editor_init(Editor *editor); +void editor_free(Editor *editor); + +void editor_set_font_query(Editor *editor, const char *query); +const char *editor_font_query(const Editor *editor); +bool editor_consume_font_dirty(Editor *editor); +bool editor_set_theme_color(Editor *editor, const char *name, int r, int g, int b, int a); +bool editor_set_cursor_shape(Editor *editor, int shape); +void editor_set_cursor_thickness(Editor *editor, int thickness); +int editor_cursor_shape(const Editor *editor); +int editor_cursor_thickness(const Editor *editor); + +int editor_aux_buffer_new(Editor *editor); +bool editor_aux_buffer_set_text(Editor *editor, int aux_index, const char *text); +Buffer *editor_aux_buffer_get(Editor *editor, int aux_index); + +void editor_layout_reset(Editor *editor); +bool editor_layout_add_view(Editor *editor, int source_type, int source_index, int x, int y, int width, int height, bool show_cursor, EditorColor bg, EditorColor fg); + +void editor_move_left(Editor *editor); +void editor_move_right(Editor *editor); +void editor_move_up(Editor *editor); +void editor_move_down(Editor *editor); +void editor_move_beginning_of_line(Editor *editor); +void editor_move_end_of_line(Editor *editor); +void editor_set_point(Editor *editor, size_t point); +char editor_char_at(const Editor *editor, size_t index); + +bool editor_open_file(Editor *editor, const char *path); +bool editor_save_file(Editor *editor, const char *path); +Buffer *editor_current_buffer(Editor *editor); +const Buffer *editor_current_buffer_const(const Editor *editor); +int editor_buffer_count(const Editor *editor); +int editor_current_buffer_index(const Editor *editor); +bool editor_switch_buffer(Editor *editor, int index); +int editor_new_buffer(Editor *editor); +const char *editor_buffer_path_at(const Editor *editor, int index); +bool editor_buffer_modified_at(const Editor *editor, int index); + +#endif |
