From 74151d515a28debfa24fc50cbcb575f800e1314f Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 3 Dec 2017 22:40:49 +0100 Subject: Type "into" slide thumbnail without full rerender --- src/frame.c | 6 ++++-- src/frame.h | 2 ++ src/sc_editor.c | 22 +++++++++++++++++++--- 3 files changed, 25 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/frame.c b/src/frame.c index 89268a6..d5ec137 100644 --- a/src/frame.c +++ b/src/frame.c @@ -429,7 +429,7 @@ static Paragraph *create_paragraph(struct frame *fr) /* Create a new paragraph in 'fr' just after paragraph 'pos' */ -static Paragraph *insert_paragraph(struct frame *fr, int pos) +Paragraph *insert_paragraph(struct frame *fr, int pos) { Paragraph **paras_new; Paragraph *pnew; @@ -446,8 +446,10 @@ static Paragraph *insert_paragraph(struct frame *fr, int pos) pnew = calloc(1, sizeof(struct _paragraph)); if ( pnew == NULL ) return NULL; + pnew->open = 1; + fr->paras = paras_new; - fr->n_paras ++; + fr->n_paras++; for ( i=fr->n_paras-1; i>pos; i-- ) { fr->paras[i] = fr->paras[i-1]; diff --git a/src/frame.h b/src/frame.h index 4c9265a..ac91548 100644 --- a/src/frame.h +++ b/src/frame.h @@ -139,6 +139,8 @@ extern void add_run(Paragraph *para, SCBlock *scblock, SCBlock *macro_real, size_t offs_bytes, size_t len_bytes, PangoFontDescription *fdesc, double col[4]); +extern Paragraph *insert_paragraph(struct frame *fr, int pos); + extern void add_callback_para(struct frame *fr, SCBlock *scblock, SCBlock *mr, double w, double h, SCCallbackDrawFunc draw_func, diff --git a/src/sc_editor.c b/src/sc_editor.c index 53b004b..1dee4b4 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -783,6 +783,7 @@ static void insert_text(char *t, SCEditor *e) } else { SCBlock *ad; + Paragraph *pnew; /* FIXME: We should not assume that box void pointers correspond * to "real" scblocks for callback paragraphs. Not in this @@ -794,10 +795,25 @@ static void insert_text(char *t, SCEditor *e) } /* No. Create a new text paragraph straight afterwards */ - sc_block_insert_after(ad, NULL, NULL, strdup(t)); - full_rerender(e); + ad = sc_block_insert_after(ad, NULL, NULL, strdup(t)); + if ( ad == NULL ) { + fprintf(stderr, "Failed to add SCBlock\n"); + return; + } - /* FIXME: Find the cursor again */ + pnew = insert_paragraph(e->cursor_frame, e->cursor_para); + if ( pnew == NULL ) { + fprintf(stderr, "Failed to insert paragraph\n"); + return; + } + add_run(pnew, ad, NULL, 0, strlen(t), + e->cursor_frame->fontdesc, e->cursor_frame->col); + + wrap_frame(e->top, e->pc); + + e->cursor_para += 1; + e->cursor_pos = 0; + e->cursor_trail = 1; } -- cgit v1.2.3