diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 48 |
1 files changed, 43 insertions, 5 deletions
@@ -1,4 +1,5 @@ /* +- ctrl+9/0 to inc/dec number FUTURE FEATURES: - better undo chaining (dechain on backspace?) - font setting & support for multiple fonts to cover more characters @@ -16,11 +17,8 @@ FUTURE FEATURES: - TED_PLUGIN macro defined before including ted.h this can remove struct definitions to guarantee forwards compatibility - language dynamic registration -- keyboard macros - - ctrl+9/0 to inc/dec number would be useful here - - with macros we can really test performance of buffer_insert_text_at_pos, etc. (which should ideally be fast) +- with macros we can really test performance of buffer_insert_text_at_pos, etc. (which should ideally be fast) - manual.md -- auto-reload config even for %included files - LSP request timeout BUG REPORTS IM TO LAZY TO FILE (RIGHT NOW) - rust-analyzer: @@ -84,6 +82,7 @@ BUG REPORTS IM TO LAZY TO FILE (RIGHT NOW) #include "ide-highlights.c" #include "ide-usages.c" #include "command.c" +#include "macro.c" #include "config.c" #include "session.c" #include "lsp.c" @@ -637,6 +636,9 @@ int main(int argc, char **argv) { } } break; case SDL_MOUSEBUTTONDOWN: { + if (ted->recording_macro) + break; // ignore mouse input during macros + Uint32 button = event.button.button; u8 times = event.button.clicks; // number of clicks float x = (float)event.button.x, y = (float)event.button.y; @@ -694,6 +696,9 @@ int main(int argc, char **argv) { } } break; case SDL_MOUSEBUTTONUP: { + if (ted->recording_macro) + break; // ignore mouse input during macros + Uint8 button = event.button.button; if (button < arr_count(ted->nmouse_releases)) { vec2 pos = Vec2((float)event.button.x, (float)event.button.y); @@ -703,6 +708,9 @@ int main(int argc, char **argv) { } } break; case SDL_MOUSEMOTION: { + if (ted->recording_macro) + break; // ignore mouse input during macros + float x = (float)event.motion.x, y = (float)event.motion.y; if (ted->drag_buffer != ted->active_buffer) ted->drag_buffer = NULL; @@ -726,7 +734,14 @@ int main(int argc, char **argv) { // unfortunately, some key combinations like ctrl+minus still register as a "-" text input event && (key_modifier & ~KEY_MODIFIER_SHIFT) == 0) { // insert the text - buffer_insert_utf8_at_cursor(buffer, text); + { + CommandContext ctx = {0}; + CommandArgument arg = { + .number = 0, + .string = text + }; + command_execute_ex(ted, CMD_INSERT_TEXT, arg, ctx); + } // check for trigger character LSP *lsp = buffer_lsp(buffer); Settings *settings = buffer_settings(buffer); @@ -1065,6 +1080,28 @@ int main(int argc, char **argv) { } } + if (ted->recording_macro) { + Font *font_bold = ted->font_bold; + u32 bg_color = ted_active_color(ted, COLOR_ERROR_BG); + u32 color = ted_active_color(ted, COLOR_TEXT); + u8 padding = ted_active_settings(ted)->padding; + const char *text = "Recording macro..."; + vec2 size = text_get_size_vec2(font_bold, text); + Rect r = { + .pos = vec2_sub(Vec2(window_width - 3 * padding, window_height - 3 * padding), size), + .size = vec2_add(size, Vec2(padding, padding)), + }; + gl_geometry_rect(r, bg_color); + Rect full_screen = { + .pos = {0, 0}, + .size = {window_width, window_height} + }; + gl_geometry_rect(full_screen, bg_color & 0xffffff0f); + text_utf8_anchored(font_bold, text, window_width - 2.5f * padding, window_height - 2.5f * padding, color, ANCHOR_BOTTOM_RIGHT); + gl_geometry_draw(); + text_render(font_bold); + } + ted_check_for_node_problems(ted); #if !NDEBUG @@ -1174,6 +1211,7 @@ int main(int argc, char **argv) { text_font_free(ted->font); text_font_free(ted->font_bold); config_free(ted); + macros_free(ted); free(ted); #if _WIN32 for (int i = 0; i < argc; ++i) |