Using the Ciao Prolog Playground
The Ciao Prolog Playground includes two main areas, which are both editable (note that the arrangement of the areas is configurable):
- The left area (or top area, if the window is narrow) is an editor for the program. Users can add their code into this editor and modify it there. The program can then be loaded into the system's top level, in the right area, where it can be run by entering queries at the prompt.
- The right area (or bottom area, if the window is narrow) hosts the top-level, where most communication with the system takes place. The top-level first shows Loading Ciao... while the system is loading its dependencies. When the top-level is completely ready to use, it will show the prompt ?- . Now programs can be loaded and queries issued.
There is also a preview area for graphical program output.
Key bindings
The playground supports a number of key bindings (including some of the most used in Emacs). They are listed below, classified by functionality.
Editing key bindings
These commands are useful to edit and move around the editor areas:
- Ctrl-A - move cursor to the beginning of the line.
- Ctrl-E - move cursor the end of the line.
- Ctrl-F - move cursor forward.
- Ctrl-B - move cursor backward.
- Ctrl-P - previous line.
- Ctrl-N - next line.
- Ctrl-S - search forward in the editor.
- Ctrl-R - search backward in the editor.
- Ctrl-D - delete character to the right.
- Ctrl-H - delete character to the left.
- Ctrl-K - kill the line after the cursor.
- Ctrl-M - insert line below.
- Ctrl-O - insert line after the current position.
- Ctrl-Z - undo.
- Ctrl-G - go to line.
- Ctrl-X + U - undo.
- Ctrl-X + O - select the other editor.
- Ctrl-V - go to the end of the editor.
- Ctrl-X + Ctrl-P - select all.
- Ctrl-X + Ctrl-U - transform selected text to upper case.
- Ctrl-X + Ctrl-L - transform selected text to lower case.
- Esc + D - delete the next word.
- Esc + V - move cursor to the beginning.
- Esc + Backspace - delete left word.
- Esc + ; - comment/uncomment current line.
Loading key bindings
These commands perform Ciao or filesystem-related actions:
- Ctrl-X + Ctrl-S - save file (same as button).
- Ctrl-C + L - load code into top-level (same as button).
- Ctrl-C + U - run tests in current module (same as button).
Specific key bindings for the top-level
The top-level area includes some key bindings of its own:
- Up arrow - previous query in history.
- Down arrow - next query in history.
- Ctrl-P - previous query in history.
- Ctrl-N - next query in history.
- Ctrl-C - abort current query, if there is any running.
Ctrl-C fully terminates the Ciao worker executing the Ciao process in the browser, so it may take some time to reload dependencies after aborting. The code present in the left (or top) window will be reloaded to the top-level.
Current playground limitations
Please be aware of some current limitations of the playground with respect to a full, native installation:
- Binaries and libraries are downloaded into your browser and code is executed locally (no connection required once loaded, no information about your code is gathered). To reduce download times, only some essential libraries are loaded by default.
- Currently this platform is limited to 32-bit binaries, runs around 2-3x slower than native binaries, and only offers partial POSIX features. Some Prolog libraries that depend on 3rd-party binaries (via the foreign interface) may not be currently available.
- The top level currently has some limitations regarding the loading of packages, debugging, portraying answers, and others. We are actively working on all of these and will be adding this functionality shortly.
- Reading input from standard input (read/1) is currently not directly supported, due to WebAssembly limitations. We plan also to fix this soon.
Please ask us if some useful library or feature is missing; if technically possible, we will add it. However, for intensive use we recommend installing Ciao Prolog natively, for improved performance and full features.