Quick start
Editing XUL code
XUL Console has been design to be a very simple but efficient way to test your XUL coding.
It uses Mozilla Midas rich text editing features to provide basic edition functionalities. But before displaying the result of the code beeing edited, it has to be saved as a XUL file.
But a more convenient way to use
XUL Console -- and skip its limited edition weakness -- is to procede thru the following steps:
- use your favorite text editor to write your XUL code
- save the code as a XUL file with a name of your choice (the xul extension for the file name is not mandatory)
- load this file in the Code panel (using the "Open" contextual menu entry or its shortcut)
- evaluate the code (using the "Run" contextual menu entry or its shortcut), this displays the file in the Output panel
If there is an error or if you want to modify your code:
- back to your text editor, edit the code
- back to XUL Console Code panel, reload the file (using the "Reopen" contextual menu entry or its shortcut)
- reevaluate the code...
This way, you can take advantage of your familiar IDE to develop your XUL code.
However, when you want to use only the
XUL Console Code panel editing feature, you can follow these steps:
- clear the Code panel content (using the "Clear" contextual menu entry)
- write your XUL code
- save your code (using the "Save as" contextual menu entry) as a XUL file with a name of your choice (the xul extension for the file name is not mandatory)
- evaluate the code (using the "Run" contextual menu entry or its shortcut), this displays the file in the Output panel
If there is an error or if you want to modify your code:
- back to XUL Console Code panel, edit the code
- save your code again (using the "Save" contextual menu entry)
- reevaluate the code...
Any code previously save as a XUL file can be loaded in the Code panel using the "Open" contextual menu entry (or its shortcut). Hence, you can edit XUL code even if you did not write it with
XUL Console. You could then modify
XUL Console code editing its XUL files: they are located in the "xul" directory found in your Mozilla/Firebird installation chrome directory (
/xulconsole/content/gui/xul). To see the result, you have to reload the
XUL Console extension itself. But, take care, this can be dangerous. However, this way, you can customize your
XUL Console version.
Using XPCOM
To have full programming access to
XPCOM components with JavaScript from a script included in a XUL file, you must either enable security privileges or load the XUL file located in a Mozilla chrome subdirectory.
In the first case, you must include the following line at the begining of your JavaScript code:
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
In the second case you must use the chrome protocol (chrome://) for your XUL file path. Unfortunatly, this protocol is not recognized when you load a file thru the file selector, which retrieves only absolute local file paths.
To circumvent these constraints,
XUL Console can load a file looking at the content of the code panel: if this content begins with a recognized protocol, the file pointed by the path is evaluated.
For instance, after cleaning the Code panel (using the "Clean" contextual menu entry), if you type in the following line:
chrome://xulconsole/content/repository/xulconsole-test.xul
the file "xulconsole-test.xul", will be evaluated using the chrome protocol, which is necessary to access the XPCOM components it requires. This gives you full access to Mozlib library modules interfacing XPCOM components with JavaScript classes.
The
repository directory, a subdirectory of the
XUL Console package, is especially provided to contain the XUL files you want to test.
Loading local and remote files
You can use
XUL Console protocol recognition feature to load a file located in your local file system thru the file protocol (file://):
file:///home/user/xulfile.xul
or even a file located on a remote server, thru the HTTP protocol (http://):
http://www.hevanet.com/acorbin/xul/top.xul
(this is the URL of Alice's Periodic Table).
XUL code samples
Of course, you need some examples of XUL code to learn how this fine but powerful markup language can be used.
Easy: just open the extended samples file provided by Alice J. Corbin (using the "Open XUL Periodic table" contextual menu entry) and evaluate this code.
Each sample entry listed at the left of Alice's Periodic Table can be opened individually (using the "Open XUL sample..." contextual menu entry): choose the file or your choice in the file selector which is displayed and then evaluate it.
To take advantage of these samples you can study the code either in the Code panel or switching to the "Source" tab of the Output panel. You can copy any code section, then paste it in the Code panel (after clearing it using the "Clear" contextual menu entry).
XUL Console Store
XUL Console provides a code store accessible thru the "Store" contextual submenu entries. You can store permanently any code fragment in this store and paste it in the Code panel where you want.
Presently, there is no way to reorganise the fragments list (we'll try to do it in a further release). But you can add and remove any Store entry, using the Store list contextual menu.
To
add a code fragment in the Store:
- in the Code panel, select a code fragment
- select the "Store > Add selection..." contextual menu entry
To
remove a code fragment in the Store:
- in the Code panel, select the "Store > List code..." contextual menu entry
- in the Store list, select a code fragment
- select the "Remove" contextual menu entry
To
paste a code fragment in the Code panel:
- in the Code panel, select the "Store > List code..." contextual menu entry
- in the Store list, select a code fragment
- select the "Paste" contextual menu entry
To switch back to the Code panel from the Store panel, just select the Code tab.
Use the context menu to navigate in the documentation pages