diff options
author | Thomas White <taw@bitwiz.org.uk> | 2014-01-17 10:13:46 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2014-01-17 10:13:46 +0100 |
commit | 93956372d317fc90f8751e6b319e0055507c2519 (patch) | |
tree | 9c290978d9ad8a05a1da66ffc4839232b3102899 /src/sc_interp.c | |
parent | bc49b9f3fd00ebc3bd62a51bb2321822618e838d (diff) |
Unwrapped text belongs to frame, not interpreter
Diffstat (limited to 'src/sc_interp.c')
-rw-r--r-- | src/sc_interp.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/sc_interp.c b/src/sc_interp.c index 9fd6b24..5e1be23 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -60,8 +60,6 @@ struct _scinterp struct sc_state *state; int j; /* Index of the current state */ int max_state; - - struct wrap_line *boxes; }; @@ -249,13 +247,6 @@ SCInterpreter *sc_interp_new(PangoContext *pc, struct frame *top) /* FIXME: Determine proper language (somehow...) */ scin->lang = pango_language_from_string("en_GB"); - scin->boxes = malloc(sizeof(struct wrap_line)); - if ( scin->boxes == NULL ) { - fprintf(stderr, "Failed to allocate boxes.\n"); - return NULL; - } - initialise_line(scin->boxes); - /* The "ultimate" default font */ set_font(scin, "Sans 12"); set_colour(scin, "#000000"); @@ -411,8 +402,8 @@ int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl) } if ( name == NULL ) { - split_words(scin->boxes, scin->pc, contents, - scin->lang, 1, scin); + split_words(sc_interp_get_frame(scin)->boxes, scin->pc, + contents, scin->lang, 1, scin); } else if ( strcmp(name, "font") == 0 ) { set_font(scin, options); @@ -444,7 +435,16 @@ int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl) #endif } else if ( strcmp(name, "f")==0 ) { + struct frame *fr = sc_block_frame(bl); + + if ( fr != NULL ) { + free(fr->boxes->boxes); + free(fr->boxes); + fr->boxes = malloc(sizeof(struct wrap_line)); + initialise_line(fr->boxes); + } + if ( fr == NULL ) { fr = add_subframe(sc_interp_get_frame(scin)); sc_block_set_frame(bl, fr); @@ -454,6 +454,7 @@ int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl) fprintf(stderr, "Failed to add frame.\n"); goto next; } + parse_frame_options(fr, sc_interp_get_frame(scin), options); set_frame(scin, fr); @@ -477,8 +478,3 @@ next: return 0; } - -struct wrap_line *sc_interp_get_boxes(SCInterpreter *scin) -{ - return scin->boxes; -} |