Re: Custom TextBuffer

2015-08-30 Thread Sébastien Wilmet
Hi,

On Sun, Aug 30, 2015 at 12:22:36AM -0400, Rena wrote:
 I want to use a TextView to display information as marked-up text.
 This information is generated on the fly and would span millions of
 lines that the user can page through. It seems like the idea would
 just be to subclass GtkTextBuffer to provide my own methods for get
 text in a particular range, but I can't find any information about
 how. I tried providing my own get_text and get_slice methods but
 they're never called. I'm using Python btw.

See this tutorial for GtkTextView:
http://www.bravegnu.org/gtktext/

And see the introduction of GObject:
https://developer.gnome.org/gobject/stable/

For Python and PyGI, there is normally also some documentation.

Cheers,
Sébastien
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: Custom TextBuffer

2015-08-30 Thread Christian Hergert
On 08/29/2015 09:22 PM, Rena wrote:
 This information is generated on the fly and would span millions of
 lines that the user can page through.

Keep in mind that a non-pageable b-tree is used to track various
information about the text so the view has fast access to it.

I don't think GtkTextBuffer can do what you want as a subclass, nor will
it gracefully handle unbound input length. GtkTextIter returns an int
for character offset, so you are at least restricted to 31-bit
addressing (read: 2Gb).

I'd start by trying to open a 1Gb file. That is going to be the trivial
case of your dynamic text generation. If it can't handle that well, then
even if the buffer could dynamically generate content, the view won't
keep up. Keep in mind it needs to size all the text rows so that it can
know about line heights and how big the rendered content would be. (It
does this lazily, but still).

You might want to look at how Vte does it's scrollback. If you don't
need any sort of syntax highlighting or exotic pango layouts or word
wrapping, you might be able to do your own thing. It will be a lot
simpler code if all the line heights are the same anyway.

Good Luck,

-- Christian

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list