code folding

BNig bernd.niggemann at uni-wh.de
Sun Sep 18 16:17:26 EDT 2016


This is for the adventurous of the community. Some file swapping involved.
I modified the Script Editor of Livecode 8.1.0 stable to allow basic code
folding. This is experimental so you should not try this on your valuable
work, only on copies.
I tested it and did not have any data loss but still, who knows.

What this modification does is to add in the Script Editor on right-click
some options to the popUp menu.

"fold-Unfold"
This option is enabled if you right-click on a line that is either the begin
of a handler, a if structure, a repeat structure, a switch structure or a
case structure.
It will fold these, right clicking on the underlined begin of the folding
will unfold that structure.
if you unfold a handler that has folded substructures it will unfold all,
the handler and the substructures.

"Fold All"
this forces a compile and will fold all handlers in a given script. Can be
applied on top of "fold-Unfold"

"Unfold All"
this will unfold all folded structures.

When going into debug mode all folding will be unfolded. Returning to edit
mode will leave the script unfolded.

When folding a structure the line numbers will reflect the folding, i.e.
will omit the folded line numbers

However, in case you use the red dot to mark a breakpoint the position of
that red dot will be wrong, although it will trigger in the debugger.



The modifications are in those two files:
revseeditorbehavior.livecodescript
revsegutterbehavior.livecodescript

on a Mac the are located in:
Contents/Tools/Toolset/palettes/script
editor/behaviors/revseeditorbehavior.livecodescript
Contents/Tools/Toolset/palettes/script
editor/behaviors/revsegutterbehavior.livecodescript

You have to have write permissions to replace those files. 

On a Mac you right click on your copy of Livecode 8.1.0 stable and choose
"show content" then navigate the path and right click on the files and
choose "Inforation"
There change your permissions to read write.

Then you can swap the files. Maybe it is a good idea to move the
unaltered/original files to a different place from where you can move them
back into their folder if you want to undo the modification of the app.

This is rather basic code folding not really integrated into the IDE, just
bolted on. But if it works it might find its way into the IDE.

To get the files download them zipped from 

http://berndniggemann.on-rev.com/fold/foldcode.zip

Kind regards

Bernd




--
View this message in context: http://runtime-revolution.278305.n4.nabble.com/code-folding-tp4708589.html
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the use-livecode mailing list