diff options
author | pommicket <pommicket@gmail.com> | 2023-01-02 00:09:07 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-01-02 00:09:07 -0500 |
commit | 43b8a9cb106d50265f5a6c1307e77d4642710f07 (patch) | |
tree | 88059ba86e957031047577622ecce52d72113e03 /ted.h | |
parent | 20ac640a6d0b8eb6343709ae6ef921b41a31a726 (diff) |
restructure buffer.c
Diffstat (limited to 'ted.h')
-rw-r--r-- | ted.h | 139 |
1 files changed, 139 insertions, 0 deletions
@@ -2,6 +2,7 @@ #define TED_H_ #include "util.h" +#include "unicode.h" #include "ds.h" #include "lsp.h" #include "base.h" @@ -592,6 +593,144 @@ typedef struct Ted { char error_shown[512]; // error display in box on screen } Ted; +// === buffer.c === +bool buffer_haserr(TextBuffer *buffer); +const char *buffer_geterr(TextBuffer *buffer); +void buffer_clearerr(TextBuffer *buffer); +bool buffer_empty(TextBuffer *buffer); +const char *buffer_get_filename(TextBuffer *buffer); +bool buffer_is_untitled(TextBuffer *buffer); +bool buffer_is_named_file(TextBuffer *buffer); +void buffer_create(TextBuffer *buffer, Ted *ted); +void line_buffer_create(TextBuffer *buffer, Ted *ted); +bool buffer_unsaved_changes(TextBuffer *buffer); +char32_t buffer_char_at_pos(TextBuffer *buffer, BufferPos p); +char32_t buffer_char_before_pos(TextBuffer *buffer, BufferPos pos); +char32_t buffer_char_after_pos(TextBuffer *buffer, BufferPos pos); +char32_t buffer_char_before_cursor(TextBuffer *buffer); +char32_t buffer_char_after_cursor(TextBuffer *buffer); +BufferPos buffer_pos_start_of_file(TextBuffer *buffer); +BufferPos buffer_pos_end_of_file(TextBuffer *buffer); +Language buffer_language(TextBuffer *buffer); +LSP *buffer_lsp(TextBuffer *buffer); +Settings *buffer_settings(TextBuffer *buffer); +size_t buffer_get_text_at_pos(TextBuffer *buffer, BufferPos pos, char32_t *text, size_t nchars); +String32 buffer_get_str32_text_at_pos(TextBuffer *buffer, BufferPos pos, size_t nchars); +char *buffer_get_utf8_text_at_pos(TextBuffer *buffer, BufferPos pos, size_t nchars); +size_t buffer_contents_utf8(TextBuffer *buffer, char *out); +char *buffer_contents_utf8_alloc(TextBuffer *buffer); +void buffer_check_valid(TextBuffer *buffer); +void buffer_check_valid(TextBuffer *buffer); +void buffer_free(TextBuffer *buffer); +void buffer_clear(TextBuffer *buffer); +void buffer_text_dimensions(TextBuffer *buffer, u32 *lines, u32 *columns); +float buffer_display_lines(TextBuffer *buffer); +float buffer_display_cols(TextBuffer *buffer); +void buffer_scroll(TextBuffer *buffer, double dx, double dy); +v2 buffer_pos_to_pixels(TextBuffer *buffer, BufferPos pos); +bool buffer_pixels_to_pos(TextBuffer *buffer, v2 pixel_coords, BufferPos *pos); +void buffer_scroll_to_pos(TextBuffer *buffer, BufferPos pos); +void buffer_scroll_center_pos(TextBuffer *buffer, BufferPos pos); +void buffer_scroll_to_cursor(TextBuffer *buffer); +void buffer_center_cursor(TextBuffer *buffer); +i64 buffer_pos_move_horizontally(TextBuffer *buffer, BufferPos *p, i64 by); +i64 buffer_pos_move_vertically(TextBuffer *buffer, BufferPos *pos, i64 by); +i64 buffer_pos_move_left(TextBuffer *buffer, BufferPos *pos, i64 by); +i64 buffer_pos_move_right(TextBuffer *buffer, BufferPos *pos, i64 by); +i64 buffer_pos_move_up(TextBuffer *buffer, BufferPos *pos, i64 by); +i64 buffer_pos_move_down(TextBuffer *buffer, BufferPos *pos, i64 by); +void buffer_cursor_move_to_pos(TextBuffer *buffer, BufferPos pos); +i64 buffer_cursor_move_left(TextBuffer *buffer, i64 by); +i64 buffer_cursor_move_right(TextBuffer *buffer, i64 by); +i64 buffer_cursor_move_up(TextBuffer *buffer, i64 by); +i64 buffer_cursor_move_down(TextBuffer *buffer, i64 by); +i64 buffer_pos_move_words(TextBuffer *buffer, BufferPos *pos, i64 nwords); +i64 buffer_pos_move_left_words(TextBuffer *buffer, BufferPos *pos, i64 nwords); +i64 buffer_pos_move_right_words(TextBuffer *buffer, BufferPos *pos, i64 nwords); +i64 buffer_cursor_move_left_words(TextBuffer *buffer, i64 nwords); +i64 buffer_cursor_move_right_words(TextBuffer *buffer, i64 nwords); +String32 buffer_word_at_pos(TextBuffer *buffer, BufferPos pos); +String32 buffer_word_at_cursor(TextBuffer *buffer); +char *buffer_word_at_cursor_utf8(TextBuffer *buffer); +BufferPos buffer_pos_start_of_line(TextBuffer *buffer, u32 line); +BufferPos buffer_pos_end_of_line(TextBuffer *buffer, u32 line); +void buffer_cursor_move_to_start_of_line(TextBuffer *buffer); +void buffer_cursor_move_to_end_of_line(TextBuffer *buffer); +void buffer_cursor_move_to_start_of_file(TextBuffer *buffer); +void buffer_cursor_move_to_end_of_file(TextBuffer *buffer); +LSPDocumentID buffer_lsp_document_id(TextBuffer *buffer); +LSPPosition buffer_pos_to_lsp_position(TextBuffer *buffer, BufferPos pos); +LSPDocumentPosition buffer_pos_to_lsp_document_position(TextBuffer *buffer, BufferPos pos); +BufferPos buffer_pos_from_lsp(TextBuffer *buffer, LSPPosition lsp_pos); +LSPPosition buffer_cursor_pos_as_lsp_position(TextBuffer *buffer); +LSPDocumentPosition buffer_cursor_pos_as_lsp_document_position(TextBuffer *buffer); +BufferPos buffer_insert_text_at_pos(TextBuffer *buffer, BufferPos pos, String32 str); +void buffer_insert_char_at_pos(TextBuffer *buffer, BufferPos pos, char32_t c); +void buffer_select_to_pos(TextBuffer *buffer, BufferPos pos); +void buffer_select_left(TextBuffer *buffer, i64 nchars); +void buffer_select_right(TextBuffer *buffer, i64 nchars); +void buffer_select_down(TextBuffer *buffer, i64 nchars); +void buffer_select_up(TextBuffer *buffer, i64 nchars); +void buffer_select_left_words(TextBuffer *buffer, i64 nwords); +void buffer_select_right_words(TextBuffer *buffer, i64 nwords); +void buffer_select_to_start_of_line(TextBuffer *buffer); +void buffer_select_to_end_of_line(TextBuffer *buffer); +void buffer_select_to_start_of_file(TextBuffer *buffer); +void buffer_select_to_end_of_file(TextBuffer *buffer); +void buffer_select_word(TextBuffer *buffer); +void buffer_select_line(TextBuffer *buffer); +void buffer_select_all(TextBuffer *buffer); +void buffer_disable_selection(TextBuffer *buffer); +void buffer_page_up(TextBuffer *buffer, i64 npages); +void buffer_page_down(TextBuffer *buffer, i64 npages); +void buffer_select_page_up(TextBuffer *buffer, i64 npages); +void buffer_select_page_down(TextBuffer *buffer, i64 npages); +void buffer_delete_chars_at_pos(TextBuffer *buffer, BufferPos pos, i64 nchars_); +i64 buffer_delete_chars_between(TextBuffer *buffer, BufferPos p1, BufferPos p2); +i64 buffer_delete_selection(TextBuffer *buffer); +void buffer_insert_text_at_cursor(TextBuffer *buffer, String32 str); +void buffer_insert_char_at_cursor(TextBuffer *buffer, char32_t c); +void buffer_insert_utf8_at_cursor(TextBuffer *buffer, const char *utf8); +void buffer_insert_tab_at_cursor(TextBuffer *buffer); +void buffer_newline(TextBuffer *buffer); +void buffer_delete_chars_at_cursor(TextBuffer *buffer, i64 nchars); +i64 buffer_backspace_at_pos(TextBuffer *buffer, BufferPos *pos, i64 ntimes); +i64 buffer_backspace_at_cursor(TextBuffer *buffer, i64 ntimes); +void buffer_delete_words_at_pos(TextBuffer *buffer, BufferPos pos, i64 nwords); +void buffer_delete_words_at_cursor(TextBuffer *buffer, i64 nwords); +void buffer_backspace_words_at_pos(TextBuffer *buffer, BufferPos *pos, i64 nwords); +void buffer_backspace_words_at_cursor(TextBuffer *buffer, i64 nwords); +void buffer_undo(TextBuffer *buffer, i64 ntimes); +void buffer_redo(TextBuffer *buffer, i64 ntimes); +void buffer_start_edit_chain(TextBuffer *buffer); +void buffer_end_edit_chain(TextBuffer *buffer); +void buffer_copy_or_cut(TextBuffer *buffer, bool cut); +void buffer_copy(TextBuffer *buffer); +void buffer_cut(TextBuffer *buffer); +void buffer_paste(TextBuffer *buffer); +Status buffer_load_file(TextBuffer *buffer, const char *filename); +void buffer_reload(TextBuffer *buffer); +bool buffer_externally_changed(TextBuffer *buffer); +void buffer_new_file(TextBuffer *buffer, const char *filename); +bool buffer_save(TextBuffer *buffer); +bool buffer_save_as(TextBuffer *buffer, const char *new_filename); +u32 buffer_first_rendered_line(TextBuffer *buffer); +u32 buffer_last_rendered_line(TextBuffer *buffer); +void buffer_goto_word_at_cursor(TextBuffer *buffer); +bool buffer_handle_click(Ted *ted, TextBuffer *buffer, v2 click, u8 times); +void buffer_render(TextBuffer *buffer, Rect r); +void buffer_indent_lines(TextBuffer *buffer, u32 first_line, u32 last_line); +void buffer_dedent_lines(TextBuffer *buffer, u32 first_line, u32 last_line); +void buffer_indent_selection(TextBuffer *buffer); +void buffer_dedent_selection(TextBuffer *buffer); +void buffer_indent_cursor_line(TextBuffer *buffer); +void buffer_dedent_cursor_line(TextBuffer *buffer); +void buffer_comment_lines(TextBuffer *buffer, u32 first_line, u32 last_line); +void buffer_uncomment_lines(TextBuffer *buffer, u32 first_line, u32 last_line); +void buffer_toggle_comment_lines(TextBuffer *buffer, u32 first_line, u32 last_line); +void buffer_toggle_comment_selection(TextBuffer *buffer); +// make sure to call gl_geometry_draw after this +void buffer_highlight_lsp_range(TextBuffer *buffer, LSPRange range); // === colors.c === ColorSetting color_setting_from_str(const char *str); const char *color_setting_to_str(ColorSetting s); |