Implement Ctrl + D
This commit is contained in:
@@ -42,14 +42,17 @@ int main() {
|
|||||||
InitScratch();
|
InitScratch();
|
||||||
InitWindow(800, 600, "Hello");
|
InitWindow(800, 600, "Hello");
|
||||||
SetTargetFPS(60);
|
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(&FrameArena);
|
||||||
InitArena(&PermArena);
|
InitArena(&PermArena);
|
||||||
float font_size = 64;
|
float font_size = 64;
|
||||||
float font_spacing = 1;
|
float font_spacing = 1;
|
||||||
Font 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);
|
||||||
|
|
||||||
if (0) font = LoadFontEx("C:/Windows/Fonts/consola.ttf", (int)font_size, NULL, 250);
|
|
||||||
|
|
||||||
Array<Window> windows = {};
|
Array<Window> windows = {};
|
||||||
{
|
{
|
||||||
@@ -78,6 +81,7 @@ int main() {
|
|||||||
windows.add(window);
|
windows.add(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EnableEventWaiting();
|
||||||
InitEventRecording();
|
InitEventRecording();
|
||||||
while (!WindowShouldClose()) {
|
while (!WindowShouldClose()) {
|
||||||
For(windows) {
|
For(windows) {
|
||||||
@@ -99,6 +103,7 @@ int main() {
|
|||||||
focused_window->cursors.clear();
|
focused_window->cursors.clear();
|
||||||
focused_window->cursors.add(MakeCursor(0, focused_window->buffer.len));
|
focused_window->cursors.add(MakeCursor(0, focused_window->buffer.len));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_LEFT) || IsKeyPressedRepeat(KEY_LEFT)) {
|
if (IsKeyPressed(KEY_LEFT) || IsKeyPressedRepeat(KEY_LEFT)) {
|
||||||
For(focused_window->cursors) {
|
For(focused_window->cursors) {
|
||||||
if (IsKeyDown(KEY_LEFT_CONTROL)) {
|
if (IsKeyDown(KEY_LEFT_CONTROL)) {
|
||||||
@@ -124,6 +129,7 @@ int main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_RIGHT) || IsKeyPressedRepeat(KEY_RIGHT)) {
|
if (IsKeyPressed(KEY_RIGHT) || IsKeyPressedRepeat(KEY_RIGHT)) {
|
||||||
For(focused_window->cursors) {
|
For(focused_window->cursors) {
|
||||||
if (IsKeyDown(KEY_LEFT_CONTROL)) {
|
if (IsKeyDown(KEY_LEFT_CONTROL)) {
|
||||||
@@ -149,6 +155,7 @@ int main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_DOWN) || IsKeyPressedRepeat(KEY_DOWN)) {
|
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
|
if (IsKeyDown(KEY_LEFT_SHIFT) && IsKeyDown(KEY_LEFT_ALT)) { // Default in VSCode seems to be Ctrl + Alt + down
|
||||||
Array<Cursor> cursors_to_add = {FrameArena};
|
Array<Cursor> 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) {
|
For(focused_window->cursors) {
|
||||||
if (IsKeyPressed(KEY_HOME) || IsKeyPressedRepeat(KEY_HOME)) {
|
if (IsKeyPressed(KEY_HOME) || IsKeyPressedRepeat(KEY_HOME)) {
|
||||||
if (IsKeyDown(KEY_LEFT_SHIFT)) {
|
if (IsKeyDown(KEY_LEFT_SHIFT)) {
|
||||||
@@ -293,9 +311,6 @@ int main() {
|
|||||||
AfterEdit(focused_window, edits);
|
AfterEdit(focused_window, edits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyDown(KEY_LEFT_CONTROL) && (IsKeyPressed(KEY_D) || IsKeyPressedRepeat(KEY_D))) {
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_DELETE) || IsKeyPressedRepeat(KEY_DELETE)) {
|
if (IsKeyPressed(KEY_DELETE) || IsKeyPressedRepeat(KEY_DELETE)) {
|
||||||
if (IsKeyDown(KEY_LEFT_SHIFT)) {
|
if (IsKeyDown(KEY_LEFT_SHIFT)) {
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user