View previous topic :: View next topic |
Author |
Message |
Mitu
Joined: 22 Sep 2009 Posts: 59 Location: Poland
|
Posted: Tue Feb 02, 2010 11:40 am Post subject: TextIter, forwardSearch - case insensitive |
|
|
Is there a version of this function, which ignores case? |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Tue Feb 02, 2010 2:40 pm Post subject: |
|
|
gsv.SourceSearch.forwardSearch supports case insensitive searching with: GtkSourceSearchFlags.GtkSourceSearchFlags
and it should work with a regular textIter. it is part of gtkSourceView though. |
|
Back to top |
|
|
Mitu
Joined: 22 Sep 2009 Posts: 59 Location: Poland
|
Posted: Sat Feb 06, 2010 1:47 pm Post subject: |
|
|
Unfortunately, still searches case sensitive.
gtkD version 1.2. Was there such a bug? |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Sun Feb 07, 2010 8:58 am Post subject: |
|
|
Not that i know.
O, and in my previous massage i meant: GtkSourceSearchFlags.CASE_INSENSITIVE
But i assume you figured that out already?
I'll see if i can get it working. |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Sun Feb 07, 2010 10:10 am Post subject: |
|
|
works for me. |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Wed Feb 10, 2010 3:41 pm Post subject: |
|
|
Something like this:
Code: | import gtk.TextBuffer;
import gtk.TextIter;
import gtk.TextView;
import gtk.Main;
import gsv.SourceSearch;
import std.stdio;
void main()
{
Main.init(null);
TextView view = new TextView();
TextBuffer buffer = view.getBuffer();
TextIter iter = new TextIter();
TextIter start = new TextIter();
TextIter matchStart = new TextIter();
TextIter matchStart2 = new TextIter();
TextIter matchEnd = new TextIter();
buffer.getIterAtOffset(iter, 0);
buffer.insert(iter, "The text widget can display text with all kinds of nifty attributes. It also supports multiple views of the same buffer; this demo is showing the same buffer in two places.\n\n");
buffer.getStartIter(start);
SourceSearch.forwardSearch(start, "widget", GtkSourceSearchFlags.CASE_INSENSITIVE, matchStart, matchEnd, null);
SourceSearch.forwardSearch(start, "WIDGET", GtkSourceSearchFlags.CASE_INSENSITIVE, matchStart2, matchEnd, null);
assert(matchStart.getVisibleLineOffset() == matchStart2.getVisibleLineOffset());
} |
|
|
Back to top |
|
|
Mitu
Joined: 22 Sep 2009 Posts: 59 Location: Poland
|
Posted: Sun Feb 28, 2010 4:39 am Post subject: |
|
|
So I can't understand it. Your example works, but my function doesn't. Here's the function I wrote and it searches case sensitive...
http://pastebin.ca/1815469 (had to post a link, code caused an error)
I can't get why it doesn't go properly... |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Sun Feb 28, 2010 6:40 am Post subject: |
|
|
The function seem to be working for me.
Make sure the text you are searching for is before/after the cursor for backwards/forward respectively.
I had some problems testing the function but it turned out that because i searched right after the creation of the text view, but then the cursor (the mark returned by getInsert) is at the end of the buffer.
And thus searching forward doesn't find anything, searching backwards from the end it did find the text. |
|
Back to top |
|
|
Mitu
Joined: 22 Sep 2009 Posts: 59 Location: Poland
|
Posted: Sun Feb 28, 2010 2:31 pm Post subject: |
|
|
Awww I got it...
I tested one function, when the error was in the other one. I thought, that it doesn't work because it doesn't highlight occurances and completely forgot, that I've got highlighting in the oter function...
My fault, sorry |
|
Back to top |
|
|
|