Previous Thread
Next Thread
Print Thread
Code Folding #28819 13 Jul 17 09:38 AM
Joined: Oct 2015
Posts: 230
S
Stuart Offline OP
Member
OP Offline
Member
S
Joined: Oct 2015
Posts: 230
I would be interested in trying to implement some form of code folding. As there is no 'standard' for how programs have been or are written, this would necessitate a custom folding option with a user defined marker.

I believe this should be possible, probably with a bit of Python code as a plugin.

However, whilst there is mention of code folding there appears to be very little documentation on this feature, particularly with regard to setting up any form of customised markers.

Does any one have any pointers that you could offer to give me a start point please?

Re: Code Folding #28820 13 Jul 17 11:07 AM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
This has been on my to-do list for quite some time. Part of the problem is that there are various approaches, and none of them are well documented. But I think the "most correct" approach is to write a proper Scintilla lexer for ASB. (Scintilla is the actual editor underlying APN.) Here's an example of the kind of short description you can find online: How to Write a Scintilla Lexer .

The strong implication is that it has to be written in C++ and linked directly to the exe. On the other hand, according to this article on the Scintilla web site you can also write one in the script language Lua. But, the linking mechanism described doesn't seem quite compatible with PN2, which although it wraps around Scintilla, has a different packaging mechanism than Scite (which is the code editor created as a working example of Scintilla by the Scintilla people. It, however, is just an editor and lacks much of the project management and other IDE aspects of APN, which is why we chose PN2 rather than Scite as the basis for APN. The downside is that the Scintilla-related extension techniques used by Scite are not always applicable).

Currently we are using the generic lexer mechanism, customized with the asb.schemedef and additionalLanguages.conf files. But that scheme configuration doesn't contain enough information to support folding.

There are a couple of dozen lexers already linked in, for a variety of languages. So in theory the plan would be to find one that is most like ASB and use it as a starting point. But it's not obvious which one to use, as none of the languages seem quite like ASB, and most of the examples have been written by different people, to varying levels of completeness, with different approaches, etc.

Aside from coding the lexer, the other challenge is figuring out how to add it to the set of available languages so that it not only compiles and links into the overall exe but that it gets called appropriately when ASB is selected. I'm sure it's doable, but it may be a bit of an adventure.

So, unfortunately, although I would welcome the idea of someone else writing an ASB lexer so that we can take advantage of code folding, I'm not sure how practical it would be, as there is no easy way to work on it without being able to recompile and relink the entire package. (And I fear your boss and/or your customers may find that to be too much of a distraction from your real job.)


Powered by UBB.threads™ PHP Forum Software 7.7.3