aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-04-19 00:54:03 -0400
committerJesse Luehrs <doy@tozt.net>2014-04-19 00:54:03 -0400
commit643f4525dba3a059aa901111d00500f2c0ef1501 (patch)
treed340d5314ff2a4dcfa033f679fed12d79e6f7821
parentce218291ff3f32d262a35c8e67d789f65cbe9476 (diff)
downloadrunes-643f4525dba3a059aa901111d00500f2c0ef1501.tar.gz
runes-643f4525dba3a059aa901111d00500f2c0ef1501.zip
let pango draw underlines instead of doing it manually
-rw-r--r--display.c27
-rw-r--r--term.h2
2 files changed, 10 insertions, 19 deletions
diff --git a/display.c b/display.c
index 507242c..8c24c56 100644
--- a/display.c
+++ b/display.c
@@ -136,21 +136,6 @@ void runes_display_show_string_ascii(RunesTerm *t, char *buf, size_t len)
pango_cairo_update_layout(t->cr, t->layout);
pango_cairo_show_layout(t->cr, t->layout);
- if (t->font_underline) {
- double x, y;
-
- runes_display_position_cursor(t, t->cr);
- cairo_get_current_point(t->cr, &x, &y);
- cairo_save(t->cr);
- cairo_set_line_width(t->cr, 1);
- cairo_move_to(t->cr, x, y + t->fonty - 0.5);
- cairo_line_to(
- t->cr,
- x + (t->fontx * to_write), y + t->fonty - 0.5);
- cairo_stroke(t->cr);
- cairo_restore(t->cr);
- }
-
buf += to_write;
remaining -= to_write;
space_in_row = t->cols;
@@ -300,12 +285,20 @@ void runes_display_reset_italic(RunesTerm *t)
void runes_display_set_underline(RunesTerm *t)
{
- t->font_underline = 1;
+ PangoAttrList *attrs;
+
+ attrs = pango_layout_get_attributes(t->layout);
+ pango_attr_list_change(
+ attrs, pango_attr_underline_new(PANGO_UNDERLINE_SINGLE));
}
void runes_display_reset_underline(RunesTerm *t)
{
- t->font_underline = 0;
+ PangoAttrList *attrs;
+
+ attrs = pango_layout_get_attributes(t->layout);
+ pango_attr_list_change(
+ attrs, pango_attr_underline_new(PANGO_UNDERLINE_NONE));
}
void runes_display_set_fg_color(RunesTerm *t, cairo_pattern_t *color)
diff --git a/term.h b/term.h
index 15b144f..cf52dc6 100644
--- a/term.h
+++ b/term.h
@@ -33,8 +33,6 @@ struct runes_term {
char *font_name;
PangoLayout *layout;
- char font_underline;
-
char hide_cursor;
char unfocused;
char alternate;