From 0d50e3bc838acf427eab57efca8e8fc45cc158c5 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Wed, 24 May 2023 18:02:34 -0500 Subject: [PATCH] Warning and error parsing can now look backwards at previous lines for information. Button of selected view in the results grid is now left pressed. --- src/compiler.c | 2 + src/results.c | 115 ++++++++++++++++++++++++++++++------------------- 2 files changed, 72 insertions(+), 45 deletions(-) diff --git a/src/compiler.c b/src/compiler.c index 58595f0..45fe05e 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -60,6 +60,7 @@ void compilerDeleteContext(CompilerContextT **context) { static void compilerErrorHandler(void *opaque, const char *msg) { (void)opaque; + //***TODO*** Use the error list from results.c message(strstr(msg, " warning: ") == NULL ? MSG_ERROR : MSG_WARN, "%s", msg); } @@ -67,6 +68,7 @@ static void compilerErrorHandler(void *opaque, const char *msg) { gboolean compilerHadError(CompilerContextT **context) { CompilerContextT *c = *context; + //***TODO*** Use the error list from results.c if (c->compilerResult != COMPILER_ERROR_NONE) { // Handle errors not handled elsewhere. switch (c->compilerResult) { diff --git a/src/results.c b/src/results.c index 89203e3..1f45041 100644 --- a/src/results.c +++ b/src/results.c @@ -33,6 +33,7 @@ typedef struct ResultsDataS { WindowDataT windowData; ProjectDataT *project; GtkWidget *gridResults; + GtkWidget *pressedButton; GtkWidget *notebookResults; GtkWidget *lstDebug; GtkWidget *lstRelease; @@ -46,19 +47,23 @@ static ResultsDataT **_resultWindows = NULL; EVENT void resultClicked(GtkButton *widget, gpointer userData); static void resultLoadRaw(gboolean release, int target, int arch, ResultsDataT *self); -static void resultParseRaw(gboolean release, char *line, ResultsDataT *self); +static void resultParseRaw(gboolean release, char **lineArray, ResultsDataT *self); static void resultsUpdate(ResultsDataT *self); EVENT gboolean winBuildResultsClose(GtkWidget *object, gpointer userData); static void winBuildResultsDelete(gpointer userData); EVENT void resultClicked(GtkButton *widget, gpointer userData) { - const char *name = gtk_widget_get_name(GTK_WIDGET(widget)); - int t; - int a; - gboolean r; + ResultsDataT *self = (ResultsDataT *)userData; + const char *name = gtk_widget_get_name(GTK_WIDGET(widget)); + int t; + int a; + gboolean r; - // ***TODO*** Highlight the button somehow so we know what we're viewing. + // Highlight the button pressed button. + gtk_button_set_relief(widget, GTK_RELIEF_NONE); + gtk_button_set_relief(GTK_BUTTON(self->pressedButton), GTK_RELIEF_NORMAL); + self->pressedButton = GTK_WIDGET(widget); // Extract button info from widget name. r = (name[0] == 'r'); @@ -72,9 +77,10 @@ EVENT void resultClicked(GtkButton *widget, gpointer userData) { static void resultLoadRaw(gboolean release, int target, int arch, ResultsDataT *self) { FILE *in; char *temp; - char *line = NULL; - size_t len = 0; TargetT *t; + char *line = NULL; + size_t len = 0; + char **lineArray = NULL; // Clear existing contents. utilClearContainer(GTK_CONTAINER(release ? self->lstRelease : self->lstDebug)); @@ -90,7 +96,7 @@ static void resultLoadRaw(gboolean release, int target, int arch, ResultsDataT * while (utilGetLine(&line, &len, in) != -1) { if (strlen(line) > 0) line[strlen(line) - 1] = 0; utilAddTextToListBox(GTK_LIST_BOX(release ? self->lstRawRelease : self->lstRawDebug), line, FALSE); - resultParseRaw(release, line, self); + arrput(lineArray, strdup(line)); // We put everything into an array so we can "rewind" later to previous lines. } } fclose(in); @@ -98,55 +104,71 @@ static void resultLoadRaw(gboolean release, int target, int arch, ResultsDataT * } DEL(temp); + // Parse it for warnings and errors. + resultParseRaw(release, lineArray, self); + + // Clear array. + while (arrlen(lineArray) > 0) { + DEL(lineArray[0]); + arrdel(lineArray, 0); + } + //ARRFREE(lineArray); + // Display appropriate tab. gtk_notebook_set_current_page(GTK_NOTEBOOK(self->notebookResults), release ? 1 : 0); } -static void resultParseRaw(gboolean release, char *line, ResultsDataT *self) { +static void resultParseRaw(gboolean release, char **lineArray, ResultsDataT *self) { GtkWidget *messages; GtkWidget *row; GtkWidget *box; GtkWidget *label; GtkWidget *button; + int i; char *temp; - char *text = NULL; - gboolean isWarning = FALSE; + char *text; + gboolean isWarning; messages = release ? self->lstRelease : self->lstDebug; - // ***TODO*** This is going to need to be a lot more complicated. - // We need the line number and filename from multiple compilers. - if (strstr(line, " warning: ") != NULL) { - text = line; - isWarning = TRUE; - } - if (strstr(line, " error: ") != NULL) { - text = line; - } + for (i=0; iarchs); j++) { if (t->archs[j]->selected) { - if (firstSystem < 0) { - firstSystem = i; - } - // Add to grid. Name. w = gtk_label_new(t->longName); gtk_label_set_line_wrap(GTK_LABEL(w), FALSE); @@ -233,6 +251,13 @@ static void resultsUpdate(ResultsDataT *self) { gtk_grid_attach(GTK_GRID(self->gridResults), w, 3, gridLine, 1, 1); g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(resultClicked), self); + if (firstSystem < 0) { + firstSystem = i; + // Highlight the button pressed button. + gtk_button_set_relief(GTK_BUTTON(w), GTK_RELIEF_NONE); + self->pressedButton = w; + } + // Next result! gridLine++; } @@ -240,7 +265,7 @@ static void resultsUpdate(ResultsDataT *self) { } // Did we load anything? - if (gridLine > 0) { + if (firstSystem >= 0) { resultLoadRaw(FALSE, firstSystem, 0, self); resultLoadRaw(TRUE, firstSystem, 0, self); }