Re: Does gtk2 provide a case 'in'-sensitive text search via 'gtk_text_iter_..._search'?



On 01/26/2017 03:21 PM, cecashon aol com wrote:
I worked on this a little more and tried to make it UTF-8 compliant.
Highlighted the text also. It should still be efficient since it is only doing
a single pass over each char. I am sure there are things that I haven't
considered but it does a little more than the first try at it.

https://github.com/cecashon/OrderedSetVelociRaptor/blob/master/Misc/Csamples/search_textbuffer1.c

You rock! Thank you. I actually did something similar, though I will probably
scavenge from your efforts, I basically wrote a generic iterator for selected
text in GtkTextBuffer, and then converted all to lowercase before comparison
manually (I like your UTF-8 compliant g_unichar_tolower() approach compared to) :

gboolean str2lower (gchar *str)
{
    if (!str) return FALSE;

    gchar *p = str;
    gboolean changed = FALSE;

    for (; *p; p++)
        if ('A' <= *p && *p <= 'Z') {
            *p ^= 32;
            changed = TRUE;
        }

    return changed;
}

Eventually when Gtk+3 stabilizes I'll look at a move to it and GtkSourceView
3X, but currently I'm quite happy with the Gtk+2 stable branch (and the wealth
of good themes available). For most of the added GtkSourceView 3X
functionality that I want, have simply backported the functions to run with
Gtk+2 (e.g. source_view_indent_lines, source_view_unindent_lines, ...)

-- 
David C. Rankin, J.D.,P.E.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]