Hi all,I am new to this list, so please excuse me if these questions are somewhat dumb...
I am trying to use GtkSourceView as replacement for a GtkTextView in the MUA balsa [1] for both composing new messages and for displaying received text/* message parts. The idea is to use GtkSourceView's built-in highlighting feature to
- highlight "structured phrases" as in Thunderbird/Mozilla to get *bold face*, /italic/ and _underlined_ text;- use a different foreground colour for quoted lines (i.e. lines beginning with ">").
Unfortunately, I have some problems implementing it (see attached screenshot):
(1) I use gtk_pattern_tag_new() with the pattern (^|[[:space:]])_[[:alnum:]]([^_]|\n)*[[:alnum:]]_to highlight underlined text (replace the "_" by "*" and "/" to get bold and italic, respectively). For me, the underlying regex mechanism failes for national characters:
- if my locale is set to de_DE.iso88591, a german Umlaut (e.g. ä) behind the 1st "_" is detected properly (i.e. is a [[:alnum:]]), but the same character immediately before the 2nd "_" is *not* detected (see shot); - if I set the the locale to de_DE.utf8, the Umlaut is not recognised in *both* cases.
The problem occurs with both glibc's regex as well as with the one included in the GtkSourceView package, probabely because characters > 255 do not match isalnum(). Do you have any idea how the regexp should be modified properly to match *all* utf-8 national characters, or is this a glibc issue?
(2) The pattern above never matches if it contains a newline (hard line break), although it is explicitly included. This is probabely a feature of the regex engine. Would it be possible to add multiline matching through the api?
(3) Sometimes the pattern above is not found if the matched part (i.e. the part between the "_"'s) is wrapped. The following is *sometimes* reproducible: - enter text with a highlighted phrase which is wrapped on the screen (has a "soft" newline in it); - enter some text above it, and either the part on the first or on the second line will loose the special attribute;
- adding and erasing a space within the pattern will restore the attribute.I activated gtk_text_view_set_wrap_mode(text_view, GTK_WRAP_WORD_CHAR) on the GtkTextView. Any ideas?
(4) Sometimes, more than /one/ pattern should match and add highlighting, e.g. *bold* in a quoted line (see shot). In that case, the quoted line was found by using gtk_line_comment_tag_new() with
^([ \\t]*[|>:}#]){2}and the bold face as above. Is it possible to tweak GtkSourceView somehow so this case would be treated properly, i.e. the full line has a different foreground colour *and* the word in the red box is bold?
Thanks in advance for your help, Cheers, Albrecht. [1] http://balsa.gnome.org -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Albrecht Dreß - Johanna-Kirchner-Straße 13 - D-53123 Bonn (Germany) Phone (+49) 228 6199571 - mailto:albrecht dress arcor de GnuPG public key: http://www.mynetcologne.de/~nc-dreszal/pubkey.asc _________________________________________________________________________
Attachment:
GtkSourceView.png
Description: PNG image
Attachment:
pgpmAGpTn9VK4.pgp
Description: PGP signature