[MonoDevelop] code folding

Michael Hutchinson m.j.hutchinson at gmail.com
Thu Jan 24 10:59:40 EST 2008


On Jan 24, 2008 5:55 AM,  <silk at boktor.net> wrote:
> * Joaquin Fernandez Campo <jfcampo at gmail.com> [2008-01-23 23:55]:
>
> > Hi!
> > yesterday i was looking through the mono-develop source code and i couldn
> > fin what i was looking for. I
> > am looking for the source code of the editor because i want to try to
> > implement code folding nothing serious
> > just something i want to try to do on my spare time, more like a hobby. Can
> > somebody tell me which part of the source code
> > is the text editor source?
>
> MD is as for now using GtkSourceView as it's editor, so you won't find
> code for text editor in MD sources :)

However, there's still our wrapper code, in
src/addins/MonoDevelop.SourceEditor. It's entirely feasible to
implement code folding on top of the existing editor widget.

The GtkSourceView widget subclasses the GTK TextView widget, and
essentially just adds/removes tabs to set the text colour. In a
similar vein, you could add code that would simply add "Hidden"
TextTags to hide the text in the folded regions. This has been
possible in theory since we started using GTK+ 2.8 instead of 2.4, but
it was too close to the beta cycle for anyone to implement this
feature. The harder bit is drawing the folding markers in the margin
of the text editor.

Note that the C# parser already extracts folding region information
from the code.

> There is work in progress to use GtkSourceView2, it is the work of Michael
> Hutchinson IIRC, you can look at it if you want to try. GtkSourceView2
> is supposed to support folding AFAIK

No, sadly GtkSourceView2 doesn't support folding. There's been a patch
for GtkSourceView in GNOME Bugzilla for well over a year, but it
didn't make it into the 2.0 release. It pretty much implements what
I've described above.

The GtkSourceView2 branch of the editor is in src/addins/SourceEditor2
(NOT src/addins/MonoDevelop.SourceEditor2 -- that's the new managed
editor binding). it pretty much complete but doesn't support printing
or bookmarks, as those features were removed for GtkSourceView2.
However, they're back in 2.1...

As Ben pointed out in a follow-up email, the managed text editor will
have folding. However, it won't be stable for some time.

-- 
Michael Hutchinson
http://mjhutchinson.com


More information about the Monodevelop-list mailing list