OCamltop-gtk

 

What is OCamltop-gtk ?

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:

  • saving the input code into a file,
  • viewing and browsing of computed values in a tree-oriented view,
  • easy access to definitions of values, modules, types, ....

One can also create his own graphical toplevel with the tool mk-ocamltop-gtk.

OCamltop-gtk was previously part of Cameleon under the name "topcameleon" but is now developped separately and is findlib compatible.

Invocation

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.

Using OCamltop-gtk

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).

Creating a graphical toplevel with mk-ocamltop-gtk

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:

  • you get a graphical toplevel instead of a text one,
  • it already contains the following libraries: Unix, LablGtk, Lablglade, Config_file, Configwin, Gmylist, Okey, Lablgtksourceview2, Gtktop.

Download

OCamltop-gtk is hosted on Github.

Releases

  • 2.1.1 [2013-02-14]: Split (un)install targets to (un)install-[lib|bin] for opam installation.
  • 2.1 [2012-11-15]: Upgrade to Lablgtk 2.16.0.
  • 2.0 [2012-04-12]: first release after extraction from Cameleon.

Installation

OCamltop-gtk requires Gtktop >= 2.0 to be installed. You must also have the compiled sources of OCaml somewhere.

To compile and install:

  • tar xvfz ocamltop-gtk-XXX.tar.gz
  • cd ocamltop-gtk-XXX
  • ./configure --with-ocaml-src-dir=/directory/of/compiled/sources/of/ocaml
  • make all install

This will install the findlib package "ocamltop-gtk". The executables ocamltop-gtk and mk-ocamltop-gtk will be installed in ocaml bin directory.

License

OCamltop-gtk is released under the LGPL v3.

Author and contact

Maxence Guesdon <Maxence 'DOT' Guesdon 'AT' inria 'DOT' fr>