The EGL editor

The EGL code editor looks and works like a standard text editor or code editor for other languages, but it has additional features to help you edit EGL code. The code editor highlights invalid syntax, provides an explanation for problems in the code, colors keywords, strings, and comments, and helps you write EGL code.

The basics

You can open an EGL source file in the EGL editor either by double-clicking it in the Project Explorer view or by right-clicking it and then clicking Open with > EGL Editor.

The editor uses many of the same editing functions as the other text and code editors in the workbench:
  • Cut, copy, and paste code with commands in the Edit menu.
  • Save the current file by pressing CTRL+S, clicking the Save button on the toolbar, or clicking File > Save.
  • Generate the current file by pressing CTRL+G or right-clicking the file in the Project Explorer view and then clicking Generate.
  • Undo your most recent change by pressing CTRL+Z or by clicking Edit > Undo.
  • Switch between open files, by clicking the tabs at the top of the editor.
  • Locate the file in a different view by clicking Navigate > Show In and then click Project Explorer, Outline, or Navigator.
  • To indent or outdent code, select one or more lines, right-click, and then click Shift Right or Shift Left.
  • To comment or uncomment one or more lines of code, select one or more lines, right-click, and then click Comment or Uncomment.
Some functions of the editor require that you select one or more lines of code (sometimes referred to as a block of code). You can select code in any of these ways
  • Click and drag the mouse over one or more lines of code.
  • Double-click a single word to select that word.
  • Put the cursor at the beginning of a code block, hold the Shift key, and use the arrow keys to move the cursor to the end of the block. Also, you can double-click at the beginning or end of a code block to select the entire code block.
  • Press Ctrl+A to select the entire file.

You can control how EGL code is displayed in the editor. See Setting preferences for EGL text.

Writing code faster

The main tool that the EGL editor provides to speed up code development time is code assist. Code assist searches for valid keywords, variables, or part names that begin with the first few characters that you type and the matching code. To activate code assistance, press CTRL+Space and choose a keyword, variable, part, or function from the list of options. You can also type the first few characters of a keyword, part, or variable to filter the list. See Content assist.

Code assist can also insert larger code templates into your code, such as a framework for a part. See Code templates.

The editor also includes wizards that can generate EGL code into the file you are editing. For example, the DataItem part source assistant can help you set the properties for a DataItem part. See Editing DataItem parts with the source assistant.

When declaring a variable or in other cases, you are sometimes required to specify a function name as the value of a property. In the workbench, you do not need to type the skeletal function. Instead, you can specify the function name by right clicking the statement and either clicking Create Functions or pressing Ctrl + 2.

Getting help

The editor provides dynamic help for most EGL keywords. To activate dynamic help, highlight an EGL keyword, such as package, and press F1. Additionally, the F1 key provides dynamic help when you are in most EGL-related wizards and windows.

Organizing code

The EGL editor can help organize your import statements. To organize import statements, right-click in the editor and then click Organize Imports. The editor changes your import statements in the following ways:
  • The editor arranges the import statements in the order specified in the Organize Imports preference page. See Setting preferences for organizing import statements in the EGL editor.
  • The editor removes any unused import statements.
  • The editor combines multiple import statements to the same package into a single import statement with a wildcard character, based on the settings in the preference page.
  • The editor attempts to add import statements for any parts that are used in the file but are not in scope.

With the editor, you can also "fold" code. Folding a block of code hides that code temporarily, so that you can see only the parts of the source file that you want to see. To fold a block of code, click the minus icon on the left side of the editor; the code collapses temporarily. You can also fold arbitrary lines of code by selecting them, right-clicking, and then clicking Fold Text. Click the icon again to restore the code. Folding does not change the behavior of your code in any way.

Depending on the folding preference settings, certain blocks of code may be folded automatically when you open a source file in the editor. See Setting preferences for folding in the EGL editor.

Organizing used forms

The EGL editor can help organize your use statements that reference form groups. To organize use statements for form groups, right-click in the editor and then click Organize Used Forms. The editor changes your use statements in the following ways:
  • If you have a use statement for form groups, Organize Used Forms converts it to a use statement for forms and lists only the forms that the program uses.
  • If you have a use statement for forms, Organize Used Forms reviews the use of forms within the program and removes any forms from the use statement that are not actually used by the program.
  • Form names are placed in alphabetical order.

Customizing the EGL editor

The formatting preferences affect how the code is formatted in the editor, including what characters and how many characters to use for indentation, whether to use upper or lower case for keywords, and how much white space to include in the source code.

You can create one or more EGL editor profiles using the EGL Editor Formatter preference. There are two formatting profiles defined within EGL:
  • EGL [build in]
  • VA Gen [build in]
You cannot change the formatting preferences within these two profiles or remove these profiles. Any profile that you create is added to the list of available profiles. You can change or remove any profile that you create.

See Setting preferences for formatting in the EGL editor for defining editor profile preferences.


Feedback