The Prolog Console View lets you
- Control Prolog processes
- Query Prolog predicates
- Generate load files
- Run the debugger, profiler and other SWI-Prolog tools
- Use some special editing features
- Jump to error lines in editors
The Prolog Console offers a unified entry point for interacting with different Prolog processes. The name of the current Prolog process is always displayed in the top left corner of the Console. If no current Prolog Process is selected, the process selector (first button in the Prolog Console's toolbar) displays a yellow warning triangle:
|Console with current Prolog Process||Console without current Prolog Process|
- Start a new Prolog process and name it as you like. If you open the drop down menu you will see a list of all defined configurations for Prolog processes.
Selecting a configuration in this list will start a new process using the selected configuration. The default configuration is emphasized with an icon. If you use the button and not the drop down menu to start a process, this process will use the default configuration.
- Restart the current process, reconsulting all currently consulted files after the restart. All active breakpoints will be preserved. WARNING: All non-persistent information (in particular, dynamically modified clauses) will be lost after restart The automatical reconsult can be disabled in the preferences.
If you want to restart a process there are three possible ways to handle the reconsulting of files.
- no reconsult: no additional files will be consulted, you have to consult everything manually
- reconsult entry points: of all the currently consulted files, only those which are marked as entry points will be reconsulted. This is the default behaviour.
- reconsult all files: all files which are currentyl consulted will be reconsulted
A query is typed at the Console's prompt and terminated with a full-stop ('.'). Hitting <enter> after the full stop issues the query to the Prolog system and displays the results (if any). If there are multiple resultes, the Console background will turn yellow to indicate that the Console is waiting for user directives as whether to continue or terminate the query. Typing semicolon(';') or simply hitting the space bar displays the next result or 'false', if there are no more results. Hitting <enter> or typing 'a' aborts the query.
If you started a query that does not seem to stop you can try one of the following:
- Pause the query and continue it under the control of the GUI tracer to see what is happening behind the scenes.
To trace a query from the very start, just prepend ”
trace, ” to your query (e.g. type ”
This will open by default the GUI tracer.
The Prolog Console supports code completion using the key binding <Ctrl><Space> or <TAB>. The following elements are shown in the completion:
- if the prefix is qualified with a module, all matching predicates visible in the qualifying module are listed.
- if a documentation of a predicate is availabe, it is shown in the right window.
- the icon shows the visibility of the predicate.
- the text inserted as completion depends on the key mask when accepting a proposal:
- no key mask: a predicate head is inserted. if a documentation is available, the argument names defined in the documentation will be used as variables for the inserted head.
- ctrl: a predicate indicator (::functor:: : ::arity::) is inserted.
- shift: a predicate name is inserted.
the following table shows some examples for the completion (click on the images to enlarge).
|predicates||modules and atoms|
The Prolog Console View supports a history mechanism (see keyboard shortcuts).
If you manually consulted multiple files into a Prolog process you can click the button on the right-hand-side of the Console's toolbar to create a file that will load all manually consulted files. Of course, you can edit it manually afterwards. Load file creation is handy if you want to consult the same set of files in a different process or after restarting Eclipse. It avoids errors otherwise caused by forgetting to (re)load certain recently created files.
By default, the created load file will be marked as an entry point.
If you click the arrow on the right side of the toolbar you can use some of the graphical tools of SWI-Prolog:
In addition to the usual editing operations (Select All, Copy, Cut, Paste) the context menu of the Prolog Console lets you paste the complete path of the file that is open in the currently active Prolog Editor. This is very helpful if you want to set breakpoints manually, for example.
Sometimes you find a predicate name in the console and you want to use it in a search query. This happens for example if you have some undefined predicate and you want to find all references to it. For this you can mark the predicate name in the console and select “Open Search Dialog” from the context menu. The Prolog Search dialog will be opened and it will get the current selection of the console as input.
|The highlighted text…||…is the input for the search dialog.|
SWI-Prolog reports warnings and errors while consulting a file. If the location is given, the prolog console links the message to the location, where the problem occurs.
|A click on the linked error message …||… opens an editor at the blamed line|
- Colored output is triggered by special keywords at the beginnig of each line: "***", “INFO:” , “WARNING:” , “ERROR:”, “DEBUG:”. The keywords are case-insensitive.
- Each line indented with tabs or (at least) two spaces is colored like the preceeding line.
- By default, "***" is treated like “INFO:”. Defaults can be overridden and output color can be (de)activated in the PDT preferences.
|Colored output on the console||definition of the predicate|
The Prolog Console appearance can be configured in the PDT Preferences: