Implement support for strikethrough text.

https://defs.ircdocs.horse/info/formatting.html
This commit is contained in:
Sadie Powell
2021-06-01 13:31:38 +01:00
committed by Patrick
parent 08e13a3ac5
commit 55e4f1c42e
6 changed files with 57 additions and 11 deletions

View File

@ -433,6 +433,7 @@ gtk_xtext_init (GtkXText * xtext)
xtext->nc = 0;
xtext->pixel_offset = 0;
xtext->underline = FALSE;
xtext->strikethrough = FALSE;
xtext->hidden = FALSE;
xtext->font = NULL;
xtext->layout = NULL;
@ -2451,6 +2452,7 @@ gtk_xtext_strip_color (unsigned char *text, int len, unsigned char *outbuf,
case ATTR_REVERSE:
case ATTR_BOLD:
case ATTR_UNDERLINE:
case ATTR_STRIKETHROUGH:
case ATTR_ITALICS:
xtext_do_chunk (&c);
if (*text == ATTR_RESET)
@ -2627,6 +2629,13 @@ gtk_xtext_render_flush (GtkXText * xtext, int x, int y, unsigned char *str,
g_object_unref (pix);
}
if (xtext->strikethrough)
{
/* pango_attr_strikethrough_new does not render in the custom widget so we need to reinvent the wheel */
y = dest_y + (xtext->fontsize / 2);
gdk_draw_line (xtext->draw_buf, gc, dest_x, y, dest_x + str_width - 1, y);
}
if (xtext->underline)
{
dounder:
@ -2651,6 +2660,7 @@ gtk_xtext_reset (GtkXText * xtext, int mark, int attribs)
if (attribs)
{
xtext->underline = FALSE;
xtext->strikethrough = FALSE;
xtext->hidden = FALSE;
}
if (!mark)
@ -2961,6 +2971,12 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent,
pstr += j + 1;
j = 0;
break;
case ATTR_STRIKETHROUGH:
RENDER_FLUSH;
xtext->strikethrough = !xtext->strikethrough;
pstr += j + 1;
j = 0;
break;
case ATTR_ITALICS:
RENDER_FLUSH;
*emphasis ^= EMPH_ITAL;
@ -3191,6 +3207,7 @@ find_next_wrap (GtkXText * xtext, textentry * ent, unsigned char *str,
case ATTR_REVERSE:
case ATTR_BOLD:
case ATTR_UNDERLINE:
case ATTR_STRIKETHROUGH:
case ATTR_ITALICS:
if (*str == ATTR_RESET)
emphasis = 0;