Code Folding Query

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
gwgs
Posts: 87
Joined: Tue Nov 21, 2006 6:30 pm
Location: Auckland

Code Folding Query

Post by gwgs »

Is there a way to fold code to a specified level with one mouse click or keyboard function?
eg
fold all the def level code, but not the class level folding

from:

Code: Select all

class xyz:
    def abc(self):
          code
          code

    def def(self):
          code
          code
to:

Code: Select all

class xyz:
   def abc(self): ...
   def def(self): ...

Thanks in advance

Grant
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Hi Grant,
Is there a way to fold code to a specified level with one mouse click or keyboard function?
There is no function or feature in Zeus that does this, but it should be fairly easy to implement as a Zeus script ;)

The pseudo code for the macro script would be something like the following:

Code: Select all

Save the current cursor details

Get the text for the current line

Calculate the whitespace indent level for the current line

For all the lines in the current document
   If line has the same indent level

        Move the cursor to this line

        Call the FoldingLineClose or FoldingLineOpen function to open/close the fold
   End If
End for

Restore the saved cursor details
NOTE: The FoldingLineClose and FoldingLineOpen are keyboard function that open and close the folds for the current line.

For more information on how to write such a script refer to the Zeus help and search for the Builtin Functions topic in the index.

Also there are lots of scripting examples in the zScript folder ;)

Cheers Jussi
Post Reply