summaryrefslogtreecommitdiffstats
path: root/source/helper.c
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-01-09 00:09:02 +0100
committerDave Davenport <qball@gmpclient.org>2017-01-09 00:09:02 +0100
commit713d41f619a1a8b311c3028a97e909e79cf88353 (patch)
tree8f30db8856307c2ebbc156573fc1dfc54969ba21 /source/helper.c
parentbaab2047adf24642cbc727b50a77dc544e934a76 (diff)
Allow matching highlighting to be set. Fixes #522
Diffstat (limited to 'source/helper.c')
-rw-r--r--source/helper.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/source/helper.c b/source/helper.c
index 84307bdd..48fbf13d 100644
--- a/source/helper.c
+++ b/source/helper.c
@@ -391,7 +391,7 @@ int find_arg_char ( const char * const key, char *val )
return FALSE;
}
-PangoAttrList *token_match_get_pango_attr ( GRegex **tokens, const char *input, PangoAttrList *retv )
+PangoAttrList *token_match_get_pango_attr ( ThemeHighlight th, GRegex **tokens, const char *input, PangoAttrList *retv )
{
// Do a tokenized match.
if ( tokens ) {
@@ -401,14 +401,35 @@ PangoAttrList *token_match_get_pango_attr ( GRegex **tokens, const char *input,
while ( g_match_info_matches ( gmi ) ) {
int count = g_match_info_get_match_count ( gmi );
for ( int index = ( count > 1 ) ? 1 : 0; index < count; index++ ) {
- int start, end;
+ int start, end;
g_match_info_fetch_pos ( gmi, index, &start, &end );
- PangoAttribute *pa = pango_attr_underline_new ( PANGO_UNDERLINE_SINGLE );
- PangoAttribute *pa2 = pango_attr_weight_new ( PANGO_WEIGHT_BOLD );
- pa2->start_index = pa->start_index = start;
- pa2->end_index = pa->end_index = end;
- pango_attr_list_insert ( retv, pa );
- pango_attr_list_insert ( retv, pa2 );
+ if ( th.style & HL_BOLD ) {
+ PangoAttribute *pa = pango_attr_weight_new ( PANGO_WEIGHT_BOLD );
+ pa->start_index = start;
+ pa->end_index = end;
+ pango_attr_list_insert ( retv, pa );
+ }
+ if ( th.style & HL_UNDERLINE ) {
+ PangoAttribute *pa = pango_attr_underline_new ( PANGO_UNDERLINE_SINGLE );
+ pa->start_index = start;
+ pa->end_index = end;
+ pango_attr_list_insert ( retv, pa );
+ }
+ if ( th.style & HL_ITALIC ) {
+ PangoAttribute *pa = pango_attr_style_new ( PANGO_STYLE_ITALIC );
+ pa->start_index = start;
+ pa->end_index = end;
+ pango_attr_list_insert ( retv, pa );
+ }
+ if ( th.style & HL_COLOR ) {
+ PangoAttribute *pa = pango_attr_foreground_new (
+ th.color.red * 65535,
+ th.color.green * 65535,
+ th.color.blue * 65535 );
+ pa->start_index = start;
+ pa->end_index = end;
+ pango_attr_list_insert ( retv, pa );
+ }
}
g_match_info_next ( gmi, NULL );
}