Sign in Join
FPDoc Onlineexperiment

Editing text

In this section, the basics of editing (source) text are explained. The IDE works like many other text editors in this respect, so mainly the distinguishing points of the IDE will be explained.

Insert modes

Normally, the IDE is in insert mode. This means that any text that is typed will be inserted before text that is present after the cursor.

In overwrite mode, any text that is typed will replace existing text.

When in insert mode, the cursor is a flat blinking line. If the IDE is in overwrite mode, the cursor is a cube with the height of one line. Switching between insert mode and overwrite mode happens with the key or with the key.

Blocks

The IDE handles selected text just as the Turbo PascalIDE handles it. This is slightly different from the way e.g. Windowsapplications handle selected text.

Text can be selected in 3 ways:

  1. Using the mouse, dragging the mouse over existing text selects it.

  2. Using the keyboard, press to mark the beginning of the selected text, and to mark the end of the selected text.

  3. Using the keyboard, hold the key depressed while navigating with the cursor keys.

There are also some special select commands:

  1. The current line can be selected using .

  2. The current word can be selected using .

In the Free PascalIDE, selected text is persistent. After selecting a range of text, the cursor can be moved, and the selection will not be destroyed; hence the term ’block’ is more appropriate for the selection, and will be used henceforth...

Several commands can be executed on a block:

  • Move the block to the cursor location ().

  • Copy the block to the cursor location ().

  • Delete the block ().

  • Write the block to a file ().

  • Read the contents of a file into a block (). If there is already a block, this block is not replaced by this command. The file is inserted at the current cursor position, and then the inserted text is selected.

  • Indent a block ().

  • Undent a block ().

  • Print the block contents ().

When searching and replacing, the search can be restricted to the block contents.

Clipboard, copying and pasting

The IDE has its own clipboard, which is independent of the operating system’s clipboard. The Cut, copy and paste commands operate with this internal clipboard. Selected text in the Clipboard window (accessible via ) can be pasted into other parts of the IDE that accept text input.

To access the OS clipboard, use commands from the menu and . If interaction with the OS clipboard is not supported, these menu options will not be visible.

The default shortcut keys for cut, copy and paste are , and , respectively. On Linux, the and may not be available to the IDE without special terminal configuration (see appendix Terminal emulator configuration examples).

It is possible to activate shortcut keys , and for cut, copy and paste commands (section The IDE). In this case, the default functionality of these shortcuts will be overridden.

Setting bookmarks

The IDE provides a feature which allows the setting of a bookmark at the current cursor position. Later, the cursor can be returned to this position by pressing a keyboard shortcut.

Up to 9 bookmarks per source file can be set up; they are set by (where number is the number of the bookmark). To go to a previously set bookmark, press .

Remark: Currently, the bookmarks are not saved when the IDE is exited. This may change in future implementations of the IDE.

Jumping to a source line

It is possible to go directly to a specific source line. To do this, open the goto line dialog via the menu.

In the dialog that appears, the line number the IDE should jump to can be entered. The goto line dialog is shown in figure [fig:gotoline].

Syntax highlighting

The IDE is capable of syntax highlighting, i.e. the color of certain Pascal elements can be set. As text is entered in an editor window, the IDE will try to recognize the elements, and set the color of the text accordingly.

The syntax highlighting can be customized in the colors preferences dialog, using the menu option . In the colors dialog, the group "Syntax" must be selected. The item list will then display the various syntactical elements that can be colored:

Whitespace

The empty text between words. Note that for whitespace, only the background color will be used.

Comments

All styles of comments in Free Pascal.

Reserved words

All reserved words of Free Pascal. (See also Language Reference).

Strings

Constant string expressions.

Numbers

Numbers in decimal notation.

Hex numbers

Numbers in hexadecimal notation.

Assembler

Any assembler blocks.

Symbols

Recognised symbols (variables, types).

Directives

Compiler directives.

Tabs

Tab characters in the source can be given a different color than other whitespace.

The editor uses some default settings, but experimentation is the best way to find a suitable color scheme. A good color scheme helps in detecting errors in sources, since errors will result in wrong syntax highlighting.

Code Completion

Code completion means the editor will try to guess the text as it is being typed. It does this by checking what text is typed, and as soon as the typed text can be used to identify a keyword in a list of keywords, the keyword will be presented in a small colored box under the typed text. Pressing the key will complete the word in the text.

There is no code completion yet for filling in function arguments, or choosing object methods as in e.g. the Lazarus or DelphiIDEs.

Code completion can be customized in the Code completion dialog, reachable through the menu option . The list of keywords that can be completed can be maintained here. The code completion dialog is shown in figure [fig:codecomp].

The dialog shows in alphabetical order the currently defined keywords that are available for completion. The following buttons are available:

Ok

Saves all changes and closes the dialog.

Edit

Pops up a dialog that allows the editing of the currently highlighted keyword.

New

Pops up a dialog that allows the entry of a new keyword which will be added to the list.

Delete

Deletes the currently highlighted keyword from the list.

Cancel

Discards all changes and closes the dialog.

All keywords are saved and are available the next time the IDE is started. Duplicate names are not allowed. If an attempt is made to add a duplicate name to the list, an error will follow.

Code Templates

Code templates are a way to insert large pieces of code at once. Each code templates is identified by a unique name. This name can be used to insert the associated piece of code in the text.

For example, the name ifthen could be associated to the following piece of code:

If | Then
  begin
  end

A code template can be inserted by typing its name, and pressing when the cursor is positioned right after the template name.

If there is no template name before the cursor, a dialog will pop up to allow selection of a template.

If a vertical bar (|) is present in the code template, the cursor is positioned on it, and the vertical bar is deleted. In the above example, the cursor would be positioned between the if and then, ready to type an expression.

Code templates can be added and edited in the code templates dialog, reachable via the menu option . The code templates dialog is shown in figure [fig:codetemp].

The top listbox in the code templates dialog shows the names of all known templates. The bottom half of the dialog shows the text associated with the currently highlighted code template. The following buttons are available:

Ok

Saves all changes and closes the dialog.

Edit

Pops up a dialog that allows the editing of the currently highlighted code template. Both the name and text can be edited.

New

Pops up a dialog that allows the entry of a new code template which will be added to the list. A name must be entered for the new template.

Delete

Deletes the currently highlighted code template from the list.

Cancel

Discards all changes and closes the dialog.

All templates are saved and are available the next time the IDE is started.

Remark: Duplicates are not allowed. If an attempt is made to add a duplicate name to the list, an error will occur.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.