<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <META name="GENERATOR" content="hevea 1.06-7 of 2001-11-14"> <TITLE> The browser/editor (ocamlbrowser) </TITLE> </HEAD> <BODY TEXT=black BGCOLOR=white> <A HREF="manual027.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A> <A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A> <A HREF="manual029.html"><IMG SRC ="next_motif.gif" ALT="Next"></A> <HR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#2de52d"><DIV ALIGN=center><TABLE> <TR><TD><A NAME="htoc141"><B><FONT SIZE=6>Chapter 14</FONT></B></A></TD> <TD WIDTH="100%" ALIGN=center><B><FONT SIZE=6>The browser/editor (ocamlbrowser)</FONT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="c:browser"></A> <BR> This chapter describes OCamlBrowser, a source and compiled interface browser, written using LablTk. This is a useful companion to the programmer.<BR> <BR> Its functions are: <UL><LI> navigation through Objective Caml's modules (using compiled interfaces). <LI>source editing, type-checking, and browsing. <LI>integrated Objective Caml shell, running as a subprocess. </UL> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#66ff66"><DIV ALIGN=center><TABLE> <TR><TD><A NAME="htoc142"><B><FONT SIZE=5>14.1</FONT></B></A></TD> <TD WIDTH="100%" ALIGN=center><B><FONT SIZE=5>Invocation</FONT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> <A NAME="s:browser-options"></A><BR> The browser is started by the command <TT>ocamlbrowser</TT>, as follows: <PRE> ocamlbrowser <I>options</I> </PRE> The following command-line options are recognized by <TT>ocamlbrowser</TT>. <DL COMPACT=compact><DT><B><TT>-I</TT> <I>directory</I></B><DD> Add the given directory to the list of directories searched for source and compiled files. By default, only the standard library directory is searched. The standard library can also be changed by setting the <TT>OCAMLLIB</TT> environment variable.<BR> <BR> <DT><B><TT>-nolabels</TT></B><DD> Ignore non-optional labels in types. Labels cannot be used in applications, and parameter order becomes strict.<BR> <BR> <DT><B><TT>-oldui</TT></B><DD> Old multi-window interface. The default is now more like Smalltalk's class browser.<BR> <BR> <DT><B><TT>-rectypes</TT></B><DD> Allow arbitrary recursive types during type-checking. By default, only recursive types where the recursion goes through an object type are supported.<BR> <BR> <DT><B><TT>-w</TT> <I>warning-list</I></B><DD> Enable or disable warnings according to the argument <I>warning-list</I>.</DL> Most options can also be modified inside the application by the <B>Modules - Path editor</B> and <B>Compiler - Preferences</B> commands. They are inherited when you start a toplevel shell.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#66ff66"><DIV ALIGN=center><TABLE> <TR><TD><A NAME="htoc143"><B><FONT SIZE=5>14.2</FONT></B></A></TD> <TD WIDTH="100%" ALIGN=center><B><FONT SIZE=5>Viewer</FONT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> This is the first window you get when you start OCamlBrowser. It displays a search window, and the list of modules in the load path. At the top a row of menus. <UL><LI> <B>File - Open</B> and <B>File - Editor</B> give access to the editor.<BR> <BR> <LI><B>File - Shell</B> creates an Objective Caml subprocess in a shell.<BR> <BR> <LI><B>View - Show all defs</B> displays the signature of the currently selected module.<BR> <BR> <LI><B>View - Search entry</B> shows/hides the search entry just below the menu bar.<BR> <BR> <LI><B>Modules - Path editor</B> changes the load path. <B>Modules - Reset cache</B> rescans the load path and resets the module cache. Do it if you recompile some interface, or get confused about what is in the cache.<BR> <BR> <LI><B>Modules - Search symbol</B> allows to search a symbol either by its name, like the bottom line of the viewer, or, more interestingly, by its type. <B>Exact type</B> searches for a type with exactly the same information as the pattern (variables match only variables). <B>Included type</B> allows to give only partial information: the actual type may take more arguments and return more results, and variables in the pattern match anything. In both cases, argument and tuple order is irrelevant<A NAME="text2" HREF="#note2"><SUP><FONT SIZE=2>1</FONT></SUP></A>, and unlabeled arguments in the pattern match any label.<BR> <BR> <LI>The <B>Search entry</B> just below the menu bar allows one to search for an identifier in all modules (wildcards ``?'' and ``*'' allowed). If you choose the <TT>type</TT> option, the search is done by type inclusion (<EM>cf.</EM> Search Symbol - Included type).<BR> <BR> <LI>The <B>Close all</B> button is there to dismiss the windows created by the Detach button. By double-clicking on it you will quit the browser.</UL> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#66ff66"><DIV ALIGN=center><TABLE> <TR><TD><A NAME="htoc144"><B><FONT SIZE=5>14.3</FONT></B></A></TD> <TD WIDTH="100%" ALIGN=center><B><FONT SIZE=5>Module browsing</FONT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE><BR> You select a module in the leftmost box by either cliking on it or pressing return when it is selected. Fast access is available in all boxes pressing the first few letter of the desired name. Double-clicking / double-return displays the whole signature for the module.<BR> <BR> Defined identifiers inside the module are displayed in a box to the right of the previous one. If you click on one, this will either display its contents in another box (if this is a sub-module) or display the signature for this identifier below.<BR> <BR> Signatures are clickable. Double clicking with the left mouse button on an identifier in a signature brings you to its signature. A single click on the right button pops up a menu displaying the type declaration for the selected identifier. Its title, when selectable, also brings you to its signature.<BR> <BR> At the bottom, a series of buttons, depending on the context. <UL><LI> <B>Detach</B> copies the currently displayed signature in a new window, to keep it. <LI><B>Impl</B> and <B>Intf</B> bring you to the implementation or interface of the currently displayed signature, if it is available. </UL> Control-S lets you search a string in the signature.<BR> <BR> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#66ff66"><DIV ALIGN=center><TABLE> <TR><TD><A NAME="htoc145"><B><FONT SIZE=5>14.4</FONT></B></A></TD> <TD WIDTH="100%" ALIGN=center><B><FONT SIZE=5>File editor</FONT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> You can edit files with it, if you're not yet used to emacs. Otherwise you can use it as a browser, making occasional corrections.<BR> <BR> The <B>Edit</B> menu contains commands for jump (C-g), search (C-s), and sending the current phrase (or selection if some text is selected) to a sub-shell (M-x). For this last option, you may choose the shell via a dialog.<BR> <BR> Essential functions are in the <B>Compiler</B> menu. <UL><LI> <B>Preferences</B> opens a dialog to set internals of the editor and type-checker.<BR> <BR> <LI><B>Lex</B> adds colors according to lexical categories.<BR> <BR> <LI><B>Typecheck</B> verifies typing, and memorizes to let one see an expression's type by double-clicking on it. This is also valid for interfaces. If an error occurs, the part of the interface preceding the error is computed.<BR> <BR> After typechecking, pressing the right button pops up a menu giving the type of the pointed expression, and eventually allowing to follow some links.<BR> <BR> <LI><B>Clear errors</B> dismisses type-checker error messages and warnings.<BR> <BR> <LI><B>Signature</B> shows the signature of the current file (after type checking). </UL> <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD BGCOLOR="#66ff66"><DIV ALIGN=center><TABLE> <TR><TD><A NAME="htoc146"><B><FONT SIZE=5>14.5</FONT></B></A></TD> <TD WIDTH="100%" ALIGN=center><B><FONT SIZE=5>Shell</FONT></B></TD> </TR></TABLE></DIV></TD> </TR></TABLE> When you create a shell, a dialog is presented to you, letting you choose which command you want to run, and the title of the shell (to choose it in the Editor).<BR> <BR> The executed subshell is given the current load path. <UL><LI> <B>File</B> use a source file or load a bytecode file. You may also import the browser's path into the subprocess. <LI><B>History</B> M-p and M-n browse up and down. <LI><B>Signal</B> C-c interrupts, and you can also kill the subprocess. </UL> <HR WIDTH="50%" SIZE=1><DL><DT><A NAME="note2" HREF="#text2"><FONT SIZE=5>1</FONT></A><DD>To avoid combinatorial explosion of the search space, optional arguments in the actual type are ignored in the actual if (1) there are too many of them, and (2) they do not appear explicitly in the pattern. </DL> <HR> <A HREF="manual027.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A> <A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A> <A HREF="manual029.html"><IMG SRC ="next_motif.gif" ALT="Next"></A> </BODY> </HTML>