Re: GtkSourceView: code folding



On Wed, 2014-08-13 at 17:28 +0200, flix wrote:
#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).

I think MonoDevelop doesn't use GtkTextView anymore, but what you
describe should be feasible with GtkTextView too.

You can apply an invisible tag to "#region " too, besides the two
following lines. You can also apply another GtkTextTag for the styling.

To unfold "My region", you can either have a + button in the gutter, or
handle click events in the GtkTextView to see if the click happens
inside "My region".

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).

Ok, I better understand the reason of using a GtkTextChildAnchor.

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.

With the solution described above, you don't need the
GtkTextChildAnchor.



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