Prototyping QueryUserFile

This commit is contained in:
Krzosa Karol
2026-01-17 13:22:33 +01:00
parent 37cb6248a5
commit 76e279920f
2 changed files with 27 additions and 8 deletions

View File

@@ -2,6 +2,7 @@
// Instead of toying with Reopen maybe it should actually detect changes in directory etc. on update
void CMD_OpenUpFolder() {
// @todo: Test this for weird cases
BSet main = GetBSet(PrimaryWindowID);
String name = ChopLastSlash(main.buffer->name);
Open(name);

View File

@@ -73,19 +73,37 @@ void ShowUIMessagef(const char *fmt, ...) {
}
String QueryUserFile(mco_coro *co) {
// @todo: how to make it so that it doesn't open the file?
#if PLUGIN_DIRECTORY_NAVIGATION
Open(GetPrimaryDirectory());
Window *window = GetWindow(PrimaryWindowID);
String filename = "";
for (;;) {
BSet main = GetBSet(window);
if ((main.window->id != PrimaryWindowID && main.window->id != ActiveWindowID) || main.window->close) {
break;
}
if (!main.buffer->is_dir) {
filename = main.buffer->name;
break;
}
CoYield(co);
}
return filename;
#else
// Just simple query
// @todo: do we want to split like this? The plugin is maybe leaking too much?
// @todo: String QueryUserString(mco_coro *co)
#endif
return "todo";
}
void Coro_TestQueryFile(mco_coro *co) {
void CO_TestQueryFile(mco_coro *co) {
String file = QueryUserFile(co);
ReportConsolef("%S", file);
}
void CMD_TestQueryFile() {
CoRemove("Coro_TestQueryFile");
CoData *data = CoAdd(Coro_TestQueryFile);
CoResume(data);
} RegisterCommand(CMD_TestQueryFile, "", "");
} RegisterCoroutineCommand(CO_TestQueryFile, "", "");
void MouseLoadWord(Event event, ResolveOpenMeta meta = ResolveOpenMeta_Normal) {
Vec2I mouse = MouseVec2I();