GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Complicated - TextView/Buffer

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
angel face
Familiar Face


Joined: 11 Feb 2008
Posts: 15

PostPosted: Mon Mar 03, 2008 5:37 pm    Post subject: Complicated - TextView/Buffer Reply with quote

Hey everyone.

I have a text view which displays the contents of a file.
When i select/highlight some text, i use the get_selection_bounds() function to get the selected text and then i display the selection in another text view.

what i want to do now is to check wether the selection has characters on either side (i.e is it part of a word?)

for example:
"Hello world"

if "or" is selected, there are characters on either side. any ideas on how to
find this?

here is my code to find the boundary of selected text and store it:


Code: (Plaintext)
1
2
3
4
5

   
gtk_text_buffer_get_selection_bounds (widget->buffer1, &start, &end);   
 selected = gtk_text_buffer_get_text (widget->buffer1, &start, &end, FALSE);
Back to top
Wolfgang
Familiar Face


Joined: 05 Feb 2008
Posts: 37

PostPosted: Wed Mar 19, 2008 8:56 am    Post subject: Reply with quote

Code: (C)
1
2
3
4
5
6
7
GtkTextIter i0, i1;

if (gtk_text_iter_starts_word(&i0) && gtk_text_iter_ends_word(&i1))
{
  ...
  // it's not a part
}

or similar methods
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP