FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TextIter, forwardSearch - case insensitive

 
Post new topic   Reply to topic     Forum Index -> gtkD
View previous topic :: View next topic  
Author Message
Mitu



Joined: 22 Sep 2009
Posts: 59
Location: Poland

PostPosted: Tue Feb 02, 2010 11:40 am    Post subject: TextIter, forwardSearch - case insensitive Reply with quote

Is there a version of this function, which ignores case?
Back to top
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Tue Feb 02, 2010 2:40 pm    Post subject: Reply with quote

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
View user's profile Send private message
Mitu



Joined: 22 Sep 2009
Posts: 59
Location: Poland

PostPosted: Sat Feb 06, 2010 1:47 pm    Post subject: Reply with quote

Unfortunately, still searches case sensitive.

gtkD version 1.2. Was there such a bug?
Back to top
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Sun Feb 07, 2010 8:58 am    Post subject: Reply with quote

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
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Sun Feb 07, 2010 10:10 am    Post subject: Reply with quote

works for me.
Back to top
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Wed Feb 10, 2010 3:41 pm    Post subject: Reply with quote

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
View user's profile Send private message
Mitu



Joined: 22 Sep 2009
Posts: 59
Location: Poland

PostPosted: Sun Feb 28, 2010 4:39 am    Post subject: Reply with quote

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
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Sun Feb 28, 2010 6:40 am    Post subject: Reply with quote

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
View user's profile Send private message
Mitu



Joined: 22 Sep 2009
Posts: 59
Location: Poland

PostPosted: Sun Feb 28, 2010 2:31 pm    Post subject: Reply with quote

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 Embarassed
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> gtkD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group