ded

Dramatic EDitor
Index Commits Files Refs README LICENSE
src/editor.h (1590B)
   1 #ifndef EDITOR_H_
   2 #define EDITOR_H_
   3 
   4 #include <stdlib.h>
   5 #include "common.h"
   6 #include "free_glyph.h"
   7 #include "simple_renderer.h"
   8 #include "lexer.h"
   9 
  10 #include <SDL2/SDL.h>
  11 
  12 typedef struct {
  13     size_t begin;
  14     size_t end;
  15 } Line;
  16 
  17 typedef struct {
  18     Line *items;
  19     size_t count;
  20     size_t capacity;
  21 } Lines;
  22 
  23 typedef struct {
  24     Token *items;
  25     size_t count;
  26     size_t capacity;
  27 } Tokens;
  28 
  29 typedef struct {
  30     Free_Glyph_Atlas *atlas;
  31 
  32     String_Builder data;
  33     Lines lines;
  34     Tokens tokens;
  35     String_Builder file_path;
  36 
  37     bool selection;
  38     size_t select_begin;
  39     size_t cursor;
  40 
  41     Uint32 last_stroke;
  42 
  43     String_Builder clipboard;
  44 } Editor;
  45 
  46 Errno editor_save_as(Editor *editor, const char *file_path);
  47 Errno editor_save(const Editor *editor);
  48 Errno editor_load_from_file(Editor *editor, const char *file_path);
  49 
  50 void editor_backspace(Editor *editor);
  51 void editor_delete(Editor *editor);
  52 size_t editor_cursor_row(const Editor *e);
  53 void editor_move_line_up(Editor *e);
  54 void editor_move_line_down(Editor *e);
  55 void editor_move_char_left(Editor *e);
  56 void editor_move_char_right(Editor *e);
  57 void editor_move_word_left(Editor *e);
  58 void editor_move_word_right(Editor *e);
  59 void editor_insert_char(Editor *e, char x);
  60 void editor_insert_buf(Editor *e, char *buf, size_t buf_len);
  61 void editor_retokenize(Editor *e);
  62 void editor_render(SDL_Window *window, Free_Glyph_Atlas *atlas, Simple_Renderer *sr, Editor *editor);
  63 void editor_update_selection(Editor *e, bool shift);
  64 void editor_clipboard_copy(Editor *e);
  65 void editor_clipboard_paste(Editor *e);
  66 
  67 #endif // EDITOR_H_