This chapter has been written by Gordon Irlam, gordoni@cygnus.com, at Cygnus Support, February 28, 1996. It is included here almost verbatim.
This section provides the specification for writing Guile applets for use with the SurfIt! demo browser.
Guile Scheme applets are denoted by the mime type application/guile. This is the default type for the file extension .scm.
An applet can be inlined within a HTML document.
<a href="applet.scm" rel=embed>
fallback_html
</a>
An applet may also be invoked when a hyperlink is followed.
<a href="applet.scm"
fallback_html
</a>
An applet is required to be a syntactically well formed Guile scheme program. When an applet is invoked the corresponding Guile program is retrieved, loaded, and executed.
Every applet is required to include the applet library:
(require 'applet)
Every applet is required to define a routine to be called by the browser when the browser requires the applet to terminate execution:
An applet will persist for as long as it is accessible -- either externally through it's being displayed on a page, or internally through the scheme environment.
All applets reside in the same top level environment. This allows state to be shared between applets and to persist between applet invocations.
An applet has access to all the features of a regular Guile scheme program and to the gtcl/gtk Guile extensions. The features of gtk allow the Guile applet to interactively display itself within the parent document.
Note: While Guile provides the ability to control namespaces, and this is necessary to provide a secure environment within which applets can be run, this has not been done for the SurfIt! Guile demo browser. The SurfIt! Guile demo browser is mainly intended as a research prototype, not a production web browser.
browser-window is the corresponding Tcl proc
to which window commands can be sent.
applet-window is
the corresponding Tcl proc to which window commands can be sent. The
frame still needs inserting into the browser window, assuming the applet
is visible.
(browser-window 'window 'create applet-embedindex :window
applet-window-name).
Applets should not monopolize the cpu. Instead they should be written using a callback or event loop polling based style so that the Tk event handler can continues to operate, and the user can continue to interact with the browser.
Any run time error occurring within an applet that goes uncaught will cause the applet to exit, but the browser will continue to function.