Several parsing bug fixes. Toolbar with custom icons started.
This commit is contained in:
parent
1d0a565e05
commit
b0f3204748
13 changed files with 282 additions and 49 deletions
|
@ -55,7 +55,7 @@ static int parserGetWord(char *wordList, char **tokenEnd);
|
|||
static gboolean parserGetX(char **tokenEnd, char ***variables, int *x);
|
||||
static gboolean parserGetXY(char **tokenEnd, char ***variables, int *x, int *y);
|
||||
static gboolean parserGetXYZ(char **tokenEnd, char ***variables, int *x, int *y, int *z);
|
||||
static int variableCollect(char *value, char ***variables);
|
||||
static gboolean variableCollect(char *value, char ***variables, int *result);
|
||||
|
||||
|
||||
static int labelGetValue(int lineNumber, VecByteCodeT *bytecode, LabelT *labels, LabelT ***unresolved, char *label) {
|
||||
|
@ -145,9 +145,7 @@ static gboolean parserGetNextValue(char *token, char **valueEnd, char ***variabl
|
|||
value = strtok_r(token, ",", valueEnd);
|
||||
if (value == NULL) return FALSE;
|
||||
|
||||
*x = variableCollect(value, variables);
|
||||
|
||||
return TRUE;
|
||||
return variableCollect(value, variables, x);;
|
||||
}
|
||||
|
||||
|
||||
|
@ -183,9 +181,7 @@ static gboolean parserGetX(char **tokenEnd, char ***variables, int *x) {
|
|||
value = strtok_r(NULL, " ", tokenEnd);
|
||||
if (value == NULL) return FALSE;
|
||||
|
||||
*x = variableCollect(value, variables);
|
||||
|
||||
return TRUE;
|
||||
return variableCollect(value, variables, x);
|
||||
}
|
||||
|
||||
|
||||
|
@ -222,7 +218,7 @@ static gboolean parserGetXYZ(char **tokenEnd, char ***variables, int *x, int *y,
|
|||
}
|
||||
|
||||
|
||||
static int variableCollect(char *value, char ***variables) {
|
||||
static gboolean variableCollect(char *value, char ***variables, int *result) {
|
||||
int index;
|
||||
int found;
|
||||
char *endPtr = NULL;
|
||||
|
@ -263,7 +259,9 @@ static int variableCollect(char *value, char ***variables) {
|
|||
|
||||
}
|
||||
|
||||
return found;
|
||||
*result = found;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -685,32 +683,35 @@ int vecparser(char *programIn, VecByteCodeT *bytecode) {
|
|||
} // read program line
|
||||
|
||||
// Resolve forward label declarations and patch bytecode.
|
||||
if (lineOkay) {
|
||||
#ifdef DEBUG
|
||||
for (y1=0; y1<shlen(labels); y1++) {
|
||||
debug("Resolved - %s\n", labels[y1].key);
|
||||
}
|
||||
for (y1=0; y1<arrlen(unresolved); y1++) {
|
||||
debug("Unresolved - %s\n", unresolved[y1]->key);
|
||||
}
|
||||
#endif
|
||||
for (y1=0; y1<arrlen(unresolved); y1++) {
|
||||
// Find offset of this unresolved label. We search ourselves so it's case-insensitive.
|
||||
x2 = -1;
|
||||
for (x1 = 0; x1 < shlen(labels); x1++) {
|
||||
debug("Checking label %d of %d - %s == %s\n", y1, (int)arrlen(unresolved), unresolved[y1]->key, labels[x1].key);
|
||||
if (strcasecmp(unresolved[y1]->key, labels[x1].key) == 0) {
|
||||
x2 = x1;
|
||||
break;
|
||||
}
|
||||
for (y1 = 0; y1 < shlen(labels); y1++) {
|
||||
debug("Resolved - %s\n", labels[y1].key);
|
||||
}
|
||||
if (x2 < 0) {
|
||||
// Label not found! Error!
|
||||
result = unresolved[y1]->line;
|
||||
break;
|
||||
} else {
|
||||
// Write this label offset into the unresolved offset.
|
||||
bytecode->bytes[unresolved[y1]->value++] = (labels[x2].value & 0xFF00) >> 8;
|
||||
bytecode->bytes[unresolved[y1]->value] = labels[x2].value & 0x00FF;
|
||||
for (y1 = 0; y1 < arrlen(unresolved); y1++) {
|
||||
debug("Unresolved - %s\n", unresolved[y1]->key);
|
||||
}
|
||||
#endif
|
||||
for (y1 = 0; y1 < arrlen(unresolved); y1++) {
|
||||
// Find offset of this unresolved label. We search ourselves so it's case-insensitive.
|
||||
x2 = -1;
|
||||
for (x1 = 0; x1 < shlen(labels); x1++) {
|
||||
debug("Checking label %d of %d - %s == %s\n", y1, (int)arrlen(unresolved), unresolved[y1]->key,
|
||||
labels[x1].key);
|
||||
if (strcasecmp(unresolved[y1]->key, labels[x1].key) == 0) {
|
||||
x2 = x1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (x2 < 0) {
|
||||
// Label not found! Error!
|
||||
result = unresolved[y1]->line;
|
||||
break;
|
||||
} else {
|
||||
// Write this label offset into the unresolved offset.
|
||||
bytecode->bytes[unresolved[y1]->value++] = (labels[x2].value & 0xFF00) >> 8;
|
||||
bytecode->bytes[unresolved[y1]->value] = labels[x2].value & 0x00FF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
71
src/vector.c
71
src/vector.c
|
@ -78,7 +78,7 @@ static int _nextEditorId = 0;
|
|||
static int byte(VectorDataT *self, unsigned char byte);
|
||||
EVENT void drawVectorImageClick(GtkWidget *object, GdkEventButton *event, gpointer userData);
|
||||
EVENT gboolean drawVectorImageDraw(GtkWidget *widget, cairo_t *cr, gpointer userData);
|
||||
EVENT gboolean drawVectorImageMotionEvent(GtkWidget* widget, GdkEventMotion* event, gpointer userData);
|
||||
EVENT gboolean drawVectorImageMotionEvent(GtkWidget *widget, GdkEventMotion *event, gpointer userData);
|
||||
EVENT void editorVectorNotify(GtkWidget *sciWidget, gint ctrlID, struct SCNotification *notifyData, gpointer userData);
|
||||
EVENT void fileVectorTraceImageFileSet(GtkWidget *object, gpointer userData);
|
||||
static int getWord(VecByteCodeT *bytecode, int *index);
|
||||
|
@ -96,6 +96,13 @@ EVENT void menuVectorHelpVector(GtkWidget *object, gpointer userData);
|
|||
static void renderBytecode(VecByteCodeT *bytecode, VectorDataT *self);
|
||||
EVENT void scaleVectorTraceImageValueChanged(GtkWidget *object, gpointer userData);
|
||||
static void setDirty(VectorDataT *self, gboolean dirty);
|
||||
EVENT void toolBoxClicked(GtkToolButton *object, gpointer user_data);
|
||||
EVENT void toolCircleClicked(GtkToolButton *object, gpointer user_data);
|
||||
EVENT void toolEllipseClicked(GtkToolButton *object, gpointer user_data);
|
||||
EVENT void toolFillClicked(GtkToolButton *object, gpointer user_data);
|
||||
EVENT void toolLineClicked(GtkToolButton *object, gpointer user_data);
|
||||
EVENT void toolPlotClicked(GtkToolButton *object, gpointer user_data);
|
||||
EVENT void toolRectangleClicked(GtkToolButton *object, gpointer user_data);
|
||||
static float variable(VectorDataT *self, unsigned char byte);
|
||||
static int word(VectorDataT *self, unsigned short word);
|
||||
EVENT gboolean winVectorClose(GtkWidget *object, gpointer userData);
|
||||
|
@ -220,6 +227,11 @@ EVENT gboolean drawVectorImageMotionEvent(GtkWidget *widget, GdkEventMotion *eve
|
|||
SSM(SCI_SETSEL, temp, temp + strlen(buffer));
|
||||
// If they're holding the button down, update the point.
|
||||
if (event->state & GDK_BUTTON1_MASK) {
|
||||
// Are these values sane?
|
||||
if (x < 0) x = 0;
|
||||
if (x > 319) x = 319;
|
||||
if (y < 0) y = 0;
|
||||
if (y > 199) y = 199;
|
||||
snprintf(buffer, 8, "%d,%d", x, y);
|
||||
SSM(SCI_REPLACETARGET, -1, (sptr_t)buffer);
|
||||
}
|
||||
|
@ -647,7 +659,7 @@ static void renderBytecode(VecByteCodeT *bytecode, VectorDataT *self) {
|
|||
x2 = word(self, GET_WORD);
|
||||
y2 = word(self, GET_WORD);
|
||||
debug("Box %d,%d to %d,%d\n", x1, y1, x2, y2);
|
||||
jlDrawBox(self->jlc, x1, y1, x2, y2);
|
||||
jlDrawBoxFilled(self->jlc, x1, y1, x2, y2);
|
||||
ADD_POINT(x1, y1);
|
||||
ADD_POINT(x2, y2);
|
||||
break;
|
||||
|
@ -891,7 +903,7 @@ static void renderBytecode(VecByteCodeT *bytecode, VectorDataT *self) {
|
|||
x2 = word(self, GET_WORD);
|
||||
y2 = word(self, GET_WORD);
|
||||
debug("Rectangle %d,%d to %d,%d\n", x1, y1, x2, y2);
|
||||
jlDrawBoxFilled(self->jlc, x1, y1, x2, y2);
|
||||
jlDrawBox(self->jlc, x1, y1, x2, y2);
|
||||
ADD_POINT(x1, y1);
|
||||
ADD_POINT(x2, y2);
|
||||
break;
|
||||
|
@ -968,6 +980,41 @@ static void setDirty(VectorDataT *self, gboolean dirty) {
|
|||
}
|
||||
|
||||
|
||||
EVENT void toolBoxClicked(GtkToolButton *object, gpointer user_data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
EVENT void toolCircleClicked(GtkToolButton *object, gpointer user_data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
EVENT void toolEllipseClicked(GtkToolButton *object, gpointer user_data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
EVENT void toolFillClicked(GtkToolButton *object, gpointer user_data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
EVENT void toolLineClicked(GtkToolButton *object, gpointer user_data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
EVENT void toolPlotClicked(GtkToolButton *object, gpointer user_data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
EVENT void toolRectangleClicked(GtkToolButton *object, gpointer user_data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
static float variable(VectorDataT *self, unsigned char byte) {
|
||||
int value;
|
||||
|
||||
|
@ -1026,8 +1073,19 @@ EVENT gboolean winVectorClose(GtkWidget *object, gpointer userData) {
|
|||
|
||||
void winVectorCreate(void) {
|
||||
VectorDataT *self;
|
||||
char *widgetNames[] = { "winVector", "boxVectorForEditor", "drawVectorImage", "fileVectorTraceImage", NULL };
|
||||
GtkWidget **widgets[] = { NULL, NULL, NULL, NULL };
|
||||
char *widgetNames[] = {
|
||||
"winVector",
|
||||
"boxVectorForEditor",
|
||||
"drawVectorImage",
|
||||
"fileVectorTraceImage",
|
||||
NULL
|
||||
};
|
||||
GtkWidget **widgets[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
// Set up instance data.
|
||||
self = NEW(VectorDataT);
|
||||
|
@ -1046,6 +1104,9 @@ void winVectorCreate(void) {
|
|||
// Grab title.
|
||||
self->title = strdup(gtk_window_get_title(GTK_WINDOW(self->windowData.window)));
|
||||
|
||||
// Add our custom icons.
|
||||
gtk_icon_theme_add_resource_path(gtk_icon_theme_get_for_screen(gdk_screen_get_default()), "/com/kangaroopunch/joeydev/icons");
|
||||
|
||||
// Add missing event to drawVectorImage
|
||||
gtk_widget_add_events(self->drawVectorImage, GDK_BUTTON_PRESS_MASK);
|
||||
g_signal_connect(G_OBJECT(self->drawVectorImage), "button-press-event", G_CALLBACK(drawVectorImageClick), self);
|
||||
|
|
|
@ -27,25 +27,29 @@ ROOT=$1
|
|||
|
||||
pushd "${ROOT}" || exit &> /dev/null
|
||||
|
||||
mkdir -p ui/generated
|
||||
echo Generating UI Embedded Code...
|
||||
mkdir -p ui/generated
|
||||
|
||||
:<<'SKIP'
|
||||
glib-compile-resources \
|
||||
--sourcedir=ui/ \
|
||||
--target=ui/generated/resources \
|
||||
--generate \
|
||||
ui/joeydev.gresource.xml
|
||||
|
||||
glib-compile-resources \
|
||||
--sourcedir=ui/ \
|
||||
--target=ui/generated/resources.h \
|
||||
--generate-header \
|
||||
ui/joeydev.gresource.xml
|
||||
SKIP
|
||||
|
||||
glib-compile-resources \
|
||||
--sourcedir=ui/ \
|
||||
--target=ui/generated/resources.c \
|
||||
--generate-source \
|
||||
ui/joeydev.gresource.xml
|
||||
|
||||
glib-compile-resources \
|
||||
--sourcedir=ui/ \
|
||||
--target=ui/generated/resources.h \
|
||||
--generate-header \
|
||||
ui/joeydev.gresource.xml
|
||||
|
||||
popd || true &> /dev/null
|
||||
|
||||
|
|
|
@ -1,7 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.40.0 -->
|
||||
<!-- Generated with glade 3.40.0
|
||||
|
||||
Copyright (C) 2018-2023 Scott Duensing <scott@kangaroopunch.com>
|
||||
|
||||
This file is part of JoeyDev.
|
||||
|
||||
JoeyDev is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
JoeyDev is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with JoeyDev. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Author: Scott Duensing <scott@kangaroopunch.com>
|
||||
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<!-- interface-license-type gplv3 -->
|
||||
<!-- interface-name JoeyDev -->
|
||||
<!-- interface-description IDE for JoeyLib -->
|
||||
<!-- interface-copyright 2018-2023 Scott Duensing <scott@kangaroopunch.com> -->
|
||||
<!-- interface-authors Scott Duensing <scott@kangaroopunch.com> -->
|
||||
<object class="GtkWindow" id="winJoeyDev">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="title" translatable="yes">JoeyDev</property>
|
||||
|
|
119
ui/Vector.glade
119
ui/Vector.glade
|
@ -1,7 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.40.0 -->
|
||||
<!-- Generated with glade 3.40.0
|
||||
|
||||
Copyright (C) 2018-2023 Scott Duensing <scott@kangaroopunch.com>
|
||||
|
||||
This file is part of JoeyDev.
|
||||
|
||||
JoeyDev is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
JoeyDev is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with JoeyDev. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Author: Scott Duensing <scott@kangaroopunch.com>
|
||||
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<!-- interface-license-type gplv3 -->
|
||||
<!-- interface-name JoeyDev -->
|
||||
<!-- interface-description IDE for JoeyLib -->
|
||||
<!-- interface-copyright 2018-2023 Scott Duensing <scott@kangaroopunch.com> -->
|
||||
<!-- interface-authors Scott Duensing <scott@kangaroopunch.com> -->
|
||||
<object class="GtkAdjustment" id="adjustmentVectorTraceImage">
|
||||
<property name="upper">100</property>
|
||||
<property name="value">50</property>
|
||||
|
@ -203,17 +229,102 @@
|
|||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkToolbar">
|
||||
<object class="GtkToolbar" id="toolbarActions">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="toolbar-style">icons</property>
|
||||
<property name="toolbar-style">both</property>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="toolBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Box</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="icon-name">action-box</property>
|
||||
<signal name="clicked" handler="toolBoxClicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="toolCircle">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Circle</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="icon-name">action-circle</property>
|
||||
<signal name="clicked" handler="toolCircleClicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="toolEllipse">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Ellipse</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="icon-name">action-ellipse</property>
|
||||
<signal name="clicked" handler="toolEllipseClicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="toolFill">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Fill</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="icon-name">action-fill</property>
|
||||
<signal name="clicked" handler="toolFillClicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="toolLine">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Line</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="icon-name">dialog-ok</property>
|
||||
<property name="icon-name">action-line</property>
|
||||
<signal name="clicked" handler="toolLineClicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="toolPlot">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Plot</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="icon-name">action-plot</property>
|
||||
<signal name="clicked" handler="toolPlotClicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="toolRectangle">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Rectangle</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="icon-name">action-rectangle</property>
|
||||
<signal name="clicked" handler="toolRectangleClicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
|
BIN
ui/action-box.png
(Stored with Git LFS)
Normal file
BIN
ui/action-box.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
ui/action-circle.png
(Stored with Git LFS)
Normal file
BIN
ui/action-circle.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
ui/action-ellipse.png
(Stored with Git LFS)
Normal file
BIN
ui/action-ellipse.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
ui/action-fill.png
(Stored with Git LFS)
Normal file
BIN
ui/action-fill.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
ui/action-line.png
(Stored with Git LFS)
Normal file
BIN
ui/action-line.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
ui/action-plot.png
(Stored with Git LFS)
Normal file
BIN
ui/action-plot.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
ui/action-rectangle.png
(Stored with Git LFS)
Normal file
BIN
ui/action-rectangle.png
(Stored with Git LFS)
Normal file
Binary file not shown.
|
@ -5,4 +5,13 @@
|
|||
<file preprocess="xml-stripblanks">Vector.glade</file>
|
||||
<file>Logo.png</file>
|
||||
</gresource>
|
||||
<gresource prefix="/com/kangaroopunch/joeydev/icons/32x32/actions">
|
||||
<file>action-box.png</file>
|
||||
<file>action-circle.png</file>
|
||||
<file>action-ellipse.png</file>
|
||||
<file>action-fill.png</file>
|
||||
<file>action-line.png</file>
|
||||
<file>action-plot.png</file>
|
||||
<file>action-rectangle.png</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
|
Loading…
Add table
Reference in a new issue