Re: GtkTextBuffer: Q: offsets to indicies?



On Wed, 07 Aug 2002 20:45:48 +0200
"Janus N. Tøndering" <j nus person dk> wrote:


I had the same problem. My current solution is to cache the offsets
already found. You could do something like this

int start = g_utf8_pointer_to_offset(data+last_index, data+t->start) +
last_offset;

where last_index is set to the byte index at the last call of
g_utf8_pointer_to_offset and last_offset is set to the char offset at
the last call of g_utf8_pointer_to_offset. This should make it a whole
lot faster.

it is indeed a bit faster, but still with this function my highlighting
engine is spending 30% of it's time to convert byte offsets to UTF8
offsets. 

Why is there no simple way to set a GtkTextIter to a byteoffset in the
text? It can be done per line (the function gtk_text_iter_set_line_index()
does exist!?) so why no gtk_text_iter_set_index() function?

regards,
        Olivier

Attachment: pgp4naCdaa9YA.pgp
Description: PGP signature



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