First prototype of coroutine based UI
This commit is contained in:
@@ -78,6 +78,7 @@ void SetMouseCursor(SDL_SystemCursor id) {
|
||||
#endif
|
||||
|
||||
void SetMouseCursor(Event event) {
|
||||
ProfileFunction();
|
||||
Scratch scratch;
|
||||
Array<Window *> order = GetWindowZOrder(scratch);
|
||||
Vec2I mouse = MouseVec2I();
|
||||
@@ -448,7 +449,6 @@ void EvalCommand(String16 command) {
|
||||
EvalCommand(ToString(scratch, command));
|
||||
}
|
||||
|
||||
|
||||
void GarbageCollect() {
|
||||
if (RunGCThisFrame == false) {
|
||||
return;
|
||||
@@ -475,7 +475,11 @@ void GarbageCollect() {
|
||||
InvalidCodepath();
|
||||
}
|
||||
|
||||
Buffer *buffer = GetBuffer(it->active_buffer);
|
||||
Buffer *buffer = GetBuffer(it->active_buffer, NULL);
|
||||
if (buffer == NULL || buffer->close) {
|
||||
it->close = true;
|
||||
}
|
||||
|
||||
if (!it->close) {
|
||||
if (!buffer->garbage) {
|
||||
continue;
|
||||
@@ -487,7 +491,7 @@ void GarbageCollect() {
|
||||
}
|
||||
}
|
||||
|
||||
RawAppendf(GCInfoBuffer, "View %d %S\n", (int)it->id.id, buffer->name);
|
||||
RawAppendf(GCInfoBuffer, "View %d %S\n", (int)it->id.id, buffer ? buffer->name : String{"NULL"});
|
||||
remove_item = true;
|
||||
Dealloc(it);
|
||||
}
|
||||
@@ -527,6 +531,11 @@ void GarbageCollect() {
|
||||
Dealloc(&it->goto_redo);
|
||||
Dealloc(sys_allocator, it);
|
||||
remove_item = true;
|
||||
} else {
|
||||
View *view = FindView(it->active_view, NULL);
|
||||
if (!view) {
|
||||
JumpToLastValidView(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -673,8 +682,17 @@ void MainLoop() {
|
||||
Update(it);
|
||||
}
|
||||
|
||||
|
||||
bool dont_wait_until_resolved = false;
|
||||
For (ActiveCoroutines) {
|
||||
if (it.dont_wait_until_resolved) {
|
||||
dont_wait_until_resolved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
WaitForEvents = ConfigWaitForEvents;
|
||||
if (IsDocumentSelectionValid() || IsScrollbarSelectionValid() || ActiveProcesses.len || ActiveCoroutines.len) {
|
||||
if (IsDocumentSelectionValid() || IsScrollbarSelectionValid() || ActiveProcesses.len || dont_wait_until_resolved) {
|
||||
WaitForEvents = false;
|
||||
}
|
||||
|
||||
@@ -847,7 +865,8 @@ int main(int argc, char **argv)
|
||||
ReportConsolef("WorkDir = %S", WorkDir);
|
||||
if (Testing) InitTests();
|
||||
#if OS_WINDOWS
|
||||
CoAdd(Windows_SetupVCVarsall);
|
||||
CoData *co_data = CoAdd(Windows_SetupVCVarsall);
|
||||
co_data->dont_wait_until_resolved = true;
|
||||
#endif
|
||||
#if OS_WASM
|
||||
emscripten_set_main_loop(MainLoop, 0, 1);
|
||||
|
||||
Reference in New Issue
Block a user