diff options
Diffstat (limited to 'src/sc_editor.c')
-rw-r--r-- | src/sc_editor.c | 56 |
1 files changed, 19 insertions, 37 deletions
diff --git a/src/sc_editor.c b/src/sc_editor.c index 5549c54..e54e60a 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -555,38 +555,13 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, SCEditor *e) } -void insert_scblock(SCBlock *scblock, SCEditor *e) +SCBlock *split_paragraph_at_cursor(SCEditor *e) { -#if 0 - /* FIXME: Insert "scblock" at the cursor */ - int sln, sbx, sps; - struct wrap_box *sbox; - struct frame *fr = e->cursor_frame; - - if ( fr == NULL ) return; - - /* If this is, say, the top level frame, do nothing */ - if ( fr->boxes == NULL ) return; - - sln = e->cursor_line; - sbx = e->cursor_box; - sps = e->cursor_pos; - sbox = bv_box(e->cursor_frame->lines[sln].boxes, sbx); - - sc_insert_block(sbox->scblock, sps+sbox->offs_char, scblock); - - fr->empty = 0; - - full_rerender(e); /* FIXME: No need for full */ - - //fixup_cursor(e); - //advance_cursor(e); - //sc_editor_redraw(e); -#endif + return split_paragraph(e->cursor_frame, e->cursor_para, + e->cursor_pos+e->cursor_trail, e->pc); } - static void insert_text(char *t, SCEditor *e) { Paragraph *para; @@ -838,6 +813,13 @@ static void check_paragraph(struct frame *fr, PangoContext *pc, { if ( fr->n_paras > 0 ) return; Paragraph *para = last_open_para(fr); + + /* We are creating the first paragraph. It uses the last SCBlock + * in the chain */ + while ( sc_block_next(scblocks) != NULL ) { + scblocks = sc_block_next(scblocks); + } + add_run(para, scblocks, 0, 0, fr->fontdesc, fr->col); wrap_paragraph(para, pc, fr->w - fr->pad_l - fr->pad_r); } @@ -923,12 +905,18 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event, } else { - /* Selected top new frame, no immediate dragging */ + /* Clicked an existing frame, no immediate dragging */ e->drag_status = DRAG_STATUS_NONE; e->drag_reason = DRAG_REASON_NONE; e->selection = clicked; e->cursor_frame = clicked; - check_paragraph(e->cursor_frame, e->pc, e->scblocks); + if ( clicked == e->top ) { + show_sc_block(clicked->scblocks, ")>"); + check_paragraph(e->cursor_frame, e->pc, clicked->scblocks); + } else { + check_paragraph(e->cursor_frame, e->pc, + sc_block_child(clicked->scblocks)); + } find_cursor(clicked, x-clicked->x, y-clicked->y, &e->cursor_para, &e->cursor_pos, &e->cursor_trail); @@ -1545,7 +1533,6 @@ SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets, { SCEditor *sceditor; GtkTargetEntry targets[1]; - GError *err; sceditor = g_object_new(SC_TYPE_EDITOR, NULL); @@ -1567,12 +1554,7 @@ SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets, sceditor->stylesheets = copy_ss_list(stylesheets); - err = NULL; - sceditor->bg_pixbuf = gdk_pixbuf_new_from_file(DATADIR"/colloquium/sky.png", &err); - if ( sceditor->bg_pixbuf == NULL ) { - fprintf(stderr, "Failed to load background: %s\n", - err->message); - } + sceditor->bg_pixbuf = NULL; gtk_widget_set_size_request(GTK_WIDGET(sceditor), sceditor->w, sceditor->h); |