Anatomy of an Applet
Each applet runs as a separate process that may access the internal data structures of Whim via call.
The call command is an abstraction for interfacing with the communication channel that every applet uses.
Whim.vfs/applets/* contains most of the applet code. Most applets use the call command provided by applet_core.tcl.
A typical applet first needs a procedure with the following pattern:
proc read.control {chan} {
gets $chan cmd
if {"STOP" eq $cmd} {
exit 0
}
}The STOP control message handler may also use [call] to cleanup any canvas items it created, or other memory associated with the applet.
Every applet must have:
proc main {argc argv} {
# Put some code here that creates applet instance data.
}The tail of every applet ends in:
set dir [file dirname [info script]] source [file join $dir applet_core.tcl]
The script Whim.vfs/applets/applet_frontend can be used to test most applets. It emulates enough of the Whim internals to be useful for such things. For example:
tclkit8.5 applet_frontend.tcl diamond-3.tcl
Note: Steve has an alternative method of applet IPC that uses shared arrays. George and Steve are also working on a method that would allow friends to share applets that run over the network with each other. It's not currently known which method will be chosen from the prototypes already created for this.