summaryrefslogtreecommitdiff
path: root/saedit
diff options
context:
space:
mode:
Diffstat (limited to 'saedit')
-rw-r--r--saedit/interface.ui1
-rw-r--r--saedit/main.c42
-rw-r--r--saedit/main.h4
-rw-r--r--saedit/sae.c3
-rw-r--r--saedit/sae.h1
-rw-r--r--saedit/xml.c73
-rw-r--r--saedit/xml.h1
7 files changed, 108 insertions, 17 deletions
diff --git a/saedit/interface.ui b/saedit/interface.ui
index 7c1ba9d..f49af39 100644
--- a/saedit/interface.ui
+++ b/saedit/interface.ui
@@ -793,6 +793,7 @@ Reid Yaro &lt;reidyaro@gmail.com&gt;</property>
<property name="tab_width">4</property>
<property name="auto_indent">True</property>
<property name="indent_on_tab">False</property>
+ <property name="highlight_current_line">True</property>
</object>
</child>
</object>
diff --git a/saedit/main.c b/saedit/main.c
index 44cd48c..5fc3e77 100644
--- a/saedit/main.c
+++ b/saedit/main.c
@@ -81,7 +81,7 @@ gboolean darea_draw_event(GtkWidget *widget, cairo_t *cr, SAEInfo *sae_info) {
return FALSE;
}
-//String functions (common)
+//Common functions
gchar *markup_bold(gchar *str) {
return g_strconcat("<b>", str, "</b>");
@@ -93,6 +93,14 @@ void format_src_string(gchar *src) {
strncpy(str, "\0", 1);
}
+GtkTextIter *gtk_source_buffer_highlight_line(GtkSourceBuffer *buffer, int line_number) {
+ GtkTextIter start;
+ gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(buffer), &start);
+ gtk_text_iter_set_line(&start, line_number);
+ gtk_text_buffer_place_cursor(GTK_TEXT_BUFFER(buffer), &start);
+ return gtk_text_iter_copy(&start);
+}
+
//File working
void open_xml_file(GtkButton *button) {
@@ -220,9 +228,7 @@ void open_menu_item_activate_callback(GtkMenuItem *menuitem, GtkFileChooserDialo
void toolbar_to_first_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) {
toolbar_pause_clicked_callback(toolbutton, user_data);
gen_sae_info->animation = g_list_first(gen_sae_info->animation);
- Frame *sprite = gen_sae_info->animation->data;
- gen_sae_info->sprite = sprite;
- gtk_widget_queue_draw(darea);
+ show_sprite(gen_sae_info);
}
void toolbar_prev_frame_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) {
@@ -231,9 +237,7 @@ void toolbar_prev_frame_clicked_callback(GtkToolButton *toolbutton, gpointer use
if (prev == NULL)
return;
gen_sae_info->animation = prev;
- Frame *sprite = gen_sae_info->animation->data;
- gen_sae_info->sprite = sprite;
- gtk_widget_queue_draw(darea);
+ show_sprite(gen_sae_info);
}
void toolbar_play_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) {
@@ -258,17 +262,13 @@ void toolbar_next_frame_clicked_callback(GtkToolButton *toolbutton, gpointer use
if (next == NULL)
return;
gen_sae_info->animation = next;
- Frame *sprite = gen_sae_info->animation->data;
- gen_sae_info->sprite = sprite;
- gtk_widget_queue_draw(darea);
+ show_sprite(gen_sae_info);
}
void toolbar_to_last_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) {
toolbar_pause_clicked_callback(toolbutton, user_data);
gen_sae_info->animation = g_list_last(gen_sae_info->animation);
- Frame *sprite = gen_sae_info->animation->data;
- gen_sae_info->sprite = sprite;
- gtk_widget_queue_draw(darea);
+ show_sprite(gen_sae_info);
}
//Dialogs
@@ -369,13 +369,25 @@ gboolean set_up_imagesets(SAEInfo *sae_info) {
return TRUE;
}
+void show_sprite(SAEInfo *sae_info) {
+ Frame *sprite = sae_info->animation->data;
+ gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(source_view),
+ gtk_source_buffer_highlight_line(source_buffer, sprite->line_number-1),
+ 0.25,
+ FALSE,
+ 0.0,
+ 0.0);
+ sae_info->sprite = sprite;
+ gtk_widget_queue_draw(darea);
+}
+
void show_animation(SAEInfo *sae_info) {
kill_timeout(sae_info->anim_tag);
if (sae_info->animation == NULL)
return;
+
+ show_sprite(sae_info);
Frame *sprite = sae_info->animation->data;
- sae_info->sprite = sprite;
- gtk_widget_queue_draw(darea);
GList *next = g_list_next(sae_info->animation);
if (next == NULL)
diff --git a/saedit/main.h b/saedit/main.h
index a02fd3a..68566d9 100644
--- a/saedit/main.h
+++ b/saedit/main.h
@@ -61,9 +61,10 @@ Keys *config;
cairo_surface_t *get_grid_surface(int w, int h);
gboolean darea_draw_event(GtkWidget *widget, cairo_t *cr, SAEInfo *sae_info);
-//String functions (common)
+//Common functions
gchar *markup_bold(gchar *str);
void format_src_string(gchar *src);
+GtkTextIter *gtk_source_buffer_highlight_line(GtkSourceBuffer *buffer, int line_number);
//File working
void open_xml_file(GtkButton *button);
@@ -111,6 +112,7 @@ void load_config();
void save_config_and_quit();
void load_options();
void parse_xml_text(gchar *text, SAEInfo *sae_info);
+void show_sprite(SAEInfo *sae_info);
void show_animation(SAEInfo *sae_info);
#endif
diff --git a/saedit/sae.c b/saedit/sae.c
index 472901e..e2627a7 100644
--- a/saedit/sae.c
+++ b/saedit/sae.c
@@ -112,6 +112,7 @@ gboolean set_up_animation_by_direction(SAEInfo *sae_info, const gchar *direction
for (r = 1; r <= repeat; r++) {
for (i = start; i <= end; i++) {
Frame *sprite = frame_new(i, offsetX, offsetY, delay);
+ sprite->line_number = node->line_number;
sprite->pixbuf = get_sprite_by_index(i, sae_info);
count++;
if (sae_info->animation != NULL)
@@ -123,7 +124,7 @@ gboolean set_up_animation_by_direction(SAEInfo *sae_info, const gchar *direction
}
}
}
- list = list->next;
+ list = g_list_next(list);
}
if (sae_info->animation == NULL)
return FALSE;
diff --git a/saedit/sae.h b/saedit/sae.h
index 830e64b..322eca5 100644
--- a/saedit/sae.h
+++ b/saedit/sae.h
@@ -23,6 +23,7 @@ typedef struct {
int offsetX;
int offsetY;
int delay;
+ int line_number;
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
} Frame;
diff --git a/saedit/xml.c b/saedit/xml.c
index d7b697e..602dfaf 100644
--- a/saedit/xml.c
+++ b/saedit/xml.c
@@ -42,6 +42,76 @@ gint xml_node_compare_with_attr_func(const XMLNode *node, const gchar **attr) {
xml_node_get_attr_value(node, attr[0]));
}
+typedef enum
+{
+ STATE_START,
+ STATE_AFTER_OPEN_ANGLE,
+ STATE_AFTER_CLOSE_ANGLE,
+ STATE_AFTER_ELISION_SLASH, /* the slash that obviates need for end element */
+ STATE_INSIDE_OPEN_TAG_NAME,
+ STATE_INSIDE_ATTRIBUTE_NAME,
+ STATE_AFTER_ATTRIBUTE_NAME,
+ STATE_BETWEEN_ATTRIBUTES,
+ STATE_AFTER_ATTRIBUTE_EQUALS_SIGN,
+ STATE_INSIDE_ATTRIBUTE_VALUE_SQ,
+ STATE_INSIDE_ATTRIBUTE_VALUE_DQ,
+ STATE_INSIDE_TEXT,
+ STATE_AFTER_CLOSE_TAG_SLASH,
+ STATE_INSIDE_CLOSE_TAG_NAME,
+ STATE_AFTER_CLOSE_TAG_NAME,
+ STATE_INSIDE_PASSTHROUGH,
+ STATE_ERROR
+} GMarkupParseState;
+
+typedef struct
+{
+ const GMarkupParser *parser;
+
+ GMarkupParseFlags flags;
+
+ gint line_number;
+ gint char_number;
+
+ GMarkupParseState state;
+
+ gpointer user_data;
+ GDestroyNotify dnotify;
+
+ /* A piece of character data or an element that
+ * hasn't "ended" yet so we haven't yet called
+ * the callback for it.
+ */
+ GString *partial_chunk;
+ GSList *spare_chunks;
+
+ GSList *tag_stack;
+ GSList *tag_stack_gstr;
+ GSList *spare_list_nodes;
+
+ GString **attr_names;
+ GString **attr_values;
+ gint cur_attr;
+ gint alloc_attrs;
+
+ const gchar *current_text;
+ gssize current_text_len;
+ const gchar *current_text_end;
+
+ /* used to save the start of the last interesting thingy */
+ const gchar *start;
+
+ const gchar *iter;
+
+ guint document_empty : 1;
+ guint parsing : 1;
+ guint awaiting_pop : 1;
+ gint balance;
+
+ /* subparser support */
+ GSList *subparser_stack; /* (GMarkupRecursionTracker *) */
+ const char *subparser_element;
+ gpointer held_user_data;
+} _GMarkupParseContext;
static GMarkupParser parser;
void
@@ -99,6 +169,7 @@ _start_element_cb (GMarkupParseContext *context,
gpointer user_data,
GError **error)
{
+
XMLNode *node = (XMLNode *) user_data;
if (node->text) {
@@ -123,6 +194,8 @@ _start_element_cb (GMarkupParseContext *context,
}
p->attributes = (gchar **)g_array_free (attributes, FALSE);
+
+ p->line_number = ((_GMarkupParseContext*)context)->line_number - (((_GMarkupParseContext*)context)->char_number <= 1);
}
static void
diff --git a/saedit/xml.h b/saedit/xml.h
index 4030d72..2f5bc2b 100644
--- a/saedit/xml.h
+++ b/saedit/xml.h
@@ -19,6 +19,7 @@ typedef struct {
gchar *name;
gchar *text;
gchar **attributes;
+ int line_number;
GList *sub_nodes;
} XMLNode;