Re: Re: Why GtkTextIter doesn't provide a function to return its byte index? How to retrieve it?

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

 



g_utf8_offset_to_pointer scans the buffer. Too expensive. This is why
I ask why the text iterator doesn't cache the byte index.

Thanks,
Gang

2011/8/11  <ian.liu88@xxxxxxxxx>:
> You can use g_utf8_offset_to_pointer, and then its just a pointer
> arithmetic:
>
> gchar *buffer = ... ;
> gint offset = gtk_tree_iter_get_offset(iter);
> gint index = g_utf8_offset_to_pointer(buffer, offset) - buffer;
>
> Cheers
> Ian L.
>
> On , Gang Chen <gang.chen.cn@xxxxxxxxx> wrote:
>> gtk-text-get-offset() returns the character offset, not byte indexes.
>>
>>
>>
>> 2011/8/10 Ian Liu Rodrigues ian.liu88@xxxxxxxxx>:
>>
>> > gtk_text_iter_get_offset -
>>
>> >
>> > http://developer.gnome.org/gtk/stable/GtkTextIter.html#gtk-text-iter-get-offset
>>
>> >
>>
>> > Ian L.
>>
>> >
>>
>> > On Mon, Aug 8, 2011 at 11:51 PM, Gang Chen gang.chen.cn@xxxxxxxxx>
>> > wrote:
>>
>> >>
>>
>> >> Hi all,
>>
>> >>
>>
>> >> My application has its own text buffer which uses byte indexes to
>>
>> >> index the text. I create a GtkTextBuffer as a mirror of the text
>>
>> >> buffer in order to display the text in a GtkTextView. I need to
>>
>> >> retrieve the byte index of a GtkTextIter but found no such function
>>
>> >> exists. How to?
>>
>> >>
>>
>> >> Thanks,
>>
>> >> Gang
>>
>> >> _______________________________________________
>>
>> >> gtk-list mailing list
>>
>> >> gtk-list@xxxxxxxxx
>>
>> >> http://mail.gnome.org/mailman/listinfo/gtk-list
>>
>> >
>>
>> >
>>
>>
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux