UIMessagef

This commit is contained in:
krzosa
2025-12-29 10:33:50 +01:00
parent 1ae20a46b2
commit 35d68bda61

View File

@@ -158,15 +158,24 @@ void Appendf(View *view, const char *fmt, ...) {
Append(view, string, true);
}
void UIMessagef(const char *fmt, ...) {
Scratch scratch;
STRING_FORMAT(scratch, fmt, string);
BSet main = GetBSet(LastActiveLayoutWindowID);
JumpGarbageBuffer(&main);
NextActiveWindowID = main.window->id;
RawAppendf(main.buffer, "\n %S\n", string);
}
void ReportErrorf(const char *fmt, ...) {
Scratch scratch;
STRING_FORMAT(scratch, fmt, string);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error!", string.data, NULL);
View *view = GetView(NullViewID);
if (view) {
Appendf(view, "%S\n", string);
NextActiveWindowID = NullWindowID;
}
UIMessagef("%S", string);
}
void ReportConsolef(const char *fmt, ...) {
@@ -577,7 +586,7 @@ BSet Open(Window *window, String path, String meta, bool set_active = true) {
} else if (o.kind == OpenKind_Skip) {
return {};
} else {
ReportWarningf("Failed to open: %S", path);
ReportErrorf("Failed to open: %S", path);
}
return GetBSet(window);