diff --git a/src/event.cpp b/src/event.cpp index 1fe3391..a714f52 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -487,6 +487,7 @@ void GetEventsForFrame(Array *events) { For (EventPlayback) { Add(events, it); } + EventPlayback.len = 0; SDL_Event event; if (WaitForEventsState) { diff --git a/src/plugin_record_events.cpp b/src/plugin_record_events.cpp index ecbe78f..dfdca25 100644 --- a/src/plugin_record_events.cpp +++ b/src/plugin_record_events.cpp @@ -64,3 +64,7 @@ void Serialize(Buffer *buffer, Event *e) { #undef X SerializeEnd(buffer); } + +void CMD_CopyEvents() { + SaveStringInClipboard(GetString(EventBuffer)); +} RegisterCommand(CMD_CopyEvents, "ctrl-shift-alt-j", "Copy all the events from the EventBuffer"); \ No newline at end of file diff --git a/src/plugin_tests.cpp b/src/plugin_tests.cpp new file mode 100644 index 0000000..3cf7fc0 --- /dev/null +++ b/src/plugin_tests.cpp @@ -0,0 +1,40 @@ +bool Testing = true; + +void Wait(mco_coro *co) { + Add(&EventPlayback, {EVENT_KIND_INVALID}); + for (Event *event = Yield(co); event->kind != EVENT_KIND_INVALID; event = Yield(co)) { + } +} + +void CO_FirstTest(mco_coro *co) { + Testing = true; + WaitForEvents = false; + {Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_RETURN; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_RETURN; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_RETURN; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_RETURN; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_RETURN; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_RETURN; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_RETURN; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_LSHIFT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.shift = 1; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.shift = 1; ev.text = "M"; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "e"; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "m"; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "e"; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "s"; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_SPACE; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = " "; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_LSHIFT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.shift = 1; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "a"; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "n"; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "d"; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_KEY_PRESS; ev.key = SDLK_SPACE; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = " "; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "s"; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "t"; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "u"; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "f"; Add(&EventPlayback, ev);} + {Event ev = {};ev.kind = EVENT_TEXT_INPUT; ev.xwindow = 1412; ev.ywindow = 1032; ev.xmouse = 1234; ev.ymouse = 594; ev.text = "f"; Add(&EventPlayback, ev);} + Wait(co); + +} RegisterCoroutineCommand(CO_FirstTest, "", "Basic tests"); diff --git a/src/text_editor.cpp b/src/text_editor.cpp index f2f2229..54ff0a5 100644 --- a/src/text_editor.cpp +++ b/src/text_editor.cpp @@ -1,9 +1,13 @@ /* +- [x] list_functions.sh and rg in general in the color mode is prinitng differently from terminal as well as output is truncated! +- [ ] Syntax for executing commands from root of project +- [ ] Fuzzy search over executed command ouput - [ ] When inserting parenthesis and selection is there, put the parens on both sides? - [ ] KillProcess in console !!! - should also kill all the children ........... -- [ ] ctrl-e with these short main.c:290: breaks a little, need to first click ctrl-e and then alt-e to jump +- [x] ctrl-e with these short main.c:290: breaks a little, need to first click ctrl-e and then alt-e to jump - [ ] Use command window without special fuzzy search features to type commands and stuff for executing shell etc.. +- [ ] Make a platform layer and separate SDL stuff out - [x] ReplaceAll - heap-use-after-free address, how to debug? I think would be nice to iterate all buffer ids and their addresses along with the state - [x] BRO, the caret teleports on linux when I press the arrow for too long @@ -126,6 +130,7 @@ #include "plugin_profiler.cpp" #include "plugin_file_commands.cpp" #include "plugin_word_complete.cpp" +#include "plugin_tests.cpp" #if OS_WASM EM_JS(void, JS_SetMouseCursor, (const char *cursor_str), { @@ -836,7 +841,7 @@ void MainLoop() { GetEventsForFrame(&FrameEvents); For (FrameEvents) { #if PLUGIN_RECORD_EVENTS - if (it.kind != EVENT_UPDATE) { + if (it.kind != EVENT_UPDATE && !Testing) { Serialize(EventBuffer, &it); } #endif @@ -1099,7 +1104,6 @@ int main(int argc, char **argv, char **envp) Open(argv[i]); } - // if (Testing) InitTests(); #if PLUGIN_LOAD_VCVARS LoadVCVars(); #endif