aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2013-03-12 22:40:22 +0100
committerThomas White <taw@bitwiz.org.uk>2013-03-12 22:40:22 +0100
commit0e7b56a1350ae2157a9557c8d0fc291f9c4f67c8 (patch)
tree492a47f2f557bf7f6bfa83acc1505c659df224e2
parent5dcb40f39b76d3699983fa833b0c50f9be7eee9b (diff)
Mark overfull lines
-rw-r--r--src/render.c9
-rw-r--r--src/wrap.c9
-rw-r--r--src/wrap.h1
3 files changed, 18 insertions, 1 deletions
diff --git a/src/render.c b/src/render.c
index b11b4fd..42898d8 100644
--- a/src/render.c
+++ b/src/render.c
@@ -123,6 +123,15 @@ static void render_lines(struct frame *fr, cairo_t *cr)
/* Render the line */
render_boxes(&fr->lines[i], cr);
+ if ( fr->lines[i].overfull ) {
+ cairo_move_to(cr, fr->w, 0.0);
+ cairo_line_to(cr, fr->w,
+ 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);
+ }
+
/* FIXME: line spacing */
y_pos += pango_units_to_double(fr->lines[i].height) + 0.0;
diff --git a/src/wrap.c b/src/wrap.c
index 0343f11..67654ff 100644
--- a/src/wrap.c
+++ b/src/wrap.c
@@ -438,6 +438,7 @@ static void distribute_spaces(struct wrap_line *l, double w)
int i;
double total;
double sp;
+ int overfull = 0;
total = 0.0;
for ( i=0; i<l->n_boxes; i++ ) {
@@ -447,9 +448,15 @@ 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++ ) {
- l->boxes[i].sp = sp;
+ if ( sp < sp_zp(l->boxes[i].space) ) {
+ l->boxes[i].sp = sp_zp(l->boxes[i].space);
+ overfull = 1;
+ } else {
+ l->boxes[i].sp = sp;
+ }
}
l->boxes[l->n_boxes-1].sp = 0.0;
+ l->overfull = overfull;
}
diff --git a/src/wrap.h b/src/wrap.h
index 91dcf6b..576ad10 100644
--- a/src/wrap.h
+++ b/src/wrap.h
@@ -87,6 +87,7 @@ struct wrap_line
int max_boxes;
struct wrap_box *boxes;
+ int overfull;
size_t sc_offset;
};