diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/render.c | 32 | ||||
-rw-r--r-- | src/wrap.c | 28 |
2 files changed, 36 insertions, 24 deletions
diff --git a/src/render.c b/src/render.c index 2fc90b0..8e65a07 100644 --- a/src/render.c +++ b/src/render.c @@ -53,11 +53,11 @@ static void render_glyph_box(cairo_t *cr, struct wrap_box *box) box->col[3]); cairo_fill(cr); - cairo_rectangle(cr, 0.0, 0.0, pango_units_to_double(box->width), - pango_units_to_double(box->height)); - cairo_set_source_rgb(cr, 1.0, 0.0, 0.0); - cairo_set_line_width(cr, 0.1); - cairo_stroke(cr); +// cairo_rectangle(cr, 0.0, 0.0, pango_units_to_double(box->width), +// pango_units_to_double(box->height)); +// cairo_set_source_rgb(cr, 1.0, 0.0, 0.0); +// cairo_set_line_width(cr, 0.1); +// cairo_stroke(cr); } @@ -100,6 +100,17 @@ static void render_boxes(struct wrap_line *line, cairo_t *cr) } +static void draw_overfull_marker(cairo_t *cr, struct frame *fr, int i) +{ + cairo_move_to(cr, fr->w - fr->lop.pad_l- fr->lop.pad_r, 0.0); + cairo_line_to(cr, fr->w - fr->lop.pad_l - fr->lop.pad_r, + pango_units_to_double(fr->lines[i].height)); + cairo_set_source_rgb(cr, 1.0, 0.0, 0.0); + cairo_set_line_width(cr, 4.0); + cairo_stroke(cr); +} + + static void render_lines(struct frame *fr, cairo_t *cr) { int i; @@ -112,6 +123,7 @@ static void render_lines(struct frame *fr, cairo_t *cr) /* Move to beginning of the line */ cairo_translate(cr, 0.0, y_pos); + #if 0 cairo_move_to(cr, 0.0, 0.5+pango_units_to_double(fr->lines[i].ascent)); cairo_line_to(cr, pango_units_to_double(fr->lines[i].width), @@ -119,17 +131,13 @@ static void render_lines(struct frame *fr, cairo_t *cr) cairo_set_source_rgb(cr, 0.0, 0.0, 1.0); cairo_set_line_width(cr, 1.0); cairo_stroke(cr); + #endif /* Render the line */ render_boxes(&fr->lines[i], cr); if ( fr->lines[i].overfull ) { - cairo_move_to(cr, fr->w - fr->lop.pad_l - fr->lop.pad_r, 0.0); - cairo_line_to(cr, fr->w - fr->lop.pad_l - fr->lop.pad_r, - pango_units_to_double(fr->lines[i].height)); - cairo_set_source_rgb(cr, 1.0, 0.0, 0.0); - cairo_set_line_width(cr, 4.0); - cairo_stroke(cr); + draw_overfull_marker(cr, fr, i); } /* FIXME: line spacing */ @@ -240,7 +248,7 @@ static int render_frame(struct frame *fr, cairo_t *cr) break; } - + render_frame(ch, cr); ch->x = ch->lop.x + fr->lop.pad_l + ch->lop.margin_l; @@ -451,6 +451,18 @@ static enum wrap_box_space space(struct wrap_line *boxes, int i) } +static void distribute_spaces_last_line(struct wrap_line *l, double w, + double sp) +{ + int overfull = 0; + + for ( i=0; i<l->n_boxes-1; i++ ) { + l->boxes[i].sp = sp_x(l->boxes[i].space); + } + l->boxes[l->n_boxes-1].sp = 0.0; + l->overfull = overfull; +} + static void distribute_spaces(struct wrap_line *l, double w) { @@ -466,18 +478,11 @@ static void distribute_spaces(struct wrap_line *l, double w) sp = (pango_units_from_double(w)-total) / (l->n_boxes-1); - for ( i=0; i<l->n_boxes-1; i++ ) { - if ( sp < sp_zp(l->boxes[i].space) ) { - l->boxes[i].sp = sp_zp(l->boxes[i].space); - overfull = 1; - } else if ( l->last_line ) { - l->boxes[i].sp = sp_x(l->boxes[i].space); - } else { - l->boxes[i].sp = sp; - } + if ( l->last_line ) { + distribute_spaces_last_line(l, w, sp); + } else { + distribute_spaces_normal_line(l, w, sp); } - l->boxes[l->n_boxes-1].sp = 0.0; - l->overfull = overfull; } @@ -771,4 +776,3 @@ int wrap_contents(struct frame *fr, PangoContext *pc) return 0; } - |