- 1 What is it ?
- 2 Download and installation
- 3 Studio Quick tour
- 4 Listener Window
- 5 Editor
- 6 Prolog Query Panel
- 7 Looking at tabled data
- 8 Project Window
- 9 Visualizing your own tables, trees, graphs
- 10 Environment Customization
- 11 Prolog Studio Bugs and Missing Features
- 12 Prolog Studio FAQ
What is it ?
An Integrated Development Environment for XSB Prolog, to which it adds a thin but powerful Java layer, providing syntax-sensitive editors, query control, tabled data browsing and more.
See the Studio Quick Tour.
Open source dependencies
Studio runs over Java 1.6 or later, and includes and/or depends on the following open source libraries:
- XSB Prolog
- Java-Prolog bridge
- XJ Swing UI library for Prolog, originally developed by XSB, Inc. and now part of Studio.
- JUNG graph framework
For convenience all of the above are packaged inside InterprologStudio.jar, except XSB Prolog.
Under the hood: architecture, etc.
Studio is a Java app using the InterProlog Java-Prolog bridge and two XSB Prolog subprocesses. The GUI layer is implemented on Java Foundation Classes (Swing), complemented with two open source frameworks: a text editor library (RSyntaxTextArea), and a Java+Prolog GUI generation component (XJ); graphs are represented and visualized with JUNG.
PICTURE TO APPEAR HERE
The Java side thus controls two XSB Prolog instances: a "main" one to load programs and execute queries, and an auxiliary one for (source code editor) parsing and incremental call graph extraction and representation.
See here .
Download and installation
The listener window exposes XSB's top level goal shell, including its tracer. It is a center point for reaching other Studio windows. The listener is a "console-type" window, likely to be kept hidden from non-gurus, as it can break (or at least disturb) the GUI layer, which depends on calling Prolog itself often. The GUI layer disables itself partially when Prolog is unavailable to it, such as when a user query is running.
Prolog source files can be dragged from the user desktop, opening in the editor.
An editor window edits one Prolog file, providing functionality specific to the language; in particular, a Prolog parser runs in background (on a dedicated XSB engine) to provide in place warnings etc. Coloring for a couple of dozen languages (Java, HTML, etc.) is also bundled in courtesy of RSTA.
- To load the file use the File menu
- To copy a subterm to the Query window and execute it, use the menu Edit/Query Selection
Editing Prolog clauses
- While editing or writing the Prolog code, a red circle with a white X may appear in the left margin. This signifies an error in the clause. Hover your mouse over the X to see what the error is. You may also see a yellow caution sign in that location, this is a warning - it will run but it may be problematic.
- Clicking a variable will highlight all its occurrences in the same clause.
- Pressing ctrl-space while writing a variable expands it (or displays a choice of completions)
- The "Predicates" menu shows all predicates in the current file, navigating to them
- To navigate from a clause subgoal to the matching clause definition (even in a different file) ctrl-click it (on Mac, Cmd-click)
- To see a tree with all calls down from a subgoal, right-click it and choose "My Call Tree"
- To see the same in a graph, right-click and choose "My Call Graph"
- To see callers to a goal, right-click and choose "Called by..."
Changing font size
Add the following line to the .fidji.prefs file, using the desired font size. Without this line, 12 is the default font size.
Do this while Studio is NOT running, otherwise it will overwrite your changes.
Changing syntax coloring
To change editor (syntax) colors, extract fidjiTheme.xml from the interPrologStudio.jar file, rename it to .fidjiTheme.xml, place it in the same directory as the jar file, and edit the color definitions in the style elements there.
Increasing the size of files handled
To get instant warnings and errors regarding syntax etc., Studio needs to do some analysis, which can take a while for larger files. After a certain size threshold it does not give those messages anymore. The precise threshold is determined dynamically; if you need to override it (typically to enlarge it), you need to add either (or both) of the following preferences to the text file .fidji.prefs (without Studio being running):
Prolog Query Panel
Where the user can pose queries, reasonably restrained by default, optionally stop or pause/continue them, get answers, and enquire the reason of undefined-ness.
- Go to the Prolog Studio listener window and select Tools / Prolog Query query to open the Query window.
- Enter your Prolog goal (including the trailing dot) where it says 'Query_here' then hit 'enter' or the Execute button.
- If you need to Stop or Pause it click the buttons
- You can specify term size bounds by using the Restraint menu (please refer to section 5.5 of XSB Manual 1).
- The answers (solutions) to the goal appears in the grey window below the Query_here area.
- You can select some or all of the answers, and copy them with ctrl-C; pasting into Excel or somewhere else works as expected
- You can also use the menu View / View results as graph, to display each answer as a graph edge, the graph being defined as a binary relation between the first two variables in the query
- When using "View results as graph", beware that answers with free variables may lead to more edges than expected
Looking at tabled data
In the listener window there is a menu Tools / Tabled Data; this will open up a window showing all XSB tables, in a 3-level tree showing predicate, subgoal and answer. Subgoals without answers are shown in red, others in green. Incremental tables (predicates) in orange. Data is current only when tree nodes expand the first time.
Please see XSB Manual 1 chapter 5 for an introduction to tabling.
Studio has a minimal facility to ease managing a bunch of Prolog files. In the listener window menu:
- File / New Project...: creates an empty window, which will persist in a project file (.fidji extension)
- File / Open Project...: opens an existing project file
In the project window:
- File / Include... to add an existing logic file
- .... or simply drag your files onto the project window
- Double-click a file name to edit it
- File / Save: save the project file, NOT its editor files.
- File / Load All: loads and/or adds files as indicated for each
- File / Open All: opens all files in editor windows, and minimizes them
Visualizing your own tables, trees, graphs
See XJ Prolog UI Library.
You can make Studio auto load and start a Prolog goal, thus being able to (say) launch an application while keeping Studio features hidden; or to pre-open Prolog files for editing; etc.
fijiRC.P ("Run Commands in Prolog"...) file: if present in the same directory as interPrologStudio.jar, this file will be loaded and Prolog predicate "fjMain" will run, preconfiguring the environment as specified therein. If someone is inspired by this please feel free to ask email@example.com for recipes.
/* Example Prolog file to kick Studio into action. An application is likely to replace it in order to set up some user screen */ fjMain :- ipListenerWindow(W), javaMessage(W,show), javaMessage(W,focusInput), % commenting the previous line would let the listener window invisible; % to make it visible from Prolog (if you have the Query window, see below...): % (ipListenerWindow(W), javaMessage(W,show). javaMessage('java.lang.System',string(U),getProperty(string('user.name'))), write('Hello '), write(U), writeln('!'), javaMessage(W,showPrologQuery(string('X=1'))), % a predefined query % Open a file into the editor: javaMessage('com.declarativa.fiji.LogicProgramEditor',_E,makeEditor(string('/Users/YourPath/YourFile.P'),W)). */
Notice that it is possible to replace the fidjiRC.P file inside the jar file (which is a simplified variant of the above), and therefore distribute a interPrologStudio.jar file which auto-configures and executes an application.
This is an alternative to the above, for use in shell scripts invoking Studio. The Prolog file will be loaded and a different predicate will be executed (xjMain).
See editor #Customization.
Under the hood dept
If for some peculiar reason (e.g. while debugging Studio itself) you need to access the auxiliary engine used for editor parsing and call graph features, add the following preference:
Next Studio starts it will present a second listener window, where you can query the auxiliar Prolog engine. This is NOT intended for user development.
Studio uses a Java-Prolog bridge feature to interject Java calls every so often, to implement an efficient polling mechanism for the Query window Pause/Continue/Stop buttons. This is based on XSB Prolog's timed_call predicate, see Manual 1 section 6.11. IF for some reason you need to specify a polling interval add a preference such as (for 1 second):