diff options
author | Thomas White <taw@bitwiz.org.uk> | 2015-08-16 17:50:07 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2015-08-16 17:50:07 +0200 |
commit | 4534e5af52a226327590b3c19a010a460212427a (patch) | |
tree | c4749cd036cdf0e1fb7d2139836b6934b5d2c239 /src | |
parent | a54c8fae031aa34b6286e8f08fc4861681d24200 (diff) |
Remove sc_block_frame() crap
Diffstat (limited to 'src')
-rw-r--r-- | src/render.c | 8 | ||||
-rw-r--r-- | src/sc_editor.c | 9 | ||||
-rw-r--r-- | src/sc_editor.h | 1 | ||||
-rw-r--r-- | src/sc_interp.c | 73 | ||||
-rw-r--r-- | src/sc_interp.h | 2 | ||||
-rw-r--r-- | src/sc_parse.c | 30 | ||||
-rw-r--r-- | src/sc_parse.h | 6 |
7 files changed, 25 insertions, 104 deletions
diff --git a/src/render.c b/src/render.c index 4615e25..d24d437 100644 --- a/src/render.c +++ b/src/render.c @@ -431,12 +431,8 @@ static void render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *surf, pc = pango_font_map_create_context(fontmap); pango_cairo_update_context(cr, pc); - top = sc_block_frame(scblocks); - if ( top == NULL ) { - top = frame_new(); - top->resizable = 0; - sc_block_set_frame(scblocks, top); - } + top = frame_new(); + top->resizable = 0; top->x = 0.0; top->y = 0.0; top->w = log_w; diff --git a/src/sc_editor.c b/src/sc_editor.c index 2845a18..95351e2 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -819,8 +819,7 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event, if ( within_frame(e->selection, x, y) ) { clicked = e->selection; } else { - clicked = find_frame_at_position(sc_block_frame(e->scblocks), - x, y); + clicked = find_frame_at_position(e->top, x, y); } /* If the user clicked the currently selected frame, position cursor @@ -867,8 +866,7 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event, } } else if ( (clicked == NULL) - || ( !e->top_editable - && (clicked == sc_block_frame(e->scblocks)) ) ) + || ( !e->top_editable && (clicked == e->top) ) ) { /* Clicked no object. Deselect old object and set up for * (maybe) creating a new one. */ @@ -955,7 +953,7 @@ static struct frame *create_frame(SCEditor *e, double x, double y, struct frame *parent; struct frame *fr; - parent = sc_block_frame(e->scblocks); + parent = e->top; if ( w < 0.0 ) { x += w; @@ -972,7 +970,6 @@ static struct frame *create_frame(SCEditor *e, double x, double y, /* Add to SC */ fr->scblocks = sc_block_append_end(e->scblocks, "f", NULL, NULL); - sc_block_set_frame(fr->scblocks, fr); sc_block_append_inside(fr->scblocks, NULL, NULL, strdup("")); fr->x = x; diff --git a/src/sc_editor.h b/src/sc_editor.h index 203910a..b9f1c19 100644 --- a/src/sc_editor.h +++ b/src/sc_editor.h @@ -96,6 +96,7 @@ struct _sceditor SCBlock **stylesheets; ImageStore *is; SCCallbackList *cbl; + struct frame *top; /* Pointers to the frame currently being edited */ struct frame *selection; diff --git a/src/sc_interp.c b/src/sc_interp.c index dc0bad4..a261410 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -809,23 +809,19 @@ static int check_outputs(SCBlock *bl, SCInterpreter *scin) } else if ( strcmp(name, "f")==0 ) { - struct frame *fr = sc_block_frame(bl); + struct frame *fr; - if ( fr == NULL ) { - fr = add_subframe(sc_interp_get_frame(scin)); - sc_block_set_frame(bl, fr); - fr->scblocks = bl; - if ( in_macro(scin) ) { - fr->resizable = 0; - } else { - fr->resizable = 1; - } + fr = add_subframe(sc_interp_get_frame(scin)); + fr->scblocks = bl; + if ( in_macro(scin) ) { + fr->resizable = 0; + } else { + fr->resizable = 1; } if ( fr == NULL ) { fprintf(stderr, "Failed to add frame.\n"); return 1; } - fr->visited = 1; parse_frame_options(fr, sc_interp_get_frame(scin), options); @@ -859,31 +855,20 @@ static int check_macro(const char *name, SCInterpreter *scin) static void exec_macro(SCBlock *bl, SCInterpreter *scin, SCBlock *child) { - SCBlock *mchild; struct sc_state *st = &scin->state[scin->j]; + int i; + const char *name; - st->macro_contents = child; - st->macro_real_block = bl; - - mchild = sc_block_macro_child(bl); - - if ( (mchild == NULL) || (strcmp(sc_block_name(bl), "slidenumber")==0) ) { - - int i; - const char *name; - - /* Copy macro blocks into structure */ - name = sc_block_name(bl); - for ( i=0; i<st->n_macros; i++ ) { - if ( strcmp(st->macros[i].name, name) == 0 ) { - mchild = sc_block_copy(st->macros[i].bl); - sc_block_set_macro_child(bl, mchild); - } + name = sc_block_name(bl); + for ( i=0; i<st->n_macros; i++ ) { + if ( strcmp(st->macros[i].name, name) == 0 ) { + sc_interp_save(scin); + scin->state[scin->j].macro_real_block = bl; + scin->state[scin->j].macro_contents = child; + sc_interp_add_blocks(scin, st->macros[i].bl); + sc_interp_restore(scin); } - } - - sc_interp_add_blocks(scin, mchild); } @@ -897,28 +882,6 @@ static void run_macro_contents(SCInterpreter *scin) } -static void delete_unused_subframes(struct frame *fr) -{ - int i; - int done = 1; - int start = 0; - - do { - done = 1; - for ( i=start; i<fr->num_children; i++ ) { - if ( !fr->children[i]->visited ) { - // delete_subframe(fr, fr->children[i]); - // done = 0; - // start = i; - // break; - } else { - delete_unused_subframes(fr->children[i]); - } - } - } while ( !done ); -} - - int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl) { //printf("Running this --------->\n"); @@ -997,8 +960,6 @@ int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl) } - delete_unused_subframes(sc_interp_get_frame(scin)); - return 0; } diff --git a/src/sc_interp.h b/src/sc_interp.h index 7354e16..4591bae 100644 --- a/src/sc_interp.h +++ b/src/sc_interp.h @@ -29,6 +29,8 @@ #include <pango/pangocairo.h> +#include "frame.h" + struct presentation; typedef struct _scinterp SCInterpreter; typedef struct _sccallbacklist SCCallbackList; diff --git a/src/sc_parse.c b/src/sc_parse.c index 4aab2af..89253f6 100644 --- a/src/sc_parse.c +++ b/src/sc_parse.c @@ -43,9 +43,6 @@ struct _scblock SCBlock *next; SCBlock *prev; SCBlock *child; - SCBlock *macro_child; - - struct frame *fr; }; @@ -56,8 +53,6 @@ SCBlock *sc_block_new() bl = calloc(1, sizeof(SCBlock)); if ( bl == NULL ) return NULL; - bl->macro_child = NULL; - return bl; } @@ -74,18 +69,6 @@ SCBlock *sc_block_child(const SCBlock *bl) } -SCBlock *sc_block_macro_child(const SCBlock *bl) -{ - return bl->macro_child; -} - - -void sc_block_set_macro_child(SCBlock *bl, SCBlock *mchild) -{ - bl->macro_child = mchild; -} - - const char *sc_block_name(const SCBlock *bl) { return bl->name; @@ -104,18 +87,6 @@ const char *sc_block_contents(const SCBlock *bl) } -struct frame *sc_block_frame(const SCBlock *bl) -{ - return bl->fr; -} - - -void sc_block_set_frame(SCBlock *bl, struct frame *fr) -{ - bl->fr = fr; -} - - /* Insert a new block after "bl". "name", "options" and "contents" * will not be copied. Returns the block just created, or NULL on error. * If *blfp points to NULL, it will updated to point at the new block. */ @@ -335,7 +306,6 @@ void show_sc_block(const SCBlock *bl, const char *prefix) if ( bl->name != NULL ) printf("\\%s ", bl->name); if ( bl->options != NULL ) printf("[%s] ", bl->options); if ( bl->contents != NULL ) printf("{%s} ", bl->contents); - if ( bl->fr != NULL ) printf("-> frame %p", bl->fr); printf("\n"); if ( bl->child != NULL ) { diff --git a/src/sc_parse.h b/src/sc_parse.h index bf1960d..b1b59dd 100644 --- a/src/sc_parse.h +++ b/src/sc_parse.h @@ -39,13 +39,10 @@ extern SCBlock *sc_block_copy(const SCBlock *bl); extern SCBlock *sc_block_next(const SCBlock *bl); extern SCBlock *sc_block_child(const SCBlock *bl); -extern SCBlock *sc_block_macro_child(const SCBlock *bl); extern const char *sc_block_name(const SCBlock *bl); extern const char *sc_block_options(const SCBlock *bl); extern const char *sc_block_contents(const SCBlock *bl); -extern void sc_block_set_macro_child(SCBlock *bl, SCBlock *mchild); - extern SCBlock *sc_block_append(SCBlock *bl, char *name, char *opt, char *contents, SCBlock **blfp); @@ -61,9 +58,6 @@ extern SCBlock *sc_block_insert_after(SCBlock *afterme, extern void sc_block_delete(SCBlock *top, SCBlock *deleteme); -extern struct frame *sc_block_frame(const SCBlock *bl); -extern void sc_block_set_frame(SCBlock *bl, struct frame *fr); - extern SCBlock *find_last_child(SCBlock *bl); |