Folding is primarily used with block structured languages. In addition to colorization, the language lexical analyzer (lex analyzer) performs fold point calculations. It scans the text for keywords or characters that indicate statement blocks.
The line introducing a statement block is marked as a fold point. The following lines through to, and sometimes including, the line where the block ends are linked to the fold point header line. Statement blocks can have other statement blocks embedded inside them.
Programming languages like C and C++ use brace characters ({ }) to mark the extent of statement blocks. The JADE language uses matched pairs of keywords (for example, the
Some languages (including JADE) support the following styles of fold calculation (selected by using the named attribute fold.compact). See also the setNamedAttribute method.
NORMAL
The fold point is placed on the line containing the end of the header statement. For an
The lines that can be hidden by using this fold point extend to, but do not include, the line that contains the matching block terminator word (for example,
COMPACT
The fold point is placed on the line containing the first word of the instruction (for example,
A fold point can be in two states, as follows.
Expanded, in which the text lines of the statement block are visible. Blocks embedded inside this block can be independently expanded or contracted.
Contracted, in which the text lines of the statement block are all hidden, including the lines in embedded blocks.
A fold point can optionally have a horizontal line drawn above or below it, to indicate its current state. The suggested setting for a fold point (used by the JadeEditor class) is a line drawn below a contracted fold point (foldFlags := 16).
The fold point symbols drawn in the fold margin can be completely customized, by using the setLinemarkAttributes method to modify the attributes of linemarks in the range 25 through 31.
Use the foldSymbols property to select one of the four available sets of fold point markers. The symbol set represented by the SC_FOLDSYM_TREESQUARE constant is recommended.
To contract and expand fold points:
Use the mouse in the fold margin
Press Ctrl+* (the asterisk on the numeric keypad).