diff options
author | Thomas White <taw@bitwiz.org.uk> | 2016-04-01 17:01:39 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2016-04-01 17:01:39 +0200 |
commit | 985b498081cfbf6f3ecf08b320a65aff7edeb207 (patch) | |
tree | 484e20d29b21209ced0561b060a378401ddc29a5 /src | |
parent | 37468b97fc8acff0948498da0996bf0835d3365a (diff) |
Initial paragraph stuff
Diffstat (limited to 'src')
-rw-r--r-- | src/sc_editor.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/sc_editor.c b/src/sc_editor.c index c75c8ac..d36b51c 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -825,6 +825,20 @@ static void calculate_box_size(struct frame *fr, SCEditor *e, } +static void check_paragraph(struct frame *fr, PangoContext *pc) +{ + if ( fr->n_paras > 0 ) return; + + printf("Adding dummy run.\n"); + show_sc_block(fr->scblocks, ">"); + printf("----\n"); + Paragraph *para = last_open_para(fr); + add_run(para, sc_block_child(fr->scblocks), 0, 0, + fr->fontdesc, fr->col); + wrap_paragraph(para, pc, fr->w - fr->pad_l - fr->pad_r); +} + + static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event, SCEditor *e) { @@ -871,6 +885,7 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event, /* Position cursor and prepare for possible drag */ e->cursor_frame = clicked; + check_paragraph(e->cursor_frame, e->pc); find_cursor(clicked, x-fr->x, y-fr->y, &e->cursor_para, &e->cursor_pos, &e->cursor_trail); @@ -1068,6 +1083,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); + check_paragraph(fr, e->pc); e->selection = fr; e->cursor_frame = fr; e->cursor_para = 0; @@ -1379,6 +1395,8 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context, sc_block_append_inside(fr->scblocks, "image", opts, ""); full_rerender(e); /* FIXME: No need for full */ e->selection = fr; + e->cursor_para = 0; + e->cursor_pos = 0; sc_editor_redraw(e); free(filename); |