diff --git a/src/text_editor/main.cpp b/src/text_editor/main.cpp index 6408337..9d05c96 100644 --- a/src/text_editor/main.cpp +++ b/src/text_editor/main.cpp @@ -42,14 +42,17 @@ int main() { InitScratch(); InitWindow(800, 600, "Hello"); SetTargetFPS(60); + { + uint32_t data = 0xffdddddd; + Image window_icon_image = {(void *)&data, 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8}; + SetWindowIcon(window_icon_image); + } InitArena(&FrameArena); InitArena(&PermArena); float font_size = 64; float font_spacing = 1; - Font font = LoadFontEx("C:/Windows/Fonts/consola.ttf", (int)font_size, NULL, 250); - - if (0) font = LoadFontEx("C:/Windows/Fonts/consola.ttf", (int)font_size, NULL, 250); + Font font = LoadFontEx("C:/Windows/Fonts/times.ttf", (int)font_size, NULL, 250); Array windows = {}; { @@ -78,6 +81,7 @@ int main() { windows.add(window); } + // EnableEventWaiting(); InitEventRecording(); while (!WindowShouldClose()) { For(windows) { @@ -99,6 +103,7 @@ int main() { focused_window->cursors.clear(); focused_window->cursors.add(MakeCursor(0, focused_window->buffer.len)); } + if (IsKeyPressed(KEY_LEFT) || IsKeyPressedRepeat(KEY_LEFT)) { For(focused_window->cursors) { if (IsKeyDown(KEY_LEFT_CONTROL)) { @@ -124,6 +129,7 @@ int main() { } } } + if (IsKeyPressed(KEY_RIGHT) || IsKeyPressedRepeat(KEY_RIGHT)) { For(focused_window->cursors) { if (IsKeyDown(KEY_LEFT_CONTROL)) { @@ -149,6 +155,7 @@ int main() { } } } + if (IsKeyPressed(KEY_DOWN) || IsKeyPressedRepeat(KEY_DOWN)) { if (IsKeyDown(KEY_LEFT_SHIFT) && IsKeyDown(KEY_LEFT_ALT)) { // Default in VSCode seems to be Ctrl + Alt + down Array cursors_to_add = {FrameArena}; @@ -223,6 +230,17 @@ int main() { } } + if (IsKeyDown(KEY_LEFT_CONTROL) && (IsKeyPressed(KEY_D) || IsKeyPressedRepeat(KEY_D))) { + Cursor cursor = *focused_window->cursors.last(); + String needle = GetString(focused_window->buffer, cursor.range); + String to_seek = GetString(focused_window->buffer, {cursor.range.max, INT64_MAX}); + int64_t found_index = 0; + if (Seek(to_seek, needle, &found_index, SeekFlag_IgnoreCase)) { + found_index += cursor.range.max; + focused_window->cursors.add(MakeCursor(found_index + needle.len, found_index)); + } + } + For(focused_window->cursors) { if (IsKeyPressed(KEY_HOME) || IsKeyPressedRepeat(KEY_HOME)) { if (IsKeyDown(KEY_LEFT_SHIFT)) { @@ -293,9 +311,6 @@ int main() { AfterEdit(focused_window, edits); } - if (IsKeyDown(KEY_LEFT_CONTROL) && (IsKeyPressed(KEY_D) || IsKeyPressedRepeat(KEY_D))) { - } - if (IsKeyPressed(KEY_DELETE) || IsKeyPressedRepeat(KEY_DELETE)) { if (IsKeyDown(KEY_LEFT_SHIFT)) { }