Re: gtk_text_iter_get_char() and g_unichar_isspace()



On Wed, Mar 26, 2003 at 08:37:28AM -0000, martyn 2 russell bt com wrote:
If I have a while loop and I am iterating through a GtkTextBuffer with
gtk_text_iter_forward_char(&iter).  Can I expect
g_unichar_isspace(gtk_text_iter_get_char(&iter)) to work if there is a space
in the text?

That should work, I would think.

Ideally I would use gtk_text_iter_forward_word_ends() and
gtk_text_iter_backward_word_starts() but my delimiters are a form-feed (\f),
newline (\n), carriage return (\r), horizontal tab (\t), and vertical tab
(\v). I found these functions to stop on puncutation marks (such as full
stops etc) which is to be expected. Is there a better way?

You might also consider gtk_text_iter_forward_find_char() which is
more efficient than calling gtk_text_iter_get_char() over and over.

I have noticed gtk_text_buffer_get_char_count(mybuffer) returns a number
less than the number of character I have typed (probably because of the text
encoding). As a result I don't see how checking for a g_unichar_isspace() on
that particular GtkTextIter can work in my situation.  Can anyone enlighten
me?

get_char_count() definitely should correspond to the number of chars
(not bytes) in the buffer; if not, something is wrong.

Havoc



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