Drop file working in proper window

This commit is contained in:
Krzosa Karol
2026-02-05 17:14:00 +01:00
parent 36d39f9417
commit 2acf7fbb45
2 changed files with 44 additions and 9 deletions

View File

@@ -454,6 +454,8 @@ Event TranslateSDLEvent(SDL_Event *input_event) {
SDL_DropEvent &b = input_event->drop; SDL_DropEvent &b = input_event->drop;
String string = b.data; String string = b.data;
event.text = Intern(&GlobalInternTable, string).data; event.text = Intern(&GlobalInternTable, string).data;
event.xmouse = (int16_t)roundf(DPIScale * b.x);
event.ymouse = (int16_t)roundf(DPIScale * b.y);
} break; } break;
default: { default: {
}; };

View File

@@ -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 #define PLUGIN_PROFILER 1
#include "plugin_profiler.h" #include "plugin_profiler.h"
@@ -283,7 +317,7 @@ void OnCommand(Event event) {
} }
// Set active window on click // Set active window on click
if (MousePress()) { if (MousePress() || event.kind == EVENT_DROP_FILE) {
Vec2I mouse = MouseVec2I(); Vec2I mouse = MouseVec2I();
For(order) { For(order) {
if (!it->visible) { if (!it->visible) {
@@ -292,6 +326,9 @@ void OnCommand(Event event) {
bool mouse_in_document = AreOverlapping(mouse, it->document_rect); bool mouse_in_document = AreOverlapping(mouse, it->document_rect);
if (mouse_in_document) { if (mouse_in_document) {
NextActiveWindowID = ActiveWindowID = it->id; NextActiveWindowID = ActiveWindowID = it->id;
if (event.kind == EVENT_DROP_FILE) {
WindowOpenBufferView(it, event.text);
}
break; 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) { if (event.kind == EVENT_TEXT_INPUT) {
String16 string16 = ToString16(scratch, event.text); String16 string16 = ToString16(scratch, event.text);
Replace(active.view, string16); Replace(active.view, string16);