aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-04-13 11:21:55 -0400
committerJesse Luehrs <doy@tozt.net>2014-04-13 11:21:55 -0400
commit68fed85b2c847598d158004fefb55b214eeb1560 (patch)
treee23369908c7fc1418986bfd6924b48bd3ffad10d
parenta4f0738700c6f2cde5de7b3bccf1c32bba22bac4 (diff)
downloadrunes-68fed85b2c847598d158004fefb55b214eeb1560.tar.gz
runes-68fed85b2c847598d158004fefb55b214eeb1560.zip
need to erase the cells that i write text into
-rw-r--r--display.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/display.c b/display.c
index d7faab9..ce17276 100644
--- a/display.c
+++ b/display.c
@@ -122,16 +122,24 @@ void runes_display_move_to(RunesTerm *t, int row, int col)
void runes_display_show_string(RunesTerm *t, char *buf, size_t len)
{
if (len) {
+ double x, y;
+ double fontx, fonty, ascent;
+
buf[len] = '\0';
+
+ cairo_save(t->cr);
+ cairo_set_source(t->cr, t->bgcolor);
+ cairo_get_current_point(t->cr, &x, &y);
+ runes_display_get_font_dimensions(t, &fontx, &fonty, &ascent);
+ cairo_rectangle(t->cr, x, y - ascent, fontx * len, fonty);
+ cairo_fill(t->cr);
+ cairo_restore(t->cr);
+
+ cairo_move_to(t->cr, x, y);
cairo_show_text(t->cr, buf);
if (t->font_underline) {
- double x, y;
- double fontx, fonty, ascent;
-
cairo_save(t->cr);
- cairo_get_current_point(t->cr, &x, &y);
- runes_display_get_font_dimensions(t, &fontx, &fonty, &ascent);
cairo_set_line_width(t->cr, 1);
cairo_move_to(
t->cr, x - (fontx * strlen(buf)), y - ascent + fonty - 0.5);
@@ -142,7 +150,7 @@ void runes_display_show_string(RunesTerm *t, char *buf, size_t len)
runes_display_move_to(t, t->row, t->col);
}
- t->col += strlen(buf);
+ t->col += len;
/* we have to flush manually because XNextEvent (which normally handles
* flushing) will most likely be called again before the keystroke is
* handled */