[Xfce4-commits] <xfce4-clipman-plugin:master> [settings-dialog] Fix utf8 offset for tagging

Mike Massonnet noreply at xfce.org
Sun Dec 13 12:02:01 CET 2009


Updating branch refs/heads/master
         to f07af5a7e157073425b8e8816ca0438dae571372 (commit)
       from 74b0d4681e7118f7fe9e96ab0c1acc4c952d2ee3 (commit)

commit f07af5a7e157073425b8e8816ca0438dae571372
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Sun Dec 13 11:56:11 2009 +0100

    [settings-dialog] Fix utf8 offset for tagging
    
    The tag were missplaced because GMatchInfo returns the position in bytes
    and not in characters. This is fixed by using g_utf8_pointer_to_offset.
    
    Also change the regex compilation flags, use MULTILINE and drop DOTALL,
    to use every new lines as a new string to test against.

 panel-plugin/xfce4-clipman-settings.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/panel-plugin/xfce4-clipman-settings.c b/panel-plugin/xfce4-clipman-settings.c
index da4f195..8080bea 100644
--- a/panel-plugin/xfce4-clipman-settings.c
+++ b/panel-plugin/xfce4-clipman-settings.c
@@ -724,7 +724,7 @@ update_test_regex_textview_tags ()
 
   /* Build Regex */
   pattern = gtk_entry_get_text (GTK_ENTRY (entry));
-  regex = g_regex_new (pattern, G_REGEX_DOTALL|G_REGEX_CASELESS, 0, NULL);
+  regex = g_regex_new (pattern, G_REGEX_CASELESS|G_REGEX_MULTILINE, 0, NULL);
   if (regex == NULL)
     {
 #if GTK_CHECK_VERSION (2, 16, 0)
@@ -759,6 +759,8 @@ update_test_regex_textview_tags ()
 
           /* Insert tag at pos start_pos,end_pos */
           g_match_info_fetch_pos (match_info, i, &start_pos, &end_pos);
+          start_pos = g_utf8_pointer_to_offset (text, text + start_pos);
+          end_pos = g_utf8_pointer_to_offset (text, text + end_pos);
           gtk_text_buffer_get_iter_at_offset (buffer, &tag_start, start_pos);
           gtk_text_buffer_get_iter_at_offset (buffer, &tag_end, end_pos);
           if (i == 0)



More information about the Xfce4-commits mailing list