Depending on their properties, predicates, quoted atoms and comments are highlighted with a specific colours. These colours can be modified in the preferences.
|Module transparent predicate|
Occurences of atom and variable names are highlighted in the current clause. The highlighting is updated instantly, upon typing.
|Highlighting in the editor||Description|
|All occurences of the variable touched by the cursor are highlighted with a grey background.|
|All occurences of the atom touched by the cursor are highlighted with a grey background.|
|Singleton variables are highlighted with a red background.|
|Variables that start with “_” but occur multiply in the current clause are highlighted with a light ivory background.|
All SWI-Prolog errors and warnings that occur while consulting a file are displayed in the Prolog Editor:
These errors and warnings are also displayed in the Eclipse Package Explorer and Eclipse Problems View:
|Prolog Editor||Package Explorer||Problems View|
The file which is opened in the editor can be consulted to the current process by pressing F9.
Whenever you save a file in the editor it is automatically (re)consulted. If you don't want a file to be consulted after saving you can save the file by pressing Ctrl+Alt+S or by selecting the menu item “Save without consult”. 1)
Furthermore you have the possibility to deactivate the reconsult on save in the Preferences. This means, that files will only be consulted manually.
The Outline view displays an outline of all predicates defined in the Prolog file opened in the editor. The Outline supports multi-file awareness, that is, it shows all the clauses of a predicate, also for multifile predicates:
In the outline, multifile predicates are shown either as “for” or “from” contributions:
A single click on the icon of a local predicate or clause selects the first line of that predicate / clause in the associated editor. A single click on the icon of remote clause has no effect. Double clicking a remote clause shows its first line in another editor. Single click is equivalent to navigating via the arrow keys, double click is equivalent to hitting <Return>.
The order of modules in the outline is
Within each module's section, predicates are displayed by default according to the textual order in the local file. However, the predicates can also be sorted alphabetically using the corresponding icon in the outline's tool bar. The order of modules cannot be changed.
When nothing is typed into the input field, the quick outline shows the same content as the outline view. Typing retains only the predicates whose name contains the typed string. Hitting Return when there is just one choice left jumps to that predicate.
The Prolog Editor supports code completion dependent on the current file and the loaded code in the currently selected Prolog process. Code completion in the Prolog editor uses the default Eclipse key binding (<Ctrl><Space>). The following elements are shown in the completion:
the following table shows some examples for the completion (click on the images to enlarge).
|predicates and atoms||modules and atoms||logtalk templates|
|Select a predicate call and run Open Primary Definition or Declaration||The cursor goes to line 17||Suggested alternatives if a non-existing or locally invisible predicate is searched|
Open Primary Definition or Declaration offers the possibility to easily jump to the first clause of a selected predicate, similar to the “Open Declaration” command in the Java editor. In the example above the declaration is contained in the same file and therefore the cursor will jump to line 17. If the declaration of the predicate is contained in another file, the other file will be opened in new editor.
Search for all declarations and definitions of the currently selected predicate in the editor. This search is done using the currently selected prolog process in the Prolog Console. The resulting modules get a visibility depending on the context of the selected goal. Possible values for visibility are local, super, sub and invisible.
Search for all references to the currently selected predicate in the editor. This search is done using the currently selected prolog process in the Prolog Console. Each result represents one clause that contains a call to the selected predicate.
SWI Prolog offers the possibility of setting breakpoints in the prolog code. These breakpoints are visible in the SWI GUI Tracer and they can be set and removed within the GUI Tracer.
The PDT Prolog Editor also displays these breakpoints. These breakpoints are those from the currently selected prolog process in the Prolog Console. In the PDT Prolog Editor, one line in the editor can only have one breakpoint. It is possible to set and remove breakpoints directly from the editor. This can be done by double-clicking at the required location on the bar at the left edge of the editor or by using the context menu at the same location (see the screenshots below).
Setting a breakpoint in the editor means setting the breakpoint in the currently selected prolog process in the Prolog Console. Therefore the file in the editor must be consulted in this prolog process, otherwise setting of breakpoints is not possible.
|Breakpoint in the SWI GUI Tracer||The same breakpoint in the PDT Prolog Editor||Context menu of the bar at the left edge of the editor|
Files which are not contained in any project in the workspace are called external files. For example the prolog code of SWI Prolog is usually not contained in any project in the workspace. To emphasize that a file in the Prolog Editor is an external file the editor uses a different icon in the editor title bar and the background colour of the editor is different (light gray).
The SWI-Prolog predicate edit/1 can be used in the Prolog Console to open a Prolog editor for any currently loaded predicate that has attached source code. This applies also to predicates residing in external files.
E. g. the query ”?- edit(member).” will open the library file “lists.pl” and position the cursor in the first clause of member/2 (see screenshots).
Even then, please be aware that the default behaviour of saving an edited file includes reconsulting the file. So it is very easy to break a running system if you edit a system file and save it before editing another file that would need a consistent change.
If you want to perform a set of related changes in different system files use <Ctrl> <Alt> S for saving, disabling the auto-consult for that particular action. You can also change the default behaviour of <Ctrl> S in the PDT preferences.