Previous Up Next

Chapter 9  Topcameleon

9.1  Introduction

Topcameleon is a graphical OCaml toplevel. It offers the same possibilities as the ocaml toplevel, and adds the following features: As for the ocaml toplevel, you can also build your own graphical toplevel, including more modules, using the cam-mktop utility (see section 9.4 below).

See the ocaml utility user manual, in the OCaml user manual, for details about using the toplevel.

9.2  Invocation

Topcameleon is launched by the following command:
topcameleon [options] [object-files] [source-file]
The options are the same as the ocaml toplevel, and files in arguments are handled the same was as by ocaml, except that if a source-file is given, Topcameleon 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 topcameleon cannot be used as a script interpreter, but it was not developed for such a purpose.

9.3  Using Topcameleon




Figure 9.1: Topcameleon main window.



Figure 9.1 shows the Topcameleon 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 widget 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, and eventually copy part of the code to re-use it in the input field.

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/Configuration menu opens the configuration window where you can change some colors, the font, 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).

9.4  Building a custom graphical toplevel

As for the ocaml toplevel, you have a command which lets you define your own graphical toplevel. This command is cam-mktop and is used the same way as the ocamlmktop command (see the OCaml manual for more information). The only differences are:
Previous Up Next