Re: GtkTextBuffer: Q: offsets to indicies?



On Tue, 06 Aug 2002 14:25:20 +0200 "Olivier Sessink"
<olivier lx student wau nl> wrote:


My problem is the handling of multibyte characters. I need to be able
to somehow convert an integer offset in the GtkTextBuffer into a index
(somthing a. la. gtk_text_buffer_get_iter_from_index). But I cannot
find such a function?

this is my function:

glong utf8_byteoffset_to_charsoffset(gchar *string, glong byteoffset) {
      return g_utf8_pointer_to_offset(string, &string[byteoffset]);
}

hmm today I was profiling my syntax highlighting, and I found that 90% of
the CPU time was spent on this function, is there a faster way of doing
this??

my syntax highlighting is based on regular expressions, so it returns
offsets in bytes, but to set a tag in the widget I currently use
gtk_text_buffer_get_iter_at_offset(doc->buffer, &itstart, istart);
which uses character offsets, and not byte-offsets.

regards,
        Olivier

Attachment: pgpmfwincZWfN.pgp
Description: PGP signature



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