Reporting errors, set active to console

This commit is contained in:
Krzosa Karol
2024-12-02 08:35:15 +01:00
parent f1e674ca37
commit ed9ec06eee

View File

@@ -177,6 +177,21 @@ void ReportErrorf(const char *fmt, ...) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error!", string.data, NULL);
View *view = GetView(NullViewID);
Command_Append(view, string, true);
// Set console view as active
{
Window *w = GetWindowWithView(NullViewID);
if (!w) {
BSet bset = GetActiveMainSet();
w = GetNextLayoutWindow(bset.window);
Buffer *b = GetBuffer(NullBufferID);
CheckpointBeforeGoto(w);
WindowOpenBufferView(w, b->name);
}
ActiveWindow = w->id;
}
}
void ReportConsolef(const char *fmt, ...) {
@@ -191,6 +206,21 @@ void ReportWarningf(const char *fmt, ...) {
STRING_FORMAT(scratch, fmt, string);
View *null_view = GetView(NullViewID);
Command_Append(null_view, string, true);
// Set console view as active
{
Window *w = GetWindowWithView(NullViewID);
if (!w) {
BSet bset = GetActiveMainSet();
w = GetNextLayoutWindow(bset.window);
Buffer *b = GetBuffer(NullBufferID);
CheckpointBeforeGoto(w);
WindowOpenBufferView(w, b->name);
}
ActiveWindow = w->id;
}
}
void Command_MoveCursorsByPageSize(Window *window, int direction, bool shift = false) {