OCamltop-gtk is a Gtk2 graphical interface for the OCaml toplevel. Like the text mode toplevel, it permits interactive use of the OCaml system through a read-eval-print loop. Some additional functionalities are provided:
One can also create his own graphical toplevel with the tool
OCamltop-gtk was previously part of Cameleon under the name "topcameleon" but is now developped separately and is findlib compatible.
OCamltop-gtk is launched by the following command:
ocamltop-gtk [options] [object-files] [source-file]
The options are the same as the OCaml toplevel, and files in arguments are handled the same way, except that if a source file is given, ocamltop-gtk does not exit after having evaluated the code in this file, but rather shows the main window with the code in the file still present like if the user had typed it. This way, you can type your code after the loaded code, and when you're satisfied you can save the whole code in one file (by default it is saved in the given source file). So ocamltop-gtk cannot be used as a script interpreter, but it was not developed for such a purpose.
On the OCamltop-gtk main window, the left pane contains a list of the defined elements (values, types, modules, ...). The second pane shows the selected value, in a tree-oriented way. The right pane is the console, with the result on top and the input text at the bottom. The "Execute" button executes the code in the input widget.
Each time you define a new element, it is added to the list of elements. When you select an element is this list, its value is shown (if it is a value) in the 'tree view', and the result box jumps to its definition so you can see how it was defined.
Errors in the input field are hilighted when you execute a phrase (do not forget the ";;" at the end of your phrases).
You can use the "File/Load file ...", "File/Save" and "File/Save as ..." menus to load and save files. Note that the current file you're using is displayed in the title bar. It is the file your code will be saved into if you use the "File/Save" menu.
The "File/Preferences" menu opens the configuration window where you can change the style scheme and choose whether the values in the tree are automatically expanded or not (default is true, but it can take some time and memory for very large values).
As for the OCaml toplevel, you have a command which lets you define
your own graphical toplevel. This command is
mk-ocamltop-gtk and is used the same way as the ocamlmktop command
(see the OCaml manual for more information). The only differences are:
OCamltop-gtk is hosted on Github.
OCamltop-gtk requires Gtktop >= 2.0 to be installed. You must also have the compiled sources of OCaml somewhere.
To compile and install:
This will install the findlib package "ocamltop-gtk".
will be installed in ocaml bin directory.
<Maxence 'DOT' Guesdon 'AT' inria 'DOT' fr>