After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 61852 - GtkTextBuffer needs a case insensitive search
GtkTextBuffer needs a case insensitive search
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
1.3.x
Other Linux
: Normal enhancement
: 3.0
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2001-10-06 19:08 UTC by Mikael Hermansson
Modified: 2010-11-01 14:47 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
gtktextiter case sensitive search patch (1.77 KB, patch)
2001-10-06 19:10 UTC, Mikael Hermansson
rejected Details | Review
case insensitive v1 (18.03 KB, patch)
2010-10-26 20:06 UTC, Ignacio Casal Quinteiro (nacho)
none Details | Review
unit test (7.02 KB, patch)
2010-10-31 12:57 UTC, Paolo Borelli
none Details | Review
patch (829 bytes, patch)
2010-10-31 12:58 UTC, Paolo Borelli
none Details | Review
case insensitive v2 (18.39 KB, patch)
2010-10-31 16:59 UTC, Ignacio Casal Quinteiro (nacho)
none Details | Review
case insensitive tests v1 (7.66 KB, patch)
2010-10-31 17:00 UTC, Ignacio Casal Quinteiro (nacho)
accepted-commit_now Details | Review

Description Mikael Hermansson 2001-10-06 19:08:02 UTC
Here is a patch to gtk_text_iter_[forward/backward]_search
with an extra boolean flag (is_case_sensitive).
 
This is until we have a better solution.
Comment 1 Mikael Hermansson 2001-10-06 19:10:53 UTC
Created attachment 5769 [details] [review]
gtktextiter case sensitive search patch
Comment 2 Havoc Pennington 2001-10-22 18:56:45 UTC
The case insensitive search is really hard to make i18n-correct, so
punting from 2.0. However, I'm changing forward/backward search to
take a "flags" field instead of the current visible_only/slice boolean
args; we can add a GTK_TEXT_SEARCH_CASE_INSENSITIVE flag in a future
version,
as well as GTK_TEXT_SEARCH_REGEXP.
Comment 3 Paolo Maggi 2001-12-19 14:20:19 UTC
Look at http://www.unicode.org/unicode/reports/tr21/

I think that writing a function to perform "caseless matching" should be
not so difficult since we already have g_utf8_casefold (...)

Please, reconsider it for inclusion in 2.0, we need it in gedit.
Comment 4 Havoc Pennington 2001-12-19 14:59:48 UTC
Implementing search yourself shouldn't be too difficult.
There's nothing magic about how it's done in gtktextiter.c.
Comment 5 Paolo Maggi 2002-02-28 14:48:27 UTC
I have an experimental implementation for it in gedit (you can find it
in gedit-utils.c)
It works quite well even if it has 1 or 2 little problems.
Comment 6 Paolo Maggi 2004-02-25 19:02:25 UTC
This has been implemented in gtksourceview. 
Comment 7 Luis Villa 2004-04-29 14:37:14 UTC
Paolo: should we just close this then?
Comment 8 Peter Johanson 2006-09-27 21:55:57 UTC
I'd really love to have this available in GtkTextBuffer itself, please don't close this only because gtksourceview has this functionality.
Comment 9 Javier Jardón (IRC: jjardon) 2010-10-18 02:29:51 UTC
As discussed in the 20100907 meeting, the code from gtksourceview should be merged in GTK+
Comment 10 Ignacio Casal Quinteiro (nacho) 2010-10-18 08:42:56 UTC
I'm working on this.
Comment 11 Ignacio Casal Quinteiro (nacho) 2010-10-26 20:06:13 UTC
Created attachment 173286 [details] [review]
case insensitive v1

This patch has been reviewed by pbor.
Comment 12 Matthias Clasen 2010-10-27 00:13:48 UTC
It would be awesome to have some testcases for this stuff, either in the existing gtk/tests/textbuffer.c, or as a new gtk/tests/textiter.c.
Comment 13 Paolo Borelli 2010-10-31 12:57:42 UTC
Created attachment 173591 [details] [review]
unit test

Here is a unit test for text iter search. I actually exposes a bug in the current backward search. The next patch in the series will fix the bug.

Later nacho will upload an updated version of his patch that adds caseless testcases to the unit test
Comment 14 Paolo Borelli 2010-10-31 12:58:18 UTC
Created attachment 173592 [details] [review]
patch

Fixes bug exposed by the unit test
Comment 15 Ignacio Casal Quinteiro (nacho) 2010-10-31 16:59:30 UTC
Created attachment 173598 [details] [review]
case insensitive v2

minor fix
Comment 16 Ignacio Casal Quinteiro (nacho) 2010-10-31 17:00:03 UTC
Created attachment 173599 [details] [review]
case insensitive tests v1

and the unit tests
Comment 17 Matthias Clasen 2010-11-01 14:16:30 UTC
Review of attachment 173598 [details] [review]:

Ok, thanks for the tests, lets commit this now.
Comment 18 Matthias Clasen 2010-11-01 14:17:38 UTC
Review of attachment 173599 [details] [review]:

Would be great to have some more tests around the more finicky parts of the tests, e.g decomposed forms, or maybe some Unicode chars with more unusual casedness (e.g. titlecase, etc).
But this is a good start, thanks.
Comment 19 Paolo Borelli 2010-11-01 14:47:58 UTC
Pushed the patch set. Great to see a 10 year old bug die :)

The current tests already check decomposed forms of accented letters etc, we can add more test cases, but I will need some suggestions (italian mostly uses utf8 for accented letters).. for instance I tried to add a test with Ӕ but it turns out it should not match "ae"