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.
This commit is contained in:
parent
75a9d5aa98
commit
0d50e3bc83
2 changed files with 72 additions and 45 deletions
|
@ -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) {
|
||||
|
|
115
src/results.c
115
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; i<arrlen(lineArray); i++) {
|
||||
text = NULL;
|
||||
isWarning = FALSE;
|
||||
|
||||
if (text) {
|
||||
// New listbox row.
|
||||
row = gtk_list_box_row_new();
|
||||
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
gtk_widget_set_hexpand(box, TRUE);
|
||||
// ***TODO*** This is going to need to be a lot more complicated.
|
||||
// We need the line number and filename from multiple compilers.
|
||||
if (strstr(lineArray[i], " warning: ") != NULL) {
|
||||
text = lineArray[i];
|
||||
isWarning = TRUE;
|
||||
}
|
||||
if (strstr(lineArray[i], " error: ") != NULL) {
|
||||
text = lineArray[i];
|
||||
}
|
||||
|
||||
// Icon button.
|
||||
button = gtk_button_new_from_icon_name(isWarning ? "dialog-warning" : "dialog-error", GTK_ICON_SIZE_BUTTON);
|
||||
temp = utilCreateString("%c", isWarning ? 'w' : 'e'); // We store data about this button in its name.
|
||||
gtk_widget_set_name(button, temp);
|
||||
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
|
||||
DEL(temp);
|
||||
if (text) {
|
||||
// New listbox row.
|
||||
row = gtk_list_box_row_new();
|
||||
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
gtk_widget_set_hexpand(box, TRUE);
|
||||
|
||||
// Message.
|
||||
label = gtk_label_new(text);
|
||||
gtk_label_set_use_markup(GTK_LABEL(label), FALSE);
|
||||
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
|
||||
// Icon button.
|
||||
button = gtk_button_new_from_icon_name(isWarning ? "dialog-warning" : "dialog-error", GTK_ICON_SIZE_BUTTON);
|
||||
temp = utilCreateString("%c", isWarning ? 'w' : 'e'); // We store data about this button in its name.
|
||||
gtk_widget_set_name(button, temp);
|
||||
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
|
||||
DEL(temp);
|
||||
|
||||
// Add to list.
|
||||
gtk_container_add(GTK_CONTAINER(row), box);
|
||||
gtk_list_box_insert(GTK_LIST_BOX(messages), row, -1);
|
||||
gtk_widget_show_all(GTK_WIDGET(messages));
|
||||
// Message.
|
||||
label = gtk_label_new(text);
|
||||
gtk_label_set_use_markup(GTK_LABEL(label), FALSE);
|
||||
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
|
||||
|
||||
// Add to list.
|
||||
gtk_container_add(GTK_CONTAINER(row), box);
|
||||
gtk_list_box_insert(GTK_LIST_BOX(messages), row, -1);
|
||||
gtk_widget_show_all(GTK_WIDGET(messages));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,10 +198,6 @@ static void resultsUpdate(ResultsDataT *self) {
|
|||
for (j=0; j<arrlen(t->archs); 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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue