From 2acf7fbb45cd095d250630bdb30e1d0543bc67eb Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Thu, 5 Feb 2026 17:14:00 +0100 Subject: [PATCH] Drop file working in proper window --- src/text_editor/event.cpp | 10 +++++--- src/text_editor/text_editor.cpp | 43 +++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/text_editor/event.cpp b/src/text_editor/event.cpp index 971c14c..1fe3391 100644 --- a/src/text_editor/event.cpp +++ b/src/text_editor/event.cpp @@ -450,10 +450,12 @@ Event TranslateSDLEvent(SDL_Event *input_event) { } break; case SDL_EVENT_DROP_FILE: { - event.kind = EVENT_DROP_FILE; - SDL_DropEvent &b = input_event->drop; - String string = b.data; - event.text = Intern(&GlobalInternTable, string).data; + event.kind = EVENT_DROP_FILE; + SDL_DropEvent &b = input_event->drop; + String string = b.data; + event.text = Intern(&GlobalInternTable, string).data; + event.xmouse = (int16_t)roundf(DPIScale * b.x); + event.ymouse = (int16_t)roundf(DPIScale * b.y); } break; default: { }; diff --git a/src/text_editor/text_editor.cpp b/src/text_editor/text_editor.cpp index 3ec46e8..445b614 100644 --- a/src/text_editor/text_editor.cpp +++ b/src/text_editor/text_editor.cpp @@ -1,3 +1,37 @@ +/* +- [ ] Cleanups + - [ ] Delta based scrolling!! + - [ ] Enable framerate? + - [x] When dragging a file into the editor, would be nice if the file opened in the window user dropped the file into. Not the active window. + - [ ] When 2 views of same buffer are open, the view with caret below the caret which modifies the view - starts moving and getting messed up + - [ ] Reduce number of created buffers to one per window, should be enough + - [ ] GetWindowZOrder to IterateWindowsInZOrder + - [ ] Rework history API, tagging modification blocks with carets? + - [ ] The lexing / parsing code for config / bindings appears sloppy would be nice to clean it up but I don't have any ideas +- [ ] Test BlockArena correctnsess - random allocations, writes and undos, try to crash + +- [ ] New error mechanism + - [ ] BeginLog EndLog, and then show all logs as a list in the UI thing +- [ ] Undo kinds (to enable history in fuzzy buffers) + - [ ] Add undo kind. Snapshot kind, so that history is possible in weird buffers without paying a huge memory cost. The idea is that we would store the exact buffer state to replace with, editor would just save history of first line etc. + +- [ ] Macros +- [ ] Regex + - [ ] ctags based indexing +- [ ] WordComplete + - [ ] Rewrite WordComplete to use CoroutineCreate, maybe try reducing globals to just the coroutine itself + - [ ] More bounded? seems like it might be problematic on a bigger project but so far it isn't (even for SDL or raddbg) +- [ ] Shell / terminal buffer plugin (keep the shell alive and talk with it) +- [ ] Directory Navigation + - [ ] Remake lister when files change on disk + - [ ] When saving apply all the modifications instead (like deleting files, renaming etc.) or maybe that's not even needed considering we are integrating shell commands +- [ ] OpenCode + - [ ] Hangs the editor on big files +- [ ] Open + - [ ] Way to bind "open" commands to keys from config + - [ ] Ability to access and set clipboard as well as affect selection in the open scripts + +*/ #define PLUGIN_PROFILER 1 #include "plugin_profiler.h" @@ -283,7 +317,7 @@ void OnCommand(Event event) { } // Set active window on click - if (MousePress()) { + if (MousePress() || event.kind == EVENT_DROP_FILE) { Vec2I mouse = MouseVec2I(); For(order) { if (!it->visible) { @@ -292,6 +326,9 @@ void OnCommand(Event event) { bool mouse_in_document = AreOverlapping(mouse, it->document_rect); if (mouse_in_document) { NextActiveWindowID = ActiveWindowID = it->id; + if (event.kind == EVENT_DROP_FILE) { + WindowOpenBufferView(it, event.text); + } break; } } @@ -429,10 +466,6 @@ void OnCommand(Event event) { } } - if (event.kind == EVENT_DROP_FILE) { - WindowOpenBufferView(active.window, event.text); - } - if (event.kind == EVENT_TEXT_INPUT) { String16 string16 = ToString16(scratch, event.text); Replace(active.view, string16);