All the features of Tk are not included in Inferno. This section provides information about the differences between the Limbo/Tk implementation and Tk 4.0.
Programmers need only deal with the toplevel, namechan, and cmd functions. The mouse and keyboard functions are used by the window manager to deliver mouse and keyboard events into applications.
top := tk->toplevel(ctxt.screen, tkargs);
A typical call of the cmd function is:
range := tk->cmd(ed, ".b.t tag nextrange sel 1.0");
A single command is divided into a number of words. Words are separated by one or more blanks and tabs.
A word beginning with an opening brace ( { ) continues until the balancing closing brace ( } ) is reached. The outer brace characters are stripped. A backslash can be used to escape a brace in this context.
A word beginning with an opening bracket ( [ ) continues until the balancing closing bracket ( ] ) is reached. The enclosed string is then evaluated as if it were a command string, and the resulting value is used as the contents of the word.
Single commands are executed in order until they are all done or an error is encountered. By convention, an error is signaled by a return value starting with an exclamation mark. The return value from cmd is the return value of the first error-producing command or else the return value of the final single command.
To execute a single command, the first word is examined. It can be one of the following:
c := chan of string; tk->namechan(top, c, "c"); The main use of named channels and the send command that uses them is to allow Limbo programs to be notified when Tk events happen. For example,
tk->cmd(top, ".m.file.menu add command -label Open..." + " -command {send c open}"); might be used to add an entry to a menu. Whenever the 'Open...' entry is selected, the string 'open' will be sent along the channel associated with name 'c'. The Limbo program should be waiting for such events, with code like:
s := <-c => case s { "open" => do_open(); ... } Because the language accepted by the cmd function has no user-defined functions, no control flow and very few variables, almost all applications need to have some of their logic in Limbo programs.
-activebackground color -activeforeground color -actwidth dist -actheight dist
The -actwidth and -actheight variables are overridden by the packer, but are useful as arguments to cget to retrieve the actual width and height (inside the border) of a widget after packing.
-background color or -bg color -borderwidth dist or -bd dist -font font -foreground color or -fg color -height dist (Requested height.) -padx dist -pady dist -relief relief -state normal or -state active or -state disabled
The -state variable is only relevant for some widgets (for example, entry widgets).
-selectbackground color -selectborderwidth dist -selectcolor color
The -selectcolor variable is the color of the box in selection menu items.
In Tcl/Tk 4.0, the widgets do not uniformly take -width and -height options; rather, each widget may take either or both options, and if they do, the meaning of bare number (without a unit specifier) varies from widget to widget. For example, in Tk 4.0 -width 25 means 25 characters to an entry widget, but 25 pixels to a canvas widget. In Limbo/Tk, all widgets may have height and width specified, and bare numbers always mean screen pixels.
The color parameters can be color names or RGB values. Only a small set of names are known currently:
black
|
blue
|
darkblue
|
red
|
yellow
|
green
|
white
|
orange
|
aqua
|
fuchia
|
gray
|
lime
|
maroon
|
navy
|
olive
|
purple
|
teal
|
|
|
|
For RGB values, one of the two syntaxes #RGB or #RRGGBB must be used.
Options Not Supported in Limbo Tk
The following options, listed in as Tk 4.0 Options, are not implemented by any Limbo/Tk widget:
-cursor -disabledforeground -exportselection -geometry -highlightbackground -highlightcolor -highlightthickness -insertbackground -insertborderwidth -insertofftime -insertontime -insertwidth -repeatdelay -repeatinterval -setgrid -takefocus -textvariable -troughcolor
Many of the Tk 4.0 widgets take 'Standard Options' such as
-insertontime that are not implemented in Limbo/Tk. See Options
Not Supported in Limbo Tk.
The following seqitems are accepted:
Key or KeyPress. This represents the press of the character in the following seqitem. If there is no following seqitem, this represents the press of any key.
The characters cannot be specified using X11 names (for example, Return).
ButtonPress or Button. This represents the pressed state of the mouse button given by the following seqitem, which should be 1, 2, or 3. If there is no following seqitem, this represents the press of any button.
Unlike Tk 4.0, if the mouse is moved with a button pressed, the Button event is delivered in combination with a Motion event as long as the button remains pressed.
Motion. This represents possible motion of the mouse.
Double. This means that any seqitems in the sequence representing button presses must be double-clicked for the sequence to match.
Map. This represents the event of the widget being drawn on the screen, either for the first time or after being de-iconified.
Unmap. This represents the event of the widget being de-iconified.
Enter. This represents the event of the mouse entering the widget from outside.
Leave. This represents the event of the mouse going outside the boundaries of the widget.
FocusIn. This represents the event of the widget getting the keyboard focus.
FocusOut. This represents the event of the widget losing the keyboard focus.
The event sequence can contain any combination of the above seqitems. They are treated as independent events, and if any of the events occur, the sequence matches. You cannot combine Key Presses of more than one key. As for delivery: events will not be combined, except that Motion events may be combined with button presses (possibly doubled).
The binding script argument has % substitution, as specified in Tk 4.0. However, only the following are implemented: %%, %b, %h, %s, %w, %x, %y, %A, %K, %W, %X, and %Y. The %s substitution gives the logical OR of the mouse buttons for mouse events, and the decimal value of the pressed character for key events. The %K substitution gives the pressed character in the form of four hexadecimal digits (not a textual string, as in Tk 4.0). The %A substitution will escape a {, }, or a \, so that it won't confuse the command string parser when used in a bind script.
The -displayof, -force, and -lastfor options are not implemented.