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) {
|
static void compilerErrorHandler(void *opaque, const char *msg) {
|
||||||
(void)opaque;
|
(void)opaque;
|
||||||
|
|
||||||
|
//***TODO*** Use the error list from results.c
|
||||||
message(strstr(msg, " warning: ") == NULL ? MSG_ERROR : MSG_WARN, "%s", msg);
|
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) {
|
gboolean compilerHadError(CompilerContextT **context) {
|
||||||
CompilerContextT *c = *context;
|
CompilerContextT *c = *context;
|
||||||
|
|
||||||
|
//***TODO*** Use the error list from results.c
|
||||||
if (c->compilerResult != COMPILER_ERROR_NONE) {
|
if (c->compilerResult != COMPILER_ERROR_NONE) {
|
||||||
// Handle errors not handled elsewhere.
|
// Handle errors not handled elsewhere.
|
||||||
switch (c->compilerResult) {
|
switch (c->compilerResult) {
|
||||||
|
|
115
src/results.c
115
src/results.c
|
@ -33,6 +33,7 @@ typedef struct ResultsDataS {
|
||||||
WindowDataT windowData;
|
WindowDataT windowData;
|
||||||
ProjectDataT *project;
|
ProjectDataT *project;
|
||||||
GtkWidget *gridResults;
|
GtkWidget *gridResults;
|
||||||
|
GtkWidget *pressedButton;
|
||||||
GtkWidget *notebookResults;
|
GtkWidget *notebookResults;
|
||||||
GtkWidget *lstDebug;
|
GtkWidget *lstDebug;
|
||||||
GtkWidget *lstRelease;
|
GtkWidget *lstRelease;
|
||||||
|
@ -46,19 +47,23 @@ static ResultsDataT **_resultWindows = NULL;
|
||||||
|
|
||||||
EVENT void resultClicked(GtkButton *widget, gpointer userData);
|
EVENT void resultClicked(GtkButton *widget, gpointer userData);
|
||||||
static void resultLoadRaw(gboolean release, int target, int arch, ResultsDataT *self);
|
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);
|
static void resultsUpdate(ResultsDataT *self);
|
||||||
EVENT gboolean winBuildResultsClose(GtkWidget *object, gpointer userData);
|
EVENT gboolean winBuildResultsClose(GtkWidget *object, gpointer userData);
|
||||||
static void winBuildResultsDelete(gpointer userData);
|
static void winBuildResultsDelete(gpointer userData);
|
||||||
|
|
||||||
|
|
||||||
EVENT void resultClicked(GtkButton *widget, gpointer userData) {
|
EVENT void resultClicked(GtkButton *widget, gpointer userData) {
|
||||||
const char *name = gtk_widget_get_name(GTK_WIDGET(widget));
|
ResultsDataT *self = (ResultsDataT *)userData;
|
||||||
int t;
|
const char *name = gtk_widget_get_name(GTK_WIDGET(widget));
|
||||||
int a;
|
int t;
|
||||||
gboolean r;
|
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.
|
// Extract button info from widget name.
|
||||||
r = (name[0] == 'r');
|
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) {
|
static void resultLoadRaw(gboolean release, int target, int arch, ResultsDataT *self) {
|
||||||
FILE *in;
|
FILE *in;
|
||||||
char *temp;
|
char *temp;
|
||||||
char *line = NULL;
|
|
||||||
size_t len = 0;
|
|
||||||
TargetT *t;
|
TargetT *t;
|
||||||
|
char *line = NULL;
|
||||||
|
size_t len = 0;
|
||||||
|
char **lineArray = NULL;
|
||||||
|
|
||||||
// Clear existing contents.
|
// Clear existing contents.
|
||||||
utilClearContainer(GTK_CONTAINER(release ? self->lstRelease : self->lstDebug));
|
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) {
|
while (utilGetLine(&line, &len, in) != -1) {
|
||||||
if (strlen(line) > 0) line[strlen(line) - 1] = 0;
|
if (strlen(line) > 0) line[strlen(line) - 1] = 0;
|
||||||
utilAddTextToListBox(GTK_LIST_BOX(release ? self->lstRawRelease : self->lstRawDebug), line, FALSE);
|
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);
|
fclose(in);
|
||||||
|
@ -98,55 +104,71 @@ static void resultLoadRaw(gboolean release, int target, int arch, ResultsDataT *
|
||||||
}
|
}
|
||||||
DEL(temp);
|
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.
|
// Display appropriate tab.
|
||||||
gtk_notebook_set_current_page(GTK_NOTEBOOK(self->notebookResults), release ? 1 : 0);
|
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 *messages;
|
||||||
GtkWidget *row;
|
GtkWidget *row;
|
||||||
GtkWidget *box;
|
GtkWidget *box;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
|
int i;
|
||||||
char *temp;
|
char *temp;
|
||||||
char *text = NULL;
|
char *text;
|
||||||
gboolean isWarning = FALSE;
|
gboolean isWarning;
|
||||||
|
|
||||||
messages = release ? self->lstRelease : self->lstDebug;
|
messages = release ? self->lstRelease : self->lstDebug;
|
||||||
|
|
||||||
// ***TODO*** This is going to need to be a lot more complicated.
|
for (i=0; i<arrlen(lineArray); i++) {
|
||||||
// We need the line number and filename from multiple compilers.
|
text = NULL;
|
||||||
if (strstr(line, " warning: ") != NULL) {
|
isWarning = FALSE;
|
||||||
text = line;
|
|
||||||
isWarning = TRUE;
|
|
||||||
}
|
|
||||||
if (strstr(line, " error: ") != NULL) {
|
|
||||||
text = line;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (text) {
|
// ***TODO*** This is going to need to be a lot more complicated.
|
||||||
// New listbox row.
|
// We need the line number and filename from multiple compilers.
|
||||||
row = gtk_list_box_row_new();
|
if (strstr(lineArray[i], " warning: ") != NULL) {
|
||||||
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
|
text = lineArray[i];
|
||||||
gtk_widget_set_hexpand(box, TRUE);
|
isWarning = TRUE;
|
||||||
|
}
|
||||||
|
if (strstr(lineArray[i], " error: ") != NULL) {
|
||||||
|
text = lineArray[i];
|
||||||
|
}
|
||||||
|
|
||||||
// Icon button.
|
if (text) {
|
||||||
button = gtk_button_new_from_icon_name(isWarning ? "dialog-warning" : "dialog-error", GTK_ICON_SIZE_BUTTON);
|
// New listbox row.
|
||||||
temp = utilCreateString("%c", isWarning ? 'w' : 'e'); // We store data about this button in its name.
|
row = gtk_list_box_row_new();
|
||||||
gtk_widget_set_name(button, temp);
|
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
|
||||||
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
|
gtk_widget_set_hexpand(box, TRUE);
|
||||||
DEL(temp);
|
|
||||||
|
|
||||||
// Message.
|
// Icon button.
|
||||||
label = gtk_label_new(text);
|
button = gtk_button_new_from_icon_name(isWarning ? "dialog-warning" : "dialog-error", GTK_ICON_SIZE_BUTTON);
|
||||||
gtk_label_set_use_markup(GTK_LABEL(label), FALSE);
|
temp = utilCreateString("%c", isWarning ? 'w' : 'e'); // We store data about this button in its name.
|
||||||
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
|
gtk_widget_set_name(button, temp);
|
||||||
|
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
|
||||||
|
DEL(temp);
|
||||||
|
|
||||||
// Add to list.
|
// Message.
|
||||||
gtk_container_add(GTK_CONTAINER(row), box);
|
label = gtk_label_new(text);
|
||||||
gtk_list_box_insert(GTK_LIST_BOX(messages), row, -1);
|
gtk_label_set_use_markup(GTK_LABEL(label), FALSE);
|
||||||
gtk_widget_show_all(GTK_WIDGET(messages));
|
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++) {
|
for (j=0; j<arrlen(t->archs); j++) {
|
||||||
if (t->archs[j]->selected) {
|
if (t->archs[j]->selected) {
|
||||||
|
|
||||||
if (firstSystem < 0) {
|
|
||||||
firstSystem = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add to grid. Name.
|
// Add to grid. Name.
|
||||||
w = gtk_label_new(t->longName);
|
w = gtk_label_new(t->longName);
|
||||||
gtk_label_set_line_wrap(GTK_LABEL(w), FALSE);
|
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);
|
gtk_grid_attach(GTK_GRID(self->gridResults), w, 3, gridLine, 1, 1);
|
||||||
g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(resultClicked), self);
|
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!
|
// Next result!
|
||||||
gridLine++;
|
gridLine++;
|
||||||
}
|
}
|
||||||
|
@ -240,7 +265,7 @@ static void resultsUpdate(ResultsDataT *self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Did we load anything?
|
// Did we load anything?
|
||||||
if (gridLine > 0) {
|
if (firstSystem >= 0) {
|
||||||
resultLoadRaw(FALSE, firstSystem, 0, self);
|
resultLoadRaw(FALSE, firstSystem, 0, self);
|
||||||
resultLoadRaw(TRUE, firstSystem, 0, self);
|
resultLoadRaw(TRUE, firstSystem, 0, self);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue