tk, chan, send, recv, alt - loadable tk module for sh.
is a loadable module for
that provides access to Inferno Tk graphics
and string channels.
Most of the builtin commands that it defines map
closely to primitives within
Unless otherwise stated, if a command requires
argument, if no window with that id is found, a
exception is raised. Similarly, a reference to
an unknown channel name will raise a
There is no requirement that this module be used in
a windowing context: although window creation will
fail if there is no context, the channel communication
primitives will work regardless.
creates a new channel called
within the tk module.
henceforth represents a Limbo
and can be used to send string values between
processes running in parallel. A
is also used to receive events arriving from the window
manager. It is illegal to create a channel whose name
consists entirely of numeric digits.
sends its argument
down the channel
blocking until a corresponding receive operation
takes place on the channel.
creates a new top-level window with the text of
in the titlebar at the top. Each window created by the
tk module is assigned a unique numeric id. This id
is printed by this command; to get access to the value
in a script, use
All the remaining arguments are joined together
by spaces and passed as the tk options for the window.
When a window is created, a corresponding
channel of the same name is created. Events from
the window manager arrive on this channel, and
should be responded to appropriately using
must be called to make window
visible for the first time, the same as
is the same as for that call - if given, it must be one of
is used to communicate requests to the window manager.
If an event arriving on a window's channel is passed
a suitable default action will take place.
The set of possible actions include:
A request to close the window.
A request to resize the window.
A request to miniaturise the window.
A request to move the window.
changes the title of the window
deletes a channel or a window. If
of an existing window, then both the
window and its associated channel are destroyed.
of a non-existent channel or window is ignored.
invokes the Tk module's
function to give a tk name to a
channel within the tk module.
is omitted, then the tk name given will be
the same as
is the id of an existing window, the rest of the
arguments joined together by spaces
and sent as a tk command to be interpreted
in that window. If the shell is in interactive mode,
then the string returned by tk will be printed.
The exit status of
is false if the string returned by tk begins with
is the same as its command counterpart, except
that it yields the
of the newly created window rather than printing
This command is the same as its command counterpart,
except that it yields the return value from the
Tk command as its result.
receives a string value from
and yields that value. It will block until a corresponding
send operation takes place on the channel.
waits until a value is available on any of the
It yields a list containing two elements,
the name of the channel from which the value was
received, and the actual value received.
The following code creates a window and allows
normal window manager operations on it. Another
shell in a new process group is created in order to prevent
the shell window from
disappearing when the tk window is deleted.