diff options
author | Thomas White <taw@bitwiz.org.uk> | 2016-04-03 17:41:10 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2016-04-03 17:41:10 +0200 |
commit | 43cefb51f137481e873e3401bbad88b140c4b521 (patch) | |
tree | 2652c35f6b769cea73ff7bc7a4c12ef56cee527b | |
parent | ddb030da60742f9255ceded021ae46b89cea97d0 (diff) |
Improve handling of top-level frame
-rw-r--r-- | src/render.c | 8 | ||||
-rw-r--r-- | src/sc_editor.c | 28 |
2 files changed, 25 insertions, 11 deletions
diff --git a/src/render.c b/src/render.c index d3dfa01..e68fe5a 100644 --- a/src/render.c +++ b/src/render.c @@ -186,6 +186,7 @@ struct frame *interp_and_shape(SCBlock *scblocks, SCBlock **stylesheets, top->y = 0.0; top->w = w; top->h = h; + top->scblocks = scblocks; scin = sc_interp_new(pc, lang, top); if ( scin == NULL ) { @@ -206,6 +207,13 @@ struct frame *interp_and_shape(SCBlock *scblocks, SCBlock **stylesheets, i++; } } + + top->fontdesc = pango_font_description_copy(sc_interp_get_fontdesc(scin)); + top->col[0] = sc_interp_get_fgcol(scin)[0]; + top->col[1] = sc_interp_get_fgcol(scin)[1]; + top->col[2] = sc_interp_get_fgcol(scin)[2]; + top->col[3] = sc_interp_get_fgcol(scin)[3]; + sc_interp_add_blocks(scin, scblocks); sc_interp_destroy(scin); diff --git a/src/sc_editor.c b/src/sc_editor.c index b4b2e78..0ad5e37 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -97,8 +97,16 @@ static void set_vertical_params(SCEditor *e) static void update_size(SCEditor *e) { if ( e->flow ) { + + double total = total_height(e->top); + + if ( total == 0.0 ) { + total = 1000.0; /* FIXME: Height of window */ + } + e->w = e->top->w; - e->h = total_height(e->top) + e->top->pad_t + e->top->pad_b; + e->h = total + e->top->pad_t + e->top->pad_b; + e->log_w = e->w; e->log_h = e->h; e->top->h = e->h; @@ -825,16 +833,12 @@ static void calculate_box_size(struct frame *fr, SCEditor *e, } -static void check_paragraph(struct frame *fr, PangoContext *pc) +static void check_paragraph(struct frame *fr, PangoContext *pc, + SCBlock *scblocks) { 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); + add_run(para, scblocks, 0, 0, fr->fontdesc, fr->col); wrap_paragraph(para, pc, fr->w - fr->pad_l - fr->pad_r); } @@ -885,7 +889,8 @@ 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); + check_paragraph(e->cursor_frame, e->pc, + sc_block_child(fr->scblocks)); find_cursor(clicked, x-fr->x, y-fr->y, &e->cursor_para, &e->cursor_pos, &e->cursor_trail); @@ -918,11 +923,12 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event, } else { - /* Select new frame, no immediate dragging */ + /* Selected top new 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); find_cursor(clicked, x-clicked->x, y-clicked->y, &e->cursor_para, &e->cursor_pos, &e->cursor_trail); @@ -1083,7 +1089,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); + check_paragraph(fr, e->pc, sc_block_child(fr->scblocks)); e->selection = fr; e->cursor_frame = fr; e->cursor_para = 0; |