Script Editor


To create and edit scripts, Mira integrates a script editor derived from the Scintilla Source Editing Component. The editor provides context highlighting as well as full editor functionality such as cut/copy/paste, line numbering, formatting, etc. Context highlighting uses different formatting such as fonts and color to display different parts of the script syntax.

The picture below shows a typical script displayed in the Mira Script Editor. In this script you can see various elements of the Lua language and Scintilla formatting styles available in Mira. The various format styles are labeled. These are the default settings for the Pro Script module, but you can alter them at any time.

The toolbar on the top margin of the Script Editor has buttons for common actions, including for executing the script. The toolbar buttons are otherwise standard buttons for Windows software, and they have their usual functions.

Note

To run the script using data in the top-most window, use the button on the Main Toolbar. This button attaches the currently open script window to the Image window or Plot window that is top-most. The top-most window is attached from the script using the CImageView:Attach() or CPlotView:Attach() method.

Menu Commands

When the Script Editor is the active document window in Mira, it loads its own menu bar containing relevant commands. Many of the commands in these menus are are common to all text editors, such as cut, copy, and paste commands. Other features are described in the following table.

View Menu Commands

Word Wrap

Check this option to wrap long lines to the right Editor margin.

Line Numbers

Check this option to show line numbers in the gray margin on the left edge of the Editor window.

Bookmark Margin

Check this option to show bookmarks in a gray book mark margin on the left edge of the window. This margin is different from the Line Number margin.

Folding Margin

Check this option to show a Text Folding margin on the left edge of the Editor window. This margin shows a special symbol that you can click to toggle between folded text and normal text.Folding allows you to show only the beginning of block structures such as for orwhile loops.

Initialize Styles

Click this command to reset to default values all syntax styles (see topic below). This is normally useful only if you have changed all the syntax styles in a way that makes the script unreadable. After initializing the styles you will need to recreate your special styles as described below.

Toolbar

Click this command to toggle the Script Editor Toolbar on and off.

Preferences

Opens the Mira Preferences dialog.

 

Syntax Styles

The elements of a script include regular text for function calls, values, etc., as well as keywords of the Lua language, comments, and strings. Each of these syntax components may be highlighted to make it easier to distinguish from the other components. The Script Editor processes each character you enter and formats it accordingly if it matches one of the syntax rules. For example, when one dash, -, is typed, it appears as regular text. But typing a second dash to make '--' begins a comment, which is immediately highlighted in the comment style. The default for comments uses the Comic Sans font in italic form as shown above. The default settings shown above are described in the table below.

Default Syntax Highlighting

Language keywords

Arial font, blue, normal weight.

Normal Text

Arial font, black, normal weight.

Numbers

Same font as Normal Text, bold, yellow background.

Strings

Arial font, red, normal weight.

Comments

Comic Sans font, green, normal weight.

 

To Change the Syntax Format:
  1. Move the Editor caret (its cursor) onto an example of the syntax element you want to change. You can do this using the mouse or arrow keys.

  2. Right click inside the editor window to open its Context Menu.

  3. In the central section of the context menu, under Set Current Style:, click on Font, Color, or Background to change that element. The change will appear immediately in this Editor window.

  4. Changes you make are saved and will also apply to all future Script Editor windows.

Printing Scripts

To print a script, use the standard method of File > Print or the button. There are two very useful options in the View menu that are described in the following table.

Script Printing Options

Print Syntax Styles

This option controls how your font and color styles will print:

  • Check this option to include the current syntax coloring in your printed script.

  • Uncheck this option to print the entire script in black.

If checked and you print on a non-color printer, the syntax coloring is converted to gray shades.

Print Wrapped Lines

This option controls how long lines are handled by the printer:

  • Check this option to wrap long lines to the printing margins.

  • Uncheck this option to allow long lines to extend beyond the right page margin.

This setting does not affect the view in the Script Editor window.

 

Related Topics

Working with Scripts, Script Manager, Running Scripts