Web lists-archives.com

Re: Developing a new text editor widget?




On Sun, Jun 05, 2016 at 03:15:30PM -0400, Rena wrote:
> As an application developer, my main gripes with GtkTextView have been:
> 
> 1. The view/buffer model. I expected that the view just asks the buffer for
> text, and I could supply a custom buffer object that generates text on the
> fly. In reality it seems I have to use a GtkTextBuffer and fill it with the
> text I want to display, and manually respond to cursor movements by
> modifying the buffer. It rather defeats the purpose of having a view/buffer
> model at all.

The view is not the only user of a buffer. There can be scanners that
scan the buffer, to do various things such as highlighting the syntax.
The buffer/view split permits in theory to have several views for the
same buffer. Lazy loading of the buffer content is something separate.

> 2. Difficult to compute how much text will actually fit in the view, when
> varying character sizes (especially heights) are involved. This relates to
> #1, since I'm not putting text into a view, I'm putting it into a buffer
> which doesn't know much about how the view is going to render it. This
> makes it difficult to know how much text I need to supply. (I can usually
> get away with over-estimating and supplying more than enough, but then when
> the cursor is moved down at the bottom of the view, it wants to scroll, so
> I have to handle that... also I hadn't even thought until now about what
> "select all, copy" will do in this case.)

I don't think GtkTextBuffer was meant to be used like that, despite its
name.

> 3. No way to control the positioning of text and/or movement of the cursor.
> When implementing a hex editor widget, I wanted to display data in a format
> like "00000000__00_00_00_00__00..." (where _ is a space), but have the
> cursor skip over the spaces. I could find no way to achieve this except by
> (again) manually handling all cursor movement events, trying to figure out
> what the best valid position is for where it's trying to go, and putting it
> there. I had hoped I could either tag the spaces to say "have the cursor
> skip over this", or add a "margin-right" attribute to the digits like I
> would in a web page, so that spaces would be added without using an actual
> space character. (Although in the latter case I'd have to have a custom
> "copy" handler that renders the text *with* spaces for the clipboard, so
> that might not be so good either.)

I think it's possible to implement virtual spaces with a utility class.
It's probably not straightforward, but it should be feasible. I also
need virtual spaces in gCSVedit:
https://sourceforge.net/projects/gcsvedit/

--
Sébastien
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-devel-list