Re: GtkSourceView: code folding



First of all, thank you for your quick reply.
A probably better solution is to implement the code folding as every other text editor do: show +/- buttons in the margin. See GtkSourceGutter. I've implemented a prototype of a gutter renderer for code folding: https://git.gnome.org/browse/gtksourceview/log/?h=wip/gutter-renderer-folds Ideally an API for the code folding should be created in GtkSourceView, but having first a working implementation in an application would be a good first step. See also this utility class, which is useful to store the folding points (it is a private class): https://git.gnome.org/browse/gtksourceview/tree/gtksourceview/gtksourcemarkssequence.h Regards, Sébastien

Well, yes, actually I've already made the gutter part myself and it's working great (zoom included). Initially I just used the default implementation Gsv provides for Gsv::Mark icons (by swapping a 'collapsed mark' with an 'expanded mark' to change state): it worked, but with a custom gutter rendered I managed to use just one mark (extended to contain the folding state) for both states, and to make zooming work in the gutter icons too.

However the main problem of my post is that the TextChildAnchor is necessary if we want to handle collapsed regions properly (for example for saving all the possible space, or to implement free collapsable regions, like in C#): otherwise we can just make bad looking regions (like the Scintilla Editor do, together with many other editors that are commonly used on Linux).

That's why my primary issue is to find out how to remove obj characters (TextChildAnchors in my case, but Pixbufs inside text too) from the undo stack.

P.S. Now I can build a custom UndoManager properly in GtkSourceViewmm (I had to derive from Glib::Object as well and to add something like: Glib::ObjectBase(MyUndoManager) in the ctr initialization list). I'll see if creating a custom undo stack is too complicated for me or not...

Thanks for the links: I'll check them out.




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