diff options
author | Thomas White <taw@bitwiz.me.uk> | 2019-10-10 21:52:21 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2019-10-10 21:52:21 +0200 |
commit | fe64bad2147d1abd20740873886ab95482b7c626 (patch) | |
tree | 63e9391233f00751af4dabb557236318bbe92538 /libstorycode/narrative_render_cairo.c | |
parent | 0243f814940b6f2a02664b5a19ef21e636e2af2e (diff) |
Take paraspace into account in cursor calculations
Diffstat (limited to 'libstorycode/narrative_render_cairo.c')
-rw-r--r-- | libstorycode/narrative_render_cairo.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/libstorycode/narrative_render_cairo.c b/libstorycode/narrative_render_cairo.c index 63f0865..ebd14f9 100644 --- a/libstorycode/narrative_render_cairo.c +++ b/libstorycode/narrative_render_cairo.c @@ -49,16 +49,6 @@ const double dummy_h_val = 1024.0; -static double narrative_lcalc(struct length l, double pd) -{ - if ( l.unit == LENGTH_UNIT ) { - return l.len; - } else { - return l.len * pd; - } -} - - static void wrap_text(struct narrative_item *item, PangoContext *pc, Stylesheet *ss, const char *stn, double w, size_t sel_start, size_t sel_end) @@ -259,10 +249,10 @@ int narrative_wrap_range(Narrative *n, Stylesheet *stylesheet, PangoLanguage *la struct length paraspace[4]; if ( stylesheet_get_padding(stylesheet, "NARRATIVE", pad) ) return 1; - n->space_l = narrative_lcalc(pad[0], w); - n->space_r = narrative_lcalc(pad[1], w); - n->space_t = narrative_lcalc(pad[2], dummy_h_val); - n->space_b = narrative_lcalc(pad[3], dummy_h_val); + n->space_l = lcalc(pad[0], w); + n->space_r = lcalc(pad[1], w); + n->space_t = lcalc(pad[2], dummy_h_val); + n->space_b = lcalc(pad[3], dummy_h_val); n->w = w; w -= n->space_l + n->space_r; @@ -334,10 +324,10 @@ int narrative_wrap_range(Narrative *n, Stylesheet *stylesheet, PangoLanguage *la } if ( stylesheet_get_paraspace(stylesheet, stn, paraspace) == 0 ) { - n->items[i].space_l = narrative_lcalc(paraspace[0], w); - n->items[i].space_r = narrative_lcalc(paraspace[1], w); - n->items[i].space_t = narrative_lcalc(paraspace[2], dummy_h_val); - n->items[i].space_b = narrative_lcalc(paraspace[3], dummy_h_val); + n->items[i].space_l = lcalc(paraspace[0], w); + n->items[i].space_r = lcalc(paraspace[1], w); + n->items[i].space_t = lcalc(paraspace[2], dummy_h_val); + n->items[i].space_b = lcalc(paraspace[3], dummy_h_val); } switch ( n->items[i].type ) { |