diff --git a/src/main.cpp b/src/main.cpp index 5f1cdb1..28a786f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4203,19 +4203,41 @@ static void show_build_result(const std::string& title, r.ok ? std::string("Build succeeded.\nExecutable: ") + r.exe_path + "\n\n" : std::string("Build FAILED.\n\n"); - // Keep the dialog readable: show the tail of the log. + // Show the full log: the text view scrolls, so a long build log is + // fully visible instead of only its tail. std::string log = r.output; - if (log.size() > 6000) log = "[…]\n" + log.substr(log.size() - 6000); GtkWidget* view = gtk_text_view_new(); gtk_text_view_set_editable(GTK_TEXT_VIEW(view), FALSE); gtk_text_view_set_monospace(GTK_TEXT_VIEW(view), TRUE); + // Wrap long lines (cmake command lines) so the whole log is readable + // without horizontal scrolling. + gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_CHAR); GtkTextBuffer* buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)); gtk_text_buffer_set_text(buf, (head + log).c_str(), -1); GtkWidget* scroll = gtk_scrolled_window_new(nullptr, nullptr); gtk_container_add(GTK_CONTAINER(scroll), view); - gtk_container_add( - GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dlg))), scroll); + // Pack expanding: gtk_container_add() on the dialog's GtkBox packs + // with expand=FALSE, which left the log area at its ~2-line natural + // height pinned to the top of the dialog and wasted the rest of the + // window. Pack with expand+fill so the log fills the dialog. + gtk_box_pack_start( + GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dlg))), scroll, + TRUE, TRUE, 0); gtk_widget_show_all(dlg); + // Failures land at the end of the log: start scrolled there so the + // error is visible immediately; the user can scroll up for the rest. + // Do it in an idle callback, not right after show_all: scrolling + // before the dialog is realized/allocated computes against the + // not-yet-final size and lands a few lines short of the true end. + // The idle runs inside gtk_dialog_run's loop, after allocation. + g_idle_add([](gpointer data) -> gboolean { + GtkTextView* v = GTK_TEXT_VIEW(data); + GtkTextBuffer* b = gtk_text_view_get_buffer(v); + GtkTextIter end; + gtk_text_buffer_get_end_iter(b, &end); + gtk_text_view_scroll_to_iter(v, &end, 0.0, FALSE, 0.0, 0.0); + return FALSE; + }, view); gtk_dialog_run(GTK_DIALOG(dlg)); gtk_widget_destroy(dlg); }