Setting Display Modes

You can set preferences for the display of source code in the editor window.

This section contains information on:


Formatting and Coloring Source Code

You can format source code by indenting source-code lines. Indentation is performed differently for sources created in reporting mode than for sources created in structured mode. In addition, you can color syntax elements for better readability. Syntax coloring is set on by default. However, you can change the default color definitions or switch syntax coloring off.

Start of instruction setTo format source code

  1. Place the cursor anywhere in the source code.

  2. From the Edit menu choose Format Source.

    Or:
    Choose the following toolbar button:

    graphics/pgm_win_format.png

    Or:
    In the command line, enter the following system command:

    STRUCT

    See also STRUCT in the System Commands documentation.

    The lines in the source code are indented.

Start of instruction setTo change syntax coloring

  • Change the default color settings by using the Colors editor option, or switch Syntax coloring off as described in Program Editor Options in the Using Natural Studio documentation.

Showing and Hiding Source Code

You can show (expand) or hide (collapse) logical blocks of source code to improve readability and maintainability of objects with complex code structures. When a block of source code is collapsed, all of the lines of source code between the block begin statement and block end statement are hidden, including any other nested blocks if they are part of the chosen block. Hidden blocks retain their collapsed or expanded status.

Expanding and collapsing code blocks only applies to object sources that were created in structured mode.

Code blocks that can be expanded or collapsed are, for example, DEFINE DATA blocks, REPEAT blocks, IF THEN ELSE blocks, READ blocks, and blocks of two or more consecutive comment lines.

When scanning source code, collapsed blocks can be excluded from the search. For more information, see Finding Text.

When you are searching for a line number in source code that is part of a collapsed block, the block is expanded to display the line. For more information, see Going to a Line Number.

If you want to expand and collapse code blocks, you need to set the appropriate editor option referenced in the instructions below.

Start of instruction setTo expand and collapse single code blocks

  1. Set the Expand/Collapse editor option as described in Program Editor Options in the Using Natural Studio documentation.

    When the Expand/Collapse option is set, an expand/collapse toggle ( or ) appears as shown in the example below:

    The toggle indicates the first line of an expanded block.

    Each block is marked with a vertical line that goes from the begin statement (here, for example: DEFINE DATA) to the end statement (here: END-DEFINE).

    The gray vertical bar in the column next to the source-line numbers indicates the current block (here: REPEAT) which depends on the logical relationship of the statement where the cursor is positioned. In the example above, the cursor is positioned in the INPUT statement line which belongs to the REPEAT loop. (IF and the READ are separate nested loops.)

    The toggle indicates the first line of a collapsed block.

  2. Click on the toggle to expand the block or click on the toggle to collapse the block.

    Or:
    To expand a block and insert a line:

    Place the cursor in the first position of a toggle line and press SHIFT+ENTER to expand the block and insert a line above the expanded block.

    Place the cursor in the last position of a toggle line and press SHIFT+ENTER to expand the block and insert a line below the expanded block.

    If you place the cursor in the first or last position of a toggle line and choose ENTER, a line will be inserted above or below the collapsed block but the block will not expand.

    Or:
    Position the cursor within a line that contains the toggle or and, from the View menu, choose Expand/Collapse or choose the following toolbar button:

    graphics/pgm_win_exp_collapse.png

Start of instruction setTo expand or collapse all code blocks

  • From the View menu, choose Expand All or Collapse All.

    Or:
    Choose either of the following toolbar buttons:

    graphics/pgm_win_expand_all.png (Expand All) or graphics/pgm_win_collapse_all.png (Collapse All).

Splitting the Editor Window

You can split the program editor window vertically or horizontally to view and modify two different parts of the object simultaneously. This feature saves you the trouble of printing an object source to view two different sections simultaneously. Changes made in one section are made simultaneously in the other section.

You can jump between split windows.

Start of instruction setTo split the editor window into two sections

  1. From the View menu, choose Vertical Split or Horizontal Split.

    Or:
    Choose either of the following toolbar buttons:

    graphics/pgm_win_split_v.png (Split Vertical) or graphics/pgm_win_split_h.png(Split Horizontal)

    The mouse pointer changes to a split pointer.

  2. Drag the line to the left/right or up/down to the position you want by either moving the mouse or using the arrow keys.

  3. Freeze panes by either clicking the left mouse button or pressing the ENTER key.

    The screen is split into two sections, each displaying the same information. You can now scroll each section individually and edit both sections as if they were part of the same object (as indeed they are).

Start of instruction setTo exit split-editor mode and return to a single screen

  • From the View menu, choose Unsplit.

    Or:
    Choose the following toolbar button:

    graphics/pgm_win_unsplit.png

    Two editor sections are transformed into one.

Start of instruction setTo jump between split screens

  • Place the mouse pointer in the required screen section and click.

    Or:
    Press F6.

    The cursor moves from one screen section to the other.