Type "into" slide thumbnail without full rerender
authorThomas White <taw@physics.org>
Sun, 3 Dec 2017 21:40:49 +0000 (22:40 +0100)
committerThomas White <taw@physics.org>
Sun, 3 Dec 2017 21:40:49 +0000 (22:40 +0100)
src/frame.c
src/frame.h
src/sc_editor.c

index 89268a6..d5ec137 100644 (file)
@@ -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];
index 4c9265a..ac91548 100644 (file)
@@ -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,
index 53b004b..1dee4b4 100644 (file)
@@ -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;
 
        }