diff --git a/src/text_editor/buffer.cpp b/src/text_editor/buffer.cpp index 28d6553..e6fb356 100644 --- a/src/text_editor/buffer.cpp +++ b/src/text_editor/buffer.cpp @@ -131,7 +131,6 @@ Cursor ChangeFront(Cursor cursor, int64_t front) { void AddEdit(Array *edits, Range range, String string) { edits->add({range, string}); } -// SortKey = range.min bool InBounds(const Buffer &buffer, int64_t pos) { bool result = pos >= 0 && pos < buffer.len; diff --git a/src/text_editor/main.cpp b/src/text_editor/main.cpp index c518a49..d89f465 100644 --- a/src/text_editor/main.cpp +++ b/src/text_editor/main.cpp @@ -191,6 +191,8 @@ int main() { windows.add(window); } + // @todo: multiple ui elements, add focus + // @todo: immediate mode interface for all this Vec2 camera_offset_world_to_render_units = {}; while (!WindowShouldClose()) { For(windows) { @@ -211,6 +213,7 @@ int main() { focused_window->scroll.y -= mouse_wheel; focused_window->scroll.y = ClampBottom(focused_window->scroll.y, 0.f); + BeforeEdit(focused_window); // Merge cursors if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_A)) { focused_window->cursors.clear(); focused_window->cursors.add(MakeCursor(0, focused_window->buffer.len)); @@ -332,8 +335,8 @@ int main() { } } } - BeforeEdit(focused_window); + // @todo: improve behaviour of all copy pasting if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_C)) { Array strings = {FrameArena}; For(focused_window->cursors) { @@ -354,7 +357,6 @@ int main() { ApplyEdits(&focused_window->buffer, edits); AfterEdit(focused_window, edits); } - if (IsKeyDown(KEY_LEFT_CONTROL) && (IsKeyPressed(KEY_X) || IsKeyPressedRepeat(KEY_X))) { // First, if there is no selection - select the entire line For(focused_window->cursors) { @@ -396,7 +398,9 @@ int main() { } } - // @todo: scrolling + if (IsKeyDown(KEY_LEFT_CONTROL) && (IsKeyPressed(KEY_D) || IsKeyPressedRepeat(KEY_D))) { + } + if (IsKeyPressed(KEY_DELETE) || IsKeyPressedRepeat(KEY_DELETE)) { if (IsKeyDown(KEY_LEFT_SHIFT)) { } @@ -558,7 +562,6 @@ int main() { Assert(rows.len); // @todo: x axis - // @tood: moving using mouse // Update the scroll based on first cursor if (!AreEqual(window.main_cursor_begin_frame, window.cursors[0])) { Vec2 rect_in_render_units = GetSize(window_text_rect_in_render_units_clamped_to_screen); @@ -591,7 +594,9 @@ int main() { // Mouse in text area { - // @todo: test for focus + // @todo: click twice to select word + // @tood: scrolling when selecting (Y and X) + // @todo: change cursors Vec2 mouse_in_render_units = GetMousePosition(); if (CheckCollisionPointRec(mouse_in_render_units, ToRectangle(window_text_rect_in_render_units_clamped_to_screen))) { ForItem(row, rows) {