aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2015-08-16 19:31:52 +0200
committerThomas White <taw@bitwiz.org.uk>2015-08-16 19:31:52 +0200
commitb68b17261aa394d0b0c0a7ddd058c987385637ad (patch)
tree4132f48efa7404993b293a31013707255dbaeffe
parent321afdd0e417c701fbf9797ccfc3fd59a86d4dc2 (diff)
Rerender means full rerender
-rw-r--r--src/frame.c27
-rw-r--r--src/frame.h1
-rw-r--r--src/render.c1
-rw-r--r--src/sc_editor.c59
4 files changed, 38 insertions, 50 deletions
diff --git a/src/frame.c b/src/frame.c
index 9f23d17..ebd30ce 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -82,40 +82,27 @@ void frame_free(struct frame *fr)
{
int i;
- free(fr->boxes);
- for ( i=0; i<fr->num_children; i++ ) {
- frame_free(fr->children[i]);
- }
- free(fr->children);
- free(fr);
-}
-
-
-void renew_frame(struct frame *fr)
-{
- int i;
-
if ( fr == NULL ) return;
+ /* Free all lines */
for ( i=0; i<fr->n_lines; i++ ) {
wrap_line_free(&fr->lines[i]);
}
free(fr->lines);
- fr->lines = NULL;
- fr->n_lines = 0;
- fr->max_lines = 0;
+ /* Free unwrapped boxes */
if ( fr->boxes != NULL ) {
free(fr->boxes->boxes);
free(fr->boxes);
}
- fr->boxes = malloc(sizeof(struct wrap_line));
- initialise_line(fr->boxes);
- fr->visited = 0;
+ /* Free all children */
for ( i=0; i<fr->num_children; i++ ) {
- renew_frame(fr->children[i]);
+ frame_free(fr->children[i]);
}
+ free(fr->children);
+
+ free(fr);
}
diff --git a/src/frame.h b/src/frame.h
index b5679da..8b59dde 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -95,7 +95,6 @@ struct frame
extern struct frame *frame_new(void);
extern void frame_free(struct frame *fr);
extern struct frame *add_subframe(struct frame *fr);
-extern void renew_frame(struct frame *fr);
extern void show_hierarchy(struct frame *fr, const char *t);
extern void delete_subframe(struct frame *top, struct frame *fr);
diff --git a/src/render.c b/src/render.c
index 3bdc4ca..45c825e 100644
--- a/src/render.c
+++ b/src/render.c
@@ -459,7 +459,6 @@ static struct frame *render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *su
i++;
}
}
- renew_frame(top);
sc_interp_add_blocks(scin, scblocks);
recursive_wrap_and_draw(top, cr, is, isz);
diff --git a/src/sc_editor.c b/src/sc_editor.c
index 93a1245..180c70f 100644
--- a/src/sc_editor.c
+++ b/src/sc_editor.c
@@ -66,20 +66,29 @@ void sc_editor_set_background(SCEditor *e, double r, double g, double b)
}
-/* Update the view, once it's been edited in some way. */
-static void rerender(SCEditor *e)
+/* (Re-)run the entire rendering pipeline.
+ * NB "full" means "full". All frame, line and box handles will become
+ * invalid. The cursor position will be unset. */
+static void full_rerender(SCEditor *e)
{
if ( e->surface != NULL ) {
cairo_surface_destroy(e->surface);
}
+ frame_free(e->top);
+ e->cursor_frame = NULL;
+ e->cursor_line = 0;
+ e->cursor_pos = 0;
+ e->selection = NULL;
+
e->surface = render_sc(e->scblocks, e->w, e->h, e->log_w, e->log_h,
e->stylesheets, e->cbl, e->is, ISZ_EDITOR,
e->slidenum, &e->top);
+
+ sc_editor_redraw(e);
}
-/* Force a redraw of the editor window */
void sc_editor_redraw(SCEditor *e)
{
gint w, h;
@@ -94,12 +103,7 @@ void sc_editor_redraw(SCEditor *e)
void sc_editor_delete_selected_frame(SCEditor *e)
{
sc_block_delete(e->scblocks, e->selection->scblocks);
- e->cursor_frame = NULL;
- e->cursor_line = 0;
- e->cursor_pos = 0;
- e->selection = NULL;
- rerender(e);
- sc_editor_redraw(e);
+ full_rerender(e);
}
@@ -535,12 +539,11 @@ void insert_scblock(SCBlock *scblock, SCEditor *e)
fr->empty = 0;
- rerender(e);
+ full_rerender(e); /* FIXME: No need for full */
- fixup_cursor(e);
- advance_cursor(e);
-
- sc_editor_redraw(e);
+ //fixup_cursor(e);
+ //advance_cursor(e);
+ //sc_editor_redraw(e);
}
@@ -560,16 +563,17 @@ static void insert_text(char *t, SCEditor *e)
sps = e->cursor_pos;
sbox = &e->cursor_frame->lines[sln].boxes[sbx];
+ cur_box_diag(e);
+ printf("sps=%i, offs_char=%i\n", sps, sbox->offs_char);
sc_insert_text(sbox->scblock, sps+sbox->offs_char, t);
fr->empty = 0;
- rerender(e);
+ full_rerender(e); /* FIXME: No need for full */
- fixup_cursor(e);
- advance_cursor(e);
-
- sc_editor_redraw(e);
+ //fixup_cursor(e);
+ //advance_cursor(e);
+ //sc_editor_redraw(e);
}
@@ -609,7 +613,7 @@ static void do_backspace(struct frame *fr, SCEditor *e)
// scbl = sc_block_next(scbl);
// } while ( (scbl != fbox->scblock) && (scbl != NULL) );
- rerender(e);
+ full_rerender(e); /* FIXME: No need for full */
fixup_cursor(e);
sc_editor_redraw(e);
}
@@ -1009,7 +1013,7 @@ static void do_resize(SCEditor *e, double x, double y, double w, double h)
fr->h = h;
update_geom(fr);
- rerender(e);
+ full_rerender(e);
sc_editor_redraw(e);
}
@@ -1041,7 +1045,7 @@ static gboolean button_release_sig(GtkWidget *da, GdkEventButton *event,
fr = create_frame(e, e->start_corner_x, e->start_corner_y,
e->drag_corner_x - e->start_corner_x,
e->drag_corner_y - e->start_corner_y);
- rerender(e);
+ full_rerender(e);
e->selection = fr;
e->cursor_frame = fr;
e->cursor_line = 0;
@@ -1343,7 +1347,7 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context,
fr->is_image = 1;
fr->empty = 0;
sc_block_append_inside(fr->scblocks, "image", opts, "");
- rerender(e);
+ full_rerender(e); /* FIXME: No need for full */
e->selection = fr;
sc_editor_redraw(e);
free(filename);
@@ -1388,7 +1392,7 @@ static gint realise_sig(GtkWidget *da, SCEditor *e)
/* FIXME: Can do this "properly" by setting up a separate font map */
e->pc = gtk_widget_get_pango_context(GTK_WIDGET(e));
- rerender(e);
+ full_rerender(e);
return FALSE;
}
@@ -1397,8 +1401,7 @@ static gint realise_sig(GtkWidget *da, SCEditor *e)
void sc_editor_set_scblock(SCEditor *e, SCBlock *scblocks)
{
e->scblocks = scblocks;
- rerender(e);
- sc_editor_redraw(e);
+ full_rerender(e);
}
@@ -1414,7 +1417,7 @@ void sc_editor_set_size(SCEditor *e, int w, int h)
e->h = h;
update_size_request(e);
if ( gtk_widget_get_mapped(GTK_WIDGET(e)) ) {
- rerender(e);
+ full_rerender(e);
sc_editor_redraw(e);
}
}
@@ -1425,7 +1428,7 @@ void sc_editor_set_logical_size(SCEditor *e, double w, double h)
e->log_w = w;
e->log_h = h;
if ( gtk_widget_get_mapped(GTK_WIDGET(e)) ) {
- rerender(e);
+ full_rerender(e);
sc_editor_redraw(e);
}
}