Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement code folding in C#

Tags:

c#

folding

vsx

I'm beginning to work on a COBOL/BASIC IDE at work (to replace the one that we have currently that's a slight step up from Notepad). It'll be made in C#. The management is really interested in implementing some Visual Studio type features, and a big one is code folding. I've looked on MSDN, but I didn't see any good way to collapse lines (or to add the expand/collapse buttons).

I'm assuming that the text area should be a RichTextBox. Am I off track here? I suppose it could be done with some sort of modified TreeView, but that seems a little wrong to me. Is there some way of doing this that I'm just missing?

like image 224
ctoneal Avatar asked Nov 27 '22 23:11

ctoneal


1 Answers

Why not use an existing IDE and extend it? Writing one from scratch is a huge undertaking (you need a parser, lexer, syntax highlighter and more), and is even more complicated if you need to support multiple languages (you mention COBOL and Basic).

Notepad++ has syntax coloring and one can add languages to it - COBOL is one of the ones installed by default. It supports code folding and has many plugins (you can write your own, that will suit your needs).

Edit: Eclipse is another excellent IDE that has similar support, and as mentioned in the comments has a COBOL plug-in.

like image 109
Oded Avatar answered Nov 30 '22 11:11

Oded