Re: GtkSourceView: code folding



On 08/12/2014 04:28 PM, Sébastien Wilmet wrote:
What do you call "zooming" in the context of code folding? With a custom gutter renderer you can draw also a vertical line below the + buttons, to show where the "foldable" region stops (like Scintilla does). Or you can draw different background colors, like Qt text editors do.
Well, actually, I just meant that when I zoom the editor (through CTRL+mouse wheel), the icons in the gutters can grow and shrink themselves (not a big deal after all).

I don't follow you, what is a free collapsable region? A block beginning and ending in the middle of a line? If so, is the code folding really useful for such blocks? Btw, the code folding is still not implemented in GtkSourceView or gedit because we don't think it is a really useful feature. Having the structure of the file in the side panel is more useful in my opinion. Like the list of functions, or the list of chapters, sections, etc of a LaTeX document.
A free collapseble region in C# (but can be generalized) is:

#region My region
some code here
#endregion

And when collapsed it should look like:

My region

(well, with a tiny frame around it and a different background and foreground color)
MonoDevelop does it: that's a proof that Gtk# can make it).

The default undo manager can be improved to handle correctly non-text elements. If you really need this, you can file a bug on bugzilla. But using a GtkTextChildAnchor for the code folding seems like a hack to me. Especially with a GtkLabel inside it, since it can easily be replaced by normal text in the GtkTextBuffer.
Yes: that's another solution I was thinking about. Anyway by using buffer->get_text() we get wrong code using normal text in the GtkTextBuffer: that's why TextChildAnchor seems a better solution to me (furthermore I can use: tooltips, on_click events and a different mouse icon on them, but maybe that can be done with custom tags too, I don't know).

However the main issue to me remains the handling of the undo stack. In either case it contains child anchor characters (gunichar 65532), or extra characters if we use normal text.

That's the part I can't fix.



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