diff options
author | Thomas White <taw@bitwiz.org.uk> | 2015-10-12 22:53:02 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2015-10-12 22:53:02 +0200 |
commit | 4e204b3e02f78ca60d32d0c704abcb5499384157 (patch) | |
tree | c726ddb3c6b8b4b0ad68ffb1719356bebeb0e6c8 /src/sc_editor.c | |
parent | a8112c90cf0fdf44ceee5b54fed77468f5c15757 (diff) |
Redraw on edit
Diffstat (limited to 'src/sc_editor.c')
-rw-r--r-- | src/sc_editor.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/sc_editor.c b/src/sc_editor.c index b9a0032..c8ef09a 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -43,6 +43,7 @@ #include "sc_interp.h" #include "sc_editor.h" #include "slideshow.h" +#include "shape.h" G_DEFINE_TYPE(SCEditor, sc_editor, GTK_TYPE_DRAWING_AREA); @@ -559,6 +560,31 @@ void insert_scblock(SCBlock *scblock, SCEditor *e) } +/* The StoryCode for this box on this line in this frame has changed. + * Update the boxes from the StoryCode */ +static void update_local(SCEditor *e, struct frame *fr, int line, int bn) +{ + struct wrap_box *box = &fr->lines[line].boxes[bn]; + cairo_t *cr; + + /* Shape the box again */ + shape_box(box); + + /* Wrap the paragraph again */ + wrap_contents(fr); /* FIXME: Only the current paragraph */ + + /* Render the lines again */ + if ( e->surface != NULL ) { + cairo_surface_destroy(e->surface); + } + e->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, e->w, e->h); + cr = cairo_create(e->surface); + cairo_scale(cr, e->w/e->log_w, e->h/e->log_h); + recursive_draw(e->top, cr, e->is, ISZ_EDITOR); + cairo_destroy(cr); +} + + static void insert_text(char *t, SCEditor *e) { int sln, sbx, sps; @@ -588,11 +614,13 @@ static void insert_text(char *t, SCEditor *e) fr->empty = 0; - full_rerender(e); /* FIXME: No need for full */ + update_local(e, fr, sln, sbx); - //fixup_cursor(e); - //advance_cursor(e); - //sc_editor_redraw(e); + /* ... by doing this properly */ + fixup_cursor(e); + advance_cursor(e); + + sc_editor_redraw(e); } |