コード例 #1
0
ファイル: Watchers.cs プロジェクト: shubhtr/tomboy-1
        void ApplyUrlToBlock(Gtk.TextIter start, Gtk.TextIter end)
        {
            NoteBuffer.GetBlockExtents(ref start,
                                       ref end,
                                       256 /* max url length */,
                                       Note.TagTable.UrlTag);

            Buffer.RemoveTag(Note.TagTable.UrlTag, start, end);

            Gtk.TextIter searchiter = start;
            for (Match match = regex.Match(start.GetSlice(end));
                 match.Success;
                 match = match.NextMatch())
            {
                System.Text.RegularExpressions.Group group = match.Groups [1];

                /*
                 * Logger.Log ("Highlighting url: '{0}' at offset {1}",
                 *   group,
                 *   group.Index);
                 */

                // Use the ForwardSearch instead of group's Index to account for multibyte chars in the text.
                // We'll search using the exact match value within provided boundaries.
                Gtk.TextIter startiter, enditer;
                searchiter.ForwardSearch(group.Value, Gtk.TextSearchFlags.VisibleOnly, out startiter, out enditer, end);
                searchiter = enditer;

                Buffer.ApplyTag(Note.TagTable.UrlTag, startiter, enditer);
            }
        }