home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcl76inf.zip / tcl76.INF (.txt)
OS/2 Help File  |  1999-06-04  |  763KB  |  27,639 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Tcl Applications ΓòÉΓòÉΓòÉ
  3.  
  4.  
  5. ΓòÉΓòÉΓòÉ 1.1. tclsh ΓòÉΓòÉΓòÉ
  6.  
  7.  NAME 
  8.  
  9. tclsh - Simple shell containing Tcl interpreter 
  10.  
  11. SYNOPSIS 
  12.  
  13. tclsh ?fileName arg arg ...? 
  14.  
  15. DESCRIPTION 
  16.  
  17. Tclsh is a shell-like application that reads Tcl commands from its standard 
  18. input or from a file and evaluates them. If invoked with no arguments then it 
  19. runs interactively, reading Tcl commands from standard input and printing 
  20. command results and error messages to standard output. It runs until the exit 
  21. command is invoked or until it reaches end-of-file on its standard input. If 
  22. there exists a file .tclshrc in the home directory of the user, tclsh evaluates 
  23. the file as a Tcl script just before reading the first command from standard 
  24. input. 
  25.  
  26. SCRIPT FILES 
  27.  
  28. If tclsh is invoked with arguments then the first argument is the name of a 
  29. script file and any additional arguments are made available to the script as 
  30. variables (see below). Instead of reading commands from standard input tclsh 
  31. will read Tcl commands from the named file;  tclsh will exit when it reaches 
  32. the end of the file. There is no automatic evaluation of .tclshrc in this case, 
  33. but the script file can always source it if desired. 
  34.  
  35. If you create a Tcl script in a file whose first line is 
  36.  
  37. #!/usr/local/bin/tclsh
  38. then you can invoke the script file directly from your shell if you mark the 
  39. file as executable. This assumes that tclsh has been installed in the default 
  40. location in /usr/local/bin;  if it's installed somewhere else then you'll have 
  41. to modify the above line to match. Many UNIX systems do not allow the #! line 
  42. to exceed about 30 characters in length, so be sure that the tclsh executable 
  43. can be accessed with a short file name. 
  44.  
  45. An even better approach is to start your script files with the following three 
  46. lines: 
  47.  
  48. #!/bin/sh
  49. # the next line restarts using tclsh \
  50. exec tclsh "$0" "$@"
  51. This approach has three advantages over the approach in the previous paragraph. 
  52. First, the location of the tclsh binary doesn't have to be hard-wired into the 
  53. script:  it can be anywhere in your shell search path.  Second, it gets around 
  54. the 30-character file name limit in the previous approach. Third, this approach 
  55. will work even if tclsh is itself a shell script (this is done on some systems 
  56. in order to handle multiple architectures or operating systems:  the tclsh 
  57. script selects one of several binaries to run).  The three lines cause both sh 
  58. and tclsh to process the script, but the exec is only executed by sh. sh 
  59. processes the script first;  it treats the second line as a comment and 
  60. executes the third line. The exec statement cause the shell to stop processing 
  61. and instead to start up tclsh to reprocess the entire script. When tclsh starts 
  62. up, it treats all three lines as comments, since the backslash at the end of 
  63. the second line causes the third line to be treated as part of the comment on 
  64. the second line. 
  65.  
  66. VARIABLES 
  67.  
  68. Tclsh sets the following Tcl variables: 
  69.  
  70.  argc      Contains a count of the number of arg arguments (0 if none), not 
  71.            including the name of the script file. 
  72.  
  73.  argv      Contains a Tcl list whose elements are the arg arguments, in order, 
  74.            or an empty string if there are no arg arguments. 
  75.  
  76.  argv0     Contains fileName if it was specified. Otherwise, contains the name 
  77.            by which tclsh was invoked. 
  78.  
  79.  tcl_interactive  Contains 1 if tclsh is running interactively (no fileName was 
  80.            specified and standard input is a terminal-like device), 0 
  81.            otherwise. 
  82.  
  83.  PROMPTS 
  84.  
  85.  When tclsh is invoked interactively it normally prompts for each command with 
  86.  "% ".  You can change the prompt by setting the variables tcl_prompt1 and 
  87.  tcl_prompt2.  If variable tcl_prompt1 exists then it must consist of a Tcl 
  88.  script to output a prompt;  instead of outputting a prompt tclsh will evaluate 
  89.  the script in tcl_prompt1. The variable tcl_prompt2 is used in a similar way 
  90.  when a newline is typed but the current command isn't yet complete; if 
  91.  tcl_prompt2 isn't set then no prompt is output for incomplete commands. 
  92.  
  93.  KEYWORDS 
  94.  
  95.  argument, interpreter, prompt, script file, shell 
  96.  
  97.  
  98. ΓòÉΓòÉΓòÉ 2. Tcl Library Procedures ΓòÉΓòÉΓòÉ
  99.  
  100.  
  101. ΓòÉΓòÉΓòÉ 2.1. Tcl_AddErrorInfo ΓòÉΓòÉΓòÉ
  102.  
  103.  NAME 
  104.  
  105. Tcl_AddErrorInfo, Tcl_SetErrorCode, Tcl_PosixError - record information about 
  106. errors 
  107.  
  108. SYNOPSIS 
  109.  
  110. #include <tcl.h> 
  111.  
  112.  Tcl_AddErrorInfo(interp, message) 
  113.  
  114.  Tcl_SetErrorCode(interp, element, element, ... (char *) NULL) 
  115.  
  116.  char * 
  117.  Tcl_PosixError(interp) 
  118.  
  119. ARGUMENTS 
  120.  
  121.  Tcl_Interp  *interp (in)  Interpreter in which to record information. 
  122.  
  123.  char  *message (in)  Identifying string to record in errorInfo variable. 
  124.  
  125.  char  *element (in)  String to record as one element of errorCode variable. 
  126.            Last element argument must be NULL. 
  127.  
  128.  DESCRIPTION 
  129.  
  130.  These procedures are used to manipulate two Tcl global variables that hold 
  131.  information about errors. The variable errorInfo holds a stack trace of the 
  132.  operations that were in progress when an error occurred, and is intended to be 
  133.  human-readable. The variable errorCode holds a list of items that are intended 
  134.  to be machine-readable. The first item in errorCode identifies the class of 
  135.  error that occurred (e.g. POSIX means an error occurred in a POSIX system 
  136.  call) and additional elements in errorCode hold additional pieces of 
  137.  information that depend on the class. See the Tcl overview manual entry for 
  138.  details on the various formats for errorCode. 
  139.  
  140.  The errorInfo variable is gradually built up as an error unwinds through the 
  141.  nested operations. Each time an error code is returned to Tcl_Eval it calls 
  142.  the procedure Tcl_AddErrorInfo to add additional text to errorInfo describing 
  143.  the command that was being executed when the error occurred. By the time the 
  144.  error has been passed all the way back to the application, it will contain a 
  145.  complete trace of the activity in progress when the error occurred. 
  146.  
  147.  It is sometimes useful to add additional information to errorInfo beyond what 
  148.  can be supplied automatically by Tcl_Eval. Tcl_AddErrorInfo may be used for 
  149.  this purpose: its message argument contains an additional string to be 
  150.  appended to errorInfo. For example, the source command calls Tcl_AddErrorInfo 
  151.  to record the name of the file being processed and the line number on which 
  152.  the error occurred;  for Tcl procedures, the procedure name and line number 
  153.  within the procedure are recorded, and so on. The best time to call 
  154.  Tcl_AddErrorInfo is just after Tcl_Eval has returned TCL_ERROR. In calling 
  155.  Tcl_AddErrorInfo, you may find it useful to use the errorLine field of the 
  156.  interpreter (see the Tcl_Interp manual entry for details). 
  157.  
  158.  The procedure Tcl_SetErrorCode is used to set the errorCode variable. Its 
  159.  element arguments give one or more strings to record in errorCode:  each 
  160.  element will become one item of a properly-formed Tcl list stored in 
  161.  errorCode. Tcl_SetErrorCode is typically invoked just before returning an 
  162.  error. If an error is returned without calling Tcl_SetErrorCode then the Tcl 
  163.  interpreter automatically sets errorCode to NONE. 
  164.  
  165.  Tcl_PosixError sets the errorCode variable after an error in a POSIX kernel 
  166.  call. It reads the value of the errno C variable and calls Tcl_SetErrorCode to 
  167.  set errorCode in the POSIX format. The caller must previously have called 
  168.  Tcl_SetErrno to set errno; this is necessary on some platforms (e.g. Windows) 
  169.  where Tcl is linked into an application as a shared library, or when the error 
  170.  occurs in a dynamically loaded extension. See the manual entry for 
  171.  Tcl_SetErrno for more information. 
  172.  
  173.  Tcl_PosixError returns a human-readable diagnostic message for the error (this 
  174.  is the same value that will appear as the third element in errorCode). It may 
  175.  be convenient to include this string as part of the error message returned to 
  176.  the application in interp->result. 
  177.  
  178.  It is important to call the procedures described here rather than setting 
  179.  errorInfo or errorCode directly with Tcl_SetVar. The reason for this is that 
  180.  the Tcl interpreter keeps information about whether these procedures have been 
  181.  called. For example, the first time Tcl_AppendResult is called for an error, 
  182.  it clears the existing value of errorInfo and adds the error message in 
  183.  interp->result to the variable before appending message;  in subsequent calls, 
  184.  it just appends the new message. When Tcl_SetErrorCode is called, it sets a 
  185.  flag indicating that errorCode has been set;  this allows the Tcl interpreter 
  186.  to set errorCode to NONE if it receives an error return when Tcl_SetErrorCode 
  187.  hasn't been called. 
  188.  
  189.  If the procedure Tcl_ResetResult is called, it clears all of the state 
  190.  associated with errorInfo and errorCode (but it doesn't actually modify the 
  191.  variables). If an error had occurred, this will clear the error state to make 
  192.  it appear as if no error had occurred after all. 
  193.  
  194.  SEE ALSO 
  195.  
  196.  Tcl_Interp, Tcl_ResetResult, Tcl_SetErrno 
  197.  
  198.  KEYWORDS 
  199.  
  200.  error, stack, trace, variable 
  201.  
  202.  
  203. ΓòÉΓòÉΓòÉ 2.2. Tcl_Alloc ΓòÉΓòÉΓòÉ
  204.  
  205.  NAME 
  206.  
  207. Tcl_Alloc, Tcl_Free, Tcl_Realloc - allocate or free heap memory 
  208.  
  209. SYNOPSIS 
  210.  
  211. #include <tcl.h> 
  212.  
  213.  char * 
  214.  Tcl_Alloc(size) 
  215.  
  216.  Tcl_Free(ptr) 
  217.  
  218.  char * 
  219.  Tcl_Realloc(ptr, size) 
  220.  
  221. ARGUMENTS 
  222.  
  223.  int  size (in)  Size in bytes of the memory block to allocate. 
  224.  
  225.  char  *ptr (in)  Pointer to memory block to free or realloc. 
  226.  
  227.  DESCRIPTION 
  228.  
  229.  These procedures provide a platform and compiler independent interface for 
  230.  memory allocation.  Programs that need to transfer ownership of memory blocks 
  231.  between Tcl and other modules should use these routines rather than the native 
  232.  malloc() and free() routines provided by the C run-time library. 
  233.  
  234.  Tcl_Alloc returns a pointer to a block of at least size bytes suitably aligned 
  235.  for any use. 
  236.  
  237.  Tcl_Free makes the space referred to by ptr available for further allocation. 
  238.  
  239.  Tcl_Realloc changes the size of the block pointed to by ptr to size bytes and 
  240.  returns a pointer to the new block. The contents will be unchanged up to the 
  241.  lesser of the new and old sizes.  The returned location may be different from 
  242.  ptr. 
  243.  
  244.  KEYWORDS 
  245.  
  246.  alloc, allocation, free, malloc, memory, realloc 
  247.  
  248.  
  249. ΓòÉΓòÉΓòÉ 2.3. Tcl_AllowExceptions ΓòÉΓòÉΓòÉ
  250.  
  251.  NAME 
  252.  
  253. Tcl_AllowExceptions - allow all exceptions in next script evaluation 
  254.  
  255. SYNOPSIS 
  256.  
  257. #include <tcl.h> 
  258.  
  259.  Tcl_AllowExceptions(interp) 
  260.  
  261. ARGUMENTS 
  262.  
  263.  Tcl_Interp  *interp (in)  Interpreter in which script will be evaluated. 
  264.  
  265.  DESCRIPTION 
  266.  
  267.  If a script is evaluated at top-level (i.e. no other scripts are pending 
  268.  evaluation when the script is invoked), and if the script terminates with a 
  269.  completion code other than TCL_OK, TCL_CONTINUE or TCL_RETURN, then Tcl 
  270.  normally converts this into a TCL_ERROR return with an appropriate message. 
  271.  
  272.  However, if Tcl_AllowExceptions is invoked immediately before calling a 
  273.  procedure such as Tcl_Eval, then arbitrary completion codes are permitted from 
  274.  the script, and they are returned without modification. This is useful in 
  275.  cases where the caller can deal with exceptions such as TCL_BREAK or 
  276.  TCL_CONTINUE in a meaningful way. 
  277.  
  278.  KEYWORDS 
  279.  
  280.  continue, break, exception, interpreter 
  281.  
  282.  
  283. ΓòÉΓòÉΓòÉ 2.4. Tcl_AppInit ΓòÉΓòÉΓòÉ
  284.  
  285.  NAME 
  286.  
  287. Tcl_AppInit - perform application-specific initialization 
  288.  
  289. SYNOPSIS 
  290.  
  291. #include <tcl.h> 
  292.  
  293.  int 
  294.  Tcl_AppInit(interp) 
  295.  
  296. ARGUMENTS 
  297.  
  298.  Tcl_Interp  *interp (in)  Interpreter for the application. 
  299.  
  300.  DESCRIPTION 
  301.  
  302.  Tcl_AppInit is a "hook" procedure that is invoked by the main programs for Tcl 
  303.  applications such as tclsh and wish. Its purpose is to allow new Tcl 
  304.  applications to be created without modifying the main programs provided as 
  305.  part of Tcl and Tk. To create a new application you write a new version of 
  306.  Tcl_AppInit to replace the default version provided by Tcl, then link your new 
  307.  Tcl_AppInit with the Tcl library. 
  308.  
  309.  Tcl_AppInit is invoked after by Tcl_Main and Tk_Main after their own 
  310.  initialization and before entering the main loop to process commands. Here are 
  311.  some examples of things that Tcl_AppInit might do: 
  312.  
  313.    1. Call initialization procedures for various packages used by the 
  314.       application. Each initialization procedure adds new commands to interp 
  315.       for its package and performs other package-specific initialization. 
  316.  
  317.    2. Process command-line arguments, which can be accessed from the Tcl 
  318.       variables argv and argv0 in interp. 
  319.  
  320.    3. Invoke a startup script to initialize the application. 
  321.  
  322.  Tcl_AppInit returns TCL_OK or TCL_ERROR. If it returns TCL_ERROR then it must 
  323.  leave an error message in interp->result;  otherwise the result is ignored. 
  324.  
  325.  In addition to Tcl_AppInit, your application should also contain a procedure 
  326.  main that calls Tcl_Main as follows: 
  327.  
  328.   Tcl_Main(argc, argv, Tcl_AppInit);
  329.  The third argument to Tcl_Main gives the address of the application-specific 
  330.  initialization procedure to invoke. This means that you don't have to use the 
  331.  name Tcl_AppInit for the procedure, but in practice the name is nearly always 
  332.  Tcl_AppInit (in versions before Tcl 7.4 the name Tcl_AppInit was implicit; 
  333.  there was no way to specify the procedure explicitly). The best way to get 
  334.  started is to make a copy of the file tclAppInit.c from the Tcl library or 
  335.  source directory. It already contains a main procedure and a template for 
  336.  Tcl_AppInit that you can modify for your application. 
  337.  
  338.  KEYWORDS 
  339.  
  340.  application, argument, command, initialization, interpreter 
  341.  
  342.  
  343. ΓòÉΓòÉΓòÉ 2.5. Tcl_SetAssocData ΓòÉΓòÉΓòÉ
  344.  
  345.  NAME 
  346.  
  347. Tcl_GetAssocData, Tcl_SetAssocData, Tcl_DeleteAssocData - manage associations 
  348. of string keys and user specified data with Tcl interpreters. 
  349.  
  350. SYNOPSIS 
  351.  
  352. #include <tcl.h> 
  353.  
  354.  ClientData 
  355.  Tcl_GetAssocData(interp, key, delProcPtr) 
  356.  
  357.  Tcl_SetAssocData(interp, key, delProc, clientData) 
  358.  
  359.  Tcl_DeleteAssocData(interp, key) 
  360.  
  361. ARGUMENTS 
  362.  
  363.  Tcl_Interp  *interp (in)  Interpreter in which to execute the specified 
  364.            command. 
  365.  
  366.  char  *key (in)  Key for association with which to store data or from which to 
  367.            delete or retrieve data.  Typically the module prefix for a package. 
  368.  
  369.  Tcl_InterpDeleteProc  *delProc (in)  Procedure to call when interp is deleted. 
  370.  
  371.  Tcl_InterpDeleteProc  **delProcPtr (in)  Pointer to location in which to store 
  372.            address of current deletion procedure for association.  Ignored if 
  373.            NULL. 
  374.  
  375.  ClientData  clientData (in)  Arbitrary one-word value associated with the 
  376.            given key in this interpreter.  This data is owned by the caller. 
  377.  
  378.  DESCRIPTION 
  379.  
  380.  These procedures allow extensions to associate their own data with a Tcl 
  381.  interpreter. An association consists of a string key, typically the name of 
  382.  the extension, and a one-word value, which is typically a pointer to a data 
  383.  structure holding data specific to the extension. Tcl makes no interpretation 
  384.  of either the key or the value for an association. 
  385.  
  386.  Storage management is facilitated by storing with each association a procedure 
  387.  to call when the interpreter is deleted. This procedure can dispose of the 
  388.  storage occupied by the client's data in any way it sees fit. 
  389.  
  390.  Tcl_SetAssocData creates an association between a string key and a user 
  391.  specified datum in the given interpreter. If there is already an association 
  392.  with the given key, Tcl_SetAssocData overwrites it with the new information. 
  393.  It is up to callers to organize their use of names to avoid conflicts, for 
  394.  example, by using package names as the keys. If the deleteProc argument is 
  395.  non-NULL it specifies the address of a procedure to invoke if the interpreter 
  396.  is deleted before the association is deleted.  DeleteProc should have 
  397.  arguments and result that match the type Tcl_InterpDeleteProc: 
  398.  
  399.   typedef void Tcl_InterpDeleteProc(
  400.          ClientData clientData,
  401.          Tcl_Interp *interp);
  402.  When deleteProc is invoked the clientData and interp arguments will be the 
  403.  same as the corresponding arguments passed to Tcl_SetAssocData. The deletion 
  404.  procedure will not be invoked if the association is deleted before the 
  405.  interpreter is deleted. 
  406.  
  407.  Tcl_GetAssocData returns the datum stored in the association with the 
  408.  specified key in the given interpreter, and if the delProcPtr field is 
  409.  non-NULL, the address indicated by it gets the address of the delete procedure 
  410.  stored with this association. If no association with the specified key exists 
  411.  in the given interpreter Tcl_GetAssocData returns NULL. 
  412.  
  413.  Tcl_DeleteAssocData deletes an association with a specified key in the given 
  414.  interpreter.  It does not call the deletion procedure. 
  415.  
  416.  KEYWORDS 
  417.  
  418.  association, data, deletion procedure, interpreter, key 
  419.  
  420.  
  421. ΓòÉΓòÉΓòÉ 2.6. Tcl_AsyncCreate ΓòÉΓòÉΓòÉ
  422.  
  423.  NAME 
  424.  
  425. Tcl_AsyncCreate, Tcl_AsyncMark, Tcl_AsyncInvoke, Tcl_AsyncDelete - handle 
  426. asynchronous events 
  427.  
  428. SYNOPSIS 
  429.  
  430. #include <tcl.h> 
  431.  
  432.  Tcl_AsyncHandler 
  433.  Tcl_AsyncCreate(proc, clientData) 
  434.  
  435.  Tcl_AsyncMark(async) 
  436.  
  437.  int 
  438.  Tcl_AsyncInvoke(interp, code) 
  439.  
  440.  Tcl_AsyncDelete(async) 
  441.  
  442.  int 
  443.  Tcl_AsyncReady() 
  444.  
  445. ARGUMENTS 
  446.  
  447.  Tcl_AsyncProc  *proc (in)  Procedure to invoke to handle an asynchronous 
  448.            event. 
  449.  
  450.  ClientData  clientData (in)  One-word value to pass to proc. 
  451.  
  452.  Tcl_AsyncHandler  async (in)  Token for asynchronous event handler. 
  453.  
  454.  Tcl_Interp  *interp (in)  Tcl interpreter in which command was being evaluated 
  455.            when handler was invoked, or NULL if handler was invoked when there 
  456.            was no interpreter active. 
  457.  
  458.  int  code (in)  Completion code from command that just completed in interp, or 
  459.            0 if interp is NULL. 
  460.  
  461.  DESCRIPTION 
  462.  
  463.  These procedures provide a safe mechanism for dealing with asynchronous events 
  464.  such as signals. If an event such as a signal occurs while a Tcl script is 
  465.  being evaluated then it isn't safe to take any substantive action to process 
  466.  the event. For example, it isn't safe to evaluate a Tcl script since the 
  467.  interpreter may already be in the middle of evaluating a script; it may not 
  468.  even be safe to allocate memory, since a memory allocation could have been in 
  469.  progress when the event occurred. The only safe approach is to set a flag 
  470.  indicating that the event occurred, then handle the event later when the world 
  471.  has returned to a clean state, such as after the current Tcl command 
  472.  completes. 
  473.  
  474.  Tcl_AsyncCreate creates an asynchronous handler and returns a token for it. 
  475.  The asynchronous handler must be created before any occurrences of the 
  476.  asynchronous event that it is intended to handle (it is not safe to create a 
  477.  handler at the time of an event). When an asynchronous event occurs the code 
  478.  that detects the event (such as a signal handler) should call Tcl_AsyncMark 
  479.  with the token for the handler. Tcl_AsyncMark will mark the handler as ready 
  480.  to execute, but it will not invoke the handler immediately. Tcl will call the 
  481.  proc associated with the handler later, when the world is in a safe state, and 
  482.  proc can then carry out the actions associated with the asynchronous event. 
  483.  Proc should have arguments and result that match the type Tcl_AsyncProc: 
  484.  
  485.   typedef int Tcl_AsyncProc(
  486.          ClientData clientData,
  487.          Tcl_Interp *interp,
  488.          int code);
  489.  The clientData will be the same as the clientData argument passed to 
  490.  Tcl_AsyncCreate when the handler was created. If proc is invoked just after a 
  491.  command has completed execution in an interpreter, then interp will identify 
  492.  the interpreter in which the command was evaluated and code will be the 
  493.  completion code returned by that command. The command's result will be present 
  494.  in interp->result. When proc returns, whatever it leaves in interp->result 
  495.  will be returned as the result of the command and the integer value returned 
  496.  by proc will be used as the new completion code for the command. 
  497.  
  498.  It is also possible for proc to be invoked when no interpreter is active. This 
  499.  can happen, for example, if an asynchronous event occurs while the application 
  500.  is waiting for interactive input or an X event. In this case interp will be 
  501.  NULL and code will be 0, and the return value from proc will be ignored. 
  502.  
  503.  The procedure Tcl_AsyncInvoke is called to invoke all of the handlers that are 
  504.  ready. The procedure Tcl_AsyncReady will return non-zero whenever any 
  505.  asynchronous handlers are ready;  it can be checked to avoid calls to 
  506.  Tcl_AsyncInvoke when there are no ready handlers. Tcl calls Tcl_AsyncReady 
  507.  after each command is evaluated and calls Tcl_AsyncInvoke if needed. 
  508.  Applications may also call Tcl_AsyncInvoke at interesting times for that 
  509.  application. For example, Tcl's event handler calls Tcl_AsyncReady after each 
  510.  event and calls Tcl_AsyncInvoke if needed. The interp and code arguments to 
  511.  Tcl_AsyncInvoke have the same meaning as for proc:  they identify the active 
  512.  interpreter, if any, and the completion code from the command that just 
  513.  completed. 
  514.  
  515.  Tcl_AsyncDelete removes an asynchronous handler so that its proc will never be 
  516.  invoked again. A handler can be deleted even when ready, and it will still not 
  517.  be invoked. 
  518.  
  519.  If multiple handlers become active at the same time, the handlers are invoked 
  520.  in the order they were created (oldest handler first). The code and 
  521.  interp->result for later handlers reflect the values returned by earlier 
  522.  handlers, so that the most recently created handler has last say about the 
  523.  interpreter's result and completion code. If new handlers become ready while 
  524.  handlers are executing, Tcl_AsyncInvoke will invoke them all;  at each point 
  525.  it invokes the highest-priority (oldest) ready handler, repeating this over 
  526.  and over until there are no longer any ready handlers. 
  527.  
  528.  WARNING 
  529.  
  530.  It is almost always a bad idea for an asynchronous event handler to modify 
  531.  interp->result or return a code different from its code argument. This sort of 
  532.  behavior can disrupt the execution of scripts in subtle ways and result in 
  533.  bugs that are extremely difficult to track down. If an asynchronous event 
  534.  handler needs to evaluate Tcl scripts then it should first save interp->result 
  535.  plus the values of the variables errorInfo and errorCode (this can be done, 
  536.  for example, by storing them in dynamic strings). When the asynchronous 
  537.  handler is finished it should restore interp->result, errorInfo, and 
  538.  errorCode, and return the code argument. 
  539.  
  540.  KEYWORDS 
  541.  
  542.  asynchronous event, handler, signal 
  543.  
  544.  
  545. ΓòÉΓòÉΓòÉ 2.7. Tcl_BackgroundError ΓòÉΓòÉΓòÉ
  546.  
  547.  NAME 
  548.  
  549. Tcl_BackgroundError - report Tcl error that occurred in background processing 
  550.  
  551. SYNOPSIS 
  552.  
  553. #include <tcl.h> 
  554.  
  555.  Tcl_BackgroundError(interp) 
  556.  
  557. ARGUMENTS 
  558.  
  559.  Tcl_Interp  *interp (in)  Interpreter in which the error occurred. 
  560.  
  561.  DESCRIPTION 
  562.  
  563.  This procedure is typically invoked when a Tcl error occurs during "background 
  564.  processing" such as executing an event handler. When such an error occurs, the 
  565.  error condition is reported to Tcl or to a widget or some other C code, and 
  566.  there is not usually any obvious way for that code to report the error to the 
  567.  user. In these cases the code calls Tcl_BackgroundError with an interp 
  568.  argument identifying the interpreter in which the error occurred.  At the time 
  569.  Tcl_BackgroundError is invoked, interp->result is expected to contain an error 
  570.  message. Tcl_BackgroundError will invoke the bgerror Tcl command to report the 
  571.  error in an application-specific fashion. If no bgerror command exists, or if 
  572.  it returns with an error condition, then Tcl_BackgroundError reports the error 
  573.  itself by printing a message on the standard error file. 
  574.  
  575.  Tcl_BackgroundError does not invoke bgerror immediately because this could 
  576.  potentially interfere with scripts that are in process at the time the error 
  577.  occurred. Instead, it invokes bgerror later as an idle callback. 
  578.  Tcl_BackgroundError saves the values of the errorInfo and errorCode variables 
  579.  and restores these values just before invoking bgerror. 
  580.  
  581.  It is possible for many background errors to accumulate before bgerror is 
  582.  invoked.  When this happens, each of the errors is processed in order. 
  583.  However, if bgerror returns a break exception, then all remaining error 
  584.  reports for the interpreter are skipped. 
  585.  
  586.  KEYWORDS 
  587.  
  588.  background, bgerror, error 
  589.  
  590.  
  591. ΓòÉΓòÉΓòÉ 2.8. Tcl_Backslash ΓòÉΓòÉΓòÉ
  592.  
  593.  NAME 
  594.  
  595. Tcl_Backslash - parse a backslash sequence 
  596.  
  597. SYNOPSIS 
  598.  
  599. #include <tcl.h> 
  600.  
  601.  char 
  602.  Tcl_Backslash(src, countPtr) 
  603.  
  604. ARGUMENTS 
  605.  
  606.  char  *src (in)  Pointer to a string starting with a backslash. 
  607.  
  608.  int  *countPtr (out)  If countPtr isn't NULL, *countPtr gets filled in with 
  609.            number of characters in the backslash sequence, including the 
  610.            backslash character. 
  611.  
  612.  DESCRIPTION 
  613.  
  614.  This is a utility procedure used by several of the Tcl commands.  It parses a 
  615.  backslash sequence and returns the single character corresponding to the 
  616.  sequence. Tcl_Backslash modifies *countPtr to contain the number of characters 
  617.  in the backslash sequence. 
  618.  
  619.  See the Tcl manual entry for information on the valid backslash sequences. All 
  620.  of the sequences described in the Tcl manual entry are supported by 
  621.  Tcl_Backslash. 
  622.  
  623.  KEYWORDS 
  624.  
  625.  backslash, parse 
  626.  
  627.  
  628. ΓòÉΓòÉΓòÉ 2.9. Tcl_CallWhenDeleted ΓòÉΓòÉΓòÉ
  629.  
  630.  NAME 
  631.  
  632. Tcl_CallWhenDeleted, Tcl_DontCallWhenDeleted - Arrange for callback when 
  633. interpreter is deleted 
  634.  
  635. SYNOPSIS 
  636.  
  637. #include <tcl.h> 
  638.  
  639.  Tcl_CallWhenDeleted(interp, proc, clientData) 
  640.  
  641.  Tcl_DontCallWhenDeleted(interp, proc, clientData) 
  642.  
  643. ARGUMENTS 
  644.  
  645.  Tcl_Interp  *interp (in)  Interpreter with which to associated callback. 
  646.  
  647.  Tcl_InterpDeleteProc  *proc (in)  Procedure to call when interp is deleted. 
  648.  
  649.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  650.  
  651.  DESCRIPTION 
  652.  
  653.  Tcl_CallWhenDeleted arranges for proc to be called by Tcl_DeleteInterp if/when 
  654.  interp is deleted at some future time.  Proc will be invoked just before the 
  655.  interpreter is deleted, but the interpreter will still be valid at the time of 
  656.  the call. Proc should have arguments and result that match the type 
  657.  Tcl_InterpDeleteProc: 
  658.  
  659.   typedef void Tcl_InterpDeleteProc(
  660.          ClientData clientData,
  661.          Tcl_Interp *interp);
  662.  The clientData and interp parameters are copies of the clientData and interp 
  663.  arguments given to Tcl_CallWhenDeleted. Typically, clientData points to an 
  664.  application-specific data structure that proc uses to perform cleanup when an 
  665.  interpreter is about to go away. Proc does not return a value. 
  666.  
  667.  Tcl_DontCallWhenDeleted cancels a previous call to Tcl_CallWhenDeleted with 
  668.  the same arguments, so that proc won't be called after all when interp is 
  669.  deleted. If there is no deletion callback that matches interp, proc, and 
  670.  clientData then the call to Tcl_DontCallWhenDeleted has no effect. 
  671.  
  672.  KEYWORDS 
  673.  
  674.  callback, delete, interpreter 
  675.  
  676.  
  677. ΓòÉΓòÉΓòÉ 2.10. Tcl_CommandComplete ΓòÉΓòÉΓòÉ
  678.  
  679.  NAME 
  680.  
  681. Tcl_CommandComplete - Check for unmatched braces in a Tcl command 
  682.  
  683. SYNOPSIS 
  684.  
  685. #include <tcl.h> 
  686.  
  687.  int 
  688.  Tcl_CommandComplete(cmd) 
  689.  
  690. ARGUMENTS 
  691.  
  692.  char  *cmd (in)  Command string to test for completeness. 
  693.  
  694.  DESCRIPTION 
  695.  
  696.  Tcl_CommandComplete takes a Tcl command string as argument and determines 
  697.  whether it contains one or more complete commands (i.e. there are no unclosed 
  698.  quotes, braces, brackets, or variable references). If the command string is 
  699.  complete then it returns 1; otherwise it returns 0. 
  700.  
  701.  KEYWORDS 
  702.  
  703.  complete command, partial command 
  704.  
  705.  
  706. ΓòÉΓòÉΓòÉ 2.11. Tcl_Concat ΓòÉΓòÉΓòÉ
  707.  
  708.  NAME 
  709.  
  710. Tcl_Concat - concatenate a collection of strings 
  711.  
  712. SYNOPSIS 
  713.  
  714. #include <tcl.h> 
  715.  
  716.  char * 
  717.  Tcl_Concat(argc, argv) 
  718.  
  719. ARGUMENTS 
  720.  
  721.  int  argc (in)  Number of strings. 
  722.  
  723.  char  *argv[] (in)  Array of strings to concatenate.  Must have argc entries. 
  724.  
  725.  DESCRIPTION 
  726.  
  727.  Tcl_Concat is a utility procedure used by several of the Tcl commands.  Given 
  728.  a collection of strings, it concatenates them together into a single string, 
  729.  with the original strings separated by spaces.  This procedure behaves 
  730.  differently than Tcl_Merge, in that the arguments are simply concatenated: no 
  731.  effort is made to ensure proper list structure. However, in most common usage 
  732.  the arguments will all be proper lists themselves;  if this is true, then the 
  733.  result will also have proper list structure. 
  734.  
  735.  Tcl_Concat eliminates leading and trailing white space as it copies strings 
  736.  from argv to the result.  If an element of argv consists of nothing but white 
  737.  space, then that string is ignored entirely.  This white-space removal was 
  738.  added to make the output of the concat command cleaner-looking. 
  739.  
  740.  The result string is dynamically allocated using Tcl_Alloc;  the caller must 
  741.  eventually release the space by calling Tcl_Free. 
  742.  
  743.  KEYWORDS 
  744.  
  745.  concatenate, strings 
  746.  
  747.  
  748. ΓòÉΓòÉΓòÉ 2.12. Tcl_CreateChannel ΓòÉΓòÉΓòÉ
  749.  
  750.  NAME 
  751.  
  752. Tcl_CreateChannel, Tcl_GetChannelInstanceData, Tcl_GetChannelType, 
  753. Tcl_GetChannelName, Tcl_GetChannelFile, Tcl_GetChannelMode, 
  754. Tcl_GetChannelBufferSize,  Tcl_SetDefaultTranslation, Tcl_SetChannelBufferSize 
  755. - procedures for creating and manipulating channels 
  756.  
  757. SYNOPSIS 
  758.  
  759. #include <tcl.h> 
  760.  
  761.  Tcl_Channel 
  762.  Tcl_CreateChannel(typePtr, channelName, instanceData, mask) 
  763.  
  764.  ClientData 
  765.  Tcl_GetChannelInstanceData(channel) 
  766.  
  767.  Tcl_ChannelType * 
  768.  Tcl_GetChannelType(channel) 
  769.  
  770.  char * 
  771.  Tcl_GetChannelName(channel) 
  772.  
  773.  Tcl_File 
  774.  Tcl_GetChannelFile(channel, direction) 
  775.  
  776.  int 
  777.  Tcl_GetChannelFlags(channel) 
  778.  
  779.  void 
  780.  Tcl_SetDefaultTranslation(channel, transMode) 
  781.  
  782.  int 
  783.  Tcl_GetChannelBufferSize(channel) 
  784.  
  785.  void 
  786.  Tcl_SetChannelBufferSize(channel, size) 
  787.  
  788. ARGUMENTS 
  789.  
  790.  Tcl_ChannelType  *typePtr (in)  Points to a structure containing the addresses 
  791.            of procedures that can be called to perform I/O and other functions 
  792.            on the channel. 
  793.  
  794.  char  *channelName (in)  The name of this channel, such as file3; must not be 
  795.            in use by any other channel. Can be NULL, in which case the channel 
  796.            is created without a name. 
  797.  
  798.  ClientData  instanceData (in)  Arbitrary one-word value to be associated with 
  799.            this channel.  This value is passed to procedures in typePtr when 
  800.            they are invoked. 
  801.  
  802.  int  mask (in)  OR-ed combination of TCL_READABLE and TCL_WRITABLE to indicate 
  803.            whether a channel is readable and writable. 
  804.  
  805.  Tcl_Channel  channel (in)  The channel to operate on. 
  806.  
  807.  int  direction (in)  TCL_READABLE means the input file is wanted; TCL_WRITABLE 
  808.            means the output file is wanted. 
  809.  
  810.  Tcl_EolTranslation  transMode (in)  The translation mode; one of the constants 
  811.            TCL_TRANSLATE_AUTO, TCL_TRANSLATE_CR, TCL_TRANSLATE_LF and 
  812.            TCL_TRANSLATE_CRLF. 
  813.  
  814.  int  size (in)  The size, in bytes, of buffers to allocate in this channel. 
  815.  
  816.  DESCRIPTION 
  817.  
  818.  Tcl uses a two-layered channel architecture. It provides a generic upper layer 
  819.  to enable C and Tcl programs to perform input and output using the same APIs 
  820.  for a variety of files, devices, sockets etc. The generic C APIs are described 
  821.  in the manual entry for Tcl_OpenFileChannel. 
  822.  
  823.  The lower layer provides type-specific channel drivers for each type of file, 
  824.  socket and device supported on each platform. This manual entry describes the 
  825.  C APIs used by the generic layer to communicate with type-specific channel 
  826.  drivers to perform the input and output operations. It also explains how new 
  827.  types of channels can be added by providing new channel drivers. 
  828.  
  829.  Channel drivers consist of a number of components: First, each channel driver 
  830.  provides a Tcl_ChannelType structure containing pointers to functions 
  831.  implementing the various operations used by the generic layer to communicate 
  832.  with the channel driver. The Tcl_ChannelType structure and the functions 
  833.  referenced by it are described in the section TCL_CHANNELTYPE, below. 
  834.  
  835.  Second, channel drivers usually provide a Tcl command to create instances of 
  836.  that type of channel. For example, the Tcl open command creates channels that 
  837.  use the file and command channel drivers, and the Tcl socket command creates 
  838.  channels that use TCP sockets for network communication. 
  839.  
  840.  Third, a channel driver optionally provides a C function to open channel 
  841.  instances of that type. For example, Tcl_OpenFileChannel opens a channel that 
  842.  uses the file channel driver, and Tcl_OpenTcpClient opens a channel that uses 
  843.  the TCP network protocol. These creation functions typically use 
  844.  Tcl_CreateChannel internally to open the channel. 
  845.  
  846.  To add a new type of channel you must implement a C API or a Tcl command that 
  847.  opens a channel by invoking Tcl_CreateChannel. When your driver calls 
  848.  Tcl_CreateChannel it passes in a Tcl_ChannelType structure describing the 
  849.  driver's I/O procedures. The generic layer will then invoke the functions 
  850.  referenced in that structure to perform operations on the channel. 
  851.  
  852.  Tcl_CreateChannel opens a new channel and associates the supplied typePtr and 
  853.  instanceData with it. The channel is opened in the mode indicated by mask. For 
  854.  a discussion of channel drivers, their operations and the Tcl_ChannelType 
  855.  structure, see the section TCL_CHANNELTYPE, below. 
  856.  
  857.  Tcl_GetChannelInstanceData returns the instance data associated with the 
  858.  channel in channel. This is the same as the instanceData argument in the call 
  859.  to Tcl_CreateChannel that created this channel. 
  860.  
  861.  Tcl_GetChannelType returns a pointer to the Tcl_ChannelType structure used by 
  862.  the channel in the channel argument. This is the same as the typePtr argument 
  863.  in the call to Tcl_CreateChannel that created this channel. 
  864.  
  865.  Tcl_GetChannelName returns a string containing the name associated with the 
  866.  channel, or NULL if the channelName argument to Tcl_CreateChannel was NULL. 
  867.  
  868.  Tcl_GetChannelFile returns the inFile associated with channel if direction is 
  869.  TCL_READABLE, or the outFile if direction is TCL_WRITABLE. The operation 
  870.  returns NULL if the channel is not based on Tcl_Files or if the channel is not 
  871.  open for the specified direction. 
  872.  
  873.  Tcl_GetChannelMode returns an OR-ed combination of TCL_READABLE and 
  874.  TCL_WRITABLE, indicating whether the channel is open for input and output. 
  875.  
  876.  Tcl_SetDefaultTranslation sets the default end of line translation mode. This 
  877.  mode will be installed as the translation mode for the channel if an attempt 
  878.  is made to output on the channel while it is still in TCL_TRANSLATE_AUTO mode. 
  879.  For a description of end of line translation modes, see the manual entry for 
  880.  fconfigure. 
  881.  
  882.  Tcl_GetChannelBufferSize returns the size, in bytes, of buffers allocated to 
  883.  store input or output in chan. If the value was not set by a previous call to 
  884.  Tcl_SetChannelBufferSize, described below, then the default value of 4096 is 
  885.  returned. 
  886.  
  887.  Tcl_SetChannelBufferSize sets the size, in bytes, of buffers that will be 
  888.  allocated in subsequent operations on the channel to store input or output. 
  889.  The size argument should be between ten and one million, allowing buffers of 
  890.  ten bytes to one million bytes. If size is outside this range, 
  891.  Tcl_SetChannelBufferSize sets the buffer size to 4096. 
  892.  
  893.  TCL_CHANNELTYPE 
  894.  
  895.  A channel driver provides a Tcl_ChannelType structure that contains pointers 
  896.  to functions that implement the various operations on a channel; these 
  897.  operations are invoked as needed by the generic layer. The Tcl_ChannelType 
  898.  structure contains the following fields: 
  899.  
  900.   typedef struct Tcl_ChannelType {
  901.          char *typeName;
  902.          Tcl_DriverBlockModeProc *blockModeProc;
  903.          Tcl_DriverCloseProc *closeProc;
  904.          Tcl_DriverInputProc *inputProc;
  905.          Tcl_DriverOutputProc *outputProc;
  906.          Tcl_DriverSeekProc *seekProc;
  907.          Tcl_DriverSetOptionProc *setOptionProc;
  908.          Tcl_DriverGetOptionProc *getOptionProc;
  909.          Tcl_DriverWatchChannelProc *watchChannelProc;
  910.          Tcl_DriverChannelReadyProc *channelReadyProc;
  911.          Tcl_DriverGetFileProc *getFileProc;
  912.   } Tcl_ChannelType;
  913.  
  914.  The driver must provide implementations for all functions except 
  915.  blockModeProc, seekProc, setOptionProc, and getOptionProc, which may be 
  916.  specified as NULL to indicate that the channel does not support seeking. 
  917.  Other functions that can not be implemented for this type of device should 
  918.  return EINVAL when invoked to indicate that they are not implemented. 
  919.  
  920.  TYPENAME 
  921.  
  922.  The typeName field contains a null-terminated string that identifies the type 
  923.  of the device implemented by this driver, e.g. file or socket. 
  924.  
  925.  BLOCKMODEPROC 
  926.  
  927.  The blockModeProc field contains the address of a function called by the 
  928.  generic layer to set blocking and nonblocking mode on the device. 
  929.  BlockModeProc should match the following prototype: 
  930.  
  931.   typedef int Tcl_DriverBlockModeProc(
  932.          ClientData instanceData,
  933.          int mode);
  934.  
  935.  The instanceData is the same as the value passed to Tcl_CreateChannel when 
  936.  this channel was created.  The mode argument is either TCL_MODE_BLOCKING or 
  937.  TCL_MODE_NONBLOCKING to set the device into blocking or nonblocking mode. The 
  938.  function should return zero if the operation was successful, or a nonzero 
  939.  POSIX error code if the operation failed. 
  940.  
  941.  If the operation is successful, the function can modify the supplied 
  942.  instanceData to record that the channel entered blocking or nonblocking mode 
  943.  and to implement the blocking or nonblocking behavior. For some device types, 
  944.  the blocking and nonblocking behavior can be implemented by the underlying 
  945.  operating system; for other device types, the behavior must be emulated in the 
  946.  channel driver. 
  947.  
  948.  CLOSEPROC 
  949.  
  950.  The closeProc field contains the address of a function called by the generic 
  951.  layer to clean up driver-related information when the channel is closed. 
  952.  CloseProc must match the following prototype: 
  953.  
  954.   typedef int Tcl_DriverCloseProc(
  955.          ClientData instanceData,
  956.          Tcl_Interp *interp);
  957.  
  958.  The instanceData argument is the same as the value provided to 
  959.  Tcl_CreateChannel when the channel was created. The function should release 
  960.  any storage maintained by the channel driver for this channel, and close the 
  961.  input and output devices encapsulated by this channel. All queued output will 
  962.  have been flushed to the device before this function is called, and no further 
  963.  driver operations will be invoked on this instance after calling the 
  964.  closeProc. If the close operation is successful, the procedure should return 
  965.  zero; otherwise it should return a nonzero POSIX error code. In addition, if 
  966.  an error occurs and interp is not NULL, the procedure should store an error 
  967.  message in interp->result. 
  968.  
  969.  INPUTPROC 
  970.  
  971.  The inputProc field contains the address of a function called by the generic 
  972.  layer to read data from the file or device and store it in an internal buffer. 
  973.  InputProc must match the following prototype: 
  974.  
  975.   typedef int Tcl_DriverInputProc(
  976.          ClientData instanceData,
  977.          char *buf,
  978.          int bufSize,
  979.          int *errorCodePtr);
  980.  
  981.  InstanceData is the same as the value passed to Tcl_CreateChannel when the 
  982.  channel was created.  The buf argument points to an array of bytes in which to 
  983.  store input from the device, and the bufSize argument indicates how many bytes 
  984.  are available at buf. 
  985.  
  986.  The errorCodePtr argument points to an integer variable provided by the 
  987.  generic layer. If an error occurs, the function should set the variable to a 
  988.  POSIX error code that identifies the error that occurred. 
  989.  
  990.  The function should read data from the input device encapsulated by the 
  991.  channel and store it at buf.  On success, the function should return a 
  992.  nonnegative integer indicating how many bytes were read from the input device 
  993.  and stored at buf. On error, the function should return -1. If an error occurs 
  994.  after some data has been read from the device, that data is lost. 
  995.  
  996.  If inputProc can determine that the input device has some data available but 
  997.  less than requested by the bufSize argument, the function should only attempt 
  998.  to read as much data as is available and return without blocking. If the input 
  999.  device has no data available whatsoever and the channel is in nonblocking 
  1000.  mode, the function should return an EAGAIN error. If the input device has no 
  1001.  data available whatsoever and the channel is in blocking mode, the function 
  1002.  should block for the shortest possible time until at least one byte of data 
  1003.  can be read from the device; then, it should return as much data as it can 
  1004.  read without blocking. 
  1005.  
  1006.  OUTPUTPROC 
  1007.  
  1008.  The outputProc field contains the address of a function called by the generic 
  1009.  layer to transfer data from an internal buffer to the output device. 
  1010.  OutputProc must match the following prototype: 
  1011.  
  1012.   typedef int Tcl_DriverOutputProc(
  1013.          ClientData instanceData,
  1014.          char *buf,
  1015.          int toWrite,
  1016.          int *errorCodePtr);
  1017.  
  1018.  InstanceData is the same as the value passed to Tcl_CreateChannel when the 
  1019.  channel was created. The buf argument contains an array of bytes to be written 
  1020.  to the device, and the toWrite argument indicates how many bytes are to be 
  1021.  written from the buf argument. 
  1022.  
  1023.  The errorCodePtr argument points to an integer variable provided by the 
  1024.  generic layer. If an error occurs, the function should set this variable to a 
  1025.  POSIX error code that identifies the error. 
  1026.  
  1027.  The function should write the data at buf to the output device encapsulated by 
  1028.  the channel. On success, the function should return a nonnegative integer 
  1029.  indicating how many bytes were written to the output device.  The return value 
  1030.  is normally the same as toWrite, but may be less in some cases such as if the 
  1031.  output operation is interrupted by a signal. If an error occurs the function 
  1032.  should return -1.  In case of error, some data may have been written to the 
  1033.  device. 
  1034.  
  1035.  If the channel is nonblocking and the output device is unable to absorb any 
  1036.  data whatsoever, the function should return -1 with an EAGAIN error without 
  1037.  writing any data. 
  1038.  
  1039.  SEEKPROC 
  1040.  
  1041.  The seekProc field contains the address of a function called by the generic 
  1042.  layer to move the access point at which subsequent input or output operations 
  1043.  will be applied. SeekProc must match the following prototype: 
  1044.  
  1045.   typedef int Tcl_DriverSeekProc(
  1046.          ClientData instanceData,
  1047.          long offset,
  1048.          int seekMode,
  1049.          int *errorCodePtr);
  1050.  
  1051.  The instanceData argument is the same as the value given to Tcl_CreateChannel 
  1052.  when this channel was created.  Offset and seekMode have the same meaning as 
  1053.  for the Tcl_SeekChannel procedure (described in the manual entry for 
  1054.  Tcl_OpenFileChannel). 
  1055.  
  1056.  The errorCodePtr argument points to an integer variable provided by the 
  1057.  generic layer for returning errno values from the function.  The function 
  1058.  should set this variable to a POSIX error code if an error occurs. The 
  1059.  function should store an EINVAL error code if the channel type does not 
  1060.  implement seeking. 
  1061.  
  1062.  The return value is the new access point or -1 in case of error. If an error 
  1063.  occurred, the function should not move the access point. 
  1064.  
  1065.  SETOPTIONPROC 
  1066.  
  1067.  The setOptionProc field contains the address of a function called by the 
  1068.  generic layer to set a channel type specific option on a channel. 
  1069.  setOptionProc must match the following prototype: 
  1070.  
  1071.   typedef int Tcl_DriverSetOptionProc(
  1072.          ClientData instanceData,
  1073.          Tcl_Interp *interp,
  1074.          char *optionName,
  1075.          char *optionValue);
  1076.  
  1077.  optionName is the name of an option to set, and optionValue is the new value 
  1078.  for that option, as a string. The instanceData is the same as the value given 
  1079.  to Tcl_CreateChannel when this channel was created. The function should do 
  1080.  whatever channel type specific action is required to implement the new value 
  1081.  of the option. 
  1082.  
  1083.  Some options are handled by the generic code and this function is never called 
  1084.  to set them, e.g. -blockmode. Other options are specific to each channel type 
  1085.  and the setOptionProc procedure of the channel driver will get called to 
  1086.  implement them. The setOptionProc field can be NULL, which indicates that this 
  1087.  channel type supports no type specific options. 
  1088.  
  1089.  If the option value is successfully modified to the new value, the function 
  1090.  returns TCL_OK. It returns TCL_ERROR if the optionName is unrecognized or if 
  1091.  optionValue specifies a value for the option that is not supported. In this 
  1092.  case, the function leaves an error message in the result field of interp if 
  1093.  interp is not NULL. The function should also call Tcl_SetErrno to store an 
  1094.  appropriate POSIX error code. 
  1095.  
  1096.  GETOPTIONPROC 
  1097.  
  1098.  The getOptionProc field contains the address of a function called by the 
  1099.  generic layer to get the value of a channel type specific option on a channel. 
  1100.  getOptionProc must match the following prototype: 
  1101.  
  1102.   typedef int Tcl_DriverGetOptionProc(
  1103.          ClientData instanceData,
  1104.          char *optionName,
  1105.          Tcl_DString *dsPtr);
  1106.  
  1107.  OptionName is the name of an option supported by this type of channel. If the 
  1108.  option name is not NULL, the function stores its current value, as a string, 
  1109.  in the Tcl dynamic string dsPtr. If optionName is NULL, the function stores in 
  1110.  dsPtr an alternating list of all supported options and their current values. 
  1111.  On success, the function returns TCL_OK. If an error occurs, the function 
  1112.  returns TCL_ERROR and calls Tcl_SetErrno to store an appropriate POSIX error 
  1113.  code. 
  1114.  
  1115.  Some options are handled by the generic code and this function is never called 
  1116.  to retrieve their value, e.g. -blockmode. Other options are specific to each 
  1117.  channel type and the getOptionProc procedure of the channel driver will get 
  1118.  called to implement them. The getOptionProc field can be NULL, which indicates 
  1119.  that this channel type supports no type specific options. 
  1120.  
  1121.  WATCHCHANNELPROC 
  1122.  
  1123.  The watchChannelProc field contains the address of a function called by the 
  1124.  generic layer to initialize the event notification mechanism to notice events 
  1125.  of interest on this channel. WatchChannelProc should match the following 
  1126.  prototype: 
  1127.  
  1128.   typeded void Tcl_DriverWatchChannelProc(
  1129.          ClientData instanceData,
  1130.          int mask);
  1131.  
  1132.  The instanceData is the same as the value passed to Tcl_CreateChannel when 
  1133.  this channel was created. The mask argument is an OR-ed combination of 
  1134.  TCL_READABLE, TCL_WRITABLE and TCL_EXCEPTION; it indicates events the caller 
  1135.  is interested in noticing on this channel. 
  1136.  
  1137.  The function should initialize device type specific mechanisms to notice when 
  1138.  an event of interest is present on the channel. It may invoke 
  1139.  Tcl_SetMaxBlockTime to specify an upper limit on the length of time to wait 
  1140.  for an event, and it may invoke Tcl_WatchFile if the channel implementation is 
  1141.  based on Tcl_Files. 
  1142.  
  1143.  CHANNELREADYPROC 
  1144.  
  1145.  The channelReadyProc field contains the address of a function called by the 
  1146.  generic layer to sense whether events of interest have occurred for this 
  1147.  channel. ChannelReadyProc should match the following prototype: 
  1148.  
  1149.   typedef int Tcl_DriverChannelReadyProc(
  1150.          ClientData instanceData,
  1151.          int mask);
  1152.  
  1153.  InstanceData is the same as the value passed to Tcl_CreateChannel when this 
  1154.  channel was created. The mask argument is an OR-ed combination of 
  1155.  TCL_READABLE, TCL_WRITABLE and TCL_EXCEPTION indicating what events are of 
  1156.  interest. The function returns a mask containing an OR-ed combination of a 
  1157.  subset of the flags in mask to indicate what events have actually occurred on 
  1158.  the channel. 
  1159.  
  1160.  The function should use a device type dependent mechanism to detect whether 
  1161.  events of interest have occurred on the channel. It may invoke Tcl_FileReady 
  1162.  if the channel implementation is based on Tcl_Files. 
  1163.  
  1164.  GETFILEPROC 
  1165.  
  1166.  The getFileProc field contains the address of a function called by the generic 
  1167.  layer to retrieve a Tcl_File from the channel. GetFileProc should match the 
  1168.  following prototype: 
  1169.  
  1170.   typedef Tcl_File Tcl_DriverGetFileProc(
  1171.          ClientData instanceData,
  1172.          int direction);
  1173.  
  1174.  InstanceData is the same as the value passed to Tcl_CreateChannel when this 
  1175.  channel was created. The direction argument is either TCL_READABLE to retrieve 
  1176.  the Tcl_File used for input, or TCL_WRITABLE to retrieve the Tcl_File used for 
  1177.  output. 
  1178.  
  1179.  If the channel implementation is based on Tcl_Files, the function should 
  1180.  retrieve the appropriate Tcl_File associated with the channel, according the 
  1181.  direction argument; it can return NULL if the channel is not open for that 
  1182.  direction.  If the channel implementation does not use Tcl_Files, the function 
  1183.  should always return NULL. 
  1184.  
  1185.  SEE ALSO 
  1186.  
  1187.  Tcl_Close(3), Tcl_OpenFileChannel(3), Tcl_SetErrno(3), Tcl_SetMaxBlockTime(3), 
  1188.  Tcl_WatchFile(3), Tcl_FileReady(3) 
  1189.  
  1190.  KEYWORDS 
  1191.  
  1192.  blocking, channel driver, channel registration, channel type, nonblocking 
  1193.  
  1194.  
  1195. ΓòÉΓòÉΓòÉ 2.13. Tcl_CreateChannelHandler ΓòÉΓòÉΓòÉ
  1196.  
  1197.  NAME 
  1198.  
  1199. Tcl_CreateChannelHandler, Tcl_DeleteChannelHandler - call a procedure when a 
  1200. channel becomes readable or writable 
  1201.  
  1202. SYNOPSIS 
  1203.  
  1204. #include <tcl.h> 
  1205.  
  1206.  void 
  1207.  Tcl_CreateChannelHandler(channel, mask, proc, clientData) 
  1208.  
  1209.  void 
  1210.  Tcl_DeleteChannelHandler(channel, proc, clientData) 
  1211.  
  1212. ARGUMENTS 
  1213.  
  1214.  Tcl_Channel  channel (in)  Tcl channel such as returned by Tcl_CreateChannel. 
  1215.  
  1216.  int  mask (in)  Conditions under which proc should be called: OR-ed 
  1217.            combination of TCL_READABLE, TCL_WRITABLE and TCL_EXCEPTION. Specify 
  1218.            a zero value to temporarily disable an existing handler. 
  1219.  
  1220.  Tcl_FileProc  *proc (in)  Procedure to invoke whenever the channel indicated 
  1221.            by channel meets the conditions specified by mask. 
  1222.  
  1223.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  1224.  
  1225.  DESCRIPTION 
  1226.  
  1227.  Tcl_CreateChannelHandler arranges for proc to be called in the future whenever 
  1228.  input or output becomes possible on the channel identified by channel, or 
  1229.  whenever an exceptional condition exists for channel. The conditions of 
  1230.  interest under which proc will be invoked are specified by the mask argument. 
  1231.  See the manual entry for fileevent for a precise description of what it means 
  1232.  for a channel to be readable or writable. Proc must conform to the following 
  1233.  prototype: 
  1234.  
  1235.   typedef void Tcl_ChannelProc(
  1236.          ClientData clientData,
  1237.          int mask);
  1238.  
  1239.  The clientData argument is the same as the value passed to 
  1240.  Tcl_CreateChannelHandler when the handler was created. Typically, clientData 
  1241.  points to a data structure containing application-specific information about 
  1242.  the channel. Mask is an integer mask indicating which of the requested 
  1243.  conditions actually exists for the channel; it will contain a subset of the 
  1244.  bits from the mask argument to Tcl_CreateChannelHandler when the handler was 
  1245.  created. 
  1246.  
  1247.  Each channel handler is identified by a unique combination of channel, proc 
  1248.  and clientData. There may be many handlers for a given channel as long as they 
  1249.  don't have the same channel, proc, and clientData. If Tcl_CreateChannelHandler 
  1250.  is invoked when there is already a handler for channel, proc, and clientData, 
  1251.  then no new handler is created;  instead, the mask is changed for the existing 
  1252.  handler. 
  1253.  
  1254.  Tcl_DeleteChannelHandler deletes a channel handler identified by channel, proc 
  1255.  and clientData; if no such handler exists, the call has no effect. 
  1256.  
  1257.  Channel handlers are invoked via the Tcl event mechanism, so they are only 
  1258.  useful in applications that are event-driven. Note also that the conditions 
  1259.  specified in the mask argument to proc may no longer exist when proc is 
  1260.  invoked:  for example, if there are two handlers for TCL_READABLE on the same 
  1261.  channel, the first handler could consume all of the available input so that 
  1262.  the channel is no longer readable when the second handler is invoked. For this 
  1263.  reason it may be useful to use nonblocking I/O on channels for which there are 
  1264.  event handlers. 
  1265.  
  1266.  SEE ALSO 
  1267.  
  1268.  Notifier(3), Tcl_CreateChannel(3), Tcl_OpenFileChannel(3), vwait(n). 
  1269.  
  1270.  KEYWORDS 
  1271.  
  1272.  blocking, callback, channel, events, handler, nonblocking. 
  1273.  
  1274.  
  1275. ΓòÉΓòÉΓòÉ 2.14. Tcl_CreateCloseHandler ΓòÉΓòÉΓòÉ
  1276.  
  1277.  NAME 
  1278.  
  1279. Tcl_CreateCloseHandler, Tcl_DeleteCloseHandler - arrange for callbacks when 
  1280. channels are closed 
  1281.  
  1282. SYNOPSIS 
  1283.  
  1284. #include <tcl.h> 
  1285.  
  1286.  void 
  1287.  Tcl_CreateCloseHandler(channel, proc, clientData) 
  1288.  
  1289.  void 
  1290.  Tcl_DeleteCloseHandler(channel, proc, clientData) 
  1291.  
  1292. ARGUMENTS 
  1293.  
  1294.  Tcl_Channel  channel (in)  The channel for which to create or delete a close 
  1295.            callback. 
  1296.  
  1297.  Tcl_CloseProc  *proc (in)  The procedure to call as the callback. 
  1298.  
  1299.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  1300.  
  1301.  DESCRIPTION 
  1302.  
  1303.  Tcl_CreateCloseHandler arranges for proc to be called when channel is closed 
  1304.  with Tcl_Close or Tcl_UnregisterChannel, or using the Tcl close command. Proc 
  1305.  should match the following prototype: 
  1306.  
  1307.   typedef void Tcl_CloseProc(
  1308.          ClientData clientData);
  1309.  
  1310.  The clientData is the same as the value provided in the call to 
  1311.  Tcl_CreateCloseHandler. 
  1312.  
  1313.  Tcl_DeleteCloseHandler removes a close callback for channel. The proc and 
  1314.  clientData identify which close callback to remove; Tcl_DeleteCloseHandler 
  1315.  does nothing if its proc and clientData arguments do not match the proc and 
  1316.  clientData for a  close handler for channel. 
  1317.  
  1318.  SEE ALSO 
  1319.  
  1320.  close(n), Tcl_Close(3), Tcl_UnregisterChannel(3) 
  1321.  
  1322.  KEYWORDS 
  1323.  
  1324.  callback, channel closing 
  1325.  
  1326.  
  1327. ΓòÉΓòÉΓòÉ 2.15. Tcl_CreateCommand ΓòÉΓòÉΓòÉ
  1328.  
  1329.  NAME 
  1330.  
  1331. Tcl_CreateCommand, Tcl_DeleteCommand, Tcl_GetCommandInfo, Tcl_SetCommandInfo - 
  1332. implement new commands in C 
  1333.  
  1334. SYNOPSIS 
  1335.  
  1336. #include <tcl.h> 
  1337.  
  1338.  Tcl_Command 
  1339.  Tcl_CreateCommand(interp, cmdName, proc, clientData, deleteProc) 
  1340.  
  1341.  int 
  1342.  Tcl_DeleteCommand(interp, cmdName) 
  1343.  
  1344.  int 
  1345.  Tcl_GetCommandInfo(interp, cmdName, infoPtr) 
  1346.  
  1347.  int 
  1348.  Tcl_SetCommandInfo(interp, cmdName, infoPtr) 
  1349.  
  1350.  char * 
  1351.  Tcl_GetCommandName(interp, token) 
  1352.  
  1353. ARGUMENTS 
  1354.  
  1355.  Tcl_Interp  *interp (in)  Interpreter in which to create new command. 
  1356.  
  1357.  char  *cmdName (in)  Name of command. 
  1358.  
  1359.  Tcl_CmdProc  *proc (in)  Implementation of new command:  proc will be called 
  1360.            whenever cmdName is invoked as a command. 
  1361.  
  1362.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc and 
  1363.            deleteProc. 
  1364.  
  1365.  Tcl_CmdDeleteProc  *deleteProc (in)  Procedure to call before cmdName is 
  1366.            deleted from the interpreter; allows for command-specific cleanup. 
  1367.            If NULL, then no procedure is called before the command is deleted. 
  1368.  
  1369.  Tcl_CmdInfo  *infoPtr (in/out)  Pointer to structure containing various 
  1370.            information about a Tcl command. 
  1371.  
  1372.  Tcl_Command  token (in)  Token for command, returned by previous call to 
  1373.            Tcl_CreateCommand. The command must not have been deleted. 
  1374.  
  1375.  DESCRIPTION 
  1376.  
  1377.  Tcl_CreateCommand defines a new command in interp and associates it with 
  1378.  procedure proc such that whenever cmdName is invoked as a Tcl command (via a 
  1379.  call to Tcl_Eval) the Tcl interpreter will call proc to process the command. 
  1380.  If there is already a command cmdName associated with the interpreter, it is 
  1381.  deleted. Tcl_CreateCommand returns a token that may be used to refer to the 
  1382.  command in subsequent calls to Tcl_GetCommandName. If Tcl_CreateCommand is 
  1383.  called for an interpreter that is in the process of being deleted, then it 
  1384.  does not create a new command and it returns NULL. Proc should have arguments 
  1385.  and result that match the type Tcl_CmdProc: 
  1386.  
  1387.   typedef int Tcl_CmdProc(
  1388.          ClientData clientData,
  1389.          Tcl_Interp *interp,
  1390.          int argc,
  1391.          char *argv[]);
  1392.  When proc is invoked the clientData and interp parameters will be copies of 
  1393.  the clientData and interp arguments given to Tcl_CreateCommand. Typically, 
  1394.  clientData points to an application-specific data structure that describes 
  1395.  what to do when the command procedure is invoked.  Argc and argv describe the 
  1396.  arguments to the command, argc giving the number of arguments (including the 
  1397.  command name) and argv giving the values of the arguments as strings.  The 
  1398.  argv array will contain argc+1 values; the first argc values point to the 
  1399.  argument strings, and the last value is NULL. 
  1400.  
  1401.  Proc must return an integer code that is either TCL_OK, TCL_ERROR, TCL_RETURN, 
  1402.  TCL_BREAK, or TCL_CONTINUE.  See the Tcl overview man page for details on what 
  1403.  these codes mean.  Most normal commands will only return TCL_OK or TCL_ERROR. 
  1404.  In addition, proc must set interp->result to point to a string value; in the 
  1405.  case of a TCL_OK return code this gives the result of the command, and in the 
  1406.  case of TCL_ERROR it gives an error message. The Tcl_SetResult procedure 
  1407.  provides an easy interface for setting the return value;  for complete details 
  1408.  on how the interp->result field is managed, see the Tcl_Interp man page. 
  1409.  Before invoking a command procedure, Tcl_Eval sets interp->result to point to 
  1410.  an empty string, so simple commands can return an empty result by doing 
  1411.  nothing at all. 
  1412.  
  1413.  The contents of the argv array belong to Tcl and are not guaranteed to persist 
  1414.  once proc returns:  proc should not modify them, nor should it set 
  1415.  interp->result to point anywhere within the argv values. Call Tcl_SetResult 
  1416.  with status TCL_VOLATILE if you want to return something from the argv array. 
  1417.  
  1418.  DeleteProc will be invoked when (if) cmdName is deleted. This can occur 
  1419.  through a call to Tcl_DeleteCommand or Tcl_DeleteInterp, or by replacing 
  1420.  cmdName in another call to Tcl_CreateCommand. DeleteProc is invoked before the 
  1421.  command is deleted, and gives the application an opportunity to release any 
  1422.  structures associated with the command.  DeleteProc should have arguments and 
  1423.  result that match the type Tcl_CmdDeleteProc: 
  1424.  
  1425.   typedef void Tcl_CmdDeleteProc(ClientData clientData);
  1426.  The clientData argument will be the same as the clientData argument passed to 
  1427.  Tcl_CreateCommand. 
  1428.  
  1429.  Tcl_DeleteCommand deletes a command from a command interpreter. Once the call 
  1430.  completes, attempts to invoke cmdName in interp will result in errors. If 
  1431.  cmdName isn't bound as a command in interp then Tcl_DeleteCommand does nothing 
  1432.  and returns -1;  otherwise it returns 0. There are no restrictions on cmdName: 
  1433.  it may refer to a built-in command, an application-specific command, or a Tcl 
  1434.  procedure. 
  1435.  
  1436.  Tcl_GetCommandInfo checks to see whether its cmdName argument exists as a 
  1437.  command in interp.  If not then it returns 0. Otherwise it places information 
  1438.  about the command in the structure pointed to by infoPtr and returns 1. 
  1439.  Tcl_CmdInfo structures have fields named proc, clientData, and deleteProc, 
  1440.  which have the same meaning as the corresponding arguments to 
  1441.  Tcl_CreateCommand. There is also a field deleteData, which is the ClientData 
  1442.  value to pass to deleteProc;  it is normally the same as clientData but may be 
  1443.  set independently using the Tcl_SetCommandInfo procedure. 
  1444.  
  1445.  Tcl_SetCommandInfo is used to modify the procedures and ClientData values 
  1446.  associated with a command. Its cmdName argument is the name of a command in 
  1447.  interp. If this command does not exist then Tcl_SetCommandInfo returns 0. 
  1448.  Otherwise, it copies the information from *infoPtr to Tcl's internal structure 
  1449.  for the command and returns 1. Note that this procedure allows the ClientData 
  1450.  for a command's deletion procedure to be given a different value than the 
  1451.  ClientData for its command procedure. 
  1452.  
  1453.  Tcl_GetCommandName provides a mechanism for tracking commands that have been 
  1454.  renamed.  Given a token returned by Tcl_CreateCommand when the command was 
  1455.  created, Tcl_GetCommandName returns the string name of the command.  If the 
  1456.  command has been renamed since it was created, then Tcl_GetCommandName returns 
  1457.  the current name. The command corresponding to token must not have been 
  1458.  deleted. The string returned by Tcl_GetCommandName is in dynamic memory owned 
  1459.  by Tcl and is only guaranteed to retain its value as long as the command isn't 
  1460.  deleted or renamed;  callers should copy the string if they need to keep it 
  1461.  for a long time. 
  1462.  
  1463.  KEYWORDS 
  1464.  
  1465.  bind, command, create, delete, interpreter 
  1466.  
  1467.  
  1468. ΓòÉΓòÉΓòÉ 2.16. Tcl_CreateFileHandler ΓòÉΓòÉΓòÉ
  1469.  
  1470.  NAME 
  1471.  
  1472. Tcl_CreateFileHandler, Tcl_DeleteFileHandler - associate procedure callbacks 
  1473. with files or devices 
  1474.  
  1475. SYNOPSIS 
  1476.  
  1477. #include <tcl.h> 
  1478.  
  1479.  Tcl_CreateFileHandler(file, mask, proc, clientData) 
  1480.  
  1481.  Tcl_DeleteFileHandler(file) 
  1482.  
  1483. ARGUMENTS 
  1484.  
  1485.  Tcl_File  file (in)  Generic file handle for an open file or device (such as 
  1486.            returned by Tcl_GetFile call). 
  1487.  
  1488.  int  mask (in)  Conditions under which proc should be called: OR-ed 
  1489.            combination of TCL_READABLE, TCL_WRITABLE, and TCL_EXCEPTION.  May 
  1490.            be set to 0 to temporarily disable a handler. 
  1491.  
  1492.  Tcl_FileProc  *proc (in)  Procedure to invoke whenever the file or device 
  1493.            indicated by file meets the conditions specified by mask. 
  1494.  
  1495.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  1496.  
  1497.  DESCRIPTION 
  1498.  
  1499.  Tcl_CreateFileHandler arranges for proc to be invoked in the future whenever 
  1500.  I/O becomes possible on a file or an exceptional condition exists for the 
  1501.  file.  The file is indicated by file, and the conditions of interest are 
  1502.  indicated by mask.  For example, if mask is TCL_READABLE, proc will be called 
  1503.  when the file is readable. The callback to proc is made by Tcl_DoOneEvent, so 
  1504.  Tcl_CreateFileHandler is only useful in programs that dispatch events through 
  1505.  Tcl_DoOneEvent or through Tcl commands such as vwait. 
  1506.  
  1507.  Proc should have arguments and result that match the type Tcl_FileProc: 
  1508.  
  1509.   typedef void Tcl_FileProc(
  1510.          ClientData clientData,
  1511.          int mask);
  1512.  The clientData parameter to proc is a copy of the clientData argument given to 
  1513.  Tcl_CreateFileHandler when the callback was created.  Typically, clientData 
  1514.  points to a data structure containing application-specific information about 
  1515.  the file.  Mask is an integer mask indicating which of the requested 
  1516.  conditions actually exists for the file;  it will contain a subset of the bits 
  1517.  in the mask argument to Tcl_CreateFileHandler. 
  1518.  
  1519.  There may exist only one handler for a given file at a given time. If 
  1520.  Tcl_CreateFileHandler is called when a handler already exists for file, then 
  1521.  the new callback replaces the information that was previously recorded. 
  1522.  
  1523.  Tcl_DeleteFileHandler may be called to delete the file handler for file;  if 
  1524.  no handler exists for the file given by file then the procedure has no effect. 
  1525.  
  1526.  The purpose of file handlers is to enable an application to respond to events 
  1527.  while waiting for files to become ready for I/O.  For this to work correctly, 
  1528.  the application may need to use non-blocking I/O operations on the files for 
  1529.  which handlers are declared.  Otherwise the application may block if it reads 
  1530.  or writes too much data; while waiting for the I/O to complete the application 
  1531.  won't be able to service other events. Use Tcl_SetChannelOption with -blocking 
  1532.  to set the channel into blocking or nonblocking mode as required. 
  1533.  
  1534.  KEYWORDS 
  1535.  
  1536.  callback, file, handler 
  1537.  
  1538.  
  1539. ΓòÉΓòÉΓòÉ 2.17. Tcl_CreateInterp ΓòÉΓòÉΓòÉ
  1540.  
  1541.  NAME 
  1542.  
  1543. Tcl_CreateInterp, Tcl_DeleteInterp, Tcl_InterpDeleted - create and delete Tcl 
  1544. command interpreters 
  1545.  
  1546. SYNOPSIS 
  1547.  
  1548. #include <tcl.h> 
  1549.  
  1550.  Tcl_Interp * 
  1551.  Tcl_CreateInterp() 
  1552.  
  1553.  Tcl_DeleteInterp(interp) 
  1554.  
  1555.  int 
  1556.  Tcl_InterpDeleted(interp) 
  1557.  
  1558. ARGUMENTS 
  1559.  
  1560.  Tcl_Interp  *interp (in)  Token for interpreter to be destroyed. 
  1561.  
  1562.  DESCRIPTION 
  1563.  
  1564.  Tcl_CreateInterp creates a new interpreter structure and returns a token for 
  1565.  it.  The token is required in calls to most other Tcl procedures, such as 
  1566.  Tcl_CreateCommand, Tcl_Eval, and Tcl_DeleteInterp. Clients are only allowed to 
  1567.  access a few of the fields of Tcl_Interp structures;  see the Tcl_Interp and 
  1568.  Tcl_CreateCommand man pages for details. The new interpreter is initialized 
  1569.  with no defined variables and only the built-in Tcl commands.  To bind in 
  1570.  additional commands, call Tcl_CreateCommand. 
  1571.  
  1572.  Tcl_DeleteInterp marks an interpreter as deleted; the interpreter will 
  1573.  eventually be deleted when all calls to Tcl_Preserve for it have been matched 
  1574.  by calls to Tcl_Release. At that time, all of the resources associated with 
  1575.  it, including variables, procedures, and application-specific command 
  1576.  bindings, will be deleted.  After Tcl_DeleteInterp returns any attempt to use 
  1577.  Tcl_Eval on the interpreter will fail and return TCL_ERROR. After the call to 
  1578.  Tcl_DeleteInterp it is safe to examine interp->result, query or set the values 
  1579.  of variables, define, undefine or retrieve procedures, and examine the runtime 
  1580.  evaluation stack. See below, in the section INTERPRETERS AND MEMORY MANAGEMENT 
  1581.  for details. 
  1582.  
  1583.  Tcl_InterpDeleted returns nonzero if Tcl_DeleteInterp was called with interp 
  1584.  as its argument; this indicates that the interpreter will eventually be 
  1585.  deleted, when the last call to Tcl_Preserve for it is matched by a call to 
  1586.  Tcl_Release. If nonzero is returned, further calls to Tcl_Eval in this 
  1587.  interpreter will return TCL_ERROR. 
  1588.  
  1589.  Tcl_InterpDeleted is useful in deletion callbacks to distinguish between when 
  1590.  only the memory the callback is responsible for is being deleted and when the 
  1591.  whole interpreter is being deleted. In the former case the callback may 
  1592.  recreate the data being deleted, but this would lead to an infinite loop if 
  1593.  the interpreter were being deleted. 
  1594.  
  1595.  INTERPRETERS AND MEMORY MANAGEMENT 
  1596.  
  1597.  Tcl_DeleteInterp can be called at any time on an interpreter that may be used 
  1598.  by nested evaluations and C code in various extensions. Tcl implements a 
  1599.  simple mechanism that allows callers to use interpreters without worrying 
  1600.  about the interpreter being deleted in a nested call, and without requiring 
  1601.  special code to protect the interpreter, in most cases. This mechanism ensures 
  1602.  that nested uses of an interpreter can safely continue using it even after 
  1603.  Tcl_DeleteInterp is called. 
  1604.  
  1605.  The mechanism relies on matching up calls to Tcl_Preserve with calls to 
  1606.  Tcl_Release. If Tcl_DeleteInterp has been called, only when the last call to 
  1607.  Tcl_Preserve is matched by a call to Tcl_Release, will the interpreter be 
  1608.  freed. See the manual entry for Tcl_Preserve for a description of these 
  1609.  functions. 
  1610.  
  1611.  The rules for when the user of an interpreter must call Tcl_Preserve and 
  1612.  Tcl_Release are simple: 
  1613.  
  1614.  Interpreters Passed As Arguments  Functions that are passed an interpreter as 
  1615.            an argument can safely use the interpreter without any special 
  1616.            protection. Thus, when you write an extension consisting of new Tcl 
  1617.            commands, no special code is needed to protect interpreters received 
  1618.            as arguments. This covers the majority of all uses. 
  1619.  
  1620.  Interpreter Creation And Deletion  When a new interpreter is created and used 
  1621.            in a call to Tcl_Eval, Tcl_VarEval, Tcl_GlobalEval, Tcl_SetVar, or 
  1622.            Tcl_GetVar, a pair of calls to Tcl_Preserve and Tcl_Release should 
  1623.            be wrapped around all uses of the interpreter. Remember that it is 
  1624.            unsafe to use the interpreter once Tcl_Release has been called. To 
  1625.            ensure that the interpreter is properly deleted when it is no longer 
  1626.            needed, call Tcl_InterpDeleted to test if some other code already 
  1627.            called Tcl_DeleteInterp; if not, call Tcl_DeleteInterp before 
  1628.            calling Tcl_Release in your own code. Do not call Tcl_DeleteInterp 
  1629.            on an interpreter for which Tcl_InterpDeleted returns nonzero. 
  1630.  
  1631.  Retrieving An Interpreter From A Data Structure  When an interpreter is 
  1632.            retrieved from a data structure (e.g. the client data of a callback) 
  1633.            for use in Tcl_Eval, Tcl_VarEval, Tcl_GlobalEval, Tcl_SetVar, or 
  1634.            Tcl_GetVar, a pair of calls to Tcl_Preserve and Tcl_Release should 
  1635.            be wrapped around all uses of the interpreter; it is unsafe to reuse 
  1636.            the interpreter once Tcl_Release has been called.  If an interpreter 
  1637.            is stored inside a callback data structure, an appropriate deletion 
  1638.            cleanup mechanism should be set up by the code that creates the data 
  1639.            structure so that the interpreter is removed from the data structure 
  1640.            (e.g. by setting the field to NULL) when the interpreter is deleted. 
  1641.            Otherwise, you may be using an interpreter that has been freed and 
  1642.            whose memory may already have been reused. 
  1643.  
  1644.  All uses of interpreters in Tcl and Tk have already been protected. Extension 
  1645.  writers should ensure that their code also properly protects any additional 
  1646.  interpreters used, as described above. 
  1647.  
  1648.  KEYWORDS 
  1649.  
  1650.  command, create, delete, interpreter 
  1651.  
  1652.  SEE ALSO 
  1653.  
  1654.  Tcl_Preserve(3), Tcl_Release(3) 
  1655.  
  1656.  
  1657. ΓòÉΓòÉΓòÉ 2.18. Tcl_CreateMathFunc ΓòÉΓòÉΓòÉ
  1658.  
  1659.  NAME 
  1660.  
  1661. Tcl_CreateMathFunc - Define a new math function for expressions 
  1662.  
  1663. SYNOPSIS 
  1664.  
  1665. #include <tcl.h> 
  1666.  
  1667.  Tcl_CreateMathFunc(interp, name, numArgs, argTypes, proc, clientData) 
  1668.  
  1669. ARGUMENTS 
  1670.  
  1671.  Tcl_Interp  *interp (in)  Interpreter in which new function will be defined. 
  1672.  
  1673.  char  *name (in)  Name for new function. 
  1674.  
  1675.  int  numArgs (in)  Number of arguments to new function;  also gives size of 
  1676.            argTypes array. 
  1677.  
  1678.  Tcl_ValueType  *argTypes (in)  Points to an array giving the permissible types 
  1679.            for each argument to function. 
  1680.  
  1681.  Tcl_MathProc  *proc (in)  Procedure that implements the function. 
  1682.  
  1683.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc when it 
  1684.            is invoked. 
  1685.  
  1686.  DESCRIPTION 
  1687.  
  1688.  Tcl allows a number of mathematical functions to be used in expressions, such 
  1689.  as sin, cos, and hypot. Tcl_CreateMathFunc allows applications to add 
  1690.  additional functions to those already provided by Tcl or to replace existing 
  1691.  functions. Name is the name of the function as it will appear in expressions. 
  1692.  If name doesn't already exist as a function then a new function is created. 
  1693.  If it does exist, then the existing function is replaced. NumArgs and argTypes 
  1694.  describe the arguments to the function. Each entry in the argTypes array must 
  1695.  be either TCL_INT, TCL_DOUBLE, or TCL_EITHER to indicate whether the 
  1696.  corresponding argument must be an integer, a double-precision floating value, 
  1697.  or either, respectively. 
  1698.  
  1699.  Whenever the function is invoked in an expression Tcl will invoke proc.  Proc 
  1700.  should have arguments and result that match the type Tcl_MathProc: 
  1701.  
  1702.   typedef int Tcl_MathProc(
  1703.          ClientData clientData,
  1704.          Tcl_Interp *interp,
  1705.          Tcl_Value *args,
  1706.          Tcl_Value *resultPtr);
  1707.  
  1708.  When proc is invoked the clientData and interp arguments will be the same as 
  1709.  those passed to Tcl_CreateMathFunc. Args will point to an array of numArgs 
  1710.  Tcl_Value structures, which describe the actual arguments to the function: 
  1711.  
  1712.   typedef struct Tcl_Value {
  1713.          Tcl_ValueType type;
  1714.          long intValue;
  1715.          double doubleValue;
  1716.   } Tcl_Value;
  1717.  
  1718.  The type field indicates the type of the argument and is either TCL_INT or 
  1719.  TCL_DOUBLE. It will match the argTypes value specified for the function unless 
  1720.  the argTypes value was TCL_EITHER. Tcl converts the argument supplied in the 
  1721.  expression to the type requested in argTypes, if that is necessary. Depending 
  1722.  on the value of the type field, the intValue or doubleValue field will contain 
  1723.  the actual value of the argument. 
  1724.  
  1725.  Proc should compute its result and store it either as an integer in 
  1726.  resultPtr->intValue or as a floating value in resultPtr->doubleValue. It 
  1727.  should set also resultPtr->type to either TCL_INT or TCL_DOUBLE to indicate 
  1728.  which value was set. Under normal circumstances proc should return TCL_OK. If 
  1729.  an error occurs while executing the function, proc should return TCL_ERROR and 
  1730.  leave an error message in interp->result. 
  1731.  
  1732.  KEYWORDS 
  1733.  
  1734.  expression, mathematical function 
  1735.  
  1736.  
  1737. ΓòÉΓòÉΓòÉ 2.19. Tcl_CreateModalTimeout ΓòÉΓòÉΓòÉ
  1738.  
  1739.  NAME 
  1740.  
  1741. Tcl_CreateModalTimeout, Tcl_DeleteModalTimeout - special timer for modal 
  1742. operations 
  1743.  
  1744. SYNOPSIS 
  1745.  
  1746. #include <tcl.h> 
  1747.  
  1748.  Tcl_CreateModalTimeout(milliseconds, proc, clientData) 
  1749.  
  1750.  Tcl_DeleteModalTimeout(proc, clientData) 
  1751.  
  1752. ARGUMENTS 
  1753.  
  1754.  int  milliseconds (in)  How many milliseconds to wait before invoking proc. 
  1755.  
  1756.  Tcl_TimerProc  *proc (in)  Procedure to invoke after milliseconds have 
  1757.            elapsed. 
  1758.  
  1759.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  1760.  
  1761.  DESCRIPTION 
  1762.  
  1763.  Tcl_CreateModalTimeout provides an alternate form of timer from those provided 
  1764.  by Tcl_CreateTimerHandler. These timers are called "modal" because they are 
  1765.  typically used in situations where a particular operation must be completed 
  1766.  before the application does anything else. If such an operation needs a 
  1767.  timeout, it cannot use normal timer events:  if normal timer events were 
  1768.  processed, arbitrary Tcl scripts might be invoked via other event handlers, 
  1769.  which could interfere with the completion of the modal operation. The purpose 
  1770.  of modal timers is to allow a single timeout to occur without allowing any 
  1771.  normal timer events to occur. 
  1772.  
  1773.  Tcl_CreateModalTimeout behaves just like Tcl_CreateTimerHandler except that it 
  1774.  creates a modal timeout. Its arguments have the same meaning as for 
  1775.  Tcl_CreateTimerHandler and proc is invoked just as for Tcl_CreateTimerHandler. 
  1776.  Tcl_DeleteModalTimeout deletes the most recently created modal timeout;  its 
  1777.  arguments must match the corresponding arguments to the most recent call to 
  1778.  Tcl_CreateModalTimeout. 
  1779.  
  1780.  Modal timeouts differ from a normal timers in three ways.  First, they will 
  1781.  trigger regardless of whether the TCL_TIMER_EVENTS flag has been passed to 
  1782.  Tcl_DoOneEvent. Typically modal timers are used with the TCL_TIMER_EVENTS flag 
  1783.  off so that normal timers don't fire but modal ones do. Second, if several 
  1784.  modal timers have been created they stack: only the top timer on the stack 
  1785.  (the most recently created one) is active at any point in time. Modal timeouts 
  1786.  must be deleted in inverse order from their creation. Third, modal timeouts 
  1787.  are not deleted when they fire:  once a modal timeout has fired, it will 
  1788.  continue firing every time Tcl_DoOneEvent is called, until the timeout is 
  1789.  deleted by calling Tcl_DeleteModalTimeout. 
  1790.  
  1791.  Modal timeouts are only needed in a few special situations, and they should be 
  1792.  used with caution. 
  1793.  
  1794.  KEYWORDS 
  1795.  
  1796.  callback, clock, handler, modal timeout 
  1797.  
  1798.  
  1799. ΓòÉΓòÉΓòÉ 2.20. Tcl_CreateSlave ΓòÉΓòÉΓòÉ
  1800.  
  1801.  NAME 
  1802.  
  1803. Tcl_IsSafe, Tcl_MakeSafe, Tcl_CreateSlave, Tcl_GetSlave, Tcl_GetSlaves, 
  1804. Tcl_GetMaster, Tcl_CreateAlias, Tcl_GetAlias, Tcl_GetAliases - manage multiple 
  1805. Tcl interpreters and aliases. 
  1806.  
  1807. SYNOPSIS 
  1808.  
  1809. #include <tcl.h> 
  1810.  
  1811.  int 
  1812.  Tcl_IsSafe(interp) 
  1813.  
  1814.  int 
  1815.  Tcl_MakeSafe(interp) 
  1816.  
  1817.  Tcl_Interp * 
  1818.  Tcl_CreateSlave(interp, slaveName, isSafe) 
  1819.  
  1820.  Tcl_Interp * 
  1821.  Tcl_GetSlave(interp, slaveName) 
  1822.  
  1823.  Tcl_Interp * 
  1824.  Tcl_GetMaster(interp) 
  1825.  
  1826.  int 
  1827.  Tcl_GetInterpPath(askingInterp, slaveInterp) 
  1828.  
  1829.  int 
  1830.  Tcl_CreateAlias(slaveInterp, srcCmd, targetInterp, targetCmd, argc, argv) 
  1831.  
  1832.  int 
  1833.  Tcl_GetAlias(interp, srcCmd, targetInterpPtr, targetCmdPtr, argcPtr, argvPtr) 
  1834.  
  1835. ARGUMENTS 
  1836.  
  1837.  Tcl_Interp  *interp (in)  Interpreter in which to execute the specified 
  1838.            command. 
  1839.  
  1840.  char  *slaveName (in)  Name of slave interpreter to create or manipulate. 
  1841.  
  1842.  int  isSafe (in)  Zero means the interpreter may have all Tcl functions. 
  1843.            Non-zero means the new interpreter's functionality should be limited 
  1844.            to make it safe. 
  1845.  
  1846.  Tcl_Interp  *slaveInterp (in)  Interpreter to use for creating the source 
  1847.            command for an alias (see below). 
  1848.  
  1849.  char  *srcCmd (in)  Name of source command for alias. 
  1850.  
  1851.  Tcl_Interp  *targetInterp (in)  Interpreter that contains the target command 
  1852.            for an alias. 
  1853.  
  1854.  char  *targetCmd (in)  Name of target command for alias in targetInterp. 
  1855.  
  1856.  int  argc (in)  Count of additional arguments to pass to the alias command. 
  1857.  
  1858.  char  **argv (in)  Vector of strings, the additional arguments to pass to the 
  1859.            alias command. This storage is owned by the caller. 
  1860.  
  1861.  Tcl_Interp  **targetInterpPtr (in)  Pointer to location to store the address 
  1862.            of the interpreter where a target command is defined for an alias. 
  1863.  
  1864.  char  **targetCmdPtr (out)  Pointer to location to store the address of the 
  1865.            name of the target command for an alias. 
  1866.  
  1867.  int  *argcPtr (out)  Pointer to location to store count of additional 
  1868.            arguments to be passed to the alias. The location is in storage 
  1869.            owned by the caller. 
  1870.  
  1871.  char  ***argvPtr (out)  Pointer to location to store a vector of strings, the 
  1872.            additional arguments to pass to an alias. The location is in storage 
  1873.            owned by the caller, the vector of strings is owned by the called 
  1874.            function. 
  1875.  
  1876.  DESCRIPTION 
  1877.  
  1878.  These procedures are intended for access to the multiple interpreter facility 
  1879.  from inside C programs. They enable managing multiple interpreters in a 
  1880.  hierarchical relationship, and the management of aliases, commands that when 
  1881.  invoked in one interpreter execute a command in another interpreter. The 
  1882.  return value for those procedures that return an int is either TCL_OK or 
  1883.  TCL_ERROR. If TCL_ERROR is returned then the result field of the interpreter 
  1884.  contains an error message. 
  1885.  
  1886.  Tcl_CreateSlave creates a new interpreter as a slave of the given interpreter. 
  1887.  It also creates a slave command in the given interpreter which allows the 
  1888.  master interpreter to manipulate the slave. The slave interpreter and the 
  1889.  slave command have the specified name. If isSafe is 1, the new slave 
  1890.  interpreter is made "safe" by removing all unsafe functionality. If the 
  1891.  creation failed, NULL is returned. 
  1892.  
  1893.  Tcl_IsSafe returns 1 if the given interpreter is "safe", 0 otherwise. 
  1894.  
  1895.  Tcl_MakeSafe makes the given interpreter "safe" by removing all non-core and 
  1896.  core unsafe functionality. Note that if you call this after adding some 
  1897.  extension to an interpreter, all traces of that extension will be removed from 
  1898.  the interpreter. This operation always succeeds and returns TCL_OK. 
  1899.  
  1900.  Tcl_GetSlave returns a pointer to a slave interpreter of the given 
  1901.  interpreter. The slave interpreter is identified by the name specified. If no 
  1902.  such slave interpreter exists, NULL is returned. 
  1903.  
  1904.  Tcl_GetMaster returns a pointer to the master interpreter of the given 
  1905.  interpreter. If the given interpreter has no master (it is a top-level 
  1906.  interpreter) then NULL is returned. 
  1907.  
  1908.  Tcl_GetInterpPath sets the result field in askingInterp to the relative path 
  1909.  between askingInterp and slaveInterp; slaveInterp must be a slave of 
  1910.  askingInterp. If the computation of the relative path succeeds, TCL_OK is 
  1911.  returned, else TCL_ERROR is returned and the result field in askingInterp 
  1912.  contains the error message. 
  1913.  
  1914.  Tcl_GetAlias returns information about an alias of a specified name in a given 
  1915.  interpreter. Any of the result fields can be NULL, in which case the 
  1916.  corresponding datum is not returned. If a result field is non-NULL, the 
  1917.  address indicated is set to the corresponding datum. For example, if 
  1918.  targetNamePtr is non-NULL it is set to a pointer to the string containing the 
  1919.  name of the target command. 
  1920.  
  1921.  In order to map over all slave interpreters, use Tcl_Eval with the command 
  1922.  interp slaves and use the value (a Tcl list) deposited in the result field of 
  1923.  the interpreter. Similarly, to map over all aliases whose source commands are 
  1924.  defined in an interpreter, use Tcl_Eval with the command interp aliases and 
  1925.  use the value (a Tcl list) deposited in the result field. Note that the 
  1926.  storage of this list belongs to Tcl, so you should copy it before invoking any 
  1927.  other Tcl commands in that interpreter. 
  1928.  
  1929.  SEE ALSO 
  1930.  
  1931.  For a description of the Tcl interface to multiple interpreters, see 
  1932.  interp(n). 
  1933.  
  1934.  KEYWORDS 
  1935.  
  1936.  alias, command, interpreter, master, slave 
  1937.  
  1938.  
  1939. ΓòÉΓòÉΓòÉ 2.21. Tcl_CreateTimerHandler ΓòÉΓòÉΓòÉ
  1940.  
  1941.  NAME 
  1942.  
  1943. Tcl_CreateTimerHandler, Tcl_DeleteTimerHandler - call a procedure at a given 
  1944. time 
  1945.  
  1946. SYNOPSIS 
  1947.  
  1948. #include <tcl.h> 
  1949.  
  1950.  Tcl_TimerToken 
  1951.  Tcl_CreateTimerHandler(milliseconds, proc, clientData) 
  1952.  
  1953.  Tcl_DeleteTimerHandler(token) 
  1954.  
  1955. ARGUMENTS 
  1956.  
  1957.  int  milliseconds (in)  How many milliseconds to wait before invoking proc. 
  1958.  
  1959.  Tcl_TimerProc  *proc (in)  Procedure to invoke after milliseconds have 
  1960.            elapsed. 
  1961.  
  1962.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  1963.  
  1964.  Tcl_TimerToken  token (in)  Token for previously-created timer handler (the 
  1965.            return value from some previous call to Tcl_CreateTimerHandler). 
  1966.  
  1967.  DESCRIPTION 
  1968.  
  1969.  Tcl_CreateTimerHandler arranges for proc to be invoked at a time milliseconds 
  1970.  milliseconds in the future. The callback to proc will be made by 
  1971.  Tcl_DoOneEvent, so Tcl_CreateTimerHandler is only useful in programs that 
  1972.  dispatch events through Tcl_DoOneEvent or through Tcl commands such as vwait. 
  1973.  The call to proc may not be made at the exact time given by milliseconds:  it 
  1974.  will be made at the next opportunity after that time.  For example, if 
  1975.  Tcl_DoOneEvent isn't called until long after the time has elapsed, or if there 
  1976.  are other pending events to process before the call to proc, then the call to 
  1977.  proc will be delayed. 
  1978.  
  1979.  Proc should have arguments and return value that match the type Tcl_TimerProc: 
  1980.  
  1981.   typedef void Tcl_TimerProc(ClientData clientData);
  1982.  The clientData parameter to proc is a copy of the clientData argument given to 
  1983.  Tcl_CreateTimerHandler when the callback was created.  Typically, clientData 
  1984.  points to a data structure containing application-specific information about 
  1985.  what to do in proc. 
  1986.  
  1987.  Tcl_DeleteTimerHandler may be called to delete a previously-created timer 
  1988.  handler.  It deletes the handler indicated by token so that no call to proc 
  1989.  will be made;  if that handler no longer exists (e.g. because the time period 
  1990.  has already elapsed and proc has been invoked then Tcl_DeleteTimerHandler does 
  1991.  nothing. The tokens returned by Tcl_CreateTimerHandler never have a value of 
  1992.  NULL, so if NULL is passed to Tcl_DeleteTimerHandler then the procedure does 
  1993.  nothing. 
  1994.  
  1995.  KEYWORDS 
  1996.  
  1997.  callback, clock, handler, timer 
  1998.  
  1999.  
  2000. ΓòÉΓòÉΓòÉ 2.22. Tcl_CreateTrace ΓòÉΓòÉΓòÉ
  2001.  
  2002.  NAME 
  2003.  
  2004. Tcl_CreateTrace, Tcl_DeleteTrace - arrange for command execution to be traced 
  2005.  
  2006. SYNOPSIS 
  2007.  
  2008. #include <tcl.h> 
  2009.  
  2010.  Tcl_Trace 
  2011.  Tcl_CreateTrace(interp, level, proc, clientData) 
  2012.  
  2013.  Tcl_DeleteTrace(interp, trace) 
  2014.  
  2015. ARGUMENTS 
  2016.  
  2017.  Tcl_Interp  *interp (in)  Interpreter containing command to be traced or 
  2018.            untraced. 
  2019.  
  2020.  int  level (in)  Only commands at or below this nesting level will be traced. 
  2021.            1 means top-level commands only, 2 means top-level commands or those 
  2022.            that are invoked as immediate consequences of executing top-level 
  2023.            commands (procedure bodies, bracketed commands, etc.) and so on. 
  2024.  
  2025.  Tcl_CmdTraceProc  *proc (in)  Procedure to call for each command that's 
  2026.            executed.  See below for details on the calling sequence. 
  2027.  
  2028.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  2029.  
  2030.  Tcl_Trace  trace (in)  Token for trace to be removed (return value from 
  2031.            previous call to Tcl_CreateTrace). 
  2032.  
  2033.  DESCRIPTION 
  2034.  
  2035.  Tcl_CreateTrace arranges for command tracing.  From now on, proc will be 
  2036.  invoked before Tcl calls command procedures to process commands in interp. 
  2037.  The return value from Tcl_CreateTrace is a token for the trace, which may be 
  2038.  passed to Tcl_DeleteTrace to remove the trace.  There may be many traces in 
  2039.  effect simultaneously for the same command interpreter. 
  2040.  
  2041.  Proc should have arguments and result that match the type Tcl_CmdTraceProc: 
  2042.  
  2043.   typedef void Tcl_CmdTraceProc(
  2044.          ClientData clientData,
  2045.          Tcl_Interp *interp,
  2046.          int level,
  2047.          char *command,
  2048.          Tcl_CmdProc *cmdProc,
  2049.          ClientData cmdClientData,
  2050.          int argc,
  2051.          char *argv[]);
  2052.  The clientData and interp parameters are copies of the corresponding arguments 
  2053.  given to Tcl_CreateTrace. ClientData typically points to an 
  2054.  application-specific data structure that describes what to do when proc is 
  2055.  invoked.  Level gives the nesting level of the command (1 for top-level 
  2056.  commands passed to Tcl_Eval by the application, 2 for the next-level commands 
  2057.  passed to Tcl_Eval as part of parsing or interpreting level-1 commands, and so 
  2058.  on).  Command points to a string containing the text of the command, before 
  2059.  any argument substitution. CmdProc contains the address of the command 
  2060.  procedure that will be called to process the command (i.e. the proc argument 
  2061.  of some previous call to Tcl_CreateCommand) and cmdClientData contains the 
  2062.  associated client data for cmdProc (the clientData value passed to 
  2063.  Tcl_CreateCommand).  Argc and argv give the final argument information that 
  2064.  will be passed to cmdProc, after command, variable, and backslash 
  2065.  substitution. Proc must not modify the command or argv strings. 
  2066.  
  2067.  Tracing will only occur for commands at nesting level less than or equal to 
  2068.  the level parameter (i.e. the level parameter to proc will always be less than 
  2069.  or equal to the level parameter to Tcl_CreateTrace). 
  2070.  
  2071.  Calls to proc will be made by the Tcl parser immediately before it calls the 
  2072.  command procedure for the command (cmdProc).  This occurs after argument 
  2073.  parsing and substitution, so tracing for substituted commands occurs before 
  2074.  tracing of the commands containing the substitutions.  If there is a syntax 
  2075.  error in a command, or if there is no command procedure associated with a 
  2076.  command name, then no tracing will occur for that command.  If a string passed 
  2077.  to Tcl_Eval contains multiple commands (bracketed, or on different lines) then 
  2078.  multiple calls to proc will occur, one for each command.  The command string 
  2079.  for each of these trace calls will reflect only a single command, not the 
  2080.  entire string passed to Tcl_Eval. 
  2081.  
  2082.  Tcl_DeleteTrace removes a trace, so that no future calls will be made to the 
  2083.  procedure associated with the trace.  After Tcl_DeleteTrace returns, the 
  2084.  caller should never again use the trace token. 
  2085.  
  2086.  KEYWORDS 
  2087.  
  2088.  command, create, delete, interpreter, trace 
  2089.  
  2090.  
  2091. ΓòÉΓòÉΓòÉ 2.23. Tcl_DString ΓòÉΓòÉΓòÉ
  2092.  
  2093.  NAME 
  2094.  
  2095. Tcl_DStringInit, Tcl_DStringAppend, Tcl_DStringAppendElement, 
  2096. Tcl_DStringStartSublist, Tcl_DStringEndSublist, Tcl_DStringLength, 
  2097. Tcl_DStringValue, Tcl_DStringSetLength,  Tcl_DStringFree, Tcl_DStringResult, 
  2098. Tcl_DStringGetResult - manipulate dynamic strings 
  2099.  
  2100. SYNOPSIS 
  2101.  
  2102. #include <tcl.h> 
  2103.  
  2104.  Tcl_DStringInit(dsPtr) 
  2105.  
  2106.  char * 
  2107.  Tcl_DStringAppend(dsPtr, string, length) 
  2108.  
  2109.  char * 
  2110.  Tcl_DStringAppendElement(dsPtr, string) 
  2111.  
  2112.  Tcl_DStringStartSublist(dsPtr) 
  2113.  
  2114.  Tcl_DStringEndSublist(dsPtr) 
  2115.  
  2116.  int 
  2117.  Tcl_DStringLength(dsPtr) 
  2118.  
  2119.  char * 
  2120.  Tcl_DStringValue(dsPtr) 
  2121.  
  2122.  Tcl_DStringSetLength(dsPtr, newLength) 
  2123.  
  2124.  Tcl_DStringFree(dsPtr) 
  2125.  
  2126.  Tcl_DStringResult(interp, dsPtr) 
  2127.  
  2128.  Tcl_DStringGetResult(interp, dsPtr) 
  2129.  
  2130. ARGUMENTS 
  2131.  
  2132.  Tcl_DString  *dsPtr (in/out)  Pointer to structure that is used to manage a 
  2133.            dynamic string. 
  2134.  
  2135.  char  *string (in)  Pointer to characters to add to dynamic string. 
  2136.  
  2137.  int  length (in)  Number of characters from string to add to dynamic string. 
  2138.            If -1, add all characters up to null terminating character. 
  2139.  
  2140.  int  newLength (in)  New length for dynamic string, not including null 
  2141.            terminating character. 
  2142.  
  2143.  Tcl_Interp  *interp (in/out)  Interpreter whose result is to be set from or 
  2144.            moved to the dynamic string. 
  2145.  
  2146.  DESCRIPTION 
  2147.  
  2148.  Dynamic strings provide a mechanism for building up arbitrarily long strings 
  2149.  by gradually appending information.  If the dynamic string is short then there 
  2150.  will be no memory allocation overhead;  as the string gets larger, additional 
  2151.  space will be allocated as needed. 
  2152.  
  2153.  Tcl_DStringInit initializes a dynamic string to zero length. The Tcl_DString 
  2154.  structure must have been allocated by the caller. No assumptions are made 
  2155.  about the current state of the structure; anything already in it is discarded. 
  2156.  If the structure has been used previously, Tcl_DStringFree should be called 
  2157.  first to free up any memory allocated for the old string. 
  2158.  
  2159.  Tcl_DStringAppend adds new information to a dynamic string, allocating more 
  2160.  memory for the string if needed. If length is less than zero then everything 
  2161.  in string is appended to the dynamic string;  otherwise length specifies the 
  2162.  number of bytes to append. Tcl_DStringAppend returns a pointer to the 
  2163.  characters of the new string.  The string can also be retrieved from the 
  2164.  string field of the Tcl_DString structure. 
  2165.  
  2166.  Tcl_DStringAppendElement is similar to Tcl_DStringAppend except that it 
  2167.  doesn't take a length argument (it appends all of string) and it converts the 
  2168.  string to a proper list element before appending. Tcl_DStringAppendElement 
  2169.  adds a separator space before the new list element unless the new list element 
  2170.  is the first in a list or sub-list (i.e. either the current string is empty, 
  2171.  or it contains the single character "{", or the last two characters of the 
  2172.  current string are " {"). Tcl_DStringAppendElement returns a pointer to the 
  2173.  characters of the new string. 
  2174.  
  2175.  Tcl_DStringStartSublist and Tcl_DStringEndSublist can be used to create nested 
  2176.  lists. To append a list element that is itself a sublist, first call 
  2177.  Tcl_DStringStartSublist, then call Tcl_DStringAppendElement for each of the 
  2178.  elements in the sublist, then call Tcl_DStringEndSublist to end the sublist. 
  2179.  Tcl_DStringStartSublist appends a space character if needed, followed by an 
  2180.  open brace;  Tcl_DStringEndSublist appends a close brace. Lists can be nested 
  2181.  to any depth. 
  2182.  
  2183.  Tcl_DStringLength is a macro that returns the current length of a dynamic 
  2184.  string (not including the terminating null character). Tcl_DStringValue is a 
  2185.  macro that returns a pointer to the current contents of a dynamic string. 
  2186.  
  2187.  Tcl_DStringSetLength changes the length of a dynamic string. If newLength is 
  2188.  less than the string's current length, then the string is truncated. If 
  2189.  newLength is greater than the string's current length, then the string will 
  2190.  become longer and new space will be allocated for the string if needed. 
  2191.  However, Tcl_DStringSetLength will not initialize the new space except to 
  2192.  provide a terminating null character;  it is up to the caller to fill in the 
  2193.  new space. Tcl_DStringSetLength does not free up the string's storage space 
  2194.  even if the string is truncated to zero length, so Tcl_DStringFree will still 
  2195.  need to be called. 
  2196.  
  2197.  Tcl_DStringFree should be called when you're finished using the string.  It 
  2198.  frees up any memory that was allocated for the string and reinitializes the 
  2199.  string's value to an empty string. 
  2200.  
  2201.  Tcl_DStringResult sets the result of interp to the value of the dynamic string 
  2202.  given by dsPtr.  It does this by moving a pointer from dsPtr to 
  2203.  interp->result. This saves the cost of allocating new memory and copying the 
  2204.  string. Tcl_DStringResult also reinitializes the dynamic string to an empty 
  2205.  string. 
  2206.  
  2207.  Tcl_DStringGetResult does the opposite of Tcl_DStringResult. It sets the value 
  2208.  of dsPtr to the result of interp and it clears interp's result. If possible it 
  2209.  does this by moving a pointer rather than by copying the string. 
  2210.  
  2211.  KEYWORDS 
  2212.  
  2213.  append, dynamic string, free, result 
  2214.  
  2215.  
  2216. ΓòÉΓòÉΓòÉ 2.24. Tcl_DetachPids ΓòÉΓòÉΓòÉ
  2217.  
  2218.  NAME 
  2219.  
  2220. Tcl_DetachPids, Tcl_ReapDetachedProcs - manage child processes in background 
  2221.  
  2222. SYNOPSIS 
  2223.  
  2224. #include <tcl.h> 
  2225.  
  2226.  Tcl_DetachPids(numPids, pidPtr) 
  2227.  
  2228.  Tcl_ReapDetachedProcs() 
  2229.  
  2230. ARGUMENTS 
  2231.  
  2232.  int  numPids (in)  Number of process ids contained in the array pointed to by 
  2233.            pidPtr. 
  2234.  
  2235.  int  *pidPtr (in)  Address of array containing numPids process ids. 
  2236.  
  2237.  DESCRIPTION 
  2238.  
  2239.  Tcl_DetachPids and Tcl_ReapDetachedProcs provide a mechanism for managing 
  2240.  subprocesses that are running in background. These procedures are needed 
  2241.  because the parent of a process must eventually invoke the waitpid kernel call 
  2242.  (or one of a few other similar kernel calls) to wait for the child to exit. 
  2243.  Until the parent waits for the child, the child's state cannot be completely 
  2244.  reclaimed by the system.  If a parent continually creates children and doesn't 
  2245.  wait on them, the system's process table will eventually overflow, even if all 
  2246.  the children have exited. 
  2247.  
  2248.  Tcl_DetachPids may be called to ask Tcl to take responsibility for one or more 
  2249.  processes whose process ids are contained in the pidPtr array passed as 
  2250.  argument.  The caller presumably has started these processes running in 
  2251.  background and doesn't want to have to deal with them again. 
  2252.  
  2253.  Tcl_ReapDetachedProcs invokes the waitpid kernel call on each of the 
  2254.  background processes so that its state can be cleaned up if it has exited.  If 
  2255.  the process hasn't exited yet, Tcl_ReapDetachedProcs doesn't wait for it to 
  2256.  exit;  it will check again the next time it is invoked. Tcl automatically 
  2257.  calls Tcl_ReapDetachedProcs each time the exec command is executed, so in most 
  2258.  cases it isn't necessary for any code outside of Tcl to invoke 
  2259.  Tcl_ReapDetachedProcs. However, if you call Tcl_DetachPids in situations where 
  2260.  the exec command may never get executed, you may wish to call 
  2261.  Tcl_ReapDetachedProcs from time to time so that background processes can be 
  2262.  cleaned up. 
  2263.  
  2264.  KEYWORDS 
  2265.  
  2266.  background, child, detach, process, wait 
  2267.  
  2268.  
  2269. ΓòÉΓòÉΓòÉ 2.25. Tcl_DoOneEvent ΓòÉΓòÉΓòÉ
  2270.  
  2271.  NAME 
  2272.  
  2273. Tcl_DoOneEvent - wait for events and invoke event handlers 
  2274.  
  2275. SYNOPSIS 
  2276.  
  2277. #include <tcl.h> 
  2278.  
  2279.  int 
  2280.  Tcl_DoOneEvent(flags) 
  2281.  
  2282. ARGUMENTS 
  2283.  
  2284.  int  flags (in)  This parameter is normally zero.  It may be an OR-ed 
  2285.            combination of any of the following flag bits: TCL_WINDOW_EVENTS, 
  2286.            TCL_FILE_EVENTS, TCL_TIMER_EVENTS, TCL_IDLE_EVENTS, TCL_ALL_EVENTS, 
  2287.            or TCL_DONT_WAIT. 
  2288.  
  2289.  DESCRIPTION 
  2290.  
  2291.  This procedure is the entry point to Tcl's event loop; it is responsible for 
  2292.  waiting for events and dispatching event handlers created with procedures such 
  2293.  as Tk_CreateEventHandler, Tcl_CreateFileHandler, Tcl_CreateTimerHandler, and 
  2294.  Tcl_DoWhenIdle. Tcl_DoOneEvent checks to see if events are already present on 
  2295.  the Tcl event queue; if so, it calls the handler(s) for the first (oldest) 
  2296.  event, removes it from the queue, and returns. If there are no events ready to 
  2297.  be handled, then Tcl_DoOneEvent checks for new events from all possible 
  2298.  sources. If any are found, it puts all of them on Tcl's event queue, calls 
  2299.  handlers for the first event on the queue, and returns. If no events are 
  2300.  found, Tcl_DoOneEvent checks for Tcl_DoWhenIdle callbacks; if any are found, 
  2301.  it invokes all of them and returns. Finally, if no events or idle callbacks 
  2302.  have been found, then Tcl_DoOneEvent sleeps until an event occurs; then it 
  2303.  adds any ew events to the Tcl event queue, calls handlers for the first event, 
  2304.  and returns. The normal return value is 1 to signify that some event was 
  2305.  processed (see below for other alternatives). 
  2306.  
  2307.  If the flags argument to Tcl_DoOneEvent is non-zero, it restricts the kinds of 
  2308.  events that will be processed by Tcl_DoOneEvent. Flags may be an OR-ed 
  2309.  combination of any of the following bits: 
  2310.  
  2311.  TCL_WINDOW_EVENTS -  Process window system events. 
  2312.  
  2313.  TCL_FILE_EVENTS -  Process file events. 
  2314.  
  2315.  TCL_TIMER_EVENTS -  Process timer events. 
  2316.  
  2317.  TCL_IDLE_EVENTS -  Process idle callbacks. 
  2318.  
  2319.  TCL_ALL_EVENTS -  Process all kinds of events:  equivalent to OR-ing together 
  2320.            all of the above flags or specifying none of them. 
  2321.  
  2322.  TCL_DONT_WAIT -  Don't sleep:  process only events that are ready at the time 
  2323.            of the call. 
  2324.  
  2325.  If any of the flags TCL_WINDOW_EVENTS, TCL_FILE_EVENTS, TCL_TIMER_EVENTS, or 
  2326.  TCL_IDLE_EVENTS is set, then the only events that will be considered are those 
  2327.  for which flags are set. Setting none of these flags is equivalent to the 
  2328.  value TCL_ALL_EVENTS, which causes all event types to be processed. If an 
  2329.  application has defined additional event sources with Tcl_CreateEventSource, 
  2330.  then additional flag values may also be valid, depending on those event 
  2331.  sources. 
  2332.  
  2333.  The TCL_DONT_WAIT flag causes Tcl_DoOneEvent not to put the process to sleep: 
  2334.  it will check for events but if none are found then it returns immediately 
  2335.  with a return value of 0 to indicate that no work was done. Tcl_DoOneEvent 
  2336.  will also return 0 without doing anything if the only alternative is to block 
  2337.  forever (this can happen, for example, if flags is TCL_IDLE_EVENTS and there 
  2338.  are no Tcl_DoWhenIdle callbacks pending, or if no event handlers or timer 
  2339.  handlers exist). 
  2340.  
  2341.  Tcl_DoOneEvent may be invoked recursively.  For example, it is possible to 
  2342.  invoke Tcl_DoOneEvent recursively from a handler called by Tcl_DoOneEvent. 
  2343.  This sort of operation is useful in some modal situations, such as when a 
  2344.  notification dialog has been popped up and an application wishes to wait for 
  2345.  the user to click a button in the dialog before doing anything else. 
  2346.  
  2347.  KEYWORDS 
  2348.  
  2349.  callback, event, handler, idle, timer 
  2350.  
  2351.  
  2352. ΓòÉΓòÉΓòÉ 2.26. Tcl_DoWhenIdle ΓòÉΓòÉΓòÉ
  2353.  
  2354.  NAME 
  2355.  
  2356. Tcl_DoWhenIdle, Tcl_CancelIdleCall - invoke a procedure when there are no 
  2357. pending events 
  2358.  
  2359. SYNOPSIS 
  2360.  
  2361. #include <tcl.h> 
  2362.  
  2363.  Tcl_DoWhenIdle(proc, clientData) 
  2364.  
  2365.  Tcl_CancelIdleCall(proc, clientData) 
  2366.  
  2367. ARGUMENTS 
  2368.  
  2369.  Tcl_IdleProc  *proc (in)  Procedure to invoke. 
  2370.  
  2371.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  2372.  
  2373.  DESCRIPTION 
  2374.  
  2375.  Tcl_DoWhenIdle arranges for proc to be invoked when the application becomes 
  2376.  idle.  The application is considered to be idle when Tcl_DoOneEvent has been 
  2377.  called, couldn't find any events to handle, and is about to go to sleep 
  2378.  waiting for an event to occur.  At this point all pending Tcl_DoWhenIdle 
  2379.  handlers are invoked.  For each call to Tcl_DoWhenIdle there will be a single 
  2380.  call to proc;  after proc is invoked the handler is automatically removed. 
  2381.  Tcl_DoWhenIdle is only usable in programs that use Tcl_DoOneEvent to dispatch 
  2382.  events. 
  2383.  
  2384.  Proc should have arguments and result that match the type Tcl_IdleProc: 
  2385.  
  2386.   typedef void Tcl_IdleProc(ClientData clientData);
  2387.  The clientData parameter to proc is a copy of the clientData argument given to 
  2388.  Tcl_DoWhenIdle.  Typically, clientData points to a data structure containing 
  2389.  application-specific information about what proc should do. 
  2390.  
  2391.  Tcl_CancelIdleCall may be used to cancel one or more previous calls to 
  2392.  Tcl_DoWhenIdle:  if there is a Tcl_DoWhenIdle handler registered for proc and 
  2393.  clientData, then it is removed without invoking it.  If there is more than one 
  2394.  handler on the idle list that refers to proc and clientData, all of the 
  2395.  handlers are removed.  If no existing handlers match proc and clientData then 
  2396.  nothing happens. 
  2397.  
  2398.  Tcl_DoWhenIdle is most useful in situations where (a) a piece of work will 
  2399.  have to be done but (b) it's possible that something will happen in the near 
  2400.  future that will change what has to be done or require something different to 
  2401.  be done.  Tcl_DoWhenIdle allows the actual work to be deferred until all 
  2402.  pending events have been processed.  At this point the exact work to be done 
  2403.  will presumably be known and it can be done exactly once. 
  2404.  
  2405.  For example, Tcl_DoWhenIdle might be used by an editor to defer display 
  2406.  updates until all pending commands have been processed.  Without this feature, 
  2407.  redundant redisplays might occur in some situations, such as the processing of 
  2408.  a command file. 
  2409.  
  2410.  BUGS 
  2411.  
  2412.  At present it is not safe for an idle callback to reschedule itself 
  2413.  continuously.  This will interact badly with certain features of Tk that 
  2414.  attempt to wait for all idle callbacks to complete.  If you would like for an 
  2415.  idle callback to reschedule itself continuously, it is better to use a timer 
  2416.  handler with a zero timeout period. 
  2417.  
  2418.  KEYWORDS 
  2419.  
  2420.  callback, defer, idle callback 
  2421.  
  2422.  
  2423. ΓòÉΓòÉΓòÉ 2.27. Tcl_Eval ΓòÉΓòÉΓòÉ
  2424.  
  2425.  NAME 
  2426.  
  2427. Tcl_Eval, Tcl_VarEval, Tcl_EvalFile, Tcl_GlobalEval - execute Tcl commands 
  2428.  
  2429. SYNOPSIS 
  2430.  
  2431. #include <tcl.h> 
  2432.  
  2433.  int 
  2434.  Tcl_Eval(interp, cmd) 
  2435.  
  2436.  int 
  2437.  Tcl_VarEval(interp, string, string, ... (char *) NULL) 
  2438.  
  2439.  int 
  2440.  Tcl_EvalFile(interp, fileName) 
  2441.  
  2442.  int 
  2443.  Tcl_GlobalEval(interp, cmd) 
  2444.  
  2445. ARGUMENTS 
  2446.  
  2447.  Tcl_Interp  *interp (in)  Interpreter in which to execute the command.  String 
  2448.            result will be stored in interp->result. 
  2449.  
  2450.  char  *cmd (in)  Command (or sequence of commands) to execute.  Must be in 
  2451.            writable memory (Tcl_Eval makes temporary modifications to the 
  2452.            command). 
  2453.  
  2454.  char  *string (in)  String forming part of Tcl command. 
  2455.  
  2456.  char  *fileName (in)  Name of file containing Tcl command string. 
  2457.  
  2458.  DESCRIPTION 
  2459.  
  2460.  All four of these procedures execute Tcl commands. Tcl_Eval is the core 
  2461.  procedure:  it parses commands from cmd and executes them in order until 
  2462.  either an error occurs or it reaches the end of the string. The return value 
  2463.  from Tcl_Eval is one of the Tcl return codes TCL_OK, TCL_ERROR, TCL_RETURN, 
  2464.  TCL_BREAK, or TCL_CONTINUE, and interp->result will point to a string with 
  2465.  additional information (result value or error message). This return 
  2466.  information corresponds to the last command executed from cmd. 
  2467.  
  2468.  Tcl_VarEval takes any number of string arguments of any length, concatenates 
  2469.  them into a single string, then calls Tcl_Eval to execute that string as a Tcl 
  2470.  command. It returns the result of the command and also modifies interp->result 
  2471.  in the usual fashion for Tcl commands.  The last argument to Tcl_VarEval must 
  2472.  be NULL to indicate the end of arguments. 
  2473.  
  2474.  Tcl_EvalFile reads the file given by fileName and evaluates its contents as a 
  2475.  Tcl command by calling Tcl_Eval.  It returns a standard Tcl result that 
  2476.  reflects the result of evaluating the file. If the file couldn't be read then 
  2477.  a Tcl error is returned to describe why the file couldn't be read. 
  2478.  
  2479.  Tcl_GlobalEval is similar to Tcl_Eval except that it processes the command at 
  2480.  global level. This means that the variable context for the command consists of 
  2481.  global variables only (it ignores any Tcl procedure that is active). This 
  2482.  produces an effect similar to the Tcl command "uplevel 0". 
  2483.  
  2484.  During the processing of a Tcl command it is legal to make nested calls to 
  2485.  evaluate other commands (this is how conditionals, loops, and procedures are 
  2486.  implemented). If a code other than TCL_OK is returned from a nested Tcl_Eval 
  2487.  invocation, then the caller should normally return immediately, passing that 
  2488.  same return code back to its caller, and so on until the top-level application 
  2489.  is reached.  A few commands, like for, will check for certain return codes, 
  2490.  like TCL_BREAK and TCL_CONTINUE, and process them specially without returning. 
  2491.  
  2492.  Tcl_Eval keeps track of how many nested Tcl_Eval invocations are in progress 
  2493.  for interp. If a code of TCL_RETURN, TCL_BREAK, or TCL_CONTINUE is about to be 
  2494.  returned from the topmost Tcl_Eval invocation for interp, then Tcl_Eval 
  2495.  converts the return code to TCL_ERROR and sets interp->result to point to an 
  2496.  error message indicating that the return, break, or continue command was 
  2497.  invoked in an inappropriate place.  This means that top-level applications 
  2498.  should never see a return code from Tcl_Eval other then TCL_OK or TCL_ERROR. 
  2499.  
  2500.  KEYWORDS 
  2501.  
  2502.  command, execute, file, global, interpreter, variable 
  2503.  
  2504.  
  2505. ΓòÉΓòÉΓòÉ 2.28. Tcl_Exit ΓòÉΓòÉΓòÉ
  2506.  
  2507.  NAME 
  2508.  
  2509. Tcl_Exit, Tcl_CreateExitHandler, Tcl_DeleteExitHandler - end the application 
  2510. (and invoke exit handlers) 
  2511.  
  2512. SYNOPSIS 
  2513.  
  2514. #include <tcl.h> 
  2515.  
  2516.  Tcl_Exit(status) 
  2517.  
  2518.  Tcl_CreateExitHandler(proc, clientData) 
  2519.  
  2520.  Tcl_DeleteExitHandler(proc, clientData) 
  2521.  
  2522. ARGUMENTS 
  2523.  
  2524.  int  status (in)  Provides information about why application exited.  Exact 
  2525.            meaning may be platform-specific.  0 usually means a normal exit, 1 
  2526.            means that an error occurred. 
  2527.  
  2528.  Tcl_ExitProc  *proc (in)  Procedure to invoke before exiting application. 
  2529.  
  2530.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  2531.  
  2532.  DESCRIPTION 
  2533.  
  2534.  Tcl_Exit is the procedure that is invoked to end a Tcl application. It is 
  2535.  invoked by the exit command, as well as anyplace else that terminates the 
  2536.  application. No-one should ever invoke the exit procedure directly;  always 
  2537.  invoke Tcl_Exit instead, so that it can invoke exit handlers. 
  2538.  
  2539.  Tcl_CreateExitHandler arranges for proc to be invoked by Tcl_Exit before it 
  2540.  terminates the application. This provides a hook for cleanup operations such 
  2541.  as flushing buffers and freeing global memory. Proc should have arguments and 
  2542.  return value that match the type Tcl_ExitProc: 
  2543.  
  2544.   typedef void Tcl_ExitProc(ClientData clientData);
  2545.  The clientData parameter to proc is a copy of the clientData argument given to 
  2546.  Tcl_CreateExitHandler when the callback was created.  Typically, clientData 
  2547.  points to a data structure containing application-specific information about 
  2548.  what to do in proc. 
  2549.  
  2550.  Tcl_DeleteExitHandler may be called to delete a previously-created exit 
  2551.  handler.  It removes the handler indicated by proc and clientData so that no 
  2552.  call to proc will be made.  If no such handler exists then 
  2553.  Tcl_DeleteExitHandler does nothing. 
  2554.  
  2555.  KEYWORDS 
  2556.  
  2557.  callback, end application, exit 
  2558.  
  2559.  
  2560. ΓòÉΓòÉΓòÉ 2.29. Tcl_ExprLong ΓòÉΓòÉΓòÉ
  2561.  
  2562.  NAME 
  2563.  
  2564. Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBoolean, Tcl_ExprString - evaluate an 
  2565. expression 
  2566.  
  2567. SYNOPSIS 
  2568.  
  2569. #include <tcl.h> 
  2570.  
  2571.  int 
  2572.  Tcl_ExprLong(interp, string, longPtr) 
  2573.  
  2574.  int 
  2575.  Tcl_ExprDouble(interp, string, doublePtr) 
  2576.  
  2577.  int 
  2578.  Tcl_ExprBoolean(interp, string, booleanPtr) 
  2579.  
  2580.  int 
  2581.  Tcl_ExprString(interp, string) 
  2582.  
  2583. ARGUMENTS 
  2584.  
  2585.  Tcl_Interp  *interp (in)  Interpreter in whose context to evaluate string. 
  2586.  
  2587.  char  *string (in)  Expression to be evaluated.  Must be in writable memory 
  2588.            (the expression parser makes temporary modifications to the string 
  2589.            during parsing, which it undoes before returning). 
  2590.  
  2591.  long  *longPtr (out)  Pointer to location in which to store the integer value 
  2592.            of the expression. 
  2593.  
  2594.  int  *doublePtr (out)  Pointer to location in which to store the 
  2595.            floating-point value of the expression. 
  2596.  
  2597.  int  *booleanPtr (out)  Pointer to location in which to store the 0/1 boolean 
  2598.            value of the expression. 
  2599.  
  2600.  DESCRIPTION 
  2601.  
  2602.  These four procedures all evaluate an expression, returning the result in one 
  2603.  of four different forms. The expression is given by the string argument, and 
  2604.  it can have any of the forms accepted by the expr command. The interp argument 
  2605.  refers to an interpreter used to evaluate the expression (e.g. for variables 
  2606.  and nested Tcl commands) and to return error information.  Interp->result is 
  2607.  assumed to be initialized in the standard fashion when any of the procedures 
  2608.  are invoked. 
  2609.  
  2610.  For all of these procedures the return value is a standard Tcl result:  TCL_OK 
  2611.  means the expression was successfully evaluated, and TCL_ERROR means that an 
  2612.  error occurred while evaluating the expression.  If TCL_ERROR is returned then 
  2613.  interp->result will hold a message describing the error. If an error occurs 
  2614.  while executing a Tcl command embedded in the expression then that error will 
  2615.  be returned. 
  2616.  
  2617.  If the expression is successfully evaluated, then its value is returned in one 
  2618.  of four forms, depending on which procedure is invoked. Tcl_ExprLong stores an 
  2619.  integer value at *longPtr. If the expression's actual value is a 
  2620.  floating-point number, then it is truncated to an integer. If the expression's 
  2621.  actual value is a non-numeric string then an error is returned. 
  2622.  
  2623.  Tcl_ExprDouble stores a floating-point value at *doublePtr. If the 
  2624.  expression's actual value is an integer, it is converted to floating-point. If 
  2625.  the expression's actual value is a non-numeric string then an error is 
  2626.  returned. 
  2627.  
  2628.  Tcl_ExprBoolean stores a 0/1 integer value at *booleanPtr. If the expression's 
  2629.  actual value is an integer or floating-point number, then Tcl_ExprBoolean 
  2630.  stores 0 at *booleanPtr if the value was zero and 1 otherwise. If the 
  2631.  expression's actual value is a non-numeric string then it must be one of the 
  2632.  values accepted by Tcl_GetBoolean, such as "yes" or "no", or else an error 
  2633.  occurs. 
  2634.  
  2635.  Tcl_ExprString returns the value of the expression as a string stored in 
  2636.  interp->result. If the expression's actual value is an integer then 
  2637.  Tcl_ExprString converts it to a string using sprintf with a "%d" converter. If 
  2638.  the expression's actual value is a floating-point number, then Tcl_ExprString 
  2639.  calls Tcl_PrintDouble to convert it to a string. 
  2640.  
  2641.  KEYWORDS 
  2642.  
  2643.  boolean, double, evaluate, expression, integer, string 
  2644.  
  2645.  
  2646. ΓòÉΓòÉΓòÉ 2.30. Tcl_FindExecutable ΓòÉΓòÉΓòÉ
  2647.  
  2648.  NAME 
  2649.  
  2650. Tcl_FindExecutable - identify the binary file containing the application 
  2651.  
  2652. SYNOPSIS 
  2653.  
  2654. #include <tcl.h> 
  2655.  
  2656.  char * 
  2657.  Tcl_FindExecutable(argv0) 
  2658.  
  2659. ARGUMENTS 
  2660.  
  2661.  char  *argv0 (in)  The first command-line argument to the program, which gives 
  2662.            the application's name. 
  2663.  
  2664.  DESCRIPTION 
  2665.  
  2666.  This procedure computes the full path name of the executable file from which 
  2667.  the application was invoked and saves it for Tcl's internal use. The 
  2668.  executable's path name is needed for several purposes in Tcl.  For example, it 
  2669.  is needed on some platforms in the implementation of the load command. It is 
  2670.  also returned by the info nameofexecutable command. 
  2671.  
  2672.  On UNIX platforms this procedure is typically invoked as the very first thing 
  2673.  in the application's main program;  it must be passed argv[0] as its argument. 
  2674.  Tcl_FindExecutable uses argv0 along with the PATH environment variable to find 
  2675.  the application's executable, if possible.  If it fails to find the binary, 
  2676.  then future calls to info nameofexecutable will return an empty string. 
  2677.  
  2678.  KEYWORDS 
  2679.  
  2680.  binary, executable file 
  2681.  
  2682.  
  2683. ΓòÉΓòÉΓòÉ 2.31. Tcl_GetFile ΓòÉΓòÉΓòÉ
  2684.  
  2685.  NAME 
  2686.  
  2687. Tcl_GetFile, Tcl_FreeFile, Tcl_GetFileInfo - procedures to manipulate generic 
  2688. file handles 
  2689.  
  2690. SYNOPSIS 
  2691.  
  2692. #include <tcl.h> 
  2693.  
  2694.  Tcl_File 
  2695.  Tcl_GetFile(osHandle, type) 
  2696.  
  2697.  Tcl_FreeFile(handle) 
  2698.  
  2699.  ClientData 
  2700.  Tcl_GetFileInfo(handle, typePtr) 
  2701.  
  2702.  ClientData 
  2703.  Tcl_GetNotifierData(handle, freeProcPtr) 
  2704.  
  2705.  Tcl_SetNotifierData(handle, freeProc, clientData) 
  2706.  
  2707. ARGUMENTS 
  2708.  
  2709.  ClientData  osHandle (in)  Platform-specific file handle to be associated with 
  2710.            the generic file handle. 
  2711.  
  2712.  int  type (in)  The type of platform-specific file handle associated with the 
  2713.            generic file handle.  See below for a list of valid types. 
  2714.  
  2715.  Tcl_File  handle (in)  Generic file handle associated with platform-specific 
  2716.            file information. 
  2717.  
  2718.  int  *typePtr (in/out)  If *typePtr is not NULL, then the specified word is 
  2719.            set to contain the type associated with handle. 
  2720.  
  2721.  Tcl_FileFreeProc  *freeProc (in)  Procedure to call when handle is deleted. 
  2722.  
  2723.  Tcl_FileFreeProc  **freeProcPtr (in/out)  Pointer to location in which to 
  2724.            store address of current free procedure for file handle.  Ignored if 
  2725.            NULL. 
  2726.  
  2727.  ClientData  clientData (in)  Arbitrary one-word value associated with the 
  2728.            given file handle. This data is owned by the caller. 
  2729.  
  2730.  DESCRIPTION 
  2731.  
  2732.  A Tcl_File is an opaque handle used to refer to files in a platform 
  2733.  independent way in Tcl routines like Tcl_CreateFileHandler.  A file handle has 
  2734.  an associated platform-dependent osHandle, a type and additional private data 
  2735.  used by the notifier to generate events for the file.  The type is an integer 
  2736.  that determines how the platform-specific drivers will interpret the osHandle. 
  2737.  The types that are defined by the core are: 
  2738.  
  2739.  TCL_UNIX_FD  The osHandle is a Unix file descriptor. 
  2740.  
  2741.  TCL_MAC_FILE  The file is a Macintosh file handle. 
  2742.  
  2743.  TCL_WIN_FILE  The osHandle is a Windows normal file HANDLE. 
  2744.  
  2745.  TCL_WIN_PIPE  The osHandle is a Windows anonymous pipe HANDLE. 
  2746.  
  2747.  TCL_WIN_SOCKET  The osHandle is a Windows SOCKET. 
  2748.  
  2749.  TCL_WIN_CONSOLE  The osHandle is a Windows console buffer HANDLE. 
  2750.  
  2751.  Tcl_GetFile locates the file handle corresponding to a particular osHandle and 
  2752.  a type.  If a file handle already existed for the given file, then that handle 
  2753.  will be returned.  If this is the first time that the file handle for a 
  2754.  particular file is being retrieved, then a new file handle will be allocated 
  2755.  and returned. 
  2756.  
  2757.  When a file handle is no longer in use, it should be deallocated with a call 
  2758.  to Tcl_FreeFile.  A call to this function will invoke the notifier free 
  2759.  procedure proc, if there is one.  After the notifier has cleaned up, any 
  2760.  resources used by the file handle will be deallocated.  Tcl_FreeFile will not 
  2761.  close the platform-specific osHandle. 
  2762.  
  2763.  Tcl_GetFileInfo may be used to retrieve the platform-specific osHandle and 
  2764.  type associated with a file handle.  If typePtr is not NULL, then the word at 
  2765.  *typePtr is set to the type of the file handle.  The return value of the 
  2766.  function is the associated platform-specific osHandle.  Note that this 
  2767.  function may be used to extract the platform-specific file handle from a 
  2768.  Tcl_File so that it may be used in external interfaces. However, programs 
  2769.  written using this interface will be platform-specific. 
  2770.  
  2771.  The Tcl_SetNotifierData and Tcl_GetNotifierData procedures are intended to be 
  2772.  used only by notifier writers.  See the Tcl_CreateEventSource(3) manual entry 
  2773.  for more information on the notifier. 
  2774.  
  2775.  Tcl_SetNotifierData may be used by notifier writers to associate 
  2776.  notifier-specific information with a Tcl_File.  The data argument specifies a 
  2777.  word that may be retrieved with a later call to Tcl_GetNotifierData.  If the 
  2778.  freeProc argument is non-NULL it specifies the address of a procedure to 
  2779.  invoke when the Tcl_File is deleted.  freeProc should have arguments and 
  2780.  result that match the type Tcl_FileFreeProc: 
  2781.  
  2782.   typedef void Tcl_FileFreeProc(
  2783.          ClientData clientData);
  2784.  When freeProc is invoked the clientData argument will be the same as the 
  2785.  corresponding argument passed to Tcl_SetNotifierData. 
  2786.  
  2787.  Tcl_GetNotifierData returns the clientData associated with the given Tcl_File, 
  2788.  and if the freeProcPtr field is non-NULL, the address indicated by it gets the 
  2789.  address of the free procedure stored with this file. 
  2790.  
  2791.  KEYWORDS 
  2792.  
  2793.  generic file handle, file type, file descriptor, notifier 
  2794.  
  2795.  
  2796. ΓòÉΓòÉΓòÉ 2.32. Tcl_GetInt ΓòÉΓòÉΓòÉ
  2797.  
  2798.  NAME 
  2799.  
  2800. Tcl_GetInt, Tcl_GetDouble, Tcl_GetBoolean - convert from string to integer, 
  2801. double, or boolean 
  2802.  
  2803. SYNOPSIS 
  2804.  
  2805. #include <tcl.h> 
  2806.  
  2807.  int 
  2808.  Tcl_GetInt(interp, string, intPtr) 
  2809.  
  2810.  int 
  2811.  Tcl_GetDouble(interp, string, doublePtr) 
  2812.  
  2813.  int 
  2814.  Tcl_GetBoolean(interp, string, boolPtr) 
  2815.  
  2816. ARGUMENTS 
  2817.  
  2818.  Tcl_Interp  *interp (in)  Interpreter to use for error reporting. 
  2819.  
  2820.  char  *string (in)  Textual value to be converted. 
  2821.  
  2822.  int  *intPtr (out)  Points to place to store integer value converted from 
  2823.            string. 
  2824.  
  2825.  double  *doublePtr (out)  Points to place to store double-precision 
  2826.            floating-point value converted from string. 
  2827.  
  2828.  int  *boolPtr (out)  Points to place to store boolean value (0 or 1) converted 
  2829.            from string. 
  2830.  
  2831.  DESCRIPTION 
  2832.  
  2833.  These procedures convert from strings to integers or double-precision 
  2834.  floating-point values or booleans (represented as 0- or 1-valued integers). 
  2835.  Each of the procedures takes a string argument, converts it to an internal 
  2836.  form of a particular type, and stores the converted value at the location 
  2837.  indicated by the procedure's third argument.  If all goes well, each of the 
  2838.  procedures returns TCL_OK.  If string doesn't have the proper syntax for the 
  2839.  desired type then TCL_ERROR is returned, an error message is left in 
  2840.  interp->result, and nothing is stored at *intPtr or *doublePtr or *boolPtr. 
  2841.  
  2842.  Tcl_GetInt expects string to consist of a collection of integer digits, 
  2843.  optionally signed and optionally preceded by white space.  If the first two 
  2844.  characters of string are "0x" then string is expected to be in hexadecimal 
  2845.  form;  otherwise, if the first character of string is "0" then string is 
  2846.  expected to be in octal form;  otherwise, string is expected to be in decimal 
  2847.  form. 
  2848.  
  2849.  Tcl_GetDouble expects string to consist of a floating-point number, which is: 
  2850.  white space;  a sign; a sequence of digits;  a decimal point;  a sequence of 
  2851.  digits;  the letter "e";  and a signed decimal exponent.  Any of the fields 
  2852.  may be omitted, except that the digits either before or after the decimal 
  2853.  point must be present and if the "e" is present then it must be followed by 
  2854.  the exponent number. 
  2855.  
  2856.  Tcl_GetBoolean expects string to specify a boolean value.  If string is any of 
  2857.  0, false, no, or off, then Tcl_GetBoolean stores a zero value at *boolPtr. If 
  2858.  string is any of 1, true, yes, or on, then 1 is stored at *boolPtr. Any of 
  2859.  these values may be abbreviated, and upper-case spellings are also acceptable. 
  2860.  
  2861.  KEYWORDS 
  2862.  
  2863.  boolean, conversion, double, floating-point, integer 
  2864.  
  2865.  
  2866. ΓòÉΓòÉΓòÉ 2.33. Tcl_GetOpenFile ΓòÉΓòÉΓòÉ
  2867.  
  2868.  NAME 
  2869.  
  2870. Tcl_GetOpenFile - Get a standard IO File * handle from a channel. 
  2871.  
  2872. SYNOPSIS 
  2873.  
  2874. #include <tcl.h> 
  2875.  
  2876.  int 
  2877.  Tcl_GetOpenFile(interp, string, write, checkUsage, filePtr) 
  2878.  
  2879. ARGUMENTS 
  2880.  
  2881.  Tcl_Interp  *interp (in)  Tcl interpreter from which file handle is to be 
  2882.            obtained. 
  2883.  
  2884.  char  *string (in)  String identifying channel, such as stdin or file4. 
  2885.  
  2886.  int  write (in)  Non-zero means the file will be used for writing, zero means 
  2887.            it will be used for reading. 
  2888.  
  2889.  int  checkUsage (in)  If non-zero, then an error will be generated if the file 
  2890.            wasn't opened for the access indicated by write. 
  2891.  
  2892.  ClientData  *filePtr (out)  Points to word in which to store pointer to FILE 
  2893.            structure for the file given by string. 
  2894.  
  2895.  DESCRIPTION 
  2896.  
  2897.  Tcl_GetOpenFile takes as argument a file identifier of the form returned by 
  2898.  the open command and returns at *filePtr a pointer to the FILE structure for 
  2899.  the file. The write argument indicates whether the FILE pointer will be used 
  2900.  for reading or writing. In some cases, such as a channel that connects to a 
  2901.  pipeline of subprocesses, different FILE pointers will be returned for reading 
  2902.  and writing. Tcl_GetOpenFile normally returns TCL_OK. If an error occurs in 
  2903.  Tcl_GetOpenFile (e.g. string didn't make any sense or checkUsage was set and 
  2904.  the file wasn't opened for the access specified by write) then TCL_ERROR is 
  2905.  returned and interp->result will contain an error message. In the current 
  2906.  implementation checkUsage is ignored and consistency checks are always 
  2907.  performed. 
  2908.  
  2909.  KEYWORDS 
  2910.  
  2911.  channel, file handle, permissions, pipeline, read, write 
  2912.  
  2913.  
  2914. ΓòÉΓòÉΓòÉ 2.34. Tcl_GetStdChannel ΓòÉΓòÉΓòÉ
  2915.  
  2916.  NAME 
  2917.  
  2918. Tcl_GetStdChannel, Tcl_SetStdChannel - procedures for retrieving and replacing 
  2919. the standard channels 
  2920.  
  2921. SYNOPSIS 
  2922.  
  2923. #include <tcl.h> 
  2924.  
  2925.  Tcl_Channel 
  2926.  Tcl_GetStdChannel(type) 
  2927.  
  2928.  Tcl_SetStdChannel(channel, type) 
  2929.  
  2930. ARGUMENTS 
  2931.  
  2932.  int  type (in)  The identifier for the standard channel to retrieve or modify. 
  2933.            Must be one of TCL_STDIN, TCL_STDOUT, or TCL_STDERR. 
  2934.  
  2935.  Tcl_Channel  channel (in)  The channel to use as the new value for the 
  2936.            specified standard channel. 
  2937.  
  2938.  DESCRIPTION 
  2939.  
  2940.  Tcl defines three special channels that are used by various I/O related 
  2941.  commands if no other channels are specified.  The standard input channel has a 
  2942.  channel name of stdin and is used by read and gets. The standard output 
  2943.  channel is named stdout and is used by puts.  The standard error channel is 
  2944.  named stderr and is used for reporting errors.  In addition, the standard 
  2945.  channels are inherited by any child processes created using exec or open in 
  2946.  the absence of any other redirections. 
  2947.  
  2948.  The standard channels are actually aliases for other normal channels.  The 
  2949.  current channel associated with a standard channel can be retrieved by calling 
  2950.  Tcl_GetStdChannel with one of TCL_STDIN, TCL_STDOUT, or TCL_STDERR as the 
  2951.  type.  The return value will be a valid channel, or NULL. 
  2952.  
  2953.  A new channel can be set for the standard channel specified by type by calling 
  2954.  Tcl_SetStdChannel with a new channel or NULL in the channel argument.  If the 
  2955.  specified channel is closed by a later call to Tcl_Close, then the 
  2956.  corresponding standard channel will automatically be set to NULL. 
  2957.  
  2958.  If Tcl_GetStdChannel is called before Tcl_SetStdChannel, Tcl will construct a 
  2959.  new channel to wrap the appropriate platform-specific standard file handle. 
  2960.  If Tcl_SetStdChannel is called before Tcl_GetStdChannel, then the default 
  2961.  channel will not be created. 
  2962.  
  2963.  If one of the standard channels is set to NULL, either by calling 
  2964.  Tcl_SetStdChannel with a null channel argument, or by calling Tcl_Close on the 
  2965.  channel, then the next call to Tcl_CreateChannel will automatically set the 
  2966.  standard channel with the newly created channel.  If more than one standard 
  2967.  channel is NULL, then the standard channels will be assigned starting with 
  2968.  standard input, followed by standard output, with standard error being last. 
  2969.  
  2970.  SEE ALSO 
  2971.  
  2972.  Tcl_Close(3), Tcl_CreateChannel(3) 
  2973.  
  2974.  KEYWORDS 
  2975.  
  2976.  standard channel, standard input, standard output, standard error 
  2977.  
  2978.  
  2979. ΓòÉΓòÉΓòÉ 2.35. Tcl_Hash ΓòÉΓòÉΓòÉ
  2980.  
  2981.  NAME 
  2982.  
  2983. Tcl_InitHashTable, Tcl_DeleteHashTable, Tcl_CreateHashEntry, 
  2984. Tcl_DeleteHashEntry, Tcl_FindHashEntry, Tcl_GetHashValue, Tcl_SetHashValue, 
  2985. Tcl_GetHashKey, Tcl_FirstHashEntry,  Tcl_NextHashEntry, Tcl_HashStats - 
  2986. procedures to manage hash tables 
  2987.  
  2988. SYNOPSIS 
  2989.  
  2990. #include <tcl.h> 
  2991.  
  2992.  Tcl_InitHashTable(tablePtr, keyType) 
  2993.  
  2994.  Tcl_DeleteHashTable(tablePtr) 
  2995.  
  2996.  Tcl_HashEntry * 
  2997.  Tcl_CreateHashEntry(tablePtr, key, newPtr) 
  2998.  
  2999.  Tcl_DeleteHashEntry(entryPtr) 
  3000.  
  3001.  Tcl_HashEntry * 
  3002.  Tcl_FindHashEntry(tablePtr, key) 
  3003.  
  3004.  ClientData 
  3005.  Tcl_GetHashValue(entryPtr) 
  3006.  
  3007.  Tcl_SetHashValue(entryPtr, value) 
  3008.  
  3009.  char * 
  3010.  Tcl_GetHashKey(tablePtr, entryPtr) 
  3011.  
  3012.  Tcl_HashEntry * 
  3013.  Tcl_FirstHashEntry(tablePtr, searchPtr) 
  3014.  
  3015.  Tcl_HashEntry * 
  3016.  Tcl_NextHashEntry(searchPtr) 
  3017.  
  3018.  char * 
  3019.  Tcl_HashStats(tablePtr) 
  3020.  
  3021. ARGUMENTS 
  3022.  
  3023.  Tcl_HashTable  *tablePtr (in)  Address of hash table structure (for all 
  3024.            procedures but Tcl_InitHashTable, this must have been initialized by 
  3025.            previous call to Tcl_InitHashTable). 
  3026.  
  3027.  int  keyType (in)  Kind of keys to use for new hash table.  Must be either 
  3028.            TCL_STRING_KEYS, TCL_ONE_WORD_KEYS, or an integer value greater than 
  3029.            1. 
  3030.  
  3031.  char  *key (in)  Key to use for probe into table.  Exact form depends on 
  3032.            keyType used to create table. 
  3033.  
  3034.  int  *newPtr (out)  The word at *newPtr is set to 1 if a new entry was created 
  3035.            and 0 if there was already an entry for key. 
  3036.  
  3037.  Tcl_HashEntry  *entryPtr (in)  Pointer to hash table entry. 
  3038.  
  3039.  ClientData  value (in)  New value to assign to hash table entry.  Need not 
  3040.            have type ClientData, but must fit in same space as ClientData. 
  3041.  
  3042.  Tcl_HashSearch  *searchPtr (in)  Pointer to record to use to keep track of 
  3043.            progress in enumerating all the entries in a hash table. 
  3044.  
  3045.  DESCRIPTION 
  3046.  
  3047.  A hash table consists of zero or more entries, each consisting of a key and a 
  3048.  value. Given the key for an entry, the hashing routines can very quickly 
  3049.  locate the entry, and hence its value. There may be at most one entry in a 
  3050.  hash table with a particular key, but many entries may have the same value. 
  3051.  Keys can take one of three forms:  strings, one-word values, or integer 
  3052.  arrays. All of the keys in a given table have the same form, which is 
  3053.  specified when the table is initialized. 
  3054.  
  3055.  The value of a hash table entry can be anything that fits in the same space as 
  3056.  a "char *" pointer. Values for hash table entries are managed entirely by 
  3057.  clients, not by the hash module itself. Typically each entry's value is a 
  3058.  pointer to a data structure managed by client code. 
  3059.  
  3060.  Hash tables grow gracefully as the number of entries increases, so that there 
  3061.  are always less than three entries per hash bucket, on average. This allows 
  3062.  for fast lookups regardless of the number of entries in a table. 
  3063.  
  3064.  Tcl_InitHashTable initializes a structure that describes a new hash table. The 
  3065.  space for the structure is provided by the caller, not by the hash module. The 
  3066.  value of keyType indicates what kinds of keys will be used for all entries in 
  3067.  the table.  KeyType must have one of the following values: 
  3068.  
  3069.  TCL_STRING_KEYS Keys are null-terminated ASCII strings. They are passed to 
  3070.            hashing routines using the address of the first character of the 
  3071.            string. 
  3072.  
  3073.  TCL_ONE_WORD_KEYS Keys are single-word values;  they are passed to hashing 
  3074.            routines and stored in hash table entries as "char *" values. The 
  3075.            pointer value is the key;  it need not (and usually doesn't) 
  3076.            actually point to a string. 
  3077.  
  3078.  other     If keyType is not TCL_STRING_KEYS or TCL_ONE_WORD_KEYS, then it must 
  3079.            be an integer value greater than 1. In this case the keys will be 
  3080.            arrays of "int" values, where keyType gives the number of ints in 
  3081.            each key. This allows structures to be used as keys. All keys must 
  3082.            have the same size. Array keys are passed into hashing functions 
  3083.            using the address of the first int in the array. 
  3084.  
  3085.  Tcl_DeleteHashTable deletes all of the entries in a hash table and frees up 
  3086.  the memory associated with the table's bucket array and entries. It does not 
  3087.  free the actual table structure (pointed to by tablePtr), since that memory is 
  3088.  assumed to be managed by the client. Tcl_DeleteHashTable also does not free or 
  3089.  otherwise manipulate the values of the hash table entries. If the entry values 
  3090.  point to dynamically-allocated memory, then it is the client's responsibility 
  3091.  to free these structures before deleting the table. 
  3092.  
  3093.  Tcl_CreateHashEntry locates the entry corresponding to a particular key, 
  3094.  creating a new entry in the table if there wasn't already one with the given 
  3095.  key. If an entry already existed with the given key then *newPtr is set to 
  3096.  zero. If a new entry was created, then *newPtr is set to a non-zero value and 
  3097.  the value of the new entry will be set to zero. The return value from 
  3098.  Tcl_CreateHashEntry is a pointer to the entry, which may be used to retrieve 
  3099.  and modify the entry's value or to delete the entry from the table. 
  3100.  
  3101.  Tcl_DeleteHashEntry will remove an existing entry from a table. The memory 
  3102.  associated with the entry itself will be freed, but the client is responsible 
  3103.  for any cleanup associated with the entry's value, such as freeing a structure 
  3104.  that it points to. 
  3105.  
  3106.  Tcl_FindHashEntry is similar to Tcl_CreateHashEntry except that it doesn't 
  3107.  create a new entry if the key doesn't exist; instead, it returns NULL as 
  3108.  result. 
  3109.  
  3110.  Tcl_GetHashValue and Tcl_SetHashValue are used to read and write an entry's 
  3111.  value, respectively. Values are stored and retrieved as type "ClientData", 
  3112.  which is large enough to hold a pointer value.  On almost all machines this is 
  3113.  large enough to hold an integer value too. 
  3114.  
  3115.  Tcl_GetHashKey returns the key for a given hash table entry, either as a 
  3116.  pointer to a string, a one-word ("char *") key, or as a pointer to the first 
  3117.  word of an array of integers, depending on the keyType used to create a hash 
  3118.  table. In all cases Tcl_GetHashKey returns a result with type "char *". When 
  3119.  the key is a string or array, the result of Tcl_GetHashKey points to 
  3120.  information in the table entry;  this information will remain valid until the 
  3121.  entry is deleted or its table is deleted. 
  3122.  
  3123.  Tcl_FirstHashEntry and Tcl_NextHashEntry may be used to scan all of the 
  3124.  entries in a hash table. A structure of type "Tcl_HashSearch", provided by the 
  3125.  client, is used to keep track of progress through the table. 
  3126.  Tcl_FirstHashEntry initializes the search record and returns the first entry 
  3127.  in the table (or NULL if the table is empty). Each subsequent call to 
  3128.  Tcl_NextHashEntry returns the next entry in the table or NULL if the end of 
  3129.  the table has been reached. A call to Tcl_FirstHashEntry followed by calls to 
  3130.  Tcl_NextHashEntry will return each of the entries in the table exactly once, 
  3131.  in an arbitrary order. It is unadvisable to modify the structure of the table, 
  3132.  e.g. by creating or deleting entries, while the search is in progress. 
  3133.  
  3134.  Tcl_HashStats returns a dynamically-allocated string with overall information 
  3135.  about a hash table, such as the number of entries it contains, the number of 
  3136.  buckets in its hash array, and the utilization of the buckets. It is the 
  3137.  caller's responsibility to free the result string by passing it to free. 
  3138.  
  3139.  The header file tcl.h defines the actual data structures used to implement 
  3140.  hash tables. This is necessary so that clients can allocate Tcl_HashTable 
  3141.  structures and so that macros can be used to read and write the values of 
  3142.  entries. However, users of the hashing routines should never refer directly to 
  3143.  any of the fields of any of the hash-related data structures; use the 
  3144.  procedures and macros defined here. 
  3145.  
  3146.  KEYWORDS 
  3147.  
  3148.  hash table, key, lookup, search, value 
  3149.  
  3150.  
  3151. ΓòÉΓòÉΓòÉ 2.36. Tcl_Interp ΓòÉΓòÉΓòÉ
  3152.  
  3153.  NAME 
  3154.  
  3155. Tcl_Interp - client-visible fields of interpreter structures 
  3156.  
  3157. SYNOPSIS 
  3158.  
  3159. #include <tcl.h> 
  3160.  
  3161.  typedef struct { 
  3162.  char *result; 
  3163.  Tcl_FreeProc *freeProc; 
  3164.  int errorLine; 
  3165.  } Tcl_Interp; 
  3166.  
  3167.  typedef void Tcl_FreeProc(char *blockPtr); 
  3168.  
  3169. DESCRIPTION 
  3170.  
  3171. The Tcl_CreateInterp procedure returns a pointer to a Tcl_Interp structure. 
  3172. This pointer is then passed into other Tcl procedures to process commands in 
  3173. the interpreter and perform other operations on the interpreter.  Interpreter 
  3174. structures contain many many fields that are used by Tcl, but only three that 
  3175. may be accessed by clients:  result, freeProc, and errorLine. 
  3176.  
  3177. The result and freeProc fields are used to return results or error messages 
  3178. from commands. This information is returned by command procedures back to 
  3179. Tcl_Eval, and by Tcl_Eval back to its callers. The result field points to the 
  3180. string that represents the result or error message, and the freeProc field 
  3181. tells how to dispose of the storage for the string when it isn't needed 
  3182. anymore. The easiest way for command procedures to manipulate these fields is 
  3183. to call procedures like Tcl_SetResult or Tcl_AppendResult;  they will hide all 
  3184. the details of managing the fields. The description below is for those 
  3185. procedures that manipulate the fields directly. 
  3186.  
  3187. Whenever a command procedure returns, it must ensure that the result field of 
  3188. its interpreter points to the string being returned by the command. The result 
  3189. field must always point to a valid string. If a command wishes to return no 
  3190. result then interp->result should point to an empty string. Normally, results 
  3191. are assumed to be statically allocated, which means that the contents will not 
  3192. change before the next time Tcl_Eval is called or some other command procedure 
  3193. is invoked. In this case, the freeProc field must be zero. Alternatively, a 
  3194. command procedure may dynamically allocate its return value (e.g. using 
  3195. Tcl_Alloc) and store a pointer to it in interp->result. In this case, the 
  3196. command procedure must also set interp->freeProc to the address of a procedure 
  3197. that can free the value, or TCL_DYNAMIC if the storage was allocated directly 
  3198. by Tcl or by a call to Tcl_Alloc. If interp->freeProc is non-zero, then Tcl 
  3199. will call freeProc to free the space pointed to by interp->result before it 
  3200. invokes the next command. If a client procedure overwrites interp->result when 
  3201. interp->freeProc is non-zero, then it is responsible for calling freeProc to 
  3202. free the old interp->result (the Tcl_FreeResult macro should be used for this 
  3203. purpose). 
  3204.  
  3205. FreeProc should have arguments and result that match the Tcl_FreeProc 
  3206. declaration above:  it receives a single argument which is a pointer to the 
  3207. result value to free. In most applications TCL_DYNAMIC is the only non-zero 
  3208. value ever used for freeProc. However, an application may store a different 
  3209. procedure address in freeProc in order to use an alternate memory allocator or 
  3210. in order to do other cleanup when the result memory is freed. 
  3211.  
  3212. As part of processing each command, Tcl_Eval initializes interp->result and 
  3213. interp->freeProc just before calling the command procedure for the command. 
  3214. The freeProc field will be initialized to zero, and interp->result will point 
  3215. to an empty string.  Commands that do not return any value can simply leave the 
  3216. fields alone. Furthermore, the empty string pointed to by result is actually 
  3217. part of an array of TCL_RESULT_SIZE characters (approximately 200). If a 
  3218. command wishes to return a short string, it can simply copy it to the area 
  3219. pointed to by interp->result.  Or, it can use the sprintf procedure to generate 
  3220. a short result string at the location pointed to by interp->result. 
  3221.  
  3222. It is a general convention in Tcl-based applications that the result of an 
  3223. interpreter is normally in the initialized state described in the previous 
  3224. paragraph. Procedures that manipulate an interpreter's result (e.g. by 
  3225. returning an error) will generally assume that the result has been initialized 
  3226. when the procedure is called. If such a procedure is to be called after the 
  3227. result has been changed, then Tcl_ResetResult should be called first to reset 
  3228. the result to its initialized state. 
  3229.  
  3230. The errorLine field is valid only after Tcl_Eval returns a TCL_ERROR return 
  3231. code.  In this situation the errorLine field identifies the line number of the 
  3232. command being executed when the error occurred.  The line numbers are relative 
  3233. to the command being executed:  1 means the first line of the command passed to 
  3234. Tcl_Eval, 2 means the second line, and so on. The errorLine field is typically 
  3235. used in conjunction with Tcl_AddErrorInfo to report information about where an 
  3236. error occurred. ErrorLine should not normally be modified except by Tcl_Eval. 
  3237.  
  3238. KEYWORDS 
  3239.  
  3240. free, initialized, interpreter, malloc, result 
  3241.  
  3242.  
  3243. ΓòÉΓòÉΓòÉ 2.37. Tcl_LinkVar ΓòÉΓòÉΓòÉ
  3244.  
  3245.  NAME 
  3246.  
  3247. Tcl_LinkVar, Tcl_UnlinkVar, Tcl_UpdateLinkedVar - link Tcl variable to C 
  3248. variable 
  3249.  
  3250. SYNOPSIS 
  3251.  
  3252. #include <tcl.h> 
  3253.  
  3254.  int 
  3255.  Tcl_LinkVar(interp, varName, addr, type) 
  3256.  
  3257.  Tcl_UnlinkVar(interp, varName) 
  3258.  
  3259.  Tcl_UpdateLinkedVar(interp, varName) 
  3260.  
  3261. ARGUMENTS 
  3262.  
  3263.  Tcl_Interp  *interp (in)  Interpreter that contains varName. Also used by 
  3264.            Tcl_LinkVar to return error messages. 
  3265.  
  3266.  char  *varName (in)  Name of global variable.  Must be in writable memory: Tcl 
  3267.            may make temporary modifications to it while parsing the variable 
  3268.            name. 
  3269.  
  3270.  char  *addr (in)  Address of C variable that is to be linked to varName. 
  3271.  
  3272.  int  type (in)  Type of C variable.  Must be one of TCL_LINK_INT, 
  3273.            TCL_LINK_DOUBLE, TCL_LINK_BOOLEAN, or TCL_LINK_STRING, optionally 
  3274.            OR'ed with TCL_LINK_READ_ONLY to make Tcl variable read-only. 
  3275.  
  3276.  DESCRIPTION 
  3277.  
  3278.  Tcl_LinkVar uses variable traces to keep the Tcl variable named by varName in 
  3279.  sync with the C variable at the address given by addr. Whenever the Tcl 
  3280.  variable is read the value of the C variable will be returned, and whenever 
  3281.  the Tcl variable is written the C variable will be updated to have the same 
  3282.  value. Tcl_LinkVar normally returns TCL_OK;  if an error occurs while setting 
  3283.  up the link (e.g. because varName is the name of array) then TCL_ERROR is 
  3284.  returned and interp->result contains an error message. 
  3285.  
  3286.  The type argument specifies the type of the C variable, and must have one of 
  3287.  the following values, optionally OR'ed with TCL_LINK_READ_ONLY: 
  3288.  
  3289.  TCL_LINK_INT  The C variable is of type int. Any value written into the Tcl 
  3290.            variable must have a proper integer form acceptable to Tcl_GetInt; 
  3291.            attempts to write non-integer values into varName will be rejected 
  3292.            with Tcl errors. 
  3293.  
  3294.  TCL_LINK_DOUBLE  The C variable is of type double. Any value written into the 
  3295.            Tcl variable must have a proper real form acceptable to 
  3296.            Tcl_GetDouble;  attempts to write non-real values into varName will 
  3297.            be rejected with Tcl errors. 
  3298.  
  3299.  TCL_LINK_BOOLEAN  The C variable is of type int. If its value is zero then it 
  3300.            will read from Tcl as "0"; otherwise it will read from Tcl as "1". 
  3301.            Whenever varName is modified, the C variable will be set to a 0 or 1 
  3302.            value. Any value written into the Tcl variable must have a proper 
  3303.            boolean form acceptable to Tcl_GetBoolean;  attempts to write 
  3304.            non-boolean values into varName will be rejected with Tcl errors. 
  3305.  
  3306.  TCL_LINK_STRING  The C variable is of type char *. If its value is not null 
  3307.            then it must be a pointer to a string allocated with Tcl_Alloc. 
  3308.            Whenever the Tcl variable is modified the current C string will be 
  3309.            freed and new memory will be allocated to hold a copy of the 
  3310.            variable's new value. If the C variable contains a null pointer then 
  3311.            the Tcl variable will read as "NULL". 
  3312.  
  3313.  If the TCL_LINK_READ_ONLY flag is present in type then the variable will be 
  3314.  read-only from Tcl, so that its value can only be changed by modifying the C 
  3315.  variable. Attempts to write the variable from Tcl will be rejected with 
  3316.  errors. 
  3317.  
  3318.  Tcl_UnlinkVar removes the link previously set up for the variable given by 
  3319.  varName.  If there does not exist a link for varName then the procedure has no 
  3320.  effect. 
  3321.  
  3322.  Tcl_UpdateLinkedVar may be invoked after the C variable has changed to force 
  3323.  the Tcl variable to be updated immediately. In many cases this procedure is 
  3324.  not needed, since any attempt to read the Tcl variable will return the latest 
  3325.  value of the C variable. However, if a trace has been set on the Tcl variable 
  3326.  (such as a Tk widget that wishes to display the value of the variable), the 
  3327.  trace will not trigger when the C variable has changed. Tcl_UpdateLinkedVar 
  3328.  ensures that any traces on the Tcl variable are invoked. 
  3329.  
  3330.  KEYWORDS 
  3331.  
  3332.  boolean, integer, link, read-only, real, string, traces, variable 
  3333.  
  3334.  
  3335. ΓòÉΓòÉΓòÉ 2.38. Tcl_CreateEventSource ΓòÉΓòÉΓòÉ
  3336.  
  3337.  NAME 
  3338.  
  3339. Tcl_CreateEventSource, Tcl_DeleteEventSource, Tcl_WatchFile, Tcl_FileReady, 
  3340. Tcl_SetMaxBlockTime, Tcl_QueueEvent, Tcl_WaitForEvent - Event sources, the 
  3341. event notifier, and the event queue 
  3342.  
  3343. SYNOPSIS 
  3344.  
  3345. #include <tcl.h> 
  3346.  
  3347.  Tcl_CreateEventSource(setupProc, checkProc, clientData) 
  3348.  
  3349.  Tcl_DeleteEventSource(setupProc, checkProc, clientData) 
  3350.  
  3351.  Tcl_WatchFile(file, mask) 
  3352.  
  3353.  Tcl_SetMaxBlockTime(timePtr) 
  3354.  
  3355.  int 
  3356.  Tcl_FileReady(file, mask) 
  3357.  
  3358.  Tcl_QueueEvent(evPtr, position) 
  3359.  
  3360.  int 
  3361.  Tcl_WaitForEvent(timePtr) 
  3362.  
  3363. ARGUMENTS 
  3364.  
  3365.  Tcl_EventSetupProc  *setupProc (in)  Procedure to invoke to prepare for event 
  3366.            wait in Tcl_DoWhenIdle. 
  3367.  
  3368.  Tcl_EventCheckProc  *checkProc (in)  Procedure for Tcl_DoWhenIdle to invoke 
  3369.            after waiting for events.  Checks to see if any events have occurred 
  3370.            and, if so, queues them. 
  3371.  
  3372.  ClientData  clientData (in)  Arbitrary one-word value to pass to setupProc and 
  3373.            checkProc. 
  3374.  
  3375.  Tcl_File  file (in)  Generic file handle as returned by Tcl_GetFile. 
  3376.  
  3377.  int  mask (in)  Indicates the events of interest on file:  an OR'ed 
  3378.            combination of TCL_READABLE, TCL_WRITABLE, and TCL_EXCEPTION. 
  3379.  
  3380.  Tcl_Time  *timePtr (in)  Indicates the maximum amount of time to wait for an 
  3381.            event.  This is specified as an interval (how long to wait), not an 
  3382.            absolute time (when to wakeup).  If the pointer passed to 
  3383.            Tcl_WaitForEvent is NULL, it means there is no maximum wait time: 
  3384.            wait forever if necessary. 
  3385.  
  3386.  Tcl_Event  *evPtr (in)  An event to add to the event queue.  The storage for 
  3387.            the event must have been allocated by the caller using Tcl_Alloc or 
  3388.            ckalloc. 
  3389.  
  3390.  Tcl_QueuePosition  position (in)  Where to add the new event in the queue: 
  3391.            TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, or TCL_QUEUE_MARK. 
  3392.  
  3393.  int  flags (in)  A copy of the flags argument passed to Tcl_DoOneEvent. 
  3394.  
  3395.  INTRODUCTION 
  3396.  
  3397.  The procedures described here are the building blocks out of which the Tcl 
  3398.  event notifier is constructed.  The event notifier is the lowest layer in the 
  3399.  Tcl event mechanism.  It consists of three things: 
  3400.  
  3401.    1. Event sources:  these represent the ways in which events can be 
  3402.       generated.  For example, there is a timer event source that implements 
  3403.       the Tcl_CreateTimerHandler procedure and the after command, and there is 
  3404.       a file event source that implements the Tcl_CreateFileHandler procedure. 
  3405.       An event source must work with the notifier to detect events at the right 
  3406.       times, record them on the event queue, and eventually notify higher-level 
  3407.       software that they have occurred. 
  3408.  
  3409.    2. The event queue:  there is a single queue for the whole application, 
  3410.       containing events that have been detected but not yet serviced. The event 
  3411.       queue guarantees a fair discipline of event handling, so that no event 
  3412.       source can starve the others.  It also allows events to be saved for 
  3413.       servicing at a future time. 
  3414.  
  3415.    3. The procedure Tcl_DoOneEvent:  this is procedure that is invoked by the 
  3416.       application to service events.  It works with the event sources and the 
  3417.       event queue to detect and handle events, and calls Tcl_WaitForEvent to 
  3418.       actually wait for an event to occur. 
  3419.  
  3420.  The easiest way to understand how the notifier works is to consider what 
  3421.  happens when Tcl_DoOneEvent is called. Tcl_DoOneEvent is passed a flags 
  3422.  argument that indicates what sort of events it is OK to process and also 
  3423.  whether or not to block if no events are ready. Tcl_DoOneEvent does the 
  3424.  following things: 
  3425.  
  3426.    1. Check the event queue to see if it contains any events that can be 
  3427.       serviced.  If so, service the first possible event, remove it from the 
  3428.       queue, and return. 
  3429.  
  3430.    2. Prepare to block for an event.  To do this, Tcl_DoOneEvent invokes a 
  3431.       setup procedure in each event source. The event source will call 
  3432.       procedures like Tcl_WatchFile and Tcl_SetMaxBlockTime to indicate what 
  3433.       low-level events to look for in Tcl_WaitForEvent. 
  3434.  
  3435.    3. Call Tcl_WaitForEvent.  This procedure is implemented differently on 
  3436.       different platforms;  it waits for an event to occur, based on the 
  3437.       information provided by the event sources. It may cause the application 
  3438.       to block if timePtr specifies an interval other than 0. Tcl_WaitForEvent 
  3439.       returns when something has happened, such as a file becoming readable or 
  3440.       the interval given by timePtr expiring.  If there are no events for 
  3441.       Tcl_WaitForEvent to wait for, so that it would block forever, then it 
  3442.       returns immediately and Tcl_DoOneEvent returns 0. 
  3443.  
  3444.    4. Call a check procedure in each event source.  The check procedure 
  3445.       determines whether any events of interest to this source occurred (e.g. 
  3446.       by calling Tcl_FileReady).  If so, the events are added to the event 
  3447.       queue. 
  3448.  
  3449.    5. Check the event queue to see if it contains any events that can be 
  3450.       serviced.  If so, service the first possible event, remove it from the 
  3451.       queue, and return. 
  3452.  
  3453.    6. See if there are idle callbacks pending. If so, invoke all of them and 
  3454.       return. 
  3455.  
  3456.    7. Either return 0 to indicate that no events were ready, or go back to step 
  3457.       [2] if blocking was requested by the caller. 
  3458.  
  3459.  The procedures in this file allow you to do two things.  First, they allow you 
  3460.  to create new event sources, such as one for UNIX signals or one to notify 
  3461.  when subprocesses have exited.  Second, the procedures can be used to build a 
  3462.  new version of Tcl_DoOneEvent.  This might be necessary to support a new 
  3463.  operating system with different low-level event reporting mechanisms, or it 
  3464.  might be necessary to merge Tcl's event loop with that of some other toolkit 
  3465.  like Xt. 
  3466.  
  3467.  CREATING A NEW EVENT SOURCE 
  3468.  
  3469.  An event source consists of three procedures invoked by the notifier, plus 
  3470.  additional C procedures that are invoked by higher-level code to arrange for 
  3471.  event-driven callbacks.  The three procedures called by the notifier consist 
  3472.  of the setup and check procedures described above, plus an additional 
  3473.  procedure that is invoked when an event is removed from the event queue for 
  3474.  servicing. 
  3475.  
  3476.  The procedure Tcl_CreateEventSource creates a new event source. Its arguments 
  3477.  specify the setup procedure and check procedure for the event source. 
  3478.  SetupProc should match the following prototype: 
  3479.  
  3480.   typedef void Tcl_EventSetupProc(
  3481.          ClientData clientData,
  3482.          int flags);
  3483.  The clientData argument will be the same as the clientData argument to 
  3484.  Tcl_CreateEventSource;  it is typically used to point to private information 
  3485.  managed by the event source. The flags argument will be the same as the flags 
  3486.  argument passed to Tcl_DoOneEvent except that it will never by 0 
  3487.  (Tcl_DoOneEvent replaces 0 with TCL_ALL_EVENTS). Flags indicates what kinds of 
  3488.  events should be considered; if the bit corresponding to this event source 
  3489.  isn't set, the event source should return immediately without doing anything. 
  3490.  For example, the file event source checks for the TCL_FILE_EVENTS bit. 
  3491.  
  3492.  SetupProc's job is to provide information to Tcl_WaitForEvent about how to 
  3493.  wait for events. It usually does this by calling Tcl_WatchFile or 
  3494.  Tcl_SetMaxBlockTime. For example, setupProc can call Tcl_WatchFile to indicate 
  3495.  that Tcl_WaitForEvent should return when the conditions given by the mask 
  3496.  argument become true for the file given by file. The UNIX version of 
  3497.  Tcl_WaitForEvent uses the information passed to Tcl_WatchFile to set the file 
  3498.  masks for select, which it uses to wait for events. If Tcl_WatchFile isn't 
  3499.  called by any event sources then Tcl_WaitForEvent will ignore files while 
  3500.  waiting. 
  3501.  
  3502.  SetupProc can also invoke Tcl_SetMaxBlockTime to set an upper bound on how 
  3503.  long Tcl_WaitForEvent will block. If no event source calls Tcl_SetMaxBlockTime 
  3504.  then Tcl_WaitForEvent will wait as long as necessary for an event to occur; 
  3505.  otherwise, it will only wait as long as the shortest interval passed to 
  3506.  Tcl_SetMaxBlockTime by one of the event sources. For example, the timer event 
  3507.  source uses this procedure to limit the wait time to the interval before the 
  3508.  next timer event is ready. If an event source knows that it already has events 
  3509.  ready to report, it can request a zero maximum block time. The timePtr 
  3510.  argument to Tcl_WaitForEvent points to a structure that describes a time 
  3511.  interval in seconds and microseconds: 
  3512.  
  3513.   typedef struct Tcl_Time {
  3514.          long sec;
  3515.          long usec;
  3516.   } Tcl_Time;
  3517.  The usec field should be less than 1000000. 
  3518.  
  3519.  Information provided to Tcl_WatchFile and Tcl_SetMaxBlockTime is only used for 
  3520.  the next call to Tcl_WaitForEvent; it is discarded after Tcl_WaitForEvent 
  3521.  returns. The next time an event wait is done each of the event sources' setup 
  3522.  procedures will be called again, and they can specify new information for that 
  3523.  event wait. 
  3524.  
  3525.  In addition to the generic procedures Tcl_WatchFile and Tcl_SetMaxBlockTime, 
  3526.  other platform-specific procedures may also be available for setupProc, if 
  3527.  there is additional information needed by Tcl_WaitForEvent on that platform. 
  3528.  
  3529.  The second procedure provided by each event source is its check procedure, 
  3530.  indicated by the checkProc argument to Tcl_CreateEventSource.  CheckProc must 
  3531.  match the following prototype: 
  3532.  
  3533.   typedef void Tcl_EventCheckProc(
  3534.          ClientData clientData,
  3535.          int flags);
  3536.  The arguments to this procedure are the same as those for setupProc. CheckProc 
  3537.  is invoked by Tcl_DoOneEvent after it has waited for events.  Presumably at 
  3538.  least one event source is now prepared to queue an event.  Tcl_DoOneEvent 
  3539.  calls each of the event sources in turn, so they all have a chance to queue 
  3540.  any events that are ready. The check procedure does two things.  First, it 
  3541.  must see if any events have triggered.  Different event sources do this in 
  3542.  different ways, but the procedure Tcl_FileReady may be useful for some event 
  3543.  sources.  It takes as arguments a file identifier file and a mask of 
  3544.  interesting conditions;  it returns another mask indicating which of those 
  3545.  conditions were found to be present on the file during the most recent call to 
  3546.  Tcl_WaitForEvent. Tcl_WaitForEvent only checks a file if Tcl_WatchFile was 
  3547.  called by at least one event source, so it is possible for Tcl_FileReady to 
  3548.  return 0 even if the file is ready. 
  3549.  
  3550.  If an event source's check procedure detects that an interesting event has 
  3551.  occurred, then it must add the event to Tcl's event queue. To do this, the 
  3552.  event source calls Tcl_QueueEvent. The evPtr argument is a pointer to a 
  3553.  dynamically allocated structure containing the event (see below for more 
  3554.  information on memory management issues). Each event source can define its own 
  3555.  event structure with whatever information is relevant to that event source. 
  3556.  However, the first element of the structure must be a structure of type 
  3557.  Tcl_Event, and the address of this structure is used when communicating 
  3558.  between the event source and the rest of the notifier. A Tcl_Event has the 
  3559.  following definition: 
  3560.  
  3561.   typedef struct Tcl_Event {
  3562.       Tcl_EventProc *proc;
  3563.       struct Tcl_Event *nextPtr;
  3564.   };
  3565.  The event source must fill in the proc field of the event before calling 
  3566.  Tcl_QueueEvent. The nextPtr is used to link together the events in the queue 
  3567.  and should not be modified by the event source. 
  3568.  
  3569.  An event may be added to the queue at any of three positions, depending on the 
  3570.  position argument to Tcl_QueueEvent: 
  3571.  
  3572.  TCL_QUEUE_TAIL Add the event at the back of the queue, so that all other 
  3573.            pending events will be serviced first.  This is almost always the 
  3574.            right place for new events. 
  3575.  
  3576.  TCL_QUEUE_HEAD Add the event at the front of the queue, so that it will be 
  3577.            serviced before all other queued events. 
  3578.  
  3579.  TCL_QUEUE_MARK Add the event at the front of the queue, unless there are other 
  3580.            events at the front whose position is TCL_QUEUE_MARK;  if so, add 
  3581.            the new event just after all other TCL_QUEUE_MARK events. This value 
  3582.            of position is used to insert an ordered sequence of events at the 
  3583.            front of the queue, such as a series of Enter and Leave events 
  3584.            synthesized during a grab or ungrab operation in Tk. 
  3585.  
  3586.  When it is time to handle an event from the queue (steps 1 and 5 above) 
  3587.  Tcl_DoOneEvent will invoke the proc specified in the first queued Tcl_Event 
  3588.  structure. Proc must match the following prototype: 
  3589.  
  3590.   typedef int Tcl_EventProc(
  3591.          Tcl_Event *evPtr,
  3592.          int flags);
  3593.  The first argument to proc is a pointer to the event, which will be the same 
  3594.  as the first argument to the Tcl_QueueEvent call that added the event to the 
  3595.  queue. The second argument to proc is the flags argument for the current call 
  3596.  to Tcl_DoOneEvent;  this is used by the event source to return immediately if 
  3597.  its events are not relevant. 
  3598.  
  3599.  It is up to proc to handle the event, typically by invoking one or more Tcl 
  3600.  commands or C-level callbacks. Once the event source has finished handling the 
  3601.  event it returns 1 to indicate that the event can be removed from the queue. 
  3602.  If for some reason the event source decides that the event cannot be handled 
  3603.  at this time, it may return 0 to indicate that the event should be deferred 
  3604.  for processing later;  in this case Tcl_DoOneEvent will go on to the next 
  3605.  event in the queue and attempt to service it. There are several reasons why an 
  3606.  event source might defer an event. One possibility is that events of this type 
  3607.  are excluded by the flags argument. For example, the file event source will 
  3608.  always return 0 if the TCL_FILE_EVENTS bit isn't set in flags. Another example 
  3609.  of deferring events happens in Tk if Tk_RestrictEvents has been invoked to 
  3610.  defer certain kinds of window events. 
  3611.  
  3612.  When proc returns 1, Tcl_DoOneEvent will remove the event from the event queue 
  3613.  and free its storage. Note that the storage for an event must be allocated by 
  3614.  the event source (using Tcl_Alloc or the Tcl macro ckalloc) before calling 
  3615.  Tcl_QueueEvent, but it will be freed by Tcl_DoOneEvent, not by the event 
  3616.  source. 
  3617.  
  3618.  CREATING A NEW NOTIFIER 
  3619.  
  3620.  The notifier consists of all the procedures described in this manual entry, 
  3621.  plus Tcl_DoOneEvent and Tcl_Sleep. Most of these procedures are generic, in 
  3622.  that they are the same for all platforms.  However, four of the procedures are 
  3623.  platform-dependent:  Tcl_WatchFile, Tcl_FileReady, Tcl_WaitForEvent, and 
  3624.  Tcl_Sleep. To support a new platform, you must write new versions of these 
  3625.  procedures. Tcl_WatchFile and Tcl_FileReady have already been described 
  3626.  previously in this document, and Tcl_Sleep is described in its own manual 
  3627.  entry. 
  3628.  
  3629.  Tcl_WaitForEvent is the lowest-level procedure in the notifier;  it is 
  3630.  responsible for waiting for an "interesting" event to occur or for a given 
  3631.  time to elapse. Before Tcl_WaitForEvent is invoked, each of the event sources' 
  3632.  setup procedure will have been invoked;  the setup procedures will have 
  3633.  provided information about what to wait for by invoking procedures like 
  3634.  Tcl_WatchFile. The timePtr argument to Tcl_WaitForEvent gives the maximum time 
  3635.  to block for an event, based on calls to Tcl_SetMaxBlockTime made by setup 
  3636.  procedures and on other information (such as the TCL_DONT_WAIT bit in flags). 
  3637.  Tcl_WaitForEvent uses information saved by Tcl_WatchFile, plus the timePtr 
  3638.  argument to decide what to wait for and how long to block. It returns TCL_OK 
  3639.  as soon as one of the specified events has occurred or the given amount of 
  3640.  time has elapsed. However, if there are no event handlers (neither 
  3641.  Tcl_WatchFile nor Tcl_SetMaxBlockTime has been called since the last call to 
  3642.  Tcl_WaitForEvent), so that the procedure would block forever, then it returns 
  3643.  immediately with a result of TCL_ERROR. 
  3644.  
  3645.  The easiest way to create a new notifier is to look at the code for an 
  3646.  existing notifier, such as the files generic/tclNotify.c and 
  3647.  unix/tclUnixNotfy.c. 
  3648.  
  3649.  KEYWORDS 
  3650.  
  3651.  block time, event notifier, event queue, event sources, file events 
  3652.  
  3653.  
  3654. ΓòÉΓòÉΓòÉ 2.39. Tcl_OpenFileChannel ΓòÉΓòÉΓòÉ
  3655.  
  3656.  NAME 
  3657.  
  3658. Tcl_OpenFileChannel, Tcl_OpenCommandChannel, Tcl_Close, Tcl_Read, Tcl_Gets, 
  3659. Tcl_Write, Tcl_Flush, Tcl_Seek, Tcl_Tell, Tcl_Eof, Tcl_InputBlocked, 
  3660. Tcl_GetChannelOption,  Tcl_SetChannelOption - buffered I/O facilities using 
  3661. channels 
  3662.  
  3663. SYNOPSIS 
  3664.  
  3665. #include <tcl.h> 
  3666.  
  3667.  typedef ... Tcl_Channel; 
  3668.  
  3669.  Tcl_Channel 
  3670.  Tcl_OpenFileChannel(interp, fileName, mode, permissions) 
  3671.  
  3672.  Tcl_Channel 
  3673.  Tcl_OpenCommandChannel(interp, argc, argv, flags) 
  3674.  
  3675.  Tcl_Channel 
  3676.  Tcl_MakeFileChannel(inOsFile, outOsFile, readOrWrite) 
  3677.  
  3678.  Tcl_Channel 
  3679.  Tcl_GetChannel(interp, channelName, modePtr) 
  3680.  
  3681.  void 
  3682.  Tcl_RegisterChannel(interp, channel) 
  3683.  
  3684.  int 
  3685.  Tcl_UnregisterChannel(interp, channel) 
  3686.  
  3687.  int 
  3688.  Tcl_Close(interp, channel) 
  3689.  
  3690.  int 
  3691.  Tcl_Read(channel, buf, toRead) 
  3692.  
  3693.  int 
  3694.  Tcl_Gets(channel, lineRead) 
  3695.  
  3696.  int 
  3697.  Tcl_Write(channel, buf, toWrite) 
  3698.  
  3699.  int 
  3700.  Tcl_Flush(channel) 
  3701.  
  3702.  int 
  3703.  Tcl_Seek(channel, offset, seekMode) 
  3704.  
  3705.  int 
  3706.  Tcl_Tell(channel) 
  3707.  
  3708.  int 
  3709.  Tcl_GetChannelOption(channel, optionName, optionValue) 
  3710.  
  3711.  int 
  3712.  Tcl_SetChannelOption(interp, channel, optionName, newValue) 
  3713.  
  3714.  int 
  3715.  Tcl_Eof(channel) 
  3716.  
  3717.  int 
  3718.  Tcl_InputBlocked(channel) 
  3719.  
  3720.  int 
  3721.  Tcl_InputBuffered(channel) 
  3722.  
  3723. ARGUMENTS 
  3724.  
  3725.  Tcl_Interp  *interp (in)  Used for error reporting and to look up a channel 
  3726.            registered in it. 
  3727.  
  3728.  char  *fileName (in)  The name of a local or network file. 
  3729.  
  3730.  char  *mode (in)  Specifies how the file is to be accessed.  May have any of 
  3731.            the values allowed for the mode argument to the Tcl open command. 
  3732.            For Tcl_OpenCommandChannel, may be NULL. 
  3733.  
  3734.  int  permissions (in)  POSIX-style permission flags such as 0644. If a new 
  3735.            file is created, these permissions will be set on the created file. 
  3736.  
  3737.  int  argc (in)  The number of elements in argv. 
  3738.  
  3739.  char  **argv (in)  Arguments for constructing a command pipeline. These values 
  3740.            have the same meaning as the non-switch arguments to the Tcl exec 
  3741.            command. 
  3742.  
  3743.  int  flags (in)  Specifies the disposition of the stdio handles in pipeline: 
  3744.            OR-ed combination of TCL_STDIN, TCL_STDOUT, TCL_STDERR, and 
  3745.            TCL_ENFORCE_MODE. If TCL_STDIN is set, stdin for the first child in 
  3746.            the pipe is the pipe channel, otherwise it is the same as the 
  3747.            standard input of the invoking process; likewise for TCL_STDOUT and 
  3748.            TCL_STDERR. If TCL_ENFORCE_MODE is not set, then the pipe can 
  3749.            redirect stdio handles to override the stdio handles for which 
  3750.            TCL_STDIN, TCL_STDOUT and TCL_STDERR have been set. If it is set, 
  3751.            then such redirections cause an error. 
  3752.  
  3753.  ClientData  inOsFile (in)  Operating system specific handle for input from a 
  3754.            file. For Unix this is a file descriptor, for Windows it is a 
  3755.            HANDLE, etc. 
  3756.  
  3757.  ClientData  outOsFile (in)  Operating system specific handle for output to a 
  3758.            file. 
  3759.  
  3760.  int  readOrWrite (in)  OR-ed combination of TCL_READABLE and TCL_WRITABLE to 
  3761.            indicate which of inOsFile and outOsFile contains a valid value. 
  3762.  
  3763.  int  *modePtr (out)  Points at an integer variable that will receive an OR-ed 
  3764.            combination of TCL_READABLE and TCL_WRITABLE denoting whether the 
  3765.            channel is open for reading and writing. 
  3766.  
  3767.  Tcl_Channel  channel (in)  A Tcl channel for input or output.  Must have been 
  3768.            the return value from a procedure such as Tcl_OpenFileChannel. 
  3769.  
  3770.  char  *buf (in)  An array of bytes in which to store channel input, or from 
  3771.            which to read channel output. 
  3772.  
  3773.  int  len (in)  The length of the input or output. 
  3774.  
  3775.  int  atEnd (in)  If nonzero, store the input at the end of the input queue, 
  3776.            otherwise store it at the head of the input queue. 
  3777.  
  3778.  int  toRead (in)  The number of bytes to read from the channel. 
  3779.  
  3780.  Tcl_DString  *lineRead (in)  A pointer to a Tcl dynamic string in which to 
  3781.            store the line read from the channel.  Must have been initialized by 
  3782.            the caller. 
  3783.  
  3784.  int  toWrite (in)  The number of bytes to read from buf and output to the 
  3785.            channel. 
  3786.  
  3787.  int  offset (in)  How far to move the access point in the channel at which the 
  3788.            next input or output operation will be applied, measured in bytes 
  3789.            from the position given by seekMode.  May be either positive or 
  3790.            negative. 
  3791.  
  3792.  int  seekMode (in)  Relative to which point to seek; used with offset to 
  3793.            calculate the new access point for the channel. Legal values are 
  3794.            SEEK_SET, SEEK_CUR, and SEEK_END. 
  3795.  
  3796.  char  *optionName (in)  The name of an option applicable to this channel, such 
  3797.            as -blocking. May have any of the values accepted by the fconfigure 
  3798.            command. 
  3799.  
  3800.  Tcl_DString  *optionValue (in)  Where to store the value of an option or a 
  3801.            list of all options and their values. Must have been initialized by 
  3802.            the caller. 
  3803.  
  3804.  char  *newValue (in)  New value for the option given by optionName. 
  3805.  
  3806.  DESCRIPTION 
  3807.  
  3808.  The Tcl channel mechanism provides a device-independent and 
  3809.  platform-independent mechanism for performing buffered input and output 
  3810.  operations on a variety of file, socket, and device types. The channel 
  3811.  mechanism is extensible to new channel types, by providing a low level channel 
  3812.  driver for the new type; the channel driver interface is described in the 
  3813.  manual entry for Tcl_CreateChannel. The channel mechanism provides a buffering 
  3814.  scheme modelled after Unix's standard I/O, and it also allows for nonblocking 
  3815.  I/O on channels. 
  3816.  
  3817.  The procedures described in this manual entry comprise the C APIs of the 
  3818.  generic layer of the channel architecture. For a description of the channel 
  3819.  driver architecture and how to implement channel drivers for new types of 
  3820.  channels, see the manual entry for Tcl_CreateChannel. 
  3821.  
  3822.  TCL_OPENFILECHANNEL 
  3823.  
  3824.  Tcl_OpenFileChannel opens a file specified by fileName and returns a channel 
  3825.  handle that can be used to perform input and output on the file. This API is 
  3826.  modelled after the fopen procedure of the Unix standard I/O library. The 
  3827.  syntax and meaning of all arguments is similar to those given in the Tcl open 
  3828.  command when opening a file. If an error occurs while opening the channel, 
  3829.  Tcl_OpenFileChannel returns NULL and records a POSIX error code that can be 
  3830.  retrieved with Tcl_GetErrno. In addition, if interp is non-NULL, 
  3831.  Tcl_OpenFileChannel leaves an error message in interp->result after any error. 
  3832.  
  3833.  The newly created channel is not registered in the supplied interpreter; to 
  3834.  register it, use Tcl_RegisterChannel, described below. If one of the standard 
  3835.  channels, stdin, stdout or stderr was previously closed, the act of creating 
  3836.  the new channel also assigns it as a replacement for the standard channel. 
  3837.  
  3838.  TCL_OPENCOMMANDCHANNEL 
  3839.  
  3840.  Tcl_OpenCommandChannel provides a C-level interface to the functions of the 
  3841.  exec and open commands. It creates a sequence of subprocesses specified by the 
  3842.  argv and argc arguments and returns a channel that can be used to communicate 
  3843.  with these subprocesses. The flags argument indicates what sort of 
  3844.  communication will exist with the command pipeline. 
  3845.  
  3846.  If the TCL_STDIN flag is set then the standard input for the first subprocess 
  3847.  will be tied to the channel: writing to the channel will provide input to the 
  3848.  subprocess.  If TCL_STDIN is not set, then standard input for the first 
  3849.  subprocess will be the same as this application's standard input.  If 
  3850.  TCL_STDOUT is set then standard output from the last subprocess can be read 
  3851.  from the channel; otherwise it goes to this application's standard output.  If 
  3852.  TCL_STDERR is set, standard error output for all subprocesses is returned to 
  3853.  the channel and results in an error when the channel is closed; otherwise it 
  3854.  goes to this application's standard error.  If TCL_ENFORCE_MODE is not set, 
  3855.  then argc and argv can redirect the stdio handles to override TCL_STDIN, 
  3856.  TCL_STDOUT, and TCL_STDERR; if it is set, then it is an error for argc and 
  3857.  argv to override stdio channels for which TCL_STDIN, TCL_STDOUT, and 
  3858.  TCL_STDERR have been set. 
  3859.  
  3860.  If an error occurs while opening the channel, Tcl_OpenCommandChannel returns 
  3861.  NULL and records a POSIX error code that can be retrieved with Tcl_GetErrno. 
  3862.  In addition, Tcl_OpenCommandChannel leaves an error message in interp->result 
  3863.  if interp is not NULL. 
  3864.  
  3865.  The newly created channel is not registered in the supplied interpreter; to 
  3866.  register it, use Tcl_RegisterChannel, described below. If one of the standard 
  3867.  channels, stdin, stdout or stderr was previously closed, the act of creating 
  3868.  the new channel also assigns it as a replacement for the standard channel. 
  3869.  
  3870.  TCL_MAKEFILECHANNEL 
  3871.  
  3872.  Tcl_MakeFileChannel makes a Tcl_Channel from an existing, platform-specific, 
  3873.  file handle. The newly created channel is not registered in the supplied 
  3874.  interpreter; to register it, use Tcl_RegisterChannel, described below. If one 
  3875.  of the standard channels, stdin, stdout or stderr was previously closed, the 
  3876.  act of creating the new channel also assigns it as a replacement for the 
  3877.  standard channel. 
  3878.  
  3879.  TCL_GETCHANNEL 
  3880.  
  3881.  Tcl_GetChannel returns a channel given the channelName used to create it with 
  3882.  Tcl_CreateChannel and a pointer to a Tcl interpreter in interp. If a channel 
  3883.  by that name is not registered in that interpreter, the procedure returns 
  3884.  NULL. If the mode argument is not NULL, it points at an integer variable that 
  3885.  will receive an OR-ed combination of TCL_READABLE and TCL_WRITABLE describing 
  3886.  whether the channel is open for reading and writing. 
  3887.  
  3888.  TCL_REGISTERCHANNEL 
  3889.  
  3890.  Tcl_RegisterChannel adds a channel to the set of channels accessible in 
  3891.  interp. After this call, Tcl programs executing in that interpreter can refer 
  3892.  to the channel in input or output operations using the name given in the call 
  3893.  to Tcl_CreateChannel.  After this call, the channel becomes the property of 
  3894.  the interpreter, and the caller should not call Tcl_Close for the channel; the 
  3895.  channel will be closed automatically when it is unregistered from the 
  3896.  interpreter. 
  3897.  
  3898.  Code executing outside of any Tcl interpreter can call Tcl_RegisterChannel 
  3899.  with interp as NULL, to indicate that it wishes to hold a reference to this 
  3900.  channel. Subsequently, the channel can be registered in a Tcl interpreter and 
  3901.  it will only be closed when the matching number of calls to 
  3902.  Tcl_UnregisterChannel have been made. This allows code executing outside of 
  3903.  any interpreter to safely hold a reference to a channel that is also 
  3904.  registered in a Tcl interpreter. 
  3905.  
  3906.  TCL_UNREGISTERCHANNEL 
  3907.  
  3908.  Tcl_UnregisterChannel removes a channel from the set of channels accessible in 
  3909.  interp. After this call, Tcl programs will no longer be able to use the 
  3910.  channel's name to refer to the channel in that interpreter. If this operation 
  3911.  removed the last registration of the channel in any interpreter, the channel 
  3912.  is also closed and destroyed. 
  3913.  
  3914.  Code not associated with a Tcl interpreter can call Tcl_UnregisterChannel with 
  3915.  interp as NULL, to indicate to Tcl that it no longer holds a reference to that 
  3916.  channel. If this is the last reference to the channel, it will now be closed. 
  3917.  
  3918.  TCL_CLOSE 
  3919.  
  3920.  Tcl_Close destroys the channel channel, which must denote a currently open 
  3921.  channel. The channel should not be registered in any interpreter when 
  3922.  Tcl_Close is called. Buffered output is flushed to the channel's output device 
  3923.  prior to destroying the channel, and any buffered input is discarded.  If this 
  3924.  is a blocking channel, the call does not return until all buffered data is 
  3925.  successfully sent to the channel's output device.  If this is a nonblocking 
  3926.  channel and there is buffered output that cannot be written without blocking, 
  3927.  the call returns immediately; output is flushed in the background and the 
  3928.  channel will be closed once all of the buffered data has been output.  In this 
  3929.  case errors during flushing are not reported. 
  3930.  
  3931.  If the channel was closed successfully, Tcl_Close returns TCL_OK. If an error 
  3932.  occurs, Tcl_Close returns TCL_ERROR and records a POSIX error code that can be 
  3933.  retrieved with Tcl_GetErrno. If the channel is being closed synchronously and 
  3934.  an error occurs during closing of the channel and interp is not NULL, an error 
  3935.  message is left in interp->result. 
  3936.  
  3937.  Note: it is not safe to call Tcl_Close on a channel that has been registered 
  3938.  using Tcl_RegisterChannel; see the documentation for Tcl_RegisterChannel, 
  3939.  above, for details. If the channel has ever been given as the chan argument in 
  3940.  a call to Tcl_RegisterChannel, you should instead use Tcl_UnregisterChannel, 
  3941.  which will internally call Tcl_Close when all calls to Tcl_RegisterChannel 
  3942.  have been matched by corresponding calls to Tcl_UnregisterChannel. 
  3943.  
  3944.  TCL_READ 
  3945.  
  3946.  Tcl_Read consumes up to toRead bytes of data from channel and stores it at 
  3947.  buf. The return value of Tcl_Read is the number of characters written at buf. 
  3948.  The buffer produced by Tcl_Read is not NULL terminated. Its contents are valid 
  3949.  from the zeroth position up to and excluding the position indicated by the 
  3950.  return value. If an error occurs, the return value is -1 and Tcl_Read records 
  3951.  a POSIX error code that can be retrieved with Tcl_GetErrno. 
  3952.  
  3953.  The return value may be smaller than the value of toRead, indicating that less 
  3954.  data than requested was available, also called a short read. In blocking mode, 
  3955.  this can only happen on an end-of-file. In nonblocking mode, a short read can 
  3956.  also occur if there is not enough input currently available:  Tcl_Read returns 
  3957.  a short count rather than waiting for more data. 
  3958.  
  3959.  If the channel is in blocking mode, a return value of zero indicates an end of 
  3960.  file condition. If the channel is in nonblocking mode, a return value of zero 
  3961.  indicates either that no input is currently available or an end of file 
  3962.  condition. Use Tcl_Eof and Tcl_InputBlocked to tell which of these conditions 
  3963.  actually occurred. 
  3964.  
  3965.  Tcl_Read translates platform-specific end-of-line representations into the 
  3966.  canonical \n internal representation according to the current end-of-line 
  3967.  recognition mode. End-of-line recognition and the various platform-specific 
  3968.  modes are described in the manual entry for the Tcl fconfigure command. 
  3969.  
  3970.  TCL_GETS 
  3971.  
  3972.  Tcl_Gets reads a line of input from a channel and appends all of the 
  3973.  characters of the line except for the terminating end-of-line character(s) to 
  3974.  the dynamic string given by dsPtr. The end-of-line character(s) are read and 
  3975.  discarded. 
  3976.  
  3977.  If a line was successfully read, the return value is greater than or equal to 
  3978.  zero, and it indicates the number of characters stored in the dynamic string. 
  3979.  If an error occurs, Tcl_Gets returns -1 and records a POSIX error code that 
  3980.  can be retrieved with Tcl_GetErrno. Tcl_Gets also returns -1 if the end of the 
  3981.  file is reached; the Tcl_Eof procedure can be used to distinguish an error 
  3982.  from an end-of-file condition. 
  3983.  
  3984.  If the channel is in nonblocking mode, the return value can also be -1 if no 
  3985.  data was available or the data that was available did not contain an 
  3986.  end-of-line character. When -1 is returned, the Tcl_InputBlocked procedure may 
  3987.  be invoked to determine if the channel is blocked because of input 
  3988.  unavailability. 
  3989.  
  3990.  TCL_WRITE 
  3991.  
  3992.  Tcl_Write accepts toWrite bytes of data at buf for output on channel. This 
  3993.  data may not appear on the output device immediately. If the data should 
  3994.  appear immediately, call Tcl_Flush after the call to Tcl_Write, or set the 
  3995.  -buffering option on the channel to none. If you wish the data to appear as 
  3996.  soon as an end of line is accepted for output, set the -buffering option on 
  3997.  the channel to line mode. 
  3998.  
  3999.  The toWrite argument specifies how many bytes of data are provided in the buf 
  4000.  argument. If it is negative, Tcl_Write expects the data to be NULL terminated 
  4001.  and it outputs everything up to the NULL. 
  4002.  
  4003.  The return value of Tcl_Write is a count of how many characters were accepted 
  4004.  for output to the channel. This is either equal to toWrite or -1 to indicate 
  4005.  that an error occurred. If an error occurs, Tcl_Write also records a POSIX 
  4006.  error code that may be retrieved with Tcl_GetErrno. 
  4007.  
  4008.  Newline characters in the output data are translated to platform-specific 
  4009.  end-of-line sequences according to the -translation option for the channel. 
  4010.  
  4011.  TCL_FLUSH 
  4012.  
  4013.  Tcl_Flush causes all of the buffered output data for channel to be written to 
  4014.  its underlying file or device as soon as possible. If the channel is in 
  4015.  blocking mode, the call does not return until all the buffered data has been 
  4016.  sent to the channel or some error occurred. The call returns immediately if 
  4017.  the channel is nonblocking; it starts a background flush that will write the 
  4018.  buffered data to the channel eventually, as fast as the channel is able to 
  4019.  absorb it. 
  4020.  
  4021.  The return value is normally TCL_OK. If an error occurs, Tcl_Flush returns 
  4022.  TCL_ERROR and records a POSIX error code that can be retrieved with 
  4023.  Tcl_GetErrno. 
  4024.  
  4025.  TCL_SEEK 
  4026.  
  4027.  Tcl_Seek moves the access point in channel where subsequent data will be read 
  4028.  or written. Buffered output is flushed to the channel and buffered input is 
  4029.  discarded, prior to the seek operation. 
  4030.  
  4031.  Tcl_Seek normally returns the new access point. If an error occurs, Tcl_Seek 
  4032.  returns -1 and records a POSIX error code that can be retrieved with 
  4033.  Tcl_GetErrno. After an error, the access point may or may not have been moved. 
  4034.  
  4035.  TCL_TELL 
  4036.  
  4037.  Tcl_Tell returns the current access point for a channel. The returned value is 
  4038.  -1 if the channel does not support seeking. 
  4039.  
  4040.  TCL_GETCHANNELOPTION 
  4041.  
  4042.  Tcl_GetChannelOption retrieves, in dsPtr, the value of one of the options 
  4043.  currently in effect for a channel, or a list of all options and their values. 
  4044.  The channel argument identifies the channel for which to query an option or 
  4045.  retrieve all options and their values. If optionName is not NULL, it is the 
  4046.  name of the option to query; the option's value is copied to the Tcl dynamic 
  4047.  string denoted by optionValue. If optionName is NULL, the function stores an 
  4048.  alternating list of option names and their values in optionValue, using a 
  4049.  series of calls to Tcl_DStringAppendElement. The various preexisting options 
  4050.  and their possible values are described in the manual entry for the Tcl 
  4051.  fconfigure command. Other options can be added by each channel type. These 
  4052.  channel type specific options are described in the manual entry for the Tcl 
  4053.  command that creates a channel of that type; for example, the additional 
  4054.  options for TCP based channels are described in the manual entry for the Tcl 
  4055.  socket command. The procedure normally returns TCL_OK. If an error occurs, it 
  4056.  returns TCL_ERROR and calls Tcl_SetErrno to store an appropriate POSIX error 
  4057.  code. 
  4058.  
  4059.  TCL_SETCHANNELOPTION 
  4060.  
  4061.  Tcl_SetChannelOption sets a new value for an option on channel. OptionName is 
  4062.  the option to set and newValue is the value to set. The procedure normally 
  4063.  returns TCL_OK.  If an error occurs, it returns TCL_ERROR;  in addition, if 
  4064.  interp is non-NULL, Tcl_SetChannelOption leaves an error message in 
  4065.  interp->result. 
  4066.  
  4067.  TCL_EOF 
  4068.  
  4069.  Tcl_Eof returns a nonzero value if channel encountered an end of file during 
  4070.  the last input operation. 
  4071.  
  4072.  TCL_INPUTBLOCKED 
  4073.  
  4074.  Tcl_InputBlocked returns a nonzero value if channel is in nonblocking mode and 
  4075.  the last input operation returned less data than requested because there was 
  4076.  insufficient data available. The call always returns zero if the channel is in 
  4077.  blocking mode. 
  4078.  
  4079.  TCL_INPUTBUFFERED 
  4080.  
  4081.  Tcl_InputBuffered returns the number of bytes of input currently buffered in 
  4082.  the internal buffers for a channel. If the channel is not open for reading, 
  4083.  this function always returns zero. 
  4084.  
  4085.  SEE ALSO 
  4086.  
  4087.  DString(3), fconfigure(n), filename(n), fopen(2), Tcl_CreateChannel(3) 
  4088.  
  4089.  KEYWORDS 
  4090.  
  4091.  access point, blocking, buffered I/O, channel, channel driver, end of file, 
  4092.  flush, input, nonblocking, output, read, seek, write 
  4093.  
  4094.  
  4095. ΓòÉΓòÉΓòÉ 2.40. Tcl_OpenTcpClient ΓòÉΓòÉΓòÉ
  4096.  
  4097.  NAME 
  4098.  
  4099. Tcl_OpenTcpClient, Tcl_OpenTcpServer - procedures to open channels using TCP 
  4100. sockets 
  4101.  
  4102. SYNOPSIS 
  4103.  
  4104. #include <tcl.h> 
  4105.  
  4106.  Tcl_Channel 
  4107.  Tcl_OpenTcpClient(interp, port, host, myaddr, myport, async) 
  4108.  
  4109.  Tcl_Channel 
  4110.  Tcl_MakeTcpClientChannel(sock) 
  4111.  
  4112.  Tcl_Channel 
  4113.  Tcl_OpenTcpServer(interp, port, myaddr, proc, clientData) 
  4114.  
  4115. ARGUMENTS 
  4116.  
  4117.  Tcl_Interp  *interp (in)  Tcl interpreter to use for error reporting.  If 
  4118.            non-NULL and an error occurs, an error message is left in 
  4119.            interp->result. 
  4120.  
  4121.  int  port (in)  A port number to connect to as a client or to listen on as a 
  4122.            server. 
  4123.  
  4124.  char  *host (in)  A string specifying a host name or address for the remote 
  4125.            end of the connection. 
  4126.  
  4127.  int  myport (in)  A port number for the client's end of the socket.  If 0, a 
  4128.            port number is allocated at random. 
  4129.  
  4130.  char  *myaddr (in)  A string specifying the host name or address for network 
  4131.            interface to use for the local end of the connection.  If NULL, a 
  4132.            default interface is chosen. 
  4133.  
  4134.  int  async (in)  If nonzero, the client socket is connected asynchronously to 
  4135.            the server. 
  4136.  
  4137.  ClientData  sock (in)  Platform-specific handle for client TCP socket. 
  4138.  
  4139.  Tcl_TcpAcceptProc  *proc (in)  Pointer to a procedure to invoke each time a 
  4140.            new connection is accepted via the socket. 
  4141.  
  4142.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  4143.  
  4144.  DESCRIPTION 
  4145.  
  4146.  These functions are convenience procedures for creating channels that 
  4147.  communicate over TCP sockets. The operations on a channel are described in the 
  4148.  manual entry for Tcl_OpenFileChannel. 
  4149.  
  4150.  TCL_OPENTCPCLIENT 
  4151.  
  4152.  Tcl_OpenTcpClient opens a client TCP socket connected to a port on a specific 
  4153.  host, and returns a channel that can be used to communicate with the server. 
  4154.  The host to connect to can be specified either as a domain name style name 
  4155.  (e.g. www.sunlabs.com), or as a string containing the alphanumeric 
  4156.  representation of its four-byte address (e.g. 127.0.0.1). Use the string 
  4157.  localhost to connect to a TCP socket on the host on which the function is 
  4158.  invoked. 
  4159.  
  4160.  The myaddr and myport arguments allow a client to specify an address for the 
  4161.  local end of the connection.  If myaddr is NULL, then an interface is chosen 
  4162.  automatically by the operating system. If myport is 0, then a port number is 
  4163.  chosen at random by the operating system. 
  4164.  
  4165.  If async is zero, the call to Tcl_OpenTcpClient returns only after the client 
  4166.  socket has either successfully connected to the server, or the attempted 
  4167.  connection has failed. If async is nonzero the socket is connected 
  4168.  asynchronously and the returned channel may not yet be connected to the server 
  4169.  when the call to Tcl_OpenTcpClient returns. If the channel is in blocking mode 
  4170.  and an input or output operation is done on the channel before the connection 
  4171.  is completed or fails, that operation will wait until the connection either 
  4172.  completes successfully or fails. If the channel is in nonblocking mode, the 
  4173.  input or output operation will return immediately and a subsequent call to 
  4174.  Tcl_InputBlocked on the channel will return nonzero. 
  4175.  
  4176.  The returned channel is opened for reading and writing. If an error occurs in 
  4177.  opening the socket, Tcl_OpenTcpClient returns NULL and records a POSIX error 
  4178.  code that can be retrieved with Tcl_GetErrno. In addition, if interp is 
  4179.  non-NULL, an error message is left in interp->result. 
  4180.  
  4181.  The newly created channel is not registered in the supplied interpreter; to 
  4182.  register it, use Tcl_RegisterChannel. If one of the standard channels, stdin, 
  4183.  stdout or stderr was previously closed, the act of creating the new channel 
  4184.  also assigns it as a replacement for the standard channel. 
  4185.  
  4186.  TCL_MAKETCPCLIENTCHANNEL 
  4187.  
  4188.  Tcl_MakeTcpClientChannel creates a Tcl_Channel around an existing, platform 
  4189.  specific, handle for a client TCP socket. 
  4190.  
  4191.  The newly created channel is not registered in the supplied interpreter; to 
  4192.  register it, use Tcl_RegisterChannel. If one of the standard channels, stdin, 
  4193.  stdout or stderr was previously closed, the act of creating the new channel 
  4194.  also assigns it as a replacement for the standard channel. 
  4195.  
  4196.  TCL_OPENTCPSERVER 
  4197.  
  4198.  Tcl_OpenTcpServer opens a TCP socket on the local host on a specified port and 
  4199.  uses the Tcl event mechanism to accept requests from clients to connect to it. 
  4200.  The myaddr argument specifies the network interface. If myaddr is NULL the 
  4201.  special address INADDR_ANY should be used to allow connections from any 
  4202.  network interface. Each time a client connects to this socket, Tcl creates a 
  4203.  channel for the new connection and invokes proc with information about the 
  4204.  channel.  Proc must match the following prototype: 
  4205.  
  4206.   typedef void Tcl_TcpAcceptProc(
  4207.          ClientData clientData,
  4208.          Tcl_Channel channel,
  4209.          char *hostName,
  4210.          int port);
  4211.  
  4212.  The clientData argument will be the same as the clientData argument to 
  4213.  Tcl_OpenTcpServer, channel will be the handle for the new channel, hostName 
  4214.  points to a string containing the name of the client host making the 
  4215.  connection, and port will contain the client's port number. The new channel is 
  4216.  opened for both input and output. If proc raises an error, the connection is 
  4217.  closed automatically. Proc has no return value, but if it wishes to reject the 
  4218.  connection it can close channel. 
  4219.  
  4220.  Tcl_OpenTcpServer normally returns a pointer to a channel representing the 
  4221.  server socket. If an error occurs, Tcl_OpenTcpServer returns NULL and records 
  4222.  a POSIX error code that can be retrieved with Tcl_GetErrno. In addition, if 
  4223.  interp->result is non-NULL, an error message is left in interp->result. 
  4224.  
  4225.  The channel returned by Tcl_OpenTcpServer cannot be used for either input or 
  4226.  output. It is simply a handle for the socket used to accept connections. The 
  4227.  caller can close the channel to shut down the server and disallow further 
  4228.  connections from new clients. 
  4229.  
  4230.  TCP server channels operate correctly only in applications that dispatch 
  4231.  events through Tcl_DoOneEvent or through Tcl commands such as vwait; otherwise 
  4232.  Tcl will never notice that a connection request from a remote client is 
  4233.  pending. 
  4234.  
  4235.  The newly created channel is not registered in the supplied interpreter; to 
  4236.  register it, use Tcl_RegisterChannel. If one of the standard channels, stdin, 
  4237.  stdout or stderr was previously closed, the act of creating the new channel 
  4238.  also assigns it as a replacement for the standard channel. 
  4239.  
  4240.  SEE ALSO 
  4241.  
  4242.  Tcl_OpenFileChannel(3), Tcl_RegisterChannel(3), vwait(n) 
  4243.  
  4244.  KEYWORDS 
  4245.  
  4246.  client, server, TCP 
  4247.  
  4248.  
  4249. ΓòÉΓòÉΓòÉ 2.41. Tcl_PkgRequire ΓòÉΓòÉΓòÉ
  4250.  
  4251.  NAME 
  4252.  
  4253. Tcl_PkgRequire, Tcl_PkgProvide - package version control 
  4254.  
  4255. SYNOPSIS 
  4256.  
  4257. #include <tcl.h> 
  4258.  
  4259.  char * 
  4260.  Tcl_PkgRequire(interp, name, version, exact) 
  4261.  
  4262.  int 
  4263.  Tcl_PkgProvide(interp, name, version) 
  4264.  
  4265. ARGUMENTS 
  4266.  
  4267.  Tcl_Interp  *interp (in)  Interpreter where package is needed or available. 
  4268.  
  4269.  char  *name (in)  Name of package. 
  4270.  
  4271.  char  *version (in)  A version string consisting of one or more decimal 
  4272.            numbers separated by dots. 
  4273.  
  4274.  int  exact (in)  Non-zero means that only the particular version specified by 
  4275.            version is acceptable. Zero means that newer versions than version 
  4276.            are also acceptable as long as they have the same major version 
  4277.            number as version. 
  4278.  
  4279.  DESCRIPTION 
  4280.  
  4281.  These procedures provide C-level interfaces to Tcl's package and version 
  4282.  management facilities. Tcl_PkgRequire is equivalent to the package require 
  4283.  command, and Tcl_PkgProvide is equivalent to the package provide command. See 
  4284.  the documentation for the Tcl commands for details on what these procedures 
  4285.  do. If Tcl_PkgRequire completes successfully it returns a pointer to the 
  4286.  version string for the version of the package that is provided in the 
  4287.  interpreter (which may be different than version); if an error occurs it 
  4288.  returns NULL and leaves an error message in interp->result. Tcl_PkgProvide 
  4289.  returns TCL_OK if it completes successfully; if an error occurs it returns 
  4290.  TCL_ERROR and leaves an error message in interp->result. 
  4291.  
  4292.  KEYWORDS 
  4293.  
  4294.  package, provide, require, version 
  4295.  
  4296.  
  4297. ΓòÉΓòÉΓòÉ 2.42. Tcl_Preserve ΓòÉΓòÉΓòÉ
  4298.  
  4299.  NAME 
  4300.  
  4301. Tcl_Preserve, Tcl_Release, Tcl_EventuallyFree - avoid freeing storage while 
  4302. it's being used 
  4303.  
  4304. SYNOPSIS 
  4305.  
  4306. #include <tcl.h> 
  4307.  
  4308.  Tcl_Preserve(clientData) 
  4309.  
  4310.  Tcl_Release(clientData) 
  4311.  
  4312.  Tcl_EventuallyFree(clientData, freeProc) 
  4313.  
  4314. ARGUMENTS 
  4315.  
  4316.  ClientData  clientData (in)  Token describing structure to be freed or 
  4317.            reallocated.  Usually a pointer to memory for structure. 
  4318.  
  4319.  Tcl_FreeProc  *freeProc (in)  Procedure to invoke to free clientData. 
  4320.  
  4321.  DESCRIPTION 
  4322.  
  4323.  These three procedures help implement a simple reference count mechanism for 
  4324.  managing storage.  They are designed to solve a problem having to do with 
  4325.  widget deletion, but are also useful in many other situations.  When a widget 
  4326.  is deleted, its widget record (the structure holding information specific to 
  4327.  the widget) must be returned to the storage allocator. However, it's possible 
  4328.  that the widget record is in active use by one of the procedures on the stack 
  4329.  at the time of the deletion. This can happen, for example, if the command 
  4330.  associated with a button widget causes the button to be destroyed:  an X event 
  4331.  causes an event-handling C procedure in the button to be invoked, which in 
  4332.  turn causes the button's associated Tcl command to be executed, which in turn 
  4333.  causes the button to be deleted, which in turn causes the button's widget 
  4334.  record to be de-allocated. Unfortunately, when the Tcl command returns, the 
  4335.  button's event-handling procedure will need to reference the button's widget 
  4336.  record. Because of this, the widget record must not be freed as part of the 
  4337.  deletion, but must be retained until the event-handling procedure has finished 
  4338.  with it. In other situations where the widget is deleted, it may be possible 
  4339.  to free the widget record immediately. 
  4340.  
  4341.  Tcl_Preserve and Tcl_Release implement short-term reference counts for their 
  4342.  clientData argument. The clientData argument identifies an object and usually 
  4343.  consists of the address of a structure. The reference counts guarantee that an 
  4344.  object will not be freed until each call to Tcl_Preserve for the object has 
  4345.  been matched by calls to Tcl_Release. There may be any number of unmatched 
  4346.  Tcl_Preserve calls in effect at once. 
  4347.  
  4348.  Tcl_EventuallyFree is invoked to free up its clientData argument. It checks to 
  4349.  see if there are unmatched Tcl_Preserve calls for the object. If not, then 
  4350.  Tcl_EventuallyFree calls freeProc immediately. Otherwise Tcl_EventuallyFree 
  4351.  records the fact that clientData needs eventually to be freed. When all calls 
  4352.  to Tcl_Preserve have been matched with calls to Tcl_Release then freeProc will 
  4353.  be called by Tcl_Release to do the cleanup. 
  4354.  
  4355.  All the work of freeing the object is carried out by freeProc. FreeProc must 
  4356.  have arguments and result that match the type Tcl_FreeProc: 
  4357.  
  4358.   typedef void Tcl_FreeProc(char *blockPtr);
  4359.  The blockPtr argument to freeProc will be the same as the clientData argument 
  4360.  to Tcl_EventuallyFree. The type of blockPtr (char *) is different than the 
  4361.  type of the clientData argument to Tcl_EventuallyFree for historical reasons, 
  4362.  but the value is the same. 
  4363.  
  4364.  This mechanism can be used to solve the problem described above by placing 
  4365.  Tcl_Preserve and Tcl_Release calls around actions that may cause undesired 
  4366.  storage re-allocation.  The mechanism is intended only for short-term use 
  4367.  (i.e. while procedures are pending on the stack);  it will not work 
  4368.  efficiently as a mechanism for long-term reference counts. The implementation 
  4369.  does not depend in any way on the internal structure of the objects being 
  4370.  freed;  it keeps the reference counts in a separate structure. 
  4371.  
  4372.  KEYWORDS 
  4373.  
  4374.  free, reference count, storage 
  4375.  
  4376.  
  4377. ΓòÉΓòÉΓòÉ 2.43. Tcl_PrintDouble ΓòÉΓòÉΓòÉ
  4378.  
  4379.  NAME 
  4380.  
  4381. Tcl_PrintDouble - Convert floating value to string 
  4382.  
  4383. SYNOPSIS 
  4384.  
  4385. #include <tcl.h> 
  4386.  
  4387.  Tcl_PrintDouble(interp, value, dst) 
  4388.  
  4389. ARGUMENTS 
  4390.  
  4391.  Tcl_Interp  *interp (in)  Interpreter that controls the conversion. 
  4392.  
  4393.  double  value (in)  Floating-point value to be converted. 
  4394.  
  4395.  char  *dst (out)  Where to store string representing value.  Must have at 
  4396.            least TCL_DOUBLE_SPACE characters of storage. 
  4397.  
  4398.  DESCRIPTION 
  4399.  
  4400.  Tcl_PrintDouble generates a string that represents the value of value and 
  4401.  stores it in memory at the location given by dst.  It uses %g format to 
  4402.  generate the string, with two special twists.  First, the string is guaranteed 
  4403.  to contain either a "." or an "e" so that it doesn't look like an integer 
  4404.  (where %g would generate an integer with no decimal point, Tcl_PrintDouble 
  4405.  adds ".0").  Second, the number of significant digits printed at dst is 
  4406.  controlled by the tcl_precision variable in interp;  if tcl_precision is 
  4407.  undefined then 6 significant digits are printed. 
  4408.  
  4409.  KEYWORDS 
  4410.  
  4411.  conversion, double-precision, floating-point, string 
  4412.  
  4413.  
  4414. ΓòÉΓòÉΓòÉ 2.44. Tcl_RecordAndEval ΓòÉΓòÉΓòÉ
  4415.  
  4416.  NAME 
  4417.  
  4418. Tcl_RecordAndEval - save command on history list before evaluating 
  4419.  
  4420. SYNOPSIS 
  4421.  
  4422. #include <tcl.h> 
  4423.  
  4424.  int 
  4425.  Tcl_RecordAndEval(interp, cmd, eval) 
  4426.  
  4427. ARGUMENTS 
  4428.  
  4429.  Tcl_Interp  *interp (in)  Tcl interpreter in which to evaluate command. 
  4430.  
  4431.  char  *cmd (in)  Command (or sequence of commands) to execute. 
  4432.  
  4433.  int  flags (in)  An OR'ed combination of flag bits.  TCL_NO_EVAL means record 
  4434.            the command but don't evaluate it.  TCL_EVAL_GLOBAL means evaluate 
  4435.            the command at global level instead of the current stack level. 
  4436.  
  4437.  DESCRIPTION 
  4438.  
  4439.  Tcl_RecordAndEval is invoked to record a command as an event on the history 
  4440.  list and then execute it using Tcl_Eval (or Tcl_GlobalEval if the 
  4441.  TCL_EVAL_GLOBAL bit is set in flags). It returns a completion code such as 
  4442.  TCL_OK just like Tcl_Eval and it leaves information in interp->result. If you 
  4443.  don't want the command recorded on the history list then you should invoke 
  4444.  Tcl_Eval instead of Tcl_RecordAndEval. Normally Tcl_RecordAndEval is only 
  4445.  called with top-level commands typed by the user, since the purpose of history 
  4446.  is to allow the user to re-issue recently-invoked commands. If the flags 
  4447.  argument contains the TCL_NO_EVAL bit then the command is recorded without 
  4448.  being evaluated. 
  4449.  
  4450.  KEYWORDS 
  4451.  
  4452.  command, event, execute, history, interpreter, record 
  4453.  
  4454.  
  4455. ΓòÉΓòÉΓòÉ 2.45. Tcl_RegExpMatch ΓòÉΓòÉΓòÉ
  4456.  
  4457.  NAME 
  4458.  
  4459. Tcl_RegExpMatch, Tcl_RegExpCompile, Tcl_RegExpExec, Tcl_RegExpRange - Pattern 
  4460. matching with regular expressions 
  4461.  
  4462. SYNOPSIS 
  4463.  
  4464. #include <tcl.h> 
  4465.  
  4466.  int 
  4467.  Tcl_RegExpMatch(interp, string, pattern) 
  4468.  
  4469.  Tcl_RegExp 
  4470.  Tcl_RegExpCompile(interp, pattern) 
  4471.  
  4472.  int 
  4473.  Tcl_RegExpExec(interp, regexp, string, start) 
  4474.  
  4475.  Tcl_RegExpRange(regexp, index, startPtr, endPtr) 
  4476.  
  4477. ARGUMENTS 
  4478.  
  4479.  Tcl_Interp  *interp (in)  Tcl interpreter to use for error reporting. 
  4480.  
  4481.  char  *string (in)  String to check for a match with a regular expression. 
  4482.  
  4483.  char  *pattern (in)  String in the form of a regular expression pattern. 
  4484.  
  4485.  Tcl_RegExp  regexp (in)  Compiled regular expression.  Must have been returned 
  4486.            previously by Tcl_RegExpCompile. 
  4487.  
  4488.  char  *start (in)  If string is just a portion of some other string, this 
  4489.            argument identifies the beginning of the larger string. If it isn't 
  4490.            the same as string, then no ^ matches will be allowed. 
  4491.  
  4492.  int  index (in)  Specifies which range is desired:  0 means the range of the 
  4493.            entire match, 1 or greater means the range that matched a 
  4494.            parenthesized sub-expression. 
  4495.  
  4496.  char  **startPtr (out)  The address of the first character in the range is 
  4497.            stored here, or NULL if there is no such range. 
  4498.  
  4499.  char  **endPtr (out)  The address of the character just after the last one in 
  4500.            the range is stored here, or NULL if there is no such range. 
  4501.  
  4502.  DESCRIPTION 
  4503.  
  4504.  Tcl_RegExpMatch determines whether its pattern argument matches regexp, where 
  4505.  regexp is interpreted as a regular expression using the same rules as for the 
  4506.  regexp Tcl command. If there is a match then Tcl_RegExpMatch returns 1. If 
  4507.  there is no match then Tcl_RegExpMatch returns 0. If an error occurs in the 
  4508.  matching process (e.g. pattern is not a valid regular expression) then 
  4509.  Tcl_RegExpMatch returns -1 and leaves an error message in interp->result. 
  4510.  
  4511.  Tcl_RegExpCompile, Tcl_RegExpExec, and Tcl_RegExpRange provide lower-level 
  4512.  access to the regular expression pattern matcher. Tcl_RegExpCompile compiles a 
  4513.  regular expression string into the internal form used for efficient pattern 
  4514.  matching. The return value is a token for this compiled form, which can be 
  4515.  used in subsequent calls to Tcl_RegExpExec or Tcl_RegExpRange. If an error 
  4516.  occurs while compiling the regular expression then Tcl_RegExpCompile returns 
  4517.  NULL and leaves an error message in interp->result. Note:  the return value 
  4518.  from Tcl_RegExpCompile is only valid up to the next call to Tcl_RegExpCompile; 
  4519.  it is not safe to retain these values for long periods of time. 
  4520.  
  4521.  Tcl_RegExpExec executes the regular expression pattern matcher. It returns 1 
  4522.  if string contains a range of characters that match regexp, 0 if no match is 
  4523.  found, and -1 if an error occurs. In the case of an error, Tcl_RegExpExec 
  4524.  leaves an error message in interp->result. When searching a string for 
  4525.  multiple matches of a pattern, it is important to distinguish between the 
  4526.  start of the original string and the start of the current search. For example, 
  4527.  when searching for the second occurrence of a match, the string argument might 
  4528.  point to the character just after the first match;  however, it is important 
  4529.  for the pattern matcher to know that this is not the start of the entire 
  4530.  string, so that it doesn't allow ^ atoms in the pattern to match. The start 
  4531.  argument provides this information by pointing to the start of the overall 
  4532.  string containing string. Start will be less than or equal to string;  if it 
  4533.  is less than string then no ^ matches will be allowed. 
  4534.  
  4535.  Tcl_RegExpRange may be invoked after Tcl_RegExpExec returns;  it provides 
  4536.  detailed information about what ranges of the string matched what parts of the 
  4537.  pattern. Tcl_RegExpRange returns a pair of pointers in *startPtr and *endPtr 
  4538.  that identify a range of characters in the source string for the most recent 
  4539.  call to Tcl_RegExpExec. Index indicates which of several ranges is desired: if 
  4540.  index is 0, information is returned about the overall range of characters that 
  4541.  matched the entire pattern;  otherwise, information is returned about the 
  4542.  range of characters that matched the index'th parenthesized subexpression 
  4543.  within the pattern. If there is no range corresponding to index then NULL is 
  4544.  stored in *firstPtr and *lastPtr. 
  4545.  
  4546.  KEYWORDS 
  4547.  
  4548.  match, pattern, regular expression, string, subexpression 
  4549.  
  4550.  
  4551. ΓòÉΓòÉΓòÉ 2.46. Tcl_SetErrno ΓòÉΓòÉΓòÉ
  4552.  
  4553.  NAME 
  4554.  
  4555. Tcl_SetErrno, Tcl_GetErrno - manipulate errno to store and retrieve error codes 
  4556.  
  4557. SYNOPSIS 
  4558.  
  4559. #include <tcl.h> 
  4560.  
  4561.  void 
  4562.  Tcl_SetErrno(errorCode) 
  4563.  
  4564.  int 
  4565.  Tcl_GetErrno() 
  4566.  
  4567. ARGUMENTS 
  4568.  
  4569.  int  errorCode (in)  A POSIX error code such as ENOENT. 
  4570.  
  4571.  DESCRIPTION 
  4572.  
  4573.  Tcl_SetErrno and Tcl_GetErrno provide portable access to the errno variable, 
  4574.  which is used to record a POSIX error code after system calls and other 
  4575.  operations such as Tcl_Gets. These procedures are necessary because global 
  4576.  variable accesses cannot be made across module boundaries on some platforms. 
  4577.  
  4578.  Tcl_SetErrno sets the errno variable to the value of the errorCode argument C 
  4579.  procedures that wish to return error information to their callers via errno 
  4580.  should call Tcl_SetErrno rather than setting errno directly. 
  4581.  
  4582.  Tcl_GetErrno returns the current value of errno. Procedures wishing to access 
  4583.  errno should call this procedure instead of accessing errno directly. 
  4584.  
  4585.  KEYWORDS 
  4586.  
  4587.  errno, error code, global variables 
  4588.  
  4589.  
  4590. ΓòÉΓòÉΓòÉ 2.47. Tcl_SetRecursionLimit ΓòÉΓòÉΓòÉ
  4591.  
  4592.  NAME 
  4593.  
  4594. Tcl_SetRecursionLimit - set maximum allowable nesting depth in interpreter 
  4595.  
  4596. SYNOPSIS 
  4597.  
  4598. #include <tcl.h> 
  4599.  
  4600.  int 
  4601.  Tcl_SetRecursionLimit(interp, depth) 
  4602.  
  4603. ARGUMENTS 
  4604.  
  4605.  Tcl_Interp  *interp (in)  Interpreter whose recursion limit is to be set. Must 
  4606.            be greater than zero. 
  4607.  
  4608.  int  depth (in)  New limit for nested calls to Tcl_Eval for interp. 
  4609.  
  4610.  DESCRIPTION 
  4611.  
  4612.  At any given time Tcl enforces a limit on the number of recursive calls that 
  4613.  may be active for Tcl_Eval and related procedures such as Tcl_GlobalEval. Any 
  4614.  call to Tcl_Eval that exceeds this depth is aborted with an error. By default 
  4615.  the recursion limit is 1000. 
  4616.  
  4617.  Tcl_SetRecursionLimit may be used to change the maximum allowable nesting 
  4618.  depth for an interpreter. The depth argument specifies a new limit for interp, 
  4619.  and Tcl_SetRecursionLimit returns the old limit. To read out the old limit 
  4620.  without modifying it, invoke Tcl_SetRecursionDepth with depth equal to 0. 
  4621.  
  4622.  The Tcl_SetRecursionLimit only sets the size of the Tcl call stack:  it cannot 
  4623.  by itself prevent stack overflows on the C stack being used by the 
  4624.  application.  If your machine has a limit on the size of the C stack, you may 
  4625.  get stack overflows before reaching the limit set by Tcl_SetRecursionLimit. If 
  4626.  this happens, see if there is a mechanism in your system for increasing the 
  4627.  maximum size of the C stack. 
  4628.  
  4629.  KEYWORDS 
  4630.  
  4631.  nesting depth, recursion 
  4632.  
  4633.  
  4634. ΓòÉΓòÉΓòÉ 2.48. Tcl_SetResult ΓòÉΓòÉΓòÉ
  4635.  
  4636.  NAME 
  4637.  
  4638. Tcl_SetResult, Tcl_AppendResult, Tcl_AppendElement, Tcl_ResetResult - 
  4639. manipulate Tcl result string 
  4640.  
  4641. SYNOPSIS 
  4642.  
  4643. #include <tcl.h> 
  4644.  
  4645.  Tcl_SetResult(interp, string, freeProc) 
  4646.  
  4647.  Tcl_AppendResult(interp, string, string, ... , (char *) NULL) 
  4648.  
  4649.  Tcl_AppendElement(interp, string) 
  4650.  
  4651.  Tcl_ResetResult(interp) 
  4652.  
  4653.  Tcl_FreeResult(interp) 
  4654.  
  4655. ARGUMENTS 
  4656.  
  4657.  Tcl_Interp  *interp (out)  Interpreter whose result is to be modified. 
  4658.  
  4659.  char  *string (in)  String value to become result for interp or to be appended 
  4660.            to existing result. 
  4661.  
  4662.  Tcl_FreeProc  *freeProc (in)  Address of procedure to call to release storage 
  4663.            at string, or TCL_STATIC, TCL_DYNAMIC, or TCL_VOLATILE. 
  4664.  
  4665.  DESCRIPTION 
  4666.  
  4667.  The procedures described here are utilities for setting the result/error 
  4668.  string in a Tcl interpreter. 
  4669.  
  4670.  Tcl_SetResult arranges for string to be the return string for the current Tcl 
  4671.  command in interp, replacing any existing result. If freeProc is TCL_STATIC it 
  4672.  means that string refers to an area of static storage that is guaranteed not 
  4673.  to be modified until at least the next call to Tcl_Eval. If freeProc is 
  4674.  TCL_DYNAMIC it means that string was allocated with a call to Tcl_Alloc and is 
  4675.  now the property of the Tcl system. Tcl_SetResult will arrange for the 
  4676.  string's storage to be released by calling Tcl_Free when it is no longer 
  4677.  needed. If freeProc is TCL_VOLATILE it means that string points to an area of 
  4678.  memory that is likely to be overwritten when Tcl_SetResult returns (e.g. it 
  4679.  points to something in a stack frame). In this case Tcl_SetResult will make a 
  4680.  copy of the string in dynamically allocated storage and arrange for the copy 
  4681.  to be the return string for the current Tcl command. 
  4682.  
  4683.  If freeProc isn't one of the values TCL_STATIC, TCL_DYNAMIC, and TCL_VOLATILE, 
  4684.  then it is the address of a procedure that Tcl should call to free the string. 
  4685.  This allows applications to use non-standard storage allocators. When Tcl no 
  4686.  longer needs the storage for the string, it will call freeProc.  FreeProc 
  4687.  should have arguments and result that match the type Tcl_FreeProc: 
  4688.  
  4689.   typedef void Tcl_FreeProc(char *blockPtr);
  4690.  When freeProc is called, its blockPtr will be set to the value of string 
  4691.  passed to Tcl_SetResult. 
  4692.  
  4693.  If string is NULL, then freeProc is ignored and Tcl_SetResult re-initializes 
  4694.  interp's result to point to the pre-allocated result area, with an empty 
  4695.  string in the result area. 
  4696.  
  4697.  If Tcl_SetResult is called at a time when interp holds a result, Tcl_SetResult 
  4698.  does whatever is necessary to dispose of the old result (see the Tcl_Interp 
  4699.  manual entry for details on this). 
  4700.  
  4701.  Tcl_AppendResult makes it easy to build up Tcl results in pieces. It takes 
  4702.  each of its string arguments and appends them in order to the current result 
  4703.  associated with interp. If the result is in its initialized empty state (e.g. 
  4704.  a command procedure was just invoked or Tcl_ResetResult was just called), then 
  4705.  Tcl_AppendResult sets the result to the concatenation of its string arguments. 
  4706.  Tcl_AppendResult may be called repeatedly as additional pieces of the result 
  4707.  are produced. Tcl_AppendResult takes care of all the storage management issues 
  4708.  associated with managing interp's result, such as allocating a larger result 
  4709.  area if necessary. Any number of string arguments may be passed in a single 
  4710.  call;  the last argument in the list must be a NULL pointer. 
  4711.  
  4712.  Tcl_AppendElement is similar to Tcl_AppendResult in that it allows results to 
  4713.  be built up in pieces. However, Tcl_AppendElement takes only a single string 
  4714.  argument and it appends that argument to the current result as a proper Tcl 
  4715.  list element. Tcl_AppendElement adds backslashes or braces if necessary to 
  4716.  ensure that interp's result can be parsed as a list and that string will be 
  4717.  extracted as a single element. Under normal conditions, Tcl_AppendElement will 
  4718.  add a space character to interp's result just before adding the new list 
  4719.  element, so that the list elements in the result are properly separated. 
  4720.  However if the new list element is the first in a list or sub-list (i.e. 
  4721.  interp's current result is empty, or consists of the single character "{", or 
  4722.  ends in the characters " {") then no space is added. 
  4723.  
  4724.  Tcl_ResetResult clears the result for interp, freeing the memory associated 
  4725.  with it if the current result was dynamically allocated. It leaves the result 
  4726.  in its normal initialized state with interp->result pointing to a static 
  4727.  buffer containing TCL_RESULT_SIZE characters, of which the first character is 
  4728.  zero. Tcl_ResetResult also clears the error state managed by Tcl_AddErrorInfo 
  4729.  and Tcl_SetErrorCode. 
  4730.  
  4731.  Tcl_FreeResult is a macro that performs part of the work of Tcl_ResetResult. 
  4732.  It frees up the memory associated with interp's result and sets 
  4733.  interp->freeProc to zero, but it doesn't change interp->result or clear error 
  4734.  state. Tcl_FreeResult is most commonly used when a procedure is about to 
  4735.  replace one result value with another. 
  4736.  
  4737.  SEE ALSO 
  4738.  
  4739.  Tcl_AddErrorInfo, Tcl_SetErrorCode, Tcl_Interp 
  4740.  
  4741.  KEYWORDS 
  4742.  
  4743.  append, command, element, list, result, return value, interpreter 
  4744.  
  4745.  
  4746. ΓòÉΓòÉΓòÉ 2.49. Tcl_SetVar ΓòÉΓòÉΓòÉ
  4747.  
  4748.  NAME 
  4749.  
  4750. Tcl_SetVar, Tcl_SetVar2, Tcl_GetVar, Tcl_GetVar2, Tcl_UnsetVar, Tcl_UnsetVar2 - 
  4751. manipulate Tcl variables 
  4752.  
  4753. SYNOPSIS 
  4754.  
  4755. #include <tcl.h> 
  4756.  
  4757.  char * 
  4758.  Tcl_SetVar(interp, varName, newValue, flags) 
  4759.  
  4760.  char * 
  4761.  Tcl_SetVar2(interp, name1, name2, newValue, flags) 
  4762.  
  4763.  char * 
  4764.  Tcl_GetVar(interp, varName, flags) 
  4765.  
  4766.  char * 
  4767.  Tcl_GetVar2(interp, name1, name2, flags) 
  4768.  
  4769.  int 
  4770.  Tcl_UnsetVar(interp, varName, flags) 
  4771.  
  4772.  int 
  4773.  Tcl_UnsetVar2(interp, name1, name2, flags) 
  4774.  
  4775. ARGUMENTS 
  4776.  
  4777.  Tcl_Interp  *interp (in)  Interpreter containing variable. 
  4778.  
  4779.  char  *varName (in)  Name of variable.  May refer to a scalar variable or an 
  4780.            element of an array variable. If the name references an element of 
  4781.            an array, then it must be in writable memory:  Tcl will make 
  4782.            temporary modifications to it while looking up the name. 
  4783.  
  4784.  char  *newValue (in)  New value for variable. 
  4785.  
  4786.  int  flags (in)  OR-ed combination of bits providing additional information 
  4787.            for operation. See below for valid values. 
  4788.  
  4789.  char  *name1 (in)  Name of scalar variable, or name of array variable if name2 
  4790.            is non-NULL. 
  4791.  
  4792.  char  *name2 (in)  If non-NULL, gives name of element within array and name1 
  4793.            must refer to an array variable. 
  4794.  
  4795.  DESCRIPTION 
  4796.  
  4797.  These procedures may be used to create, modify, read, and delete Tcl variables 
  4798.  from C code. Tcl_SetVar and Tcl_SetVar2 will create a new variable or modify 
  4799.  an existing one. Both of these procedures set the given variable to the value 
  4800.  given by newValue, and they return a pointer to a copy of the variable's new 
  4801.  value, which is stored in Tcl's variable structure. Tcl keeps a private copy 
  4802.  of the variable's value, so the caller may change newValue after these 
  4803.  procedures return without affecting the value of the variable. If an error 
  4804.  occurs in setting the variable (e.g. an array variable is referenced without 
  4805.  giving an index into the array), then NULL is returned. 
  4806.  
  4807.  The name of the variable may be specified in either of two ways. If Tcl_SetVar 
  4808.  is called, the variable name is given as a single string, varName. If varName 
  4809.  contains an open parenthesis and ends with a close parenthesis, then the value 
  4810.  between the parentheses is treated as an index (which can have any string 
  4811.  value) and the characters before the first open parenthesis are treated as the 
  4812.  name of an array variable. If varName doesn't have parentheses as described 
  4813.  above, then the entire string is treated as the name of a scalar variable. If 
  4814.  Tcl_SetVar2 is called, then the array name and index have been separated by 
  4815.  the caller into two separate strings, name1 and name2 respectively;  if name2 
  4816.  is zero it means that a scalar variable is being referenced. 
  4817.  
  4818.  The flags argument may be used to specify any of several options to the 
  4819.  procedures. It consists of an OR-ed combination of any of the following bits: 
  4820.  
  4821.  TCL_GLOBAL_ONLY  Under normal circumstances the procedures look up variables 
  4822.            at the current level of procedure call for interp, or at global 
  4823.            level if there is no call active. However, if this bit is set in 
  4824.            flags then the variable is looked up at global level even if there 
  4825.            is a procedure call active. 
  4826.  
  4827.  TCL_LEAVE_ERR_MSG  If an error is returned and this bit is set in flags, then 
  4828.            an error message will be left in interp->result.  If this flag bit 
  4829.            isn't set then no error message is left (interp->result will not be 
  4830.            modified). 
  4831.  
  4832.  TCL_APPEND_VALUE  If this bit is set then newValue is appended to the current 
  4833.            value, instead of replacing it. If the variable is currently 
  4834.            undefined, then this bit is ignored. 
  4835.  
  4836.  TCL_LIST_ELEMENT  If this bit is set, then newValue is converted to a valid 
  4837.            Tcl list element before setting (or appending to) the variable. A 
  4838.            separator space is appended before the new list element unless the 
  4839.            list element is going to be the first element in a list or sublist 
  4840.            (i.e. the variable's current value is empty, or contains the single 
  4841.            character "{", or ends in " }"). 
  4842.  
  4843.  Tcl_GetVar and Tcl_GetVar2 return the current value of a variable. The 
  4844.  arguments to these procedures are treated in the same way as the arguments to 
  4845.  Tcl_SetVar and Tcl_SetVar2. Under normal circumstances, the return value is a 
  4846.  pointer to the variable's value (which is stored in Tcl's variable structure 
  4847.  and will not change before the next call to Tcl_SetVar or Tcl_SetVar2). The 
  4848.  only bits of flags that are used are TCL_GLOBAL_ONLY and TCL_LEAVE_ERR_MSG, 
  4849.  both of which have the same meaning as for Tcl_SetVar. If an error occurs in 
  4850.  reading the variable (e.g. the variable doesn't exist or an array element is 
  4851.  specified for a scalar variable), then NULL is returned. 
  4852.  
  4853.  Tcl_UnsetVar and Tcl_UnsetVar2 may be used to remove a variable, so that 
  4854.  future calls to Tcl_GetVar or Tcl_GetVar2 for the variable will return an 
  4855.  error. The arguments to these procedures are treated in the same way as the 
  4856.  arguments to Tcl_GetVar and Tcl_GetVar2. If the variable is successfully 
  4857.  removed then TCL_OK is returned. If the variable cannot be removed because it 
  4858.  doesn't exist then TCL_ERROR is returned. If an array element is specified, 
  4859.  the given element is removed but the array remains. If an array name is 
  4860.  specified without an index, then the entire array is removed. 
  4861.  
  4862.  SEE ALSO 
  4863.  
  4864.  Tcl_TraceVar 
  4865.  
  4866.  KEYWORDS 
  4867.  
  4868.  array, interpreter, scalar, set, unset, variable 
  4869.  
  4870.  
  4871. ΓòÉΓòÉΓòÉ 2.50. Tcl_Sleep ΓòÉΓòÉΓòÉ
  4872.  
  4873.  NAME 
  4874.  
  4875. Tcl_Sleep - delay execution for a given number of milliseconds 
  4876.  
  4877. SYNOPSIS 
  4878.  
  4879. #include <tcl.h> 
  4880.  
  4881.  Tcl_Sleep(ms) 
  4882.  
  4883. ARGUMENTS 
  4884.  
  4885.  int  ms (in)  Number of milliseconds to sleep. 
  4886.  
  4887.  DESCRIPTION 
  4888.  
  4889.  This procedure delays the calling process by the number of milliseconds given 
  4890.  by the ms parameter and returns after that time has elapsed.  It is typically 
  4891.  used for things like flashing a button, where the delay is short and the 
  4892.  application needn't do anything while it waits.  For longer delays where the 
  4893.  application needs to respond to other events during the delay, the procedure 
  4894.  Tcl_CreateTimerHandler should be used instead of Tcl_Sleep. 
  4895.  
  4896.  KEYWORDS 
  4897.  
  4898.  sleep, time, wait 
  4899.  
  4900.  
  4901. ΓòÉΓòÉΓòÉ 2.51. Tcl_SplitList ΓòÉΓòÉΓòÉ
  4902.  
  4903.  NAME 
  4904.  
  4905. Tcl_SplitList, Tcl_Merge, Tcl_ScanElement, Tcl_ConvertElement - manipulate Tcl 
  4906. lists 
  4907.  
  4908. SYNOPSIS 
  4909.  
  4910. #include <tcl.h> 
  4911.  
  4912.  int 
  4913.  Tcl_SplitList(interp, list, argcPtr, argvPtr) 
  4914.  
  4915.  char * 
  4916.  Tcl_Merge(argc, argv) 
  4917.  
  4918.  int 
  4919.  Tcl_ScanElement(src, flagsPtr) 
  4920.  
  4921.  int 
  4922.  Tcl_ConvertElement(src, dst, flags) 
  4923.  
  4924. ARGUMENTS 
  4925.  
  4926.  Tcl_Interp  *interp (out)  Interpreter to use for error reporting.  If NULL, 
  4927.            then no error message is left. 
  4928.  
  4929.  char  *list (in)  Pointer to a string with proper list structure. 
  4930.  
  4931.  int  *argcPtr (out)  Filled in with number of elements in list. 
  4932.  
  4933.  char  ***argvPtr (out)  *argvPtr will be filled in with the address of an 
  4934.            array of pointers to the strings that are the extracted elements of 
  4935.            list. There will be *argcPtr valid entries in the array, followed by 
  4936.            a NULL entry. 
  4937.  
  4938.  int  argc (in)  Number of elements in argv. 
  4939.  
  4940.  char  **argv (in)  Array of strings to merge together into a single list. Each 
  4941.            string will become a separate element of the list. 
  4942.  
  4943.  char  *src (in)  String that is to become an element of a list. 
  4944.  
  4945.  int  *flagsPtr (in)  Pointer to word to fill in with information about src. 
  4946.            The value of *flagsPtr must be passed to Tcl_ConvertElement. 
  4947.  
  4948.  char  *dst (in)  Place to copy converted list element.  Must contain enough 
  4949.            characters to hold converted string. 
  4950.  
  4951.  int  flags (in)  Information about src. Must be value returned by previous 
  4952.            call to Tcl_ScanElement, possibly OR-ed with TCL_DONT_USE_BRACES. 
  4953.  
  4954.  DESCRIPTION 
  4955.  
  4956.  These procedures may be used to disassemble and reassemble Tcl lists. 
  4957.  Tcl_SplitList breaks a list up into its constituent elements, returning an 
  4958.  array of pointers to the elements using argcPtr and argvPtr. While extracting 
  4959.  the arguments, Tcl_SplitList obeys the usual rules for backslash substitutions 
  4960.  and braces.  The area of memory pointed to by *argvPtr is dynamically 
  4961.  allocated;  in addition to the array of pointers, it also holds copies of all 
  4962.  the list elements.  It is the caller's responsibility to free up all of this 
  4963.  storage. For example, suppose that you have called Tcl_SplitList with the 
  4964.  following code: 
  4965.  
  4966.   int argc, code;
  4967.   char *string;
  4968.   char **argv;
  4969.   ...
  4970.   code = Tcl_SplitList(interp, string, &argc, &argv);
  4971.  Then you should eventually free the storage with a call like the following: 
  4972.  
  4973.   Tcl_Free((char *) argv);
  4974.  
  4975.  Tcl_SplitList normally returns TCL_OK, which means the list was successfully 
  4976.  parsed. If there was a syntax error in list, then TCL_ERROR is returned and 
  4977.  interp->result will point to an error message describing the problem (if 
  4978.  interp was not NULL). If TCL_ERROR is returned then no memory is allocated and 
  4979.  *argvPtr is not modified. 
  4980.  
  4981.  Tcl_Merge is the inverse of Tcl_SplitList:  it takes a collection of strings 
  4982.  given by argc and argv and generates a result string that has proper list 
  4983.  structure. This means that commands like index may be used to extract the 
  4984.  original elements again. In addition, if the result of Tcl_Merge is passed to 
  4985.  Tcl_Eval, it will be parsed into argc words whose values will be the same as 
  4986.  the argv strings passed to Tcl_Merge. Tcl_Merge will modify the list elements 
  4987.  with braces and/or backslashes in order to produce proper Tcl list structure. 
  4988.  The result string is dynamically allocated using Tcl_Alloc;  the caller must 
  4989.  eventually release the space using Tcl_Free. 
  4990.  
  4991.  If the result of Tcl_Merge is passed to Tcl_SplitList, the elements returned 
  4992.  by Tcl_SplitList will be identical to those passed into Tcl_Merge. However, 
  4993.  the converse is not true:  if Tcl_SplitList is passed a given string, and the 
  4994.  resulting argc and argv are passed to Tcl_Merge, the resulting string may not 
  4995.  be the same as the original string passed to Tcl_SplitList. This is because 
  4996.  Tcl_Merge may use backslashes and braces differently than the original string. 
  4997.  
  4998.  Tcl_ScanElement and Tcl_ConvertElement are the procedures that do all of the 
  4999.  real work of Tcl_Merge. Tcl_ScanElement scans its src argument and determines 
  5000.  how to use backslashes and braces when converting it to a list element. It 
  5001.  returns an overestimate of the number of characters required to represent src 
  5002.  as a list element, and it stores information in *flagsPtr that is needed by 
  5003.  Tcl_ConvertElement. 
  5004.  
  5005.  Tcl_ConvertElement is a companion procedure to Tcl_ScanElement. It does the 
  5006.  actual work of converting a string to a list element. Its flags argument must 
  5007.  be the same as the value returned by Tcl_ScanElement. Tcl_ConvertElement 
  5008.  writes a proper list element to memory starting at *dst and returns a count of 
  5009.  the total number of characters written, which will be no more than the result 
  5010.  returned by Tcl_ScanElement. Tcl_ConvertElement writes out only the actual 
  5011.  list element without any leading or trailing spaces: it is up to the caller to 
  5012.  include spaces between adjacent list elements. 
  5013.  
  5014.  Tcl_ConvertElement uses one of two different approaches to handle the special 
  5015.  characters in src.  Wherever possible, it handles special characters by 
  5016.  surrounding the string with braces. This produces clean-looking output, but 
  5017.  can't be used in some situations, such as when src contains unmatched braces. 
  5018.  In these situations, Tcl_ConvertElement handles special characters by 
  5019.  generating backslash sequences for them. The caller may insist on the second 
  5020.  approach by OR-ing the flag value returned by Tcl_ScanElement with 
  5021.  TCL_DONT_USE_BRACES. Although this will produce an uglier result, it is useful 
  5022.  in some special situations, such as when Tcl_ConvertElement is being used to 
  5023.  generate a portion of an argument for a Tcl command. In this case, surrounding 
  5024.  src with curly braces would cause the command not to be parsed correctly. 
  5025.  
  5026.  KEYWORDS 
  5027.  
  5028.  backslash, convert, element, list, merge, split, strings 
  5029.  
  5030.  
  5031. ΓòÉΓòÉΓòÉ 2.52. Tcl_SplitPath ΓòÉΓòÉΓòÉ
  5032.  
  5033.  NAME 
  5034.  
  5035. Tcl_SplitPath, Tcl_JoinPath, Tcl_GetPathType - manipulate platform-dependent 
  5036. file paths 
  5037.  
  5038. SYNOPSIS 
  5039.  
  5040. #include <tcl.h> 
  5041.  
  5042.  Tcl_SplitPath(path, argcPtr, argvPtr) 
  5043.  
  5044.  char * 
  5045.  Tcl_JoinPath(argc, argv, resultPtr) 
  5046.  
  5047.  Tcl_PathType 
  5048.  Tcl_GetPathType(path) 
  5049.  
  5050. ARGUMENTS 
  5051.  
  5052.  char  *path (in)  File path in a form appropriate for the current platform 
  5053.            (see the filename manual entry for acceptable forms for path names). 
  5054.  
  5055.  int  *argcPtr (out)  Filled in with number of path elements in path. 
  5056.  
  5057.  char  ***argvPtr (out)  *argvPtr will be filled in with the address of an 
  5058.            array of pointers to the strings that are the extracted elements of 
  5059.            path. There will be *argcPtr valid entries in the array, followed by 
  5060.            a NULL entry. 
  5061.  
  5062.  int  argc (in)  Number of elements in argv. 
  5063.  
  5064.  char  **argv (in)  Array of path elements to merge together into a single 
  5065.            path. 
  5066.  
  5067.  Tcl_DString  *resultPtr (in/out)  A pointer to an initialized Tcl_DString to 
  5068.            which the result of Tcl_JoinPath will be appended. 
  5069.  
  5070.  DESCRIPTION 
  5071.  
  5072.  These procedures may be used to disassemble and reassemble file paths in a 
  5073.  platform independent manner: they provide C-level access to the same 
  5074.  functionality as the file split, file join, and file pathtype commands. 
  5075.  
  5076.  Tcl_SplitPath breaks a path into its constituent elements, returning an array 
  5077.  of pointers to the elements using argcPtr and argvPtr.  The area of memory 
  5078.  pointed to by *argvPtr is dynamically allocated; in addition to the array of 
  5079.  pointers, it also holds copies of all the path elements.  It is the caller's 
  5080.  responsibility to free all of this storage. For example, suppose that you have 
  5081.  called Tcl_SplitPath with the following code: 
  5082.  
  5083.   int argc;
  5084.   char *path;
  5085.   char **argv;
  5086.   ...
  5087.   Tcl_SplitPath(string, &argc, &argv);
  5088.  Then you should eventually free the storage with a call like the following: 
  5089.  
  5090.   Tcl_Free((char *) argv);
  5091.  
  5092.  Tcl_JoinPath is the inverse of Tcl_SplitPath: it takes a collection of path 
  5093.  elements given by argc and argv and generates a result string that is a 
  5094.  properly constructed path. The result string is appended to resultPtr. 
  5095.  ResultPtr must refer to an initialized Tcl_DString. 
  5096.  
  5097.  If the result of Tcl_SplitPath is passed to Tcl_JoinPath, the result will 
  5098.  refer to the same location, but may not be in the same form.  This is because 
  5099.  Tcl_SplitPath and Tcl_JoinPath eliminate duplicate path separators and return 
  5100.  a normalized form for each platform. 
  5101.  
  5102.  Tcl_GetPathType returns the type of the specified path, where Tcl_PathType is 
  5103.  one of TCL_PATH_ABSOLUTE, TCL_PATH_RELATIVE, or TCL_PATH_VOLUME_RELATIVE.  See 
  5104.  the filename manual entry for a description of the path types for each 
  5105.  platform. 
  5106.  
  5107.  KEYWORDS 
  5108.  
  5109.  file, filename, join, path, split, type 
  5110.  
  5111.  
  5112. ΓòÉΓòÉΓòÉ 2.53. Tcl_StaticPackage ΓòÉΓòÉΓòÉ
  5113.  
  5114.  NAME 
  5115.  
  5116. Tcl_StaticPackage - make a statically linked package available via the load 
  5117. command 
  5118.  
  5119. SYNOPSIS 
  5120.  
  5121. #include <tcl.h> 
  5122.  
  5123.  Tcl_StaticPackage(interp, pkgName, initProc, safeInitProc) 
  5124.  
  5125. ARGUMENTS 
  5126.  
  5127.  Tcl_Interp  *interp (in)  If not NULL, points to an interpreter into which the 
  5128.            package has already been loaded (i.e., the caller has already 
  5129.            invoked the appropriate initialization procedure).  NULL means the 
  5130.            package hasn't yet been incorporated into any interpreter. 
  5131.  
  5132.  char  *pkgName (in)  Name of the package;  should be properly capitalized 
  5133.            (first letter upper-case, all others lower-case). 
  5134.  
  5135.  Tcl_PackageInitProc  *initProc (in)  Procedure to invoke to incorporate this 
  5136.            package into a trusted interpreter. 
  5137.  
  5138.  Tcl_PackageInitProc  *safeInitProc (in)  Procedure to call to incorporate this 
  5139.            package into a safe interpreter (one that will execute untrusted 
  5140.            scripts).  NULL means the package can't be used in safe 
  5141.            interpreters. 
  5142.  
  5143.  DESCRIPTION 
  5144.  
  5145.  This procedure may be invoked to announce that a package has been linked 
  5146.  statically with a Tcl application and, optionally, that it has already been 
  5147.  loaded into an interpreter. Once Tcl_StaticPackage has been invoked for a 
  5148.  package, it may be loaded into interpreters using the load command. 
  5149.  Tcl_StaticPackage is normally invoked only by the Tcl_AppInit procedure for 
  5150.  the application, not by packages for themselves (Tcl_StaticPackage should only 
  5151.  be invoked for statically loaded packages, and code in the package itself 
  5152.  should not need to know whether the package is dynamically or statically 
  5153.  loaded). 
  5154.  
  5155.  When the load command is used later to load the package into an interpreter, 
  5156.  one of initProc and safeInitProc will be invoked, depending on whether the 
  5157.  target interpreter is safe or not. initProc and safeInitProc must both match 
  5158.  the following prototype: 
  5159.  
  5160.   typedef int Tcl_PackageInitProc(Tcl_Interp *interp);
  5161.  The interp argument identifies the interpreter in which the package is to be 
  5162.  loaded.  The initialization procedure must return TCL_OK or TCL_ERROR to 
  5163.  indicate whether or not it completed successfully;  in the event of an error 
  5164.  it should set interp->result to point to an error message. The result or error 
  5165.  from the initialization procedure will be returned as the result of the load 
  5166.  command that caused the initialization procedure to be invoked. 
  5167.  
  5168.  KEYWORDS 
  5169.  
  5170.  initialization procedure, package, static linking 
  5171.  
  5172.  
  5173. ΓòÉΓòÉΓòÉ 2.54. Tcl_StringMatch ΓòÉΓòÉΓòÉ
  5174.  
  5175.  NAME 
  5176.  
  5177. Tcl_StringMatch - test whether a string matches a pattern 
  5178.  
  5179. SYNOPSIS 
  5180.  
  5181. #include <tcl.h> 
  5182.  
  5183.  int 
  5184.  Tcl_StringMatch(string, pattern) 
  5185.  
  5186. ARGUMENTS 
  5187.  
  5188.  char  *string (in)  String to test. 
  5189.  
  5190.  char  *pattern (in)  Pattern to match against string.  May contain special 
  5191.            characters from the set *?\[]. 
  5192.  
  5193.  DESCRIPTION 
  5194.  
  5195.  This utility procedure determines whether a string matches a given pattern. 
  5196.  If it does, then Tcl_StringMatch returns 1.  Otherwise Tcl_StringMatch returns 
  5197.  0.  The algorithm used for matching is the same algorithm used in the "string 
  5198.  match" Tcl command and is similar to the algorithm used by the C-shell for 
  5199.  file name matching;  see the Tcl manual entry for details. 
  5200.  
  5201.  KEYWORDS 
  5202.  
  5203.  match, pattern, string 
  5204.  
  5205.  
  5206. ΓòÉΓòÉΓòÉ 2.55. Tcl_Main ΓòÉΓòÉΓòÉ
  5207.  
  5208.  NAME 
  5209.  
  5210. Tcl_Main - main program for Tcl-based applications 
  5211.  
  5212. SYNOPSIS 
  5213.  
  5214. #include <tcl.h> 
  5215.  
  5216.  Tcl_Main(argc, argv, appInitProc) 
  5217.  
  5218. ARGUMENTS 
  5219.  
  5220.  int  argc (in)  Number of elements in argv. 
  5221.  
  5222.  char  *argv[] (in)  Array of strings containing command-line arguments. 
  5223.  
  5224.  Tcl_AppInitProc  *appInitProc (in)  Address of an application-specific 
  5225.            initialization procedure. The value for this argument is usually 
  5226.            Tcl_AppInit. 
  5227.  
  5228.  DESCRIPTION 
  5229.  
  5230.  Tcl_Main acts as the main program for most Tcl-based applications. Starting 
  5231.  with Tcl 7.4 it is not called main anymore because it is part of the Tcl 
  5232.  library and having a function main in a library (particularly a shared 
  5233.  library) causes problems on many systems. Having main in the Tcl library would 
  5234.  also make it hard to use Tcl in C++ programs, since C++ programs must have 
  5235.  special C++ main functions. 
  5236.  
  5237.  Normally each application contains a small main function that does nothing but 
  5238.  invoke Tcl_Main. Tcl_Main then does all the work of creating and running a 
  5239.  tclsh-like application. 
  5240.  
  5241.  When it is has finished its own initialization, but before it processes 
  5242.  commands, Tcl_Main calls the procedure given by the appInitProc argument. 
  5243.  This procedure provides a "hook" for the application to perform its own 
  5244.  initialization, such as defining application-specific commands.  The procedure 
  5245.  must have an interface that matches the type Tcl_AppInitProc: 
  5246.  
  5247.   typedef int Tcl_AppInitProc(Tcl_Interp *interp);
  5248.  AppInitProc is almost always a pointer to Tcl_AppInit; for more details on 
  5249.  this procedure, see the documentation for Tcl_AppInit. 
  5250.  
  5251.  KEYWORDS 
  5252.  
  5253.  application-specific initialization, command-line arguments, main program 
  5254.  
  5255.  
  5256. ΓòÉΓòÉΓòÉ 2.56. Tcl_TraceVar ΓòÉΓòÉΓòÉ
  5257.  
  5258.  NAME 
  5259.  
  5260. Tcl_TraceVar, Tcl_TraceVar2, Tcl_UntraceVar, Tcl_UntraceVar2, Tcl_VarTraceInfo, 
  5261. Tcl_VarTraceInfo2 - monitor accesses to a variable 
  5262.  
  5263. SYNOPSIS 
  5264.  
  5265. #include <tcl.h> 
  5266.  
  5267.  int 
  5268.  Tcl_TraceVar(interp, varName, flags, proc, clientData) 
  5269.  
  5270.  int 
  5271.  Tcl_TraceVar2(interp, name1, name2, flags, proc, clientData) 
  5272.  
  5273.  Tcl_UntraceVar(interp, varName, flags, proc, clientData) 
  5274.  
  5275.  Tcl_UntraceVar2(interp, name1, name2, flags, proc, clientData) 
  5276.  
  5277.  ClientData 
  5278.  Tcl_VarTraceInfo(interp, varName, flags, proc, prevClientData) 
  5279.  
  5280.  ClientData 
  5281.  Tcl_VarTraceInfo2(interp, name1, name2, flags, proc, prevClientData) 
  5282.  
  5283. ARGUMENTS 
  5284.  
  5285.  Tcl_Interp  *interp (in)  Interpreter containing variable. 
  5286.  
  5287.  char  *varName (in)  Name of variable.  May refer to a scalar variable, to an 
  5288.            array variable with no index, or to an array variable with a 
  5289.            parenthesized index. If the name references an element of an array, 
  5290.            then it must be in writable memory:  Tcl will make temporary 
  5291.            modifications to it while looking up the name. 
  5292.  
  5293.  int  flags (in)  OR-ed combination of the values TCL_TRACE_READS, 
  5294.            TCL_TRACE_WRITES, and TCL_TRACE_UNSETS, and TCL_GLOBAL_ONLY.  Not 
  5295.            all flags are used by all procedures.  See below for more 
  5296.            information. 
  5297.  
  5298.  Tcl_VarTraceProc  *proc (in)  Procedure to invoke whenever one of the traced 
  5299.            operations occurs. 
  5300.  
  5301.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  5302.  
  5303.  char  *name1 (in)  Name of scalar or array variable (without array index). 
  5304.  
  5305.  char  *name2 (in)  For a trace on an element of an array, gives the index of 
  5306.            the element.  For traces on scalar variables or on whole arrays, is 
  5307.            NULL. 
  5308.  
  5309.  ClientData  prevClientData (in)  If non-NULL, gives last value returned by 
  5310.            Tcl_VarTraceInfo or Tcl_VarTraceInfo2, so this call will return 
  5311.            information about next trace.  If NULL, this call will return 
  5312.            information about first trace. 
  5313.  
  5314.  DESCRIPTION 
  5315.  
  5316.  Tcl_TraceVar allows a C procedure to monitor and control access to a Tcl 
  5317.  variable, so that the C procedure is invoked whenever the variable is read or 
  5318.  written or unset. If the trace is created successfully then Tcl_TraceVar 
  5319.  returns TCL_OK.  If an error occurred (e.g. varName specifies an element of an 
  5320.  array, but the actual variable isn't an array) then TCL_ERROR is returned and 
  5321.  an error message is left in interp->result. 
  5322.  
  5323.  The flags argument to Tcl_TraceVar indicates when the trace procedure is to be 
  5324.  invoked and provides information for setting up the trace.  It consists of an 
  5325.  OR-ed combination of any of the following values: 
  5326.  
  5327.  TCL_GLOBAL_ONLY  Normally, the variable will be looked up at the current level 
  5328.            of procedure call;  if this bit is set then the variable will be 
  5329.            looked up at global level, ignoring any active procedures. 
  5330.  
  5331.  TCL_TRACE_READS  Invoke proc whenever an attempt is made to read the variable. 
  5332.  
  5333.  TCL_TRACE_WRITES  Invoke proc whenever an attempt is made to modify the 
  5334.            variable. 
  5335.  
  5336.  TCL_TRACE_UNSETS  Invoke proc whenever the variable is unset. A variable may 
  5337.            be unset either explicitly by an unset command, or implicitly when a 
  5338.            procedure returns (its local variables are automatically unset) or 
  5339.            when the interpreter is deleted (all variables are automatically 
  5340.            unset). 
  5341.  
  5342.  Whenever one of the specified operations occurs on the variable, proc will be 
  5343.  invoked. It should have arguments and result that match the type 
  5344.  Tcl_VarTraceProc: 
  5345.  
  5346.   typedef char *Tcl_VarTraceProc(
  5347.          ClientData clientData,
  5348.          Tcl_Interp *interp,
  5349.          char *name1,
  5350.          char *name2,
  5351.          int flags);
  5352.  The clientData and interp parameters will have the same values as those passed 
  5353.  to Tcl_TraceVar when the trace was created. ClientData typically points to an 
  5354.  application-specific data structure that describes what to do when proc is 
  5355.  invoked. Name1 and name2 give the name of the traced variable in the normal 
  5356.  two-part form (see the description of Tcl_TraceVar2 below for details). Flags 
  5357.  is an OR-ed combination of bits providing several pieces of information. One 
  5358.  of the bits TCL_TRACE_READS, TCL_TRACE_WRITES, or TCL_TRACE_UNSETS will be set 
  5359.  in flags to indicate which operation is being performed on the variable. The 
  5360.  bit TCL_GLOBAL_ONLY will be set whenever the variable being accessed is a 
  5361.  global one not accessible from the current level of procedure call:  the trace 
  5362.  procedure will need to pass this flag back to variable-related procedures like 
  5363.  Tcl_GetVar if it attempts to access the variable. The bit TCL_TRACE_DESTROYED 
  5364.  will be set in flags if the trace is about to be destroyed;  this information 
  5365.  may be useful to proc so that it can clean up its own internal data structures 
  5366.  (see the section TCL_TRACE_DESTROYED below for more details). Lastly, the bit 
  5367.  TCL_INTERP_DESTROYED will be set if the entire interpreter is being destroyed. 
  5368.  When this bit is set, proc must be especially careful in the things it does 
  5369.  (see the section TCL_INTERP_DESTROYED below). The trace procedure's return 
  5370.  value should normally be NULL;  see ERROR RETURNS below for information on 
  5371.  other possibilities. 
  5372.  
  5373.  Tcl_UntraceVar may be used to remove a trace. If the variable specified by 
  5374.  interp, varName, and flags has a trace set with flags, proc, and clientData, 
  5375.  then the corresponding trace is removed. If no such trace exists, then the 
  5376.  call to Tcl_UntraceVar has no effect. The same bits are valid for flags as for 
  5377.  calls to Tcl_TraceVar. 
  5378.  
  5379.  Tcl_VarTraceInfo may be used to retrieve information about traces set on a 
  5380.  given variable. The return value from Tcl_VarTraceInfo is the clientData 
  5381.  associated with a particular trace. The trace must be on the variable 
  5382.  specified by the interp, varName, and flags arguments (only the 
  5383.  TCL_GLOBAL_ONLY bit from flags is used;  other bits are ignored) and its trace 
  5384.  procedure must the same as the proc argument. If the prevClientData argument 
  5385.  is NULL then the return value corresponds to the first (most recently created) 
  5386.  matching trace, or NULL if there are no matching traces. If the prevClientData 
  5387.  argument isn't NULL, then it should be the return value from a previous call 
  5388.  to Tcl_VarTraceInfo. In this case, the new return value will correspond to the 
  5389.  next matching trace after the one whose clientData matches prevClientData, or 
  5390.  NULL if no trace matches prevClientData or if there are no more matching 
  5391.  traces after it. This mechanism makes it possible to step through all of the 
  5392.  traces for a given variable that have the same proc. 
  5393.  
  5394.  TWO-PART NAMES 
  5395.  
  5396.  The procedures Tcl_TraceVar2, Tcl_UntraceVar2, and Tcl_VarTraceInfo2 are 
  5397.  identical to Tcl_TraceVar, Tcl_UntraceVar, and Tcl_VarTraceInfo, respectively, 
  5398.  except that the name of the variable has already been separated by the caller 
  5399.  into two parts. Name1 gives the name of a scalar variable or array, and name2 
  5400.  gives the name of an element within an array. If name2 is NULL it means that 
  5401.  either the variable is a scalar or the trace is to be set on the entire array 
  5402.  rather than an individual element (see WHOLE-ARRAY TRACES below for more 
  5403.  information). 
  5404.  
  5405.  ACCESSING VARIABLES DURING TRACES 
  5406.  
  5407.  During read and write traces, the trace procedure can read, write, or unset 
  5408.  the traced variable using Tcl_GetVar2, Tcl_SetVar2, and other procedures. 
  5409.  While proc is executing, traces are temporarily disabled for the variable, so 
  5410.  that calls to Tcl_GetVar2 and Tcl_SetVar2 will not cause proc or other trace 
  5411.  procedures to be invoked again. Disabling only occurs for the variable whose 
  5412.  trace procedure is active;  accesses to other variables will still be traced. 
  5413.  However, if a variable is unset during a read or write trace then unset traces 
  5414.  will be invoked. 
  5415.  
  5416.  During unset traces the variable has already been completely expunged. It is 
  5417.  possible for the trace procedure to read or write the variable, but this will 
  5418.  be a new version of the variable. Traces are not disabled during unset traces 
  5419.  as they are for read and write traces, but existing traces have been removed 
  5420.  from the variable before any trace procedures are invoked. If new traces are 
  5421.  set by unset trace procedures, these traces will be invoked on accesses to the 
  5422.  variable by the trace procedures. 
  5423.  
  5424.  CALLBACK TIMING 
  5425.  
  5426.  When read tracing has been specified for a variable, the trace procedure will 
  5427.  be invoked whenever the variable's value is read.  This includes set Tcl 
  5428.  commands, $-notation in Tcl commands, and invocations of the Tcl_GetVar and 
  5429.  Tcl_GetVar2 procedures. Proc is invoked just before the variable's value is 
  5430.  returned. It may modify the value of the variable to affect what is returned 
  5431.  by the traced access. If it unsets the variable then the access will return an 
  5432.  error just as if the variable never existed. 
  5433.  
  5434.  When write tracing has been specified for a variable, the trace procedure will 
  5435.  be invoked whenever the variable's value is modified.  This includes set 
  5436.  commands, commands that modify variables as side effects (such as catch and 
  5437.  scan), and calls to the Tcl_SetVar and Tcl_SetVar2 procedures). Proc will be 
  5438.  invoked after the variable's value has been modified, but before the new value 
  5439.  of the variable has been returned. It may modify the value of the variable to 
  5440.  override the change and to determine the value actually returned by the traced 
  5441.  access. If it deletes the variable then the traced access will return an empty 
  5442.  string. 
  5443.  
  5444.  When unset tracing has been specified, the trace procedure will be invoked 
  5445.  whenever the variable is destroyed. The traces will be called after the 
  5446.  variable has been completely unset. 
  5447.  
  5448.  WHOLE-ARRAY TRACES 
  5449.  
  5450.  If a call to Tcl_TraceVar or Tcl_TraceVar2 specifies the name of an array 
  5451.  variable without an index into the array, then the trace will be set on the 
  5452.  array as a whole. This means that proc will be invoked whenever any element of 
  5453.  the array is accessed in the ways specified by flags. When an array is unset, 
  5454.  a whole-array trace will be invoked just once, with name1 equal to the name of 
  5455.  the array and name2 NULL;  it will not be invoked once for each element. 
  5456.  
  5457.  MULTIPLE TRACES 
  5458.  
  5459.  It is possible for multiple traces to exist on the same variable. When this 
  5460.  happens, all of the trace procedures will be invoked on each access, in order 
  5461.  from most-recently-created to least-recently-created. When there exist 
  5462.  whole-array traces for an array as well as traces on individual elements, the 
  5463.  whole-array traces are invoked before the individual-element traces. If a read 
  5464.  or write trace unsets the variable then all of the unset traces will be 
  5465.  invoked but the remainder of the read and write traces will be skipped. 
  5466.  
  5467.  ERROR RETURNS 
  5468.  
  5469.  Under normal conditions trace procedures should return NULL, indicating 
  5470.  successful completion. If proc returns a non-NULL value it signifies that an 
  5471.  error occurred. The return value must be a pointer to a static character 
  5472.  string containing an error message. If a trace procedure returns an error, no 
  5473.  further traces are invoked for the access and the traced access aborts with 
  5474.  the given message. Trace procedures can use this facility to make variables 
  5475.  read-only, for example (but note that the value of the variable will already 
  5476.  have been modified before the trace procedure is called, so the trace 
  5477.  procedure will have to restore the correct value). 
  5478.  
  5479.  The return value from proc is only used during read and write tracing. During 
  5480.  unset traces, the return value is ignored and all relevant trace procedures 
  5481.  will always be invoked. 
  5482.  
  5483.  RESTRICTIONS 
  5484.  
  5485.  A trace procedure can be called at any time, even when there is a 
  5486.  partially-formed result in the interpreter's result area.  If the trace 
  5487.  procedure does anything that could damage this result (such as calling 
  5488.  Tcl_Eval) then it must save the original values of the interpreter's result 
  5489.  and freeProc fields and restore them before it returns. 
  5490.  
  5491.  UNDEFINED VARIABLES 
  5492.  
  5493.  It is legal to set a trace on an undefined variable. The variable will still 
  5494.  appear to be undefined until the first time its value is set. If an undefined 
  5495.  variable is traced and then unset, the unset will fail with an error ("no such 
  5496.  variable"), but the trace procedure will still be invoked. 
  5497.  
  5498.  TCL_TRACE_DESTROYED FLAG 
  5499.  
  5500.  In an unset callback to proc, the TCL_TRACE_DESTROYED bit is set in flags if 
  5501.  the trace is being removed as part of the deletion. Traces on a variable are 
  5502.  always removed whenever the variable is deleted;  the only time 
  5503.  TCL_TRACE_DESTROYED isn't set is for a whole-array trace invoked when only a 
  5504.  single element of an array is unset. 
  5505.  
  5506.  TCL_INTERP_DESTROYED 
  5507.  
  5508.  When an interpreter is destroyed, unset traces are called for all of its 
  5509.  variables. The TCL_INTERP_DESTROYED bit will be set in the flags argument 
  5510.  passed to the trace procedures. Trace procedures must be extremely careful in 
  5511.  what they do if the TCL_INTERP_DESTROYED bit is set. It is not safe for the 
  5512.  procedures to invoke any Tcl procedures on the interpreter, since its state is 
  5513.  partially deleted. All that trace procedures should do under these 
  5514.  circumstances is to clean up and free their own internal data structures. 
  5515.  
  5516.  BUGS 
  5517.  
  5518.  Tcl doesn't do any error checking to prevent trace procedures from misusing 
  5519.  the interpreter during traces with TCL_INTERP_DESTROYED set. 
  5520.  
  5521.  KEYWORDS 
  5522.  
  5523.  clientData, trace, variable 
  5524.  
  5525.  
  5526. ΓòÉΓòÉΓòÉ 2.57. Tcl_TranslateFileName ΓòÉΓòÉΓòÉ
  5527.  
  5528.  NAME 
  5529.  
  5530. Tcl_TranslateFileName - convert file name to native form and replace tilde with 
  5531. home directory 
  5532.  
  5533. SYNOPSIS 
  5534.  
  5535. #include <tcl.h> 
  5536.  
  5537.  char * 
  5538.  Tcl_TranslateFileName(interp, name, bufferPtr) 
  5539.  
  5540. ARGUMENTS 
  5541.  
  5542.  Tcl_Interp  *interp (in)  Interpreter in which to report an error, if any. 
  5543.  
  5544.  char  *name (in)  File name, which may start with a "~". 
  5545.  
  5546.  Tcl_DString  *bufferPtr (in/out)  If needed, this dynamic string is used to 
  5547.            store the new file name. At the time of the call it should be 
  5548.            uninitialized or empty.  The caller must eventually call 
  5549.            Tcl_DStringFree to free up anything stored here. 
  5550.  
  5551.  DESCRIPTION 
  5552.  
  5553.  This utility procedure translates a file name to a form suitable for passing 
  5554.  to the local operating system.  It converts network names into native form and 
  5555.  does tilde substitution. 
  5556.  
  5557.  If Tcl_TranslateFileName has to do tilde substitution or translate the name 
  5558.  then it uses the dynamic string at *bufferPtr to hold the new string it 
  5559.  generates. After Tcl_TranslateFileName returns a non-NULL result, the caller 
  5560.  must eventually invoke Tcl_DStringFree to free any information placed in 
  5561.  *bufferPtr.  The caller need not know whether or not Tcl_TranslateFileName 
  5562.  actually used the string;  Tcl_TranslateFileName initializes *bufferPtr even 
  5563.  if it doesn't use it, so the call to Tcl_DStringFree will be safe in either 
  5564.  case. 
  5565.  
  5566.  If an error occurs (e.g. because there was no user by the given name) then 
  5567.  NULL is returned and an error message will be left at interp->result. When an 
  5568.  error occurs, Tcl_TranslateFileName frees the dynamic string itself so that 
  5569.  the caller need not call Tcl_DStringFree. 
  5570.  
  5571.  The caller is responsible for making sure that interp->result has its default 
  5572.  empty value when Tcl_TranslateFileName is invoked. 
  5573.  
  5574.  SEE ALSO 
  5575.  
  5576.  filename 
  5577.  
  5578.  KEYWORDS 
  5579.  
  5580.  file name, home directory, tilde, translate, user 
  5581.  
  5582.  
  5583. ΓòÉΓòÉΓòÉ 2.58. Tcl_UpVar ΓòÉΓòÉΓòÉ
  5584.  
  5585.  NAME 
  5586.  
  5587. Tcl_UpVar, Tcl_UpVar2 - link one variable to another 
  5588.  
  5589. SYNOPSIS 
  5590.  
  5591. #include <tcl.h> 
  5592.  
  5593.  int 
  5594.  Tcl_UpVar(interp, frameName, sourceName, destName, flags) 
  5595.  
  5596.  int 
  5597.  Tcl_UpVar2(interp, frameName, name1, name2, destName, flags) 
  5598.  
  5599. ARGUMENTS 
  5600.  
  5601.  Tcl_Interp  *interp (in)  Interpreter containing variables;  also used for 
  5602.            error reporting. 
  5603.  
  5604.  char  *frameName (in)  Identifies the stack frame containing source variable. 
  5605.            May have any of the forms accepted by the upvar command, such as #0 
  5606.            or 1. 
  5607.  
  5608.  char  *sourceName (in)  Name of source variable, in the frame given by 
  5609.            frameName. May refer to a scalar variable or to an array variable 
  5610.            with a parenthesized index. 
  5611.  
  5612.  char  *destName (in)  Name of destination variable, which is to be linked to 
  5613.            source variable so that references to destName refer to the other 
  5614.            variable.  Must not currently exist except as an upvar-ed variable. 
  5615.  
  5616.  int  flags (in)  Either TCL_GLOBAL_ONLY or 0;  if non-zero, then destName is a 
  5617.            global variable;  otherwise it is a local to the current procedure 
  5618.            (or global if no procedure is active). 
  5619.  
  5620.  char  *name1 (in)  First part of source variable's name (scalar name, or name 
  5621.            of array without array index). 
  5622.  
  5623.  char  *name2 (in)  If source variable is an element of an array, gives the 
  5624.            index of the element. For scalar source variables, is NULL. 
  5625.  
  5626.  DESCRIPTION 
  5627.  
  5628.  Tcl_UpVar and Tcl_UpVar2 provide the same functionality as the upvar command: 
  5629.  they make a link from a source variable to a destination variable, so that 
  5630.  references to the destination are passed transparently through to the source. 
  5631.  The name of the source variable may be specified either as a single string 
  5632.  such as xyx or a(24) (by calling Tcl_UpVar) or in two parts where the array 
  5633.  name has been separated from the element name (by calling Tcl_UpVar2). The 
  5634.  destination variable name is specified in a single string;  it may not be an 
  5635.  array element. 
  5636.  
  5637.  Both procedures return either TCL_OK or TCL_ERROR, and they leave an error 
  5638.  message in interp->result if an error occurs. 
  5639.  
  5640.  As with the upvar command, the source variable need not exist; if it does 
  5641.  exist, unsetting it later does not destroy the link.  The destination variable 
  5642.  may exist at the time of the call, but if so it must exist as a linked 
  5643.  variable. 
  5644.  
  5645.  KEYWORDS 
  5646.  
  5647.  linked variable, upvar, variable 
  5648.  
  5649.  
  5650. ΓòÉΓòÉΓòÉ 3. Tcl Built-In Commands ΓòÉΓòÉΓòÉ
  5651.  
  5652.  
  5653. ΓòÉΓòÉΓòÉ 3.1. Tcl ΓòÉΓòÉΓòÉ
  5654.  
  5655.  NAME 
  5656.  
  5657. Tcl - Summary of Tcl language syntax. 
  5658.  
  5659. DESCRIPTION 
  5660.  
  5661. The following rules define the syntax and semantics of the Tcl language: 
  5662.  
  5663.    1. A Tcl script is a string containing one or more commands. Semi-colons and 
  5664.       newlines are command separators unless quoted as described below. Close 
  5665.       brackets are command terminators during command substitution (see below) 
  5666.       unless quoted. 
  5667.  
  5668.    2. A command is evaluated in two steps. First, the Tcl interpreter breaks 
  5669.       the command into words and performs substitutions as described below. 
  5670.       These substitutions are performed in the same way for all commands. The 
  5671.       first word is used to locate a command procedure to carry out the 
  5672.       command, then all of the words of the command are passed to the command 
  5673.       procedure. The command procedure is free to interpret each of its words 
  5674.       in any way it likes, such as an integer, variable name, list, or Tcl 
  5675.       script. Different commands interpret their words differently. 
  5676.  
  5677.    3. Words of a command are separated by white space (except for newlines, 
  5678.       which are command separators). 
  5679.  
  5680.    4. If the first character of a word is double-quote (""") then the word is 
  5681.       terminated by the next double-quote character. If semi-colons, close 
  5682.       brackets, or white space characters (including newlines) appear between 
  5683.       the quotes then they are treated as ordinary characters and included in 
  5684.       the word. Command substitution, variable substitution, and backslash 
  5685.       substitution are performed on the characters between the quotes as 
  5686.       described below. The double-quotes are not retained as part of the word. 
  5687.  
  5688.    5. If the first character of a word is an open brace ("{") then the word is 
  5689.       terminated by the matching close brace ("}"). Braces nest within the 
  5690.       word: for each additional open brace there must be an additional close 
  5691.       brace (however, if an open brace or close brace within the word is quoted 
  5692.       with a backslash then it is not counted in locating the matching close 
  5693.       brace). No substitutions are performed on the characters between the 
  5694.       braces except for backslash-newline substitutions described below, nor do 
  5695.       semi-colons, newlines, close brackets, or white space receive any special 
  5696.       interpretation. The word will consist of exactly the characters between 
  5697.       the outer braces, not including the braces themselves. 
  5698.  
  5699.    6. If a word contains an open bracket ("[") then Tcl performs command 
  5700.       substitution. To do this it invokes the Tcl interpreter recursively to 
  5701.       process the characters following the open bracket as a Tcl script. The 
  5702.       script may contain any number of commands and must be terminated by a 
  5703.       close bracket ("]"). The result of the script (i.e. the result of its 
  5704.       last command) is substituted into the word in place of the brackets and 
  5705.       all of the characters between them. There may be any number of command 
  5706.       substitutions in a single word. Command substitution is not performed on 
  5707.       words enclosed in braces. 
  5708.  
  5709.    7. If a word contains a dollar-sign ("$") then Tcl performs variable 
  5710.       substitution:  the dollar-sign and the following characters are replaced 
  5711.       in the word by the value of a variable. Variable substitution may take 
  5712.       any of the following forms: 
  5713.  
  5714.       $name          Name is the name of a scalar variable;  the name is 
  5715.                      terminated by any character that isn't a letter, digit, or 
  5716.                      underscore. 
  5717.  
  5718.       $name(index)   Name gives the name of an array variable and index gives 
  5719.                      the name of an element within that array. Name must 
  5720.                      contain only letters, digits, and underscores. Command 
  5721.                      substitutions, variable substitutions, and backslash 
  5722.                      substitutions are performed on the characters of index. 
  5723.  
  5724.       ${name}        Name is the name of a scalar variable.  It may contain any 
  5725.                      characters whatsoever except for close braces. 
  5726.  
  5727.       There may be any number of variable substitutions in a single word. 
  5728.       Variable substitution is not performed on words enclosed in braces. 
  5729.  
  5730.    8. If a backslash ("\") appears within a word then backslash substitution 
  5731.       occurs. In all cases but those described below the backslash is dropped 
  5732.       and the following character is treated as an ordinary character and 
  5733.       included in the word. This allows characters such as double quotes, close 
  5734.       brackets, and dollar signs to be included in words without triggering 
  5735.       special processing. The following table lists the backslash sequences 
  5736.       that are handled specially, along with the value that replaces each 
  5737.       sequence. 
  5738.  
  5739.       \a             Audible alert (bell) (0x7). 
  5740.  
  5741.       \b             Backspace (0x8). 
  5742.  
  5743.       \f             Form feed (0xc). 
  5744.  
  5745.       \n             Newline (0xa). 
  5746.  
  5747.       \ r            Carriage-return (0xd). 
  5748.  
  5749.       \t             Tab (0x9). 
  5750.  
  5751.       \v             Vertical tab (0xb). 
  5752.  
  5753.       \<newline>whiteSpace  A single space character replaces the backslash, 
  5754.                      newline, and all spaces and tabs after the newline. This 
  5755.                      backslash sequence is unique in that it is replaced in a 
  5756.                      separate pre-pass before the command is actually parsed. 
  5757.                      This means that it will be replaced even when it occurs 
  5758.                      between braces, and the resulting space will be treated as 
  5759.                      a word separator if it isn't in braces or quotes. 
  5760.  
  5761.       \\             Backslash ("\"). 
  5762.  
  5763.       \ooo           The digits ooo (one, two, or three of them) give the octal 
  5764.                      value of the character. 
  5765.  
  5766.       \xhh           The hexadecimal digits hh give the hexadecimal value of 
  5767.                      the character.  Any number of digits may be present. 
  5768.  
  5769.       Backslash substitution is not performed on words enclosed in braces, 
  5770.       except for backslash-newline as described above. 
  5771.  
  5772.    9. If a hash character ("#") appears at a point where Tcl is expecting the 
  5773.       first character of the first word of a command, then the hash character 
  5774.       and the characters that follow it, up through the next newline, are 
  5775.       treated as a comment and ignored. The comment character only has 
  5776.       significance when it appears at the beginning of a command. 
  5777.  
  5778.   10. Each character is processed exactly once by the Tcl interpreter as part 
  5779.       of creating the words of a command. For example, if variable substitution 
  5780.       occurs then no further substitutions are performed on the value of the 
  5781.       variable;  the value is inserted into the word verbatim. If command 
  5782.       substitution occurs then the nested command is processed entirely by the 
  5783.       recursive call to the Tcl interpreter; no substitutions are performed 
  5784.       before making the recursive call and no additional substitutions are 
  5785.       performed on the result of the nested script. 
  5786.  
  5787.   11. Substitutions do not affect the word boundaries of a command. For 
  5788.       example, during variable substitution the entire value of the variable 
  5789.       becomes part of a single word, even if the variable's value contains 
  5790.       spaces. 
  5791.  
  5792.  
  5793. ΓòÉΓòÉΓòÉ 3.2. after ΓòÉΓòÉΓòÉ
  5794.  
  5795.  NAME 
  5796.  
  5797. after - Execute a command after a time delay 
  5798.  
  5799. SYNOPSIS 
  5800.  
  5801. after ms 
  5802.  after ms ?script script script ...? 
  5803.  after cancel id 
  5804.  after cancel script script script ... 
  5805.  after idle ?script script script ...? 
  5806.  after info ?id? 
  5807.  
  5808. DESCRIPTION 
  5809.  
  5810. This command is used to delay execution of the program or to execute a command 
  5811. in background sometime in the future.  It has several forms, depending on the 
  5812. first argument to the command: 
  5813.  
  5814.  after ms  Ms must be an integer giving a time in milliseconds. The command 
  5815.            sleeps for ms milliseconds and then returns. While the command is 
  5816.            sleeping the application does not respond to events. 
  5817.  
  5818.  after ms ?script script script ...?  In this form the command returns 
  5819.            immediately, but it arranges for a Tcl command to be executed ms 
  5820.            milliseconds later as an event handler. The command will be executed 
  5821.            exactly once, at the given time. The delayed command is formed by 
  5822.            concatenating all the script arguments in the same fashion as the 
  5823.            concat command. The command will be executed at global level 
  5824.            (outside the context of any Tcl procedure). If an error occurs while 
  5825.            executing the delayed command then the bgerror mechanism is used to 
  5826.            report the error. The after command returns an identifier that can 
  5827.            be used to cancel the delayed command using after cancel. 
  5828.  
  5829.  after cancel id  Cancels the execution of a delayed command that was 
  5830.            previously scheduled. Id indicates which command should be canceled; 
  5831.            it must have been the return value from a previous after command. If 
  5832.            the command given by id has already been executed then the after 
  5833.            cancel command has no effect. 
  5834.  
  5835.  after cancel script script ...  This command also cancels the execution of a 
  5836.            delayed command. The script arguments are concatenated together with 
  5837.            space separators (just as in the concat command). If there is a 
  5838.            pending command that matches the string, it is cancelled and will 
  5839.            never be executed;  if no such command is currently pending then the 
  5840.            after cancel command has no effect. 
  5841.  
  5842.  after idle script ?script script ...?  Concatenates the script arguments 
  5843.            together with space separators (just as in the concat command), and 
  5844.            arranges for the resulting script to be evaluated later as an idle 
  5845.            callback. The script will be run exactly once, the next time the 
  5846.            event loop is entered and there are no events to process. The 
  5847.            command returns an identifier that can be used to cancel the delayed 
  5848.            command using after cancel. If an error occurs while executing the 
  5849.            script then the bgerror mechanism is used to report the error. 
  5850.  
  5851.  after info ?id?  This command returns information about existing event 
  5852.            handlers. If no id argument is supplied, the command returns a list 
  5853.            of the identifiers for all existing event handlers created by the 
  5854.            after command for this interpreter. If id is supplied, it specifies 
  5855.            an existing handler; id must have been the return value from some 
  5856.            previous call to after and it must not have triggered yet or been 
  5857.            cancelled. In this case the command returns a list with two 
  5858.            elements. The first element of the list is the script associated 
  5859.            with id, and the second element is either idle or timer to indicate 
  5860.            what kind of event handler it is. 
  5861.  
  5862.  The after ms and after idle forms of the command assume that the application 
  5863.  is event driven:  the delayed commands will not be executed unless the 
  5864.  application enters the event loop. In applications that are not normally 
  5865.  event-driven, such as tclsh, the event loop can be entered with the vwait and 
  5866.  update commands. 
  5867.  
  5868.  SEE ALSO 
  5869.  
  5870.  bgerror 
  5871.  
  5872.  KEYWORDS 
  5873.  
  5874.  cancel, delay, idle callback, sleep, time 
  5875.  
  5876.  
  5877. ΓòÉΓòÉΓòÉ 3.3. append ΓòÉΓòÉΓòÉ
  5878.  
  5879.  NAME 
  5880.  
  5881. append - Append to variable 
  5882.  
  5883. SYNOPSIS 
  5884.  
  5885. append varName ?value value value ...? 
  5886.  
  5887. DESCRIPTION 
  5888.  
  5889. Append all of the value arguments to the current value of variable varName.  If 
  5890. varName doesn't exist, it is given a value equal to the concatenation of all 
  5891. the value arguments. This command provides an efficient way to build up long 
  5892. variables incrementally. For example, "append a $b" is much more efficient than 
  5893. "set a $a$b" if $a is long. 
  5894.  
  5895. KEYWORDS 
  5896.  
  5897. append, variable 
  5898.  
  5899.  
  5900. ΓòÉΓòÉΓòÉ 3.4. array ΓòÉΓòÉΓòÉ
  5901.  
  5902.  NAME 
  5903.  
  5904. array - Manipulate array variables 
  5905.  
  5906. SYNOPSIS 
  5907.  
  5908. array option arrayName ?arg arg ...? 
  5909.  
  5910. DESCRIPTION 
  5911.  
  5912. This command performs one of several operations on the variable given by 
  5913. arrayName. Unless otherwise specified for individual commands below, arrayName 
  5914. must be the name of an existing array variable. The option argument determines 
  5915. what action is carried out by the command. The legal options (which may be 
  5916. abbreviated) are: 
  5917.  
  5918.  array anymore arrayName searchId  Returns 1 if there are any more elements 
  5919.            left to be processed in an array search, 0 if all elements have 
  5920.            already been returned. SearchId indicates which search on arrayName 
  5921.            to check, and must have been the return value from a previous 
  5922.            invocation of array startsearch. This option is particularly useful 
  5923.            if an array has an element with an empty name, since the return 
  5924.            value from array nextelement won't indicate whether the search has 
  5925.            been completed. 
  5926.  
  5927.  array donesearch arrayName searchId  This command terminates an array search 
  5928.            and destroys all the state associated with that search.  SearchId 
  5929.            indicates which search on arrayName to destroy, and must have been 
  5930.            the return value from a previous invocation of array startsearch. 
  5931.            Returns an empty string. 
  5932.  
  5933.  array exists arrayName  Returns 1 if arrayName is an array variable, 0 if 
  5934.            there is no variable by that name or if it is a scalar variable. 
  5935.  
  5936.  array get arrayName ?pattern?  Returns a list containing pairs of elements. 
  5937.            The first element in each pair is the name of an element in 
  5938.            arrayName and the second element of each pair is the value of the 
  5939.            array element.  The order of the pairs is undefined. If pattern is 
  5940.            not specified, then all of the elements of the array are included in 
  5941.            the result. If pattern is specified, then only those elements whose 
  5942.            names match pattern (using the glob-style matching rules of string 
  5943.            match) are included. If arrayName isn't the name of an array 
  5944.            variable, or if the array contains no elements, then an empty list 
  5945.            is returned. 
  5946.  
  5947.  array names arrayName ?pattern?  Returns a list containing the names of all of 
  5948.            the elements in the array that match pattern (using the glob-style 
  5949.            matching rules of string match). If pattern is omitted then the 
  5950.            command returns all of the element names in the array. If there are 
  5951.            no (matching) elements in the array, or if arrayName isn't the name 
  5952.            of an array variable, then an empty string is returned. 
  5953.  
  5954.  array nextelement arrayName searchId  Returns the name of the next element in 
  5955.            arrayName, or an empty string if all elements of arrayName have 
  5956.            already been returned in this search.  The searchId argument 
  5957.            identifies the search, and must have been the return value of an 
  5958.            array startsearch command. Warning:  if elements are added to or 
  5959.            deleted from the array, then all searches are automatically 
  5960.            terminated just as if array donesearch had been invoked; this will 
  5961.            cause array nextelement operations to fail for those searches. 
  5962.  
  5963.  array set arrayName list  Sets the values of one or more elements in 
  5964.            arrayName. list must have a form like that returned by array get, 
  5965.            consisting of an even number of elements. Each odd-numbered element 
  5966.            in list is treated as an element name within arrayName, and the 
  5967.            following element in list is used as a new value for that array 
  5968.            element. 
  5969.  
  5970.  array size arrayName  Returns a decimal string giving the number of elements 
  5971.            in the array. If arrayName isn't the name of an array then 0 is 
  5972.            returned. 
  5973.  
  5974.  array startsearch arrayName  This command initializes an element-by-element 
  5975.            search through the array given by arrayName, such that invocations 
  5976.            of the array nextelement command will return the names of the 
  5977.            individual elements in the array. When the search has been 
  5978.            completed, the array donesearch command should be invoked. The 
  5979.            return value is a search identifier that must be used in array 
  5980.            nextelement and array donesearch commands; it allows multiple 
  5981.            searches to be underway simultaneously for the same array. 
  5982.  
  5983.  KEYWORDS 
  5984.  
  5985.  array, element names, search 
  5986.  
  5987.  
  5988. ΓòÉΓòÉΓòÉ 3.5. bgerror ΓòÉΓòÉΓòÉ
  5989.  
  5990.  NAME 
  5991.  
  5992. bgerror - Command invoked to process background errors 
  5993.  
  5994. SYNOPSIS 
  5995.  
  5996. bgerror message 
  5997.  
  5998. DESCRIPTION 
  5999.  
  6000. The bgerror command doesn't exist as built-in part of Tcl.  Instead, individual 
  6001. applications or users can define a bgerror command (e.g. as a Tcl procedure) if 
  6002. they wish to handle background errors. 
  6003.  
  6004. A background error is one that occurs in an event handler or some other command 
  6005. that didn't originate with the application. For example, if an error occurs 
  6006. while executing a command specified with the after command, then it is a 
  6007. background error. For a non-background error, the error can simply be returned 
  6008. up through nested Tcl command evaluations until it reaches the top-level code 
  6009. in the application; then the application can report the error in whatever way 
  6010. it wishes. When a background error occurs, the unwinding ends in the Tcl 
  6011. library and there is no obvious way for Tcl to report the error. 
  6012.  
  6013. When Tcl detects a background error, it saves information about the error and 
  6014. invokes the bgerror command later as an idle event handler. Before invoking 
  6015. bgerror, Tcl restores the errorInfo and errorCode variables to their values at 
  6016. the time the error occurred, then it invokes bgerror with the error message as 
  6017. its only argument. Tcl assumes that the application has implemented the bgerror 
  6018. command, and that the command will report the error in a way that makes sense 
  6019. for the application.  Tcl will ignore any result returned by the bgerror 
  6020. command as long as no error is generated. 
  6021.  
  6022. If another Tcl error occurs within the bgerror command (for example, because no 
  6023. bgerror command has been defined) then Tcl reports the error itself by writing 
  6024. a message to stderr. 
  6025.  
  6026. If several background errors accumulate before bgerror is invoked to process 
  6027. them, bgerror will be invoked once for each error, in the order they occurred. 
  6028. However, if bgerror returns with a break exception, then any remaining errors 
  6029. are skipped without calling bgerror. 
  6030.  
  6031. Tcl has no default implementation for bgerror. However, in applications using 
  6032. Tk there will be a default bgerror procedure that posts a dialog box containing 
  6033. the error message and offers the user a chance to see a stack trace showing 
  6034. where the error occurred. 
  6035.  
  6036. KEYWORDS 
  6037.  
  6038. background error, reporting 
  6039.  
  6040.  
  6041. ΓòÉΓòÉΓòÉ 3.6. break ΓòÉΓòÉΓòÉ
  6042.  
  6043.  NAME 
  6044.  
  6045. break - Abort looping command 
  6046.  
  6047. SYNOPSIS 
  6048.  
  6049. break 
  6050.  
  6051. DESCRIPTION 
  6052.  
  6053. This command is typically invoked inside the body of a looping command such as 
  6054. for or foreach or while. It returns a TCL_BREAK code, which causes a break 
  6055. exception to occur. The exception causes the current script to be aborted out 
  6056. to the innermost containing loop command, which then aborts its execution and 
  6057. returns normally. Break exceptions are also handled in a few other situations, 
  6058. such as the catch command, Tk event bindings, and the outermost scripts of 
  6059. procedure bodies. 
  6060.  
  6061. KEYWORDS 
  6062.  
  6063. abort, break, loop 
  6064.  
  6065.  
  6066. ΓòÉΓòÉΓòÉ 3.7. case ΓòÉΓòÉΓòÉ
  6067.  
  6068.  NAME 
  6069.  
  6070. case - Evaluate one of several scripts, depending on a given value 
  6071.  
  6072. SYNOPSIS 
  6073.  
  6074. case string ?in? patList body ?patList body ...? 
  6075.  case string ?in? {patList body ?patList body ...?} 
  6076.  
  6077. DESCRIPTION 
  6078.  
  6079. Note: the case command is obsolete and is supported only for backward 
  6080. compatibility.  At some point in the future it may be removed entirely.  You 
  6081. should use the switch command instead. 
  6082.  
  6083. The case command matches string against each of the patList arguments in order. 
  6084. Each patList argument is a list of one or more patterns.  If any of these 
  6085. patterns matches string then case evaluates the following body argument by 
  6086. passing it recursively to the Tcl interpreter and returns the result of that 
  6087. evaluation. Each patList argument consists of a single pattern or list of 
  6088. patterns.  Each pattern may contain any of the wild-cards described under 
  6089. string match.  If a patList argument is default, the corresponding body will be 
  6090. evaluated if no patList matches string.  If no patList argument matches string 
  6091. and no default is given, then the case command returns an empty string. 
  6092.  
  6093. Two syntaxes are provided for the patList and body arguments. The first uses a 
  6094. separate argument for each of the patterns and commands; this form is 
  6095. convenient if substitutions are desired on some of the patterns or commands. 
  6096. The second form places all of the patterns and commands together into a single 
  6097. argument; the argument must have proper list structure, with the elements of 
  6098. the list being the patterns and commands. The second form makes it easy to 
  6099. construct multi-line case commands, since the braces around the whole list make 
  6100. it unnecessary to include a backslash at the end of each line. Since the 
  6101. patList arguments are in braces in the second form, no command or variable 
  6102. substitutions are performed on them;  this makes the behavior of the second 
  6103. form different than the first form in some cases. 
  6104.  
  6105. KEYWORDS 
  6106.  
  6107. case, match, regular expression 
  6108.  
  6109.  
  6110. ΓòÉΓòÉΓòÉ 3.8. catch ΓòÉΓòÉΓòÉ
  6111.  
  6112.  NAME 
  6113.  
  6114. catch - Evaluate script and trap exceptional returns 
  6115.  
  6116. SYNOPSIS 
  6117.  
  6118. catch script ?varName? 
  6119.  
  6120. DESCRIPTION 
  6121.  
  6122. The catch command may be used to prevent errors from aborting command 
  6123. interpretation.  Catch calls the Tcl interpreter recursively to execute script, 
  6124. and always returns a TCL_OK code, regardless of any errors that might occur 
  6125. while executing script.  The return value from catch is a decimal string giving 
  6126. the code returned by the Tcl interpreter after executing script. This will be 0 
  6127. (TCL_OK) if there were no errors in script; otherwise it will have a non-zero 
  6128. value corresponding to one of the exceptional return codes (see tcl.h for the 
  6129. definitions of code values).  If the varName argument is given, then it gives 
  6130. the name of a variable; catch will set the variable to the string returned from 
  6131. script (either a result or an error message). 
  6132.  
  6133. Note that catch catches all exceptions, including those generated by break and 
  6134. continue as well as errors. 
  6135.  
  6136. KEYWORDS 
  6137.  
  6138. catch, error 
  6139.  
  6140.  
  6141. ΓòÉΓòÉΓòÉ 3.9. cd ΓòÉΓòÉΓòÉ
  6142.  
  6143.  NAME 
  6144.  
  6145. cd - Change working directory 
  6146.  
  6147. SYNOPSIS 
  6148.  
  6149. cd ?dirName? 
  6150.  
  6151. DESCRIPTION 
  6152.  
  6153. Change the current working directory to dirName, or to the home directory (as 
  6154. specified in the HOME environment variable) if dirName is not given. Returns an 
  6155. empty string. 
  6156.  
  6157. KEYWORDS 
  6158.  
  6159. working directory 
  6160.  
  6161.  
  6162. ΓòÉΓòÉΓòÉ 3.10. clock ΓòÉΓòÉΓòÉ
  6163.  
  6164.  NAME 
  6165.  
  6166. clock - Obtain and manipulate time 
  6167.  
  6168. SYNOPSIS 
  6169.  
  6170. clock option ?arg arg ...? 
  6171.  
  6172. DESCRIPTION 
  6173.  
  6174. This command performs one of several operations that may obtain or manipulate 
  6175. strings or values that represent some notion of time.  The option argument 
  6176. determines what action is carried out by the command.  The legal options (which 
  6177. may be abbreviated) are: 
  6178.  
  6179.  clock clicks  Return a high-resolution time value as a system-dependent 
  6180.            integer value.  The unit of the value is system-dependent but should 
  6181.            be the highest resolution clock available on the system such as a 
  6182.            CPU cycle counter. This value should only be used for the relative 
  6183.            measurement of elapsed time. 
  6184.  
  6185.  clock format clockValue ?-format string? ?-gmt boolean?  Converts an integer 
  6186.            time value, typically returned by clock seconds, clock scan, or the 
  6187.            atime, mtime, or ctime options of the file command, to 
  6188.            human-readable form.  If the -format argument is present the next 
  6189.            argument is a string that describes how the date and time are to be 
  6190.            formatted. Field descriptors consist of a % followed by a field 
  6191.            descriptor character.  All other characters are copied into the 
  6192.            result. Valid field descriptors are: 
  6193.  
  6194.              1. Insert a %. 
  6195.  
  6196.              2. Abbreviated weekday name (Mon, Tue, etc.). 
  6197.  
  6198.              3. Full weekday name (Monday, Tuesday, etc.). 
  6199.  
  6200.              4. Abbreviated month name (Jan, Feb, etc.). 
  6201.  
  6202.              5. Full month name. 
  6203.  
  6204.              6. Locale specific date and time. 
  6205.  
  6206.              7. Day of month (01 - 31). 
  6207.  
  6208.              8. Hour in 24-hour format (00 - 23). 
  6209.  
  6210.              9. Hour in 12-hour format (00 - 12). 
  6211.  
  6212.             10. Day of year (001 - 366). 
  6213.  
  6214.             11. Month number (01 - 12). 
  6215.  
  6216.             12. Minute (00 - 59). 
  6217.  
  6218.             13. AM/PM indicator. 
  6219.  
  6220.             14. Seconds (00 - 59). 
  6221.  
  6222.             15. Week of year (01 - 52), Sunday is the first day of the week. 
  6223.  
  6224.             16. Weekday number (Sunday = 0). 
  6225.  
  6226.             17. Week of year (01 - 52), Monday is the first day of the week. 
  6227.  
  6228.             18. Locale specific date format. 
  6229.  
  6230.             19. Locale specific time format. 
  6231.  
  6232.             20. Year without century (00 - 99). 
  6233.  
  6234.             21. Year with century (e.g. 1990) 
  6235.  
  6236.             22. Time zone name. 
  6237.             In addition, the following field descriptors may be supported on 
  6238.            some systems (e.g. Unix but not Windows): 
  6239.  
  6240.              1. Date as %m/%d/%y. 
  6241.  
  6242.              2. Day of month (1 - 31), no leading zeros. 
  6243.  
  6244.              3. Abbreviated month name. 
  6245.  
  6246.              4. Insert a newline. 
  6247.  
  6248.              5. Time as %I:%M:%S %p. 
  6249.  
  6250.              6. Time as %H:%M. 
  6251.  
  6252.              7. Insert a tab. 
  6253.  
  6254.              8. Time as %H:%M:%S. 
  6255.             If the -format argument is not specified, the format string "%a %b 
  6256.            %d %H:%M:%S %Z %Y" is used.  If the -gmt argument is present the 
  6257.            next argument must be a boolean which if true specifies that the 
  6258.            time will be formatted as Greenwich Mean Time. If false then the 
  6259.            local timezone will be used as defined by the operating environment. 
  6260.  
  6261.  clock scan dateString ?-base clockVal? ?-gmt boolean?  Convert dateString to 
  6262.            an integer clock value (see clock seconds). This command can parse 
  6263.            and convert virtually any standard date and/or time string, which 
  6264.            can include standard time zone mnemonics.  If only a time is 
  6265.            specified, the current date is assumed.  If the string does not 
  6266.            contain a time zone mnemonic, the local time zone is assumed, unless 
  6267.            the -gmt argument is true, in which case the clock value is 
  6268.            calculated assuming that the specified time is relative to Greenwich 
  6269.            Mean Time. 
  6270.             If the -base flag is specified, the next argument should contain an 
  6271.            integer clock value.  Only the date in this value is used, not the 
  6272.            time.  This is useful for determining the time on a specific day or 
  6273.            doing other date-relative conversions. 
  6274.             The dateString consists of zero or more specifications of the 
  6275.            following form: 
  6276.  
  6277.            time           A time of day, which is of the form: hh?:mm?:ss?? 
  6278.                           ?meridian? ?zone? or hhmm ?meridian? ?zone?. If no 
  6279.                           meridian is specified, hh is interpreted on a 24-hour 
  6280.                           clock. 
  6281.  
  6282.            date           A specific month and day with optional year.  The 
  6283.                           acceptable formats are mm/dd?/yy?, monthname dd ?, 
  6284.                           yy?, dd monthname ?yy? and day, dd monthname yy.  The 
  6285.                           default year is the current year.  If the year is 
  6286.                           less then 100, then 1900 is added to it. 
  6287.  
  6288.            relative time  A specification relative to the current time.  The 
  6289.                           format is number unit acceptable units are year, 
  6290.                           fortnight, month, week, day, hour, minute (or min), 
  6291.                           and second (or sec).  The unit can be specified as a 
  6292.                           singular or plural, as in 3 weeks. These modifiers 
  6293.                           may also be specified: tomorrow, yesterday, today, 
  6294.                           now, last, this, next, ago. 
  6295.             The actual date is calculated according to the following steps. 
  6296.            First, any absolute date and/or time is processed and converted. 
  6297.            Using that time as the base, day-of-week specifications are added. 
  6298.            Next, relative specifications are used.  If a date or day is 
  6299.            specified, and no absolute or relative time is given, midnight is 
  6300.            used.  Finally, a correction is applied so that the correct hour of 
  6301.            the day is produced after allowing for daylight savings time 
  6302.            differences. 
  6303.  
  6304.  clock seconds  Return the current date and time as a system-dependent integer 
  6305.            value.  The unit of the value is seconds, allowing it to be used for 
  6306.            relative time calculations.  The value is usually defined as total 
  6307.            elapsed time from an "epoch".  You shouldn't assume the value of the 
  6308.            epoch. 
  6309.  
  6310.  KEYWORDS 
  6311.  
  6312.  clock, date, time 
  6313.  
  6314.  
  6315. ΓòÉΓòÉΓòÉ 3.11. close ΓòÉΓòÉΓòÉ
  6316.  
  6317.  NAME 
  6318.  
  6319. close - Close an open channel. 
  6320.  
  6321. SYNOPSIS 
  6322.  
  6323. close channelId 
  6324.  
  6325. DESCRIPTION 
  6326.  
  6327. Closes the channel given by channelId.  ChannelId must be a channel identifier 
  6328. such as the return value from a previous open or socket command. All buffered 
  6329. output is flushed to the channel's output device, any buffered input is 
  6330. discarded, the underlying file or device is closed, and channelId becomes 
  6331. unavailable for use. 
  6332.  
  6333. If the channel is blocking, the command does not return until all output is 
  6334. flushed. If the channel is nonblocking and there is unflushed output, the 
  6335. channel remains open and the command returns immediately; output will be 
  6336. flushed in the background and the channel will be closed when all the flushing 
  6337. is complete. 
  6338.  
  6339. If channelId is a blocking channel for a command pipeline then close waits for 
  6340. the child processes to complete. 
  6341.  
  6342. If the channel is shared between interpreters, then close makes channelId 
  6343. unavailable in the invoking interpreter but has no other effect until all of 
  6344. the sharing interpreters have closed the channel. When the last interpreter in 
  6345. which the channel is registered invokes close, the cleanup actions described 
  6346. above occur. See the interp command for a description of channel sharing. 
  6347.  
  6348. Channels are automatically closed when an interpreter is destroyed and when the 
  6349. process exits.  Channels are switched to blocking mode, to ensure that all 
  6350. output is correctly flushed before the process exits. 
  6351.  
  6352. The command returns an empty string, and may generate an error if an error 
  6353. occurs while flushing output. 
  6354.  
  6355. KEYWORDS 
  6356.  
  6357. blocking, channel, close, nonblocking 
  6358.  
  6359.  
  6360. ΓòÉΓòÉΓòÉ 3.12. concat ΓòÉΓòÉΓòÉ
  6361.  
  6362.  NAME 
  6363.  
  6364. concat - Join lists together 
  6365.  
  6366. SYNOPSIS 
  6367.  
  6368. concat ?arg arg ...? 
  6369.  
  6370. DESCRIPTION 
  6371.  
  6372. This command treats each argument as a list and concatenates them into a single 
  6373. list. It also eliminates leading and trailing spaces in the arg's and adds a 
  6374. single separator space between arg's. It permits any number of arguments.  For 
  6375. example, the command 
  6376.  
  6377. concat a b {c d e} {f {g h}}
  6378. will return 
  6379.  
  6380. a b c d e f {g h}
  6381. as its result. 
  6382.  
  6383. If no args are supplied, the result is an empty string. 
  6384.  
  6385. KEYWORDS 
  6386.  
  6387. concatenate, join, lists 
  6388.  
  6389.  
  6390. ΓòÉΓòÉΓòÉ 3.13. continue ΓòÉΓòÉΓòÉ
  6391.  
  6392.  NAME 
  6393.  
  6394. continue - Skip to the next iteration of a loop 
  6395.  
  6396. SYNOPSIS 
  6397.  
  6398. continue 
  6399.  
  6400. DESCRIPTION 
  6401.  
  6402. This command is typically invoked inside the body of a looping command such as 
  6403. for or foreach or while. It returns a TCL_CONTINUE code, which causes a 
  6404. continue exception to occur. The exception causes the current script to be 
  6405. aborted out to the innermost containing loop command, which then continues with 
  6406. the next iteration of the loop. Catch exceptions are also handled in a few 
  6407. other situations, such as the catch command and the outermost scripts of 
  6408. procedure bodies. 
  6409.  
  6410. KEYWORDS 
  6411.  
  6412. continue, iteration, loop 
  6413.  
  6414.  
  6415. ΓòÉΓòÉΓòÉ 3.14. eof ΓòÉΓòÉΓòÉ
  6416.  
  6417.  NAME 
  6418.  
  6419. eof - Check for end of file condition on channel 
  6420.  
  6421. SYNOPSIS 
  6422.  
  6423. eof channelId 
  6424.  
  6425. DESCRIPTION 
  6426.  
  6427. Returns 1 if an end of file condition occurred during the most recent input 
  6428. operation on channelId (such as gets), 0 otherwise. 
  6429.  
  6430. KEYWORDS 
  6431.  
  6432. channel, end of file 
  6433.  
  6434.  
  6435. ΓòÉΓòÉΓòÉ 3.15. error ΓòÉΓòÉΓòÉ
  6436.  
  6437.  NAME 
  6438.  
  6439. error - Generate an error 
  6440.  
  6441. SYNOPSIS 
  6442.  
  6443. error message ?info? ?code? 
  6444.  
  6445. DESCRIPTION 
  6446.  
  6447. Returns a TCL_ERROR code, which causes command interpretation to be unwound. 
  6448. Message is a string that is returned to the application to indicate what went 
  6449. wrong. 
  6450.  
  6451. If the info argument is provided and is non-empty, it is used to initialize the 
  6452. global variable errorInfo. errorInfo is used to accumulate a stack trace of 
  6453. what was in progress when an error occurred; as nested commands unwind, the Tcl 
  6454. interpreter adds information to errorInfo.  If the info argument is present, it 
  6455. is used to initialize errorInfo and the first increment of unwind information 
  6456. will not be added by the Tcl interpreter.  In other words, the command 
  6457. containing the error command will not appear in errorInfo; in its place will be 
  6458. info. This feature is most useful in conjunction with the catch command: if a 
  6459. caught error cannot be handled successfully, info can be used to return a stack 
  6460. trace reflecting the original point of occurrence of the error: 
  6461.  
  6462. catch {...} errMsg
  6463. set savedInfo $errorInfo
  6464. ...
  6465. error $errMsg $savedInfo
  6466.  
  6467. If the code argument is present, then its value is stored in the errorCode 
  6468. global variable.  This variable is intended to hold a machine-readable 
  6469. description of the error in cases where such information is available; see the 
  6470. tclvars manual page for information on the proper format for the variable. If 
  6471. the code argument is not present, then errorCode is automatically reset to 
  6472. "NONE" by the Tcl interpreter as part of processing the error generated by the 
  6473. command. 
  6474.  
  6475. KEYWORDS 
  6476.  
  6477. error, errorCode, errorInfo 
  6478.  
  6479.  
  6480. ΓòÉΓòÉΓòÉ 3.16. eval ΓòÉΓòÉΓòÉ
  6481.  
  6482.  NAME 
  6483.  
  6484. eval - Evaluate a Tcl script 
  6485.  
  6486. SYNOPSIS 
  6487.  
  6488. eval arg ?arg ...? 
  6489.  
  6490. DESCRIPTION 
  6491.  
  6492. Eval takes one or more arguments, which together comprise a Tcl script 
  6493. containing one or more commands. Eval concatenates all its arguments in the 
  6494. same fashion as the concat command, passes the concatenated string to the Tcl 
  6495. interpreter recursively, and returns the result of that evaluation (or any 
  6496. error generated by it). 
  6497.  
  6498. KEYWORDS 
  6499.  
  6500. concatenate, evaluate, script 
  6501.  
  6502.  
  6503. ΓòÉΓòÉΓòÉ 3.17. exec ΓòÉΓòÉΓòÉ
  6504.  
  6505.  NAME 
  6506.  
  6507. exec - Invoke subprocess(es) 
  6508.  
  6509. SYNOPSIS 
  6510.  
  6511. exec ?switches? arg ?arg ...? 
  6512.  
  6513. DESCRIPTION 
  6514.  
  6515. This command treats its arguments as the specification of one or more 
  6516. subprocesses to execute. The arguments take the form of a standard shell 
  6517. pipeline where each arg becomes one word of a command, and each distinct 
  6518. command becomes a subprocess. 
  6519.  
  6520. If the initial arguments to exec start with - then they are treated as 
  6521. command-line switches and are not part of the pipeline specification.  The 
  6522. following switches are currently supported: 
  6523.  
  6524.  -keepnewline  Retains a trailing newline in the pipeline's output. Normally a 
  6525.            trailing newline will be deleted. 
  6526.  
  6527.  --        Marks the end of switches.  The argument following this one will be 
  6528.            treated as the first arg even if it starts with a -. 
  6529.  
  6530.  If an arg (or pair of arg's) has one of the forms described below then it is 
  6531.  used by exec to control the flow of input and output among the subprocess(es). 
  6532.  Such arguments will not be passed to the subprocess(es).  In forms such as "< 
  6533.  fileName" fileName may either be in a separate argument from "<" or in the 
  6534.  same argument with no intervening space (i.e. "<fileName"). 
  6535.  
  6536.  |         Separates distinct commands in the pipeline.  The standard output of 
  6537.            the preceding command will be piped into the standard input of the 
  6538.            next command. 
  6539.  
  6540.  |&        Separates distinct commands in the pipeline.  Both standard output 
  6541.            and standard error of the preceding command will be piped into the 
  6542.            standard input of the next command. This form of redirection 
  6543.            overrides forms such as 2> and >&. 
  6544.  
  6545.  < fileName  The file named by fileName is opened and used as the standard 
  6546.            input for the first command in the pipeline. 
  6547.  
  6548.  <@ fileId  FileId must be the identifier for an open file, such as the return 
  6549.            value from a previous call to open. It is used as the standard input 
  6550.            for the first command in the pipeline. FileId must have been opened 
  6551.            for reading. 
  6552.  
  6553.  << value  Value is passed to the first command as its standard input. 
  6554.  
  6555.  > fileName  Standard output from the last command is redirected to the file 
  6556.            named fileName, overwriting its previous contents. 
  6557.  
  6558.  2> fileName  Standard error from all commands in the pipeline is redirected to 
  6559.            the file named fileName, overwriting its previous contents. 
  6560.  
  6561.  >& fileName  Both standard output from the last command and standard error 
  6562.            from all commands are redirected to the file named fileName, 
  6563.            overwriting its previous contents. 
  6564.  
  6565.  >> fileName  Standard output from the last command is redirected to the file 
  6566.            named fileName, appending to it rather than overwriting it. 
  6567.  
  6568.  2>> fileName  Standard error from all commands in the pipeline is redirected 
  6569.            to the file named fileName, appending to it rather than overwriting 
  6570.            it. 
  6571.  
  6572.  >>& fileName  Both standard output from the last command and standard error 
  6573.            from all commands are redirected to the file named fileName, 
  6574.            appending to it rather than overwriting it. 
  6575.  
  6576.  >@ fileId  FileId must be the identifier for an open file, such as the return 
  6577.            value from a previous call to open. Standard output from the last 
  6578.            command is redirected to fileId's file, which must have been opened 
  6579.            for writing. 
  6580.  
  6581.  2>@ fileId  FileId must be the identifier for an open file, such as the return 
  6582.            value from a previous call to open. Standard error from all commands 
  6583.            in the pipeline is redirected to fileId's file. The file must have 
  6584.            been opened for writing. 
  6585.  
  6586.  >&@ fileId  FileId must be the identifier for an open file, such as the return 
  6587.            value from a previous call to open. Both standard output from the 
  6588.            last command and standard error from all commands are redirected to 
  6589.            fileId's file. The file must have been opened for writing. 
  6590.  
  6591.  If standard output has not been redirected then the exec command returns the 
  6592.  standard output from the last command in the pipeline. If any of the commands 
  6593.  in the pipeline exit abnormally or are killed or suspended, then exec will 
  6594.  return an error and the error message will include the pipeline's output 
  6595.  followed by error messages describing the abnormal terminations; the errorCode 
  6596.  variable will contain additional information about the last abnormal 
  6597.  termination encountered. If any of the commands writes to its standard error 
  6598.  file and that standard error isn't redirected, then exec will return an error; 
  6599.  the error message will include the pipeline's standard output, followed by 
  6600.  messages about abnormal terminations (if any), followed by the standard error 
  6601.  output. 
  6602.  
  6603.  If the last character of the result or error message is a newline then that 
  6604.  character is normally deleted from the result or error message. This is 
  6605.  consistent with other Tcl return values, which don't normally end with 
  6606.  newlines. However, if -keepnewline is specified then the trailing newline is 
  6607.  retained. 
  6608.  
  6609.  If standard input isn't redirected with "<" or "<<" or "<@" then the standard 
  6610.  input for the first command in the pipeline is taken from the application's 
  6611.  current standard input. 
  6612.  
  6613.  If the last arg is "&" then the pipeline will be executed in background. In 
  6614.  this case the exec command will return a list whose elements are the process 
  6615.  identifiers for all of the subprocesses in the pipeline. The standard output 
  6616.  from the last command in the pipeline will go to the application's standard 
  6617.  output if it hasn't been redirected, and error output from all of the commands 
  6618.  in the pipeline will go to the application's standard error file unless 
  6619.  redirected. 
  6620.  
  6621.  The first word in each command is taken as the command name; 
  6622.  tilde-substitution is performed on it, and if the result contains no slashes 
  6623.  then the directories in the PATH environment variable are searched for an 
  6624.  executable by the given name. If the name contains a slash then it must refer 
  6625.  to an executable reachable from the current directory. No "glob" expansion or 
  6626.  other shell-like substitutions are performed on the arguments to commands. 
  6627.  
  6628.  PORTABILITY ISSUES 
  6629.  
  6630.  Windows (all versions)  Reading from or writing to a socket, using the "@ 
  6631.            fileId" notation, does not work.  When reading from a socket, a 
  6632.            16-bit DOS application will hang and a 32-bit application will 
  6633.            return immediately with end-of-file.  When either type of 
  6634.            application writes to a socket, the information is instead sent to 
  6635.            the console, if one is present, or is discarded. 
  6636.             The Tk console text widget does not provide real standard IO 
  6637.            capabilities. Under Tk, when redirecting from standard input, all 
  6638.            applications will see an immediate end-of-file; information 
  6639.            redirected to standard output or standard error will be discarded. 
  6640.             Either forward or backward slashes are accepted as path separators 
  6641.            for arguments to Tcl commands.  When executing an application, the 
  6642.            path name specified for the application may also contain forward or 
  6643.            backward slashes as path separators.  Bear in mind, however, that 
  6644.            most Windows applications accept arguments with forward slashes only 
  6645.            as option delimiters and backslashes only in paths.  Any arguments 
  6646.            to an application that specify a path name with forward slashes will 
  6647.            not automatically be converted to use the backslash character.  If 
  6648.            an argument contains forward slashes as the path separator, it may 
  6649.            or may not be recognized as a path name, depending on the program. 
  6650.             Additionally, when calling a 16-bit DOS or Windows 3.X application, 
  6651.            all path names must use the short, cryptic, path format (e.g., using 
  6652.            "applba~1.def" instead of "applbakery.default"). 
  6653.             Two or more forward or backward slashes in a row in a path refer to 
  6654.            a network path.  For example, a simple concatenation of the root 
  6655.            directory c:/ with a subdirectory /windows/system will yield 
  6656.            c://windows/system (two slashes together), which refers to the 
  6657.            directory /system on the machine windows (and the c:/ is ignored), 
  6658.            and is not equivalent to c:/windows/system, which describes a 
  6659.            directory on the current computer. 
  6660.  
  6661.  Windows NT  When attempting to execute an application, exec first searches for 
  6662.            the name as it was specified.  Then, in order, .com, .exe, and .bat 
  6663.            are appended to the end of the specified name and it searches for 
  6664.            the longer name.  If a directory name was not specified as part of 
  6665.            the application name, the following directories are automatically 
  6666.            searched in order when attempting to locate the application: 
  6667.             The directory from which the Tcl executable was loaded. 
  6668.             The current directory. 
  6669.             The Windows NT 32-bit system directory. 
  6670.             The Windows NT 16-bit system directory. 
  6671.             The Windows NT home directory. 
  6672.             The directories listed in the path. 
  6673.             In order to execute the shell builtin commands like dir and copy, 
  6674.            the caller must prepend "cmd.exe /c " to the desired command. 
  6675.  
  6676.  Windows 95  When attempting to execute an application, exec first searches for 
  6677.            the name as it was specified.  Then, in order, .com, .exe, and .bat 
  6678.            are appended to the end of the specified name and it searches for 
  6679.            the longer name.  If a directory name was not specified as part of 
  6680.            the application name, the following directories are automatically 
  6681.            searched in order when attempting to locate the application: 
  6682.             The directory from which the Tcl executable was loaded. 
  6683.             The current directory. 
  6684.             The Windows 95 system directory. 
  6685.             The Windows 95 home directory. 
  6686.             The directories listed in the path. 
  6687.             In order to execute the shell builtin commands like dir and copy, 
  6688.            the caller must prepend "command.com /c " to the desired command. 
  6689.             Once a 16-bit DOS application has read standard input from a 
  6690.            console and then quit, all subsequently run 16-bit DOS applications 
  6691.            will see the standard input as already closed.  32-bit applications 
  6692.            do not have this problem and will run correctly even after a 16-bit 
  6693.            DOS application thinks that standard input is closed.  There is no 
  6694.            known workaround for this bug at this time. 
  6695.             Redirection between the NUL: device and a 16-bit application does 
  6696.            not always work.  When redirecting from NUL:, some applications may 
  6697.            hang, others will get an infinite stream of "0x01" bytes, and some 
  6698.            will actually correctly get an immediate end-of-file; the behavior 
  6699.            seems to depend upon something compiled into the application itself. 
  6700.            When redirecting greater than 4K or so to NUL:, some applications 
  6701.            will hang.  The above problems do not happen with 32-bit 
  6702.            applications. 
  6703.             All DOS 16-bit applications are run synchronously.  All standard 
  6704.            input from a pipe to a 16-bit DOS application is collected into a 
  6705.            temporary file; the other end of the pipe must be closed before the 
  6706.            16-bit DOS application begins executing.  All standard output or 
  6707.            error from a 16-bit DOS application to a pipe is collected into 
  6708.            temporary files; the application must terminate before the temporary 
  6709.            files are redirected to the next stage of the pipeline.  This is due 
  6710.            to a workaround for a Windows 95 bug in the implementation of pipes, 
  6711.            and is how the Windows 95 command line interpreter handles pipes 
  6712.            itself. 
  6713.             Certain applications, such as command.com, should not be executed 
  6714.            interactively.  Applications which directly access the console 
  6715.            window, rather than reading from their standard input and writing to 
  6716.            their standard output may fail, hang Tcl, or even hang the system if 
  6717.            their own private console window is not available to them. 
  6718.  
  6719.  Windows 3.X  When attempting to execute an application, exec first searches 
  6720.            for the name as it was specified.  Then, in order, .com, .exe, and 
  6721.            .bat are appended to the end of the specified name and it searches 
  6722.            for the longer name.  If a directory name was not specified as part 
  6723.            of the application name, the following directories are automatically 
  6724.            searched in order when attempting to locate the application: 
  6725.             The directory from which the Tcl executable was loaded. 
  6726.             The current directory. 
  6727.             The Windows 3.X system directory. 
  6728.             The Windows 3.X home directory. 
  6729.             The directories listed in the path. 
  6730.             In order to execute the shell builtin commands like dir and copy, 
  6731.            the caller must prepend "command.com /c " to the desired command. 
  6732.             16-bit and 32-bit DOS and Windows applications may be executed. 
  6733.            However, redirection and piping of standard IO only works with 
  6734.            16-bit DOS applications.  32-bit applications always see standard 
  6735.            input as already closed, and any standard output or error is 
  6736.            discarded, no matter where in the pipeline the application occurs or 
  6737.            what redirection symbols are used by the caller.  Additionally, for 
  6738.            16-bit applications, standard error is always sent to the same place 
  6739.            as standard output; it cannot be redirected to a separate location. 
  6740.            In order to achieve pseudo-redirection for 32-bit applications, the 
  6741.            32-bit application must instead be written to take command line 
  6742.            arguments that specify the files that it should read from and write 
  6743.            to and open those files itself. 
  6744.             All applications, both 16-bit and 32-bit, run synchronously; each 
  6745.            application runs to completion before the next one in the pipeline 
  6746.            starts.  Temporary files are used to simulate piping between 
  6747.            applications.  The exec command cannot be used to start an 
  6748.            application in the background. 
  6749.             When standard input is redirected from an open file using the "@ 
  6750.            fileId" notation, the open file is completely read up to its end. 
  6751.            This is slightly different than under Windows 95 or NT, where the 
  6752.            child application consumes from the open file only as much as it 
  6753.            wants. Redirecting to an open file is supported as normal. 
  6754.  
  6755.  Macintosh  The exec command is not implemented and does not exist under 
  6756.            Macintosh. 
  6757.  
  6758.  Unix      The exec command is fully functional and works as described. 
  6759.  
  6760.  SEE ALSO 
  6761.  
  6762.  open(n) 
  6763.  
  6764.  KEYWORDS 
  6765.  
  6766.  execute, pipeline, redirection, subprocess 
  6767.  
  6768.  
  6769. ΓòÉΓòÉΓòÉ 3.18. exit ΓòÉΓòÉΓòÉ
  6770.  
  6771.  NAME 
  6772.  
  6773. exit - End the application 
  6774.  
  6775. SYNOPSIS 
  6776.  
  6777. exit ?returnCode? 
  6778.  
  6779. DESCRIPTION 
  6780.  
  6781. Terminate the process, returning returnCode to the system as the exit status. 
  6782. If returnCode isn't specified then it defaults to 0. 
  6783.  
  6784. KEYWORDS 
  6785.  
  6786. exit, process 
  6787.  
  6788.  
  6789. ΓòÉΓòÉΓòÉ 3.19. expr ΓòÉΓòÉΓòÉ
  6790.  
  6791.  NAME 
  6792.  
  6793. expr - Evaluate an expression 
  6794.  
  6795. SYNOPSIS 
  6796.  
  6797. expr arg ?arg arg ...? 
  6798.  
  6799. DESCRIPTION 
  6800.  
  6801. Concatenates arg's (adding separator spaces between them), evaluates the result 
  6802. as a Tcl expression, and returns the value. The operators permitted in Tcl 
  6803. expressions are a subset of the operators permitted in C expressions, and they 
  6804. have the same meaning and precedence as the corresponding C operators. 
  6805. Expressions almost always yield numeric results (integer or floating-point 
  6806. values). For example, the expression 
  6807.  
  6808. expr 8.2 + 6
  6809. evaluates to 14.2. Tcl expressions differ from C expressions in the way that 
  6810. operands are specified.  Also, Tcl expressions support non-numeric operands and 
  6811. string comparisons. 
  6812.  
  6813. OPERANDS 
  6814.  
  6815. A Tcl expression consists of a combination of operands, operators, and 
  6816. parentheses. White space may be used between the operands and operators and 
  6817. parentheses; it is ignored by the expression processor. Where possible, 
  6818. operands are interpreted as integer values. Integer values may be specified in 
  6819. decimal (the normal case), in octal (if the first character of the operand is 
  6820. 0), or in hexadecimal (if the first two characters of the operand are 0x). If 
  6821. an operand does not have one of the integer formats given above, then it is 
  6822. treated as a floating-point number if that is possible.  Floating-point numbers 
  6823. may be specified in any of the ways accepted by an ANSI-compliant C compiler 
  6824. (except that the "f", "F", "l", and "L" suffixes will not be permitted in most 
  6825. installations).  For example, all of the following are valid floating-point 
  6826. numbers:  2.1, 3., 6e4, 7.91e+16. If no numeric interpretation is possible, 
  6827. then an operand is left as a string (and only a limited set of operators may be 
  6828. applied to it). 
  6829.  
  6830. Operands may be specified in any of the following ways: 
  6831.  
  6832.    1. As an numeric value, either integer or floating-point. 
  6833.  
  6834.    2. As a Tcl variable, using standard $ notation. The variable's value will 
  6835.       be used as the operand. 
  6836.  
  6837.    3. As a string enclosed in double-quotes. The expression parser will perform 
  6838.       backslash, variable, and command substitutions on the information between 
  6839.       the quotes, and use the resulting value as the operand 
  6840.  
  6841.    4. As a string enclosed in braces. The characters between the open brace and 
  6842.       matching close brace will be used as the operand without any 
  6843.       substitutions. 
  6844.  
  6845.    5. As a Tcl command enclosed in brackets. The command will be executed and 
  6846.       its result will be used as the operand. 
  6847.  
  6848.    6. As a mathematical function whose arguments have any of the above forms 
  6849.       for operands, such as "sin($x)".  See below for a list of defined 
  6850.       functions. 
  6851.  
  6852.  Where substitutions occur above (e.g. inside quoted strings), they are 
  6853.  performed by the expression processor. However, an additional layer of 
  6854.  substitution may already have been performed by the command parser before the 
  6855.  expression processor was called. As discussed below, it is usually best to 
  6856.  enclose expressions in braces to prevent the command parser from performing 
  6857.  substitutions on the contents. 
  6858.  
  6859.  For some examples of simple expressions, suppose the variable a has the value 
  6860.  3 and the variable b has the value 6. Then the command on the left side of 
  6861.  each of the lines below will produce the value on the right side of the line: 
  6862.  
  6863.   expr 3.1 + $a                    6.1
  6864.   expr 2 + "$a.$b"                 5.6
  6865.   expr 4*[llength "6 2"]           8
  6866.   expr {{word one} < "word $a"}    0
  6867.  
  6868.  OPERATORS 
  6869.  
  6870.  The valid operators are listed below, grouped in decreasing order of 
  6871.  precedence: 
  6872.  
  6873.  -  +  ~  !  Unary minus, unary plus, bit-wise NOT, logical NOT.  None of these 
  6874.            operands may be applied to string operands, and bit-wise NOT may be 
  6875.            applied only to integers. 
  6876.  
  6877.  *  /  %   Multiply, divide, remainder.  None of these operands may be applied 
  6878.            to string operands, and remainder may be applied only to integers. 
  6879.            The remainder will always have the same sign as the divisor and an 
  6880.            absolute value smaller than the divisor. 
  6881.  
  6882.  +  -      Add and subtract.  Valid for any numeric operands. 
  6883.  
  6884.  <<  >>    Left and right shift.  Valid for integer operands only. A right 
  6885.            shift always propagates the sign bit. 
  6886.  
  6887.  <  >  <=  >=  Boolean less, greater, less than or equal, and greater than or 
  6888.            equal. Each operator produces 1 if the condition is true, 0 
  6889.            otherwise. These operators may be applied to strings as well as 
  6890.            numeric operands, in which case string comparison is used. 
  6891.  
  6892.  ==  !=    Boolean equal and not equal.  Each operator produces a zero/one 
  6893.            result. Valid for all operand types. 
  6894.  
  6895.  &         Bit-wise AND.  Valid for integer operands only. 
  6896.  
  6897.  ^         Bit-wise exclusive OR.  Valid for integer operands only. 
  6898.  
  6899.  |         Bit-wise OR.  Valid for integer operands only. 
  6900.  
  6901.  &&        Logical AND.  Produces a 1 result if both operands are non-zero, 0 
  6902.            otherwise. Valid for numeric operands only (integers or 
  6903.            floating-point). 
  6904.  
  6905.  ||        Logical OR.  Produces a 0 result if both operands are zero, 1 
  6906.            otherwise. Valid for numeric operands only (integers or 
  6907.            floating-point). 
  6908.  
  6909.  x?y:z     If-then-else, as in C.  If x evaluates to non-zero, then the result 
  6910.            is the value of y. Otherwise the result is the value of z. The x 
  6911.            operand must have a numeric value. 
  6912.  
  6913.  See the C manual for more details on the results produced by each operator. 
  6914.  All of the binary operators group left-to-right within the same precedence 
  6915.  level.  For example, the command 
  6916.  
  6917.   expr 4*2 < 7
  6918.  returns 0. 
  6919.  
  6920.  The &&, ||, and ?: operators have "lazy evaluation", just as in C, which means 
  6921.  that operands are not evaluated if they are not needed to determine the 
  6922.  outcome.  For example, in the command 
  6923.  
  6924.   expr {$v ? [a] : [b]}
  6925.  only one of [a] or [b] will actually be evaluated, depending on the value of 
  6926.  $v.  Note, however, that this is only true if the entire expression is 
  6927.  enclosed in braces;  otherwise the Tcl parser will evaluate both [a] and [b] 
  6928.  before invoking the expr command. 
  6929.  
  6930.  MATH FUNCTIONS 
  6931.  
  6932.  Tcl supports the following mathematical functions in expressions: 
  6933.  
  6934.   acos             cos              hypot            sinh
  6935.   asin             cosh             log              sqrt
  6936.   atan             exp              log10            tan
  6937.   atan2            floor            pow              tanh
  6938.   ceil             fmod             sin
  6939.  Each of these functions invokes the math library function of the same name; 
  6940.  see the manual entries for the library functions for details on what they do. 
  6941.  Tcl also implements the following functions for conversion between integers 
  6942.  and floating-point numbers: 
  6943.  
  6944.  abs(arg)  Returns the absolute value of arg.  Arg may be either integer or 
  6945.            floating-point, and the result is returned in the same form. 
  6946.  
  6947.  double(arg)  If arg is a floating value, returns arg, otherwise converts arg 
  6948.            to floating and returns the converted value. 
  6949.  
  6950.  int(arg)  If arg is an integer value, returns arg, otherwise converts arg to 
  6951.            integer by truncation and returns the converted value. 
  6952.  
  6953.  round(arg)  If arg is an integer value, returns arg, otherwise converts arg to 
  6954.            integer by rounding and returns the converted value. 
  6955.  
  6956.  In addition to these predefined functions, applications may define additional 
  6957.  functions using Tcl_CreateMathFunc(). 
  6958.  
  6959.  TYPES, OVERFLOW, AND PRECISION 
  6960.  
  6961.  All internal computations involving integers are done with the C type long, 
  6962.  and all internal computations involving floating-point are done with the C 
  6963.  type double. When converting a string to floating-point, exponent overflow is 
  6964.  detected and results in a Tcl error. For conversion to integer from string, 
  6965.  detection of overflow depends on the behavior of some routines in the local C 
  6966.  library, so it should be regarded as unreliable. In any case, integer overflow 
  6967.  and underflow are generally not detected reliably for intermediate results. 
  6968.  Floating-point overflow and underflow are detected to the degree supported by 
  6969.  the hardware, which is generally pretty reliable. 
  6970.  
  6971.  Conversion among internal representations for integer, floating-point, and 
  6972.  string operands is done automatically as needed. For arithmetic computations, 
  6973.  integers are used until some floating-point number is introduced, after which 
  6974.  floating-point is used. For example, 
  6975.  
  6976.   expr 5 / 4
  6977.  returns 1, while 
  6978.  
  6979.   expr 5 / 4.0
  6980.   expr 5 / ( [string length "abcd"] + 0.0 )
  6981.  both return 1.25. Floating-point values are always returned with a "." or an 
  6982.  "e" so that they will not look like integer values.  For example, 
  6983.  
  6984.   expr 20.0/5.0
  6985.  returns "4.0", not "4".  The global variable tcl_precision determines the 
  6986.  number of significant digits that are retained when floating values are 
  6987.  converted to strings (except that trailing zeroes are omitted).  If 
  6988.  tcl_precision is unset then 6 digits of precision are used. To retain all of 
  6989.  the significant bits of an IEEE floating-point number set tcl_precision to 17; 
  6990.  if a value is converted to string with 17 digits of precision and then 
  6991.  converted back to binary for some later calculation, the resulting binary 
  6992.  value is guaranteed to be identical to the original one. 
  6993.  
  6994.  STRING OPERATIONS 
  6995.  
  6996.  String values may be used as operands of the comparison operators, although 
  6997.  the expression evaluator tries to do comparisons as integer or floating-point 
  6998.  when it can. If one of the operands of a comparison is a string and the other 
  6999.  has a numeric value, the numeric operand is converted back to a string using 
  7000.  the C sprintf format specifier %d for integers and %g for floating-point 
  7001.  values. For example, the commands 
  7002.  
  7003.   expr {"0x03" > "2"}
  7004.   expr {"0y" < "0x12"}
  7005.  both return 1.  The first comparison is done using integer comparison, and the 
  7006.  second is done using string comparison after the second operand is converted 
  7007.  to the string "18". Because of Tcl's tendency to treat values as numbers 
  7008.  whenever possible, it isn't generally a good idea to use operators like == 
  7009.  when you really want string comparison and the values of the operands could be 
  7010.  arbitrary;  it's better in these cases to use the string compare command 
  7011.  instead. 
  7012.  
  7013.  KEYWORDS 
  7014.  
  7015.  arithmetic, boolean, compare, expression 
  7016.  
  7017.  
  7018. ΓòÉΓòÉΓòÉ 3.20. fblocked ΓòÉΓòÉΓòÉ
  7019.  
  7020.  NAME 
  7021.  
  7022. fblocked - Test whether the last input operation exhausted all available input 
  7023.  
  7024. SYNOPSIS 
  7025.  
  7026. fblocked channelId 
  7027.  
  7028. DESCRIPTION 
  7029.  
  7030. The fblocked command returns 1 if the most recent input operation on channelId 
  7031. returned less information than requested because all available input was 
  7032. exhausted. For example, if gets is invoked when there are only three characters 
  7033. available for input and no end-of-line sequence, gets returns an empty string 
  7034. and a subsequent call to fblocked will return 1. 
  7035.  
  7036. SEE ALSO 
  7037.  
  7038. gets(n), read(n) 
  7039.  
  7040. KEYWORDS 
  7041.  
  7042. blocking, nonblocking 
  7043.  
  7044.  
  7045. ΓòÉΓòÉΓòÉ 3.21. fconfigure ΓòÉΓòÉΓòÉ
  7046.  
  7047.  NAME 
  7048.  
  7049. fconfigure - Set and get options on a channel 
  7050.  
  7051. SYNOPSIS 
  7052.  
  7053. fconfigure channelId 
  7054.  fconfigure channelId name 
  7055.  fconfigure channelId name value ?name value ...? 
  7056.  
  7057. DESCRIPTION 
  7058.  
  7059. The fconfigure command sets and retrieves options for channels. ChannelId 
  7060. identifies the channel for which to set or query an option. If no name or value 
  7061. arguments are supplied, the command returns a list containing alternating 
  7062. option names and values for the channel. If name is supplied but no value then 
  7063. the command returns the current value of the given option. If one or more pairs 
  7064. of name and value are supplied, the command sets each of the named options to 
  7065. the corresponding value; in this case the return value is an empty string. 
  7066.  
  7067. The options described below are supported for all channels. In addition, each 
  7068. channel type may add options that only it supports. See the manual entry for 
  7069. the command that creates each type of channels for the options that that 
  7070. specific type of channel supports. For example, see the manual entry for the 
  7071. socket command for its additional options. 
  7072.  
  7073.  -blocking boolean  The -blocking option determines whether I/O operations on 
  7074.            the channel can cause the process to block indefinitely. The value 
  7075.            of the option must be a proper boolean value. Channels are normally 
  7076.            in blocking mode;  if a channel is placed into nonblocking mode it 
  7077.            will affect the operation of the gets, read, puts, flush, and close 
  7078.            commands; see the documentation for those commands for details. For 
  7079.            nonblocking mode to work correctly, the application must be using 
  7080.            the Tcl event loop (e.g. by calling Tcl_DoOneEvent or invoking the 
  7081.            vwait command). 
  7082.  
  7083.  -buffering newValue  If newValue is full then the I/O system will buffer 
  7084.            output until its internal buffer is full or until the flush command 
  7085.            is invoked. If newValue is line, then the I/O system will 
  7086.            automatically flush output for the channel whenever a newline 
  7087.            character is output. If newValue is none, the I/O system will flush 
  7088.            automatically after every output operation. The default is for 
  7089.            -buffering to be set to full except for channels that connect to 
  7090.            terminal-like devices; for these channels the initial setting is 
  7091.            line. 
  7092.  
  7093.  -buffersize newSize  Newvalue must be an integer; its value is used to set the 
  7094.            size of buffers, in bytes, subsequently allocated for this channel 
  7095.            to store input or output. Newvalue must be between ten and one 
  7096.            million, allowing buffers of ten to one million bytes in size. 
  7097.  
  7098.  -eofchar char 
  7099.  
  7100.  -eofchar {inChar outChar}  This option supports DOS file systems that use 
  7101.            Control-z (\x1a) as an end of file marker. If char is not an empty 
  7102.            string, then this character signals end of file when it is 
  7103.            encountered during input. For output, the end of file character is 
  7104.            output when the channel is closed. If char is the empty string, then 
  7105.            there is no special end of file character marker. For read-write 
  7106.            channels, a two-element list specifies the end of file marker for 
  7107.            input and output, respectively. As a convenience, when setting the 
  7108.            end-of-file character for a read-write channel you can specify a 
  7109.            single value that will apply to both reading and writing. When 
  7110.            querying the end-of-file character of a read-write channel, a 
  7111.            two-element list will always be returned. The default value for 
  7112.            -eofchar is the empty string in all cases except for files under 
  7113.            Windows.  In that case the -eofchar is Control-z (\x1a) for reading 
  7114.            and the empty string for writing. 
  7115.  
  7116.  -translation mode 
  7117.  
  7118.  -translation {inMode outMode}  In Tcl scripts the end of a line is always 
  7119.            represented using a single newline character (\n). However, in 
  7120.            actual files and devices the end of a line may be represented 
  7121.            differently on different platforms, or even for different devices on 
  7122.            the same platform.  For example, under UNIX newlines are used in 
  7123.            files, whereas carriage-return-linefeed sequences are normally used 
  7124.            in network connections. On input (i.e., with gets and read) the Tcl 
  7125.            I/O system automatically translates the external end-of-line 
  7126.            representation into newline characters. Upon output (i.e., with 
  7127.            puts), the I/O system translates newlines to the external 
  7128.            end-of-line representation. The default translation mode, auto, 
  7129.            handles all the common cases automatically, but the -translation 
  7130.            option provides explicit control over the end of line translations. 
  7131.  
  7132.            The value associated with -translation is a single item for 
  7133.            read-only and write-only channels. The value is a two-element list 
  7134.            for read-write channels; the read translation mode is the first 
  7135.            element of the list, and the write translation mode is the second 
  7136.            element. As a convenience, when setting the translation mode for a 
  7137.            read-write channel you can specify a single value that will apply to 
  7138.            both reading and writing. When querying the translation mode of a 
  7139.            read-write channel, a two-element list will always be returned. The 
  7140.            following values are currently supported: 
  7141.  
  7142.            auto           As the input translation mode, auto treats any of 
  7143.                           newline (lf), carriage return (cr), or carriage 
  7144.                           return followed by a newline (crlf) as the end of 
  7145.                           line representation.  The end of line representation 
  7146.                           can even change from line-to-line, and all cases are 
  7147.                           translated to a newline. As the output translation 
  7148.                           mode, auto chooses a platform specific 
  7149.                           representation; for sockets on all platforms Tcl 
  7150.                           chooses crlf, for all Unix flavors, it chooses lf, 
  7151.                           for the Macintosh platform it chooses cr and for the 
  7152.                           various flavors of Windows it chooses crlf. The 
  7153.                           default setting for -translation is auto for both 
  7154.                           input and output. 
  7155.  
  7156.            binary         No end-of-line translations are performed.  This is 
  7157.                           nearly identical to lf mode, except that in addition 
  7158.                           binary mode also sets the end of file character to 
  7159.                           the empty string, which disables it. See the 
  7160.                           description of -eofchar for more information. 
  7161.  
  7162.            cr             The end of a line in the underlying file or device is 
  7163.                           represented by a single carriage return character. As 
  7164.                           the input translation mode, cr mode converts carriage 
  7165.                           returns to newline characters. As the output 
  7166.                           translation mode, cr mode translates newline 
  7167.                           characters to carriage returns. This mode is 
  7168.                           typically used on Macintosh platforms. 
  7169.  
  7170.            crlf           The end of a line in the underlying file or device is 
  7171.                           represented by a carriage return character followed 
  7172.                           by a linefeed character. As the input translation 
  7173.                           mode, crlf mode converts carriage-return-linefeed 
  7174.                           sequences to newline characters. As the output 
  7175.                           translation mode, crlf mode translates newline 
  7176.                           characters to carriage-return-linefeed sequences. 
  7177.                           This mode is typically used on Windows platforms and 
  7178.                           for network connections. 
  7179.  
  7180.            lf             The end of a line in the underlying file or device is 
  7181.                           represented by a single newline (linefeed) character. 
  7182.                           In this mode no translations occur during either 
  7183.                           input or output. This mode is typically used on UNIX 
  7184.                           platforms. 
  7185.  
  7186.  SEE ALSO 
  7187.  
  7188.  close(n), flush(n), gets(n), puts(n), read(n), socket(n) 
  7189.  
  7190.  KEYWORDS 
  7191.  
  7192.  blocking, buffering, carriage return, end of line, flushing, linemode, 
  7193.  newline, nonblocking, platform, translation 
  7194.  
  7195.  
  7196. ΓòÉΓòÉΓòÉ 3.22. file ΓòÉΓòÉΓòÉ
  7197.  
  7198.  NAME 
  7199.  
  7200. file - Manipulate file names and attributes 
  7201.  
  7202. SYNOPSIS 
  7203.  
  7204. file option name ?arg arg ...? 
  7205.  
  7206. DESCRIPTION 
  7207.  
  7208. This command provides several operations on a file's name or attributes. Name 
  7209. is the name of a file; if it starts with a tilde, then tilde substitution is 
  7210. done before executing the command (see the manual entry for filename for 
  7211. details).  Option indicates what to do with the file name.  Any unique 
  7212. abbreviation for option is acceptable.  The valid options are: 
  7213.  
  7214.  file atime name  Returns a decimal string giving the time at which file name 
  7215.            was last accessed.  The time is measured in the standard POSIX 
  7216.            fashion as seconds from a fixed starting time (often January 1, 
  7217.            1970). If the file doesn't exist or its access time cannot be 
  7218.            queried then an error is generated. 
  7219.  
  7220.  file copy ?-force? ?--? source target 
  7221.   file copy ?-force? ?--? source ?source ...? targetDir The first form makes a 
  7222.  copy of the file or directory source under the pathname target.  If target is 
  7223.  an existing directory, then the second form is used.  The second form makes a 
  7224.  copy inside targetDir of each source file listed.  If a directory is specified 
  7225.  as a source, then the contents of the directory will be recursively copied 
  7226.  into targetDir.  Existing files will not be overwritten unless the -force 
  7227.  option is specified.  Trying to overwrite a non-empty directory, overwrite a 
  7228.  directory with a file, or a file with a directory will all result in errors 
  7229.  even if -force was specified.  Arguments are processed in the order specified, 
  7230.  halting at the first error, if any.  A -- marks the end of switches; the 
  7231.  argument following the -- will be treated as a source even if it starts with a 
  7232.  -. 
  7233.  
  7234.  file delete ?-force? ?--? pathname ?pathname ... ?  Removes the file or 
  7235.            directory specified by each pathname argument. Non-empty directories 
  7236.            will be removed only if the -force option is specified.  Trying to 
  7237.            delete a non-existant file is not considered an error.  Trying to 
  7238.            delete a read-only file will cause the file to be deleted, even if 
  7239.            the -force flags is not specified.  Arguments are processed in the 
  7240.            order specified, halting at the first error, if any.  A -- marks the 
  7241.            end of switches; the argument following the -- will be treated as a 
  7242.            pathname even if it starts with a -. 
  7243.  
  7244.  file dirname name  Returns a name comprised of all of the path components in 
  7245.            name excluding the last element.  If name is a relative file name 
  7246.            and only contains one path element, then returns "." (or ":" on the 
  7247.            Macintosh).  If name refers to a root directory, then the root 
  7248.            directory is returned.  For example, 
  7249.  
  7250.                       file dirname c:/
  7251.            returns c:/. 
  7252.  
  7253.            Note that tilde substitution will only be performed if it is 
  7254.            necessary to complete the command. For example, 
  7255.  
  7256.                       file dirname ~/src/foo.c
  7257.            returns ~/src, whereas 
  7258.  
  7259.                       file dirname ~
  7260.            returns /home (or something similar). 
  7261.  
  7262.  file executable name  Returns 1 if file name is executable by the current 
  7263.            user, 0 otherwise. 
  7264.  
  7265.  file exists name  Returns 1 if file name exists and the current user has 
  7266.            search privileges for the directories leading to it, 0 otherwise. 
  7267.  
  7268.  file extension name  Returns all of the characters in name after and including 
  7269.            the last dot in the last element of name.  If there is no dot in the 
  7270.            last element of name then returns the empty string. 
  7271.  
  7272.  file isdirectory name  Returns 1 if file name is a directory, 0 otherwise. 
  7273.  
  7274.  file isfile name  Returns 1 if file name is a regular file, 0 otherwise. 
  7275.  
  7276.  file join name ?name ...?  Takes one or more file names and combines them, 
  7277.            using the correct path separator for the current platform.  If a 
  7278.            particular name is relative, then it will be joined to the previous 
  7279.            file name argument. Otherwise, any earlier arguments will be 
  7280.            discarded, and joining will proceed from the current argument.  For 
  7281.            example, 
  7282.  
  7283.                       file join a b /foo bar
  7284.            returns /foo/bar. 
  7285.  
  7286.            Note that any of the names can contain separators, and that the 
  7287.            result is always canonical for the current platform: / for Unix and 
  7288.            Windows, and : for Macintosh. 
  7289.  
  7290.  file lstat name varName  Same as stat option (see below) except uses the lstat 
  7291.            kernel call instead of stat.  This means that if name refers to a 
  7292.            symbolic link the information returned in varName is for the link 
  7293.            rather than the file it refers to.  On systems that don't support 
  7294.            symbolic links this option behaves exactly the same as the stat 
  7295.            option. 
  7296.  
  7297.  file mkdir dir ?dir ...?  Creates each directory specified.  For each pathname 
  7298.            dir specified, this command will create all non-existing parent 
  7299.            directories as well as dir itself.  If an existing directory is 
  7300.            specified, then no action is taken and no error is returned.  Trying 
  7301.            to overwrite an existing file with a directory will result in an 
  7302.            error.  Arguments are processed in the order specified, halting at 
  7303.            the first error, if any. 
  7304.  
  7305.  file mtime name  Returns a decimal string giving the time at which file name 
  7306.            was last modified.  The time is measured in the standard POSIX 
  7307.            fashion as seconds from a fixed starting time (often January 1, 
  7308.            1970).  If the file doesn't exist or its modified time cannot be 
  7309.            queried then an error is generated. 
  7310.  
  7311.  file owned name  Returns 1 if file name is owned by the current user, 0 
  7312.            otherwise. 
  7313.  
  7314.  file pathtype name  Returns one of absolute, relative, volumerelative.  If 
  7315.            name refers to a specific file on a specific volume, the path type 
  7316.            will be absolute.  If name refers to a file relative to the current 
  7317.            working directory, then the path type will be relative.  If name 
  7318.            refers to a file relative to the current working directory on a 
  7319.            specified volume, or to a specific file on the current working 
  7320.            volume, then the file type is volumerelative. 
  7321.  
  7322.  file readable name  Returns 1 if file name is readable by the current user, 0 
  7323.            otherwise. 
  7324.  
  7325.  file readlink name  Returns the value of the symbolic link given by name (i.e. 
  7326.            the name of the file it points to).  If name isn't a symbolic link 
  7327.            or its value cannot be read, then an error is returned.  On systems 
  7328.            that don't support symbolic links this option is undefined. 
  7329.  
  7330.  file rename ?-force? ?--? source target 
  7331.   file rename ?-force? ?--? source ?source ...? targetDir The first form takes 
  7332.  the file or directory specified by pathname source and renames it to target, 
  7333.  moving the file if the pathname target specifies a name in a different 
  7334.  directory.  If target is an existing directory, then the second form is used. 
  7335.  The second form moves each source file or directory into the directory 
  7336.  targetDir.  Existing files will not be overwritten unless the -force option is 
  7337.  specified.  Trying to overwrite a non-empty directory, overwrite a directory 
  7338.  with a file, or a file with a directory will all result in errors.  Arguments 
  7339.  are processed in the order specified, halting at the first error, if any.  A 
  7340.  -- marks the end of switches; the argument following the -- will be treated as 
  7341.  a source even if it starts with a -. 
  7342.  
  7343.  file rootname name  Returns all of the characters in name up to but not 
  7344.            including the last "." character in the last component of name.  If 
  7345.            the last component of name doesn't contain a dot, then returns name. 
  7346.  
  7347.  file size name  Returns a decimal string giving the size of file name in 
  7348.            bytes.  If the file doesn't exist or its size cannot be queried then 
  7349.            an error is generated. 
  7350.  
  7351.  file split name  Returns a list whose elements are the path components in 
  7352.            name.  The first element of the list will have the same path type as 
  7353.            name. All other elements will be relative.  Path separators will be 
  7354.            discarded unless they are needed ensure that an element is 
  7355.            unambiguously relative. For example, under Unix 
  7356.  
  7357.                       file split /foo/~bar/baz
  7358.            returns /  foo  ./~bar  baz to ensure that later commands that use 
  7359.            the third component do not attempt to perform tilde substitution. 
  7360.  
  7361.  file stat  name varName  Invokes the stat kernel call on name, and uses the 
  7362.            variable given by varName to hold information returned from the 
  7363.            kernel call. VarName is treated as an array variable, and the 
  7364.            following elements of that variable are set: atime, ctime, dev, gid, 
  7365.            ino, mode, mtime, nlink, size, type, uid.  Each element except type 
  7366.            is a decimal string with the value of the corresponding field from 
  7367.            the stat return structure; see the manual entry for stat for details 
  7368.            on the meanings of the values.  The type element gives the type of 
  7369.            the file in the same form returned by the command file type.  This 
  7370.            command returns an empty string. 
  7371.  
  7372.  file tail name  Returns all of the characters in name after the last directory 
  7373.            separator.  If name contains no separators then returns name. 
  7374.  
  7375.  file type name  Returns a string giving the type of file name, which will be 
  7376.            one of file, directory, characterSpecial, blockSpecial, fifo, link, 
  7377.            or socket. 
  7378.  
  7379.  file writable name  Returns 1 if file name is writable by the current user, 0 
  7380.            otherwise. 
  7381.  
  7382.  PORTABILITY ISSUES 
  7383.  
  7384.  Unix      These commands always operate using the real user and group 
  7385.            identifiers, not the effective ones. 
  7386.  
  7387.  SEE ALSO 
  7388.  
  7389.  filename 
  7390.  
  7391.  KEYWORDS 
  7392.  
  7393.  attributes, copy files, delete files, directory, file, move files, name, 
  7394.  rename files, stat 
  7395.  
  7396.  
  7397. ΓòÉΓòÉΓòÉ 3.23. fileevent ΓòÉΓòÉΓòÉ
  7398.  
  7399.  NAME 
  7400.  
  7401. fileevent - Execute a script when a channel becomes readable or writable 
  7402.  
  7403. SYNOPSIS 
  7404.  
  7405. fileevent channelId readable ?script? 
  7406.  fileevent channelId writable ?script? 
  7407.  
  7408. DESCRIPTION 
  7409.  
  7410. This command is used to create file event handlers.  A file event handler is a 
  7411. binding between a channel and a script, such that the script is evaluated 
  7412. whenever the channel becomes readable or writable.  File event handlers are 
  7413. most commonly used to allow data to be received from another process on an 
  7414. event-driven basis, so that the receiver can continue to interact with the user 
  7415. while waiting for the data to arrive.  If an application invokes gets or read 
  7416. on a blocking channel when there is no input data available, the process will 
  7417. block; until the input data arrives, it will not be able to service other 
  7418. events, so it will appear to the user to "freeze up".  With fileevent, the 
  7419. process can tell when data is present and only invoke gets or read when they 
  7420. won't block. 
  7421.  
  7422. The channelId argument to fileevent refers to an open channel, such as the 
  7423. return value from a previous open or socket command. If the script argument is 
  7424. specified, then fileevent creates a new event handler:  script will be 
  7425. evaluated whenever the channel becomes readable or writable (depending on the 
  7426. second argument to fileevent). In this case fileevent returns an empty string. 
  7427. The readable and writable event handlers for a file are independent, and may be 
  7428. created and deleted separately. However, there may be at most one readable and 
  7429. one writable handler for a file at a given time in a given interpreter. If 
  7430. fileevent is called when the specified handler already exists in the invoking 
  7431. interpreter, the new script replaces the old one. 
  7432.  
  7433. If the script argument is not specified, fileevent returns the current script 
  7434. for channelId, or an empty string if there is none. If the script argument is 
  7435. specified as an empty string then the event handler is deleted, so that no 
  7436. script will be invoked. A file event handler is also deleted automatically 
  7437. whenever its channel is closed or its interpreter is deleted. 
  7438.  
  7439. A channel is considered to be readable if there is unread data available on the 
  7440. underlying device. A channel is also considered to be readable if there is 
  7441. unread data in an input buffer, except in the special case where the most 
  7442. recent attempt to read from the channel was a gets call that could not find a 
  7443. complete line in the input buffer. This feature allows a file to be read a line 
  7444. at a time in nonblocking mode using events. A channel is also considered to be 
  7445. readable if an end of file or error condition is present on the underlying file 
  7446. or device. It is important for script to check for these conditions and handle 
  7447. them appropriately;  for example, if there is no special check for end of file, 
  7448. an infinite loop may occur where script reads no data, returns, and is 
  7449. immediately invoked again. 
  7450.  
  7451. A channel is considered to be writable if at least one byte of data can be 
  7452. written to the underlying file or device without blocking, or if an error 
  7453. condition is present on the underlying file or device. 
  7454.  
  7455. Event-driven I/O works best for channels that have been placed into nonblocking 
  7456. mode with the fconfigure command. In blocking mode, a puts command may block if 
  7457. you give it more data than the underlying file or device can accept, and a gets 
  7458. or read command will block if you attempt to read more data than is ready;  no 
  7459. events will be processed while the commands block. In nonblocking mode puts, 
  7460. read, and gets never block. See the documentation for the individual commands 
  7461. for information on how they handle blocking and nonblocking channels. 
  7462.  
  7463. The script for a file event is executed at global level (outside the context of 
  7464. any Tcl procedure) in the interpreter in which the fileevent command was 
  7465. invoked. If an error occurs while executing the script then the bgerror 
  7466. mechanism is used to report the error. In addition, the file event handler is 
  7467. deleted if it ever returns an error;  this is done in order to prevent infinite 
  7468. loops due to buggy handlers. 
  7469.  
  7470. CREDITS 
  7471.  
  7472. fileevent is based on the addinput command created by Mark Diekhans. 
  7473.  
  7474. SEE ALSO 
  7475.  
  7476. bgerror, fconfigure, gets, puts, read 
  7477.  
  7478. KEYWORDS 
  7479.  
  7480. asynchronous I/O, blocking, channel, event handler, nonblocking, readable, 
  7481. script, writable. 
  7482.  
  7483.  
  7484. ΓòÉΓòÉΓòÉ 3.24. filename ΓòÉΓòÉΓòÉ
  7485.  
  7486.  NAME 
  7487.  
  7488. filename - File name conventions supported by Tcl commands 
  7489.  
  7490. INTRODUCTION 
  7491.  
  7492. All Tcl commands and C procedures that take file names as arguments expect the 
  7493. file names to be in one of three forms, depending on the current platform.  On 
  7494. each platform, Tcl supports file names in the standard forms(s) for that 
  7495. platform.  In addition, on all platforms, Tcl supports a Unix-like syntax 
  7496. intended to provide a convenient way of constructing simple file names. 
  7497. However, scripts that are intended to be portable should not assume a 
  7498. particular form for file names. Instead, portable scripts must use the file 
  7499. split and file join commands to manipulate file names (see the file manual 
  7500. entry for more details). 
  7501.  
  7502. PATH TYPES 
  7503.  
  7504. File names are grouped into three general types based on the starting point for 
  7505. the path used to specify the file: absolute, relative, and volume-relative. 
  7506. Absolute names are completely qualified, giving a path to the file relative to 
  7507. a particular volume and the root directory on that volume.  Relative names are 
  7508. unqualified, giving a path to the file relative to the current working 
  7509. directory.  Volume-relative names are partially qualified, either giving the 
  7510. path relative to the root directory on the current volume, or relative to the 
  7511. current directory of the specified volume.  The file pathtype command can be 
  7512. used to determine the type of a given path. 
  7513.  
  7514. PATH SYNTAX 
  7515.  
  7516. The rules for native names depend on the value reported in the Tcl array 
  7517. element tcl_platform(platform): 
  7518.  
  7519.  mac       On Apple Macintosh systems, Tcl supports two forms of path names. 
  7520.            The normal Mac style names use colons as path separators.  Paths may 
  7521.            be relative or absolute, and file names may contain any character 
  7522.            other than colon.  A leading colon causes the rest of the path to be 
  7523.            interpreted relative to the current directory.  If a path contains a 
  7524.            colon that is not at the beginning, then the path is interpreted as 
  7525.            an absolute path.  Sequences of two or more colons anywhere in the 
  7526.            path are used to construct relative paths where :: refers to the 
  7527.            parent of the current directory, ::: refers to the parent of the 
  7528.            parent, and so forth. 
  7529.  
  7530.            In addition to Macintosh style names, Tcl also supports a subset of 
  7531.            Unix-like names.  If a path contains no colons, then it is 
  7532.            interpreted like a Unix path.  Slash is used as the path separator. 
  7533.            The file name . refers to the current directory, and .. refers to 
  7534.            the parent of the current directory.  However, some names like / or 
  7535.            /.. have no mapping, and are interpreted as Macintosh names.  In 
  7536.            general, commands that generate file names will return Macintosh 
  7537.            style names, but commands that accept file names will take both 
  7538.            Macintosh and Unix-style names. 
  7539.  
  7540.            The following examples illustrate various forms of path names: 
  7541.  
  7542.            :              Relative path to the current folder. 
  7543.  
  7544.            MyFile         Relative path to a file named MyFile in the current 
  7545.                           folder. 
  7546.  
  7547.            MyDisk:MyFile  Absolute path to a file named MyFile on the device 
  7548.                           named MyDisk. 
  7549.  
  7550.            :MyDir:MyFile  Relative path to a file name MyFile in a folder named 
  7551.                           MyDir in the current folder. 
  7552.  
  7553.            ::MyFile       Relative path to a file named MyFile in the folder 
  7554.                           above the current folder. 
  7555.  
  7556.            :::MyFile      Relative path to a file named MyFile in the folder 
  7557.                           two levels above the current folder. 
  7558.  
  7559.            /MyDisk/MyFile  Absolute path to a file named MyFile on the device 
  7560.                           named MyDisk. 
  7561.  
  7562.            ../MyFile      Relative path to a file named MyFile in the folder 
  7563.                           above the current folder. 
  7564.  
  7565.  unix      On Unix platforms, Tcl uses path names where the components are 
  7566.            separated by slashes.  Path names may be relative or absolute, and 
  7567.            file names may contain any character other than slash.  The file 
  7568.            names . and .. are special and refer to the current directory and 
  7569.            the parent of the current directory respectively.  Multiple adjacent 
  7570.            slash characters are interpreted as a single separator. The 
  7571.            following examples illustrate various forms of path names: 
  7572.  
  7573.            /              Absolute path to the root directory. 
  7574.  
  7575.            /etc/passwd    Absolute path to the file named passwd in the 
  7576.                           directory etc in the root directory. 
  7577.  
  7578.            .              Relative path to the current directory. 
  7579.  
  7580.            foo            Relative path to the file foo in the current 
  7581.                           directory. 
  7582.  
  7583.            foo/bar        Relative path to the file bar in the directory foo in 
  7584.                           the current directory. 
  7585.  
  7586.            ../foo         Relative path to the file foo in the directory above 
  7587.                           the current directory. 
  7588.  
  7589.  windows   On Microsoft Windows platforms, Tcl supports both drive-relative and 
  7590.            UNC style names.  Both / and \ may be used as directory separators 
  7591.            in either type of name.  Drive-relative names consist of an optional 
  7592.            drive specifier followed by an absolute or relative path.  UNC paths 
  7593.            follow the general form \\servername\sharename\path\file.  In both 
  7594.            forms, the file names . and .. are special and refer to the current 
  7595.            directory and the parent of the current directory respectively.  The 
  7596.            following examples illustrate various forms of path names: 
  7597.  
  7598.            \\Host\share/file  Absolute UNC path to a file called file in the 
  7599.                           root directory of the export point share on the host 
  7600.                           Host. 
  7601.  
  7602.            c:foo          Volume-relative path to a file foo in the current 
  7603.                           directory on drive c. 
  7604.  
  7605.            c:/foo         Absolute path to a file foo in the root directory of 
  7606.                           drive c. 
  7607.  
  7608.            foo\bar        Relative path to a file bar in the foo directory in 
  7609.                           the current directory on the current volume. 
  7610.  
  7611.            \foo           Volume-relative path to a file foo in the root 
  7612.                           directory of the current volume. 
  7613.  
  7614.  TILDE SUBSTITUTION 
  7615.  
  7616.  In addition to the file name rules described above, Tcl also supports 
  7617.  csh-style tilde substitution.  If a file name starts with a tilde, then the 
  7618.  file name will be interpreted as if the first element is replaced with the 
  7619.  location of the home directory for the given user.  If the tilde is followed 
  7620.  immediately by a separator, then the $HOME environment variable is 
  7621.  substituted.  Otherwise the characters between the tilde and the next 
  7622.  separator are taken as a user name, which is used to retrieve the user's home 
  7623.  directory for substitution. 
  7624.  
  7625.  The Macintosh and Windows platforms do not support tilde substitution when a 
  7626.  user name follows the tilde.  On these platforms, attempts to use a tilde 
  7627.  followed by a user name will generate an error.  File names that have a tilde 
  7628.  without a user name will be substituted using the $HOME environment variable, 
  7629.  just like for Unix. 
  7630.  
  7631.  PORTABILITY ISSUES 
  7632.  
  7633.  Not all file systems are case sensitive, so scripts should avoid code that 
  7634.  depends on the case of characters in a file name.  In addition, the character 
  7635.  sets allowed on different devices may differ, so scripts should choose file 
  7636.  names that do not contain special characters like: <>:"/\|.  The safest 
  7637.  approach is to use names consisting of alphanumeric characters only.  Also 
  7638.  Windows 3.1 only supports file names with a root of no more than 8 characters 
  7639.  and an extension of no more than 3 characters. 
  7640.  
  7641.  KEYWORDS 
  7642.  
  7643.  current directory, absolute file name, relative file name, volume-relative 
  7644.  file name, portability 
  7645.  
  7646.  
  7647. ΓòÉΓòÉΓòÉ 3.25. flush ΓòÉΓòÉΓòÉ
  7648.  
  7649.  NAME 
  7650.  
  7651. flush - Flush buffered output for a channel 
  7652.  
  7653. SYNOPSIS 
  7654.  
  7655. flush channelId 
  7656.  
  7657. DESCRIPTION 
  7658.  
  7659. Flushes any output that has been buffered for channelId. ChannelId must be a 
  7660. channel identifier such as returned by a previous open or socket command, and 
  7661. it must have been opened for writing. If the channel is in blocking mode the 
  7662. command does not return until all the buffered output has been flushed to the 
  7663. channel. If the channel is in nonblocking mode, the command may return before 
  7664. all buffered output has been flushed; the remainder will be flushed in the 
  7665. background as fast as the underlying file or device is able to absorb it. 
  7666.  
  7667. SEE ALSO 
  7668.  
  7669. open(n), socket(n) 
  7670.  
  7671. KEYWORDS 
  7672.  
  7673. blocking, buffer, channel, flush, nonblocking, output 
  7674.  
  7675.  
  7676. ΓòÉΓòÉΓòÉ 3.26. for ΓòÉΓòÉΓòÉ
  7677.  
  7678.  NAME 
  7679.  
  7680. for - "For" loop 
  7681.  
  7682. SYNOPSIS 
  7683.  
  7684. for start test next body 
  7685.  
  7686. DESCRIPTION 
  7687.  
  7688. For is a looping command, similar in structure to the C for statement.  The 
  7689. start, next, and body arguments must be Tcl command strings, and test is an 
  7690. expression string. The for command first invokes the Tcl interpreter to execute 
  7691. start.  Then it repeatedly evaluates test as an expression; if the result is 
  7692. non-zero it invokes the Tcl interpreter on body, then invokes the Tcl 
  7693. interpreter on next, then repeats the loop.  The command terminates when test 
  7694. evaluates to 0.  If a continue command is invoked within body then any 
  7695. remaining commands in the current execution of body are skipped; processing 
  7696. continues by invoking the Tcl interpreter on next, then evaluating test, and so 
  7697. on.  If a break command is invoked within body or next, then the for command 
  7698. will return immediately. The operation of break and continue are similar to the 
  7699. corresponding statements in C. For returns an empty string. 
  7700.  
  7701. KEYWORDS 
  7702.  
  7703. for, iteration, looping 
  7704.  
  7705.  
  7706. ΓòÉΓòÉΓòÉ 3.27. foreach ΓòÉΓòÉΓòÉ
  7707.  
  7708.  NAME 
  7709.  
  7710. foreach - Iterate over all elements in one or more lists 
  7711.  
  7712. SYNOPSIS 
  7713.  
  7714. foreach varname list body 
  7715.  foreach varlist1 list1 ?varlist2 list2 ...? body 
  7716.  
  7717. DESCRIPTION 
  7718.  
  7719. The foreach command implements a loop where the loop variable(s) take on values 
  7720. from one or more lists. In the simplest case there is one loop variable, 
  7721. varname, and one list, list, that is a list of values to assign to varname. The 
  7722. body argument is a Tcl script. For each element of list (in order from first to 
  7723. last), foreach assigns the contents of the element to varname as if the lindex 
  7724. command had been used to extract the element, then calls the Tcl interpreter to 
  7725. execute body. 
  7726.  
  7727. In the general case there can be more than one value list (e.g., list1 and 
  7728. list2), and each value list can be associated with a list of loop variables 
  7729. (e.g., varlist1 and varlist2). During each iteration of the loop the variables 
  7730. of each varlist are assigned consecutive values from the corresponding list. 
  7731. Values in each list are used in order from first to last, and each value is 
  7732. used exactly once. The total number of loop iterations is large enough to use 
  7733. up all the values from all the value lists. If a value list does not contain 
  7734. enough elements for each of its loop variables in each iteration, empty values 
  7735. are used for the missing elements. 
  7736.  
  7737. The break and continue statements may be invoked inside body, with the same 
  7738. effect as in the for command.  Foreach returns an empty string. 
  7739.  
  7740. EXAMPLES 
  7741.  
  7742. The following loop uses i and j as loop variables to iterate over pairs of 
  7743. elements of a single list. 
  7744.  
  7745. set x {}
  7746. foreach {i j} {a b c d e f} {
  7747.     lappend x $j $i
  7748. }
  7749. # The value of x is "b a d c f e"
  7750. # There are 3 iterations of the loop.
  7751.  
  7752. The next loop uses i and j to iterate over two lists in parallel. 
  7753.  
  7754. set x {}
  7755. foreach i {a b c} j {d e f g} {
  7756.     lappend x $i $j
  7757. }
  7758. # The value of x is "a d b e c f {} g"
  7759. # There are 4 iterations of the loop.
  7760.  
  7761. The two forms are combined in the following example. 
  7762.  
  7763. set x {}
  7764. foreach i {a b c} {j k} {d e f g} {
  7765.     lappend x $i $j $k
  7766. }
  7767. # The value of x is "a d e b f g c {} {}"
  7768. # There are 3 iterations of the loop.
  7769.  
  7770. KEYWORDS 
  7771.  
  7772. foreach, iteration, list, looping 
  7773.  
  7774.  
  7775. ΓòÉΓòÉΓòÉ 3.28. format ΓòÉΓòÉΓòÉ
  7776.  
  7777.  NAME 
  7778.  
  7779. format - Format a string in the style of sprintf 
  7780.  
  7781. SYNOPSIS 
  7782.  
  7783. format formatString ?arg arg ...? 
  7784.  
  7785. INTRODUCTION 
  7786.  
  7787. This command generates a formatted string in the same way as the ANSI C sprintf 
  7788. procedure (it uses sprintf in its implementation). FormatString indicates how 
  7789. to format the result, using % conversion specifiers as in sprintf, and the 
  7790. additional arguments, if any, provide values to be substituted into the result. 
  7791. The return value from format is the formatted string. 
  7792.  
  7793. DETAILS ON FORMATTING 
  7794.  
  7795. The command operates by scanning formatString from left to right. Each 
  7796. character from the format string is appended to the result string unless it is 
  7797. a percent sign. If the character is a % then it is not copied to the result 
  7798. string. Instead, the characters following the % character are treated as a 
  7799. conversion specifier. The conversion specifier controls the conversion of the 
  7800. next successive arg to a particular format and the result is appended to the 
  7801. result string in place of the conversion specifier. If there are multiple 
  7802. conversion specifiers in the format string, then each one controls the 
  7803. conversion of one additional arg. The format command must be given enough args 
  7804. to meet the needs of all of the conversion specifiers in formatString. 
  7805.  
  7806. Each conversion specifier may contain up to six different parts: an XPG3 
  7807. position specifier, a set of flags, a minimum field width, a precision, a 
  7808. length modifier, and a conversion character. Any of these fields may be omitted 
  7809. except for the conversion character. The fields that are present must appear in 
  7810. the order given above. The paragraphs below discuss each of these fields in 
  7811. turn. 
  7812.  
  7813. If the % is followed by a decimal number and a $, as in "%2$d", then the value 
  7814. to convert is not taken from the next sequential argument. Instead, it is taken 
  7815. from the argument indicated by the number, where 1 corresponds to the first 
  7816. arg. If the conversion specifier requires multiple arguments because of * 
  7817. characters in the specifier then successive arguments are used, starting with 
  7818. the argument given by the number. This follows the XPG3 conventions for 
  7819. positional specifiers. If there are any positional specifiers in formatString 
  7820. then all of the specifiers must be positional. 
  7821.  
  7822. The second portion of a conversion specifier may contain any of the following 
  7823. flag characters, in any order: 
  7824.  
  7825.  -         Specifies that the converted argument should be left-justified in 
  7826.            its field (numbers are normally right-justified with leading spaces 
  7827.            if needed). 
  7828.  
  7829.  +         Specifies that a number should always be printed with a sign, even 
  7830.            if positive. 
  7831.  
  7832.  space     Specifies that a space should be added to the beginning of the 
  7833.            number if the first character isn't a sign. 
  7834.  
  7835.  0         Specifies that the number should be padded on the left with zeroes 
  7836.            instead of spaces. 
  7837.  
  7838.  #         Requests an alternate output form. For o and O conversions it 
  7839.            guarantees that the first digit is always 0. For x or X conversions, 
  7840.            0x or 0X (respectively) will be added to the beginning of the result 
  7841.            unless it is zero. For all floating-point conversions (e, E, f, g, 
  7842.            and G) it guarantees that the result always has a decimal point. For 
  7843.            g and G conversions it specifies that trailing zeroes should not be 
  7844.            removed. 
  7845.  
  7846.  The third portion of a conversion specifier is a number giving a minimum field 
  7847.  width for this conversion. It is typically used to make columns line up in 
  7848.  tabular printouts. If the converted argument contains fewer characters than 
  7849.  the minimum field width then it will be padded so that it is as wide as the 
  7850.  minimum field width. Padding normally occurs by adding extra spaces on the 
  7851.  left of the converted argument, but the 0 and - flags may be used to specify 
  7852.  padding with zeroes on the left or with spaces on the right, respectively. If 
  7853.  the minimum field width is specified as * rather than a number, then the next 
  7854.  argument to the format command determines the minimum field width; it must be 
  7855.  a numeric string. 
  7856.  
  7857.  The fourth portion of a conversion specifier is a precision, which consists of 
  7858.  a period followed by a number. The number is used in different ways for 
  7859.  different conversions. For e, E, and f conversions it specifies the number of 
  7860.  digits to appear to the right of the decimal point. For g and G conversions it 
  7861.  specifies the total number of digits to appear, including those on both sides 
  7862.  of the decimal point (however, trailing zeroes after the decimal point will 
  7863.  still be omitted unless the # flag has been specified). For integer 
  7864.  conversions, it specifies a minimum number of digits to print (leading zeroes 
  7865.  will be added if necessary). For s conversions it specifies the maximum number 
  7866.  of characters to be printed; if the string is longer than this then the 
  7867.  trailing characters will be dropped. If the precision is specified with * 
  7868.  rather than a number then the next argument to the format command determines 
  7869.  the precision; it must be a numeric string. 
  7870.  
  7871.  The fifth part of a conversion specifier is a length modifier, which must be h 
  7872.  or l. If it is h it specifies that the numeric value should be truncated to a 
  7873.  16-bit value before converting. This option is rarely useful. The l modifier 
  7874.  is ignored. 
  7875.  
  7876.  The last thing in a conversion specifier is an alphabetic character that 
  7877.  determines what kind of conversion to perform. The following conversion 
  7878.  characters are currently supported: 
  7879.  
  7880.  d         Convert integer to signed decimal string. 
  7881.  
  7882.  u         Convert integer to unsigned decimal string. 
  7883.  
  7884.  i         Convert integer to signed decimal string;  the integer may either be 
  7885.            in decimal, in octal (with a leading 0) or in hexadecimal (with a 
  7886.            leading 0x). 
  7887.  
  7888.  o         Convert integer to unsigned octal string. 
  7889.  
  7890.  x or X    Convert integer to unsigned hexadecimal string, using digits 
  7891.            "0123456789abcdef" for x and "0123456789ABCDEF" for X). 
  7892.  
  7893.  c         Convert integer to the 8-bit character it represents. 
  7894.  
  7895.  s         No conversion; just insert string. 
  7896.  
  7897.  f         Convert floating-point number to signed decimal string of the form 
  7898.            xx.yyy, where the number of y's is determined by the precision 
  7899.            (default: 6). If the precision is 0 then no decimal point is output. 
  7900.  
  7901.  e or e    Convert floating-point number to scientific notation in the form 
  7902.            x.yyye╤æzz, where the number of y's is determined by the precision 
  7903.            (default: 6). If the precision is 0 then no decimal point is output. 
  7904.            If the E form is used then E is printed instead of e. 
  7905.  
  7906.  g or G    If the exponent is less than -4 or greater than or equal to the 
  7907.            precision, then convert floating-point number as for %e or %E. 
  7908.            Otherwise convert as for %f. Trailing zeroes and a trailing decimal 
  7909.            point are omitted. 
  7910.  
  7911.  %         No conversion: just insert %. 
  7912.  
  7913.  For the numerical conversions the argument being converted must be an integer 
  7914.  or floating-point string; format converts the argument to binary and then 
  7915.  converts it back to a string according to the conversion specifier. 
  7916.  
  7917.  DIFFERENCES FROM ANSI SPRINTF 
  7918.  
  7919.  The behavior of the format command is the same as the ANSI C sprintf procedure 
  7920.  except for the following differences: 
  7921.  
  7922.    1. %p and %n specifiers are not currently supported. 
  7923.  
  7924.    2. For %c conversions the argument must be a decimal string, which will then 
  7925.       be converted to the corresponding character value. 
  7926.  
  7927.    3. The l modifier is ignored;  integer values are always converted as if 
  7928.       there were no modifier present and real values are always converted as if 
  7929.       the l modifier were present (i.e. type double is used for the internal 
  7930.       representation). If the h modifier is specified then integer values are 
  7931.       truncated to short before conversion. 
  7932.  
  7933.  KEYWORDS 
  7934.  
  7935.  conversion specifier, format, sprintf, string, substitution 
  7936.  
  7937.  
  7938. ΓòÉΓòÉΓòÉ 3.29. gets ΓòÉΓòÉΓòÉ
  7939.  
  7940.  NAME 
  7941.  
  7942. gets - Read a line from a channel 
  7943.  
  7944. SYNOPSIS 
  7945.  
  7946. gets channelId ?varName? 
  7947.  
  7948. DESCRIPTION 
  7949.  
  7950. This command reads the next line from channelId, returns everything in the line 
  7951. up to (but not including) the end-of-line character(s), and discards the 
  7952. end-of-line character(s). If varName is omitted the line is returned as the 
  7953. result of the command. If varName is specified then the line is placed in the 
  7954. variable by that name and the return value is a count of the number of 
  7955. characters returned. 
  7956.  
  7957. If end of file occurs while scanning for an end of line, the command returns 
  7958. whatever input is available up to the end of file. If channelId is in 
  7959. nonblocking mode and there is not a full line of input available, the command 
  7960. returns an empty string and does not consume any input. If varName is specified 
  7961. and an empty string is returned in varName because of end-of-file or because of 
  7962. insufficient data in nonblocking mode, then the return count is -1. Note that 
  7963. if varName is not specified then the end-of-file and no-full-line-available 
  7964. cases can produce the same results as if there were an input line consisting 
  7965. only of the end-of-line character(s). The eof and fblocked commands can be used 
  7966. to distinguish these three cases. 
  7967.  
  7968. SEE ALSO 
  7969.  
  7970. eof(n), fblocked(n) 
  7971.  
  7972. KEYWORDS 
  7973.  
  7974. blocking, channel, end of file, end of line, line, nonblocking, read 
  7975.  
  7976.  
  7977. ΓòÉΓòÉΓòÉ 3.30. glob ΓòÉΓòÉΓòÉ
  7978.  
  7979.  NAME 
  7980.  
  7981. glob - Return names of files that match patterns 
  7982.  
  7983. SYNOPSIS 
  7984.  
  7985. glob ?switches? pattern ?pattern ...? 
  7986.  
  7987. DESCRIPTION 
  7988.  
  7989. This command performs file name "globbing" in a fashion similar to the csh 
  7990. shell.  It returns a list of the files whose names match any of the pattern 
  7991. arguments. 
  7992.  
  7993. If the initial arguments to glob start with - then they are treated as 
  7994. switches.  The following switches are currently supported: 
  7995.  
  7996.  -nocomplain  Allows an empty list to be returned without error;  without this 
  7997.            switch an error is returned if the result list would be empty. 
  7998.  
  7999.  --        Marks the end of switches.  The argument following this one will be 
  8000.            treated as a pattern even if it starts with a -. 
  8001.  
  8002.  The pattern arguments may contain any of the following special characters: 
  8003.  
  8004.  ?         Matches any single character. 
  8005.  
  8006.  *         Matches any sequence of zero or more characters. 
  8007.  
  8008.  [chars]   Matches any single character in chars.  If chars contains a sequence 
  8009.            of the form a-b then any character between a and b (inclusive) will 
  8010.            match. 
  8011.  
  8012.  \x        Matches the character x. 
  8013.  
  8014.  {a,b,...}  Matches any of the strings a, b, etc. 
  8015.  
  8016.  As with csh, a  "." at the beginning of a file's name or just after a "/" must 
  8017.  be matched explicitly or with a {} construct. In addition, all "/" characters 
  8018.  must be matched explicitly. 
  8019.  
  8020.  If the first character in a pattern is "~" then it refers to the home 
  8021.  directory for the user whose name follows the "~". If the "~" is followed 
  8022.  immediately by "/" then the value of the HOME environment variable is used. 
  8023.  
  8024.  The glob command differs from csh globbing in two ways. First, it does not 
  8025.  sort its result list (use the lsort command if you want the list sorted). 
  8026.  Second, glob only returns the names of files that actually exist;  in csh no 
  8027.  check for existence is made unless a pattern contains a ?, *, or [] construct. 
  8028.  
  8029.  PORTABILITY ISSUES 
  8030.  
  8031.  Unlike other Tcl commands that will accept both network and native style names 
  8032.  (see the filename manual entry for details on how native and network names are 
  8033.  specified), the glob command only accepts native names.  Also, for Windows UNC 
  8034.  names, the servername and sharename components of the path may not contain ?, 
  8035.  *, or [] constructs. 
  8036.  
  8037.  KEYWORDS 
  8038.  
  8039.  exist, file, glob, pattern 
  8040.  
  8041.  
  8042. ΓòÉΓòÉΓòÉ 3.31. global ΓòÉΓòÉΓòÉ
  8043.  
  8044.  NAME 
  8045.  
  8046. global - Access global variables 
  8047.  
  8048. SYNOPSIS 
  8049.  
  8050. global varname ?varname ...? 
  8051.  
  8052. DESCRIPTION 
  8053.  
  8054. This command is ignored unless a Tcl procedure is being interpreted. If so then 
  8055. it declares the given varname's to be global variables rather than local ones. 
  8056. For the duration of the current procedure (and only while executing in the 
  8057. current procedure), any reference to any of the varnames will refer to the 
  8058. global variable by the same name. 
  8059.  
  8060. KEYWORDS 
  8061.  
  8062. global, procedure, variable 
  8063.  
  8064.  
  8065. ΓòÉΓòÉΓòÉ 3.32. history ΓòÉΓòÉΓòÉ
  8066.  
  8067.  NAME 
  8068.  
  8069. history - Manipulate the history list 
  8070.  
  8071. SYNOPSIS 
  8072.  
  8073. history ?option? ?arg arg ...? 
  8074.  
  8075. DESCRIPTION 
  8076.  
  8077. The history command performs one of several operations related to 
  8078. recently-executed commands recorded in a history list.  Each of these recorded 
  8079. commands is referred to as an "event".  When specifying an event to the history 
  8080. command, the following forms may be used: 
  8081.  
  8082.    1. A number:  if positive, it refers to the event with that number (all 
  8083.       events are numbered starting at 1).  If the number is negative, it 
  8084.       selects an event relative to the current event (-1 refers to the previous 
  8085.       event, -2 to the one before that, and so on). 
  8086.  
  8087.    2. A string:  selects the most recent event that matches the string. An 
  8088.       event is considered to match the string either if the string is the same 
  8089.       as the first characters of the event, or if the string matches the event 
  8090.       in the sense of the string match command. 
  8091.  
  8092.  The history command can take any of the following forms: 
  8093.  
  8094.  history   Same as history info, described below. 
  8095.  
  8096.  history add command ?exec?  Adds the command argument to the history list as a 
  8097.            new event.  If exec is specified (or abbreviated) then the command 
  8098.            is also executed and its result is returned.  If exec isn't 
  8099.            specified then an empty string is returned as result. 
  8100.  
  8101.  history change newValue ?event?  Replaces the value recorded for an event with 
  8102.            newValue.  Event specifies the event to replace, and defaults to the 
  8103.            current event (not event -1).  This command is intended for use in 
  8104.            commands that implement new forms of history substitution and wish 
  8105.            to replace the current event (which invokes the substitution) with 
  8106.            the command created through substitution.  The return value is an 
  8107.            empty string. 
  8108.  
  8109.  history event ?event?  Returns the value of the event given by event.  Event 
  8110.            defaults to -1.  This command causes history revision to occur: see 
  8111.            below for details. 
  8112.  
  8113.  history info ?count?  Returns a formatted string (intended for humans to read) 
  8114.            giving the event number and contents for each of the events in the 
  8115.            history list except the current event.  If count is specified then 
  8116.            only the most recent count events are returned. 
  8117.  
  8118.  history keep count  This command may be used to change the size of the history 
  8119.            list to count events.  Initially, 20 events are retained in the 
  8120.            history list.  This command returns an empty string. 
  8121.  
  8122.  history nextid  Returns the number of the next event to be recorded in the 
  8123.            history list.  It is useful for things like printing the event 
  8124.            number in command-line prompts. 
  8125.  
  8126.  history redo ?event?  Re-executes the command indicated by event and return 
  8127.            its result. Event defaults to -1.  This command results in history 
  8128.            revision:  see below for details. 
  8129.  
  8130.  history substitute old new ?event?  Retrieves the command given by event (-1 
  8131.            by default), replace any occurrences of old by new in the command 
  8132.            (only simple character equality is supported; no wild cards), 
  8133.            execute the resulting command, and return the result of that 
  8134.            execution.  This command results in history revision:  see below for 
  8135.            details. 
  8136.  
  8137.  history words selector ?event?  Retrieves from the command given by event (-1 
  8138.            by default) the words given by selector, and return those words in a 
  8139.            string separated by spaces.  The selector argument has three forms. 
  8140.            If it is a single number then it selects the word given by that 
  8141.            number (0 for the command name, 1 for its first argument, and so 
  8142.            on).  If it consists of two numbers separated by a dash, then it 
  8143.            selects all the arguments between those two.  Otherwise selector is 
  8144.            treated as a pattern; all words matching that pattern (in the sense 
  8145.            of string match) are returned.  In the numeric forms $ may be used 
  8146.            to select the last word of a command. For example, suppose the most 
  8147.            recent command in the history list is 
  8148.  
  8149.                       format  {%s is %d years old} Alice [expr $ageInMonths/12]
  8150.            Below are some history commands and the results they would produce: 
  8151.  
  8152.                       Command               Result
  8153.                       history words $       [expr $ageInMonths/12]
  8154.                       history words 1-2     {%s is %d years  old} Alice
  8155.                       history words *a*o*   {%s is %d years old} [expr $ageInMonths/12]
  8156.            History words results in history revision:  see below for details. 
  8157.  
  8158.  HISTORY REVISION 
  8159.  
  8160.  The history options event, redo, substitute, and words result in "history 
  8161.  revision". When one of these options is invoked then the current event is 
  8162.  modified to eliminate the history command and replace it with the result of 
  8163.  the history command. For example, suppose that the most recent command in the 
  8164.  history list is 
  8165.  
  8166.   set a [expr $b+2]
  8167.  and suppose that the next command invoked is one of the ones on the left side 
  8168.  of the table below.  The command actually recorded in the history event will 
  8169.  be the corresponding one on the right side of the table. 
  8170.  
  8171.   Command Typed         Command Recorded
  8172.   history redo          set a [expr $b+2]
  8173.   history s a b         set b [expr $b+2]
  8174.   set c [history w 2]   set c [expr $b+2]
  8175.  History revision is needed because event specifiers like -1 are only valid at 
  8176.  a particular time:  once more events have been added to the history list a 
  8177.  different event specifier would be needed. History revision occurs even when 
  8178.  history is invoked indirectly from the current event (e.g. a user types a 
  8179.  command that invokes a Tcl procedure that invokes history):  the top-level 
  8180.  command whose execution eventually resulted in a history command is replaced. 
  8181.  If you wish to invoke commands like history words without history revision, 
  8182.  you can use history event to save the current history event and then use 
  8183.  history change to restore it later. 
  8184.  
  8185.  KEYWORDS 
  8186.  
  8187.  event, history, record, revision 
  8188.  
  8189.  
  8190. ΓòÉΓòÉΓòÉ 3.33. if ΓòÉΓòÉΓòÉ
  8191.  
  8192.  NAME 
  8193.  
  8194. if - Execute scripts conditionally 
  8195.  
  8196. SYNOPSIS 
  8197.  
  8198. if expr1 ?then? body1 elseif expr2 ?then? body2 elseif ... ?else? ?bodyN? 
  8199.  
  8200. DESCRIPTION 
  8201.  
  8202. The if command evaluates expr1 as an expression (in the same way that expr 
  8203. evaluates its argument).  The value of the expression must be a boolean (a 
  8204. numeric value, where 0 is false and anything is true, or a string value such as 
  8205. true or yes for true and false or no for false); if it is true then body1 is 
  8206. executed by passing it to the Tcl interpreter. Otherwise expr2 is evaluated as 
  8207. an expression and if it is true then body2 is executed, and so on. If none of 
  8208. the expressions evaluates to true then bodyN is executed. The then and else 
  8209. arguments are optional "noise words" to make the command easier to read. There 
  8210. may be any number of elseif clauses, including zero. BodyN may also be omitted 
  8211. as long as else is omitted too. The return value from the command is the result 
  8212. of the body script that was executed, or an empty string if none of the 
  8213. expressions was non-zero and there was no bodyN. 
  8214.  
  8215. KEYWORDS 
  8216.  
  8217. boolean, conditional, else, false, if, true 
  8218.  
  8219.  
  8220. ΓòÉΓòÉΓòÉ 3.34. incr ΓòÉΓòÉΓòÉ
  8221.  
  8222.  NAME 
  8223.  
  8224. incr - Increment the value of a variable 
  8225.  
  8226. SYNOPSIS 
  8227.  
  8228. incr varName ?increment? 
  8229.  
  8230. DESCRIPTION 
  8231.  
  8232. Increments the value stored in the variable whose name is varName. The value of 
  8233. the variable must be an integer. If increment is supplied then its value (which 
  8234. must be an integer) is added to the value of variable varName;  otherwise 1 is 
  8235. added to varName. The new value is stored as a decimal string in variable 
  8236. varName and also returned as result. 
  8237.  
  8238. KEYWORDS 
  8239.  
  8240. add, increment, variable, value 
  8241.  
  8242.  
  8243. ΓòÉΓòÉΓòÉ 3.35. info ΓòÉΓòÉΓòÉ
  8244.  
  8245.  NAME 
  8246.  
  8247. info - Return information about the state of the Tcl interpreter 
  8248.  
  8249. SYNOPSIS 
  8250.  
  8251. info option ?arg arg ...? 
  8252.  
  8253. DESCRIPTION 
  8254.  
  8255. This command provides information about various internals of the Tcl 
  8256. interpreter. The legal option's (which may be abbreviated) are: 
  8257.  
  8258.  info args procname  Returns a list containing the names of the arguments to 
  8259.            procedure procname, in order.  Procname must be the name of a Tcl 
  8260.            command procedure. 
  8261.  
  8262.  info body procname  Returns the body of procedure procname.  Procname must be 
  8263.            the name of a Tcl command procedure. 
  8264.  
  8265.  info cmdcount  Returns a count of the total number of commands that have been 
  8266.            invoked in this interpreter. 
  8267.  
  8268.  info commands ?pattern?  If pattern isn't specified, returns a list of names 
  8269.            of all the Tcl commands, including both the built-in commands 
  8270.            written in C and the command procedures defined using the proc 
  8271.            command. If pattern is specified, only those names matching pattern 
  8272.            are returned.  Matching is determined using the same rules as for 
  8273.            string match. 
  8274.  
  8275.  info complete command  Returns 1 if command is a complete Tcl command in the 
  8276.            sense of having no unclosed quotes, braces, brackets or array 
  8277.            element names, If the command doesn't appear to be complete then 0 
  8278.            is returned. This command is typically used in line-oriented input 
  8279.            environments to allow users to type in commands that span multiple 
  8280.            lines;  if the command isn't complete, the script can delay 
  8281.            evaluating it until additional lines have been typed to complete the 
  8282.            command. 
  8283.  
  8284.  info default procname arg varname  Procname must be the name of a Tcl command 
  8285.            procedure and arg must be the name of an argument to that procedure. 
  8286.            If arg doesn't have a default value then the command returns 0. 
  8287.            Otherwise it returns 1 and places the default value of arg into 
  8288.            variable varname. 
  8289.  
  8290.  info exists varName  Returns 1 if the variable named varName exists in the 
  8291.            current context (either as a global or local variable), returns 0 
  8292.            otherwise. 
  8293.  
  8294.  info globals ?pattern?  If pattern isn't specified, returns a list of all the 
  8295.            names of currently-defined global variables. If pattern is 
  8296.            specified, only those names matching pattern are returned.  Matching 
  8297.            is determined using the same rules as for string match. 
  8298.  
  8299.  info hostname  Returns the name of the computer on which this invocation is 
  8300.            being executed. 
  8301.  
  8302.  info level ?number?  If number is not specified, this command returns a number 
  8303.            giving the stack level of the invoking procedure, or 0 if the 
  8304.            command is invoked at top-level.  If number is specified, then the 
  8305.            result is a list consisting of the name and arguments for the 
  8306.            procedure call at level number on the stack.  If number is positive 
  8307.            then it selects a particular stack level (1 refers to the top-most 
  8308.            active procedure, 2 to the procedure it called, and so on); 
  8309.            otherwise it gives a level relative to the current level (0 refers 
  8310.            to the current procedure, -1 to its caller, and so on). See the 
  8311.            uplevel command for more information on what stack levels mean. 
  8312.  
  8313.  info library  Returns the name of the library directory in which standard Tcl 
  8314.            scripts are stored. This is actually the value of the tcl_library 
  8315.            variable and may be changed by setting tcl_library. See the tclvars 
  8316.            manual entry for more information. 
  8317.  
  8318.  info loaded ?interp?  Returns a list describing all of the packages that have 
  8319.            been loaded into interp with the load command. Each list element is 
  8320.            a sub-list with two elements consisting of the name of the file from 
  8321.            which the package was loaded and the name of the package. For 
  8322.            statically-loaded packages the file name will be an empty string. If 
  8323.            interp is omitted then information is returned for all packages 
  8324.            loaded in any interpreter in the process. To get a list of just the 
  8325.            packages in the current interpreter, specify an empty string for the 
  8326.            interp argument. 
  8327.  
  8328.  info locals ?pattern?  If pattern isn't specified, returns a list of all the 
  8329.            names of currently-defined local variables, including arguments to 
  8330.            the current procedure, if any. Variables defined with the global and 
  8331.            upvar commands will not be returned. If pattern is specified, only 
  8332.            those names matching pattern are returned.  Matching is determined 
  8333.            using the same rules as for string match. 
  8334.  
  8335.  info nameofexecutable  Returns the full path name of the binary file from 
  8336.            which the application was invoked.  If Tcl was unable to identify 
  8337.            the file, then an empty string is returned. 
  8338.  
  8339.  info patchlevel  Returns the value of the global variable tcl_patchLevel; see 
  8340.            the tclvars manual entry for more information. 
  8341.  
  8342.  info procs ?pattern?  If pattern isn't specified, returns a list of all the 
  8343.            names of Tcl command procedures. If pattern is specified, only those 
  8344.            names matching pattern are returned.  Matching is determined using 
  8345.            the same rules as for string match. 
  8346.  
  8347.  info script  If a Tcl script file is currently being evaluated (i.e. there is 
  8348.            a call to Tcl_EvalFile active or there is an active invocation of 
  8349.            the source command), then this command returns the name of the 
  8350.            innermost file being processed.  Otherwise the command returns an 
  8351.            empty string. 
  8352.  
  8353.  info sharedlibextension  Returns the extension used on this platform for the 
  8354.            names of files containing shared libraries (for example, .so under 
  8355.            Solaris). If shared libraries aren't supported on this platform then 
  8356.            an empty string is returned. 
  8357.  
  8358.  info tclversion  Returns the value of the global variable tcl_version; see the 
  8359.            tclvars manual entry for more information. 
  8360.  
  8361.  info vars ?pattern?  If pattern isn't specified, returns a list of all the 
  8362.            names of currently-visible variables, including both locals and 
  8363.            currently-visible globals. If pattern is specified, only those names 
  8364.            matching pattern are returned.  Matching is determined using the 
  8365.            same rules as for string match. 
  8366.  
  8367.  KEYWORDS 
  8368.  
  8369.  command, information, interpreter, level, procedure, variable 
  8370.  
  8371.  
  8372. ΓòÉΓòÉΓòÉ 3.36. interp ΓòÉΓòÉΓòÉ
  8373.  
  8374.  NAME 
  8375.  
  8376. interp - Create and manipulate Tcl interpreters 
  8377.  
  8378. SYNOPSIS 
  8379.  
  8380. interp option ?arg arg ...? 
  8381.  
  8382. DESCRIPTION 
  8383.  
  8384. This command makes it possible to create one or more new Tcl interpreters that 
  8385. co-exist with the creating interpreter in the same application.  The creating 
  8386. interpreter is called the master and the new interpreter is called a slave. A 
  8387. master can create any number of slaves, and each slave can itself create 
  8388. additional slaves for which it is master, resulting in a hierarchy of 
  8389. interpreters. 
  8390.  
  8391. Each interpreter is independent from the others: it has its own name space for 
  8392. commands, procedures, and global variables. A master interpreter may create 
  8393. connections between its slaves and itself using a mechanism called an alias. 
  8394. An alias is a command in a slave interpreter which, when invoked, causes a 
  8395. command to be invoked in its master interpreter or in another slave 
  8396. interpreter.  The only other connections between interpreters are through 
  8397. environment variables (the env variable), which are normally shared among all 
  8398. interpreters in the application. Note that the name space for files (such as 
  8399. the names returned by the open command) is no longer shared between 
  8400. interpreters. Explicit commands are provided to share files and to transfer 
  8401. references to open files from one interpreter to another. 
  8402.  
  8403. The interp command also provides support for safe interpreters.  A safe 
  8404. interpreter is a slave whose functions have been greatly restricted, so that it 
  8405. is safe to execute untrusted scripts without fear of them damaging other 
  8406. interpreters or the application's environment. For example, all IO channel 
  8407. creation commands and subprocess creation commands are removed from safe 
  8408. interpreters. See SAFE INTERPRETERS below for more information on what features 
  8409. are present in a safe interpreter.  The alias mechanism can be used for 
  8410. protected communication (analogous to a kernel call) between a slave 
  8411. interpreter and its master. 
  8412.  
  8413. A qualified interpreter name is a proper Tcl lists containing a subset of its 
  8414. ancestors in the interpreter hierarchy, terminated by the string naming the 
  8415. interpreter in its immediate master. Interpreter names are relative to the 
  8416. interpreter in which they are used. For example, if a is a slave of the current 
  8417. interpreter and it has a slave a1, which in turn has a slave a11, the qualified 
  8418. name of a11 in a is the list {a1 a11}. 
  8419.  
  8420. The interp command, described below, accepts qualified interpreter names as 
  8421. arguments; the interpreter in which the command is being evaluated can always 
  8422. be referred to as {} (the empty list or string). Note that it is impossible to 
  8423. refer to a master (ancestor) interpreter by name in a slave interpreter except 
  8424. through aliases. Also, there is no global name by which one can refer to the 
  8425. first interpreter created in an application. Both restrictions are motivated by 
  8426. safety concerns. 
  8427.  
  8428. The interp command is used to create, delete, and manipulate slave 
  8429. interpreters, and to share or transfer channels between interpreters.  It can 
  8430. have any of several forms, depending on the option argument: 
  8431.  
  8432.  interp alias srcPath srcCmd  Returns a Tcl list whose elements are the 
  8433.            targetCmd and args associated with the alias named srcCmd (all of 
  8434.            these are the values specified when the alias was created; it is 
  8435.            possible that the actual source command in the slave is different 
  8436.            from srcCmd if it was renamed). 
  8437.  
  8438.  interp alias srcPath srcCmd {}  Deletes the alias for srcCmd in the slave 
  8439.            interpreter identified by srcPath. srcCmd refers to the name under 
  8440.            which the alias was created;  if the source command has been 
  8441.            renamed, the renamed command will be deleted. 
  8442.  
  8443.  interp alias srcPath srcCmd targetPath targetCmd ?arg arg ...?  This command 
  8444.            creates an alias between one slave and another (see the alias slave 
  8445.            command below for creating aliases between a slave and its master). 
  8446.            In this command, either of the slave interpreters may be anywhere in 
  8447.            the hierarchy of interpreters under the interpreter invoking the 
  8448.            command. SrcPath and srcCmd identify the source of the alias. 
  8449.            SrcPath is a Tcl list whose elements select a particular 
  8450.            interpreter.  For example, "a b" identifies an interpreter b, which 
  8451.            is a slave of interpreter a, which is a slave of the invoking 
  8452.            interpreter.  An empty list specifies the interpreter invoking the 
  8453.            command.  srcCmd gives the name of a new command, which will be 
  8454.            created in the source interpreter. TargetPath and targetCmd specify 
  8455.            a target interpreter and command, and the arg arguments, if any, 
  8456.            specify additional arguments to targetCmd which are prepended to any 
  8457.            arguments specified in the invocation of srcCmd. TargetCmd may be 
  8458.            undefined at the time of this call, or it may already exist; it is 
  8459.            not created by this command. The alias arranges for the given target 
  8460.            command to be invoked in the target interpreter whenever the given 
  8461.            source command is invoked in the source interpreter.  See ALIAS 
  8462.            INVOCATION below for more details. 
  8463.  
  8464.  interp aliases ?path?  This command returns a Tcl list of the names of all the 
  8465.            source commands for aliases defined in the interpreter identified by 
  8466.            path. 
  8467.  
  8468.  interp create ?-safe? ?--? ?path?  Creates a slave interpreter identified by 
  8469.            path and a new command, called a slave command. The name of the 
  8470.            slave command is the last component of path. The new slave 
  8471.            interpreter and the slave command are created in the interpreter 
  8472.            identified by the path obtained by removing the last component from 
  8473.            path. For example, if path is "a b c" then a new slave interpreter 
  8474.            and slave command named "c" are created in the interpreter 
  8475.            identified by the path "a b". The slave command may be used to 
  8476.            manipulate the new interpreter as described below. If path is 
  8477.            omitted, Tcl creates a unique name of the form interpx, where x is 
  8478.            an integer, and uses it for the interpreter and the slave command. 
  8479.            If the -safe switch is specified (or if the master interpreter is a 
  8480.            safe interpreter), the new slave interpreter will be created as a 
  8481.            safe interpreter with limited functionality; otherwise the slave 
  8482.            will include the full set of Tcl built-in commands and variables. 
  8483.            The -- switch can be used to mark the end of switches;  it may be 
  8484.            needed if path is an unusual value such as -safe. The result of the 
  8485.            command is the name of the new interpreter. The name of a slave 
  8486.            interpreter must be unique among all the slaves for its master;  an 
  8487.            error occurs if a slave interpreter by the given name already exists 
  8488.            in this master. 
  8489.  
  8490.  interp delete ?path ...?  Deletes zero or more interpreters given by the 
  8491.            optional path arguments, and for each interpreter, it also deletes 
  8492.            its slaves. The command also deletes the slave command for each 
  8493.            interpreter deleted. For each path argument, if no interpreter by 
  8494.            that name exists, the command raises an error. 
  8495.  
  8496.  interp eval path arg ?arg ...?  This command concatenates all of the arg 
  8497.            arguments in the same fashion as the concat command, then evaluates 
  8498.            the resulting string as a Tcl script in the slave interpreter 
  8499.            identified by path. The result of this evaluation (including error 
  8500.            information such as the errorInfo and errorCode variables, if an 
  8501.            error occurs) is returned to the invoking interpreter. 
  8502.  
  8503.  interp exists path  Returns  1 if a slave interpreter by the specified path 
  8504.            exists in this master, 0 otherwise. If path is omitted, the invoking 
  8505.            interpreter is used. 
  8506.  
  8507.  interp issafe ?path?  Returns 1 if the interpreter identified by the specified 
  8508.            path is safe, 0 otherwise. 
  8509.  
  8510.  interp share srcPath channelId destPath  Causes the IO channel identified by 
  8511.            channelId to become shared between the interpreter identified by 
  8512.            srcPath and the interpreter identified by destPath. Both 
  8513.            interpreters have the same permissions on the IO channel. Both 
  8514.            interpreters must close it to close the underlying IO channel; IO 
  8515.            channels accessible in an interpreter are automatically closed when 
  8516.            an interpreter is destroyed. 
  8517.  
  8518.  interp slaves ?path?  Returns a Tcl list of the names of all the slave 
  8519.            interpreters associated with the interpreter identified by path. If 
  8520.            path is omitted, the invoking interpreter is used. 
  8521.  
  8522.  interp target path alias  Returns a Tcl list describing the target interpreter 
  8523.            for an alias. The alias is specified with an interpreter path and 
  8524.            source command name, just as in interp alias above. The name of the 
  8525.            target interpreter is returned as an interpreter path, relative to 
  8526.            the invoking interpreter. If the target interpreter for the alias is 
  8527.            the invoking interpreter then an empty list is returned. If the 
  8528.            target interpreter for the alias is not the invoking interpreter or 
  8529.            one of its descendants then an error is generated. The target 
  8530.            command does not have to be defined at the time of this invocation. 
  8531.  
  8532.  interp transfer srcPath channelId destPath  Causes the IO channel identified 
  8533.            by channelId to become available in the interpreter identified by 
  8534.            destPath and unavailable in the interpreter identified by srcPath. 
  8535.  
  8536.  SLAVE COMMAND 
  8537.  
  8538.  For each slave interpreter created with the interp command, a new Tcl command 
  8539.  is created in the master interpreter with the same name as the new 
  8540.  interpreter. This command may be used to invoke various operations on the 
  8541.  interpreter.  It has the following general form: 
  8542.  
  8543.   slave command ?arg arg ...?
  8544.  Slave is the name of the interpreter, and command and the args determine the 
  8545.  exact behavior of the command. The valid forms of this command are: 
  8546.  
  8547.  slave aliases  Returns a Tcl list whose elements are the names of all the 
  8548.            aliases in slave.  The names returned are the srcCmd values used 
  8549.            when the aliases were created (which may not be the same as the 
  8550.            current names of the commands, if they have been renamed). 
  8551.  
  8552.  slave alias srcCmd  Returns a Tcl list whose elements are the targetCmd and 
  8553.            args associated with the alias named srcCmd (all of these are the 
  8554.            values specified when the alias was created; it is possible that the 
  8555.            actual source command in the slave is different from srcCmd if it 
  8556.            was renamed). 
  8557.  
  8558.  slave alias srcCmd {}  Deletes the alias for srcCmd in the slave interpreter. 
  8559.            srcCmd refers to the name under which the alias was created;  if the 
  8560.            source command has been renamed, the renamed command will be 
  8561.            deleted. 
  8562.  
  8563.  slave alias srcCmd targetCmd ?arg ..?  Creates an alias such that whenever 
  8564.            srcCmd is invoked in slave, targetCmd is invoked in the master. The 
  8565.            arg arguments will be passed to targetCmd as additional arguments, 
  8566.            prepended before any arguments passed in the invocation of srcCmd. 
  8567.            See ALIAS INVOCATION below for details. 
  8568.  
  8569.  slave eval arg ?arg ..?  This command concatenates all of the arg arguments in 
  8570.            the same fashion as the concat command, then evaluates the resulting 
  8571.            string as a Tcl script in slave. The result of this evaluation 
  8572.            (including error information such as the errorInfo and errorCode 
  8573.            variables, if an error occurs) is returned to the invoking 
  8574.            interpreter. 
  8575.  
  8576.  slave issafe  Returns  1 if the slave interpreter is safe, 0 otherwise. 
  8577.  
  8578.  ALIAS INVOCATION 
  8579.  
  8580.  The alias mechanism has been carefully designed so that it can be used safely 
  8581.  when an untrusted script is executing in a safe slave and the target of the 
  8582.  alias is a trusted master.  The most important thing in guaranteeing safety is 
  8583.  to ensure that information passed from the slave to the master is never 
  8584.  evaluated or substituted in the master;  if this were to occur, it would 
  8585.  enable an evil script in the slave to invoke arbitrary functions in the 
  8586.  master, which would compromise security. 
  8587.  
  8588.  When the source for an alias is invoked in the slave interpreter, the usual 
  8589.  Tcl substitutions are performed when parsing that command. These substitutions 
  8590.  are carried out in the source interpreter just as they would be for any other 
  8591.  command invoked in that interpreter. The command procedure for the source 
  8592.  command takes its arguments and merges them with the targetCmd and args for 
  8593.  the alias to create a new array of arguments.  If the words of srcCmd were 
  8594.  "srcCmd arg1 arg2 ... argN", the new set of words will be "targetCmd arg arg 
  8595.  ... arg arg1 arg2 ... argN", where targetCmd and args are the values supplied 
  8596.  when the alias was created.  TargetCmd is then used to locate a command 
  8597.  procedure in the target interpreter, and that command procedure is invoked 
  8598.  with the new set of arguments.  An error occurs if there is no command named 
  8599.  targetCmd in the target interpreter. No additional substitutions are performed 
  8600.  on the words:  the target command procedure is invoked directly, without going 
  8601.  through the normal Tcl evaluation mechanism. Substitutions are thus performed 
  8602.  on each word exactly once: targetCmd and args were substituted when parsing 
  8603.  the command that created the alias, and arg1 - argN are substituted when the 
  8604.  alias's source command is parsed in the source interpreter. 
  8605.  
  8606.  When writing the targetCmds for aliases in safe interpreters, it is very 
  8607.  important that the arguments to that command never be evaluated or 
  8608.  substituted, since this would provide an escape mechanism whereby the slave 
  8609.  interpreter could execute arbitrary code in the master.  This in turn would 
  8610.  compromise the security of the system. 
  8611.  
  8612.  SAFE INTERPRETERS 
  8613.  
  8614.  A safe interpreter is one with restricted functionality, so that is safe to 
  8615.  execute an arbitrary script from your worst enemy without fear of that script 
  8616.  damaging the enclosing application or the rest of your computing environment. 
  8617.  In order to make an interpreter safe, certain commands and variables are 
  8618.  removed from the interpreter. For example, commands to create files on disk 
  8619.  are removed, and the exec command is removed, since it could be used to cause 
  8620.  damage through subprocesses. Limited access to these facilities can be 
  8621.  provided, by creating aliases to the master interpreter which check their 
  8622.  arguments carefully and provide restricted access to a safe subset of 
  8623.  facilities. For example, file creation might be allowed in a particular 
  8624.  subdirectory and subprocess invocation might be allowed for a carefully 
  8625.  selected and fixed set of programs. 
  8626.  
  8627.  A safe interpreter is created by specifying the -safe switch to the interp 
  8628.  create command.  Furthermore, any slave created by a safe interpreter will 
  8629.  also be safe. 
  8630.  
  8631.  A safe interpreter is created with exactly the following set of built-in 
  8632.  commands: 
  8633.  
  8634.   after            append           array            break
  8635.   case             catch            clock            close
  8636.   concat           continue         eof              error
  8637.   eval             expr             fblocked         fileevent
  8638.   flush            for              foreach          format
  8639.   gets             global           history          if
  8640.   incr             info             interp           join
  8641.   lappend          lindex           linsert          list
  8642.   llength          lower            lrange           lreplace
  8643.   lsearch          lsort            package          pid
  8644.   proc             puts             read             rename
  8645.   return           scan             seek             set
  8646.   split            string           subst            switch
  8647.   tell             trace            unset            update
  8648.   uplevel          upvar            vwait            while
  8649.  All commands not on this list are removed by interp create when it creates a 
  8650.  safe interpreter. These commands can be recreated later as Tcl procedures or 
  8651.  aliases. 
  8652.  
  8653.  In addition, the env variable is not present in a safe interpreter, so it 
  8654.  cannot share environment variables with other interpreters. The env variable 
  8655.  poses a security risk, because users can store sensitive information in an 
  8656.  environment variable. For example, the PGP manual recommends storing the PGP 
  8657.  private key protection password in the environment variable PGPPASS. Making 
  8658.  this variable available to untrusted code executing in a safe interpreter 
  8659.  would incur a security risk. 
  8660.  
  8661.  If extensions are loaded into a safe interpreter, they may also restrict their 
  8662.  own functionality to eliminate unsafe commands. For a discussion of management 
  8663.  of extensions for safety see the manual entries for the package and load Tcl 
  8664.  commands. 
  8665.  
  8666.  CREDITS 
  8667.  
  8668.  This mechanism is based on the Safe-Tcl prototype implemented by Nathaniel 
  8669.  Borenstein and Marshall Rose. 
  8670.  
  8671.  SEE ALSO 
  8672.  
  8673.  load(n), package(n) Tcl_CreateSlave(3) 
  8674.  
  8675.  KEYWORDS 
  8676.  
  8677.  alias, master interpreter, safe interpreter, slave interpreter 
  8678.  
  8679.  
  8680. ΓòÉΓòÉΓòÉ 3.37. join ΓòÉΓòÉΓòÉ
  8681.  
  8682.  NAME 
  8683.  
  8684. join - Create a string by joining together list elements 
  8685.  
  8686. SYNOPSIS 
  8687.  
  8688. join list ?joinString? 
  8689.  
  8690. DESCRIPTION 
  8691.  
  8692. The list argument must be a valid Tcl list. This command returns the string 
  8693. formed by joining all of the elements of list together with joinString 
  8694. separating each adjacent pair of elements. The joinString argument defaults to 
  8695. a space character. 
  8696.  
  8697. KEYWORDS 
  8698.  
  8699. element, join, list, separator 
  8700.  
  8701.  
  8702. ΓòÉΓòÉΓòÉ 3.38. lappend ΓòÉΓòÉΓòÉ
  8703.  
  8704.  NAME 
  8705.  
  8706. lappend - Append list elements onto a variable 
  8707.  
  8708. SYNOPSIS 
  8709.  
  8710. lappend varName ?value value value ...? 
  8711.  
  8712. DESCRIPTION 
  8713.  
  8714. This command treats the variable given by varName as a list and appends each of 
  8715. the value arguments to that list as a separate element, with spaces between 
  8716. elements. If varName doesn't exist, it is created as a list with elements given 
  8717. by the value arguments. Lappend is similar to append except that the values are 
  8718. appended as list elements rather than raw text. This command provides a 
  8719. relatively efficient way to build up large lists.  For example, "lappend a $b" 
  8720. is much more efficient than "set a [concat $a [list $b]]" when $a is long. 
  8721.  
  8722. KEYWORDS 
  8723.  
  8724. append, element, list, variable 
  8725.  
  8726.  
  8727. ΓòÉΓòÉΓòÉ 3.39. library ΓòÉΓòÉΓòÉ
  8728.  
  8729.  NAME 
  8730.  
  8731. library - standard library of Tcl procedures 
  8732.  
  8733. SYNOPSIS 
  8734.  
  8735. auto_execok cmd 
  8736.  auto_load cmd 
  8737.  auto_mkindex dir pattern pattern ... 
  8738.  auto_reset 
  8739.  parray arrayName 
  8740.  
  8741. INTRODUCTION 
  8742.  
  8743. Tcl includes a library of Tcl procedures for commonly-needed functions. The 
  8744. procedures defined in the Tcl library are generic ones suitable for use by many 
  8745. different applications. The location of the Tcl library is returned by the info 
  8746. library command. In addition to the Tcl library, each application will normally 
  8747. have its own library of support procedures as well;  the location of this 
  8748. library is normally given by the value of the $app_library global variable, 
  8749. where app is the name of the application. For example, the location of the Tk 
  8750. library is kept in the variable $tk_library. 
  8751.  
  8752. To access the procedures in the Tcl library, an application should source the 
  8753. file init.tcl in the library, for example with the Tcl command 
  8754.  
  8755. source [file join [info library] init.tcl]
  8756. If the library procedure Tcl_Init is invoked from an application's Tcl_AppInit 
  8757. procedure, this happens automatically. The code in init.tcl will define the 
  8758. unknown procedure and arrange for the other procedures to be loaded on-demand 
  8759. using the auto-load mechanism defined below. 
  8760.  
  8761. COMMAND PROCEDURES 
  8762.  
  8763. The following procedures are provided in the Tcl library: 
  8764.  
  8765.  auto_execok cmd  Determines whether there is an executable file by the name 
  8766.            cmd. This command examines the directories in the current search 
  8767.            path (given by the PATH environment variable) to see if there is an 
  8768.            executable file named cmd in any of those directories. If so, it 
  8769.            returns 1;  if not it returns 0.  Auto_exec remembers information 
  8770.            about previous searches in an array named auto_execs;  this avoids 
  8771.            the path search in future calls for the same cmd.  The command 
  8772.            auto_reset may be used to force auto_execok to forget its cached 
  8773.            information. 
  8774.  
  8775.  auto_load cmd  This command attempts to load the definition for a Tcl command 
  8776.            named cmd. To do this, it searches an auto-load path, which is a 
  8777.            list of one or more directories. The auto-load path is given by the 
  8778.            global variable $auto_path if it exists. If there is no $auto_path 
  8779.            variable, then the TCLLIBPATH environment variable is used, if it 
  8780.            exists. Otherwise the auto-load path consists of just the Tcl 
  8781.            library directory. Within each directory in the auto-load path there 
  8782.            must be a file tclIndex that describes one or more commands defined 
  8783.            in that directory and a script to evaluate to load each of the 
  8784.            commands. The tclIndex file should be generated with the 
  8785.            auto_mkindex command. If cmd is found in an index file, then the 
  8786.            appropriate script is evaluated to create the command. The auto_load 
  8787.            command returns 1 if cmd was successfully created. The command 
  8788.            returns 0 if there was no index entry for cmd or if the script 
  8789.            didn't actually define cmd (e.g. because index information is out of 
  8790.            date). If an error occurs while processing the script, then that 
  8791.            error is returned. Auto_load only reads the index information once 
  8792.            and saves it in the array auto_index;  future calls to auto_load 
  8793.            check for cmd in the array rather than re-reading the index files. 
  8794.            The cached index information may be deleted with the command 
  8795.            auto_reset. This will force the next auto_load command to reload the 
  8796.            index database from disk. 
  8797.  
  8798.  auto_mkindex dir pattern pattern ...  Generates an index suitable for use by 
  8799.            auto_load. The command searches dir for all files whose names match 
  8800.            any of the pattern arguments (matching is done with the glob 
  8801.            command), generates an index of all the Tcl command procedures 
  8802.            defined in all the matching files, and stores the index information 
  8803.            in a file named tclIndex in dir. If no pattern is given a pattern of 
  8804.            *.tcl will be assumed. For example, the command 
  8805.  
  8806.                       auto_mkindex foo *.tcl
  8807.  
  8808.            will read all the .tcl files in subdirectory foo and generate a new 
  8809.            index file foo/tclIndex. 
  8810.  
  8811.            Auto_mkindex parses the Tcl scripts in a relatively unsophisticated 
  8812.            way:  if any line contains the word proc as its first characters 
  8813.            then it is assumed to be a procedure definition and the next word of 
  8814.            the line is taken as the procedure's name. Procedure definitions 
  8815.            that don't appear in this way (e.g. they have spaces before the 
  8816.            proc) will not be indexed. 
  8817.  
  8818.  auto_reset  Destroys all the information cached by auto_execok and auto_load. 
  8819.            This information will be re-read from disk the next time it is 
  8820.            needed. Auto_reset also deletes any procedures listed in the 
  8821.            auto-load index, so that fresh copies of them will be loaded the 
  8822.            next time that they're used. 
  8823.  
  8824.  parray arrayName  Prints on standard output the names and values of all the 
  8825.            elements in the array arrayName. ArrayName must be an array 
  8826.            accessible to the caller of parray. It may be either local or 
  8827.            global. 
  8828.  
  8829.  VARIABLES 
  8830.  
  8831.  The following global variables are defined or used by the procedures in the 
  8832.  Tcl library: 
  8833.  
  8834.  auto_execs  Used by auto_execok to record information about whether particular 
  8835.            commands exist as executable files. 
  8836.  
  8837.  auto_index  Used by auto_load to save the index information read from disk. 
  8838.  
  8839.  auto_noexec  If set to any value, then unknown will not attempt to auto-exec 
  8840.            any commands. 
  8841.  
  8842.  auto_noload  If set to any value, then unknown will not attempt to auto-load 
  8843.            any commands. 
  8844.  
  8845.  auto_path  If set, then it must contain a valid Tcl list giving directories to 
  8846.            search during auto-load operations. 
  8847.  
  8848.  env(TCL_LIBRARY)  If set, then it specifies the location of the directory 
  8849.            containing library scripts (the value of this variable will be 
  8850.            returned by the command info library).  If this variable isn't set 
  8851.            then a default value is used. 
  8852.  
  8853.  env(TCLLIBPATH)  If set, then it must contain a valid Tcl list giving 
  8854.            directories to search during auto-load operations. This variable is 
  8855.            only used if auto_path is not defined. 
  8856.  
  8857.  unknown_active  This variable is set by unknown to indicate that it is active. 
  8858.            It is used to detect errors where unknown recurses on itself 
  8859.            infinitely. The variable is unset before unknown returns. 
  8860.  
  8861.  KEYWORDS 
  8862.  
  8863.  auto-exec, auto-load, library, unknown 
  8864.  
  8865.  
  8866. ΓòÉΓòÉΓòÉ 3.40. lindex ΓòÉΓòÉΓòÉ
  8867.  
  8868.  NAME 
  8869.  
  8870. lindex - Retrieve an element from a list 
  8871.  
  8872. SYNOPSIS 
  8873.  
  8874. lindex list index 
  8875.  
  8876. DESCRIPTION 
  8877.  
  8878. This command treats list as a Tcl list and returns the index'th element from it 
  8879. (0 refers to the first element of the list). In extracting the element, lindex 
  8880. observes the same rules concerning braces and quotes and backslashes as the Tcl 
  8881. command interpreter; however, variable substitution and command substitution do 
  8882. not occur. If index is negative or greater than or equal to the number of 
  8883. elements in value, then an empty string is returned. If index has the value 
  8884. end, it refers to the last element in the list. 
  8885.  
  8886. KEYWORDS 
  8887.  
  8888. element, index, list 
  8889.  
  8890.  
  8891. ΓòÉΓòÉΓòÉ 3.41. linsert ΓòÉΓòÉΓòÉ
  8892.  
  8893.  NAME 
  8894.  
  8895. linsert - Insert elements into a list 
  8896.  
  8897. SYNOPSIS 
  8898.  
  8899. linsert list index element ?element element ...? 
  8900.  
  8901. DESCRIPTION 
  8902.  
  8903. This command produces a new list from list by inserting all of the element 
  8904. arguments just before the indexth element of list.  Each element argument will 
  8905. become a separate element of the new list.  If index is less than or equal to 
  8906. zero, then the new elements are inserted at the beginning of the list.  If 
  8907. index has the value end, or if it is greater than or equal to the number of 
  8908. elements in the list, then the new elements are appended to the list. 
  8909.  
  8910. KEYWORDS 
  8911.  
  8912. element, insert, list 
  8913.  
  8914.  
  8915. ΓòÉΓòÉΓòÉ 3.42. list ΓòÉΓòÉΓòÉ
  8916.  
  8917.  NAME 
  8918.  
  8919. list - Create a list 
  8920.  
  8921. SYNOPSIS 
  8922.  
  8923. list ?arg arg ...? 
  8924.  
  8925. DESCRIPTION 
  8926.  
  8927. This command returns a list comprised of all the args, or an empty string if no 
  8928. args are specified. Braces and backslashes get added as necessary, so that the 
  8929. index command may be used on the result to re-extract the original arguments, 
  8930. and also so that eval may be used to execute the resulting list, with arg1 
  8931. comprising the command's name and the other args comprising its arguments. 
  8932. List produces slightly different results than concat:  concat removes one level 
  8933. of grouping before forming the list, while list works directly from the 
  8934. original arguments. For example, the command 
  8935.  
  8936. list a b {c d e} {f {g h}}
  8937. will return 
  8938.  
  8939. a b {c d e} {f {g h}}
  8940. while concat with the same arguments will return 
  8941.  
  8942. a b c d e f {g h}
  8943.  
  8944. KEYWORDS 
  8945.  
  8946. element, list 
  8947.  
  8948.  
  8949. ΓòÉΓòÉΓòÉ 3.43. llength ΓòÉΓòÉΓòÉ
  8950.  
  8951.  NAME 
  8952.  
  8953. llength - Count the number of elements in a list 
  8954.  
  8955. SYNOPSIS 
  8956.  
  8957. llength list 
  8958.  
  8959. DESCRIPTION 
  8960.  
  8961. Treats list as a list and returns a decimal string giving the number of 
  8962. elements in it. 
  8963.  
  8964. KEYWORDS 
  8965.  
  8966. element, list, length 
  8967.  
  8968.  
  8969. ΓòÉΓòÉΓòÉ 3.44. load ΓòÉΓòÉΓòÉ
  8970.  
  8971.  NAME 
  8972.  
  8973. load - Load machine code and initialize new commands. 
  8974.  
  8975. SYNOPSIS 
  8976.  
  8977. load fileName 
  8978.  load fileName packageName 
  8979.  load fileName packageName interp 
  8980.  
  8981. DESCRIPTION 
  8982.  
  8983. This command loads binary code from a file into the application's address space 
  8984. and calls an initialization procedure in the package to incorporate it into an 
  8985. interpreter.  fileName is the name of the file containing the code;  its exact 
  8986. form varies from system to system but on most systems it is a shared library, 
  8987. such as a .so file under Solaris or a DLL under Windows. packageName is the 
  8988. name of the package, and is used to compute the name of an initialization 
  8989. procedure. interp is the path name of the interpreter into which to load the 
  8990. package (see the interp manual entry for details); if interp is omitted, it 
  8991. defaults to the interpreter in which the load command was invoked. 
  8992.  
  8993. Once the file has been loaded into the application's address space, one of two 
  8994. initialization procedures will be invoked in the new code. Typically the 
  8995. initialization procedure will add new commands to a Tcl interpreter. The name 
  8996. of the initialization procedure is determined by packageName and whether or not 
  8997. the target interpreter is a safe one.  For normal interpreters the name of the 
  8998. initialization procedure will have the form pkg_Init, where pkg is the same as 
  8999. packageName except that the first letter is converted to upper case and all 
  9000. other letters are converted to lower case.  For example, if packageName is foo 
  9001. or FOo, the initialization procedure's name will be Foo_Init. 
  9002.  
  9003. If the target interpreter is a safe interpreter, then the name of the 
  9004. initialization procedure will be pkg_SafeInit instead of pkg_Init. 
  9005.  
  9006. The initialization procedure must match the following prototype: 
  9007.  
  9008. typedef int Tcl_PackageInitProc(Tcl_Interp *interp);
  9009. The interp argument identifies the interpreter in which the package is to be 
  9010. loaded.  The initialization procedure must return TCL_OK or TCL_ERROR to 
  9011. indicate whether or not it completed successfully;  in the event of an error it 
  9012. should set interp->result to point to an error message.  The result of the load 
  9013. command will be the result returned by the initialization procedure. 
  9014.  
  9015. The actual loading of a file will only be done once for each fileName in an 
  9016. application.  If a given fileName is loaded into multiple interpreters, then 
  9017. the first load will load the code and call the initialization procedure; 
  9018. subsequent loads will call the initialization procedure without loading the 
  9019. code again. It is not possible to unload or reload a package. 
  9020.  
  9021. The load command also supports packages that are statically linked with the 
  9022. application, if those packages have been registered by calling the 
  9023. Tcl_StaticPackage procedure. If fileName is an empty string, then packageName 
  9024. must be specified. 
  9025.  
  9026. If packageName is omitted or specified as an empty string, Tcl tries to guess 
  9027. the name of the package. This may be done differently on different platforms. 
  9028. The default guess, which is used on most UNIX platforms, is to take the last 
  9029. element of fileName, strip off the first three characters if they are lib, and 
  9030. use any following alphabetic and underline characters as the module name. For 
  9031. example, the command load libxyz4.2.so uses the module name xyz and the command 
  9032. load bin/last.so {} uses the module name last. 
  9033.  
  9034. If fileName is an empty string, then packageName must be specified. The load 
  9035. command first searches for a statically loaded package (one that has been 
  9036. registered by calling the Tcl_StaticPackage procedure) by that name; if one is 
  9037. found, it is used. Otherwise, the load command searches for a dynamically 
  9038. loaded package by that name, and uses it if it is found.  If several different 
  9039. files have been loaded with different versions of the package, Tcl picks the 
  9040. file that was loaded first. 
  9041.  
  9042. BUGS 
  9043.  
  9044. If the same file is loaded by different fileNames, it will be loaded into the 
  9045. process's address space multiple times.  The behavior of this varies from 
  9046. system to system (some systems may detect the redundant loads, others may not). 
  9047.  
  9048. SEE ALSO 
  9049.  
  9050. info sharedlibextension, Tcl_StaticPackage 
  9051.  
  9052. KEYWORDS 
  9053.  
  9054. binary code, loading, shared library 
  9055.  
  9056.  
  9057. ΓòÉΓòÉΓòÉ 3.45. lrange ΓòÉΓòÉΓòÉ
  9058.  
  9059.  NAME 
  9060.  
  9061. lrange - Return one or more adjacent elements from a list 
  9062.  
  9063. SYNOPSIS 
  9064.  
  9065. lrange list first last 
  9066.  
  9067. DESCRIPTION 
  9068.  
  9069. List must be a valid Tcl list.  This command will return a new list consisting 
  9070. of elements first through last, inclusive. First or last may be end (or any 
  9071. abbreviation of it) to refer to the last element of the list. If first is less 
  9072. than zero, it is treated as if it were zero. If last is greater than or equal 
  9073. to the number of elements in the list, then it is treated as if it were end. If 
  9074. first is greater than last then an empty string is returned. Note: "lrange list 
  9075. first first" does not always produce the same result as "lindex list first" 
  9076. (although it often does for simple fields that aren't enclosed in braces); it 
  9077. does, however, produce exactly the same results as "list [lindex list first]" 
  9078.  
  9079. KEYWORDS 
  9080.  
  9081. element, list, range, sublist 
  9082.  
  9083.  
  9084. ΓòÉΓòÉΓòÉ 3.46. lreplace ΓòÉΓòÉΓòÉ
  9085.  
  9086.  NAME 
  9087.  
  9088. lreplace - Replace elements in a list with new elements 
  9089.  
  9090. SYNOPSIS 
  9091.  
  9092. lreplace list first last ?element element ...? 
  9093.  
  9094. DESCRIPTION 
  9095.  
  9096. Lreplace returns a new list formed by replacing one or more elements of list 
  9097. with the element arguments. First gives the index in list of the first element 
  9098. to be replaced (0 refers to the first element). If first is less than zero then 
  9099. it refers to the first element of list;  the element indicated by first must 
  9100. exist in the list. Last gives the index in list of the last element to be 
  9101. replaced. If last is less than first then no elements are deleted; the new 
  9102. elements are simply inserted before first. First or last may be end (or any 
  9103. abbreviation of it) to refer to the last element of the list. The element 
  9104. arguments specify zero or more new arguments to be added to the list in place 
  9105. of those that were deleted. Each element argument will become a separate 
  9106. element of the list. If no element arguments are specified, then the elements 
  9107. between first and last are simply deleted. 
  9108.  
  9109. KEYWORDS 
  9110.  
  9111. element, list, replace 
  9112.  
  9113.  
  9114. ΓòÉΓòÉΓòÉ 3.47. lsearch ΓòÉΓòÉΓòÉ
  9115.  
  9116.  NAME 
  9117.  
  9118. lsearch - See if a list contains a particular element 
  9119.  
  9120. SYNOPSIS 
  9121.  
  9122. lsearch ?mode? list pattern 
  9123.  
  9124. DESCRIPTION 
  9125.  
  9126. This command searches the elements of list to see if one of them matches 
  9127. pattern. If so, the command returns the index of the first matching element. If 
  9128. not, the command returns -1. The mode argument indicates how the elements of 
  9129. the list are to be matched against pattern and it must have one of the 
  9130. following values: 
  9131.  
  9132.  -exact    The list element must contain exactly the same string as pattern. 
  9133.  
  9134.  -glob     Pattern is a glob-style pattern which is matched against each list 
  9135.            element using the same rules as the string match command. 
  9136.  
  9137.  -regexp   Pattern is treated as a regular expression and matched against each 
  9138.            list element using the same rules as the regexp command. 
  9139.  
  9140.  If mode is omitted then it defaults to -glob. 
  9141.  
  9142.  KEYWORDS 
  9143.  
  9144.  list, match, pattern, regular expression, search, string 
  9145.  
  9146.  
  9147. ΓòÉΓòÉΓòÉ 3.48. lsort ΓòÉΓòÉΓòÉ
  9148.  
  9149.  NAME 
  9150.  
  9151. lsort - Sort the elements of a list 
  9152.  
  9153. SYNOPSIS 
  9154.  
  9155. lsort ?switches? list 
  9156.  
  9157. DESCRIPTION 
  9158.  
  9159. This command sorts the elements of list, returning a new list in sorted order. 
  9160. By default ASCII sorting is used with the result returned in increasing order. 
  9161. However, any of the following switches may be specified before list to control 
  9162. the sorting process (unique abbreviations are accepted): 
  9163.  
  9164.  -ascii    Use string comparison with ASCII collation order.  This is the 
  9165.            default. 
  9166.  
  9167.  -integer  Convert list elements to integers and use integer comparison. 
  9168.  
  9169.  -real     Convert list elements to floating-point values and use floating 
  9170.            comparison. 
  9171.  
  9172.  -command command  Use command as a comparison command. To compare two 
  9173.            elements, evaluate a Tcl script consisting of command with the two 
  9174.            elements appended as additional arguments.  The script should return 
  9175.            an integer less than, equal to, or greater than zero if the first 
  9176.            element is to be considered less than, equal to, or greater than the 
  9177.            second, respectively. 
  9178.  
  9179.  -increasing  Sort the list in increasing order ("smallest" items first). This 
  9180.            is the default. 
  9181.  
  9182.  -decreasing  Sort the list in decreasing order ("largest" items first). 
  9183.  
  9184.  KEYWORDS 
  9185.  
  9186.  element, list, order, sort 
  9187.  
  9188.  
  9189. ΓòÉΓòÉΓòÉ 3.49. open ΓòÉΓòÉΓòÉ
  9190.  
  9191.  NAME 
  9192.  
  9193. open - Open a file-based or command pipeline channel 
  9194.  
  9195. SYNOPSIS 
  9196.  
  9197.  
  9198.  open fileName 
  9199.  open fileName access 
  9200.  open fileName access permissions 
  9201.  
  9202. DESCRIPTION 
  9203.  
  9204. This command opens a file or command pipeline and returns a channel identifier 
  9205. that may be used in future invocations of commands like read, puts, and close. 
  9206. If the first character of fileName is not | then the command opens a file: 
  9207. fileName gives the name of the file to open, and it must conform to the 
  9208. conventions described in the filename manual entry. 
  9209.  
  9210. The access argument, if present, indicates the way in which the file (or 
  9211. command pipeline) is to be accessed. In the first form access may have any of 
  9212. the following values: 
  9213.  
  9214.  r         Open the file for reading only; the file must already exist. This is 
  9215.            the default value if access is not specified. 
  9216.  
  9217.  r+        Open the file for both reading and writing; the file must already 
  9218.            exist. 
  9219.  
  9220.  w         Open the file for writing only.  Truncate it if it exists.  If it 
  9221.            doesn't exist, create a new file. 
  9222.  
  9223.  w+        Open the file for reading and writing.  Truncate it if it exists. If 
  9224.            it doesn't exist, create a new file. 
  9225.  
  9226.  a         Open the file for writing only.  The file must already exist, and 
  9227.            the file is positioned so that new data is appended to the file. 
  9228.  
  9229.  a+        Open the file for reading and writing.  If the file doesn't exist, 
  9230.            create a new empty file. Set the initial access position  to the end 
  9231.            of the file. 
  9232.  
  9233.  In the second form, access consists of a list of any of the following flags, 
  9234.  all of which have the standard POSIX meanings. One of the flags must be either 
  9235.  RDONLY, WRONLY or RDWR. 
  9236.  
  9237.  RDONLY    Open the file for reading only. 
  9238.  
  9239.  WRONLY    Open the file for writing only. 
  9240.  
  9241.  RDWR      Open the file for both reading and writing. 
  9242.  
  9243.  APPEND    Set the file pointer to the end of the file prior to each write. 
  9244.  
  9245.  CREAT     Create the file if it doesn't already exist (without this flag it is 
  9246.            an error for the file not to exist). 
  9247.  
  9248.  EXCL      If CREAT is also specified, an error is returned if the file already 
  9249.            exists. 
  9250.  
  9251.  NOCTTY    If the file is a terminal device, this flag prevents the file from 
  9252.            becoming the controlling terminal of the process. 
  9253.  
  9254.  NONBLOCK  Prevents the process from blocking while opening the file, and 
  9255.            possibly in subsequent I/O operations.  The exact behavior of this 
  9256.            flag is system- and device-dependent;  its use is discouraged (it is 
  9257.            better to use the fconfigure command to put a file in nonblocking 
  9258.            mode). For details refer to your system documentation on the open 
  9259.            system call's O_NONBLOCK flag. 
  9260.  
  9261.  TRUNC     If the file exists it is truncated to zero length. 
  9262.  
  9263.  If a new file is created as part of opening it, permissions (an integer) is 
  9264.  used to set the permissions for the new file in conjunction with the process's 
  9265.  file mode creation mask. Permissions defaults to 0666. 
  9266.  
  9267.  COMMAND PIPELINES 
  9268.  
  9269.  If the first character of fileName is "|" then the remaining characters of 
  9270.  fileName are treated as a list of arguments that describe a command pipeline 
  9271.  to invoke, in the same style as the arguments for exec. In this case, the 
  9272.  channel identifier returned by open may be used to write to the command's 
  9273.  input pipe or read from its output pipe, depending on the value of access. If 
  9274.  write-only access is used (e.g. access is w), then standard output for the 
  9275.  pipeline is directed to the current standard output unless overridden by the 
  9276.  command. If read-only access is used (e.g. access is r), standard input for 
  9277.  the pipeline is taken from the current standard input unless overridden by the 
  9278.  command. 
  9279.  
  9280.  PORTABILITY ISSUES 
  9281.  
  9282.  
  9283.  Windows NT  When running Tcl interactively, there may be some strange 
  9284.            interactions between the real console, if one is present, and a 
  9285.            command pipeline that uses standard input or output.  If a command 
  9286.            pipeline is opened for reading, some of the lines entered at the 
  9287.            console will be sent to the command pipeline and some will be sent 
  9288.            to the Tcl evaluator.  If a command pipeline is opened for writing, 
  9289.            keystrokes entered into the console are not visible until the the 
  9290.            pipe is closed.  This behavior occurs whether the command pipeline 
  9291.            is executing 16-bit or 32-bit applications.  These problems only 
  9292.            occur because both Tcl and the child application are competing for 
  9293.            the console at the same time.  If the command pipeline is started 
  9294.            from a script, so that Tcl is not accessing the console, or if the 
  9295.            command pipeline does not use standard input or output, but is 
  9296.            redirected from or to a file, then the above problems do not occur. 
  9297.  
  9298.  Windows 95  A command pipeline that executes a 16-bit DOS application cannot 
  9299.            be opened for both reading and writing, since 16-bit DOS 
  9300.            applications that receive standard input from a pipe and send 
  9301.            standard output to a pipe run synchronously.  Command pipelines that 
  9302.            do not execute 16-bit DOS applications run asynchronously and can be 
  9303.            opened for both reading and writing. 
  9304.             When running Tcl interactively, there may be some strange 
  9305.            interactions between the real console, if one is present, and a 
  9306.            command pipeline that uses standard input or output.  If a command 
  9307.            pipeline is opened for reading from a 32-bit application, some of 
  9308.            the keystrokes entered at the console will be sent to the command 
  9309.            pipeline and some will be sent to the Tcl evaluator.  If a command 
  9310.            pipeline is opened for writing to a 32-bit application, no output is 
  9311.            visible on the console until the the pipe is closed.  These problems 
  9312.            only occur because both Tcl and the child application are competing 
  9313.            for the console at the same time.  If the command pipeline is 
  9314.            started from a script, so that Tcl is not accessing the console, or 
  9315.            if the command pipeline does not use standard input or output, but 
  9316.            is redirected from or to a file, then the above problems do not 
  9317.            occur. 
  9318.             Whether or not Tcl is running interactively, if a command pipeline 
  9319.            is opened for reading from a 16-bit DOS application, the call to 
  9320.            open will not return until end-of-file has been received from the 
  9321.            command pipeline's standard output.  If a command pipeline is opened 
  9322.            for writing to a 16-bit DOS application, no data will be sent to the 
  9323.            command pipeline's standard output until the pipe is actually 
  9324.            closed.  This problem occurs because 16-bit DOS applications are run 
  9325.            synchronously, as described above. 
  9326.  
  9327.  Windows 3.X  A command pipeline can execute 16-bit or 32-bit DOS or Windows 
  9328.            applications, but the call to open will not return until the last 
  9329.            program in the pipeline has finished executing; command pipelines 
  9330.            run synchronously.  If the pipeline is opened with write access 
  9331.            (either just writing or both reading and writing) the first 
  9332.            application in the pipeline will instead see an immediate 
  9333.            end-of-file; any data the caller writes to the open pipe will 
  9334.            instead be discarded. 
  9335.             Since Tcl cannot be run with a real console under Windows 3.X, 
  9336.            there are no interactions between command pipelines and the console. 
  9337.  
  9338.  Macintosh  Opening a command pipeline is not supported under Macintosh, since 
  9339.            applications do not support the concept of standard input or output. 
  9340.  
  9341.  Unix      When running Tcl interactively, there may be some strange 
  9342.            interactions between the console, if one is present, and a command 
  9343.            pipeline that uses standard input.  If a command pipeline is opened 
  9344.            for reading, some of the lines entered at the console will be sent 
  9345.            to the command pipeline and some will be sent to the Tcl evaluator. 
  9346.            This problem only occurs because both Tcl and the child application 
  9347.            are competing for the console at the same time.  If the command 
  9348.            pipeline is started from a script, so that Tcl is not accessing the 
  9349.            console, or if the command pipeline does not use standard input, but 
  9350.            is redirected from a file, then the above problem does not occur. 
  9351.  
  9352.  See the PORTABILITY ISSUES section of the exec command for additional 
  9353.  information not specific to command pipelines about executing applications on 
  9354.  the various platforms 
  9355.  
  9356.  SEE ALSO 
  9357.  
  9358.  close(n), filename(n), gets(n), read(n), puts(n), exec(n) 
  9359.  
  9360.  KEYWORDS 
  9361.  
  9362.  access mode, append, create, file, non-blocking, open, permissions, pipeline, 
  9363.  process 
  9364.  
  9365.  
  9366. ΓòÉΓòÉΓòÉ 3.50. package ΓòÉΓòÉΓòÉ
  9367.  
  9368.  NAME 
  9369.  
  9370. package - Facilities for package loading and version control 
  9371.  
  9372. SYNOPSIS 
  9373.  
  9374. package forget package 
  9375.  package ifneeded package version ?script? 
  9376.  package names 
  9377.  package provide package ?version? 
  9378.  package require ?-exact? package ?version? 
  9379.  package unknown ?command? 
  9380.  package vcompare version1 version2 
  9381.  package versions package 
  9382.  package vsatisfies version1 version2 
  9383.  
  9384. DESCRIPTION 
  9385.  
  9386. This command keeps a simple database of the packages available for use by the 
  9387. current interpreter and how to load them into the interpreter. It supports 
  9388. multiple versions of each package and arranges for the correct version of a 
  9389. package to be loaded based on what is needed by the application. This command 
  9390. also detects and reports version clashes. Typically, only the package require 
  9391. and package provide commands are invoked in normal Tcl scripts;  the other 
  9392. commands are used primarily by system scripts that maintain the package 
  9393. database. 
  9394.  
  9395. The behavior of the package command is determined by its first argument. The 
  9396. following forms are permitted: 
  9397.  
  9398.  package forget package  Removes all information about package from this 
  9399.            interpreter, including information provided by both package ifneeded 
  9400.            and package provide. 
  9401.  
  9402.  package ifneeded package version ?script?  This command typically appears only 
  9403.            in system configuration scripts to set up the package database. It 
  9404.            indicates that a particular version of a particular package is 
  9405.            available if needed, and that the package can be added to the 
  9406.            interpreter by executing script. The script is saved in a database 
  9407.            for use by subsequent package require commands;  typically, script 
  9408.            sets up auto-loading for the commands in the package (or calls load 
  9409.            and/or source directly), then invokes package provide to indicate 
  9410.            that the package is present. There may be information in the 
  9411.            database for several different versions of a single package. If the 
  9412.            database already contains information for package and version, the 
  9413.            new script replaces the existing one. If the script argument is 
  9414.            omitted, the current script for version version of package package 
  9415.            is returned, or an empty string if no package ifneeded command has 
  9416.            been invoked for this package and version. 
  9417.  
  9418.  package names  Returns a list of the names of all packages in the interpreter 
  9419.            for which a version has been provided (via package provide) or for 
  9420.            which a package ifneeded script is available. The order of elements 
  9421.            in the list is arbitrary. 
  9422.  
  9423.  package provide package ?version?  This command is invoked to indicate that 
  9424.            version version of package package is now present in the 
  9425.            interpreter. It is typically invoked once as part of an ifneeded 
  9426.            script, and again by the package itself when it is finally loaded. 
  9427.            An error occurs if a different version of package has been provided 
  9428.            by a previous package provide command. If the version argument is 
  9429.            omitted, then the command returns the version number that is 
  9430.            currently provided, or an empty string if no package provide command 
  9431.            has been invoked for package in this interpreter. 
  9432.  
  9433.  package require ?-exact? package ?version?  This command is typically invoked 
  9434.            by Tcl code that wishes to use a particular version of a particular 
  9435.            package.  The arguments indicate which package is wanted, and the 
  9436.            command ensures that a suitable version of the package is loaded 
  9437.            into the interpreter. If the command succeeds, it returns the 
  9438.            version number that is loaded;  otherwise it generates an error. If 
  9439.            both the -exact switch and the version argument are specified then 
  9440.            only the given version is acceptable.  If -exact is omitted but 
  9441.            version is specified, then versions later than version are also 
  9442.            acceptable as long as they have the same major version number as 
  9443.            version. If both -exact and version are omitted then any version 
  9444.            whatsoever is acceptable. If a version of package has already been 
  9445.            provided (by invoking the package provide command), then its version 
  9446.            number must satisfy the criteria given by -exact and version and the 
  9447.            command returns immediately. Otherwise, the command searches the 
  9448.            database of information provided by previous package ifneeded 
  9449.            commands to see if an acceptable version of the package is 
  9450.            available. If so, the script for the highest acceptable version 
  9451.            number is invoked; it must do whatever is necessary to load the 
  9452.            package, including calling package provide for the package. If the 
  9453.            package ifneeded database does not contain an acceptable version of 
  9454.            the package and a package unknown command has been specified for the 
  9455.            interpreter then that command is invoked;  when it completes, Tcl 
  9456.            checks again to see if the package is now provided or if there is a 
  9457.            package ifneeded script for it. If all of these steps fail to 
  9458.            provide an acceptable version of the package, then the command 
  9459.            returns an error. 
  9460.  
  9461.  package unknown ?command?  This command supplies a "last resort" command to 
  9462.            invoke during package require if no suitable version of a package 
  9463.            can be found in the package ifneeded database. If the command 
  9464.            argument is supplied, it contains the first part of a command;  when 
  9465.            the command is invoked during a package require command, Tcl appends 
  9466.            two additional arguments giving the desired package name and 
  9467.            version. For example, if command is foo bar and later the command 
  9468.            package require test 2.4 is invoked, then Tcl will execute the 
  9469.            command foo bar test 2.4 to load the package. If no version number 
  9470.            is supplied to the package require command, then the version 
  9471.            argument for the invoked command will be an empty string. If the 
  9472.            package unknown command is invoked without a command argument, then 
  9473.            the current package unknown script is returned, or an empty string 
  9474.            if there is none. If command is specified as an empty string, then 
  9475.            the current package unknown script is removed, if there is one. 
  9476.  
  9477.  package vcompare version1 version2  Compares the two version numbers given by 
  9478.            version1 and version2. Returns -1 if version1 is an earlier version 
  9479.            than version2, 0 if they are equal, and 1 if version1 is later than 
  9480.            version2. 
  9481.  
  9482.  package versions package  Returns a list of all the version numbers of package 
  9483.            for which information has been provided by package ifneeded 
  9484.            commands. 
  9485.  
  9486.  package vsatisfies version1 version2  Returns 1 if scripts written for 
  9487.            version2 will work unchanged with version1 (i.e. version1 is equal 
  9488.            to or greater than version2 and they both have the same major 
  9489.            version number), 0 otherwise. 
  9490.  
  9491.  VERSION NUMBERS 
  9492.  
  9493.  Version numbers consist of one or more decimal numbers separated by dots, such 
  9494.  as 2 or 1.162 or 3.1.13.1. The first number is called the major version 
  9495.  number. Larger numbers correspond to later versions of a package, with 
  9496.  leftmost numbers having greater significance. For example, version 2.1 is 
  9497.  later than 1.3 and version 3.4.6 is later than 3.3.5. Missing fields are 
  9498.  equivalent to zeroes:  version 1.3 is the same as version 1.3.0 and 1.3.0.0, 
  9499.  so it is earlier than 1.3.1 or 1.3.0.2. A later version number is assumed to 
  9500.  be upwards compatible with an earlier version number as long as both versions 
  9501.  have the same major version number. For example, Tcl scripts written for 
  9502.  version 2.3 of a package should work unchanged under versions 2.3.2, 2.4, and 
  9503.  2.5.1. Changes in the major version number signify incompatible changes: if 
  9504.  code is written to use version 2.1 of a package, it is not guaranteed to work 
  9505.  unmodified with either version 1.7.3 or version 3.1. 
  9506.  
  9507.  PACKAGE INDICES 
  9508.  
  9509.  The recommended way to use packages in Tcl is to invoke package require and 
  9510.  package provide commands in scripts, and use the procedure pkg_mkIndex to 
  9511.  create package index files. Once you've done this, packages will be loaded 
  9512.  automatically in response to package require commands. See the documentation 
  9513.  for pkg_mkIndex for details. 
  9514.  
  9515.  KEYWORDS 
  9516.  
  9517.  package, version 
  9518.  
  9519.  
  9520. ΓòÉΓòÉΓòÉ 3.51. pid ΓòÉΓòÉΓòÉ
  9521.  
  9522.  NAME 
  9523.  
  9524. pid - Retrieve process id(s) 
  9525.  
  9526. SYNOPSIS 
  9527.  
  9528. pid ?fileId? 
  9529.  
  9530. DESCRIPTION 
  9531.  
  9532. If the fileId argument is given then it should normally refer to a process 
  9533. pipeline created with the open command. In this case the pid command will 
  9534. return a list whose elements are the process identifiers of all the processes 
  9535. in the pipeline, in order. The list will be empty if fileId refers to an open 
  9536. file that isn't a process pipeline. If no fileId argument is given then pid 
  9537. returns the process identifier of the current process. All process identifiers 
  9538. are returned as decimal strings. 
  9539.  
  9540. KEYWORDS 
  9541.  
  9542. file, pipeline, process identifier 
  9543.  
  9544.  
  9545. ΓòÉΓòÉΓòÉ 3.52. pkg_mkIndex ΓòÉΓòÉΓòÉ
  9546.  
  9547.  NAME 
  9548.  
  9549. pkg_mkIndex - Build an index for automatic loading of packages 
  9550.  
  9551. SYNOPSIS 
  9552.  
  9553. pkg_mkIndex dir pattern ?pattern pattern ...? 
  9554.  
  9555. DESCRIPTION 
  9556.  
  9557. Pkg_mkIndex is a utility procedure that is part of the standard Tcl library. It 
  9558. is used to create index files that allow packages to be loaded automatically 
  9559. when package require commands are executed. To use pkg_mkIndex, follow these 
  9560. steps: 
  9561.  
  9562.    1. Create the package(s). Each package may consist of one or more Tcl script 
  9563.       files or binary files. Binary files must be suitable for loading with the 
  9564.       load command with a single argument;  for example, if the file is test.so 
  9565.       it must be possible to load this file with the command load test.so. Each 
  9566.       script file must contain a package provide command to declare the package 
  9567.       and version number, and each binary file must contain a call to 
  9568.       Tcl_PkgProvide. 
  9569.  
  9570.    2. Create the index by invoking pkg_mkIndex. The dir argument gives the name 
  9571.       of a directory and each pattern argument is a glob-style pattern that 
  9572.       selects script or binary files in dir. Pkg_mkIndex will create a file 
  9573.       pkgIndex.tcl in dir with package information about all the files given by 
  9574.       the pattern arguments. It does this by loading each file and seeing what 
  9575.       packages and new commands appear (this is why it is essential to have 
  9576.       package provide commands or Tcl_PkgProvide calls in the files, as 
  9577.       described above). 
  9578.  
  9579.    3. Install the package as a subdirectory of one of the directories given by 
  9580.       the tcl_pkgPath variable.  If $tcl_pkgPath contains more than one 
  9581.       directory, machine-dependent packages (e.g., those that contain binary 
  9582.       shared libraries) should normally be installed under the first directory 
  9583.       and machine-independent packages (e.g., those that contain only Tcl 
  9584.       scripts) should be installed under the second directory. The subdirectory 
  9585.       should include the package's script and/or binary files as well as the 
  9586.       pkgIndex.tcl file.  As long as the package is installed as a subdirectory 
  9587.       of a directory in $tcl_pkgPath it will automatically be found during 
  9588.       package require commands. 
  9589.  
  9590.       If you install the package anywhere else, then you must ensure that the 
  9591.       directory contaiingn the package is in the auto_path global variable or 
  9592.       an immediate subdirectory of one of the directories in auto_path. 
  9593.       Auto_path contains a list of directories that are searched by both the 
  9594.       auto-loader and the package loader; by default it includes $tcl_pkgPath. 
  9595.       The package loader also checks all of the subdirectories of the 
  9596.       directories in auto_path. You can add a directory to auto_path explicitly 
  9597.       in your application, or you can add the directory to your TCLLIBPATH 
  9598.       environment variable:  if this environment variable is present, Tcl 
  9599.       initializes auto_path from it during application startup. 
  9600.  
  9601.    4. Once the above steps have been taken, all you need to do to use a package 
  9602.       is to invoke package require. For example, if versions 2.1, 2.3, and 3.1 
  9603.       of package Test have been indexed by pkg_mkIndex, the command package 
  9604.       require Test will make version 3.1 available and the command package 
  9605.       require -exact Test 2.1 will make version 2.1 available. There may be 
  9606.       many versions of a package in the various index files in auto_path, but 
  9607.       only one will actually be loaded in a given interpreter, based on the 
  9608.       first call to package require. Different versions of a package may be 
  9609.       loaded in different interpreters. 
  9610.  
  9611.  PACKAGES AND THE AUTO-LOADER 
  9612.  
  9613.  The package management facilities overlap somewhat with the auto-loader, in 
  9614.  that both arrange for files to be loaded on-demand. However, package 
  9615.  management is a higher-level mechanism that uses the auto-loader for the last 
  9616.  step in the loading process. It is generally better to index a package with 
  9617.  pkg_mkIndex rather than auto_mkindex because the package mechanism provides 
  9618.  version control:  several versions of a package can be made available in the 
  9619.  index files, with different applications using different versions based on 
  9620.  package require commands. In contrast, auto_mkindex does not understand 
  9621.  versions so it can only handle a single version of each package. It is 
  9622.  probably not a good idea to index a given package with both pkg_mkIndex and 
  9623.  auto_mkindex. If you use pkg_mkIndex to index a package, its commands cannot 
  9624.  be invoked until package require has been used to select a version;  in 
  9625.  contrast, packages indexed with auto_mkindex can be used immediately since 
  9626.  there is no version control. 
  9627.  
  9628.  HOW IT WORKS 
  9629.  
  9630.  Pkg_mkIndex depends on the package unknown command, the package ifneeded 
  9631.  command, and the auto-loader. The first time a package require command is 
  9632.  invoked, the package unknown script is invoked. This is set by Tcl 
  9633.  initialization to a script that evaluates all of the pkgIndex.tcl files in the 
  9634.  auto_path. The pkgIndex.tcl files contain package ifneeded commands for each 
  9635.  version of each available package;  these commands invoke package provide 
  9636.  commands to announce the availability of the package, and they setup 
  9637.  auto-loader information to load the files of the package. A given file of a 
  9638.  given version of a given package isn't actually loaded until the first time 
  9639.  one of its commands is invoked. Thus, after invoking package require you won't 
  9640.  see the package's commands in the interpreter, but you will be able to invoke 
  9641.  the commands and they will be auto-loaded. 
  9642.  
  9643.  KEYWORDS 
  9644.  
  9645.  auto-load, index, package, version 
  9646.  
  9647.  
  9648. ΓòÉΓòÉΓòÉ 3.53. proc ΓòÉΓòÉΓòÉ
  9649.  
  9650.  NAME 
  9651.  
  9652. proc - Create a Tcl procedure 
  9653.  
  9654. SYNOPSIS 
  9655.  
  9656. proc name args body 
  9657.  
  9658. DESCRIPTION 
  9659.  
  9660. The proc command creates a new Tcl procedure named name, replacing any existing 
  9661. command or procedure there may have been by that name. Whenever the new command 
  9662. is invoked, the contents of body will be executed by the Tcl interpreter. Args 
  9663. specifies the formal arguments to the procedure.  It consists of a list, 
  9664. possibly empty, each of whose elements specifies one argument.  Each argument 
  9665. specifier is also a list with either one or two fields.  If there is only a 
  9666. single field in the specifier then it is the name of the argument; if there are 
  9667. two fields, then the first is the argument name and the second is its default 
  9668. value. 
  9669.  
  9670. When name is invoked a local variable will be created for each of the formal 
  9671. arguments to the procedure; its value will be the value of corresponding 
  9672. argument in the invoking command or the argument's default value. Arguments 
  9673. with default values need not be specified in a procedure invocation.  However, 
  9674. there must be enough actual arguments for all the formal arguments that don't 
  9675. have defaults, and there must not be any extra actual arguments.  There is one 
  9676. special case to permit procedures with variable numbers of arguments.  If the 
  9677. last formal argument has the name args, then a call to the procedure may 
  9678. contain more actual arguments than the procedure has formals.  In this case, 
  9679. all of the actual arguments starting at the one that would be assigned to args 
  9680. are combined into a list (as if the list command had been used); this combined 
  9681. value is assigned to the local variable args. 
  9682.  
  9683. When body is being executed, variable names normally refer to local variables, 
  9684. which are created automatically when referenced and deleted when the procedure 
  9685. returns.  One local variable is automatically created for each of the 
  9686. procedure's arguments. Global variables can only be accessed by invoking the 
  9687. global command or the upvar command. 
  9688.  
  9689. The proc command returns an empty string.  When a procedure is invoked, the 
  9690. procedure's return value is the value specified in a return command.  If the 
  9691. procedure doesn't execute an explicit return, then its return value is the 
  9692. value of the last command executed in the procedure's body. If an error occurs 
  9693. while executing the procedure body, then the procedure-as-a-whole will return 
  9694. that same error. 
  9695.  
  9696. KEYWORDS 
  9697.  
  9698. argument, procedure 
  9699.  
  9700.  
  9701. ΓòÉΓòÉΓòÉ 3.54. puts ΓòÉΓòÉΓòÉ
  9702.  
  9703.  NAME 
  9704.  
  9705. puts - Write to a channel 
  9706.  
  9707. SYNOPSIS 
  9708.  
  9709. puts ?-nonewline? ?channelId? string 
  9710.  
  9711. DESCRIPTION 
  9712.  
  9713. Writes the characters given by string to the channel given by channelId. 
  9714. ChannelId must be a channel identifier such as returned from a previous 
  9715. invocation of open or socket. It must have been opened for output. If no 
  9716. channelId is specified then it defaults to stdout. Puts normally outputs a 
  9717. newline character after string, but this feature may be suppressed by 
  9718. specifying the -nonewline switch. 
  9719.  
  9720. Newline characters in the output are translated by puts to platform-specific 
  9721. end-of-line sequences according to the current value of the -translation option 
  9722. for the channel (for example, on PCs newlines are normally replaced with 
  9723. carriage-return-linefeed sequences;  on Macintoshes newlines are normally 
  9724. replaced with carriage-returns). See the fconfigure manual entry for a 
  9725. discussion of end-of-line translations. 
  9726.  
  9727. Tcl buffers output internally, so characters written with puts may not appear 
  9728. immediately on the output file or device;  Tcl will normally delay output until 
  9729. the buffer is full or the channel is closed. You can force output to appear 
  9730. immediately with the flush command. 
  9731.  
  9732. When the output buffer fills up, the puts command will normally block until all 
  9733. the buffered data has been accepted for output by the operating system. If 
  9734. channelId is in nonblocking mode then the puts command will not block even if 
  9735. the operating system cannot accept the data. Instead, Tcl continues to buffer 
  9736. the data and writes it in the background as fast as the underlying file or 
  9737. device can accept it. The application must use the Tcl event loop for 
  9738. nonblocking output to work;  otherwise Tcl never finds out that the file or 
  9739. device is ready for more output data. It is possible for an arbitrarily large 
  9740. amount of data to be buffered for a channel in nonblocking mode, which could 
  9741. consume a large amount of memory. To avoid wasting memory, nonblocking I/O 
  9742. should normally be used in an event-driven fashion with the fileevent command 
  9743. (don't invoke puts unless you have recently been notified via a file event that 
  9744. the channel is ready for more output data). 
  9745.  
  9746. SEE ALSO 
  9747.  
  9748. fileevent(n) 
  9749.  
  9750. KEYWORDS 
  9751.  
  9752. channel, newline, output, write 
  9753.  
  9754.  
  9755. ΓòÉΓòÉΓòÉ 3.55. pwd ΓòÉΓòÉΓòÉ
  9756.  
  9757.  NAME 
  9758.  
  9759. pwd - Return the current working directory 
  9760.  
  9761. SYNOPSIS 
  9762.  
  9763. pwd 
  9764.  
  9765. DESCRIPTION 
  9766.  
  9767. Returns the path name of the current working directory. 
  9768.  
  9769. KEYWORDS 
  9770.  
  9771. working directory 
  9772.  
  9773.  
  9774. ΓòÉΓòÉΓòÉ 3.56. read ΓòÉΓòÉΓòÉ
  9775.  
  9776.  NAME 
  9777.  
  9778. read - Read from a channel 
  9779.  
  9780. SYNOPSIS 
  9781.  
  9782. read ?-nonewline? channelId 
  9783.  read channelId numBytes 
  9784.  
  9785. DESCRIPTION 
  9786.  
  9787. In the first form, the read command reads all of the data from channelId up to 
  9788. the end of the file. If the -nonewline switch is specified then the last 
  9789. character of the file is discarded if it is a newline. In the second form, the 
  9790. extra argument specifies how many bytes to read.  Exactly that many bytes will 
  9791. be read and returned, unless there are fewer than numBytes left in the file; 
  9792. in this case all the remaining bytes are returned. 
  9793.  
  9794. If channelId is in nonblocking mode, the command may not read as many bytes as 
  9795. requested:  once all available input has been read, the command will return the 
  9796. data that is available rather than blocking for more input. The -nonewline 
  9797. switch is ignored if the command returns before reaching the end of the file. 
  9798.  
  9799. Read translates end-of-line sequences in the input into newline characters 
  9800. according to the -translation option for the channel. See the manual entry for 
  9801. fconfigure for details on the -translation option. 
  9802.  
  9803. SEE ALSO 
  9804.  
  9805. eof(n), fblocked(n), fconfigure(n) 
  9806.  
  9807. KEYWORDS 
  9808.  
  9809. blocking, channel, end of line, end of file, nonblocking, read, translation 
  9810.  
  9811.  
  9812. ΓòÉΓòÉΓòÉ 3.57. regexp ΓòÉΓòÉΓòÉ
  9813.  
  9814.  NAME 
  9815.  
  9816. regexp - Match a regular expression against a string 
  9817.  
  9818. SYNOPSIS 
  9819.  
  9820. regexp ?switches? exp string ?matchVar? ?subMatchVar subMatchVar ...? 
  9821.  
  9822. DESCRIPTION 
  9823.  
  9824. Determines whether the regular expression exp matches part or all of string and 
  9825. returns 1 if it does, 0 if it doesn't. 
  9826.  
  9827. If additional arguments are specified after string then they are treated as the 
  9828. names of variables in which to return information about which part(s) of string 
  9829. matched exp. MatchVar will be set to the range of string that matched all of 
  9830. exp.  The first subMatchVar will contain the characters in string that matched 
  9831. the leftmost parenthesized subexpression within exp, the next subMatchVar will 
  9832. contain the characters that matched the next parenthesized subexpression to the 
  9833. right in exp, and so on. 
  9834.  
  9835. If the initial arguments to regexp start with - then they are treated as 
  9836. switches.  The following switches are currently supported: 
  9837.  
  9838.  -nocase   Causes upper-case characters in string to be treated as lower case 
  9839.            during the matching process. 
  9840.  
  9841.  -indices  Changes what is stored in the subMatchVars. Instead of storing the 
  9842.            matching characters from string, each variable will contain a list 
  9843.            of two decimal strings giving the indices in string of the first and 
  9844.            last characters in the matching range of characters. 
  9845.  
  9846.  --        Marks the end of switches.  The argument following this one will be 
  9847.            treated as exp even if it starts with a -. 
  9848.  
  9849.  If there are more subMatchVar's than parenthesized subexpressions within exp, 
  9850.  or if a particular subexpression in exp doesn't match the string (e.g. because 
  9851.  it was in a portion of the expression that wasn't matched), then the 
  9852.  corresponding subMatchVar will be set to "-1 -1" if -indices has been 
  9853.  specified or to an empty string otherwise. 
  9854.  
  9855.  REGULAR EXPRESSIONS 
  9856.  
  9857.  Regular expressions are implemented using Henry Spencer's package (thanks, 
  9858.  Henry!), and much of the description of regular expressions below is copied 
  9859.  verbatim from his manual entry. 
  9860.  
  9861.  A regular expression is zero or more branches, separated by "|". It matches 
  9862.  anything that matches one of the branches. 
  9863.  
  9864.  A branch is zero or more pieces, concatenated. It matches a match for the 
  9865.  first, followed by a match for the second, etc. 
  9866.  
  9867.  A piece is an atom possibly followed by "*", "+", or "?". An atom followed by 
  9868.  "*" matches a sequence of 0 or more matches of the atom. An atom followed by 
  9869.  "+" matches a sequence of 1 or more matches of the atom. An atom followed by 
  9870.  "?" matches a match of the atom, or the null string. 
  9871.  
  9872.  An atom is a regular expression in parentheses (matching a match for the 
  9873.  regular expression), a range (see below), "." (matching any single character), 
  9874.  "^" (matching the null string at the beginning of the input string), "$" 
  9875.  (matching the null string at the end of the input string), a "\" followed by a 
  9876.  single character (matching that character), or a single character with no 
  9877.  other significance (matching that character). 
  9878.  
  9879.  A range is a sequence of characters enclosed in "[]". It normally matches any 
  9880.  single character from the sequence. If the sequence begins with "^", it 
  9881.  matches any single character not from the rest of the sequence. If two 
  9882.  characters in the sequence are separated by "-", this is shorthand for the 
  9883.  full list of ASCII characters between them (e.g. "[0-9]" matches any decimal 
  9884.  digit). To include a literal "]" in the sequence, make it the first character 
  9885.  (following a possible "^"). To include a literal "-", make it the first or 
  9886.  last character. 
  9887.  
  9888.  CHOOSING AMONG ALTERNATIVE MATCHES 
  9889.  
  9890.  In general there may be more than one way to match a regular expression to an 
  9891.  input string.  For example, consider the command 
  9892.  
  9893.   regexp  (a*)b*  aabaaabb  x  y
  9894.  Considering only the rules given so far, x and y could end up with the values 
  9895.  aabb and aa, aaab and aaa, ab and a, or any of several other combinations. To 
  9896.  resolve this potential ambiguity regexp chooses among alternatives using the 
  9897.  rule "first then longest". In other words, it considers the possible matches 
  9898.  in order working from left to right across the input string and the pattern, 
  9899.  and it attempts to match longer pieces of the input string before shorter 
  9900.  ones.  More specifically, the following rules apply in decreasing order of 
  9901.  priority: 
  9902.  
  9903.    1. If a regular expression could match two different parts of an input 
  9904.       string then it will match the one that begins earliest. 
  9905.  
  9906.    2. If a regular expression contains | operators then the leftmost matching 
  9907.       sub-expression is chosen. 
  9908.  
  9909.    3. In *, +, and ? constructs, longer matches are chosen in preference to 
  9910.       shorter ones. 
  9911.  
  9912.    4. In sequences of expression components the components are considered from 
  9913.       left to right. 
  9914.  
  9915.  In the example from above, (a*)b* matches aab:  the (a*) portion of the 
  9916.  pattern is matched first and it consumes the leading aa; then the b* portion 
  9917.  of the pattern consumes the next b.  Or, consider the following example: 
  9918.  
  9919.   regexp  (ab|a)(b*)c  abc  x  y  z
  9920.  After this command x will be abc, y will be ab, and z will be an empty string. 
  9921.  Rule 4 specifies that (ab|a) gets first shot at the input string and Rule 2 
  9922.  specifies that the ab sub-expression is checked before the a sub-expression. 
  9923.  Thus the b has already been claimed before the (b*) component is checked and 
  9924.  (b*) must match an empty string. 
  9925.  
  9926.  KEYWORDS 
  9927.  
  9928.  match, regular expression, string 
  9929.  
  9930.  
  9931. ΓòÉΓòÉΓòÉ 3.58. regsub ΓòÉΓòÉΓòÉ
  9932.  
  9933.  NAME 
  9934.  
  9935. regsub - Perform substitutions based on regular expression pattern matching 
  9936.  
  9937. SYNOPSIS 
  9938.  
  9939. regsub ?switches? exp string subSpec varName 
  9940.  
  9941. DESCRIPTION 
  9942.  
  9943. This command matches the regular expression exp against string, and it copies 
  9944. string to the variable whose name is given by varName. If there is a match, 
  9945. then while copying string to varName the portion of string that matched exp is 
  9946. replaced with subSpec. If subSpec contains a "&" or "\0", then it is replaced 
  9947. in the substitution with the portion of string that matched exp. If subSpec 
  9948. contains a "\n", where n is a digit between 1 and 9, then it is replaced in the 
  9949. substitution with the portion of string that matched the n-th parenthesized 
  9950. subexpression of exp. Additional backslashes may be used in subSpec to prevent 
  9951. special interpretation of "&" or "\0" or "\n" or backslash. The use of 
  9952. backslashes in subSpec tends to interact badly with the Tcl parser's use of 
  9953. backslashes, so it's generally safest to enclose subSpec in braces if it 
  9954. includes backslashes. 
  9955.  
  9956. If the initial arguments to regexp start with - then they are treated as 
  9957. switches.  The following switches are currently supported: 
  9958.  
  9959.  -all      All ranges in string that match exp are found and substitution is 
  9960.            performed for each of these ranges. Without this switch only the 
  9961.            first matching range is found and substituted. If -all is specified, 
  9962.            then "&" and "\n" sequences are handled for each substitution using 
  9963.            the information from the corresponding match. 
  9964.  
  9965.  -nocase   Upper-case characters in string will be converted to lower-case 
  9966.            before matching against exp;  however, substitutions specified by 
  9967.            subSpec use the original unconverted form of string. 
  9968.  
  9969.  --        Marks the end of switches.  The argument following this one will be 
  9970.            treated as exp even if it starts with a -. 
  9971.  
  9972.  The command returns a count of the number of matching ranges that were found 
  9973.  and replaced. See the manual entry for regexp for details on the 
  9974.  interpretation of regular expressions. 
  9975.  
  9976.  KEYWORDS 
  9977.  
  9978.  match, pattern, regular expression, substitute 
  9979.  
  9980.  
  9981. ΓòÉΓòÉΓòÉ 3.59. rename ΓòÉΓòÉΓòÉ
  9982.  
  9983.  NAME 
  9984.  
  9985. rename - Rename or delete a command 
  9986.  
  9987. SYNOPSIS 
  9988.  
  9989. rename oldName newName 
  9990.  
  9991. DESCRIPTION 
  9992.  
  9993. Rename the command that used to be called oldName so that it is now called 
  9994. newName.  If newName is an empty string then oldName is deleted.  The rename 
  9995. command returns an empty string as result. 
  9996.  
  9997. KEYWORDS 
  9998.  
  9999. command, delete, rename 
  10000.  
  10001.  
  10002. ΓòÉΓòÉΓòÉ 3.60. return ΓòÉΓòÉΓòÉ
  10003.  
  10004.  NAME 
  10005.  
  10006. return - Return from a procedure 
  10007.  
  10008. SYNOPSIS 
  10009.  
  10010. return ?-code code? ?-errorinfo info? ?-errorcode code? ?string? 
  10011.  
  10012. DESCRIPTION 
  10013.  
  10014. Return immediately from the current procedure (or top-level command or source 
  10015. command), with string as the return value.  If string is not specified then an 
  10016. empty string will be returned as result. 
  10017.  
  10018. EXCEPTIONAL RETURNS 
  10019.  
  10020. In the usual case where the -code option isn't specified the procedure will 
  10021. return normally (its completion code will be TCL_OK). However, the -code option 
  10022. may be used to generate an exceptional return from the procedure. Code may have 
  10023. any of the following values: 
  10024.  
  10025.  ok        Normal return:  same as if the option is omitted. 
  10026.  
  10027.  error     Error return: same as if the error command were used to terminate 
  10028.            the procedure, except for handling of errorInfo and errorCode 
  10029.            variables (see below). 
  10030.  
  10031.  return    The current procedure will return with a completion code of 
  10032.            TCL_RETURN, so that the procedure that invoked it will return also. 
  10033.  
  10034.  break     The current procedure will return with a completion code of 
  10035.            TCL_BREAK, which will terminate the innermost nested loop in the 
  10036.            code that invoked the current procedure. 
  10037.  
  10038.  continue  The current procedure will return with a completion code of 
  10039.            TCL_CONTINUE, which will terminate the current iteration of the 
  10040.            innermost nested loop in the code that invoked the current 
  10041.            procedure. 
  10042.  
  10043.  value     Value must be an integer;  it will be returned as the completion 
  10044.            code for the current procedure. 
  10045.  
  10046.  The -code option is rarely used. It is provided so that procedures that 
  10047.  implement new control structures can reflect exceptional conditions back to 
  10048.  their callers. 
  10049.  
  10050.  Two additional options, -errorinfo and -errorcode, may be used to provide 
  10051.  additional information during error returns. These options are ignored unless 
  10052.  code is error. 
  10053.  
  10054.  The -errorinfo option specifies an initial stack trace for the errorInfo 
  10055.  variable;  if it is not specified then the stack trace left in errorInfo will 
  10056.  include the call to the procedure and higher levels on the stack but it will 
  10057.  not include any information about the context of the error within the 
  10058.  procedure. Typically the info value is supplied from the value left in 
  10059.  errorInfo after a catch command trapped an error within the procedure. 
  10060.  
  10061.  If the -errorcode option is specified then code provides a value for the 
  10062.  errorCode variable. If the option is not specified then errorCode will default 
  10063.  to NONE. 
  10064.  
  10065.  KEYWORDS 
  10066.  
  10067.  break, continue, error, procedure, return 
  10068.  
  10069.  
  10070. ΓòÉΓòÉΓòÉ 3.61. scan ΓòÉΓòÉΓòÉ
  10071.  
  10072.  NAME 
  10073.  
  10074. scan - Parse string using conversion specifiers in the style of sscanf 
  10075.  
  10076. SYNOPSIS 
  10077.  
  10078. scan string format varName ?varName ...? 
  10079.  
  10080. INTRODUCTION 
  10081.  
  10082. This command parses fields from an input string in the same fashion as the ANSI 
  10083. C sscanf procedure and returns a count of the number of conversions performed, 
  10084. or -1 if the end of the input string is reached before any conversions have 
  10085. been performed. String gives the input to be parsed and format indicates how to 
  10086. parse it, using % conversion specifiers as in sscanf. Each varName gives the 
  10087. name of a variable; when a field is scanned from string the result is converted 
  10088. back into a string and assigned to the corresponding variable. 
  10089.  
  10090. DETAILS ON SCANNING 
  10091.  
  10092. Scan operates by scanning string and formatString together. If the next 
  10093. character in formatString is a blank or tab then it matches any number of white 
  10094. space characters in string (including zero). Otherwise, if it isn't a % 
  10095. character then it must match the next character of string. When a % is 
  10096. encountered in formatString, it indicates the start of a conversion specifier. 
  10097. A conversion specifier contains three fields after the %: a *, which indicates 
  10098. that the converted value is to be discarded instead of assigned to a variable; 
  10099. a number indicating a maximum field width; and a conversion character. All of 
  10100. these fields are optional except for the conversion character. 
  10101.  
  10102. When scan finds a conversion specifier in formatString, it first skips any 
  10103. white-space characters in string. Then it converts the next input characters 
  10104. according to the conversion specifier and stores the result in the variable 
  10105. given by the next argument to scan. The following conversion characters are 
  10106. supported: 
  10107.  
  10108.  d         The input field must be a decimal integer. It is read in and the 
  10109.            value is stored in the variable as a decimal string. 
  10110.  
  10111.  o         The input field must be an octal integer. It is read in and the 
  10112.            value is stored in the variable as a decimal string. 
  10113.  
  10114.  x         The input field must be a hexadecimal integer. It is read in and the 
  10115.            value is stored in the variable as a decimal string. 
  10116.  
  10117.  c         A single character is read in and its binary value is stored in the 
  10118.            variable as a decimal string. Initial white space is not skipped in 
  10119.            this case, so the input field may be a white-space character. This 
  10120.            conversion is different from the ANSI standard in that the input 
  10121.            field always consists of a single character and no field width may 
  10122.            be specified. 
  10123.  
  10124.  s         The input field consists of all the characters up to the next 
  10125.            white-space character; the characters are copied to the variable. 
  10126.  
  10127.  e or f or g  The input field must be a floating-point number consisting of an 
  10128.            optional sign, a string of decimal digits possibly containing a 
  10129.            decimal point, and an optional exponent consisting of an e or E 
  10130.            followed by an optional sign and a string of decimal digits. It is 
  10131.            read in and stored in the variable as a floating-point string. 
  10132.  
  10133.  [chars]   The input field consists of any number of characters in chars. The 
  10134.            matching string is stored in the variable. If the first character 
  10135.            between the brackets is a ] then it is treated as part of chars 
  10136.            rather than the closing bracket for the set. 
  10137.  
  10138.  [^chars]  The input field consists of any number of characters not in chars. 
  10139.            The matching string is stored in the variable. If the character 
  10140.            immediately following the ^ is a ] then it is treated as part of the 
  10141.            set rather than the closing bracket for the set. 
  10142.  
  10143.  The number of characters read from the input for a conversion is the largest 
  10144.  number that makes sense for that particular conversion (e.g. as many decimal 
  10145.  digits as possible for %d, as many octal digits as possible for %o, and so 
  10146.  on). The input field for a given conversion terminates either when a 
  10147.  white-space character is encountered or when the maximum field width has been 
  10148.  reached, whichever comes first. If a * is present in the conversion specifier 
  10149.  then no variable is assigned and the next scan argument is not consumed. 
  10150.  
  10151.  DIFFERENCES FROM ANSI SSCANF 
  10152.  
  10153.  The behavior of the scan command is the same as the behavior of the ANSI C 
  10154.  sscanf procedure except for the following differences: 
  10155.  
  10156.    1. %p and %n conversion specifiers are not currently supported. 
  10157.  
  10158.    2. For %c conversions a single character value is converted to a decimal 
  10159.       string, which is then assigned to the corresponding varName; no field 
  10160.       width may be specified for this conversion. 
  10161.  
  10162.    3. The l, h, and L modifiers are ignored;  integer values are always 
  10163.       converted as if there were no modifier present and real values are always 
  10164.       converted as if the l modifier were present (i.e. type double is used for 
  10165.       the internal representation). 
  10166.  
  10167.  KEYWORDS 
  10168.  
  10169.  conversion specifier, parse, scan 
  10170.  
  10171.  
  10172. ΓòÉΓòÉΓòÉ 3.62. seek ΓòÉΓòÉΓòÉ
  10173.  
  10174.  NAME 
  10175.  
  10176. seek - Change the access position for an open channel 
  10177.  
  10178. SYNOPSIS 
  10179.  
  10180. seek channelId offset ?origin? 
  10181.  
  10182. DESCRIPTION 
  10183.  
  10184. Changes the current access position for channelId. ChannelId must be a channel 
  10185. identifier such as returned from a previous invocation of open or socket. The 
  10186. offset and origin arguments specify the position at which the next read or 
  10187. write will occur for channelId. Offset must be an integer (which may be 
  10188. negative) and origin must be one of the following: 
  10189.  
  10190.  start     The new access position will be offset bytes from the start of the 
  10191.            underlying file or device. 
  10192.  
  10193.  current   The new access position will be offset bytes from the current access 
  10194.            position; a negative offset moves the access position backwards in 
  10195.            the underlying file or device. 
  10196.  
  10197.  end       The new access position will be offset bytes from the end of the 
  10198.            file or device.  A negative offset places the access position before 
  10199.            the end of file, and a positive offset places the access position 
  10200.            after the end of file. 
  10201.  
  10202.  The origin argument defaults to start. 
  10203.  
  10204.  The command flushes all buffered output for the channel before the command 
  10205.  returns, even if the channel is in nonblocking mode. It also discards any 
  10206.  buffered and unread input. This command returns an empty string. An error 
  10207.  occurs if this command is applied to channels whose underlying file or device 
  10208.  does not support seeking. 
  10209.  
  10210.  KEYWORDS 
  10211.  
  10212.  access position, file, seek 
  10213.  
  10214.  
  10215. ΓòÉΓòÉΓòÉ 3.63. set ΓòÉΓòÉΓòÉ
  10216.  
  10217.  NAME 
  10218.  
  10219. set - Read and write variables 
  10220.  
  10221. SYNOPSIS 
  10222.  
  10223. set varName ?value? 
  10224.  
  10225. DESCRIPTION 
  10226.  
  10227. Returns the value of variable varName. If value is specified, then set the 
  10228. value of varName to value, creating a new variable if one doesn't already 
  10229. exist, and return its value. If varName contains an open parenthesis and ends 
  10230. with a close parenthesis, then it refers to an array element:  the characters 
  10231. before the first open parenthesis are the name of the array, and the characters 
  10232. between the parentheses are the index within the array. Otherwise varName 
  10233. refers to a scalar variable. If no procedure is active, then varName refers to 
  10234. a global variable. If a procedure is active, then varName refers to a parameter 
  10235. or local variable of the procedure unless the global command has been invoked 
  10236. to declare varName to be global. 
  10237.  
  10238. KEYWORDS 
  10239.  
  10240. read, write, variable 
  10241.  
  10242.  
  10243. ΓòÉΓòÉΓòÉ 3.64. socket ΓòÉΓòÉΓòÉ
  10244.  
  10245.  NAME 
  10246.  
  10247. socket - Open a TCP network connection 
  10248.  
  10249. SYNOPSIS 
  10250.  
  10251.  
  10252.  socket ?options? host port 
  10253.  socket -server command ?options? port 
  10254.  
  10255. DESCRIPTION 
  10256.  
  10257. This command opens a network socket and returns a channel identifier that may 
  10258. be used in future invocations of commands like read, puts and flush. At present 
  10259. only the TCP network protocol is supported;  future releases may include 
  10260. support for additional protocols. The socket command may be used to open either 
  10261. the client or server side of a connection, depending on whether the -server 
  10262. switch is specified. 
  10263.  
  10264. CLIENT SOCKETS 
  10265.  
  10266. If the -server option is not specified, then the client side of a connection is 
  10267. opened and the command returns a channel identifier that can be used for both 
  10268. reading and writing. Port and host specify a port to connect to;  there must be 
  10269. a server accepting connections on this port.  Port is an integer port number 
  10270. and host is either a domain-style name such as www.sunlabs.com or a numerical 
  10271. IP address such as 127.0.0.1. Use localhost to refer to the host on which the 
  10272. command is invoked. 
  10273.  
  10274. The following options may also be present before host to specify additional 
  10275. information about the connection: 
  10276.  
  10277.  -myaddr addr  Addr gives the domain-style name or numerical IP address of the 
  10278.            client-side network interface to use for the connection. This option 
  10279.            may be useful if the client machine has multiple network interfaces. 
  10280.            If the option is omitted then the client-side interface will be 
  10281.            chosen by the system software. 
  10282.  
  10283.  -myport port  Port specifies an integer port number to use for the client's 
  10284.            side of the connection.  If this option is omitted, the client's 
  10285.            port number will be chosen at random by the system software. 
  10286.  
  10287.  -async    The -async option will cause the client socket to be connected 
  10288.            asynchronously. This means that the socket will be created 
  10289.            immediately but may not yet be connected to the server, when the 
  10290.            call to socket returns. When a gets or flush is done on the socket 
  10291.            before the connection attempt succeeds or fails, if the socket is in 
  10292.            blocking mode, the operation will wait until the connection is 
  10293.            completed or fails. If the socket is in nonblocking mode and a gets 
  10294.            or flush is done on the socket before the connection attempt 
  10295.            succeeds or fails, the operation returns immediately and fblocked on 
  10296.            the socket returns 1. 
  10297.  
  10298.  SERVER SOCKETS 
  10299.  
  10300.  If the -server option is specified then the new socket will be a server for 
  10301.  the port given by port. Tcl will automatically accept connections to the given 
  10302.  port. For each connection Tcl will create a new channel that may be used to 
  10303.  communicate with the client.  Tcl then invokes command with three additional 
  10304.  arguments: the name of the new channel, the address, in network address 
  10305.  notation, of the client's host, and the client's port number. 
  10306.  
  10307.  The following additional option may also be specified before host: 
  10308.  
  10309.  -myaddr addr  Addr gives the domain-style name or numerical IP address of the 
  10310.            server-side network interface to use for the connection. This option 
  10311.            may be useful if the server machine has multiple network interfaces. 
  10312.            If the option is omitted then the server socket is bound to the 
  10313.            special address INADDR_ANY so that it can accept connections from 
  10314.            any interface. 
  10315.  
  10316.  Server channels cannot be used for input or output; their sole use is to 
  10317.  accept new client connections. The channels created for each incoming client 
  10318.  connection are opened for input and output. Closing the server channel shuts 
  10319.  down the server so that no new connections will be accepted;  however, 
  10320.  existing connections will be unaffected. 
  10321.  
  10322.  Server sockets depend on the Tcl event mechanism to find out when new 
  10323.  connections are opened.  If the application doesn't enter the event loop, for 
  10324.  example by invoking the vwait command or calling the C procedure 
  10325.  Tcl_DoOneEvent, then no connections will be accepted. 
  10326.  
  10327.  CONFIGURATION OPTIONS 
  10328.  
  10329.  The fconfigure command can be used to query several readonly configuration 
  10330.  options for socket channels: 
  10331.  
  10332.  -sockname  This option returns a list of three elements, the address, the host 
  10333.            name and the port number for the socket. If the host name cannot be 
  10334.            computed, the second element is identical to the address, the first 
  10335.            element of the list. 
  10336.  
  10337.  -peername  This option is not supported by server sockets. For client and 
  10338.            accepted sockets, this option returns a list of three elements; 
  10339.            these are the address, the host name and the port to which the peer 
  10340.            socket is connected or bound. If the host name cannot be computed, 
  10341.            the second element of the list is identical to the address, its 
  10342.            first element. 
  10343.  
  10344.  SEE ALSO 
  10345.  
  10346.  flush(n), open(n), read(n) 
  10347.  
  10348.  KEYWORDS 
  10349.  
  10350.  bind, channel, connection, domain name, host, network address, socket, tcp 
  10351.  
  10352.  
  10353. ΓòÉΓòÉΓòÉ 3.65. source ΓòÉΓòÉΓòÉ
  10354.  
  10355.  NAME 
  10356.  
  10357. source - Evaluate a file or resource as a Tcl script 
  10358.  
  10359. SYNOPSIS 
  10360.  
  10361. source fileName 
  10362.  source -rsrc resourceName ?fileName? 
  10363.  source -rsrcid resourceId ?fileName? 
  10364.  
  10365. DESCRIPTION 
  10366.  
  10367. This command takes the contents of the specified file or resource and passes it 
  10368. to the Tcl interpreter as a text script.  The return value from source is the 
  10369. return value of the last command executed in the script.  If an error occurs in 
  10370. evaluating the contents of the script then the source command will return that 
  10371. error. If a return command is invoked from within the script then the remainder 
  10372. of the file will be skipped and the source command will return normally with 
  10373. the result from the return command.  The -rsrc and -rsrcid forms of this 
  10374. command are only available on Macintosh computers.  These versions of the 
  10375. command allow you to source a script from a TEXT resource.  You may specify 
  10376. what TEXT resource to source by either name or id.  By default Tcl searches all 
  10377. open resource files, which include the current application and any loaded C 
  10378. extensions.  Alternatively, you may specify the fileName where the TEXT 
  10379. resource can be found. 
  10380.  
  10381. KEYWORDS 
  10382.  
  10383. file, script 
  10384.  
  10385.  
  10386. ΓòÉΓòÉΓòÉ 3.66. split ΓòÉΓòÉΓòÉ
  10387.  
  10388.  NAME 
  10389.  
  10390. split - Split a string into a proper Tcl list 
  10391.  
  10392. SYNOPSIS 
  10393.  
  10394. split string ?splitChars? 
  10395.  
  10396. DESCRIPTION 
  10397.  
  10398. Returns a list created by splitting string at each character that is in the 
  10399. splitChars argument. Each element of the result list will consist of the 
  10400. characters from string that lie between instances of the characters in 
  10401. splitChars. Empty list elements will be generated if string contains adjacent 
  10402. characters in splitChars, or if the first or last character of string is in 
  10403. splitChars. If splitChars is an empty string then each character of string 
  10404. becomes a separate element of the result list. SplitChars defaults to the 
  10405. standard white-space characters. For example, 
  10406.  
  10407. split "comp.unix.misc" .
  10408. returns "comp unix misc" and 
  10409.  
  10410. split "Hello world" {}
  10411. returns "H e l l o { } w o r l d". 
  10412.  
  10413. KEYWORDS 
  10414.  
  10415. list, split, string 
  10416.  
  10417.  
  10418. ΓòÉΓòÉΓòÉ 3.67. string ΓòÉΓòÉΓòÉ
  10419.  
  10420.  NAME 
  10421.  
  10422. string - Manipulate strings 
  10423.  
  10424. SYNOPSIS 
  10425.  
  10426. string option arg ?arg ...? 
  10427.  
  10428. DESCRIPTION 
  10429.  
  10430. Performs one of several string operations, depending on option. The legal 
  10431. options (which may be abbreviated) are: 
  10432.  
  10433.  string compare string1 string2  Perform a character-by-character comparison of 
  10434.            strings string1 and string2 in the same way as the C strcmp 
  10435.            procedure.  Return -1, 0, or 1, depending on whether string1 is 
  10436.            lexicographically less than, equal to, or greater than string2. 
  10437.  
  10438.  string first string1 string2  Search string2 for a sequence of characters that 
  10439.            exactly match the characters in string1.  If found, return the index 
  10440.            of the first character in the first such match within string2.  If 
  10441.            not found, return -1. 
  10442.  
  10443.  string index string charIndex  Returns the charIndex'th character of the 
  10444.            string argument.  A charIndex of 0 corresponds to the first 
  10445.            character of the string. If charIndex is less than 0 or greater than 
  10446.            or equal to the length of the string then an empty string is 
  10447.            returned. 
  10448.  
  10449.  string last string1 string2  Search string2 for a sequence of characters that 
  10450.            exactly match the characters in string1.  If found, return the index 
  10451.            of the first character in the last such match within string2.  If 
  10452.            there is no match, then return -1. 
  10453.  
  10454.  string length string  Returns a decimal string giving the number of characters 
  10455.            in string. 
  10456.  
  10457.  string match pattern string  See if pattern matches string; return 1 if it 
  10458.            does, 0 if it doesn't.  Matching is done in a fashion similar to 
  10459.            that used by the C-shell.  For the two strings to match, their 
  10460.            contents must be identical except that the following special 
  10461.            sequences may appear in pattern: 
  10462.  
  10463.            *              Matches any sequence of characters in string, 
  10464.                           including a null string. 
  10465.  
  10466.            ?              Matches any single character in string. 
  10467.  
  10468.            [chars]        Matches any character in the set given by chars.  If 
  10469.                           a sequence of the form x-y appears in chars, then any 
  10470.                           character between x and y, inclusive, will match. 
  10471.  
  10472.            \x             Matches the single character x.  This provides a way 
  10473.                           of avoiding the special interpretation of the 
  10474.                           characters *?[]\ in pattern. 
  10475.  
  10476.  string range string first last  Returns a range of consecutive characters from 
  10477.            string, starting with the character whose index is first and ending 
  10478.            with the character whose index is last. An index of 0 refers to the 
  10479.            first character of the string. An index of end (or any abbreviation 
  10480.            of it) refers to the last character of the string. If first is less 
  10481.            than zero then it is treated as if it were zero, and if last is 
  10482.            greater than or equal to the length of the string then it is treated 
  10483.            as if it were end.  If first is greater than last then an empty 
  10484.            string is returned. 
  10485.  
  10486.  string tolower string  Returns a value equal to string except that all upper 
  10487.            case letters have been converted to lower case. 
  10488.  
  10489.  string toupper string  Returns a value equal to string except that all lower 
  10490.            case letters have been converted to upper case. 
  10491.  
  10492.  string trim string ?chars?  Returns a value equal to string except that any 
  10493.            leading or trailing characters from the set given by chars are 
  10494.            removed. If chars is not specified then white space is removed 
  10495.            (spaces, tabs, newlines, and carriage returns). 
  10496.  
  10497.  string trimleft string ?chars?  Returns a value equal to string except that 
  10498.            any leading characters from the set given by chars are removed. If 
  10499.            chars is not specified then white space is removed (spaces, tabs, 
  10500.            newlines, and carriage returns). 
  10501.  
  10502.  string trimright string ?chars?  Returns a value equal to string except that 
  10503.            any trailing characters from the set given by chars are removed. If 
  10504.            chars is not specified then white space is removed (spaces, tabs, 
  10505.            newlines, and carriage returns). 
  10506.  
  10507.  string wordend string index  Returns the index of the character just after the 
  10508.            last one in the word containing character index of string. A word is 
  10509.            considered to be any contiguous range of alphanumeric or underscore 
  10510.            characters, or any single character other than these. 
  10511.  
  10512.  string wordstart string index  Returns the index of the first character in the 
  10513.            word containing character index of string. A word is considered to 
  10514.            be any contiguous range of alphanumeric or underscore characters, or 
  10515.            any single character other than these. 
  10516.  
  10517.  KEYWORDS 
  10518.  
  10519.  case conversion, compare, index, match, pattern, string, word 
  10520.  
  10521.  
  10522. ΓòÉΓòÉΓòÉ 3.68. subst ΓòÉΓòÉΓòÉ
  10523.  
  10524.  NAME 
  10525.  
  10526. subst - Perform backslash, command, and variable substitutions 
  10527.  
  10528. SYNOPSIS 
  10529.  
  10530. subst ?-nobackslashes? ?-nocommands? ?-novariables? string 
  10531.  
  10532. DESCRIPTION 
  10533.  
  10534. This command performs variable substitutions, command substitutions, and 
  10535. backslash substitutions on its string argument and returns the 
  10536. fully-substituted result. The substitutions are performed in exactly the same 
  10537. way as for Tcl commands. As a result, the string argument is actually 
  10538. substituted twice, once by the Tcl parser in the usual fashion for Tcl 
  10539. commands, and again by the subst command. 
  10540.  
  10541. If any of the -nobackslashes, -nocommands, or -novariables are specified, then 
  10542. the corresponding substitutions are not performed. For example, if -nocommands 
  10543. is specified, no command substitution is performed:  open and close brackets 
  10544. are treated as ordinary characters with no special interpretation. 
  10545.  
  10546. Note: when it performs its substitutions, subst does not give any special 
  10547. treatment to double quotes or curly braces.  For example, the script 
  10548.  
  10549. set a 44
  10550. subst {xyz {$a}}
  10551. returns "xyz {44}", not "xyz {$a}". 
  10552.  
  10553. KEYWORDS 
  10554.  
  10555. backslash substitution, command substitution, variable substitution 
  10556.  
  10557.  
  10558. ΓòÉΓòÉΓòÉ 3.69. switch ΓòÉΓòÉΓòÉ
  10559.  
  10560.  NAME 
  10561.  
  10562. switch - Evaluate one of several scripts, depending on a given value 
  10563.  
  10564. SYNOPSIS 
  10565.  
  10566. switch ?options? string pattern body ?pattern body ...? 
  10567.  switch ?options? string {pattern body ?pattern body ...?} 
  10568.  
  10569. DESCRIPTION 
  10570.  
  10571. The switch command matches its string argument against each of the pattern 
  10572. arguments in order. As soon as it finds a pattern that matches string it 
  10573. evaluates the following body argument by passing it recursively to the Tcl 
  10574. interpreter and returns the result of that evaluation. If the last pattern 
  10575. argument is default then it matches anything. If no pattern argument matches 
  10576. string and no default is given, then the switch command returns an empty 
  10577. string. 
  10578.  
  10579. If the initial arguments to switch start with - then they are treated as 
  10580. options.  The following options are currently supported: 
  10581.  
  10582.  -exact    Use exact matching when comparing string to a pattern.  This is the 
  10583.            default. 
  10584.  
  10585.  -glob     When matching string to the patterns, use glob-style matching (i.e. 
  10586.            the same as implemented by the string match command). 
  10587.  
  10588.  -regexp   When matching string to the patterns, use regular expression 
  10589.            matching (i.e. the same as implemented by the regexp command). 
  10590.  
  10591.  --        Marks the end of options.  The argument following this one will be 
  10592.            treated as string even if it starts with a -. 
  10593.  
  10594.  Two syntaxes are provided for the pattern and body arguments. The first uses a 
  10595.  separate argument for each of the patterns and commands; this form is 
  10596.  convenient if substitutions are desired on some of the patterns or commands. 
  10597.  The second form places all of the patterns and commands together into a single 
  10598.  argument; the argument must have proper list structure, with the elements of 
  10599.  the list being the patterns and commands. The second form makes it easy to 
  10600.  construct multi-line switch commands, since the braces around the whole list 
  10601.  make it unnecessary to include a backslash at the end of each line. Since the 
  10602.  pattern arguments are in braces in the second form, no command or variable 
  10603.  substitutions are performed on them;  this makes the behavior of the second 
  10604.  form different than the first form in some cases. 
  10605.  
  10606.  If a body is specified as "-" it means that the body for the next pattern 
  10607.  should also be used as the body for this pattern (if the next pattern also has 
  10608.  a body of "-" then the body after that is used, and so on). This feature makes 
  10609.  it possible to share a single body among several patterns. 
  10610.  
  10611.  Below are some examples of switch commands: 
  10612.  
  10613.   switch abc a - b {format 1} abc {format 2} default {format 3}
  10614.  will return 2, 
  10615.  
  10616.   switch -regexp aaab {
  10617.          ^a.*b$ -
  10618.          b {format 1}
  10619.          a* {format 2}
  10620.          default {format 3}
  10621.   }
  10622.  will return 1, and 
  10623.  
  10624.   switch xyz {
  10625.          a
  10626.                 -
  10627.          b
  10628.                 {format 1}
  10629.          a*
  10630.                 {format 2}
  10631.          default
  10632.                 {format 3}
  10633.   }
  10634.  will return 3. 
  10635.  
  10636.  KEYWORDS 
  10637.  
  10638.  switch, match, regular expression 
  10639.  
  10640.  
  10641. ΓòÉΓòÉΓòÉ 3.70. tclvars ΓòÉΓòÉΓòÉ
  10642.  
  10643.  NAME 
  10644.  
  10645. tclvars - Variables used by Tcl 
  10646.  
  10647. DESCRIPTION 
  10648.  
  10649. The following global variables are created and managed automatically by the Tcl 
  10650. library.  Except where noted below, these variables should normally be treated 
  10651. as read-only by application-specific code and by users. 
  10652.  
  10653.  env       This variable is maintained by Tcl as an array whose elements are 
  10654.            the environment variables for the process. Reading an element will 
  10655.            return the value of the corresponding environment variable. Setting 
  10656.            an element of the array will modify the corresponding environment 
  10657.            variable or create a new one if it doesn't already exist. Unsetting 
  10658.            an element of env will remove the corresponding environment 
  10659.            variable. Changes to the env array will affect the environment 
  10660.            passed to children by commands like exec. If the entire env array is 
  10661.            unset then Tcl will stop monitoring env accesses and will not update 
  10662.            environment variables. 
  10663.  
  10664.  errorCode  After an error has occurred, this variable will be set to hold 
  10665.            additional information about the error in a form that is easy to 
  10666.            process with programs. errorCode consists of a Tcl list with one or 
  10667.            more elements. The first element of the list identifies a general 
  10668.            class of errors, and determines the format of the rest of the list. 
  10669.            The following formats for errorCode are used by the Tcl core; 
  10670.            individual applications may define additional formats. 
  10671.  
  10672.            ARITH code msg  This format is used when an arithmetic error occurs 
  10673.                           (e.g. an attempt to divide by zero in the expr 
  10674.                           command). Code identifies the precise error and msg 
  10675.                           provides a human-readable description of the error. 
  10676.                           Code will be either DIVZERO (for an attempt to divide 
  10677.                           by zero), DOMAIN (if an argument is outside the 
  10678.                           domain of a function, such as acos(-3)), IOVERFLOW 
  10679.                           (for integer overflow), OVERFLOW (for a 
  10680.                           floating-point overflow), or UNKNOWN (if the cause of 
  10681.                           the error cannot be determined). 
  10682.  
  10683.            CHILDKILLED pid sigName msg  This format is used when a child 
  10684.                           process has been killed because of a signal.  The 
  10685.                           second element of errorCode will be the process's 
  10686.                           identifier (in decimal). The third element will be 
  10687.                           the symbolic name of the signal that caused the 
  10688.                           process to terminate; it will be one of the names 
  10689.                           from the include file signal.h, such as SIGPIPE. The 
  10690.                           fourth element will be a short human-readable message 
  10691.                           describing the signal, such as "write on pipe with no 
  10692.                           readers" for SIGPIPE. 
  10693.  
  10694.            CHILDSTATUS pid code  This format is used when a child process has 
  10695.                           exited with a non-zero exit status.  The second 
  10696.                           element of errorCode will be the process's identifier 
  10697.                           (in decimal) and the third element will be the exit 
  10698.                           code returned by the process (also in decimal). 
  10699.  
  10700.            CHILDSUSP pid sigName msg  This format is used when a child process 
  10701.                           has been suspended because of a signal. The second 
  10702.                           element of errorCode will be the process's 
  10703.                           identifier, in decimal. The third element will be the 
  10704.                           symbolic name of the signal that caused the process 
  10705.                           to suspend; this will be one of the names from the 
  10706.                           include file signal.h, such as SIGTTIN. The fourth 
  10707.                           element will be a short human-readable message 
  10708.                           describing the signal, such as "background tty read" 
  10709.                           for SIGTTIN. 
  10710.  
  10711.            NONE           This format is used for errors where no additional 
  10712.                           information is available for an error besides the 
  10713.                           message returned with the error.  In these cases 
  10714.                           errorCode will consist of a list containing a single 
  10715.                           element whose contents are NONE. 
  10716.  
  10717.            POSIX errName msg  If the first element of errorCode is POSIX, then 
  10718.                           the error occurred during a POSIX kernel call. The 
  10719.                           second element of the list will contain the symbolic 
  10720.                           name of the error that occurred, such as ENOENT; this 
  10721.                           will be one of the values defined in the include file 
  10722.                           errno.h. The third element of the list will be a 
  10723.                           human-readable message corresponding to errName, such 
  10724.                           as "no such file or directory" for the ENOENT case. 
  10725.  
  10726.            To set errorCode, applications should use library procedures such as 
  10727.            Tcl_SetErrorCode and Tcl_PosixError, or they may invoke the error 
  10728.            command. If one of these methods hasn't been used, then the Tcl 
  10729.            interpreter will reset the variable to NONE after the next error. 
  10730.  
  10731.  errorInfo  After an error has occurred, this string will contain one or more 
  10732.            lines identifying the Tcl commands and procedures that were being 
  10733.            executed when the most recent error occurred. Its contents take the 
  10734.            form of a stack trace showing the various nested Tcl commands that 
  10735.            had been invoked at the time of the error. 
  10736.  
  10737.  tcl_library  This variable holds the name of a directory containing the system 
  10738.            library of Tcl scripts, such as those used for auto-loading. The 
  10739.            value of this variable is returned by the info library command. See 
  10740.            the library manual entry for details of the facilities provided by 
  10741.            the Tcl script library. Normally each application or package will 
  10742.            have its own application-specific script library in addition to the 
  10743.            Tcl script library; each application should set a global variable 
  10744.            with a name like $app_library (where app is the application's name) 
  10745.            to hold the network file name for that application's library 
  10746.            directory. The initial value of tcl_library is set when an 
  10747.            interpreter is created by searching several different directories 
  10748.            until one is found that contains an appropriate Tcl startup script. 
  10749.            If the TCL_LIBRARY environment variable exists, then the directory 
  10750.            it names is checked first. If TCL_LIBRARY isn't set or doesn't refer 
  10751.            to an appropriate directory, then Tcl checks several other 
  10752.            directories based on a compiled-in default location, the location of 
  10753.            the binary containing the application, and the current working 
  10754.            directory. 
  10755.  
  10756.  tcl_patchLevel  When an interpreter is created Tcl initializes this variable 
  10757.            to hold a string giving the current patch level for Tcl, such as 
  10758.            7.3p2 for Tcl 7.3 with the first two official patches, or 7.4b4 for 
  10759.            the fourth beta release of Tcl 7.4. The value of this variable is 
  10760.            returned by the info patchlevel command. 
  10761.  
  10762.  tcl_pkgPath  This variable holds a list of directories indicating where 
  10763.            packages are normally installed.  It typically contains either one 
  10764.            or two entries; if it contains two entries, the first is normally a 
  10765.            directory for platform-dependent packages (e.g., shared library 
  10766.            binaries) and the second is normally a directory for 
  10767.            platform-independent packages (e.g., script files). Typically a 
  10768.            package is installed as a subdirectory of one of the entries in 
  10769.            $tcl_pkgPath. The directories in $tcl_pkgPath are included by 
  10770.            default in the auto_path variable, so they and their immediate 
  10771.            subdirectories are automatically searched for packages during 
  10772.            package require commands.  Note: tcl_pkgPath it not intended to be 
  10773.            modified by the application. Its value is added to auto_path at 
  10774.            startup; changes to tcl_pkgPath are not reflected in auto_path.  If 
  10775.            you want Tcl to search additional directories for packages you 
  10776.            should add the names of those directories to auto_path, not 
  10777.            tcl_pkgPath. 
  10778.  
  10779.  tcl_platform  This is an associative array whose elements contain information 
  10780.            about the platform on which the application is running, such as the 
  10781.            name of the operating system, its current release number, and the 
  10782.            machine's instruction set.  The elements listed below will always be 
  10783.            defined, but they may have empty strings as values if Tcl couldn't 
  10784.            retrieve any relevant information.  In addition, extensions and 
  10785.            applications may add additional values to the array.  The predefined 
  10786.            elements are: 
  10787.  
  10788.            machine        The instruction set executed by this machine, such as 
  10789.                           PPC, 68k, or sun4m.  On UNIX machines, this is the 
  10790.                           value returned by uname -m. 
  10791.  
  10792.            os             The name of the operating system running on this 
  10793.                           machine, such as Win95, MacOS, or SunOS.  On UNIX 
  10794.                           machines, this is the value returned by uname -s. 
  10795.  
  10796.            osVersion      The version number for the operating system running 
  10797.                           on this machine. On UNIX machines, this is the value 
  10798.                           returned by uname -r. 
  10799.  
  10800.            platform       Either windows, macintosh, or unix.  This identifies 
  10801.                           the general operating environment of the machine. 
  10802.  
  10803.  tcl_precision  If this variable is set, it must contain a decimal number 
  10804.            giving the number of significant digits to include when converting 
  10805.            floating-point values to strings. If this variable is not set then 6 
  10806.            digits are included. 17 digits is "perfect" for IEEE floating-point 
  10807.            in that it allows double-precision values to be converted to strings 
  10808.            and back to binary with no loss of precision. 
  10809.  
  10810.  tcl_rcFileName  This variable is used during initialization to indicate the 
  10811.            name of a user-specific startup file.  If it is set by 
  10812.            application-specific initialization, then the Tcl startup code will 
  10813.            check for the existence of this file and source it if it exists. 
  10814.            For example, for wish the variable is set to ~/.wishrc for Unix and 
  10815.            ~/wishrc.tcl for Windows. 
  10816.  
  10817.  tcl_rcRsrcName  This variable is only used on Macintosh systems.  The variable 
  10818.            is used during initialization to indicate the name of a 
  10819.            user-specific TEXT resource located in the application or extension 
  10820.            resource forks.  If it is set by application-specific 
  10821.            initialization, then the Tcl startup code will check for the 
  10822.            existence of this resource and source it if it exists.  For example, 
  10823.            the Macintosh wish application has the variable is set to tclshrc. 
  10824.  
  10825.  tcl_version  When an interpreter is created Tcl initializes this variable to 
  10826.            hold the version number for this version of Tcl in the form x.y. 
  10827.            Changes to x represent major changes with probable incompatibilities 
  10828.            and changes to y represent small enhancements and bug fixes that 
  10829.            retain backward compatibility. The value of this variable is 
  10830.            returned by the info tclversion command. 
  10831.  
  10832.  KEYWORDS 
  10833.  
  10834.  arithmetic, error, environment, POSIX, precision, subprocess, variables 
  10835.  
  10836.  
  10837. ΓòÉΓòÉΓòÉ 3.71. tell ΓòÉΓòÉΓòÉ
  10838.  
  10839.  NAME 
  10840.  
  10841. tell - Return current access position for an open channel 
  10842.  
  10843. SYNOPSIS 
  10844.  
  10845. tell channelId 
  10846.  
  10847. DESCRIPTION 
  10848.  
  10849. Returns a decimal string giving the current access position in channelId. The 
  10850. value returned is -1 for channels that do not support seeking. 
  10851.  
  10852. KEYWORDS 
  10853.  
  10854. access position, channel, seeking 
  10855.  
  10856.  
  10857. ΓòÉΓòÉΓòÉ 3.72. time ΓòÉΓòÉΓòÉ
  10858.  
  10859.  NAME 
  10860.  
  10861. time - Time the execution of a script 
  10862.  
  10863. SYNOPSIS 
  10864.  
  10865. time script ?count? 
  10866.  
  10867. DESCRIPTION 
  10868.  
  10869. This command will call the Tcl interpreter count times to evaluate script (or 
  10870. once if count isn't specified).  It will then return a string of the form 
  10871.  
  10872. 503 microseconds per iteration
  10873. which indicates the average amount of time required per iteration, in 
  10874. microseconds. Time is measured in elapsed time, not CPU time. 
  10875.  
  10876. KEYWORDS 
  10877.  
  10878. script, time 
  10879.  
  10880.  
  10881. ΓòÉΓòÉΓòÉ 3.73. trace ΓòÉΓòÉΓòÉ
  10882.  
  10883.  NAME 
  10884.  
  10885. trace - Monitor variable accesses 
  10886.  
  10887. SYNOPSIS 
  10888.  
  10889. trace option ?arg arg ...? 
  10890.  
  10891. DESCRIPTION 
  10892.  
  10893. This command causes Tcl commands to be executed whenever certain operations are 
  10894. invoked.  At present, only variable tracing is implemented. The legal option's 
  10895. (which may be abbreviated) are: 
  10896.  
  10897.  trace variable name ops command  Arrange for command to be executed whenever 
  10898.            variable name is accessed in one of the ways given by ops.  Name may 
  10899.            refer to a normal variable, an element of an array, or to an array 
  10900.            as a whole (i.e. name may be just the name of an array, with no 
  10901.            parenthesized index).  If name refers to a whole array, then command 
  10902.            is invoked whenever any element of the array is manipulated. 
  10903.  
  10904.            Ops indicates which operations are of interest, and consists of one 
  10905.            or more of the following letters: 
  10906.  
  10907.            r              Invoke command whenever the variable is read. 
  10908.  
  10909.            w              Invoke command whenever the variable is written. 
  10910.  
  10911.            u              Invoke command whenever the variable is unset. 
  10912.                           Variables can be unset explicitly with the unset 
  10913.                           command, or implicitly when procedures return (all of 
  10914.                           their local variables are unset).  Variables are also 
  10915.                           unset when interpreters are deleted, but traces will 
  10916.                           not be invoked because there is no interpreter in 
  10917.                           which to execute them. 
  10918.  
  10919.            When the trace triggers, three arguments are appended to command so 
  10920.            that the actual command is as follows: 
  10921.  
  10922.                       command name1 name2 op
  10923.            Name1 and name2 give the name(s) for the variable being accessed: 
  10924.            if the variable is a scalar then name1 gives the variable's name and 
  10925.            name2 is an empty string; if the variable is an array element then 
  10926.            name1 gives the name of the array and name2 gives the index into the 
  10927.            array; if an entire array is being deleted and the trace was 
  10928.            registered on the overall array, rather than a single element, then 
  10929.            name1 gives the array name and name2 is an empty string. Name1 and 
  10930.            name2 are not necessarily the same as the name used in the trace 
  10931.            variable command:  the upvar command allows a procedure to reference 
  10932.            a variable under a different name. Op indicates what operation is 
  10933.            being performed on the variable, and is one of r, w, or u as defined 
  10934.            above. 
  10935.  
  10936.            Command executes in the same context as the code that invoked the 
  10937.            traced operation:  if the variable was accessed as part of a Tcl 
  10938.            procedure, then command will have access to the same local variables 
  10939.            as code in the procedure.  This context may be different than the 
  10940.            context in which the trace was created. If command invokes a 
  10941.            procedure (which it normally does) then the procedure will have to 
  10942.            use upvar or uplevel if it wishes to access the traced variable. 
  10943.            Note also that name1 may not necessarily be the same as the name 
  10944.            used to set the trace on the variable;  differences can occur if the 
  10945.            access is made through a variable defined with the upvar command. 
  10946.  
  10947.            For read and write traces, command can modify the variable to affect 
  10948.            the result of the traced operation. If command modifies the value of 
  10949.            a variable during a read or write trace, then the new value will be 
  10950.            returned as the result of the traced operation. The return value 
  10951.            from  command is ignored except that if it returns an error of any 
  10952.            sort then the traced operation also returns an error with the same 
  10953.            error message returned by the trace command (this mechanism can be 
  10954.            used to implement read-only variables, for example). For write 
  10955.            traces, command is invoked after the variable's value has been 
  10956.            changed; it can write a new value into the variable to override the 
  10957.            original value specified in the write operation. To implement 
  10958.            read-only variables, command will have to restore the old value of 
  10959.            the variable. 
  10960.  
  10961.            While command is executing during a read or write trace, traces on 
  10962.            the variable are temporarily disabled. This means that reads and 
  10963.            writes invoked by command will occur directly, without invoking 
  10964.            command (or any other traces) again. However, if command unsets the 
  10965.            variable then unset traces will be invoked. 
  10966.  
  10967.            When an unset trace is invoked, the variable has already been 
  10968.            deleted:  it will appear to be undefined with no traces. If an unset 
  10969.            occurs because of a procedure return, then the trace will be invoked 
  10970.            in the variable context of the procedure being returned to:  the 
  10971.            stack frame of the returning procedure will no longer exist. Traces 
  10972.            are not disabled during unset traces, so if an unset trace command 
  10973.            creates a new trace and accesses the variable, the trace will be 
  10974.            invoked. Any errors in unset traces are ignored. 
  10975.  
  10976.            If there are multiple traces on a variable they are invoked in order 
  10977.            of creation, most-recent first. If one trace returns an error, then 
  10978.            no further traces are invoked for the variable. If an array element 
  10979.            has a trace set, and there is also a trace set on the array as a 
  10980.            whole, the trace on the overall array is invoked before the one on 
  10981.            the element. 
  10982.  
  10983.            Once created, the trace remains in effect either until the trace is 
  10984.            removed with the trace vdelete command described below, until the 
  10985.            variable is unset, or until the interpreter is deleted. Unsetting an 
  10986.            element of array will remove any traces on that element, but will 
  10987.            not remove traces on the overall array. 
  10988.  
  10989.            This command returns an empty string. 
  10990.  
  10991.  trace vdelete name ops command  If there is a trace set on variable name with 
  10992.            the operations and command given by ops and command, then the trace 
  10993.            is removed, so that command will never again be invoked. Returns an 
  10994.            empty string. 
  10995.  
  10996.  trace vinfo name  Returns a list containing one element for each trace 
  10997.            currently set on variable name. Each element of the list is itself a 
  10998.            list containing two elements, which are the ops and command 
  10999.            associated with the trace. If name doesn't exist or doesn't have any 
  11000.            traces set, then the result of the command will be an empty string. 
  11001.  
  11002.  KEYWORDS 
  11003.  
  11004.  read, variable, write, trace, unset 
  11005.  
  11006.  
  11007. ΓòÉΓòÉΓòÉ 3.74. unknown ΓòÉΓòÉΓòÉ
  11008.  
  11009.  NAME 
  11010.  
  11011. unknown - Handle attempts to use non-existent commands 
  11012.  
  11013. SYNOPSIS 
  11014.  
  11015. unknown cmdName ?arg arg ...? 
  11016.  
  11017. DESCRIPTION 
  11018.  
  11019. This command is invoked by the Tcl interpreter whenever a script tries to 
  11020. invoke a command that doesn't exist.  The implementation of unknown isn't part 
  11021. of the Tcl core;  instead, it is a library procedure defined by default when 
  11022. Tcl starts up.  You can override the default unknown to change its 
  11023. functionality. 
  11024.  
  11025. If the Tcl interpreter encounters a command name for which there is not a 
  11026. defined command, then Tcl checks for the existence of a command named unknown. 
  11027. If there is no such command, then the interpreter returns an error. If the 
  11028. unknown command exists, then it is invoked with arguments consisting of the 
  11029. fully-substituted name and arguments for the original non-existent command. The 
  11030. unknown command typically does things like searching through library 
  11031. directories for a command procedure with the name cmdName, or expanding 
  11032. abbreviated command names to full-length, or automatically executing unknown 
  11033. commands as sub-processes. In some cases (such as expanding abbreviations) 
  11034. unknown will change the original command slightly and then (re-)execute it. The 
  11035. result of the unknown command is used as the result for the original 
  11036. non-existent command. 
  11037.  
  11038. The default implementation of unknown behaves as follows. It first calls the 
  11039. auto_load library procedure to load the command. If this succeeds, then it 
  11040. executes the original command with its original arguments. If the auto-load 
  11041. fails then unknown calls auto_execok to see if there is an executable file by 
  11042. the name cmd. If so, it invokes the Tcl exec command with cmd and all the args 
  11043. as arguments. If cmd can't be auto-executed, unknown checks to see if the 
  11044. command was invoked at top-level and outside of any script.  If so, then 
  11045. unknown takes two additional steps. First, it sees if cmd has one of the 
  11046. following three forms: !!, !event, or ^old^new?^?. If so, then unknown carries 
  11047. out history substitution in the same way that csh would for these constructs. 
  11048. Finally, unknown checks to see if cmd is a unique abbreviation for an existing 
  11049. Tcl command. If so, it expands the command name and executes the command with 
  11050. the original arguments. If none of the above efforts has been able to execute 
  11051. the command, unknown generates an error return. If the global variable 
  11052. auto_noload is defined, then the auto-load step is skipped. If the global 
  11053. variable auto_noexec is defined then the auto-exec step is skipped. Under 
  11054. normal circumstances the return value from unknown is the return value from the 
  11055. command that was eventually executed. 
  11056.  
  11057. KEYWORDS 
  11058.  
  11059. error, non-existent command 
  11060.  
  11061.  
  11062. ΓòÉΓòÉΓòÉ 3.75. unset ΓòÉΓòÉΓòÉ
  11063.  
  11064.  NAME 
  11065.  
  11066. unset - Delete variables 
  11067.  
  11068. SYNOPSIS 
  11069.  
  11070. unset name ?name name ...? 
  11071.  
  11072. DESCRIPTION 
  11073.  
  11074. This command removes one or more variables. Each name is a variable name, 
  11075. specified in any of the ways acceptable to the set command. If a name refers to 
  11076. an element of an array then that element is removed without affecting the rest 
  11077. of the array. If a name consists of an array name with no parenthesized index, 
  11078. then the entire array is deleted. The unset command returns an empty string as 
  11079. result. An error occurs if any of the variables doesn't exist, and any 
  11080. variables after the non-existent one are not deleted. 
  11081.  
  11082. KEYWORDS 
  11083.  
  11084. remove, variable 
  11085.  
  11086.  
  11087. ΓòÉΓòÉΓòÉ 3.76. update ΓòÉΓòÉΓòÉ
  11088.  
  11089.  NAME 
  11090.  
  11091. update - Process pending events and idle callbacks 
  11092.  
  11093. SYNOPSIS 
  11094.  
  11095. update ?idletasks? 
  11096.  
  11097. DESCRIPTION 
  11098.  
  11099. This command is used to bring the application "up to date" by entering the 
  11100. event loop repeated until all pending events (including idle callbacks) have 
  11101. been processed. 
  11102.  
  11103. If the idletasks keyword is specified as an argument to the command, then no 
  11104. new events or errors are processed;  only idle callbacks are invoked. This 
  11105. causes operations that are normally deferred, such as display updates and 
  11106. window layout calculations, to be performed immediately. 
  11107.  
  11108. The update idletasks command is useful in scripts where changes have been made 
  11109. to the application's state and you want those changes to appear on the display 
  11110. immediately, rather than waiting for the script to complete.  Most display 
  11111. updates are performed as idle callbacks, so update idletasks will cause them to 
  11112. run. However, there are some kinds of updates that only happen in response to 
  11113. events, such as those triggered by window size changes; these updates will not 
  11114. occur in update idletasks. 
  11115.  
  11116. The update command with no options is useful in scripts where you are 
  11117. performing a long-running computation but you still want the application to 
  11118. respond to events such as user interactions;  if you occasionally call update 
  11119. then user input will be processed during the next call to update. 
  11120.  
  11121. KEYWORDS 
  11122.  
  11123. event, flush, handler, idle, update 
  11124.  
  11125.  
  11126. ΓòÉΓòÉΓòÉ 3.77. uplevel ΓòÉΓòÉΓòÉ
  11127.  
  11128.  NAME 
  11129.  
  11130. uplevel - Execute a script in a different stack frame 
  11131.  
  11132. SYNOPSIS 
  11133.  
  11134. uplevel ?level? arg ?arg ...? 
  11135.  
  11136. DESCRIPTION 
  11137.  
  11138. All of the arg arguments are concatenated as if they had been passed to concat; 
  11139. the result is then evaluated in the variable context indicated by level. 
  11140. Uplevel returns the result of that evaluation. 
  11141.  
  11142. If level is an integer then it gives a distance (up the procedure calling 
  11143. stack) to move before executing the command.  If level consists of # followed 
  11144. by a number then the number gives an absolute level number.  If level is 
  11145. omitted then it defaults to 1.  Level cannot be defaulted if the first command 
  11146. argument starts with a digit or #. 
  11147.  
  11148. For example, suppose that procedure a was invoked from top-level, and that it 
  11149. called b, and that b called c. Suppose that c invokes the uplevel command.  If 
  11150. level is 1 or #2  or omitted, then the command will be executed in the variable 
  11151. context of b.  If level is 2 or #1 then the command will be executed in the 
  11152. variable context of a. If level is 3 or #0 then the command will be executed at 
  11153. top-level (only global variables will be visible). 
  11154.  
  11155. The uplevel command causes the invoking procedure to disappear from the 
  11156. procedure calling stack while the command is being executed. In the above 
  11157. example, suppose c invokes the command 
  11158.  
  11159. uplevel 1 {set x 43; d}
  11160. where d is another Tcl procedure.  The set command will modify the variable x 
  11161. in b's context, and d will execute at level 3, as if called from b.  If it in 
  11162. turn executes the command 
  11163.  
  11164. uplevel {set x 42}
  11165. then the set command will modify the same variable x in b's context:  the 
  11166. procedure c does not appear to be on the call stack when d is executing.  The 
  11167. command "info level" may be used to obtain the level of the current procedure. 
  11168.  
  11169. Uplevel makes it possible to implement new control constructs as Tcl procedures 
  11170. (for example, uplevel could be used to implement the while construct as a Tcl 
  11171. procedure). 
  11172.  
  11173. KEYWORDS 
  11174.  
  11175. context, stack frame, variables 
  11176.  
  11177.  
  11178. ΓòÉΓòÉΓòÉ 3.78. upvar ΓòÉΓòÉΓòÉ
  11179.  
  11180.  NAME 
  11181.  
  11182. upvar - Create link to variable in a different stack frame 
  11183.  
  11184. SYNOPSIS 
  11185.  
  11186. upvar ?level? otherVar myVar ?otherVar myVar ...? 
  11187.  
  11188. DESCRIPTION 
  11189.  
  11190. This command arranges for one or more local variables in the current procedure 
  11191. to refer to variables in an enclosing procedure call or to global variables. 
  11192. Level may have any of the forms permitted for the uplevel command, and may be 
  11193. omitted if the first letter of the first otherVar isn't # or a digit (it 
  11194. defaults to 1). For each otherVar argument, upvar makes the variable by that 
  11195. name in the procedure frame given by level (or at global level, if level is #0) 
  11196. accessible in the current procedure by the name given in the corresponding 
  11197. myVar argument. The variable named by otherVar need not exist at the time of 
  11198. the call;  it will be created the first time myVar is referenced, just like an 
  11199. ordinary variable.  There must not exist a variable by the name myVar at the 
  11200. time upvar is invoked. MyVar is always treated as the name of a variable, not 
  11201. an array element.  Even if the name looks like an array element, such as a(b), 
  11202. a regular variable is created. OtherVar may refer to a scalar variable, an 
  11203. array, or an array element. Upvar returns an empty string. 
  11204.  
  11205. The upvar command simplifies the implementation of call-by-name procedure 
  11206. calling and also makes it easier to build new control constructs as Tcl 
  11207. procedures. For example, consider the following procedure: 
  11208.  
  11209. proc add2 name {
  11210.        upvar $name x
  11211.        set x [expr $x+2]
  11212. }
  11213. Add2 is invoked with an argument giving the name of a variable, and it adds two 
  11214. to the value of that variable. Although add2 could have been implemented using 
  11215. uplevel instead of upvar, upvar makes it simpler for add2 to access the 
  11216. variable in the caller's procedure frame. 
  11217.  
  11218. If an upvar variable is unset (e.g. x in add2 above), the unset operation 
  11219. affects the variable it is linked to, not the upvar variable.  There is no way 
  11220. to unset an upvar variable except by exiting the procedure in which it is 
  11221. defined.  However, it is possible to retarget an upvar variable by executing 
  11222. another upvar command. 
  11223.  
  11224. BUGS 
  11225.  
  11226. If otherVar refers to an element of an array, then variable traces set for the 
  11227. entire array will not be invoked when myVar is accessed (but traces on the 
  11228. particular element will still be invoked).  In particular, if the array is env, 
  11229. then changes made to myVar will not be passed to subprocesses correctly. 
  11230.  
  11231. KEYWORDS 
  11232.  
  11233. context, frame, global, level, procedure, variable 
  11234.  
  11235.  
  11236. ΓòÉΓòÉΓòÉ 3.79. vwait ΓòÉΓòÉΓòÉ
  11237.  
  11238.  NAME 
  11239.  
  11240. vwait - Process events until a variable is written 
  11241.  
  11242. SYNOPSIS 
  11243.  
  11244. vwait ?varName? 
  11245.  
  11246. DESCRIPTION 
  11247.  
  11248. This command enters the Tcl event loop to process events, blocking the 
  11249. application if no events are ready.  It continues processing events until some 
  11250. event handler sets the value of variable varName.  Once varName has been set, 
  11251. the vwait command will return as soon as the event handler that modified 
  11252. varName completes. 
  11253.  
  11254. In some cases the vwait command may not return immediately after varName is 
  11255. set.  This can happen if the event handler that sets varName does not complete 
  11256. immediately.  For example, if an event handler sets varName and then itself 
  11257. calls vwait to wait for a different variable, then it may not return for a long 
  11258. time.  During this time the top-level vwait is blocked waiting for the event 
  11259. handler to complete, so it cannot return either. 
  11260.  
  11261. KEYWORDS 
  11262.  
  11263. event, variable, wait 
  11264.  
  11265.  
  11266. ΓòÉΓòÉΓòÉ 3.80. while ΓòÉΓòÉΓòÉ
  11267.  
  11268.  NAME 
  11269.  
  11270. while - Execute script repeatedly as long as a condition is met 
  11271.  
  11272. SYNOPSIS 
  11273.  
  11274. while test body 
  11275.  
  11276. DESCRIPTION 
  11277.  
  11278. The while command evaluates test as an expression (in the same way that expr 
  11279. evaluates its argument). The value of the expression must a proper boolean 
  11280. value; if it is a true value then body is executed by passing it to the Tcl 
  11281. interpreter. Once body has been executed then test is evaluated again, and the 
  11282. process repeats until eventually test evaluates to a false boolean value. 
  11283. Continue commands may be executed inside body to terminate the current 
  11284. iteration of the loop, and break commands may be executed inside body to cause 
  11285. immediate termination of the while command.  The while command always returns 
  11286. an empty string. 
  11287.  
  11288. KEYWORDS 
  11289.  
  11290. boolean value, loop, test, while 
  11291.  
  11292.  
  11293. ΓòÉΓòÉΓòÉ 4. Tk Applications ΓòÉΓòÉΓòÉ
  11294.  
  11295.  
  11296. ΓòÉΓòÉΓòÉ 4.1. wish ΓòÉΓòÉΓòÉ
  11297.  
  11298.  NAME 
  11299.  
  11300. wish - Simple windowing shell 
  11301.  
  11302. SYNOPSIS 
  11303.  
  11304. wish ?fileName arg arg ...? 
  11305.  
  11306. OPTIONS 
  11307.  
  11308.  -colormap new Specifies that the window should have a new private colormap 
  11309.            instead of using the default colormap for the screen. 
  11310.  
  11311.  -display display Display (and screen) on which to display window. 
  11312.  
  11313.  -geometry geometry Initial geometry to use for window.  If this option is 
  11314.            specified, its value is stored in the geometry global variable of 
  11315.            the application's Tcl interpreter. 
  11316.  
  11317.  -name name Use name as the title to be displayed in the window, and as the 
  11318.            name of the interpreter for send commands. 
  11319.  
  11320.  -sync     Execute all X server commands synchronously, so that errors are 
  11321.            reported immediately.  This will result in much slower execution, 
  11322.            but it is useful for debugging. 
  11323.  
  11324.  -visual visual Specifies the visual to use for the window. Visual may have any 
  11325.            of the forms supported by the Tk_GetVisual procedure. 
  11326.  
  11327.  --        Pass all remaining arguments through to the script's argv variable 
  11328.            without interpreting them. This provides a mechanism for passing 
  11329.            arguments such as -name to a script instead of having wish interpret 
  11330.            them. 
  11331.  
  11332.  DESCRIPTION 
  11333.  
  11334.  Wish is a simple program consisting of the Tcl command language, the Tk 
  11335.  toolkit, and a main program that reads commands from standard input or from a 
  11336.  file. It creates a main window and then processes Tcl commands. If wish is 
  11337.  invoked with no arguments, or with a first argument that starts with "-", then 
  11338.  it reads Tcl commands interactively from standard input. It will continue 
  11339.  processing commands until all windows have been deleted or until end-of-file 
  11340.  is reached on standard input. If there exists a file .wishrc in the home 
  11341.  directory of the user, wish evaluates the file as a Tcl script just before 
  11342.  reading the first command from standard input. 
  11343.  
  11344.  If wish is invoked with an initial fileName argument, then fileName is treated 
  11345.  as the name of a script file. Wish will evaluate the script in fileName (which 
  11346.  presumably creates a user interface), then it will respond to events until all 
  11347.  windows have been deleted. Commands will not be read from standard input. 
  11348.  There is no automatic evaluation of .wishrc in this case, but the script file 
  11349.  can always source it if desired. 
  11350.  
  11351.  OPTIONS 
  11352.  
  11353.  Wish automatically processes all of the command-line options described in the 
  11354.  OPTIONS summary above. Any other command-line arguments besides these are 
  11355.  passed through to the application using the argc and argv variables described 
  11356.  later. 
  11357.  
  11358.  APPLICATION NAME AND CLASS 
  11359.  
  11360.  The name of the application, which is used for purposes such as send commands, 
  11361.  is taken from the -name option, if it is specified;  otherwise it is taken 
  11362.  from fileName, if it is specified, or from the command name by which wish was 
  11363.  invoked.  In the last two cases, if the name contains a "/" character, then 
  11364.  only the characters after the last slash are used as the application name. 
  11365.  
  11366.  The class of the application, which is used for purposes such as specifying 
  11367.  options with a RESOURCE_MANAGER property or .Xdefaults file, is the same as 
  11368.  its name except that the first letter is capitalized. 
  11369.  
  11370.  VARIABLES 
  11371.  
  11372.  Wish sets the following Tcl variables: 
  11373.  
  11374.  argc      Contains a count of the number of arg arguments (0 if none), not 
  11375.            including the options described above. 
  11376.  
  11377.  argv      Contains a Tcl list whose elements are the arg arguments that follow 
  11378.            a -- option or don't match any of the options described in OPTIONS 
  11379.            above, in order, or an empty string if there are no such arguments. 
  11380.  
  11381.  argv0     Contains fileName if it was specified. Otherwise, contains the name 
  11382.            by which wish was invoked. 
  11383.  
  11384.  geometry  If the -geometry option is specified, wish copies its value into 
  11385.            this variable.  If the variable still exists after fileName has been 
  11386.            evaluated, wish uses the value of the variable in a wm geometry 
  11387.            command to set the main window's geometry. 
  11388.  
  11389.  tcl_interactive  Contains 1 if wish is reading commands interactively 
  11390.            (fileName was not specified and standard input is a terminal-like 
  11391.            device), 0 otherwise. 
  11392.  
  11393.  SCRIPT FILES 
  11394.  
  11395.  If you create a Tcl script in a file whose first line is 
  11396.  
  11397.   #!/usr/local/bin/wish
  11398.  then you can invoke the script file directly from your shell if you mark it as 
  11399.  executable. This assumes that wish has been installed in the default location 
  11400.  in /usr/local/bin;  if it's installed somewhere else then you'll have to 
  11401.  modify the above line to match. Many UNIX systems do not allow the #! line to 
  11402.  exceed about 30 characters in length, so be sure that the wish executable can 
  11403.  be accessed with a short file name. 
  11404.  
  11405.  An even better approach is to start your script files with the following three 
  11406.  lines: 
  11407.  
  11408.   #!/bin/sh
  11409.   # the next line restarts using wish \
  11410.   exec wish "$0" "$@"
  11411.  This approach has three advantages over the approach in the previous 
  11412.  paragraph.  First, the location of the wish binary doesn't have to be 
  11413.  hard-wired into the script:  it can be anywhere in your shell search path. 
  11414.  Second, it gets around the 30-character file name limit in the previous 
  11415.  approach. Third, this approach will work even if wish is itself a shell script 
  11416.  (this is done on some systems in order to handle multiple architectures or 
  11417.  operating systems:  the wish script selects one of several binaries to run). 
  11418.  The three lines cause both sh and wish to process the script, but the exec is 
  11419.  only executed by sh. sh processes the script first;  it treats the second line 
  11420.  as a comment and executes the third line. The exec statement cause the shell 
  11421.  to stop processing and instead to start up wish to reprocess the entire 
  11422.  script. When wish starts up, it treats all three lines as comments, since the 
  11423.  backslash at the end of the second line causes the third line to be treated as 
  11424.  part of the comment on the second line. 
  11425.  
  11426.  PROMPTS 
  11427.  
  11428.  When wish is invoked interactively it normally prompts for each command with 
  11429.  "% ".  You can change the prompt by setting the variables tcl_prompt1 and 
  11430.  tcl_prompt2.  If variable tcl_prompt1 exists then it must consist of a Tcl 
  11431.  script to output a prompt;  instead of outputting a prompt wish will evaluate 
  11432.  the script in tcl_prompt1. The variable tcl_prompt2 is used in a similar way 
  11433.  when a newline is typed but the current command isn't yet complete; if 
  11434.  tcl_prompt2 isn't set then no prompt is output for incomplete commands. 
  11435.  
  11436.  KEYWORDS 
  11437.  
  11438.  shell, toolkit 
  11439.  
  11440.  
  11441. ΓòÉΓòÉΓòÉ 5. Tk Library Procedures ΓòÉΓòÉΓòÉ
  11442.  
  11443.  
  11444. ΓòÉΓòÉΓòÉ 5.1. Tk_Get3DBorder ΓòÉΓòÉΓòÉ
  11445.  
  11446.  NAME 
  11447.  
  11448. Tk_Get3DBorder, Tk_Draw3DRectangle, Tk_Fill3DRectangle, Tk_Draw3DPolygon, 
  11449. Tk_Fill3DPolygon, Tk_3DVerticalBevel, Tk_3DHorizontalBevel, 
  11450. Tk_SetBackgroundFromBorder,  Tk_NameOf3DBorder, Tk_3DBorderColor, 
  11451. Tk_3DBorderGC, Tk_Free3DBorder - draw borders with three-dimensional appearance 
  11452.  
  11453. SYNOPSIS 
  11454.  
  11455. #include <tk.h> 
  11456.  
  11457.  Tk_3DBorder 
  11458.  Tk_Get3DBorder(interp, tkwin, colorName) 
  11459.  
  11460.  void 
  11461.  Tk_Draw3DRectangle(tkwin, drawable, border, x, y, width, height, borderWidth, 
  11462. relief) 
  11463.  
  11464.  void 
  11465.  Tk_Fill3DRectangle(tkwin, drawable, border, x, y, width, height, borderWidth, 
  11466. relief) 
  11467.  
  11468.  void 
  11469.  Tk_Draw3DPolygon(tkwin, drawable, border, pointPtr, numPoints, 
  11470. polyBorderWidth, leftRelief) 
  11471.  
  11472.  void 
  11473.  Tk_Fill3DPolygon(tkwin, drawable, border, pointPtr, numPoints, 
  11474. polyBorderWidth, leftRelief) 
  11475.  
  11476.  void 
  11477.  Tk_3DVerticalBevel(tkwin, drawable, border, x, y, width, height, leftBevel, 
  11478. relief) 
  11479.  
  11480.  void 
  11481.  Tk_3DHorizontalBevel(tkwin, drawable, border, x, y, width, height, leftIn, 
  11482. rightIn, topBevel, relief) 
  11483.  
  11484.  void 
  11485.  Tk_SetBackgroundFromBorder(tkwin, border) 
  11486.  
  11487.  char * 
  11488.  Tk_NameOf3DBorder(border) 
  11489.  
  11490.  XColor * 
  11491.  Tk_3DBorderColor(border) 
  11492.  
  11493.  GC * 
  11494.  Tk_3DBorderGC(tkwin, border, which) 
  11495.  
  11496.  Tk_Free3DBorder(border) 
  11497.  
  11498. ARGUMENTS 
  11499.  
  11500.  Tcl_Interp  *interp (in)  Interpreter to use for error reporting. 
  11501.  
  11502.  Tk_Window  tkwin (in)  Token for window (for all procedures except 
  11503.            Tk_Get3DBorder, must be the window for which the border was 
  11504.            allocated). 
  11505.  
  11506.  Tk_Uid  colorName (in)  Textual description of color corresponding to 
  11507.            background (flat areas). Illuminated edges will be brighter than 
  11508.            this and shadowed edges will be darker than this. 
  11509.  
  11510.  Drawable  drawable (in)  X token for window or pixmap;  indicates where 
  11511.            graphics are to be drawn. Must either be the X window for tkwin or a 
  11512.            pixmap with the same screen and depth as tkwin. 
  11513.  
  11514.  Tk_3DBorder  border (in)  Token for border previously allocated in call to 
  11515.            Tk_Get3DBorder. 
  11516.  
  11517.  int  x (in)  X-coordinate of upper-left corner of rectangle describing border 
  11518.            or bevel, in pixels. 
  11519.  
  11520.  int  y (in)  Y-coordinate of upper-left corner of rectangle describing border 
  11521.            or bevel, in pixels. 
  11522.  
  11523.  int  width (in)  Width of rectangle describing border or bevel, in pixels. 
  11524.  
  11525.  int  height (in)  Height of rectangle describing border or bevel, in pixels. 
  11526.  
  11527.  int  borderWidth (in)  Width of border in pixels. Positive means border is 
  11528.            inside rectangle given by x, y, width, height, negative means border 
  11529.            is outside rectangle. 
  11530.  
  11531.  int  relief (in)  Indicates 3-D position of interior of object relative to 
  11532.            exterior; should be TK_RELIEF_RAISED, TK_RELIEF_SUNKEN, 
  11533.            TK_RELIEF_GROOVE, or TK_RELIEF_RIDGE (may also be TK_RELIEF_FLAT for 
  11534.            Tk_Fill3DRectangle). 
  11535.  
  11536.  XPoint  *pointPtr (in)  Pointer to array of points describing the set of 
  11537.            vertices in a polygon. The polygon need not be closed (it will be 
  11538.            closed automatically if it isn't). 
  11539.  
  11540.  int  numPoints (in)  Number of points at *pointPtr. 
  11541.  
  11542.  int  polyBorderWidth (in)  Width of border in pixels.  If positive, border is 
  11543.            drawn to left of trajectory given by pointPtr;  if negative, border 
  11544.            is drawn to right of trajectory.  If leftRelief is TK_RELIEF_GROOVE 
  11545.            or TK_RELIEF_RIDGE then the border is centered on the trajectory. 
  11546.  
  11547.  int  leftRelief (in)  Height of left side of polygon's path relative to right. 
  11548.            TK_RELIEF_RAISED means left side should appear higher and 
  11549.            TK_RELIEF_SUNKEN means right side should appear higher; 
  11550.            TK_RELIEF_GROOVE and TK_RELIEF_RIDGE mean the obvious things. For 
  11551.            Tk_Fill3DPolygon, TK_RELIEF_FLAT may also be specified to indicate 
  11552.            no difference in height. 
  11553.  
  11554.  int  leftBevel (in)  Non-zero means this bevel forms the left side of the 
  11555.            object;  zero means it forms the right side. 
  11556.  
  11557.  int  leftIn (in)  Non-zero means that the left edge of the horizontal bevel 
  11558.            angles in, so that the bottom of the edge is farther to the right 
  11559.            than the top. Zero means the edge angles out, so that the bottom is 
  11560.            farther to the left than the top. 
  11561.  
  11562.  int  rightIn (in)  Non-zero means that the right edge of the horizontal bevel 
  11563.            angles in, so that the bottom of the edge is farther to the left 
  11564.            than the top. Zero means the edge angles out, so that the bottom is 
  11565.            farther to the right than the top. 
  11566.  
  11567.  int  topBevel (in)  Non-zero means this bevel forms the top side of the 
  11568.            object;  zero means it forms the bottom side. 
  11569.  
  11570.  int  which (in)  Specifies which of the border's graphics contexts is desired. 
  11571.            Must be TK_3D_FLAT_GC, TK_3D_LIGHT_GC, or TK_3D_DARK_GC. 
  11572.  
  11573.  DESCRIPTION 
  11574.  
  11575.  These procedures provide facilities for drawing window borders in a way that 
  11576.  produces a three-dimensional appearance.  Tk_Get3DBorder allocates colors and 
  11577.  Pixmaps needed to draw a border in the window given by the tkwin argument. 
  11578.  The colorName argument indicates what colors should be used in the border. 
  11579.  ColorName may be any value acceptable to Tk_GetColor. The color indicated by 
  11580.  colorName will not actually be used in the border;  it indicates the 
  11581.  background color for the window (i.e. a color for flat surfaces). The 
  11582.  illuminated portions of the border will appear brighter than indicated by 
  11583.  colorName, and the shadowed portions of the border will appear darker than 
  11584.  colorName. 
  11585.  
  11586.  Tk_Get3DBorder returns a token that may be used in later calls to 
  11587.  Tk_Draw3DRectangle.  If an error occurs in allocating information for the 
  11588.  border (e.g. colorName isn't a legal color specifier), then NULL is returned 
  11589.  and an error message is left in interp->result. 
  11590.  
  11591.  Once a border structure has been created, Tk_Draw3DRectangle may be invoked to 
  11592.  draw the border. The tkwin argument specifies the window for which the border 
  11593.  was allocated, and drawable specifies a window or pixmap in which the border 
  11594.  is to be drawn. Drawable need not refer to the same window as tkwin, but it 
  11595.  must refer to a compatible pixmap or window:  one associated with the same 
  11596.  screen and with the same depth as tkwin. The x, y, width, and height arguments 
  11597.  define the bounding box of the border region within drawable (usually x and y 
  11598.  are zero and width and height are the dimensions of the window), and 
  11599.  borderWidth specifies the number of pixels actually occupied by the border. 
  11600.  The relief argument indicates which of several three-dimensional effects is 
  11601.  desired: TK_RELIEF_RAISED means that the interior of the rectangle should 
  11602.  appear raised relative to the exterior of the rectangle, and TK_RELIEF_SUNKEN 
  11603.  means that the interior should appear depressed. TK_RELIEF_GROOVE and 
  11604.  TK_RELIEF_RIDGE mean that there should appear to be a groove or ridge around 
  11605.  the exterior of the rectangle. 
  11606.  
  11607.  Tk_Fill3DRectangle is somewhat like Tk_Draw3DRectangle except that it first 
  11608.  fills the rectangular area with the background color (one corresponding to the 
  11609.  colorName used to create border).  Then it calls Tk_Draw3DRectangle to draw a 
  11610.  border just inside the outer edge of the rectangular area.  The argument 
  11611.  relief indicates the desired effect (TK_RELIEF_FLAT means no border should be 
  11612.  drawn; all that happens is to fill the rectangle with the background color). 
  11613.  
  11614.  The procedure Tk_Draw3DPolygon may be used to draw more complex shapes with a 
  11615.  three-dimensional appearance.  The pointPtr and numPoints arguments define a 
  11616.  trajectory, polyBorderWidth indicates how wide the border should be (and on 
  11617.  which side of the trajectory to draw it), and leftRelief indicates which side 
  11618.  of the trajectory should appear raised.  Tk_Draw3DPolygon draws a border 
  11619.  around the given trajectory using the colors from border to produce a 
  11620.  three-dimensional appearance.  If the trajectory is non-self-intersecting, the 
  11621.  appearance will be a raised or sunken polygon shape.  The trajectory may be 
  11622.  self-intersecting, although it's not clear how useful this is. 
  11623.  
  11624.  Tk_Fill3DPolygon is to Tk_Draw3DPolygon what Tk_Fill3DRectangle is to 
  11625.  Tk_Draw3DRectangle:  it fills the polygonal area with the background color 
  11626.  from border, then calls Tk_Draw3DPolygon to draw a border around the area 
  11627.  (unless leftRelief is TK_RELIEF_FLAT;  in this case no border is drawn). 
  11628.  
  11629.  The procedures Tk_3DVerticalBevel and Tk_3DHorizontalBevel provide lower-level 
  11630.  drawing primitives that are used by procedures such as Tk_Draw3DRectangle. 
  11631.  These procedures are also useful in their own right for drawing rectilinear 
  11632.  border shapes. Tk_3DVerticalBevel draws a vertical beveled edge, such as the 
  11633.  left or right side of a rectangle, and Tk_3DHorizontalBevel draws a horizontal 
  11634.  beveled edge, such as the top or bottom of a rectangle. Each procedure takes 
  11635.  x, y, width, and height arguments that describe the rectangular area of the 
  11636.  beveled edge (e.g., width is the border width for Tk_3DVerticalBevel). The 
  11637.  leftBorder and topBorder arguments indicate the position of the border 
  11638.  relative to the "inside" of the object, and relief indicates the relief of the 
  11639.  inside of the object relative to the outside. Tk_3DVerticalBevel just draws a 
  11640.  rectangular region. Tk_3DHorizontalBevel draws a trapezoidal region to 
  11641.  generate mitered corners;  it should be called after Tk_3DVerticalBevel 
  11642.  (otherwise Tk_3DVerticalBevel will overwrite the mitering in the corner). The 
  11643.  leftIn and rightIn arguments to Tk_3DHorizontalBevel describe the mitering at 
  11644.  the corners;  a value of 1 means that the bottom edge of the trapezoid will be 
  11645.  shorter than the top, 0 means it will be longer. For example, to draw a 
  11646.  rectangular border the top bevel should be drawn with 1 for both leftIn and 
  11647.  rightIn, and the bottom bevel should be drawn with 0 for both arguments. 
  11648.  
  11649.  The procedure Tk_SetBackgroundFromBorder will modify the background pixel 
  11650.  and/or pixmap of tkwin to produce a result compatible with border.  For color 
  11651.  displays, the resulting background will just be the color given by the 
  11652.  colorName argument passed to Tk_Get3DBorder when border was created;  for 
  11653.  monochrome displays, the resulting background will be a light stipple pattern, 
  11654.  in order to distinguish the background from the illuminated portion of the 
  11655.  border. 
  11656.  
  11657.  Given a token for a border, the procedure Tk_NameOf3DBorder will return the 
  11658.  colorName string that was passed to Tk_Get3DBorder to create the border. 
  11659.  
  11660.  The procedure Tk_3DBorderColor returns the XColor structure that will be used 
  11661.  for flat surfaces drawn for its border argument by procedures like 
  11662.  Tk_Fill3DRectangle. The return value corresponds to the colorName passed to 
  11663.  Tk_Get3DBorder. The XColor, and its associated pixel value, will remain 
  11664.  allocated as long as border exists. 
  11665.  
  11666.  The procedure Tk_3DBorderGC returns one of the X graphics contexts that are 
  11667.  used to draw the border. The argument which selects which one of the three 
  11668.  possible GC's: TK_3D_FLAT_GC returns the context used for flat surfaces, 
  11669.  TK_3D_LIGHT_GC returns the context for light shadows, and TK_3D_DARK_GC 
  11670.  returns the context for dark shadows. 
  11671.  
  11672.  When a border is no longer needed, Tk_Free3DBorder should be called to release 
  11673.  the resources associated with the border. There should be exactly one call to 
  11674.  Tk_Free3DBorder for each call to Tk_Get3DBorder. 
  11675.  
  11676.  KEYWORDS 
  11677.  
  11678.  3D, background, border, color, depressed, illumination, polygon, raised, 
  11679.  shadow, three-dimensional effect 
  11680.  
  11681.  
  11682. ΓòÉΓòÉΓòÉ 5.2. Tk_CreateBindingTable ΓòÉΓòÉΓòÉ
  11683.  
  11684.  NAME 
  11685.  
  11686. Tk_CreateBindingTable, Tk_DeleteBindingTable, Tk_CreateBinding, 
  11687. Tk_DeleteBinding, Tk_GetBinding, Tk_GetAllBindings, Tk_DeleteAllBindings, 
  11688. Tk_BindEvent - invoke scripts in response to X events 
  11689.  
  11690. SYNOPSIS 
  11691.  
  11692. #include <tk.h> 
  11693.  
  11694.  Tk_BindingTable 
  11695.  Tk_CreateBindingTable(interp) 
  11696.  
  11697.  Tk_DeleteBindingTable(bindingTable) 
  11698.  
  11699.  unsigned long 
  11700.  Tk_CreateBinding(interp, bindingTable, object, eventString, script, append) 
  11701.  
  11702.  int 
  11703.  Tk_DeleteBinding(interp, bindingTable, object, eventString) 
  11704.  
  11705.  char * 
  11706.  Tk_GetBinding(interp, bindingTable, object, eventString) 
  11707.  
  11708.  Tk_GetAllBindings(interp, bindingTable, object) 
  11709.  
  11710.  Tk_DeleteAllBindings(bindingTable, object) 
  11711.  
  11712.  Tk_BindEvent(bindingTable, eventPtr, tkwin, numObjects, objectPtr) 
  11713.  
  11714. ARGUMENTS 
  11715.  
  11716.  Tcl_Interp  *interp (in)  Interpreter to use when invoking bindings in binding 
  11717.            table.  Also used for returning results and errors from binding 
  11718.            procedures. 
  11719.  
  11720.  Tk_BindingTable  bindingTable (in)  Token for binding table;  must have been 
  11721.            returned by some previous call to Tk_CreateBindingTable. 
  11722.  
  11723.  ClientData  object (in)  Identifies object with which binding is associated. 
  11724.  
  11725.  char  *eventString (in)  String describing event sequence. 
  11726.  
  11727.  char  *script (in)  Tcl script to invoke when binding triggers. 
  11728.  
  11729.  int  append (in)  Non-zero means append script to existing script for binding, 
  11730.            if any; zero means replace existing script with new one. 
  11731.  
  11732.  XEvent  *eventPtr (in)  X event to match against bindings in bindingTable. 
  11733.  
  11734.  Tk_Window  tkwin (in)  Identifier for any window on the display where the 
  11735.            event occurred. Used to find display-related information such as key 
  11736.            maps. 
  11737.  
  11738.  int  numObjects (in)  Number of object identifiers pointed to by objectPtr. 
  11739.  
  11740.  ClientData  *objectPtr (in)  Points to an array of object identifiers: 
  11741.            bindings will be considered for each of these objects in order from 
  11742.            first to last. 
  11743.  
  11744.  DESCRIPTION 
  11745.  
  11746.  These procedures provide a general-purpose mechanism for creating and invoking 
  11747.  bindings. Bindings are organized in terms of binding tables. A binding table 
  11748.  consists of a collection of bindings plus a history of recent events. Within a 
  11749.  binding table, bindings are associated with objects. The meaning of an object 
  11750.  is defined by clients of the binding package. For example, Tk keeps uses one 
  11751.  binding table to hold all of the bindings created by the bind command. For 
  11752.  this table, objects are pointers to strings such as window names, class names, 
  11753.  or other binding tags such as all. Tk also keeps a separate binding table for 
  11754.  each canvas widget, which manages bindings created by the canvas's bind widget 
  11755.  command;  within this table, an object is either a pointer to the internal 
  11756.  structure for a canvas item or a Tk_Uid identifying a tag. 
  11757.  
  11758.  The procedure Tk_CreateBindingTable creates a new binding table and associates 
  11759.  interp with it (when bindings in the table are invoked, the scripts will be 
  11760.  evaluated in interp). Tk_CreateBindingTable returns a token for the table, 
  11761.  which must be used in calls to other procedures such as Tk_CreateBinding or 
  11762.  Tk_BindEvent. 
  11763.  
  11764.  Tk_DeleteBindingTable frees all of the state associated with a binding table. 
  11765.  Once it returns the caller should not use the bindingTable token again. 
  11766.  
  11767.  Tk_CreateBinding adds a new binding to an existing table. The object argument 
  11768.  identifies the object with which the binding is to be associated, and it may 
  11769.  be any one-word value. Typically it is a pointer to a string or data 
  11770.  structure. The eventString argument identifies the event or sequence of events 
  11771.  for the binding;  see the documentation for the bind command for a description 
  11772.  of its format. script is the Tcl script to be evaluated when the binding 
  11773.  triggers. append indicates what to do if there already exists a binding for 
  11774.  object and eventString:  if append is zero then script replaces the old 
  11775.  script;  if append is non-zero then the new script is appended to the old one. 
  11776.  Tk_CreateBinding returns an X event mask for all the events associated with 
  11777.  the bindings. This information may be useful to invoke XSelectInput to select 
  11778.  relevant events, or to disallow the use of certain events in bindings. If an 
  11779.  error occurred while creating the binding (e.g., eventString refers to a 
  11780.  non-existent event), then 0 is returned and an error message is left in 
  11781.  interp->result. 
  11782.  
  11783.  Tk_DeleteBinding removes from bindingTable the binding given by object and 
  11784.  eventString, if such a binding exists. Tk_DeleteBinding always returns TCL_OK. 
  11785.  In some cases it may reset interp->result to the default empty value. 
  11786.  
  11787.  Tk_GetBinding returns a pointer to the script associated with eventString and 
  11788.  object in bindingTable. If no such binding exists then NULL is returned and an 
  11789.  error message is left in interp->result. 
  11790.  
  11791.  Tk_GetAllBindings returns in interp->result a list of all the event strings 
  11792.  for which there are bindings in bindingTable associated with object. If there 
  11793.  are no bindings for object then an empty string is returned in interp->result. 
  11794.  
  11795.  Tk_DeleteAllBindings deletes all of the bindings in bindingTable that are 
  11796.  associated with object. 
  11797.  
  11798.  Tk_BindEvent is called to process an event. It makes a copy of the event in an 
  11799.  internal history list associated with the binding table, then it checks for 
  11800.  bindings that match the event. Tk_BindEvent processes each of the objects 
  11801.  pointed to by objectPtr in turn. For each object, it finds all the bindings 
  11802.  that match the current event history, selects the most specific binding using 
  11803.  the priority mechanism described in the documentation for bind, and invokes 
  11804.  the script for that binding. If there are no matching bindings for a 
  11805.  particular object, then the object is skipped. Tk_BindEvent continues through 
  11806.  all of the objects, handling exceptions such as errors, break, and continue as 
  11807.  described in the documentation for bind. 
  11808.  
  11809.  KEYWORDS 
  11810.  
  11811.  binding, event, object, script 
  11812.  
  11813.  
  11814. ΓòÉΓòÉΓòÉ 5.3. Tk_CanvasPsY ΓòÉΓòÉΓòÉ
  11815.  
  11816.  NAME 
  11817.  
  11818. Tk_CanvasPsY, Tk_CanvasPsBitmap, Tk_CanvasPsColor, Tk_CanvasPsFont, 
  11819. Tk_CanvasPsPath, Tk_CanvasPsStipple - utility procedures for generating 
  11820. Postscript for canvases 
  11821.  
  11822. SYNOPSIS 
  11823.  
  11824. #include <tk.h> 
  11825.  
  11826.  double 
  11827.  Tk_CanvasPsY(canvas, canvasY) 
  11828.  
  11829.  int 
  11830.  Tk_CanvasPsBitmap(interp, canvas, bitmap, x, y, width, height) 
  11831.  
  11832.  int 
  11833.  Tk_CanvasPsColor(interp, canvas, colorPtr) 
  11834.  
  11835.  int 
  11836.  Tk_CanvasPsFont(interp, canvas, fontStructPtr) 
  11837.  
  11838.  Tk_CanvasPsPath(interp, canvas, coordPtr, numPoints) 
  11839.  
  11840.  int 
  11841.  Tk_CanvasPsStipple(interp, canvas, bitmap) 
  11842.  
  11843. ARGUMENTS 
  11844.  
  11845.  Tk_Canvas  canvas (in)  A token that identifies a canvas widget for which 
  11846.            Postscript is being generated. 
  11847.  
  11848.  double  canvasY (in)  Y-coordinate in the space of the canvas. 
  11849.  
  11850.  Tcl_Interp  *interp (in/out)  A Tcl interpreter;  Postscript is appended to 
  11851.            its result, or the result may be replaced with an error message. 
  11852.  
  11853.  Pixmap  bitmap (in)  Bitmap to use for generating Postscript. 
  11854.  
  11855.  int  x (in)  X-coordinate within bitmap of left edge of region to output. 
  11856.  
  11857.  int  y (in)  Y-coordinate within bitmap of top edge of region to output. 
  11858.  
  11859.  int  width (in)  Width of region of bitmap to output, in pixels. 
  11860.  
  11861.  int  height (in)  Height of region of bitmap to output, in pixels. 
  11862.  
  11863.  XColor  *colorPtr (in)  Information about color value to set in Postscript. 
  11864.  
  11865.  XFontStruct  *fontStructPtr (in)  Font for which Postscript is to be 
  11866.            generated. 
  11867.  
  11868.  double  *coordPtr (in)  Pointer to an array of coordinates for one or more 
  11869.            points specified in canvas coordinates. The order of values in 
  11870.            coordPtr is x1, y1, x2, y2, x3, y3, and so on. 
  11871.  
  11872.  int  numPoints (in)  Number of points at coordPtr. 
  11873.  
  11874.  DESCRIPTION 
  11875.  
  11876.  These procedures are called by canvas type managers to carry out common 
  11877.  functions related to generating Postscript. Most of the procedures take a 
  11878.  canvas argument, which refers to a canvas widget for which Postscript is being 
  11879.  generated. 
  11880.  
  11881.  Tk_CanvasY takes as argument a y-coordinate in the space of a canvas and 
  11882.  returns the value that should be used for that point in the Postscript 
  11883.  currently being generated for canvas. Y coordinates require transformation 
  11884.  because Postscript uses an origin at the lower-left corner whereas X uses an 
  11885.  origin at the upper-left corner. Canvas x coordinates can be used directly in 
  11886.  Postscript without transformation. 
  11887.  
  11888.  Tk_CanvasPsBitmap generates Postscript to describe a region of a bitmap. The 
  11889.  Postscript is generated in proper image data format for Postscript, i.e., as 
  11890.  data between angle brackets, one bit per pixel. The Postscript is appended to 
  11891.  interp->result and TCL_OK is returned unless an error occurs, in which case 
  11892.  TCL_ERROR is returned and interp->result is overwritten with an error message. 
  11893.  
  11894.  Tk_CanvasPsColor generates Postscript to set the current color to correspond 
  11895.  to its colorPtr argument, taking into account any color map specified in the 
  11896.  postscript command. It appends the Postscript to interp->result and returns 
  11897.  TCL_OK unless an error occurs, in which case TCL_ERROR is returned and 
  11898.  interp->result is overwritten with an error message. 
  11899.  
  11900.  Tk_CanvasPsFont generates Postscript that sets the current font to match 
  11901.  fontStructPtr as closely as possible. Tk_CanvasPsFont takes into account any 
  11902.  font map specified in the postscript command, and it does the best it can at 
  11903.  mapping X fonts to Postscript fonts. It appends the Postscript to 
  11904.  interp->result and returns TCL_OK unless an error occurs, in which case 
  11905.  TCL_ERROR is returned and interp->result is overwritten with an error message. 
  11906.  
  11907.  Tk_CanvasPsPath generates Postscript to set the current path to the set of 
  11908.  points given by coordPtr and numPoints. It appends the resulting Postscript to 
  11909.  interp->result. 
  11910.  
  11911.  Tk_CanvasPsStipple generates Postscript that will fill the current path in 
  11912.  stippled fashion. It uses bitmap as the stipple pattern and the current 
  11913.  Postscript color;  ones in the stipple bitmap are drawn in the current color, 
  11914.  and zeroes are not drawn at all. The Postscript is appended to interp->result 
  11915.  and TCL_OK is returned, unless an error occurs, in which case TCL_ERROR is 
  11916.  returned and interp->result is overwritten with an error message. 
  11917.  
  11918.  KEYWORDS 
  11919.  
  11920.  bitmap, canvas, color, font, path, Postscript, stipple 
  11921.  
  11922.  
  11923. ΓòÉΓòÉΓòÉ 5.4. Tk_CanvasTkwin ΓòÉΓòÉΓòÉ
  11924.  
  11925.  NAME 
  11926.  
  11927. Tk_CanvasTkwin, Tk_CanvasGetCoord, Tk_CanvasDrawableCoords, 
  11928. Tk_CanvasSetStippleOrigin, Tk_CanvasWindowCoords, Tk_CanvasEventuallyRedraw, 
  11929. Tk_CanvasTagsOption - utility procedures for canvas type managers 
  11930.  
  11931. SYNOPSIS 
  11932.  
  11933. #include <tk.h> 
  11934.  
  11935.  Tk_Window 
  11936.  Tk_CanvasTkwin(canvas) 
  11937.  
  11938.  int 
  11939.  Tk_CanvasGetCoord(interp, canvas, string, doublePtr) 
  11940.  
  11941.  Tk_CanvasDrawableCoords(canvas, x, y, drawableXPtr, drawableYPtr) 
  11942.  
  11943.  Tk_CanvasSetStippleOrigin(canvas, gc) 
  11944.  
  11945.  Tk_CanvasWindowCoords(canvas, x, y, screenXPtr, screenYPtr) 
  11946.  
  11947.  Tk_CanvasEventuallyRedraw(canvas, x1, y1, x2, y2) 
  11948.  
  11949.  Tk_OptionParseProc *Tk_CanvasTagsParseProc; 
  11950.  
  11951.  Tk_OptionPrintProc *Tk_CanvasTagsPrintProc; 
  11952.  
  11953. ARGUMENTS 
  11954.  
  11955.  Tk_Canvas  canvas (in)  A token that identifies a canvas widget. 
  11956.  
  11957.  Tcl_Interp  *interp (in/out)  Interpreter to use for error reporting. 
  11958.  
  11959.  char  *string (in)  Textual description of a canvas coordinate. 
  11960.  
  11961.  double  *doublePtr (out)  Points to place to store a converted coordinate. 
  11962.  
  11963.  double  x (in)  An x coordinate in the space of the canvas. 
  11964.  
  11965.  double  y (in)  A y coordinate in the space of the canvas. 
  11966.  
  11967.  short  *drawableXPtr (out)  Pointer to a location in which to store an x 
  11968.            coordinate in the space of the drawable currently being used to 
  11969.            redisplay the canvas. 
  11970.  
  11971.  short  *drawableYPtr (out)  Pointer to a location in which to store a y 
  11972.            coordinate in the space of the drawable currently being used to 
  11973.            redisplay the canvas. 
  11974.  
  11975.  GC  gc (out)  Graphics context to modify. 
  11976.  
  11977.  short  *screenXPtr (out)  Points to a location in which to store the screen 
  11978.            coordinate in the canvas window that corresponds to x. 
  11979.  
  11980.  short  *screenYPtr (out)  Points to a location in which to store the screen 
  11981.            coordinate in the canvas window that corresponds to y. 
  11982.  
  11983.  int  x1 (in)  Left edge of the region that needs redisplay.  Only pixels at or 
  11984.            to the right of this coordinate need to be redisplayed. 
  11985.  
  11986.  int  y1 (in)  Top edge of the region that needs redisplay.  Only pixels at or 
  11987.            below this coordinate need to be redisplayed. 
  11988.  
  11989.  int  x2 (in)  Right edge of the region that needs redisplay.  Only pixels to 
  11990.            the left of this coordinate need to be redisplayed. 
  11991.  
  11992.  int  y2 (in)  Bottom edge of the region that needs redisplay.  Only pixels 
  11993.            above this coordinate need to be redisplayed. 
  11994.  
  11995.  DESCRIPTION 
  11996.  
  11997.  These procedures are called by canvas type managers to perform various utility 
  11998.  functions. 
  11999.  
  12000.  Tk_CanvasTkwin returns the Tk_Window associated with a particular canvas. 
  12001.  
  12002.  Tk_CanvasGetCoord translates a string specification of a coordinate (such as 
  12003.  2p or 1.6c) into a double-precision canvas coordinate. If string is a valid 
  12004.  coordinate description then Tk_CanvasGetCoord stores the corresponding canvas 
  12005.  coordinate at *doublePtr and returns TCL_OK. Otherwise it stores an error 
  12006.  message in interp->result and returns TCL_ERROR. 
  12007.  
  12008.  Tk_CanvasDrawableCoords is called by type managers during redisplay to compute 
  12009.  where to draw things. Given x and y coordinates in the space of the canvas, 
  12010.  Tk_CanvasDrawableCoords computes the corresponding pixel in the drawable that 
  12011.  is currently being used for redisplay; it returns those coordinates in 
  12012.  *drawableXPtr and *drawableYPtr. This procedure should not be invoked except 
  12013.  during redisplay. 
  12014.  
  12015.  Tk_CanvasSetStippleOrigin is also used during redisplay. It sets the stipple 
  12016.  origin in gc so that stipples drawn with gc in the current offscreen pixmap 
  12017.  will line up with stipples drawn with origin (0,0) in the canvas's actual 
  12018.  window. Tk_CanvasSetStippleOrigin is needed in order to guarantee that stipple 
  12019.  patterns line up properly when the canvas is redisplayed in small pieces. 
  12020.  Redisplays are carried out in double-buffered fashion where a piece of the 
  12021.  canvas is redrawn in an offscreen pixmap and then copied back onto the screen. 
  12022.  In this approach the stipple origins in graphics contexts need to be adjusted 
  12023.  during each redisplay to compensate for the position of the off-screen pixmap 
  12024.  relative to the window. If an item is being drawn with stipples, its type 
  12025.  manager typically calls Tk_CanvasSetStippleOrigin just before using gc to draw 
  12026.  something;  after it is finished drawing, the type manager calls XSetTSOrigin 
  12027.  to restore the origin in gc back to (0,0) (the restore is needed because 
  12028.  graphics contexts are shared, so they cannot be modified permanently). 
  12029.  
  12030.  Tk_CanvasWindowCoords is similar to Tk_CanvasDrawableCoords except that it 
  12031.  returns coordinates in the canvas's window on the screen, instead of 
  12032.  coordinates in an off-screen pixmap. 
  12033.  
  12034.  Tk_CanvasEventuallyRedraw may be invoked by a type manager to inform Tk that a 
  12035.  portion of a canvas needs to be redrawn. The x1, y1, x2, and y2 arguments 
  12036.  specify the region that needs to be redrawn, in canvas coordinates. Type 
  12037.  managers rarely need to invoke Tk_CanvasEventuallyRedraw, since Tk can 
  12038.  normally figure out when an item has changed and make the redisplay request on 
  12039.  its behalf (this happens, for example whenever Tk calls a configureProc or 
  12040.  scaleProc). The only time that a type manager needs to call 
  12041.  Tk_CanvasEventuallyRedraw is if an item has changed on its own without being 
  12042.  invoked through one of the procedures in its Tk_ItemType; this could happen, 
  12043.  for example, in an image item if the image is modified using image commands. 
  12044.  
  12045.  Tk_CanvasTagsParseProc and Tk_CanvasTagsPrintProc are procedures that handle 
  12046.  the -tags option for canvas items. The code of a canvas type manager won't 
  12047.  call these procedures directly, but will use their addresses to create a 
  12048.  Tk_CustomOption structure for the -tags option.  The code typically looks like 
  12049.  this: 
  12050.  
  12051.   static Tk_CustomOption tagsOption = {Tk_CanvasTagsParseProc,
  12052.          Tk_CanvasTagsPrintProc, (ClientData) NULL
  12053.   };
  12054.  
  12055.   static Tk_ConfigSpec configSpecs[] = {
  12056.          ...
  12057.          {TK_CONFIG_CUSTOM, "-tags", (char *) NULL, (char *) NULL,
  12058.                 (char *) NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
  12059.          ...
  12060.   };
  12061.  
  12062.  KEYWORDS 
  12063.  
  12064.  canvas, focus, item type, redisplay, selection, type manager 
  12065.  
  12066.  
  12067. ΓòÉΓòÉΓòÉ 5.5. Tk_CanvasTextInfo ΓòÉΓòÉΓòÉ
  12068.  
  12069.  NAME 
  12070.  
  12071. Tk_CanvasTextInfo - additional information for managing text items in canvases 
  12072.  
  12073. SYNOPSIS 
  12074.  
  12075. #include <tk.h> 
  12076.  
  12077.  Tk_CanvasTextInfo * 
  12078.  Tk_CanvasGetTextInfo(canvas) 
  12079.  
  12080. ARGUMENTS 
  12081.  
  12082.  Tk_Canvas  canvas (in)  A token that identifies a particular canvas widget. 
  12083.  
  12084.  DESCRIPTION 
  12085.  
  12086.  Textual canvas items are somewhat more complicated to manage than other items, 
  12087.  due to things like the selection and the input focus. Tk_CanvasGetTextInfo may 
  12088.  be invoked by a type manager to obtain additional information needed for items 
  12089.  that display text. The return value from Tk_CanvasGetTextInfo is a pointer to 
  12090.  a structure that is shared between Tk and all the items that display text. The 
  12091.  structure has the following form: 
  12092.  
  12093.   typedef struct Tk_CanvasTextInfo {
  12094.          Tk_3DBorder selBorder;
  12095.          int selBorderWidth;
  12096.          XColor *selFgColorPtr;
  12097.          Tk_Item *selItemPtr;
  12098.          int selectFirst;
  12099.          int selectLast;
  12100.          Tk_Item *anchorItemPtr;
  12101.          int selectAnchor;
  12102.          Tk_3DBorder insertBorder;
  12103.          int insertWidth;
  12104.          int insertBorderWidth;
  12105.          Tk_Item *focusItemPtr;
  12106.          int gotFocus;
  12107.          int cursorOn;
  12108.   } Tk_CanvasTextInfo;
  12109.  The selBorder field identifies a Tk_3DBorder that should be used for drawing 
  12110.  the background under selected text. selBorderWidth gives the width of the 
  12111.  raised border around selected text, in pixels. selFgColorPtr points to an 
  12112.  XColor that describes the foreground color to be used when drawing selected 
  12113.  text. selItemPtr points to the item that is currently selected, or NULL if 
  12114.  there is no item selected or if the canvas doesn't have the selection. 
  12115.  selectFirst and selectLast give the indices of the first and last selected 
  12116.  characters in selItemPtr, as returned by the indexProc for that item. 
  12117.  anchorItemPtr points to the item that currently has the selection anchor; 
  12118.  this is not necessarily the same as selItemPtr. selectAnchor is an index that 
  12119.  identifies the anchor position within anchorItemPtr. insertBorder contains a 
  12120.  Tk_3DBorder to use when drawing the insertion cursor;  insertWidth gives the 
  12121.  total width of the insertion cursor in pixels, and insertBorderWidth gives the 
  12122.  width of the raised  border around the insertion cursor. focusItemPtr 
  12123.  identifies the item that currently has the input focus, or NULL if there is no 
  12124.  such item. gotFocus is 1 if the canvas widget has the input focus and 0 
  12125.  otherwise. cursorOn is 1 if the insertion cursor should be drawn in 
  12126.  focusItemPtr and 0 if it should not be drawn;  this field is toggled on and 
  12127.  off by Tk to make the cursor blink. 
  12128.  
  12129.  The structure returned by Tk_CanvasGetTextInfo is shared between Tk and the 
  12130.  type managers;  typically the type manager calls Tk_CanvasGetTextInfo once 
  12131.  when an item is created and then saves the pointer in the item's record. Tk 
  12132.  will update information in the Tk_CanvasTextInfo;  for example, a configure 
  12133.  widget command might change the selBorder field, or a select widget command 
  12134.  might change the selectFirst field, or Tk might change cursorOn in order to 
  12135.  make the insertion cursor flash on and off during successive redisplays. 
  12136.  
  12137.  Type managers should treat all of the fields of the Tk_CanvasTextInfo 
  12138.  structure as read-only, except for selItemPtr, selectFirst, selectLast, and 
  12139.  selectAnchor. Type managers may change selectFirst, selectLast, and 
  12140.  selectAnchor to adjust for insertions and deletions in the item (but only if 
  12141.  the item is the current owner of the selection or anchor, as determined by 
  12142.  selItemPtr or anchorItemPtr). If all of the selected text in the item is 
  12143.  deleted, the item should set selItemPtr to NULL to indicate that there is no 
  12144.  longer a selection. 
  12145.  
  12146.  KEYWORDS 
  12147.  
  12148.  canvas, focus, insertion cursor, selection, selection anchor, text 
  12149.  
  12150.  
  12151. ΓòÉΓòÉΓòÉ 5.6. Tk_ClipboardClear ΓòÉΓòÉΓòÉ
  12152.  
  12153.  NAME 
  12154.  
  12155. Tk_ClipboardClear, Tk_ClipboardAppend - Manage the clipboard 
  12156.  
  12157. SYNOPSIS 
  12158.  
  12159. #include <tk.h> 
  12160.  
  12161.  int 
  12162.  Tk_ClipboardClear(interp, tkwin) 
  12163.  
  12164.  int 
  12165.  Tk_ClipboardAppend(interp, tkwin, target, format, buffer) 
  12166.  
  12167. ARGUMENTS 
  12168.  
  12169.  Tcl_Interp  *interp (in)  Interpreter to use for reporting errors. 
  12170.  
  12171.  Tk_Window  tkwin (in)  Window that determines which display's clipboard to 
  12172.            manipulate. 
  12173.  
  12174.  Atom  target (in)  Conversion type for this clipboard item;  has same meaning 
  12175.            as target argument to Tk_CreateSelHandler. 
  12176.  
  12177.  Atom  format (in)  Representation to use when data is retrieved;  has same 
  12178.            meaning as format argument to Tk_CreateSelHandler. 
  12179.  
  12180.  char  *buffer (in)  Null terminated string containing the data to be appended 
  12181.            to the clipboard. 
  12182.  
  12183.  DESCRIPTION 
  12184.  
  12185.  These two procedures manage the clipboard for Tk. The clipboard is typically 
  12186.  managed by calling Tk_ClipboardClear once, then calling Tk_ClipboardAppend to 
  12187.  add data for any number of targets. 
  12188.  
  12189.  Tk_ClipboardClear claims the CLIPBOARD selection and frees any data items 
  12190.  previously stored on the clipboard in this application. It normally returns 
  12191.  TCL_OK, but if an error occurs it returns TCL_ERROR and leaves an error 
  12192.  message in interp->result. Tk_ClipboardClear must be called before a sequence 
  12193.  of Tk_ClipboardAppend calls can be issued. 
  12194.  
  12195.  Tk_ClipboardAppend appends a buffer of data to the clipboard. The first buffer 
  12196.  for a given target determines the format for that target. Any successive 
  12197.  appends for that target must have the same format or an error will be 
  12198.  returned. Tk_ClipboardAppend returns TCL_OK if the buffer is successfully 
  12199.  copied onto the clipboard.  If the clipboard is not currently owned by the 
  12200.  application, either because Tk_ClipboardClear has not been called or because 
  12201.  ownership of the clipboard has changed since the last call to 
  12202.  Tk_ClipboardClear, Tk_ClipboardAppend returns TCL_ERROR and leaves an error 
  12203.  message in interp->result. 
  12204.  
  12205.  In order to guarantee atomicity, no event handling should occur between 
  12206.  Tk_ClipboardClear and the following Tk_ClipboardAppend calls (otherwise 
  12207.  someone could retrieve a partially completed clipboard or claim ownership away 
  12208.  from this application). 
  12209.  
  12210.  Tk_ClipboardClear may invoke callbacks, including arbitrary Tcl scripts, as a 
  12211.  result of losing the CLIPBOARD selection, so any calling function should take 
  12212.  care to be reentrant at the point Tk_ClipboardClear is invoked. 
  12213.  
  12214.  KEYWORDS 
  12215.  
  12216.  append, clipboard, clear, format, type 
  12217.  
  12218.  
  12219. ΓòÉΓòÉΓòÉ 5.7. Tk_ClearSelection ΓòÉΓòÉΓòÉ
  12220.  
  12221.  NAME 
  12222.  
  12223. Tk_ClearSelection - Deselect a selection 
  12224.  
  12225. SYNOPSIS 
  12226.  
  12227. #include <tk.h> 
  12228.  
  12229.  Tk_ClearSelection(tkwin, selection) 
  12230.  
  12231. ARGUMENTS 
  12232.  
  12233.  Tk_Window  tkwin (in)  The selection will be cleared from the display 
  12234.            containing this window. 
  12235.  
  12236.  Atom  selection (in)  The name of selection to be cleared. 
  12237.  
  12238.  DESCRIPTION 
  12239.  
  12240.  Tk_ClearSelection cancels the selection specified by the atom selection for 
  12241.  the display containing tkwin. The selection need not be in tkwin itself or 
  12242.  even in tkwin's application. If there is a window anywhere on tkwin's display 
  12243.  that owns selection, the window will be notified and the selection will be 
  12244.  cleared. If there is no owner for selection on the display, then the procedure 
  12245.  has no effect. 
  12246.  
  12247.  KEYWORDS 
  12248.  
  12249.  clear, selection 
  12250.  
  12251.  
  12252. ΓòÉΓòÉΓòÉ 5.8. Tk_ConfigureWidget ΓòÉΓòÉΓòÉ
  12253.  
  12254.  NAME 
  12255.  
  12256. Tk_ConfigureWidget, Tk_Offset, Tk_ConfigureInfo, Tk_ConfigureValue, 
  12257. Tk_FreeOptions - process configuration options for widgets 
  12258.  
  12259. SYNOPSIS 
  12260.  
  12261. #include <tk.h> 
  12262.  
  12263.  int 
  12264.  Tk_ConfigureWidget(interp, tkwin, specs, argc, argv, widgRec, flags) 
  12265.  
  12266.  int 
  12267.  Tk_Offset(type, field) 
  12268.  
  12269.  int 
  12270.  Tk_ConfigureInfo(interp, tkwin, specs, widgRec, argvName, flags) 
  12271.  
  12272.  int 
  12273.  
  12274.  Tk_FreeOptions(specs, widgRec, display, flags) 
  12275.  
  12276. ARGUMENTS 
  12277.  
  12278.  Tcl_Interp  *interp (in)  Interpreter to use for returning error messages. 
  12279.  
  12280.  Tk_Window  tkwin (in)  Window used to represent widget (needed to set up X 
  12281.            resources). 
  12282.  
  12283.  Tk_ConfigSpec  *specs (in)  Pointer to table specifying legal configuration 
  12284.            options for this widget. 
  12285.  
  12286.  int  argc (in)  Number of arguments in argv. 
  12287.  
  12288.  char  **argv (in)  Command-line options for configuring widget. 
  12289.  
  12290.  char  *widgRec (in/out)  Points to widget record structure.  Fields in this 
  12291.            structure get modified by Tk_ConfigureWidget to hold configuration 
  12292.            information. 
  12293.  
  12294.  int  flags (in)  If non-zero, then it specifies an OR-ed combination of flags 
  12295.            that control the processing of configuration information. 
  12296.            TK_CONFIG_ARGV_ONLY causes the option database and defaults to be 
  12297.            ignored, and flag bits TK_CONFIG_USER_BIT and higher are used to 
  12298.            selectively disable entries in specs. 
  12299.  
  12300.  type name  type (in)  The name of the type of a widget record. 
  12301.  
  12302.  field name  field (in)  The name of a field in records of type type. 
  12303.  
  12304.  char  *argvName (in)  The name used on Tcl command lines to refer to a 
  12305.            particular option (e.g. when creating a widget or invoking the 
  12306.            configure widget command).  If non-NULL, then information is 
  12307.            returned only for this option.  If NULL, then information is 
  12308.            returned for all available options. 
  12309.  
  12310.  Display  *display (in)  Display containing widget whose record is being freed; 
  12311.            needed in order to free up resources. 
  12312.  
  12313.  DESCRIPTION 
  12314.  
  12315.  Tk_ConfigureWidget is called to configure various aspects of a widget, such as 
  12316.  colors, fonts, border width, etc. It is intended as a convenience procedure to 
  12317.  reduce the amount of code that must be written in individual widget managers 
  12318.  to handle configuration information. It is typically invoked when widgets are 
  12319.  created, and again when the configure command is invoked for a widget. 
  12320.  Although intended primarily for widgets, Tk_ConfigureWidget can be used in 
  12321.  other situations where argc-argv information is to be used to fill in a record 
  12322.  structure, such as configuring graphical elements for a canvas widget or 
  12323.  entries of a menu. 
  12324.  
  12325.  Tk_ConfigureWidget processes a table specifying the configuration options that 
  12326.  are supported (specs) and a collection of command-line arguments (argc and 
  12327.  argv) to fill in fields of a record (widgRec). It uses the option database and 
  12328.  defaults specified in specs to fill in fields of widgRec that are not 
  12329.  specified in argv. Tk_ConfigureWidget normally returns the value TCL_OK; in 
  12330.  this case it does not modify interp. If an error occurs then TCL_ERROR is 
  12331.  returned and Tk_ConfigureWidget will leave an error message in interp->result 
  12332.  in the standard Tcl fashion. In the event of an error return, some of the 
  12333.  fields of widgRec could already have been set, if configuration information 
  12334.  for them was successfully processed before the error occurred. The other 
  12335.  fields will be set to reasonable initial values so that Tk_FreeOptions can be 
  12336.  called for cleanup. 
  12337.  
  12338.  The specs array specifies the kinds of configuration options expected by the 
  12339.  widget.  Each of its entries specifies one configuration option and has the 
  12340.  following structure: 
  12341.  
  12342.   typedef struct {
  12343.          int type;
  12344.          char *argvName;
  12345.          char *dbName;
  12346.          char *dbClass;
  12347.          char *defValue;
  12348.          int offset;
  12349.          int specFlags;
  12350.          Tk_CustomOption *customPtr;
  12351.   } Tk_ConfigSpec;
  12352.  The type field indicates what type of configuration option this is (e.g. 
  12353.  TK_CONFIG_COLOR for a color value, or TK_CONFIG_INT for an integer value). 
  12354.  The type field indicates how to use the value of the option (more on this 
  12355.  below). The argvName field is a string such as "-font" or "-bg", which is 
  12356.  compared with the values in argv (if argvName is NULL it means this is a 
  12357.  grouped entry;  see GROUPED ENTRIES below).  The dbName and dbClass fields are 
  12358.  used to look up a value for this option in the option database.  The defValue 
  12359.  field specifies a default value for this configuration option if no value is 
  12360.  specified in either argv or the option database. Offset indicates where in 
  12361.  widgRec to store information about this option, and specFlags contains 
  12362.  additional information to control the processing of this configuration option 
  12363.  (see FLAGS below). The last field, customPtr, is only used if type is 
  12364.  TK_CONFIG_CUSTOM;  see CUSTOM OPTION TYPES below. 
  12365.  
  12366.  Tk_ConfigureWidget first processes argv to see which (if any) configuration 
  12367.  options are specified there.  Argv must contain an even number of fields;  the 
  12368.  first of each pair of fields must match the argvName of some entry in specs 
  12369.  (unique abbreviations are acceptable), and the second field of the pair 
  12370.  contains the value for that configuration option.  If there are entries in 
  12371.  spec for which there were no matching entries in argv, Tk_ConfigureWidget uses 
  12372.  the dbName and dbClass fields of the specs entry to probe the option database; 
  12373.  if a value is found, then it is used as the value for the option. Finally, if 
  12374.  no entry is found in the option database, the defValue field of the specs 
  12375.  entry is used as the value for the configuration option.  If the defValue is 
  12376.  NULL, or if the TK_CONFIG_DONT_SET_DEFAULT bit is set in flags, then there is 
  12377.  no default value and this specs entry will be ignored if no value is specified 
  12378.  in argv or the option database. 
  12379.  
  12380.  Once a string value has been determined for a configuration option, 
  12381.  Tk_ConfigureWidget translates the string value into a more useful form, such 
  12382.  as a color if type is TK_CONFIG_COLOR or an integer if type is TK_CONFIG_INT. 
  12383.  This value is then stored in the record pointed to by widgRec.  This record is 
  12384.  assumed to contain information relevant to the manager of the widget;  its 
  12385.  exact type is unknown to Tk_ConfigureWidget.  The offset field of each specs 
  12386.  entry indicates where in widgRec to store the information about this 
  12387.  configuration option.  You should use the Tk_Offset macro to generate offset 
  12388.  values (see below for a description of Tk_Offset).  The location indicated by 
  12389.  widgRec and offset will be referred to as the "target" in the descriptions 
  12390.  below. 
  12391.  
  12392.  The type field of each entry in specs determines what to do with the string 
  12393.  value of that configuration option.  The legal values for type, and the 
  12394.  corresponding actions, are: 
  12395.  
  12396.  TK_CONFIG_ACTIVE_CURSOR  The value must be an ASCII string identifying a 
  12397.            cursor in a form suitable for passing to Tk_GetCursor. The value is 
  12398.            converted to a Tk_Cursor by calling Tk_GetCursor and the result is 
  12399.            stored in the target. In addition, the resulting cursor is made the 
  12400.            active cursor for tkwin by calling XDefineCursor. If 
  12401.            TK_CONFIG_NULL_OK is specified in specFlags then the value may be an 
  12402.            empty string, in which case the target and tkwin's active cursor 
  12403.            will be set to None. If the previous value of the target wasn't 
  12404.            None, then it is freed by passing it to Tk_FreeCursor. 
  12405.  
  12406.  TK_CONFIG_ANCHOR  The value must be an ASCII string identifying an anchor 
  12407.            point in one of the ways accepted by Tk_GetAnchor. The string is 
  12408.            converted to a Tk_Anchor by calling Tk_GetAnchor and the result is 
  12409.            stored in the target. 
  12410.  
  12411.  TK_CONFIG_BITMAP  The value must be an ASCII string identifying a bitmap in a 
  12412.            form suitable for passing to Tk_GetBitmap.  The value is converted 
  12413.            to a Pixmap by calling Tk_GetBitmap and the result is stored in the 
  12414.            target. If TK_CONFIG_NULL_OK is specified in specFlags then the 
  12415.            value may be an empty string, in which case the target is set to 
  12416.            None. If the previous value of the target wasn't None, then it is 
  12417.            freed by passing it to Tk_FreeBitmap. 
  12418.  
  12419.  TK_CONFIG_BOOLEAN  The value must be an ASCII string specifying a boolean 
  12420.            value.  Any of the values "true", "yes", "on", or "1", or an 
  12421.            abbreviation of one of these values, means true; any of the values 
  12422.            "false", "no", "off", or "0", or an abbreviation of one of these 
  12423.            values, means false. The target is expected to be an integer;  for 
  12424.            true values it will be set to 1 and for false values it will be set 
  12425.            to 0. 
  12426.  
  12427.  TK_CONFIG_BORDER  The value must be an ASCII string identifying a border color 
  12428.            in a form suitable for passing to Tk_Get3DBorder.  The value is 
  12429.            converted to a (Tk_3DBorder *) by calling Tk_Get3DBorder and the 
  12430.            result is stored in the target. If TK_CONFIG_NULL_OK is specified in 
  12431.            specFlags then the value may be an empty string, in which case the 
  12432.            target will be set to NULL. If the previous value of the target 
  12433.            wasn't NULL, then it is freed by passing it to Tk_Free3DBorder. 
  12434.  
  12435.  TK_CONFIG_CAP_STYLE  The value must be an ASCII string identifying a cap style 
  12436.            in one of the ways accepted by Tk_GetCapStyle. The string is 
  12437.            converted to an integer value corresponding to the cap style by 
  12438.            calling Tk_GetCapStyle and the result is stored in the target. 
  12439.  
  12440.  TK_CONFIG_COLOR  The value must be an ASCII string identifying a color in a 
  12441.            form suitable for passing to Tk_GetColor.  The value is converted to 
  12442.            an (XColor *) by calling Tk_GetColor and the result is stored in the 
  12443.            target. If TK_CONFIG_NULL_OK is specified in specFlags then the 
  12444.            value may be an empty string, in which case the target will be set 
  12445.            to None. If the previous value of the target wasn't NULL, then it is 
  12446.            freed by passing it to Tk_FreeColor. 
  12447.  
  12448.  TK_CONFIG_CURSOR  This option is identical to TK_CONFIG_ACTIVE_CURSOR except 
  12449.            that the new cursor is not made the active one for tkwin. 
  12450.  
  12451.  TK_CONFIG_CUSTOM  This option allows applications to define new option types. 
  12452.            The customPtr field of the entry points to a structure defining the 
  12453.            new option type. See the section CUSTOM OPTION TYPES below for 
  12454.            details. 
  12455.  
  12456.  TK_CONFIG_DOUBLE  The value must be an ASCII floating-point number in the 
  12457.            format accepted by strtol.  The string is converted to a double 
  12458.            value, and the value is stored in the target. 
  12459.  
  12460.  TK_CONFIG_END  Marks the end of the table.  The last entry in specs must have 
  12461.            this type;  all of its other fields are ignored and it will never 
  12462.            match any arguments. 
  12463.  
  12464.  TK_CONFIG_FONT  The value must be an ASCII string identifying a font in a form 
  12465.            suitable for passing to Tk_GetFontStruct.  The value is converted to 
  12466.            an (XFontStruct *) by calling Tk_GetFontStruct and the result is 
  12467.            stored in the target. If TK_CONFIG_NULL_OK is specified in specFlags 
  12468.            then the value may be an empty string, in which case the target will 
  12469.            be set to NULL. If the previous value of the target wasn't NULL, 
  12470.            then it is freed by passing it to Tk_FreeFontStruct. 
  12471.  
  12472.  TK_CONFIG_INT  The value must be an ASCII integer string in the format 
  12473.            accepted by strtol (e.g. "0" and "0x" prefixes may be used to 
  12474.            specify octal or hexadecimal numbers, respectively).  The string is 
  12475.            converted to an integer value and the integer is stored in the 
  12476.            target. 
  12477.  
  12478.  TK_CONFIG_JOIN_STYLE  The value must be an ASCII string identifying a join 
  12479.            style in one of the ways accepted by Tk_GetJoinStyle. The string is 
  12480.            converted to an integer value corresponding to the join style by 
  12481.            calling Tk_GetJoinStyle and the result is stored in the target. 
  12482.  
  12483.  TK_CONFIG_JUSTIFY  The value must be an ASCII string identifying a 
  12484.            justification method in one of the ways accepted by Tk_GetJustify. 
  12485.            The string is converted to a Tk_Justify by calling Tk_GetJustify and 
  12486.            the result is stored in the target. 
  12487.  
  12488.  TK_CONFIG_MM  The value must specify a screen distance in one of the forms 
  12489.            acceptable to Tk_GetScreenMM. The string is converted to 
  12490.            double-precision floating-point distance in millimeters and the 
  12491.            value is stored in the target. 
  12492.  
  12493.  TK_CONFIG_PIXELS  The value must specify screen units in one of the forms 
  12494.            acceptable to Tk_GetPixels. The string is converted to an integer 
  12495.            distance in pixels and the value is stored in the target. 
  12496.  
  12497.  TK_CONFIG_RELIEF  The value must be an ASCII string identifying a relief in a 
  12498.            form suitable for passing to Tk_GetRelief.  The value is converted 
  12499.            to an integer relief value by calling Tk_GetRelief and the result is 
  12500.            stored in the target. 
  12501.  
  12502.  TK_CONFIG_STRING  A copy of the value is made by allocating memory space with 
  12503.            malloc and copying the value into the dynamically-allocated space. 
  12504.            A pointer to the new string is stored in the target. If 
  12505.            TK_CONFIG_NULL_OK is specified in specFlags then the value may be an 
  12506.            empty string, in which case the target will be set to NULL. If the 
  12507.            previous value of the target wasn't NULL, then it is freed by 
  12508.            passing it to free. 
  12509.  
  12510.  TK_CONFIG_SYNONYM  This type value identifies special entries in specs that 
  12511.            are synonyms for other entries.  If an argv value matches the 
  12512.            argvName of a TK_CONFIG_SYNONYM entry, the entry isn't used 
  12513.            directly. Instead, Tk_ConfigureWidget searches specs for another 
  12514.            entry whose argvName is the same as the dbName field in the 
  12515.            TK_CONFIG_SYNONYM entry;  this new entry is used just as if its 
  12516.            argvName had matched the argv value.  The synonym mechanism allows 
  12517.            multiple argv values to be used for a single configuration option, 
  12518.            such as "-background" and "-bg". 
  12519.  
  12520.  TK_CONFIG_UID  The value is translated to a Tk_Uid (by passing it to 
  12521.            Tk_GetUid).  The resulting value is stored in the target. If 
  12522.            TK_CONFIG_NULL_OK is specified in specFlags and the value is an 
  12523.            empty string then the target will be set to NULL. 
  12524.  
  12525.  TK_CONFIG_WINDOW  The value must be a window path name.  It is translated to a 
  12526.            Tk_Window token and the token is stored in the target. 
  12527.  
  12528.  GROUPED ENTRIES 
  12529.  
  12530.  In some cases it is useful to generate multiple resources from a single 
  12531.  configuration value.  For example, a color name might be used both to generate 
  12532.  the background color for a widget (using TK_CONFIG_COLOR) and to generate a 
  12533.  3-D border to draw around the widget (using TK_CONFIG_BORDER).  In cases like 
  12534.  this it is possible to specify that several consecutive entries in specs are 
  12535.  to be treated as a group.  The first entry is used to determine a value (using 
  12536.  its argvName, dbName, dbClass, and defValue fields).  The value will be 
  12537.  processed several times (one for each entry in the group), generating multiple 
  12538.  different resources and modifying multiple targets within widgRec. Each of the 
  12539.  entries after the first must have a NULL value in its argvName field;  this 
  12540.  indicates that the entry is to be grouped with the entry that precedes it. 
  12541.  Only the type and offset fields are used from these follow-on entries. 
  12542.  
  12543.  FLAGS 
  12544.  
  12545.  The flags argument passed to Tk_ConfigureWidget is used in conjunction with 
  12546.  the specFlags fields in the entries of specs to provide additional control 
  12547.  over the processing of configuration options.  These values are used in three 
  12548.  different ways as described below. 
  12549.  
  12550.  First, if the flags argument to Tk_ConfigureWidget has the TK_CONFIG_ARGV_ONLY 
  12551.  bit set (i.e., flags | TK_CONFIG_ARGV_ONLY != 0), then the option database and 
  12552.  defValue fields are not used.  In this case, if an entry in specs doesn't 
  12553.  match a field in argv then nothing happens: the corresponding target isn't 
  12554.  modified.  This feature is useful when the goal is to modify certain 
  12555.  configuration options while leaving others in their current state, such as 
  12556.  when a configure widget command is being processed. 
  12557.  
  12558.  Second, the specFlags field of an entry in specs may be used to control the 
  12559.  processing of that entry.  Each specFlags field may consists of an OR-ed 
  12560.  combination of the following values: 
  12561.  
  12562.  TK_CONFIG_COLOR_ONLY  If this bit is set then the entry will only be 
  12563.            considered if the display for tkwin has more than one bit plane.  If 
  12564.            the display is monochromatic then this specs entry will be ignored. 
  12565.  
  12566.  TK_CONFIG_MONO_ONLY  If this bit is set then the entry will only be considered 
  12567.            if the display for tkwin has exactly one bit plane.  If the display 
  12568.            is not monochromatic then this specs entry will be ignored. 
  12569.  
  12570.  TK_CONFIG_NULL_OK  This bit is only relevant for some types of entries (see 
  12571.            the descriptions of the various entry types above). If this bit is 
  12572.            set, it indicates that an empty string value for the field is 
  12573.            acceptable and if it occurs then the target should be set to NULL or 
  12574.            None, depending on the type of the target. This flag is typically 
  12575.            used to allow a feature to be turned off entirely, e.g. set a cursor 
  12576.            value to None so that a window simply inherits its parent's cursor. 
  12577.            If this bit isn't set then empty strings are processed as strings, 
  12578.            which generally results in an error. 
  12579.  
  12580.  TK_CONFIG_DONT_SET_DEFAULT  If this bit is one, it means that the defValue 
  12581.            field of the entry should only be used for returning the default 
  12582.            value in Tk_ConfigureInfo. In calls to Tk_ConfigureWidget no default 
  12583.            will be supplied for entries with this flag set;  it is assumed that 
  12584.            the caller has already supplied a default value in the target 
  12585.            location. This flag provides a performance optimization where it is 
  12586.            expensive to process the default string:  the client can compute the 
  12587.            default once, save the value, and provide it before calling 
  12588.            Tk_ConfigureWidget. 
  12589.  
  12590.  TK_CONFIG_OPTION_SPECIFIED  This bit is set and cleared by Tk_ConfigureWidget. 
  12591.            Whenever Tk_ConfigureWidget returns, this bit will be set in all the 
  12592.            entries where a value was specified in argv. It will be zero in all 
  12593.            other entries. This bit provides a way for clients to determine 
  12594.            which values actually changed in a call to Tk_ConfigureWidget. 
  12595.  
  12596.  The TK_CONFIG_MONO_ONLY and TK_CONFIG_COLOR_ONLY flags are typically used to 
  12597.  specify different default values for monochrome and color displays.  This is 
  12598.  done by creating two entries in specs that are identical except for their 
  12599.  defValue and specFlags fields.  One entry should have the value 
  12600.  TK_CONFIG_MONO_ONLY in its specFlags and the default value for monochrome 
  12601.  displays in its defValue;  the other entry entry should have the value 
  12602.  TK_CONFIG_COLOR_ONLY in its specFlags and the appropriate defValue for color 
  12603.  displays. 
  12604.  
  12605.  Third, it is possible to use flags and specFlags together to selectively 
  12606.  disable some entries.  This feature is not needed very often.  It is useful in 
  12607.  cases where several similar kinds of widgets are implemented in one place.  It 
  12608.  allows a single specs table to be created with all the configuration options 
  12609.  for all the widget types.  When processing a particular widget type, only 
  12610.  entries relevant to that type will be used.  This effect is achieved by 
  12611.  setting the high-order bits (those in positions equal to or greater than 
  12612.  TK_CONFIG_USER_BIT) in specFlags values or in flags.  In order for a 
  12613.  particular entry in specs to be used, its high-order bits must match exactly 
  12614.  the high-order bits of the flags value passed to Tk_ConfigureWidget.  If a 
  12615.  specs table is being used for N different widget types, then N of the 
  12616.  high-order bits will be used.  Each specs entry will have one of more of those 
  12617.  bits set in its specFlags field to indicate the widget types for which this 
  12618.  entry is valid.  When calling Tk_ConfigureWidget, flags will have a single one 
  12619.  of these bits set to select the entries for the desired widget type.  For a 
  12620.  working example of this feature, see the code in tkButton.c. 
  12621.  
  12622.  TK_OFFSET 
  12623.  
  12624.  The Tk_Offset macro is provided as a safe way of generating the offset values 
  12625.  for entries in Tk_ConfigSpec structures. It takes two arguments:  the name of 
  12626.  a type of record, and the name of a field in that record.  It returns the byte 
  12627.  offset of the named field in records of the given type. 
  12628.  
  12629.  TK_CONFIGUREINFO 
  12630.  
  12631.  The Tk_ConfigureInfo procedure may be used to obtain information about one or 
  12632.  all of the options for a given widget. Given a token for a window (tkwin), a 
  12633.  table describing the configuration options for a class of widgets (specs), a 
  12634.  pointer to a widget record containing the current information for a widget 
  12635.  (widgRec), and a NULL argvName argument, Tk_ConfigureInfo generates a string 
  12636.  describing all of the configuration options for the window.  The string is 
  12637.  placed in interp->result.  Under normal circumstances it returns TCL_OK;  if 
  12638.  an error occurs then it returns TCL_ERROR and interp->result contains an error 
  12639.  message. 
  12640.  
  12641.  If argvName is NULL, then the value left in interp->result by Tk_ConfigureInfo 
  12642.  consists of a list of one or more entries, each of which describes one 
  12643.  configuration option (i.e. one entry in specs).  Each entry in the list will 
  12644.  contain either two or five values.  If the corresponding entry in specs has 
  12645.  type TK_CONFIG_SYNONYM, then the list will contain two values:  the argvName 
  12646.  for the entry and the dbName (synonym name).  Otherwise the list will contain 
  12647.  five values:  argvName, dbName, dbClass, defValue, and current value.  The 
  12648.  current value is computed from the appropriate field of widgRec by calling 
  12649.  procedures like Tk_NameOfColor. 
  12650.  
  12651.  If the argvName argument to Tk_ConfigureInfo is non-NULL, then it indicates a 
  12652.  single option, and information is returned only for that option.  The string 
  12653.  placed in interp->result will be a list containing two or five values as 
  12654.  described above;  this will be identical to the corresponding sublist that 
  12655.  would have been returned if argvName had been NULL. 
  12656.  
  12657.  The flags argument to Tk_ConfigureInfo is used to restrict the specs entries 
  12658.  to consider, just as for Tk_ConfigureWidget. 
  12659.  
  12660.  TK_CONFIGUREVALUE 
  12661.  
  12662.  Tk_ConfigureValue takes arguments similar to Tk_ConfigureInfo; instead of 
  12663.  returning a list of values, it just returns the current value of the option 
  12664.  given by argvName (argvName must not be NULL). The value is returned in 
  12665.  interp->result and TCL_OK is normally returned as the procedure's result. If 
  12666.  an error occurs in Tk_ConfigureValue (e.g., argvName is not a valid option 
  12667.  name), TCL_ERROR is returned and an error message is left in interp->result. 
  12668.  This procedure is typically called to implement cget widget commands. 
  12669.  
  12670.  TK_FREEOPTIONS 
  12671.  
  12672.  The Tk_FreeOptions procedure may be invoked during widget cleanup to release 
  12673.  all of the resources associated with configuration options. It scans through 
  12674.  specs and for each entry corresponding to a resource that must be explicitly 
  12675.  freed (e.g. those with type TK_CONFIG_COLOR), it frees the resource in the 
  12676.  widget record. If the field in the widget record doesn't refer to a resource 
  12677.  (e.g. it contains a null pointer) then no resource is freed for that entry. 
  12678.  After freeing a resource, Tk_FreeOptions sets the corresponding field of the 
  12679.  widget record to null. 
  12680.  
  12681.  CUSTOM OPTION TYPES 
  12682.  
  12683.  Applications can extend the built-in configuration types with additional 
  12684.  configuration types by writing procedures to parse and print options of the a 
  12685.  type and creating a structure pointing to those procedures: 
  12686.  
  12687.   typedef struct Tk_CustomOption {
  12688.          Tk_OptionParseProc *parseProc;
  12689.          Tk_OptionPrintProc *printProc;
  12690.          ClientData clientData;
  12691.   } Tk_CustomOption;
  12692.  
  12693.   typedef int Tk_OptionParseProc(
  12694.          ClientData clientData,
  12695.          Tcl_Interp *interp,
  12696.          Tk_Window tkwin,
  12697.          char *value,
  12698.          char *widgRec,
  12699.          int offset);
  12700.  
  12701.   typedef char *Tk_OptionPrintProc(
  12702.          ClientData clientData,
  12703.          Tk_Window tkwin,
  12704.          char *widgRec,
  12705.          int offset,
  12706.          Tcl_FreeProc **freeProcPtr);
  12707.  The Tk_CustomOption structure contains three fields, which are pointers to the 
  12708.  two procedures and a clientData value to be passed to those procedures when 
  12709.  they are invoked.  The clientData value typically points to a structure 
  12710.  containing information that is needed by the procedures when they are parsing 
  12711.  and printing options. 
  12712.  
  12713.  The parseProc procedure is invoked by Tk_ConfigureWidget to parse a string and 
  12714.  store the resulting value in the widget record. The clientData argument is a 
  12715.  copy of the clientData field in the Tk_CustomOption structure. The interp 
  12716.  argument points to a Tcl interpreter used for error reporting.  Tkwin is a 
  12717.  copy of the tkwin argument to Tk_ConfigureWidget.  The value argument is a 
  12718.  string describing the value for the option;  it could have been specified 
  12719.  explicitly in the call to Tk_ConfigureWidget or it could come from the option 
  12720.  database or a default. Value will never be a null pointer but it may point to 
  12721.  an empty string. RecordPtr is the same as the widgRec argument to 
  12722.  Tk_ConfigureWidget;  it points to the start of the widget record to modify. 
  12723.  The last argument, offset, gives the offset in bytes from the start of the 
  12724.  widget record to the location where the option value is to be placed.  The 
  12725.  procedure should translate the string to whatever form is appropriate for the 
  12726.  option and store the value in the widget record.  It should normally return 
  12727.  TCL_OK, but if an error occurs in translating the string to a value then it 
  12728.  should return TCL_ERROR and store an error message in interp->result. 
  12729.  
  12730.  The printProc procedure is called by Tk_ConfigureInfo to produce a string 
  12731.  value describing an existing option. Its clientData, tkwin, widgRec, and 
  12732.  offset arguments all have the same meaning as for Tk_OptionParseProc 
  12733.  procedures. The printProc procedure should examine the option whose value is 
  12734.  stored at offset in widgRec, produce a string describing that option, and 
  12735.  return a pointer to the string. If the string is stored in 
  12736.  dynamically-allocated memory, then the procedure must set *freeProcPtr to the 
  12737.  address of a procedure to call to free the string's memory;  Tk_ConfigureInfo 
  12738.  will call this procedure when it is finished with the string. If the result 
  12739.  string is stored in static memory then printProc need not do anything with the 
  12740.  freeProcPtr argument. 
  12741.  
  12742.  Once parseProc and printProc have been defined and a Tk_CustomOption structure 
  12743.  has been created for them, options of this new type may be manipulated with 
  12744.  Tk_ConfigSpec entries whose type fields are TK_CONFIG_CUSTOM and whose 
  12745.  customPtr fields point to the Tk_CustomOption structure. 
  12746.  
  12747.  EXAMPLES 
  12748.  
  12749.  Although the explanation of Tk_ConfigureWidget is fairly complicated, its 
  12750.  actual use is pretty straightforward. The easiest way to get started is to 
  12751.  copy the code from an existing widget. The library implementation of frames 
  12752.  (tkFrame.c) has a simple configuration table, and the library implementation 
  12753.  of buttons (tkButton.c) has a much more complex table that uses many of the 
  12754.  fancy specFlags mechanisms. 
  12755.  
  12756.  KEYWORDS 
  12757.  
  12758.  anchor, bitmap, boolean, border, cap style, color, configuration options, 
  12759.  cursor, custom, double, font, integer, join style, justify, millimeters, 
  12760.  pixels, relief, synonym, uid 
  12761.  
  12762.  
  12763. ΓòÉΓòÉΓòÉ 5.9. Tk_ConfigureWindow ΓòÉΓòÉΓòÉ
  12764.  
  12765.  NAME 
  12766.  
  12767. Tk_ConfigureWindow, Tk_MoveWindow, Tk_ResizeWindow, Tk_MoveResizeWindow, 
  12768. Tk_SetWindowBorderWidth, Tk_ChangeWindowAttributes, Tk_SetWindowBackground, 
  12769. Tk_SetWindowBackgroundPixmap, Tk_SetWindowBorder, Tk_SetWindowBorderPixmap, 
  12770. Tk_SetWindowColormap, Tk_DefineCursor, Tk_UndefineCursor - change window 
  12771. configuration or attributes 
  12772.  
  12773. SYNOPSIS 
  12774.  
  12775. #include <tk.h> 
  12776.  
  12777.  Tk_ConfigureWindow(tkwin, valueMask, valuePtr) 
  12778.  
  12779.  Tk_MoveWindow(tkwin, x, y) 
  12780.  
  12781.  Tk_ResizeWindow(tkwin, width, height) 
  12782.  
  12783.  Tk_MoveResizeWindow(tkwin, x,  y, width, height) 
  12784.  
  12785.  Tk_SetWindowBorderWidth(tkwin, borderWidth) 
  12786.  
  12787.  Tk_ChangeWindowAttributes(tkwin, valueMask, attsPtr) 
  12788.  
  12789.  Tk_SetWindowBackground(tkwin, pixel) 
  12790.  
  12791.  Tk_SetWindowBackgroundPixmap(tkwin, pixmap) 
  12792.  
  12793.  Tk_SetWindowBorder(tkwin, pixel) 
  12794.  
  12795.  Tk_SetWindowBorderPixmap(tkwin, pixmap) 
  12796.  
  12797.  Tk_SetWindowColormap(tkwin, colormap) 
  12798.  
  12799.  Tk_DefineCursor(tkwin, cursor) 
  12800.  
  12801.  Tk_UndefineCursor(tkwin) 
  12802.  
  12803. ARGUMENTS 
  12804.  
  12805.  Tk_Window  tkwin (in)  Token for window. 
  12806.  
  12807.  unsigned int  valueMask (in)  OR-ed mask of values like CWX or CWBorderPixel, 
  12808.            indicating which fields of *valuePtr or *attsPtr to use. 
  12809.  
  12810.  XWindowChanges  *valuePtr (in)  Points to a structure containing new values 
  12811.            for the configuration parameters selected by valueMask.  Fields not 
  12812.            selected by valueMask are ignored. 
  12813.  
  12814.  int  x (in)  New x-coordinate for tkwin's top left pixel (including border, if 
  12815.            any) within tkwin's parent. 
  12816.  
  12817.  int  y (in)  New y-coordinate for tkwin's top left pixel (including border, if 
  12818.            any) within tkwin's parent. 
  12819.  
  12820.  int  width (in)  New width for tkwin (interior, not including border). 
  12821.  
  12822.  int  height (in)  New height for tkwin (interior, not including border). 
  12823.  
  12824.  int  borderWidth (in)  New width for tkwin's border. 
  12825.  
  12826.  XSetWindowAttributes  *attsPtr (in)  Points to a structure containing new 
  12827.            values for the attributes given by the valueMask argument. 
  12828.            Attributes not selected by valueMask are ignored. 
  12829.  
  12830.  unsigned long  pixel (in)  New background or border color for window. 
  12831.  
  12832.  Pixmap  pixmap (in)  New pixmap to use for background or border of tkwin. 
  12833.            WARNING: cannot necessarily be deleted immediately, as for Xlib 
  12834.            calls.  See note below. 
  12835.  
  12836.  Colormap  colormap (in)  New colormap to use for tkwin. 
  12837.  
  12838.  Tk_Cursor  cursor (in)  New cursor to use for tkwin.  If None is specified, 
  12839.            then tkwin will not have its own cursor;  it will use the cursor of 
  12840.            its parent. 
  12841.  
  12842.  DESCRIPTION 
  12843.  
  12844.  These procedures are analogous to the X library procedures with similar names, 
  12845.  such as XConfigureWindow.  Each one of the above procedures calls the 
  12846.  corresponding X procedure and also saves the configuration information in Tk's 
  12847.  local structure for the window.  This allows the information to be retrieved 
  12848.  quickly by the application (using macros such as Tk_X and Tk_Height) without 
  12849.  having to contact the X server.  In addition, if no X window has actually been 
  12850.  created for tkwin yet, these procedures do not issue X operations or cause 
  12851.  event handlers to be invoked;  they save the information in Tk's local 
  12852.  structure for the window;  when the window is created later, the saved 
  12853.  information will be used to configure the window. 
  12854.  
  12855.  See the X library documentation for details on what these procedures do and 
  12856.  how they use their arguments. 
  12857.  
  12858.  In the procedures Tk_ConfigureWindow, Tk_MoveWindow, Tk_ResizeWindow, 
  12859.  Tk_MoveResizeWindow, and Tk_SetWindowBorderWidth, if tkwin is an internal 
  12860.  window then event handlers interested in configure events are invoked 
  12861.  immediately, before the procedure returns.  If tkwin is a top-level window 
  12862.  then the event handlers will be invoked later, after X has seen the request 
  12863.  and returned an event for it. 
  12864.  
  12865.  Applications using Tk should never call procedures like XConfigureWindow 
  12866.  directly;  they should always use the corresponding Tk procedures. 
  12867.  
  12868.  The size and location of a window should only be modified by the appropriate 
  12869.  geometry manager for that window and never by a window itself (but see 
  12870.  Tk_MoveToplevelWindow for moving a top-level window). 
  12871.  
  12872.  You may not use Tk_ConfigureWindow to change the stacking order of a window 
  12873.  (valueMask may not contain the CWSibling or CWStackMode bits). To change the 
  12874.  stacking order, use the procedure Tk_RestackWindow. 
  12875.  
  12876.  The procedure Tk_SetWindowColormap will automatically add tkwin to the 
  12877.  TK_COLORMAP_WINDOWS property of its nearest top-level ancestor if the new 
  12878.  colormap is different from that of tkwin's parent and tkwin isn't already in 
  12879.  the TK_COLORMAP_WINDOWS property. 
  12880.  
  12881.  BUGS 
  12882.  
  12883.  Tk_SetWindowBackgroundPixmap and Tk_SetWindowBorderPixmap differ slightly from 
  12884.  their Xlib counterparts in that the pixmap argument may not necessarily be 
  12885.  deleted immediately after calling one of these procedures.  This is because 
  12886.  tkwin's window may not exist yet at the time of the call, in which case pixmap 
  12887.  is merely saved and used later when tkwin's window is actually created.  If 
  12888.  you wish to delete pixmap, then call Tk_MakeWindowExist first to be sure that 
  12889.  tkwin's window exists and pixmap has been passed to the X server. 
  12890.  
  12891.  A similar problem occurs for the cursor argument passed to Tk_DefineCursor. 
  12892.  The solution is the same as for pixmaps above: call Tk_MakeWindowExist before 
  12893.  freeing the cursor. 
  12894.  
  12895.  SEE ALSO 
  12896.  
  12897.  Tk_MoveToplevelWindow, Tk_RestackWindow 
  12898.  
  12899.  KEYWORDS 
  12900.  
  12901.  attributes, border, color, configure, height, pixel, pixmap, width, window, x, 
  12902.  y 
  12903.  
  12904.  
  12905. ΓòÉΓòÉΓòÉ 5.10. Tk_CoordsToWindow ΓòÉΓòÉΓòÉ
  12906.  
  12907.  NAME 
  12908.  
  12909. Tk_CoordsToWindow - Find window containing a point 
  12910.  
  12911. SYNOPSIS 
  12912.  
  12913. #include <tk.h> 
  12914.  
  12915.  Tk_Window 
  12916.  Tk_CoordsToWindow(rootX, rootY, tkwin) 
  12917.  
  12918. ARGUMENTS 
  12919.  
  12920.  int  rootX (in)  X-coordinate (in root window coordinates). 
  12921.  
  12922.  int  rootY (in)  Y-coordinate (in root window coordinates). 
  12923.  
  12924.  Tk_Window  tkwin (in)  Token for window that identifies application. 
  12925.  
  12926.  DESCRIPTION 
  12927.  
  12928.  Tk_CoordsToWindow locates the window that contains a given point. The point is 
  12929.  specified in root coordinates with rootX and rootY (if a virtual-root window 
  12930.  manager is in use then rootX and rootY are in the coordinate system of the 
  12931.  virtual root window). The return value from the procedure is a token for the 
  12932.  window that contains the given point. If the point is not in any window, or if 
  12933.  the containing window is not in the same application as tkwin, then NULL is 
  12934.  returned. 
  12935.  
  12936.  The containing window is decided using the same rules that determine which 
  12937.  window contains the mouse cursor:  if a parent and a child both contain the 
  12938.  point then the child gets preference, and if two siblings both contain the 
  12939.  point then the highest one in the stacking order (i.e. the one that's visible 
  12940.  on the screen) gets preference. 
  12941.  
  12942.  KEYWORDS 
  12943.  
  12944.  containing, coordinates, root window 
  12945.  
  12946.  
  12947. ΓòÉΓòÉΓòÉ 5.11. Tk_CreateErrorHandler ΓòÉΓòÉΓòÉ
  12948.  
  12949.  NAME 
  12950.  
  12951. Tk_CreateErrorHandler, Tk_DeleteErrorHandler - handle X protocol errors 
  12952.  
  12953. SYNOPSIS 
  12954.  
  12955. #include <tk.h> 
  12956.  
  12957.  Tk_ErrorHandler 
  12958.  Tk_CreateErrorHandler(display, error, request, minor, proc, clientData) 
  12959.  
  12960.  Tk_DeleteErrorHandler(handler) 
  12961.  
  12962. ARGUMENTS 
  12963.  
  12964.  Display  *display (in)  Display whose errors are to be handled. 
  12965.  
  12966.  int  error (in)  Match only error events with this value in the error_code 
  12967.            field.  If -1, then match any error_code value. 
  12968.  
  12969.  int  request (in)  Match only error events with this value in the request_code 
  12970.            field.  If -1, then match any request_code value. 
  12971.  
  12972.  int  minor (in)  Match only error events with this value in the minor_code 
  12973.            field.  If -1, then match any minor_code value. 
  12974.  
  12975.  Tk_ErrorProc  *proc (in)  Procedure to invoke whenever an error event is 
  12976.            received for display and matches error, request, and minor. NULL 
  12977.            means ignore any matching errors. 
  12978.  
  12979.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  12980.  
  12981.  Tk_ErrorHandler  handler (in)  Token for error handler to delete (return value 
  12982.            from a previous call to Tk_CreateErrorHandler). 
  12983.  
  12984.  DESCRIPTION 
  12985.  
  12986.  Tk_CreateErrorHandler arranges for a particular procedure (proc) to be called 
  12987.  whenever certain protocol errors occur on a particular display (display). 
  12988.  Protocol errors occur when the X protocol is used incorrectly, such as 
  12989.  attempting to map a window that doesn't exist.  See the Xlib documentation for 
  12990.  XSetErrorHandler for more information on the kinds of errors that can occur. 
  12991.  For proc to be invoked to handle a particular error, five things must occur: 
  12992.  
  12993.    1. The error must pertain to display. 
  12994.  
  12995.    2. Either the error argument to Tk_CreateErrorHandler must have been -1, or 
  12996.       the error argument must match the error_code field from the error event. 
  12997.  
  12998.    3. Either the request argument to Tk_CreateErrorHandler must have been -1, 
  12999.       or the request argument must match the request_code field from the error 
  13000.       event. 
  13001.  
  13002.    4. Either the minor argument to Tk_CreateErrorHandler must have been -1, or 
  13003.       the minor argument must match the minor_code field from the error event. 
  13004.  
  13005.    5. The protocol request to which the error pertains must have been made when 
  13006.       the handler was active (see below for more information). 
  13007.  
  13008.  Proc should have arguments and result that match the following type: 
  13009.  
  13010.   typedef int Tk_ErrorProc(
  13011.          ClientData clientData,
  13012.          XErrorEvent *errEventPtr);
  13013.  The clientData parameter to proc is a copy of the clientData argument given to 
  13014.  Tcl_CreateErrorHandler when the callback was created.  Typically, clientData 
  13015.  points to a data structure containing application-specific information that is 
  13016.  needed to deal with the error.  ErrEventPtr is a pointer to the X error event. 
  13017.  The procedure proc should return an integer value.  If it returns 0 it means 
  13018.  that proc handled the error completely and there is no need to take any other 
  13019.  action for the error.  If it returns non-zero it means proc was unable to 
  13020.  handle the error. 
  13021.  
  13022.  If a value of NULL is specified for proc, all matching errors will be ignored: 
  13023.  this will produce the same result as if a procedure had been specified that 
  13024.  always returns 0. 
  13025.  
  13026.  If more than more than one handler matches a particular error, then they are 
  13027.  invoked in turn.  The handlers will be invoked in reverse order of creation: 
  13028.  most recently declared handler first. If any handler returns 0, then 
  13029.  subsequent (older) handlers will not be invoked.  If no handler returns 0, 
  13030.  then Tk invokes X'es default error handler, which prints an error message and 
  13031.  aborts the program.  If you wish to have a default handler that deals with 
  13032.  errors that no other handler can deal with, then declare it first. 
  13033.  
  13034.  The X documentation states that "the error handler should not call any 
  13035.  functions (directly or indirectly) on the display that will generate protocol 
  13036.  requests or that will look for input events." This restriction applies to 
  13037.  handlers declared by Tk_CreateErrorHandler; disobey it at your own risk. 
  13038.  
  13039.  Tk_DeleteErrorHandler may be called to delete a previously-created error 
  13040.  handler.  The handler argument identifies the error handler, and should be a 
  13041.  value returned by a previous call to Tk_CreateEventHandler. 
  13042.  
  13043.  A particular error handler applies to errors resulting from protocol requests 
  13044.  generated between the call to Tk_CreateErrorHandler and the call to 
  13045.  Tk_DeleteErrorHandler.  However, the actual callback to proc may not occur 
  13046.  until after the Tk_DeleteErrorHandler call, due to buffering in the client and 
  13047.  server. If an error event pertains to a protocol request made just before 
  13048.  calling Tk_DeleteErrorHandler, then the error event may not have been 
  13049.  processed before the Tk_DeleteErrorHandler call.  When this situation arises, 
  13050.  Tk will save information about the handler and invoke the handler's proc later 
  13051.  when the error event finally arrives. If an application wishes to delete an 
  13052.  error handler and know for certain that all relevant errors have been 
  13053.  processed, it should first call Tk_DeleteErrorHandler and then call XSync; 
  13054.  this will flush out any buffered requests and errors, but will result in a 
  13055.  performance penalty because it requires communication to and from the X 
  13056.  server.  After the XSync call Tk is guaranteed not to call any error handlers 
  13057.  deleted before the XSync call. 
  13058.  
  13059.  For the Tk error handling mechanism to work properly, it is essential that 
  13060.  application code never calls XSetErrorHandler directly; applications should 
  13061.  use only Tk_CreateErrorHandler. 
  13062.  
  13063.  KEYWORDS 
  13064.  
  13065.  callback, error, event, handler 
  13066.  
  13067.  
  13068. ΓòÉΓòÉΓòÉ 5.12. Tk_CreateGenericHandler ΓòÉΓòÉΓòÉ
  13069.  
  13070.  NAME 
  13071.  
  13072. Tk_CreateGenericHandler, Tk_DeleteGenericHandler - associate procedure callback 
  13073. with all X events 
  13074.  
  13075. SYNOPSIS 
  13076.  
  13077. #include <tk.h> 
  13078.  
  13079.  Tk_CreateGenericHandler(proc, clientData) 
  13080.  
  13081.  Tk_DeleteGenericHandler(proc, clientData) 
  13082.  
  13083. ARGUMENTS 
  13084.  
  13085.  Tk_GenericProc  *proc (in)  Procedure to invoke whenever any X event occurs on 
  13086.            any display. 
  13087.  
  13088.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  13089.  
  13090.  DESCRIPTION 
  13091.  
  13092.  Tk_CreateGenericHandler arranges for proc to be invoked in the future whenever 
  13093.  any X event occurs.  This mechanism is not intended for dispatching X events 
  13094.  on windows managed by Tk (you should use Tk_CreateEventHandler for this 
  13095.  purpose). Tk_CreateGenericHandler is intended for other purposes, such as 
  13096.  tracing X events, monitoring events on windows not owned by Tk, accessing 
  13097.  X-related libraries that were not originally designed for use with Tk, and so 
  13098.  on. 
  13099.  
  13100.  The callback to proc will be made by Tk_HandleEvent; this mechanism only works 
  13101.  in programs that dispatch events through Tk_HandleEvent (or through other Tk 
  13102.  procedures that call Tk_HandleEvent, such as Tk_DoOneEvent or Tk_MainLoop). 
  13103.  
  13104.  Proc should have arguments and result that match the type Tk_GenericProc: 
  13105.  
  13106.   typedef int Tk_GenericProc(
  13107.          ClientData clientData,
  13108.          XEvent *eventPtr);
  13109.  The clientData parameter to proc is a copy of the clientData argument given to 
  13110.  Tk_CreateGenericHandler when the callback was created.  Typically, clientData 
  13111.  points to a data structure containing application-specific information about 
  13112.  how to handle events. EventPtr is a pointer to the X event. 
  13113.  
  13114.  Whenever an X event is processed by Tk_HandleEvent, proc is called.  The 
  13115.  return value from proc is normally 0. A non-zero return value indicates that 
  13116.  the event is not to be handled further; that is, proc has done all processing 
  13117.  that is to be allowed for the event. 
  13118.  
  13119.  If there are multiple generic event handlers, each one is called for each 
  13120.  event, in the order in which they were established. 
  13121.  
  13122.  Tk_DeleteGenericHandler may be called to delete a previously-created generic 
  13123.  event handler:  it deletes each handler it finds that matches the proc and 
  13124.  clientData arguments.  If no such handler exists, then Tk_DeleteGenericHandler 
  13125.  returns without doing anything.  Although Tk supports it, it's probably a bad 
  13126.  idea to have more than one callback with the same proc and clientData 
  13127.  arguments. 
  13128.  
  13129.  Establishing a generic event handler does nothing to ensure that the process 
  13130.  will actually receive the X events that the handler wants to process. For 
  13131.  example, it is the caller's responsibility to invoke XSelectInput to select 
  13132.  the desired events, if that is necessary. 
  13133.  
  13134.  KEYWORDS 
  13135.  
  13136.  bind, callback, event, handler 
  13137.  
  13138.  
  13139. ΓòÉΓòÉΓòÉ 5.13. Tk_CreateImageType ΓòÉΓòÉΓòÉ
  13140.  
  13141.  NAME 
  13142.  
  13143. Tk_CreateImageType - define new kind of image 
  13144.  
  13145. SYNOPSIS 
  13146.  
  13147. #include <tk.h> 
  13148.  
  13149.  Tk_CreateImageType(typePtr) 
  13150.  
  13151. ARGUMENTS 
  13152.  
  13153.  Tk_ImageType  *typePtr (in)  Structure that defines the new type of image. 
  13154.  
  13155.  DESCRIPTION 
  13156.  
  13157.  Tk_CreateImageType is invoked to define a new kind of image. An image type 
  13158.  corresponds to a particular value of the type argument for the image create 
  13159.  command.  There may exist any number of different image types, and new types 
  13160.  may be defined dynamically by calling Tk_CreateImageType. For example, there 
  13161.  might be one type for 2-color bitmaps, another for multi-color images, another 
  13162.  for dithered images, another for video, and so on. 
  13163.  
  13164.  The code that implements a new image type is called an image manager. It 
  13165.  consists of a collection of procedures plus three different kinds of data 
  13166.  structures. The first data structure is a Tk_ImageType structure, which 
  13167.  contains the name of the image type and pointers to five procedures provided 
  13168.  by the image manager to deal with images of this type: 
  13169.  
  13170.   typedef struct Tk_ImageType {
  13171.          char *name;
  13172.          Tk_ImageCreateProc *createProc;
  13173.          Tk_ImageGetProc *getProc;
  13174.          Tk_ImageDisplayProc *displayProc;
  13175.          Tk_ImageFreeProc *freeProc;
  13176.          Tk_ImageDeleteProc *deleteProc;
  13177.   } Tk_ImageType;
  13178.  The fields of this structure will be described in later subsections of this 
  13179.  entry. 
  13180.  
  13181.  The second major data structure manipulated by an image manager is called an 
  13182.  image master;  it contains overall information about a particular image, such 
  13183.  as the values of the configuration options specified in an image create 
  13184.  command. There will usually be one of these structures for each invocation of 
  13185.  the image create command. 
  13186.  
  13187.  The third data structure related to images is an image instance. There will 
  13188.  usually be one of these structures for each usage of an image in a particular 
  13189.  widget. It is possible for a single image to appear simultaneously in multiple 
  13190.  widgets, or even multiple times in the same widget. Furthermore, different 
  13191.  instances may be on different screens or displays. The image instance data 
  13192.  structure describes things that may vary from instance to instance, such as 
  13193.  colors and graphics contexts for redisplay. There is usually one instance 
  13194.  structure for each -image option specified for a widget or canvas item. 
  13195.  
  13196.  The following subsections describe the fields of a Tk_ImageType in more 
  13197.  detail. 
  13198.  
  13199.  NAME 
  13200.  
  13201.  typePtr->name provides a name for the image type. Once Tk_CreateImageType 
  13202.  returns, this name may be used in image create commands to create images of 
  13203.  the new type. If there already existed an image type by this name then the new 
  13204.  image type replaces the old one. 
  13205.  
  13206.  CREATEPROC 
  13207.  
  13208.  typePtr->createProc provides the address of a procedure for Tk to call 
  13209.  whenever image create is invoked to create an image of the new type. 
  13210.  typePtr->createProc must match the following prototype: 
  13211.  
  13212.   typedef int Tk_ImageCreateProc(
  13213.          Tcl_Interp *interp,
  13214.          char *name,
  13215.          int argc,
  13216.          char **argv,
  13217.          Tk_ImageType *typePtr,
  13218.          Tk_ImageMaster master,
  13219.          ClientData *masterDataPtr);
  13220.  The interp argument is the interpreter in which the image command was invoked, 
  13221.  and name is the name for the new image, which was either specified explicitly 
  13222.  in the image command or generated automatically by the image command. The argc 
  13223.  and argv arguments describe all the configuration options for the new image 
  13224.  (everything after the name argument to image). The master argument is a token 
  13225.  that refers to Tk's information about this image;  the image manager must 
  13226.  return this token to Tk when invoking the Tk_ImageChanged procedure. Typically 
  13227.  createProc will parse argc and argv and create an image master data structure 
  13228.  for the new image. createProc may store an arbitrary one-word value at 
  13229.  *masterDataPtr, which will be passed back to the image manager when other 
  13230.  callbacks are invoked. Typically the value is a pointer to the master data 
  13231.  structure for the image. 
  13232.  
  13233.  If createProc encounters an error, it should leave an error message in 
  13234.  interp->result and return TCL_ERROR;  otherwise it should return TCL_OK. 
  13235.  
  13236.  createProc should call Tk_ImageChanged in order to set the size of the image 
  13237.  and request an initial redisplay. 
  13238.  
  13239.  GETPROC 
  13240.  
  13241.  typePtr->getProc is invoked by Tk whenever a widget calls Tk_GetImage to use a 
  13242.  particular image. This procedure must match the following prototype: 
  13243.  
  13244.   typedef ClientData Tk_ImageGetProc(
  13245.          Tk_Window tkwin,
  13246.          ClientData masterData);
  13247.  The tkwin argument identifies the window in which the image will be used and 
  13248.  masterData is the value returned by createProc when the image master was 
  13249.  created. getProc will usually create a data structure for the new instance, 
  13250.  including such things as the resources needed to display the image in the 
  13251.  given window. getProc returns a one-word token for the instance, which is 
  13252.  typically the address of the instance data structure. Tk will pass this value 
  13253.  back to the image manager when invoking its displayProc and freeProc 
  13254.  procedures. 
  13255.  
  13256.  DISPLAYPROC 
  13257.  
  13258.  typePtr->displayProc is invoked by Tk whenever an image needs to be displayed 
  13259.  (i.e., whenever a widget calls Tk_RedrawImage). displayProc must match the 
  13260.  following prototype: 
  13261.  
  13262.   typedef void Tk_ImageDisplayProc(
  13263.          ClientData instanceData,
  13264.          Display *display,
  13265.          Drawable drawable,
  13266.          int imageX,
  13267.          int imageY,
  13268.          int width,
  13269.          int height,
  13270.          int drawableX,
  13271.          int drawableY);
  13272.  The instanceData will be the same as the value returned by getProc when the 
  13273.  instance was created. display and drawable indicate where to display the 
  13274.  image;  drawable may be a pixmap rather than the window specified to getProc 
  13275.  (this is usually the case, since most widgets double-buffer their redisplay to 
  13276.  get smoother visual effects). imageX, imageY, width, and height identify the 
  13277.  region of the image that must be redisplayed. This region will always be 
  13278.  within the size of the image as specified in the most recent call to 
  13279.  Tk_ImageChanged. drawableX and drawableY indicate where in drawable the image 
  13280.  should be displayed;  displayProc should display the given region of the image 
  13281.  so that point (imageX, imageY) in the image appears at (drawableX, drawableY) 
  13282.  in drawable. 
  13283.  
  13284.  FREEPROC 
  13285.  
  13286.  typePtr->freeProc contains the address of a procedure that Tk will invoke when 
  13287.  an image instance is released (i.e., when Tk_FreeImage is invoked). This can 
  13288.  happen, for example, when a widget is deleted or a image item in a canvas is 
  13289.  deleted, or when the image displayed in a widget or canvas item is changed. 
  13290.  freeProc must match the following prototype: 
  13291.  
  13292.   typedef void Tk_ImageFreeProc(
  13293.          ClientData instanceData,
  13294.          Display *display);
  13295.  The instanceData will be the same as the value returned by getProc when the 
  13296.  instance was created, and display is the display containing the window for the 
  13297.  instance. freeProc should release any resources associated with the image 
  13298.  instance, since the instance will never be used again. 
  13299.  
  13300.  DELETEPROC 
  13301.  
  13302.  typePtr->deleteProc is a procedure that Tk invokes when an image is being 
  13303.  deleted (i.e. when the image delete command is invoked). Before invoking 
  13304.  deleteProc Tk will invoke freeProc for each of the image's instances. 
  13305.  deleteProc must match the following prototype: 
  13306.  
  13307.   typedef void Tk_ImageDeleteProc(
  13308.          ClientData masterData);
  13309.  The masterData argument will be the same as the value stored in *masterDataPtr 
  13310.  by createProc when the image was created. deleteProc should release any 
  13311.  resources associated with the image. 
  13312.  
  13313.  SEE ALSO 
  13314.  
  13315.  Tk_ImageChanged, Tk_GetImage, Tk_FreeImage, Tk_RedrawImage, Tk_SizeOfImage 
  13316.  
  13317.  KEYWORDS 
  13318.  
  13319.  image manager, image type, instance, master 
  13320.  
  13321.  
  13322. ΓòÉΓòÉΓòÉ 5.14. Tk_CreateItemType ΓòÉΓòÉΓòÉ
  13323.  
  13324.  NAME 
  13325.  
  13326. Tk_CreateItemType, Tk_GetItemTypes - define new kind of canvas item 
  13327.  
  13328. SYNOPSIS 
  13329.  
  13330. #include <tk.h> 
  13331.  
  13332.  Tk_CreateItemType(typePtr) 
  13333.  
  13334.  Tk_ItemType * 
  13335.  Tk_GetItemTypes() 
  13336.  
  13337. ARGUMENTS 
  13338.  
  13339.  Tk_ItemType  *typePtr (in)  Structure that defines the new type of canvas 
  13340.            item. 
  13341.  
  13342.  INTRODUCTION 
  13343.  
  13344.  Tk_CreateItemType is invoked to define a new kind of canvas item described by 
  13345.  the typePtr argument. An item type corresponds to a particular value of the 
  13346.  type argument to the create widget command for canvases, and the code that 
  13347.  implements a canvas item type is called a type manager. Tk defines several 
  13348.  built-in item types, such as rectangle and text and image, but 
  13349.  Tk_CreateItemType allows additional item types to be defined. Once 
  13350.  Tk_CreateItemType returns, the new item type may be used in new or existing 
  13351.  canvas widgets just like the built-in item types. 
  13352.  
  13353.  Tk_GetItemTypes returns a pointer to the first in the list of all item types 
  13354.  currently defined for canvases. The entries in the list are linked together 
  13355.  through their nextPtr fields, with the end of the list marked by a NULL 
  13356.  nextPtr. 
  13357.  
  13358.  You may find it easier to understand the rest of this manual entry by looking 
  13359.  at the code for an existing canvas item type such as bitmap (file 
  13360.  tkCanvBmap.c) or text (tkCanvText.c). The easiest way to create a new type 
  13361.  manager is to copy the code for an existing type and modify it for the new 
  13362.  type. 
  13363.  
  13364.  Tk provides a number of utility procedures for the use of canvas type 
  13365.  managers, such as Tk_CanvasCoords and Tk_CanvasPsColor; these are described in 
  13366.  separate manual entries. 
  13367.  
  13368.  DATA STRUCTURES 
  13369.  
  13370.  A type manager consists of a collection of procedures that provide a standard 
  13371.  set of operations on items of that type. The type manager deals with three 
  13372.  kinds of data structures. The first data structure is a Tk_ItemType; it 
  13373.  contains information such as the name of the type and pointers to the standard 
  13374.  procedures implemented by the type manager: 
  13375.  
  13376.   typedef struct Tk_ItemType {
  13377.          char *name;
  13378.          int itemSize;
  13379.          Tk_ItemCreateProc *createProc;
  13380.          Tk_ConfigSpec *configSpecs;
  13381.          Tk_ItemConfigureProc *configProc;
  13382.          Tk_ItemCoordProc *coordProc;
  13383.          Tk_ItemDeleteProc *deleteProc;
  13384.          Tk_ItemDisplayProc *displayProc;
  13385.          int alwaysRedraw;
  13386.          Tk_ItemPointProc *pointProc;
  13387.          Tk_ItemAreaProc *areaProc;
  13388.          Tk_ItemPostscriptProc *postscriptProc;
  13389.          Tk_ItemScaleProc *scaleProc;
  13390.          Tk_ItemTranslateProc *translateProc;
  13391.          Tk_ItemIndexProc *indexProc;
  13392.          Tk_ItemCursorProc *icursorProc;
  13393.          Tk_ItemSelectionProc *selectionProc;
  13394.          Tk_ItemInsertProc *insertProc;
  13395.          Tk_ItemDCharsProc *dCharsProc;
  13396.          Tk_ItemType *nextPtr;
  13397.   } Tk_ItemType;
  13398.  
  13399.  The fields of a Tk_ItemType structure are described in more detail later in 
  13400.  this manual entry. When Tk_CreateItemType is called, its typePtr argument must 
  13401.  point to a structure with all of the fields initialized except nextPtr, which 
  13402.  Tk sets to link all the types together into a list. The structure must be in 
  13403.  permanent memory (either statically allocated or dynamically allocated but 
  13404.  never freed);  Tk retains a pointer to this structure. 
  13405.  
  13406.  The second data structure manipulated by a type manager is an item record. For 
  13407.  each item in a canvas there exists one item record. All of the items of a 
  13408.  given type generally have item records with the same structure, but different 
  13409.  types usually have different formats for their item records. The first part of 
  13410.  each item record is a header with a standard structure defined by Tk via the 
  13411.  type Tk_Item;  the rest of the item record is defined by the type manager. A 
  13412.  type manager must define its item records with a Tk_Item as the first field. 
  13413.  For example, the item record for bitmap items is defined as follows: 
  13414.  
  13415.   typedef struct BitmapItem {
  13416.          Tk_Item header;
  13417.          double x, y;
  13418.          Tk_Anchor anchor;
  13419.          Pixmap bitmap;
  13420.          XColor *fgColor;
  13421.          XColor *bgColor;
  13422.          GC gc;
  13423.   } BitmapItem;
  13424.  The header substructure contains information used by Tk to manage the item, 
  13425.  such as its identifier, its tags, its type, and its bounding box. The fields 
  13426.  starting with x belong to the type manager: Tk will never read or write them. 
  13427.  The type manager should not need to read or write any of the fields in the 
  13428.  header except for four fields whose names are x1, y1, x2, and y2. These fields 
  13429.  give a bounding box for the items using integer canvas coordinates:  the item 
  13430.  should not cover any pixels with x-coordinate lower than x1 or y-coordinate 
  13431.  lower than y1, nor should it cover any pixels with x-coordinate greater than 
  13432.  or equal to x2 or y-coordinate greater than or equal to y2. It is up to the 
  13433.  type manager to keep the bounding box up to date as the item is moved and 
  13434.  reconfigured. 
  13435.  
  13436.  Whenever Tk calls a procedure in a type manager it passes in a pointer to an 
  13437.  item record. The argument is always passed as a pointer to a Tk_Item;  the 
  13438.  type manager will typically cast this into a pointer to its own specific type, 
  13439.  such as BitmapItem. 
  13440.  
  13441.  The third data structure used by type managers has type Tk_Canvas;  it serves 
  13442.  as an opaque handle for the canvas widget as a whole. Type managers need not 
  13443.  know anything about the contents of this structure. A Tk_Canvas handle is 
  13444.  typically passed in to the procedures of a type manager, and the type manager 
  13445.  can pass the handle back to library procedures such as Tk_CanvasTkwin to fetch 
  13446.  information about the canvas. 
  13447.  
  13448.  NAME 
  13449.  
  13450.  This section and the ones that follow describe each of the fields in a 
  13451.  Tk_ItemType structure in detail. The name field provides a string name for the 
  13452.  item type. Once Tk_CreateImageType returns, this name may be used in create 
  13453.  widget commands to create items of the new type. If there already existed an 
  13454.  item type by this name then the new item type replaces the old one. 
  13455.  
  13456.  ITEMSIZE 
  13457.  
  13458.  typePtr->itemSize gives the size in bytes of item records of this type, 
  13459.  including the Tk_Item header. Tk uses this size to allocate memory space for 
  13460.  items of the type. All of the item records for a given type must have the same 
  13461.  size. If variable length fields are needed for an item (such as a list of 
  13462.  points for a polygon), the type manager can allocate a separate object of 
  13463.  variable length and keep a pointer to it in the item record. 
  13464.  
  13465.  CREATEPROC 
  13466.  
  13467.  typePtr->createProc points to a procedure for Tk to call whenever a new item 
  13468.  of this type is created. typePtr->createProc must match the following 
  13469.  prototype: 
  13470.  
  13471.   typedef int Tk_ItemCreateProc(
  13472.          Tcl_Interp *interp,
  13473.          Tk_Canvas canvas,
  13474.          Tk_Item *itemPtr,
  13475.          int argc,
  13476.          char **argv);
  13477.  The interp argument is the interpreter in which the canvas's create widget 
  13478.  command was invoked, and canvas is a handle for the canvas widget. itemPtr is 
  13479.  a pointer to a newly-allocated item of size typePtr->itemSize. Tk has already 
  13480.  initialized the item's header (the first sizeof(Tk_ItemType) bytes). The argc 
  13481.  and argv arguments describe all of the arguments to the create command after 
  13482.  the type argument. For example, in the widget command 
  13483.  
  13484.   .c create rectangle 10 20 50 50 -fill black
  13485.  argc will be 6 and argv[0] will contain the string 10. 
  13486.  
  13487.  createProc should use argc and argv to initialize the type-specific parts of 
  13488.  the item record and set an initial value for the bounding box in the item's 
  13489.  header. It should return a standard Tcl completion code and leave an error 
  13490.  message in interp->result if an error occurs. If an error occurs Tk will free 
  13491.  the item record, so createProc must be sure to leave the item record in a 
  13492.  clean state if it returns an error (e.g., it must free any additional memory 
  13493.  that it allocated for the item). 
  13494.  
  13495.  CONFIGSPECS 
  13496.  
  13497.  Each type manager must provide a standard table describing its configuration 
  13498.  options, in a form suitable for use with Tk_ConfigureWidget. This table will 
  13499.  normally be used by typePtr->createProc and typePtr->configProc, but Tk also 
  13500.  uses it directly to retrieve option information in the itemcget and 
  13501.  itemconfigure widget commands. typePtr->configSpecs must point to the 
  13502.  configuration table for this type. Note: Tk provides a custom option type 
  13503.  tk_CanvasTagsOption for implementing the -tags option;  see an existing type 
  13504.  manager for an example of how to use it in configSpecs. 
  13505.  
  13506.  CONFIGPROC 
  13507.  
  13508.  typePtr->configProc is called by Tk whenever the itemconfigure widget command 
  13509.  is invoked to change the configuration options for a canvas item. This 
  13510.  procedure must match the following prototype: 
  13511.  
  13512.   typedef int Tk_ItemConfigureProc(
  13513.          Tcl_Interp *interp,
  13514.          Tk_Canvas canvas,
  13515.          Tk_Item *itemPtr,
  13516.          int argc,
  13517.          char **argv,
  13518.          int flags);
  13519.  The interp argument identifies the interpreter in which the widget command was 
  13520.  invoked,  canvas is a handle for the canvas widget, and itemPtr is a pointer 
  13521.  to the item being configured. argc and argv contain the configuration options. 
  13522.  For example, if the following command is invoked: 
  13523.  
  13524.   .c itemconfigure 2 -fill red -outline black
  13525.  argc is 4 and argv contains the strings -fill through black. argc will always 
  13526.  be an even value. The  flags argument contains flags to pass to 
  13527.  Tk_ConfigureWidget; currently this value is always TK_CONFIG_ARGV_ONLY when Tk 
  13528.  invokes typePtr->configProc, but the type manager's createProc procedure will 
  13529.  usually invoke configProc with different flag values. 
  13530.  
  13531.  typePtr->configProc returns a standard Tcl completion code and leaves an error 
  13532.  message in interp->result if an error occurs. It must update the item's 
  13533.  bounding box to reflect the new configuration options. 
  13534.  
  13535.  COORDPROC 
  13536.  
  13537.  typePtr->coordProc is invoked by Tk to implement the coords widget command for 
  13538.  an item. It must match the following prototype: 
  13539.  
  13540.   typedef int Tk_ItemCoordProc(
  13541.          Tcl_Interp *interp,
  13542.          Tk_Canvas canvas,
  13543.          Tk_Item *itemPtr,
  13544.          int argc,
  13545.          char **argv);
  13546.  The arguments interp, canvas, and itemPtr all have the standard meanings, and 
  13547.  argc and argv describe the coordinate arguments. For example, if the following 
  13548.  widget command is invoked: 
  13549.  
  13550.   .c coords 2 30 90
  13551.  argc will be 2 and argv will contain the string values 30 and 90. 
  13552.  
  13553.  The coordProc procedure should process the new coordinates, update the item 
  13554.  appropriately (e.g., it must reset the bounding box in the item's header), and 
  13555.  return a standard Tcl completion code. If an error occurs, coordProc must 
  13556.  leave an error message in interp->result. 
  13557.  
  13558.  DELETEPROC 
  13559.  
  13560.  typePtr->deleteProc is invoked by Tk to delete an item and free any resources 
  13561.  allocated to it. It must match the following prototype: 
  13562.  
  13563.   typedef void Tk_ItemDeleteProc(
  13564.          Tk_Canvas canvas,
  13565.          Tk_Item *itemPtr,
  13566.          Display *display);
  13567.  The canvas and itemPtr arguments have the usual interpretations, and display 
  13568.  identifies the X display containing the canvas. deleteProc must free up any 
  13569.  resources allocated for the item, so that Tk can free the item record. 
  13570.  deleteProc should not actually free the item record;  this will be done by Tk 
  13571.  when deleteProc returns. 
  13572.  
  13573.  DISPLAYPROC AND ALWAYSREDRAW 
  13574.  
  13575.  typePtr->displayProc is invoked by Tk to redraw an item on the screen. It must 
  13576.  match the following prototype: 
  13577.  
  13578.   typedef void Tk_ItemDisplayProc(
  13579.          Tk_Canvas canvas,
  13580.          Tk_Item *itemPtr,
  13581.          Display *display,
  13582.          Drawable dst,
  13583.          int x,
  13584.          int y,
  13585.          int width,
  13586.          int height);
  13587.  The canvas and itemPtr arguments have the usual meaning. display identifies 
  13588.  the display containing the canvas, and dst specifies a drawable in which the 
  13589.  item should be rendered; typically this is an off-screen pixmap, which Tk will 
  13590.  copy into the canvas's window once all relevant items have been drawn. x, y, 
  13591.  width, and height specify a rectangular region in canvas coordinates, which is 
  13592.  the area to be redrawn; only information that overlaps this area needs to be 
  13593.  redrawn. Tk will not call displayProc unless the item's bounding box overlaps 
  13594.  the redraw area, but the type manager may wish to use the redraw area to 
  13595.  optimize the redisplay of the item. 
  13596.  
  13597.  Because of scrolling and the use of off-screen pixmaps for double-buffered 
  13598.  redisplay, the item's coordinates in dst will not necessarily be the same as 
  13599.  those in the canvas. displayProc should call Tk_CanvasDrawableCoords to 
  13600.  transform coordinates from those of the canvas to those of dst. 
  13601.  
  13602.  Normally an item's displayProc is only invoked if the item overlaps the area 
  13603.  being displayed. However, if typePtr->alwaysRedraw has a non-zero value, then 
  13604.  displayProc is invoked during every redisplay operation, even if the item 
  13605.  doesn't overlap the area of redisplay. alwaysRedraw should normally be set to 
  13606.  0;  it is only set to 1 in special cases such as window items that need to be 
  13607.  unmapped when they are off-screen. 
  13608.  
  13609.  POINTPROC 
  13610.  
  13611.  typePtr->pointProc is invoked by Tk to find out how close a given point is to 
  13612.  a canvas item. Tk uses this procedure for purposes such as locating the item 
  13613.  under the mouse or finding the closest item to a given point. The procedure 
  13614.  must match the following prototype: 
  13615.  
  13616.   typedef double Tk_ItemPointProc(
  13617.          Tk_Canvas canvas,
  13618.          Tk_Item *itemPtr,
  13619.          double *pointPtr);
  13620.  canvas and itemPtr have the usual meaning. pointPtr points to an array of two 
  13621.  numbers giving the x and y coordinates of a point. pointProc must return a 
  13622.  real value giving the distance from the point to the item, or 0 if the point 
  13623.  lies inside the item. 
  13624.  
  13625.  AREAPROC 
  13626.  
  13627.  typePtr->areaProc is invoked by Tk to find out the relationship between an 
  13628.  item and a rectangular area. It must match the following prototype: 
  13629.  
  13630.   typedef int Tk_ItemAreaProc(
  13631.          Tk_Canvas canvas,
  13632.          Tk_Item *itemPtr,
  13633.          double *rectPtr);
  13634.  canvas and itemPtr have the usual meaning. rectPtr points to an array of four 
  13635.  real numbers; the first two give the x and y coordinates of the upper left 
  13636.  corner of a rectangle, and the second two give the x and y coordinates of the 
  13637.  lower right corner. areaProc must return -1 if the item lies entirely outside 
  13638.  the given area, 0 if it lies partially inside and partially outside the area, 
  13639.  and 1 if it lies entirely inside the area. 
  13640.  
  13641.  POSTSCRIPTPROC 
  13642.  
  13643.  typePtr->postscriptProc is invoked by Tk to generate Postcript for an item 
  13644.  during the postscript widget command. If the type manager is not capable of 
  13645.  generating Postscript then typePtr->postscriptProc should be NULL. The 
  13646.  procedure must match the following prototype: 
  13647.  
  13648.   typedef int Tk_ItemPostscriptProc(
  13649.          Tcl_Interp *interp,
  13650.          Tk_Canvas canvas,
  13651.          Tk_Item *itemPtr,
  13652.          int prepass);
  13653.  The interp, canvas, and itemPtr arguments all have standard meanings;  prepass 
  13654.  will be described below. If postscriptProc completes successfully, it should 
  13655.  append Postscript for the item to the information in interp->result (e.g. by 
  13656.  calling Tcl_AppendResult, not Tcl_SetResult) and return TCL_OK. If an error 
  13657.  occurs, postscriptProc should clear the result and replace its contents with 
  13658.  an error message;  then it should return TCL_ERROR. 
  13659.  
  13660.  Tk provides a collection of utility procedures to simplify postscriptProc. For 
  13661.  example, Tk_CanvasPsColor will generate Postscript to set the current color to 
  13662.  a given Tk color and Tk_CanvasPsFont will set up font information. When 
  13663.  generating Postscript, the type manager is free to change the graphics state 
  13664.  of the Postscript interpreter, since Tk places gsave and grestore commands 
  13665.  around the Postscript for the item. The type manager can use canvas x 
  13666.  coordinates directly in its Postscript, but it must call Tk_CanvasPsY to 
  13667.  convert y coordinates from the space of the canvas (where the origin is at the 
  13668.  upper left) to the space of Postscript (where the origin is at the lower 
  13669.  left). 
  13670.  
  13671.  In order to generate Postscript that complies with the Adobe Document 
  13672.  Structuring Conventions, Tk actually generates Postscript in two passes. It 
  13673.  calls each item's postscriptProc in each pass. The only purpose of the first 
  13674.  pass is to collect font information (which is done by Tk_CanvPsFont);  the 
  13675.  actual Postscript is discarded. Tk sets the prepass argument to postscriptProc 
  13676.  to 1 during the first pass;  the type manager can use prepass to skip all 
  13677.  Postscript generation except for calls to Tk_CanvasPsFont. During the second 
  13678.  pass prepass will be 0, so the type manager must generate complete Postscript. 
  13679.  
  13680.  SCALEPROC 
  13681.  
  13682.  typePtr->scaleProc is invoked by Tk to rescale a canvas item during the scale 
  13683.  widget command. The procedure must match the following prototype: 
  13684.  
  13685.   typedef void Tk_ItemScaleProc(
  13686.          Tk_Canvas canvas,
  13687.          Tk_Item *itemPtr,
  13688.          double originX,
  13689.          double originY,
  13690.          double scaleX,
  13691.          double scaleY);
  13692.  The canvas and itemPtr arguments have the usual meaning. originX and originY 
  13693.  specify an origin relative to which the item is to be scaled, and scaleX and 
  13694.  scaleY give the x and y scale factors. The item should adjust its coordinates 
  13695.  so that a point in the item that used to have coordinates x and y will have 
  13696.  new coordinates x' and y', where 
  13697.  
  13698.   x' = originX  + scaleX*(x-originX)
  13699.   y' = originY + scaleY*(y-originY)
  13700.  scaleProc must also update the bounding box in the item's header. 
  13701.  
  13702.  TRANSLATEPROC 
  13703.  
  13704.  typePtr->translateProc is invoked by Tk to translate a canvas item during the 
  13705.  move widget command. The procedure must match the following prototype: 
  13706.  
  13707.   typedef void Tk_ItemTranslateProc(
  13708.          Tk_Canvas canvas,
  13709.          Tk_Item *itemPtr,
  13710.          double deltaX,
  13711.          double deltaY);
  13712.  The canvas and itemPtr arguments have the usual meaning, and deltaX and deltaY 
  13713.  give the amounts that should be added to each x and y coordinate within the 
  13714.  item. The type manager should adjust the item's coordinates and update the 
  13715.  bounding box in the item's header. 
  13716.  
  13717.  INDEXPROC 
  13718.  
  13719.  typePtr->indexProc is invoked by Tk to translate a string index specification 
  13720.  into a numerical index, for example during the index widget command. It is 
  13721.  only relevant for item types that support indexable text; typePtr->indexProc 
  13722.  may be specified as NULL for non-textual item types. The procedure must match 
  13723.  the following prototype: 
  13724.  
  13725.   typedef int Tk_ItemIndexProc(
  13726.          Tcl_Interp *interp,
  13727.          Tk_Canvas canvas,
  13728.          Tk_Item *itemPtr,
  13729.          char indexString,
  13730.          int *indexPtr);
  13731.  The interp, canvas, and itemPtr arguments all have the usual meaning. 
  13732.  indexString contains a textual description of an index, and indexPtr points to 
  13733.  an integer value that should be filled in with a numerical index. It is up to 
  13734.  the type manager to decide what forms of index are supported (e.g., numbers, 
  13735.  insert,  sel.first, end, etc.). indexProc should return a Tcl completion code 
  13736.  and set interp->result in the event of an error. 
  13737.  
  13738.  ICURSORPROC 
  13739.  
  13740.  typePtr->icursorProc is invoked by Tk during the icursor widget command to set 
  13741.  the position of the insertion cursor in a textual item. It is only relevant 
  13742.  for item types that support an insertion cursor; typePtr->icursorProc may be 
  13743.  specified as NULL for item types that don't support an insertion cursor. The 
  13744.  procedure must match the following prototype: 
  13745.  
  13746.   typedef void Tk_ItemIndexProc(
  13747.          Tk_Canvas canvas,
  13748.          Tk_Item *itemPtr,
  13749.          int index);
  13750.  canvas and itemPtr have the usual meanings, and index is an index into the 
  13751.  item's text, as returned by a previous call to typePtr->insertProc. The type 
  13752.  manager should position the insertion cursor in the item just before the 
  13753.  character given by index. Whether or not to actually display the insertion 
  13754.  cursor is determined by other information provided by Tk_CanvasGetTextInfo. 
  13755.  
  13756.  SELECTIONPROC 
  13757.  
  13758.  typePtr->selectionProc is invoked by Tk during selection retrievals;  it must 
  13759.  return part or all of the selected text in the item (if any). It is only 
  13760.  relevant for item types that support text; typePtr->selectionProc may be 
  13761.  specified as NULL for non-textual item types. The procedure must match the 
  13762.  following prototype: 
  13763.  
  13764.   typedef int Tk_ItemSelectionProc(
  13765.          Tk_Canvas canvas,
  13766.          Tk_Item *itemPtr,
  13767.          int offset,
  13768.          char *buffer,
  13769.          int maxBytes);
  13770.  canvas and itemPtr have the usual meanings. offset is an offset in bytes into 
  13771.  the selection where 0 refers to the first byte of the selection;  it 
  13772.  identifies the first character that is to be returned in this call. buffer 
  13773.  points to an area of memory in which to store the requested bytes, and 
  13774.  maxBytes specifies the maximum number of bytes to return. selectionProc should 
  13775.  extract up to maxBytes characters from the selection and copy them to 
  13776.  maxBytes;  it should return a count of the number of bytes actually copied, 
  13777.  which may be less than maxBytes if there aren't offset+maxBytes bytes in the 
  13778.  selection. 
  13779.  
  13780.  INSERTPROC 
  13781.  
  13782.  typePtr->insertProc is invoked by Tk during the insert widget command to 
  13783.  insert new text into a canvas item. It is only relevant for item types that 
  13784.  support text; typePtr->insertProc may be specified as NULL for non-textual 
  13785.  item types. The procedure must match the following prototype: 
  13786.  
  13787.   typedef void Tk_ItemInsertProc(
  13788.          Tk_Canvas canvas,
  13789.          Tk_Item *itemPtr,
  13790.          int index,
  13791.          char *string);
  13792.  canvas and itemPtr have the usual meanings. index is an index into the item's 
  13793.  text, as returned by a previous call to typePtr->insertProc, and string 
  13794.  contains new text to insert just before the character given by index. The type 
  13795.  manager should insert the text and recompute the bounding box in the item's 
  13796.  header. 
  13797.  
  13798.  DCHARSPROC 
  13799.  
  13800.  typePtr->dCharsProc is invoked by Tk during the dchars widget command to 
  13801.  delete a range of text from a canvas item. It is only relevant for item types 
  13802.  that support text; typePtr->dCharsProc may be specified as NULL for 
  13803.  non-textual item types. The procedure must match the following prototype: 
  13804.  
  13805.   typedef void Tk_ItemDCharsProc(
  13806.          Tk_Canvas canvas,
  13807.          Tk_Item *itemPtr,
  13808.          int first,
  13809.          int last);
  13810.  canvas and itemPtr have the usual meanings. first and last give the indices of 
  13811.  the first and last bytes to be deleted, as returned by previous calls to 
  13812.  typePtr->indexProc. The type manager should delete the specified characters 
  13813.  and update the bounding box in the item's header. 
  13814.  
  13815.  SEE ALSO 
  13816.  
  13817.  Tk_CanvasPsY, Tk_CanvasTextInfo, Tk_CanvasTkwin 
  13818.  
  13819.  KEYWORDS 
  13820.  
  13821.  canvas, focus, item type, selection, type manager 
  13822.  
  13823.  
  13824. ΓòÉΓòÉΓòÉ 5.15. Tk_CreatePhotoImageFormat ΓòÉΓòÉΓòÉ
  13825.  
  13826.  NAME 
  13827.  
  13828. Tk_CreatePhotoImageFormat - define new file format for photo images 
  13829.  
  13830. SYNOPSIS 
  13831.  
  13832. #include <tk.h> 
  13833.  #include <tkPhoto.h> 
  13834.  
  13835.  Tk_CreatePhotoImageFormat(formatPtr) 
  13836.  
  13837. ARGUMENTS 
  13838.  
  13839.  Tk_PhotoImageFormat  *formatPtr (in)  Structure that defines the new file 
  13840.            format. 
  13841.  
  13842.  DESCRIPTION 
  13843.  
  13844.  Tk_CreatePhotoImageFormat is invoked to define a new file format for image 
  13845.  data for use with photo images.  The code that implements an image file format 
  13846.  is called an image file format handler, or handler for short.  The photo image 
  13847.  code maintains a list of handlers that can be used to read and write data to 
  13848.  or from a file.  Some handlers may also support reading image data from a 
  13849.  string or converting image data to a string format. The user can specify which 
  13850.  handler to use with the -format image configuration option or the -format 
  13851.  option to the read and write photo image subcommands. 
  13852.  
  13853.  An image file format handler consists of a collection of procedures plus a 
  13854.  Tk_PhotoImageFormat structure, which contains the name of the image file 
  13855.  format and pointers to six procedures provided by the handler to deal with 
  13856.  files and strings in this format.  The Tk_PhotoImageFormat structure contains 
  13857.  the following fields: 
  13858.  
  13859.   typedef struct Tk_PhotoImageFormat {
  13860.          char *name;
  13861.          Tk_ImageFileMatchProc *fileMatchProc;
  13862.          Tk_ImageStringMatchProc *stringMatchProc;
  13863.          Tk_ImageFileReadProc *fileReadProc;
  13864.          Tk_ImageStringReadProc *stringReadProc;
  13865.          Tk_ImageFileWriteProc *fileWriteProc;
  13866.          Tk_ImageStringWriteProc *stringWriteProc;
  13867.   } Tk_PhotoImageFormat;
  13868.  
  13869.  The handler need not provide implementations of all six procedures. For 
  13870.  example, the procedures that handle string data would not be provided for a 
  13871.  format in which the image data are stored in binary, and could therefore 
  13872.  contain null characters.  If any procedure is not implemented, the 
  13873.  corresponding pointer in the Tk_PhotoImageFormat structure should be set to 
  13874.  NULL.  The handler must provide the fileMatchProc procedure if it provides the 
  13875.  fileReadProc procedure, and the stringMatchProc procedure if it provides the 
  13876.  stringReadProc procedure. 
  13877.  
  13878.  NAME 
  13879.  
  13880.  formatPtr->name provides a name for the image type. Once 
  13881.  Tk_CreatePhotoImageFormat returns, this name may be used in the -format photo 
  13882.  image configuration and subcommand option. The manual page for the photo image 
  13883.  (photo(n)) describes how image file formats are chosen based on their names 
  13884.  and the value given to the -format option. 
  13885.  
  13886.  FILEMATCHPROC 
  13887.  
  13888.  formatPtr->fileMatchProc provides the address of a procedure for Tk to call 
  13889.  when it is searching for an image file format handler suitable for reading 
  13890.  data in a given file. formatPtr->fileMatchProc must match the following 
  13891.  prototype: 
  13892.  
  13893.   typedef int Tk_ImageFileMatchProc(
  13894.          FILE *f,
  13895.          char *fileName,
  13896.          char *formatString,
  13897.          int *widthPtr,
  13898.          int *heightPtr);
  13899.  The fileName argument is the name of the file containing the image data, which 
  13900.  is open for reading as f.  The formatString argument contains the value given 
  13901.  for the -format option, or NULL if the option was not specified. If the data 
  13902.  in the file appears to be in the format supported by this handler, the 
  13903.  formatPtr->fileMatchProc procedure should store the width and height of the 
  13904.  image in *widthPtr and *heightPtr respectively, and return 1.  Otherwise it 
  13905.  should return 0. 
  13906.  
  13907.  STRINGMATCHPROC 
  13908.  
  13909.  formatPtr->stringMatchProc provides the address of a procedure for Tk to call 
  13910.  when it is searching for an image file format handler for suitable for reading 
  13911.  data from a given string. formatPtr->stringMatchProc must match the following 
  13912.  prototype: 
  13913.  
  13914.   typedef int Tk_ImageStringMatchProc(
  13915.          char *string,
  13916.          char *formatString,
  13917.          int *widthPtr,
  13918.          int *heightPtr);
  13919.  The string argument points to the string containing the image data.  The 
  13920.  formatString argument contains the value given for the -format option, or NULL 
  13921.  if the option was not specified. If the data in the string appears to be in 
  13922.  the format supported by this handler, the formatPtr->stringMatchProc procedure 
  13923.  should store the width and height of the image in *widthPtr and *heightPtr 
  13924.  respectively, and return 1.  Otherwise it should return 0. 
  13925.  
  13926.  FILEREADPROC 
  13927.  
  13928.  formatPtr->fileReadProc provides the address of a procedure for Tk to call to 
  13929.  read data from an image file into a photo image. formatPtr->fileReadProc must 
  13930.  match the following prototype: 
  13931.  
  13932.   typedef int Tk_ImageFileReadProc(
  13933.          Tcl_Interp *interp,
  13934.          FILE *f,
  13935.          char *fileName,
  13936.          char *formatString,
  13937.          PhotoHandle imageHandle,
  13938.          int destX, int destY,
  13939.          int width, int height,
  13940.          int srcX, int srcY);
  13941.  The interp argument is the interpreter in which the command was invoked to 
  13942.  read the image; it should be used for reporting errors. The image data is in 
  13943.  the file named fileName, which is open for reading as f.  The formatString 
  13944.  argument contains the value given for the -format option, or NULL if the 
  13945.  option was not specified.  The image data in the file, or a subimage of it, is 
  13946.  to be read into the photo image identified by the handle imageHandle.  The 
  13947.  subimage of the data in the file is of dimensions width x height and has its 
  13948.  top-left corner at coordinates (srcX,srcY).  It is to be stored in the photo 
  13949.  image with its top-left corner at coordinates (destX,destY) using the 
  13950.  Tk_PhotoPutBlock procedure. The return value is a standard Tcl return value. 
  13951.  
  13952.  STRINGREADPROC 
  13953.  
  13954.  formatPtr->stringReadProc provides the address of a procedure for Tk to call 
  13955.  to read data from a string into a photo image. formatPtr->stringReadProc must 
  13956.  match the following prototype: 
  13957.  
  13958.   typedef int Tk_ImageStringReadProc(
  13959.          Tcl_Interp *interp,
  13960.          char *string,
  13961.          char *formatString,
  13962.          PhotoHandle imageHandle,
  13963.          int destX, int destY,
  13964.          int width, int height,
  13965.          int srcX, int srcY);
  13966.  The interp argument is the interpreter in which the command was invoked to 
  13967.  read the image; it should be used for reporting errors. The string argument 
  13968.  points to the image data in string form. The formatString argument contains 
  13969.  the value given for the -format option, or NULL if the option was not 
  13970.  specified.  The image data in the string, or a subimage of it, is to be read 
  13971.  into the photo image identified by the handle imageHandle.  The subimage of 
  13972.  the data in the string is of dimensions width x height and has its top-left 
  13973.  corner at coordinates (srcX,srcY).  It is to be stored in the photo image with 
  13974.  its top-left corner at coordinates (destX,destY) using the Tk_PhotoPutBlock 
  13975.  procedure. The return value is a standard Tcl return value. 
  13976.  
  13977.  FILEWRITEPROC 
  13978.  
  13979.  formatPtr->fileWriteProc provides the address of a procedure for Tk to call to 
  13980.  write data from a photo image to a file. formatPtr->fileWriteProc must match 
  13981.  the following prototype: 
  13982.  
  13983.   typedef int Tk_ImageFileWriteProc(
  13984.          Tcl_Interp *interp,
  13985.          char *fileName,
  13986.          char *formatString,
  13987.          Tk_PhotoImageBlock *blockPtr);
  13988.  The interp argument is the interpreter in which the command was invoked to 
  13989.  write the image; it should be used for reporting errors. The image data to be 
  13990.  written are in memory and are described by the Tk_PhotoImageBlock structure 
  13991.  pointed to by blockPtr; see the manual page FindPhoto(3) for details.  The 
  13992.  fileName argument points to the string giving the name of the file in which to 
  13993.  write the image data.  The formatString argument contains the value given for 
  13994.  the -format option, or NULL if the option was not specified.  The format 
  13995.  string can contain extra characters after the name of the format.  If 
  13996.  appropriate, the formatPtr->fileWriteProc procedure may interpret these 
  13997.  characters to specify further details about the image file. The return value 
  13998.  is a standard Tcl return value. 
  13999.  
  14000.  STRINGWRITEPROC 
  14001.  
  14002.  formatPtr->stringWriteProc provides the address of a procedure for Tk to call 
  14003.  to translate image data from a photo image into a string. 
  14004.  formatPtr->stringWriteProc must match the following prototype: 
  14005.  
  14006.   typedef int Tk_ImageStringWriteProc(
  14007.          Tcl_Interp *interp,
  14008.          Tcl_DString *dataPtr,
  14009.          char *formatString,
  14010.          Tk_PhotoImageBlock *blockPtr);
  14011.  The interp argument is the interpreter in which the command was invoked to 
  14012.  convert the image; it should be used for reporting errors. The image data to 
  14013.  be converted are in memory and are described by the Tk_PhotoImageBlock 
  14014.  structure pointed to by blockPtr; see the manual page FindPhoto(3) for 
  14015.  details.  The data for the string should be appended to the dynamic string 
  14016.  given by dataPtr. The formatString argument contains the value given for the 
  14017.  -format option, or NULL if the option was not specified.  The format string 
  14018.  can contain extra characters after the name of the format.  If appropriate, 
  14019.  the formatPtr->stringWriteProc procedure may interpret these characters to 
  14020.  specify further details about the image file. The return value is a standard 
  14021.  Tcl return value. 
  14022.  
  14023.  SEE ALSO 
  14024.  
  14025.  Tk_FindPhoto, Tk_PhotoPutBlock 
  14026.  
  14027.  KEYWORDS 
  14028.  
  14029.  photo image, image file 
  14030.  
  14031.  
  14032. ΓòÉΓòÉΓòÉ 5.16. Tk_CreateSelHandler ΓòÉΓòÉΓòÉ
  14033.  
  14034.  NAME 
  14035.  
  14036. Tk_CreateSelHandler, Tk_DeleteSelHandler - arrange to handle requests for a 
  14037. selection 
  14038.  
  14039. SYNOPSIS 
  14040.  
  14041. #include <tk.h> 
  14042.  
  14043.  Tk_CreateSelHandler(tkwin, selection, target, proc, clientData, format) 
  14044.  
  14045.  Tk_DeleteSelHandler(tkwin, selection, target) 
  14046.  
  14047. ARGUMENTS 
  14048.  
  14049.  Tk_Window  tkwin (in)  Window for which proc will provide selection 
  14050.            information. 
  14051.  
  14052.  Atom  selection (in)  The name of the selection for which proc will provide 
  14053.            selection information. 
  14054.  
  14055.  Atom  target (in)  Form in which proc can provide the selection (e.g. STRING 
  14056.            or FILE_NAME).  Corresponds to type arguments in selection commands. 
  14057.  
  14058.  Tk_SelectionProc  *proc (in)  Procedure to invoke whenever the selection is 
  14059.            owned by tkwin and the selection contents are requested in the 
  14060.            format given by target. 
  14061.  
  14062.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  14063.  
  14064.  Atom  format (in)  If the selection requestor isn't in this process, format 
  14065.            determines the representation used to transmit the selection to its 
  14066.            requestor. 
  14067.  
  14068.  DESCRIPTION 
  14069.  
  14070.  Tk_CreateSelHandler arranges for a particular procedure (proc) to be called 
  14071.  whenever selection is owned by tkwin and the selection contents are requested 
  14072.  in the form given by target. Target should be one of the entries defined in 
  14073.  the left column of Table 2 of the X Inter-Client Communication Conventions 
  14074.  Manual (ICCCM) or any other form in which an application is willing to present 
  14075.  the selection.  The most common form is STRING. 
  14076.  
  14077.  Proc should have arguments and result that match the type Tk_SelectionProc: 
  14078.  
  14079.   typedef int Tk_SelectionProc(
  14080.          ClientData clientData,
  14081.          int offset,
  14082.          char *buffer,
  14083.          int maxBytes);
  14084.  The clientData parameter to proc is a copy of the clientData argument given to 
  14085.  Tk_CreateSelHandler. Typically, clientData points to a data structure 
  14086.  containing application-specific information that is needed to retrieve the 
  14087.  selection.  Offset specifies an offset position into the selection, buffer 
  14088.  specifies a location at which to copy information about the selection, and 
  14089.  maxBytes specifies the amount of space available at buffer.  Proc should place 
  14090.  a NULL-terminated string at buffer containing maxBytes or fewer characters 
  14091.  (not including the terminating NULL), and it should return a count of the 
  14092.  number of non-NULL characters stored at buffer.  If the selection no longer 
  14093.  exists (e.g. it once existed but the user deleted the range of characters 
  14094.  containing it), then proc should return -1. 
  14095.  
  14096.  When transferring large selections, Tk will break them up into smaller pieces 
  14097.  (typically a few thousand bytes each) for more efficient transmission.  It 
  14098.  will do this by calling proc one or more times, using successively higher 
  14099.  values of offset to retrieve successive portions of the selection.  If proc 
  14100.  returns a count less than maxBytes it means that the entire remainder of the 
  14101.  selection has been returned.  If proc's return value is maxBytes it means 
  14102.  there may be additional information in the selection, so Tk must make another 
  14103.  call to proc to retrieve the next portion. 
  14104.  
  14105.  Proc always returns selection information in the form of a character string. 
  14106.  However, the ICCCM allows for information to be transmitted from the selection 
  14107.  owner to the selection requestor in any of several formats, such as a string, 
  14108.  an array of atoms, an array of integers, etc.  The format argument to 
  14109.  Tk_CreateSelHandler indicates what format should be used to transmit the 
  14110.  selection to its requestor (see the middle column of Table 2 of the ICCCM for 
  14111.  examples).  If format is not STRING, then Tk will take the value returned by 
  14112.  proc and divided it into fields separated by white space.  If format is ATOM, 
  14113.  then Tk will return the selection as an array of atoms, with each field in 
  14114.  proc's result treated as the name of one atom.  For any other value of format, 
  14115.  Tk will return the selection as an array of 32-bit values where each field of 
  14116.  proc's result is treated as a number and translated to a 32-bit value.  In any 
  14117.  event, the format atom is returned to the selection requestor along with the 
  14118.  contents of the selection. 
  14119.  
  14120.  If Tk_CreateSelHandler is called when there already exists a handler for 
  14121.  selection and target on tkwin, then the existing handler is replaced with a 
  14122.  new one. 
  14123.  
  14124.  Tk_DeleteSelHandler removes the handler given by tkwin, selection, and target, 
  14125.  if such a handler exists. If there is no such handler then it has no effect. 
  14126.  
  14127.  KEYWORDS 
  14128.  
  14129.  format, handler, selection, target 
  14130.  
  14131.  
  14132. ΓòÉΓòÉΓòÉ 5.17. Tk_DeleteImage ΓòÉΓòÉΓòÉ
  14133.  
  14134.  NAME 
  14135.  
  14136. Tk_DeleteImage - Destroy an image. 
  14137.  
  14138. SYNOPSIS 
  14139.  
  14140. #include <tk.h> 
  14141.  
  14142.  Tk_DeleteImage(interp, name) 
  14143.  
  14144. ARGUMENTS 
  14145.  
  14146.  Tcl_Interp  *interp (in)  Interpreter for which the image was created. 
  14147.  
  14148.  char  *name (in)  Name of the image. 
  14149.  
  14150.  DESCRIPTION 
  14151.  
  14152.  Tk_DeleteImage deletes the image given by interp and name, if there is one. 
  14153.  All instances of that image will redisplay as empty regions.  If the given 
  14154.  image does not exist then the procedure has no effect. 
  14155.  
  14156.  KEYWORDS 
  14157.  
  14158.  delete image, image manager 
  14159.  
  14160.  
  14161. ΓòÉΓòÉΓòÉ 5.18. Tk_DrawFocusHighlight ΓòÉΓòÉΓòÉ
  14162.  
  14163.  NAME 
  14164.  
  14165. Tk_DrawFocusHighlight - draw the traversal highlight ring for a widget 
  14166.  
  14167. SYNOPSIS 
  14168.  
  14169. #include <tk.h> 
  14170.  
  14171.  Tk_GetPixels(tkwin, gc, width, drawable) 
  14172.  
  14173. ARGUMENTS 
  14174.  
  14175.  Tk_Window  tkwin (in)  Window for which the highlight is being drawn.  Used to 
  14176.            retrieve the window's dimensions, among other things. 
  14177.  
  14178.  GC  gc (in)  Graphics context to use for drawing the highlight. 
  14179.  
  14180.  int  width (in)  Width of the highlight ring, in pixels. 
  14181.  
  14182.  Drawable  drawable (in)  Drawable in which to draw the highlight;  usually an 
  14183.            offscreen pixmap for double buffering. 
  14184.  
  14185.  DESCRIPTION 
  14186.  
  14187.  Tk_DrawFocusHighlight is a utility procedure that draws the traversal 
  14188.  highlight ring for a widget. It is typically invoked by widgets during 
  14189.  redisplay. 
  14190.  
  14191.  KEYWORDS 
  14192.  
  14193.  focus, traversal highlight 
  14194.  
  14195.  
  14196. ΓòÉΓòÉΓòÉ 5.19. Tk_CreateEventHandler ΓòÉΓòÉΓòÉ
  14197.  
  14198.  NAME 
  14199.  
  14200. Tk_CreateEventHandler, Tk_DeleteEventHandler - associate procedure callback 
  14201. with an X event 
  14202.  
  14203. SYNOPSIS 
  14204.  
  14205. #include <tk.h> 
  14206.  
  14207.  Tk_CreateEventHandler(tkwin, mask, proc, clientData) 
  14208.  
  14209.  Tk_DeleteEventHandler(tkwin, mask, proc, clientData) 
  14210.  
  14211. ARGUMENTS 
  14212.  
  14213.  Tk_Window  tkwin (in)  Token for window in which events may occur. 
  14214.  
  14215.  unsigned long  mask (in)  Bit-mask of events (such as ButtonPressMask) for 
  14216.            which proc should be called. 
  14217.  
  14218.  Tk_EventProc  *proc (in)  Procedure to invoke whenever an event in mask occurs 
  14219.            in the window given by tkwin. 
  14220.  
  14221.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  14222.  
  14223.  DESCRIPTION 
  14224.  
  14225.  Tk_CreateEventHandler arranges for proc to be invoked in the future whenever 
  14226.  one of the event types specified by mask occurs in the window specified by 
  14227.  tkwin. The callback to proc will be made by Tk_HandleEvent; this mechanism 
  14228.  only works in programs that dispatch events through Tk_HandleEvent (or through 
  14229.  other Tk procedures that call Tk_HandleEvent, such as Tk_DoOneEvent or 
  14230.  Tk_MainLoop). 
  14231.  
  14232.  Proc should have arguments and result that match the type Tk_EventProc: 
  14233.  
  14234.   typedef void Tk_EventProc(
  14235.          ClientData clientData,
  14236.          XEvent *eventPtr);
  14237.  The clientData parameter to proc is a copy of the clientData argument given to 
  14238.  Tk_CreateEventHandler when the callback was created.  Typically, clientData 
  14239.  points to a data structure containing application-specific information about 
  14240.  the window in which the event occurred.  EventPtr is a pointer to the X event, 
  14241.  which will be one of the ones specified in the mask argument to 
  14242.  Tk_CreateEventHandler. 
  14243.  
  14244.  Tk_DeleteEventHandler may be called to delete a previously-created event 
  14245.  handler:  it deletes the first handler it finds that is associated with tkwin 
  14246.  and matches the mask, proc, and clientData arguments.  If no such handler 
  14247.  exists, then Tk_EventHandler returns without doing anything.  Although Tk 
  14248.  supports it, it's probably a bad idea to have more than one callback with the 
  14249.  same mask, proc, and clientData arguments. When a window is deleted all of its 
  14250.  handlers will be deleted automatically;  in this case there is no need to call 
  14251.  Tk_DeleteEventHandler. 
  14252.  
  14253.  If multiple handlers are declared for the same type of X event on the same 
  14254.  window, then the handlers will be invoked in the order they were created. 
  14255.  
  14256.  KEYWORDS 
  14257.  
  14258.  bind, callback, event, handler 
  14259.  
  14260.  
  14261. ΓòÉΓòÉΓòÉ 5.20. Tk_FindPhoto ΓòÉΓòÉΓòÉ
  14262.  
  14263.  NAME 
  14264.  
  14265. Tk_FindPhoto, Tk_PhotoPutBlock, Tk_PhotoPutZoomedBlock, Tk_PhotoGetImage, 
  14266. Tk_PhotoBlank, Tk_PhotoExpand, Tk_PhotoGetSize, Tk_PhotoSetSize - manipulate 
  14267. the image data stored in a photo image. 
  14268.  
  14269. SYNOPSIS 
  14270.  
  14271. #include <tk.h> 
  14272.  #include <tkPhoto.h> 
  14273.  
  14274.  Tk_PhotoHandle 
  14275.  Tk_FindPhoto(imageName) 
  14276.  
  14277.  void 
  14278.  Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height) 
  14279.  
  14280.  void 
  14281.  Tk_PhotoPutZoomedBlock(handle, blockPtr, x, y, width, height, 
  14282.  zoomX, zoomY, subsampleX, subsampleY) 
  14283.  
  14284.  int 
  14285.  Tk_PhotoGetImage(handle, blockPtr) 
  14286.  
  14287.  void 
  14288.  Tk_PhotoBlank(handle) 
  14289.  
  14290.  void 
  14291.  Tk_PhotoExpand(handle, width, height) 
  14292.  
  14293.  void 
  14294.  Tk_PhotoGetSize(handle, widthPtr, heightPtr) 
  14295.  
  14296.  void 
  14297.  Tk_PhotoSetSize(handle, width, height) 
  14298.  
  14299. ARGUMENTS 
  14300.  
  14301.  char  *imageName (in)  Name of the photo image. 
  14302.  
  14303.  Tk_PhotoHandle  handle (in)  Opaque handle identifying the photo image to be 
  14304.            affected. 
  14305.  
  14306.  Tk_PhotoImageBlock  *blockPtr (in)  Specifies the address and storage layout 
  14307.            of image data. 
  14308.  
  14309.  int  x (in)  Specifies the X coordinate where the top-left corner of the block 
  14310.            is to be placed within the image. 
  14311.  
  14312.  int  y (in)  Specifies the Y coordinate where the top-left corner of the block 
  14313.            is to be placed within the image. 
  14314.  
  14315.  int  width (in)  Specifies the width of the image area to be affected (for 
  14316.            Tk_PhotoPutBlock) or the desired image width (for Tk_PhotoExpand and 
  14317.            Tk_PhotoSetSize). 
  14318.  
  14319.  int  height (in)  Specifies the height of the image area to be affected (for 
  14320.            Tk_PhotoPutBlock) or the desired image height (for Tk_PhotoExpand 
  14321.            and Tk_PhotoSetSize). 
  14322.  
  14323.  int  *widthPtr (out)  Pointer to location in which to store the image width. 
  14324.  
  14325.  int  *heightPtr (out)  Pointer to location in which to store the image height. 
  14326.  
  14327.  int  subsampleX (in)  Specifies the subsampling factor in the X direction for 
  14328.            input image data. 
  14329.  
  14330.  int  subsampleY (in)  Specifies the subsampling factor in the Y direction for 
  14331.            input image data. 
  14332.  
  14333.  int  zoomX (in)  Specifies the zoom factor to be applied in the X direction to 
  14334.            pixels being written to the photo image. 
  14335.  
  14336.  int  zoomY (in)  Specifies the zoom factor to be applied in the Y direction to 
  14337.            pixels being written to the photo image. 
  14338.  
  14339.  DESCRIPTION 
  14340.  
  14341.  Tk_FindPhoto returns an opaque handle that is used to identify a particular 
  14342.  photo image to the other procedures.  The parameter is the name of the image, 
  14343.  that is, the name specified to the image create photo command, or assigned by 
  14344.  that command if no name was specified. 
  14345.  
  14346.  Tk_PhotoPutBlock is used to supply blocks of image data to be displayed.  The 
  14347.  call affects an area of the image of size width x height pixels, with its 
  14348.  top-left corner at coordinates (x,y).  All of width, height, x, and y must be 
  14349.  non-negative. If part of this area lies outside the current bounds of the 
  14350.  image, the image will be expanded to include the area, unless the user has 
  14351.  specified an explicit image size with the -width and/or -height widget 
  14352.  configuration options (see photo(n)); in that case the area is silently 
  14353.  clipped to the image boundaries. 
  14354.  
  14355.  The block parameter is a pointer to a Tk_PhotoImageBlock structure, defined as 
  14356.  follows: 
  14357.  
  14358.   typedef struct {
  14359.          unsigned char *pixelPtr;
  14360.          int width;
  14361.          int height;
  14362.          int pitch;
  14363.          int pixelSize;
  14364.          int offset[3];
  14365.   } Tk_PhotoImageBlock;
  14366.  The pixelPtr field points to the first pixel, that is, the top-left pixel in 
  14367.  the block. The width and height fields specify the dimensions of the block of 
  14368.  pixels.  The pixelSize field specifies the address difference between two 
  14369.  horizontally adjacent pixels.  Often it is 3 or 4, but it can have any value. 
  14370.  The pitch field specifies the address difference between two vertically 
  14371.  adjacent pixels.  The offset array contains the offsets from the address of a 
  14372.  pixel to the addresses of the bytes containing the red, green and blue 
  14373.  components.  These are normally 0, 1 and 2, but can have other values, e.g., 
  14374.  for images that are stored as separate red, green and blue planes. 
  14375.  
  14376.  The value given for the width and height parameters to Tk_PhotoPutBlock do not 
  14377.  have to correspond to the values specified in block.  If they are smaller, 
  14378.  Tk_PhotoPutBlock extracts a sub-block from the image data supplied.  If they 
  14379.  are larger, the data given are replicated (in a tiled fashion) to fill the 
  14380.  specified area. These rules operate independently in the horizontal and 
  14381.  vertical directions. 
  14382.  
  14383.  Tk_PhotoPutZoomedBlock works like Tk_PhotoPutBlock except that the image can 
  14384.  be reduced or enlarged for display.  The subsampleX and subsampleY parameters 
  14385.  allow the size of the image to be reduced by subsampling. 
  14386.  Tk_PhotoPutZoomedBlock will use only pixels from the input image whose X 
  14387.  coordinates are multiples of subsampleX, and whose Y coordinates are multiples 
  14388.  of subsampleY.  For example, an image of 512x512 pixels can be reduced to 
  14389.  256x256 by setting subsampleX and subsampleY to 2. 
  14390.  
  14391.  The zoomX and zoomY parameters allow the image to be enlarged by pixel 
  14392.  replication.  Each pixel of the (possibly subsampled) input image will be 
  14393.  written to a block zoomX pixels wide and zoomY pixels high of the displayed 
  14394.  image.  Subsampling and zooming can be used together for special effects. 
  14395.  
  14396.  Tk_PhotoGetImage can be used to retrieve image data from a photo image. 
  14397.  Tk_PhotoGetImage fills in the structure pointed to by the blockPtr parameter 
  14398.  with values that describe the address and layout of the image data that the 
  14399.  photo image has stored internally.  The values are valid until the image is 
  14400.  destroyed or its size is changed. Tk_PhotoGetImage returns 1 for compatibility 
  14401.  with the corresponding procedure in the old photo widget. 
  14402.  
  14403.  Tk_PhotoBlank blanks the entire area of the photo image.  Blank areas of a 
  14404.  photo image are transparent. 
  14405.  
  14406.  Tk_PhotoExpand requests that the widget's image be expanded to be at least 
  14407.  width x height pixels in size.  The width and/or height are unchanged if the 
  14408.  user has specified an explicit image width or height with the -width and/or 
  14409.  -height configuration options, respectively. If the image data are being 
  14410.  supplied in many small blocks, it is more efficient to use Tk_PhotoExpand or 
  14411.  Tk_PhotoSetSize at the beginning rather than allowing the image to expand in 
  14412.  many small increments as image blocks are supplied. 
  14413.  
  14414.  Tk_PhotoSetSize specifies the size of the image, as if the user had specified 
  14415.  the given width and height values to the -width and -height configuration 
  14416.  options.  A value of zero for width or height does not change the image's 
  14417.  width or height, but allows the width or height to be changed by subsequent 
  14418.  calls to Tk_PhotoPutBlock, Tk_PhotoPutZoomedBlock or Tk_PhotoExpand. 
  14419.  
  14420.  Tk_PhotoGetSize returns the dimensions of the image in *widthPtr and 
  14421.  *heightPtr. 
  14422.  
  14423.  CREDITS 
  14424.  
  14425.  The code for the photo image type was developed by Paul Mackerras, based on 
  14426.  his earlier photo widget code. 
  14427.  
  14428.  KEYWORDS 
  14429.  
  14430.  photo, image 
  14431.  
  14432.  
  14433. ΓòÉΓòÉΓòÉ 5.21. Tk_FreeXId ΓòÉΓòÉΓòÉ
  14434.  
  14435.  NAME 
  14436.  
  14437. Tk_FreeXId - make X resource identifier available for reuse 
  14438.  
  14439. SYNOPSIS 
  14440.  
  14441. #include <tk.h> 
  14442.  
  14443.  Tk_FreeXId(display, id) 
  14444.  
  14445. ARGUMENTS 
  14446.  
  14447.  Display  *display (in)  Display for which id was allocated. 
  14448.  
  14449.  XID  id (in)  Identifier of X resource (window, font, pixmap, cursor, graphics 
  14450.            context, or colormap) that is no longer in use. 
  14451.  
  14452.  DESCRIPTION 
  14453.  
  14454.  The default allocator for resource identifiers provided by Xlib is very 
  14455.  simple-minded and does not allow resource identifiers to be re-used. If a 
  14456.  long-running application reaches the end of the resource id space, it will 
  14457.  generate an X protocol error and crash. Tk replaces the default id allocator 
  14458.  with its own allocator, which allows identifiers to be reused. In order for 
  14459.  this to work, Tk_FreeXId must be called to tell the allocator about resources 
  14460.  that have been freed. Tk automatically calls Tk_FreeXId whenever it frees a 
  14461.  resource, so if you use procedures like Tk_GetFontStruct, Tk_GetGC, and 
  14462.  Tk_GetPixmap then you need not call Tk_FreeXId. However, if you allocate 
  14463.  resources directly from Xlib, for example by calling XCreatePixmap, then you 
  14464.  should call Tk_FreeXId when you call the corresponding Xlib free procedure, 
  14465.  such as XFreePixmap. If you don't call Tk_FreeXId then the resource identifier 
  14466.  will be lost, which could cause problems if the application runs long enough 
  14467.  to lose all of the available identifiers. 
  14468.  
  14469.  KEYWORDS 
  14470.  
  14471.  resource identifier 
  14472.  
  14473.  
  14474. ΓòÉΓòÉΓòÉ 5.22. Tk_GeometryRequest ΓòÉΓòÉΓòÉ
  14475.  
  14476.  NAME 
  14477.  
  14478. Tk_GeometryRequest, Tk_SetInternalBorder - specify desired geometry or internal 
  14479. border for a window 
  14480.  
  14481. SYNOPSIS 
  14482.  
  14483. #include <tk.h> 
  14484.  
  14485.  Tk_GeometryRequest(tkwin, reqWidth, reqHeight) 
  14486.  
  14487.  Tk_SetInternalBorder(tkwin, width) 
  14488.  
  14489. ARGUMENTS 
  14490.  
  14491.  Tk_Window  tkwin (in)  Window for which geometry is being requested. 
  14492.  
  14493.  int  reqWidth (in)  Desired width for tkwin, in pixel units. 
  14494.  
  14495.  int  reqHeight (in)  Desired height for tkwin, in pixel units. 
  14496.  
  14497.  int  width (in)  Space to leave for internal border for tkwin, in pixel units. 
  14498.  
  14499.  DESCRIPTION 
  14500.  
  14501.  Tk_GeometryRequest is called by widget code to indicate its preference for the 
  14502.  dimensions of a particular window.  The arguments to Tk_GeometryRequest are 
  14503.  made available to the geometry manager for the window, which then decides on 
  14504.  the actual geometry for the window.  Although geometry managers generally try 
  14505.  to satisfy requests made to Tk_GeometryRequest, there is no guarantee that 
  14506.  this will always be possible.  Widget code should not assume that a geometry 
  14507.  request will be satisfied until it receives a ConfigureNotify event indicating 
  14508.  that the geometry change has occurred.  Widget code should never call 
  14509.  procedures like Tk_ResizeWindow directly.  Instead, it should invoke 
  14510.  Tk_GeometryRequest and leave the final geometry decisions to the geometry 
  14511.  manager. 
  14512.  
  14513.  If tkwin is a top-level window, then the geometry information will be passed 
  14514.  to the window manager using the standard ICCCM protocol. 
  14515.  
  14516.  Tk_SetInternalBorder is called by widget code to indicate that the widget has 
  14517.  an internal border.  This means that the widget draws a decorative border 
  14518.  inside the window instead of using the standard X borders, which are external 
  14519.  to the window's area.  For example, internal borders are used to draw 3-D 
  14520.  effects.  Width specifies the width of the border in pixels.  Geometry 
  14521.  managers will use this information to avoid placing any children of tkwin 
  14522.  overlapping the outermost width pixels of tkwin's area. 
  14523.  
  14524.  The information specified in calls to Tk_GeometryRequest and 
  14525.  Tk_SetInternalBorder can be retrieved using the macros Tk_ReqWidth, 
  14526.  Tk_ReqHeight, and Tk_InternalBorderWidth. See the Tk_WindowId manual entry for 
  14527.  details. 
  14528.  
  14529.  KEYWORDS 
  14530.  
  14531.  geometry, request 
  14532.  
  14533.  
  14534. ΓòÉΓòÉΓòÉ 5.23. Tk_GetAnchor ΓòÉΓòÉΓòÉ
  14535.  
  14536.  NAME 
  14537.  
  14538. Tk_GetAnchor, Tk_NameOfAnchor - translate between strings and anchor positions 
  14539.  
  14540. SYNOPSIS 
  14541.  
  14542. #include <tk.h> 
  14543.  
  14544.  int 
  14545.  Tk_GetAnchor(interp, string, anchorPtr) 
  14546.  
  14547.  char * 
  14548.  Tk_NameOfAnchor(anchor) 
  14549.  
  14550. ARGUMENTS 
  14551.  
  14552.  Tcl_Interp  *interp (in)  Interpreter to use for error reporting. 
  14553.  
  14554.  char  *string (in)  String containing name of anchor point: one of "n", "ne", 
  14555.            "e", "se", "s", "sw", "w", "nw", or "center". 
  14556.  
  14557.  int  *anchorPtr (out)  Pointer to location in which to store anchor position 
  14558.            corresponding to string. 
  14559.  
  14560.  Tk_Anchor  anchor (in)  Anchor position, e.g. TCL_ANCHOR_CENTER. 
  14561.  
  14562.  DESCRIPTION 
  14563.  
  14564.  Tk_GetAnchor places in *anchorPtr an anchor position (enumerated type 
  14565.  Tk_Anchor) corresponding to string,  which will be one of TK_ANCHOR_N, 
  14566.  TK_ANCHOR_NE, TK_ANCHOR_E, TK_ANCHOR_SE, TK_ANCHOR_S, TK_ANCHOR_SW, 
  14567.  TK_ANCHOR_W, TK_ANCHOR_NW, or TK_ANCHOR_CENTER. Anchor positions are typically 
  14568.  used for indicating a point on an object that will be used to position that 
  14569.  object, e.g. TK_ANCHOR_N means position the top center point of the object at 
  14570.  a particular place. 
  14571.  
  14572.  Under normal circumstances the return value is TCL_OK and interp is unused. If 
  14573.  string doesn't contain a valid anchor position or an abbreviation of one of 
  14574.  these names, then an error message is stored in interp->result, TCL_ERROR is 
  14575.  returned, and *anchorPtr is unmodified. 
  14576.  
  14577.  Tk_NameOfAnchor is the logical inverse of Tk_GetAnchor. Given an anchor 
  14578.  position such as TK_ANCHOR_N it returns a statically-allocated string 
  14579.  corresponding to anchor. If anchor isn't a legal anchor value, then "unknown 
  14580.  anchor position" is returned. 
  14581.  
  14582.  KEYWORDS 
  14583.  
  14584.  anchor position 
  14585.  
  14586.  
  14587. ΓòÉΓòÉΓòÉ 5.24. Tk_GetBitmap ΓòÉΓòÉΓòÉ
  14588.  
  14589.  NAME 
  14590.  
  14591. Tk_GetBitmap, Tk_DefineBitmap, Tk_NameOfBitmap, Tk_SizeOfBitmap, Tk_FreeBitmap, 
  14592. Tk_GetBitmapFromData - maintain database of single-plane pixmaps 
  14593.  
  14594. SYNOPSIS 
  14595.  
  14596. #include <tk.h> 
  14597.  
  14598.  Pixmap 
  14599.  Tk_GetBitmap(interp, tkwin, id) 
  14600.  
  14601.  int 
  14602.  Tk_DefineBitmap(interp, nameId, source, width, height) 
  14603.  
  14604.  Tk_Uid 
  14605.  Tk_NameOfBitmap(display, bitmap) 
  14606.  
  14607.  Tk_SizeOfBitmap(display, bitmap, widthPtr, heightPtr) 
  14608.  
  14609.  Tk_FreeBitmap(display, bitmap) 
  14610.  
  14611. ARGUMENTS 
  14612.  
  14613.  Tcl_Interp  *interp (in)  Interpreter to use for error reporting. 
  14614.  
  14615.  Tk_Window  tkwin (in)  Token for window in which the bitmap will be used. 
  14616.  
  14617.  Tk_Uid  id (in)  Description of bitmap;  see below for possible values. 
  14618.  
  14619.  Tk_Uid  nameId (in)  Name for new bitmap to be defined. 
  14620.  
  14621.  char  *source (in)  Data for bitmap, in standard bitmap format. Must be stored 
  14622.            in static memory whose value will never change. 
  14623.  
  14624.  int  width (in)  Width of bitmap. 
  14625.  
  14626.  int  height (in)  Height of bitmap. 
  14627.  
  14628.  int  *widthPtr (out)  Pointer to word to fill in with bitmap's width. 
  14629.  
  14630.  int  *heightPtr (out)  Pointer to word to fill in with bitmap's height. 
  14631.  
  14632.  Display  *display (in)  Display for which bitmap was allocated. 
  14633.  
  14634.  Pixmap  bitmap (in)  Identifier for a bitmap allocated by Tk_GetBitmap. 
  14635.  
  14636.  DESCRIPTION 
  14637.  
  14638.  These procedures manage a collection of bitmaps (one-plane pixmaps) being used 
  14639.  by an application.  The procedures allow bitmaps to be re-used efficiently, 
  14640.  thereby avoiding server overhead, and also allow bitmaps to be named with 
  14641.  character strings. 
  14642.  
  14643.  Tk_GetBitmap takes as argument a Tk_Uid describing a bitmap. It returns a 
  14644.  Pixmap identifier for a bitmap corresponding to the description.  It re-uses 
  14645.  an existing bitmap, if possible, and creates a new one otherwise.  At present, 
  14646.  id must have one of the following forms: 
  14647.  
  14648.  @fileName  FileName must be the name of a file containing a bitmap description 
  14649.            in the standard X11 or X10 format. 
  14650.  
  14651.  name      Name must be the name of a bitmap defined previously with a call to 
  14652.            Tk_DefineBitmap.  The following names are pre-defined by Tk: 
  14653.  
  14654.            error          The international "don't" symbol:  a circle with a 
  14655.                           diagonal line across it. 
  14656.  
  14657.            gray50         50% gray: a checkerboard pattern where every other 
  14658.                           bit is on. 
  14659.  
  14660.            gray12         12.5% gray: a pattern where one-eighth of the bits 
  14661.                           are on, consisting of every fourth pixel in every 
  14662.                           other row. 
  14663.  
  14664.            hourglass      An hourglass symbol. 
  14665.  
  14666.            info           A large letter "i". 
  14667.  
  14668.            questhead      The silhouette of a human head, with a question mark 
  14669.                           in it. 
  14670.  
  14671.            question       A large question-mark. 
  14672.  
  14673.            warning        A large exclamation point. 
  14674.  
  14675.  Under normal conditions, Tk_GetBitmap returns an identifier for the requested 
  14676.  bitmap.  If an error occurs in creating the bitmap, such as when id refers to 
  14677.  a non-existent file, then None is returned and an error message is left in 
  14678.  interp->result. 
  14679.  
  14680.  Tk_DefineBitmap associates a name with in-memory bitmap data so that the name 
  14681.  can be used in later calls to Tk_GetBitmap.  The nameId argument gives a name 
  14682.  for the bitmap;  it must not previously have been used in a call to 
  14683.  Tk_DefineBitmap. The arguments source, width, and height describe the bitmap. 
  14684.  Tk_DefineBitmap normally returns TCL_OK;  if an error occurs (e.g. a bitmap 
  14685.  named nameId has already been defined) then TCL_ERROR is returned and an error 
  14686.  message is left in interp->result. Note:  Tk_DefineBitmap expects the memory 
  14687.  pointed to by source to be static:  Tk_DefineBitmap doesn't make a private 
  14688.  copy of this memory, but uses the bytes pointed to by source later in calls to 
  14689.  Tk_GetBitmap. 
  14690.  
  14691.  Typically Tk_DefineBitmap is used by #include-ing a bitmap file directly into 
  14692.  a C program and then referencing the variables defined by the file. For 
  14693.  example, suppose there exists a file stip.bitmap, which was created by the 
  14694.  bitmap program and contains a stipple pattern. The following code uses 
  14695.  Tk_DefineBitmap to define a new bitmap named foo: 
  14696.  
  14697.   Pixmap bitmap;
  14698.   #include "stip.bitmap"
  14699.   Tk_DefineBitmap(interp, Tk_GetUid("foo"), stip_bits,
  14700.          stip_width, stip_height);
  14701.   ...
  14702.   bitmap = Tk_GetBitmap(interp, tkwin, Tk_GetUid("foo"));
  14703.  This code causes the bitmap file to be read at compile-time and incorporates 
  14704.  the bitmap information into the program's executable image.  The same bitmap 
  14705.  file could be read at run-time using Tk_GetBitmap: 
  14706.  
  14707.   Pixmap bitmap;
  14708.   bitmap = Tk_GetBitmap(interp, tkwin, Tk_GetUid("@stip.bitmap"));
  14709.  The second form is a bit more flexible (the file could be modified after the 
  14710.  program has been compiled, or a different string could be provided to read a 
  14711.  different file), but it is a little slower and requires the bitmap file to 
  14712.  exist separately from the program. 
  14713.  
  14714.  Tk_GetBitmap maintains a database of all the bitmaps that are currently in 
  14715.  use. Whenever possible, it will return an existing bitmap rather than creating 
  14716.  a new one. This approach can substantially reduce server overhead, so 
  14717.  Tk_GetBitmap should generally be used in preference to Xlib procedures like 
  14718.  XReadBitmapFile. 
  14719.  
  14720.  The bitmaps returned by Tk_GetBitmap are shared, so callers should never 
  14721.  modify them. If a bitmap must be modified dynamically, then it should be 
  14722.  created by calling Xlib procedures such as XReadBitmapFile or XCreatePixmap 
  14723.  directly. 
  14724.  
  14725.  The procedure Tk_NameOfBitmap is roughly the inverse of Tk_GetBitmap. Given an 
  14726.  X Pixmap argument, it returns the id that was passed to Tk_GetBitmap when the 
  14727.  bitmap was created. Bitmap must have been the return value from a previous 
  14728.  call to Tk_GetBitmap. 
  14729.  
  14730.  Tk_SizeOfBitmap returns the dimensions of its bitmap argument in the words 
  14731.  pointed to by the widthPtr and heightPtr arguments.  As with Tk_NameOfBitmap, 
  14732.  bitmap must have been created by Tk_GetBitmap. 
  14733.  
  14734.  When a bitmap returned by Tk_GetBitmap is no longer needed, Tk_FreeBitmap 
  14735.  should be called to release it. There should be exactly one call to 
  14736.  Tk_FreeBitmap for each call to Tk_GetBitmap. When a bitmap is no longer in use 
  14737.  anywhere (i.e. it has been freed as many times as it has been gotten) 
  14738.  Tk_FreeBitmap will release it to the X server and delete it from the database. 
  14739.  
  14740.  BUGS 
  14741.  
  14742.  In determining whether an existing bitmap can be used to satisfy a new 
  14743.  request, Tk_GetBitmap considers only the immediate value of its id argument. 
  14744.  For example, when a file name is passed to Tk_GetBitmap, Tk_GetBitmap will 
  14745.  assume it is safe to re-use an existing bitmap created from the same file 
  14746.  name:  it will not check to see whether the file itself has changed, or 
  14747.  whether the current directory has changed, thereby causing the name to refer 
  14748.  to a different file. 
  14749.  
  14750.  KEYWORDS 
  14751.  
  14752.  bitmap, pixmap 
  14753.  
  14754.  
  14755. ΓòÉΓòÉΓòÉ 5.25. Tk_GetCapStyle ΓòÉΓòÉΓòÉ
  14756.  
  14757.  NAME 
  14758.  
  14759. Tk_GetCapStyle, Tk_NameOfCapStyle - translate between strings and cap styles 
  14760.  
  14761. SYNOPSIS 
  14762.  
  14763. #include <tk.h> 
  14764.  
  14765.  int 
  14766.  Tk_GetCapStyle(interp, string, capPtr) 
  14767.  
  14768.  char * 
  14769.  Tk_NameOfCapStyle(cap) 
  14770.  
  14771. ARGUMENTS 
  14772.  
  14773.  Tcl_Interp  *interp (in)  Interpreter to use for error reporting. 
  14774.  
  14775.  char  *string (in)  String containing name of cap style: one of "`butt", 
  14776.            "projecting", or "round". 
  14777.  
  14778.  int  *capPtr (out)  Pointer to location in which to store X cap style 
  14779.            corresponding to string. 
  14780.  
  14781.  int  cap (in)  Cap style: one of CapButt, CapProjecting, or CapRound. 
  14782.  
  14783.  DESCRIPTION 
  14784.  
  14785.  Tk_GetCapStyle places in *capPtr the X cap style corresponding to string. This 
  14786.  will be one of the values CapButt, CapProjecting, or CapRound. Cap styles are 
  14787.  typically used in X graphics contexts to indicate how the end-points of lines 
  14788.  should be capped. See the X documentation for information on what each style 
  14789.  implies. 
  14790.  
  14791.  Under normal circumstances the return value is TCL_OK and interp is unused. If 
  14792.  string doesn't contain a valid cap style or an abbreviation of one of these 
  14793.  names, then an error message is stored in interp->result, TCL_ERROR is 
  14794.  returned, and *capPtr is unmodified. 
  14795.  
  14796.  Tk_NameOfCapStyle is the logical inverse of Tk_GetCapStyle. Given a cap style 
  14797.  such as CapButt it returns a statically-allocated string corresponding to cap. 
  14798.  If cap isn't a legal cap style, then "unknown cap style" is returned. 
  14799.  
  14800.  KEYWORDS 
  14801.  
  14802.  butt, cap style, projecting, round 
  14803.  
  14804.  
  14805. ΓòÉΓòÉΓòÉ 5.26. Tk_GetColormap ΓòÉΓòÉΓòÉ
  14806.  
  14807.  NAME 
  14808.  
  14809. Tk_GetColormap, Tk_FreeColormap - allocate and free colormaps 
  14810.  
  14811. SYNOPSIS 
  14812.  
  14813. #include <tk.h> 
  14814.  
  14815.  Colormap 
  14816.  Tk_GetColormap(interp, tkwin, string) 
  14817.  
  14818.  Tk_FreeColormap(display, colormap) 
  14819.  
  14820. ARGUMENTS 
  14821.  
  14822.  Tcl_Interp  *interp (in)  Interpreter to use for error reporting. 
  14823.  
  14824.  Tk_Window  tkwin (in)  Token for window in which colormap will be used. 
  14825.  
  14826.  char  *string (in)  Selects a colormap:  either new or the name of a window 
  14827.            with the same screen and visual as tkwin. 
  14828.  
  14829.  Display  *display (in)  Display for which colormap was allocated. 
  14830.  
  14831.  Colormap  colormap (in)  Colormap to free;  must have been returned by a 
  14832.            previous call to Tk_GetColormap or Tk_GetVisual. 
  14833.  
  14834.  DESCRIPTION 
  14835.  
  14836.  These procedures are used to manage colormaps. Tk_GetColormap returns a 
  14837.  colormap suitable for use in tkwin. If its string argument is new then a new 
  14838.  colormap is created;  otherwise string must be the name of another window with 
  14839.  the same screen and visual as tkwin, and the colormap from that window is 
  14840.  returned. If string doesn't make sense, or if it refers to a window on a 
  14841.  different screen from tkwin or with a different visual than tkwin, then 
  14842.  Tk_GetColormap returns None and leaves an error message in interp->result. 
  14843.  
  14844.  Tk_FreeColormap should be called when a colormap returned by Tk_GetColormap is 
  14845.  no longer needed. Tk maintains a reference count for each colormap returned by 
  14846.  Tk_GetColormap, so there should eventually be one call to Tk_FreeColormap for 
  14847.  each call to Tk_GetColormap. When a colormap's reference count becomes zero, 
  14848.  Tk releases the X colormap. 
  14849.  
  14850.  Tk_GetVisual and Tk_GetColormap work together, in that a new colormap created 
  14851.  by Tk_GetVisual may later be returned by Tk_GetColormap. The reference 
  14852.  counting mechanism for colormaps includes both procedures, so callers of 
  14853.  Tk_GetVisual must also call Tk_FreeColormap to release the colormap. If 
  14854.  Tk_GetColormap is called with a string value of new then the resulting 
  14855.  colormap will never be returned by Tk_GetVisual;  however, it can be used in 
  14856.  other windows by calling Tk_GetColormap with the original window's name as 
  14857.  string. 
  14858.  
  14859.  KEYWORDS 
  14860.  
  14861.  colormap 
  14862.  
  14863.  
  14864. ΓòÉΓòÉΓòÉ 5.27. Tk_GetColor ΓòÉΓòÉΓòÉ
  14865.  
  14866.  NAME 
  14867.  
  14868. Tk_GetColor, Tk_GetColorByValue, Tk_NameOfColor, Tk_FreeColor - maintain 
  14869. database of colors 
  14870.  
  14871. SYNOPSIS 
  14872.  
  14873. #include <tk.h> 
  14874.  
  14875.  XColor * 
  14876.  Tk_GetColor(interp, tkwin, nameId) 
  14877.  
  14878.  XColor * 
  14879.  Tk_GetColorByValue(tkwin, prefPtr) 
  14880.  
  14881.  char * 
  14882.  Tk_NameOfColor(colorPtr) 
  14883.  
  14884.  GC 
  14885.  Tk_GCForColor(colorPtr, drawable) 
  14886.  
  14887.  Tk_FreeColor(colorPtr) 
  14888.  
  14889. ARGUMENTS 
  14890.  
  14891.  Tcl_Interp  *interp (in)  Interpreter to use for error reporting. 
  14892.  
  14893.  Tk_Window  tkwin (in)  Token for window in which color will be used. 
  14894.  
  14895.  Tk_Uid  nameId (in)  Textual description of desired color. 
  14896.  
  14897.  XColor  *prefPtr (in)  Indicates red, green, and blue intensities of desired 
  14898.            color. 
  14899.  
  14900.  XColor  *colorPtr (in)  Pointer to X color information.  Must have been 
  14901.            allocated by previous call to Tk_GetColor or Tk_GetColorByValue, 
  14902.            except when passed to Tk_NameOfColor. 
  14903.  
  14904.  Drawable  drawable (in)  Drawable in which the result graphics context will be 
  14905.            used.  Must have same screen and depth as the window for which the 
  14906.            color was allocated. 
  14907.  
  14908.  DESCRIPTION 
  14909.  
  14910.  The Tk_GetColor and Tk_GetColorByValue procedures locate pixel values that may 
  14911.  be used to render particular colors in the window given by tkwin.  In 
  14912.  Tk_GetColor the desired color is specified with a Tk_Uid (nameId), which may 
  14913.  have any of the following forms: 
  14914.  
  14915.  colorname  Any of the valid textual names for a color defined in the server's 
  14916.            color database file, such as red or PeachPuff. 
  14917.  
  14918.  #RGB 
  14919.  
  14920.  #RRGGBB 
  14921.  
  14922.  #RRRGGGBBB 
  14923.  
  14924.  #RRRRGGGGBBBB  A numeric specification of the red, green, and blue intensities 
  14925.            to use to display the color.  Each R, G, or B represents a single 
  14926.            hexadecimal digit.  The four forms permit colors to be specified 
  14927.            with 4-bit, 8-bit, 12-bit or 16-bit values. When fewer than 16 bits 
  14928.            are provided for each color, they represent the most significant 
  14929.            bits of the color.  For example, #3a7 is the same as #3000a0007000. 
  14930.  
  14931.  In Tk_GetColorByValue, the desired color is indicated with the red, green, and 
  14932.  blue fields of the structure pointed to by colorPtr. 
  14933.  
  14934.  If Tk_GetColor or Tk_GetColorByValue is successful in allocating the desired 
  14935.  color, then it returns a pointer to an XColor structure;  the structure 
  14936.  indicates the exact intensities of the allocated color (which may differ 
  14937.  slightly from those requested, depending on the limitations of the screen) and 
  14938.  a pixel value that may be used to draw in the color. If the colormap for tkwin 
  14939.  is full, Tk_GetColor and Tk_GetColorByValue will use the closest existing 
  14940.  color in the colormap. If Tk_GetColor encounters an error while allocating the 
  14941.  color (such as an unknown color name) then NULL is returned and an error 
  14942.  message is stored in interp->result; Tk_GetColorByValue never returns an 
  14943.  error. 
  14944.  
  14945.  Tk_GetColor and Tk_GetColorByValue maintain a database of all the colors 
  14946.  currently in use. If the same nameId is requested multiple times from 
  14947.  Tk_GetColor (e.g. by different windows), or if the same intensities are 
  14948.  requested multiple times from Tk_GetColorByValue, then existing pixel values 
  14949.  will be re-used.  Re-using an existing pixel avoids any interaction with the X 
  14950.  server, which makes the allocation much more efficient.  For this reason, you 
  14951.  should generally use Tk_GetColor or Tk_GetColorByValue instead of Xlib 
  14952.  procedures like XAllocColor, XAllocNamedColor, or XParseColor. 
  14953.  
  14954.  Since different calls to Tk_GetColor or Tk_GetColorByValue may return the same 
  14955.  shared pixel value, callers should never change the color of a pixel returned 
  14956.  by the procedures. If you need to change a color value dynamically, you should 
  14957.  use XAllocColorCells to allocate the pixel value for the color. 
  14958.  
  14959.  The procedure Tk_NameOfColor is roughly the inverse of Tk_GetColor.  If its 
  14960.  colorPtr argument was created by Tk_GetColor, then the return value is the 
  14961.  nameId string that was passed to Tk_GetColor to create the color.  If colorPtr 
  14962.  was created by a call to Tk_GetColorByValue, or by any other mechanism, then 
  14963.  the return value is a string that could be passed to Tk_GetColor to return the 
  14964.  same color.  Note:  the string returned by Tk_NameOfColor is only guaranteed 
  14965.  to persist until the next call to Tk_NameOfColor. 
  14966.  
  14967.  Tk_GCForColor returns a graphics context whose Foreground field is the pixel 
  14968.  allocated for colorPtr and whose other fields all have default values. This 
  14969.  provides an easy way to do basic drawing with a color. The graphics context is 
  14970.  cached with the color and will exist only as long as colorPtr exists;  it is 
  14971.  freed when the last reference to colorPtr is freed by calling Tk_FreeColor. 
  14972.  
  14973.  When a pixel value returned by Tk_GetColor or Tk_GetColorByValue is no longer 
  14974.  needed, Tk_FreeColor should be called to release the color. There should be 
  14975.  exactly one call to Tk_FreeColor for each call to Tk_GetColor or 
  14976.  Tk_GetColorByValue. When a pixel value is no longer in use anywhere (i.e. it 
  14977.  has been freed as many times as it has been gotten) Tk_FreeColor will release 
  14978.  it to the X server and delete it from the database. 
  14979.  
  14980.  KEYWORDS 
  14981.  
  14982.  color, intensity, pixel value 
  14983.  
  14984.  
  14985. ΓòÉΓòÉΓòÉ 5.28. Tk_GetCursor ΓòÉΓòÉΓòÉ
  14986.  
  14987.  NAME 
  14988.  
  14989. Tk_GetCursor, Tk_GetCursorFromData, Tk_NameOfCursor, Tk_FreeCursor - maintain 
  14990. database of cursors 
  14991.  
  14992. SYNOPSIS 
  14993.  
  14994. #include <tk.h> 
  14995.  
  14996.  Tk_Cursor 
  14997.  Tk_GetCursor(interp, tkwin, nameId) 
  14998.  
  14999.  Tk_Cursor 
  15000.  Tk_GetCursorFromData(interp, tkwin, source, mask, width, height, xHot, yHot, 
  15001. fg, bg) 
  15002.  
  15003.  char * 
  15004.  Tk_NameOfCursor(display, cursor) 
  15005.  
  15006.  Tk_FreeCursor(display, cursor) 
  15007.  
  15008. ARGUMENTS 
  15009.  
  15010.  Tcl_Interp  *interp (in)  Interpreter to use for error reporting. 
  15011.  
  15012.  Tk_Window  tkwin (in)  Token for window in which the cursor will be used. 
  15013.  
  15014.  Tk_Uid  nameId (in)  Description of cursor;  see below for possible values. 
  15015.  
  15016.  char  *source (in)  Data for cursor bitmap, in standard bitmap format. 
  15017.  
  15018.  char  *mask (in)  Data for mask bitmap, in standard bitmap format. 
  15019.  
  15020.  int  width (in)  Width of source and mask. 
  15021.  
  15022.  int  height (in)  Height of source and mask. 
  15023.  
  15024.  int  xHot (in)  X-location of cursor hot-spot. 
  15025.  
  15026.  int  yHot (in)  Y-location of cursor hot-spot. 
  15027.  
  15028.  Tk_Uid  fg (in)  Textual description of foreground color for cursor. 
  15029.  
  15030.  Tk_Uid  bg (in)  Textual description of background color for cursor. 
  15031.  
  15032.  Display  *display (in)  Display for which cursor was allocated. 
  15033.  
  15034.  Tk_Cursor  cursor (in)  Opaque Tk identifier for cursor.  If passed 
  15035.            toTk_FreeCursor, must have been returned by some previous call to 
  15036.            Tk_GetCursor or Tk_GetCursorFromData. 
  15037.  
  15038.  DESCRIPTION 
  15039.  
  15040.  These procedures manage a collection of cursors being used by an application. 
  15041.  The procedures allow cursors to be re-used efficiently, thereby avoiding 
  15042.  server overhead, and also allow cursors to be named with character strings 
  15043.  (actually Tk_Uids). 
  15044.  
  15045.  Tk_GetCursor takes as argument a Tk_Uid describing a cursor, and returns an 
  15046.  opaque Tk identifier for a cursor corresponding to the description. It re-uses 
  15047.  an existing cursor if possible and creates a new one otherwise.  NameId must 
  15048.  be a standard Tcl list with one of the following forms: 
  15049.  
  15050.  name [fgColor [bgColor]]  Name is the name of a cursor in the standard X 
  15051.            cursor font, i.e., any of the names defined in cursorfont.h, without 
  15052.            the XC_.  Some example values are X_cursor, hand2, or left_ptr. 
  15053.            Appendix B of "The X Window System" by Scheifler & Gettys has 
  15054.            illustrations showing what each of these cursors looks like.  If 
  15055.            fgColor and bgColor are both specified, they give the foreground and 
  15056.            background colors to use for the cursor (any of the forms acceptable 
  15057.            to Tk_GetColor may be used).  If only fgColor is specified, then 
  15058.            there will be no background color:  the background will be 
  15059.            transparent. If no colors are specified, then the cursor will use 
  15060.            black for its foreground color and white for its background color. 
  15061.            The Macintosh version of Tk also supports all of the X cursors. Tk 
  15062.            on the Mac will also accept any of the standard Mac cursors 
  15063.            including ibeam, crosshair, watch, plus, and arrow.  In addition, Tk 
  15064.            will load Macintosh cursor resources of the types crsr (color) and 
  15065.            CURS (black and white) by the name of the of the resource.  The 
  15066.            application and all its open dynamic library's resource files will 
  15067.            be searched for the named cursor.  If there are conflicts color 
  15068.            cursors will always be loaded in preference to black and white 
  15069.            cursors. 
  15070.  
  15071.  @sourceName maskName fgColor bgColor  In this form, sourceName and maskName 
  15072.            are the names of files describing bitmaps for the cursor's source 
  15073.            bits and mask. Each file must be in standard X11 or X10 bitmap 
  15074.            format. FgColor and bgColor indicate the colors to use for the 
  15075.            cursor, in any of the forms acceptable to Tk_GetColor.  This form of 
  15076.            the command will not work on Macintosh or Windows computers. 
  15077.  
  15078.  @sourceName fgColor  This form is similar to the one above, except that the 
  15079.            source is used as mask also.  This means that the cursor's 
  15080.            background is transparent.  This form of the command will not work 
  15081.            on Macintosh or Windows computers. 
  15082.  
  15083.  Tk_GetCursorFromData allows cursors to be created from in-memory descriptions 
  15084.  of their source and mask bitmaps.  Source points to standard bitmap data for 
  15085.  the cursor's source bits, and mask points to standard bitmap data describing 
  15086.  which pixels of source are to be drawn and which are to be considered 
  15087.  transparent.  Width and height give the dimensions of the cursor, xHot and 
  15088.  yHot indicate the location of the cursor's hot-spot (the point that is 
  15089.  reported when an event occurs), and fg and bg describe the cursor's foreground 
  15090.  and background colors textually (any of the forms suitable for Tk_GetColor may 
  15091.  be used).  Typically, the arguments to Tk_GetCursorFromData are created by 
  15092.  including a cursor file directly into the source code for a program, as in the 
  15093.  following example: 
  15094.  
  15095.   Tk_Cursor cursor;
  15096.   #include "source.cursor"
  15097.   #include "mask.cursor"
  15098.   cursor = Tk_GetCursorFromData(interp, tkwin, source_bits,
  15099.          mask_bits, source_width, source_height, source_x_hot,
  15100.          source_y_hot, Tk_GetUid("red"), Tk_GetUid("blue"));
  15101.  
  15102.  Under normal conditions, Tk_GetCursor and Tk_GetCursorFromData will return an 
  15103.  identifier for the requested cursor.  If an error occurs in creating the 
  15104.  cursor, such as when nameId refers to a non-existent file, then None is 
  15105.  returned and an error message will be stored in interp->result. 
  15106.  
  15107.  Tk_GetCursor and Tk_GetCursorFromData maintain a database of all the cursors 
  15108.  they have created.  Whenever possible, a call to Tk_GetCursor or 
  15109.  Tk_GetCursorFromData will return an existing cursor rather than creating a new 
  15110.  one.  This approach can substantially reduce server overhead, so the Tk 
  15111.  procedures should generally be used in preference to Xlib procedures like 
  15112.  XCreateFontCursor or XCreatePixmapCursor, which create a new cursor on each 
  15113.  call. 
  15114.  
  15115.  The procedure Tk_NameOfCursor is roughly the inverse of Tk_GetCursor.  If its 
  15116.  cursor argument was created by Tk_GetCursor, then the return value is the 
  15117.  nameId argument that was passed to Tk_GetCursor to create the cursor.  If 
  15118.  cursor was created by a call to Tk_GetCursorFromData, or by any other 
  15119.  mechanism, then the return value is a hexadecimal string giving the X 
  15120.  identifier for the cursor. Note:  the string returned by Tk_NameOfCursor is 
  15121.  only guaranteed to persist until the next call to Tk_NameOfCursor.  Also, this 
  15122.  call is not portable except for cursors returned by Tk_GetCursor. 
  15123.  
  15124.  When a cursor returned by Tk_GetCursor or Tk_GetCursorFromData is no longer 
  15125.  needed, Tk_FreeCursor should be called to release it. There should be exactly 
  15126.  one call to Tk_FreeCursor for each call to Tk_GetCursor or 
  15127.  Tk_GetCursorFromData. When a cursor is no longer in use anywhere (i.e. it has 
  15128.  been freed as many times as it has been gotten) Tk_FreeCursor will release it 
  15129.  to the X server and remove it from the database. 
  15130.  
  15131.  BUGS 
  15132.  
  15133.  In determining whether an existing cursor can be used to satisfy a new 
  15134.  request, Tk_GetCursor and Tk_GetCursorFromData consider only the immediate 
  15135.  values of their arguments.  For example, when a file name is passed to 
  15136.  Tk_GetCursor, Tk_GetCursor will assume it is safe to re-use an existing cursor 
  15137.  created from the same file name:  it will not check to see whether the file 
  15138.  itself has changed, or whether the current directory has changed, thereby 
  15139.  causing the name to refer to a different file.  Similarly, 
  15140.  Tk_GetCursorFromData assumes that if the same source pointer is used in two 
  15141.  different calls, then the pointers refer to the same data;  it does not check 
  15142.  to see if the actual data values have changed. 
  15143.  
  15144.  KEYWORDS 
  15145.  
  15146.  cursor 
  15147.  
  15148.  
  15149. ΓòÉΓòÉΓòÉ 5.29. Tk_GetFontStruct ΓòÉΓòÉΓòÉ
  15150.  
  15151.  NAME 
  15152.  
  15153. Tk_GetFontStruct, Tk_NameOfFontStruct, Tk_FreeFontStruct - maintain database of 
  15154. fonts 
  15155.  
  15156. SYNOPSIS 
  15157.  
  15158. #include <tk.h> 
  15159.  
  15160.  XFontStruct * 
  15161.  Tk_GetFontStruct(interp, tkwin, nameId) 
  15162.  
  15163.  char * 
  15164.  Tk_NameOfFontStruct(fontStructPtr) 
  15165.  
  15166.  Tk_FreeFontStruct(fontStructPtr) 
  15167.  
  15168. ARGUMENTS 
  15169.  
  15170.  Tcl_Interp  *interp (in)  Interpreter to use for error reporting. 
  15171.  
  15172.  Tk_Window  tkwin (in)  Token for window in which font will be used. 
  15173.  
  15174.  Tk_Uid  nameId (in)  Name of desired font. 
  15175.  
  15176.  XFontStruct  *fontStructPtr (in)  Font structure to return name for or delete. 
  15177.  
  15178.  DESCRIPTION 
  15179.  
  15180.  Tk_GetFont loads the font indicated by nameId and returns a pointer to 
  15181.  information about the font.  The pointer returned by Tk_GetFont will remain 
  15182.  valid until Tk_FreeFont is called to release it. NameId can be either a font 
  15183.  name or pattern;  any value that could be passed to XLoadQueryFont may be 
  15184.  passed to Tk_GetFont.  If Tk_GetFont is unsuccessful (because, for example, 
  15185.  there is no font corresponding to nameId) then it returns NULL and stores an 
  15186.  error message in interp->result. 
  15187.  
  15188.  Tk_GetFont maintains a database of all fonts it has allocated. If the same 
  15189.  nameId is requested multiple times (e.g. by different windows or for different 
  15190.  purposes), then additional calls for the same nameId will be handled very 
  15191.  quickly, without involving the X server.  For this reason, it is generally 
  15192.  better to use Tk_GetFont in place of X library procedures like XLoadQueryFont. 
  15193.  
  15194.  The procedure Tk_NameOfFontStruct is roughly the inverse of Tk_GetFontStruct. 
  15195.  If its fontStructPtr argument was created by Tk_GetFontStruct, then the return 
  15196.  value is the nameId argument that was passed to Tk_GetFontStruct to create the 
  15197.  font.  If fontStructPtr was not created by a call to Tk_GetFontStruct, then 
  15198.  the return value is a hexadecimal string giving the X identifier for the 
  15199.  associated font. Note:  the string returned by Tk_NameOfFontStruct is only 
  15200.  guaranteed to persist until the next call to Tk_NameOfFontStruct. 
  15201.  
  15202.  When a font returned by Tk_GetFont is no longer needed, Tk_FreeFont should be 
  15203.  called to release it. There should be exactly one call to Tk_FreeFont for each 
  15204.  call to Tk_GetFont.  When a font is no longer in use anywhere (i.e. it has 
  15205.  been freed as many times as it has been gotten) Tk_FreeFont will release it to 
  15206.  the X server and delete it from the database. 
  15207.  
  15208.  KEYWORDS 
  15209.  
  15210.  font 
  15211.  
  15212.  
  15213. ΓòÉΓòÉΓòÉ 5.30. Tk_GetGC ΓòÉΓòÉΓòÉ
  15214.  
  15215.  NAME 
  15216.  
  15217. Tk_GetGC, Tk_FreeGC - maintain database of read-only graphics contexts 
  15218.  
  15219. SYNOPSIS 
  15220.  
  15221. #include <tk.h> 
  15222.  
  15223.  GC 
  15224.  Tk_GetGC(tkwin, valueMask, valuePtr) 
  15225.  
  15226.  Tk_FreeGC(display, gc) 
  15227.  
  15228. ARGUMENTS 
  15229.  
  15230.  Tk_Window  tkwin (in)  Token for window in which the graphics context will be 
  15231.            used. 
  15232.  
  15233.  unsigned long  valueMask (in)  Mask of bits (such as GCForeground or 
  15234.            GCStipple) indicating which fields of *valuePtr are valid. 
  15235.  
  15236.  XGCValues  *valuePtr (in)  Pointer to structure describing the desired values 
  15237.            for the graphics context. 
  15238.  
  15239.  Display  *display (in)  Display for which gc was allocated. 
  15240.  
  15241.  GC  gc (in)  X identifier for graphics context that is no longer needed. Must 
  15242.            have been allocated by Tk_GetGC. 
  15243.  
  15244.  DESCRIPTION 
  15245.  
  15246.  Tk_GetGC and Tk_FreeGC manage a collection of graphics contexts being used by 
  15247.  an application.  The procedures allow graphics contexts to be shared, thereby 
  15248.  avoiding the server overhead that would be incurred if a separate GC were 
  15249.  created for each use.  Tk_GetGC takes arguments describing the desired 
  15250.  graphics context and returns an X identifier for a GC that fits the 
  15251.  description.  The graphics context that is returned will have default values 
  15252.  in all of the fields not specified explicitly by valueMask and valuePtr. 
  15253.  
  15254.  Tk_GetGC maintains a database of all the graphics contexts it has created. 
  15255.  Whenever possible, a call to Tk_GetGC will return an existing graphics context 
  15256.  rather than creating a new one.  This approach can substantially reduce server 
  15257.  overhead, so Tk_GetGC should generally be used in preference to the Xlib 
  15258.  procedure XCreateGC, which creates a new graphics context on each call. 
  15259.  
  15260.  Since the return values of Tk_GetGC are shared, callers should never modify 
  15261.  the graphics contexts returned by Tk_GetGC. If a graphics context must be 
  15262.  modified dynamically, then it should be created by calling XCreateGC instead 
  15263.  of Tk_GetGC. 
  15264.  
  15265.  When a graphics context is no longer needed, Tk_FreeGC should be called to 
  15266.  release it. There should be exactly one call to Tk_FreeGC for each call to 
  15267.  Tk_GetGC. When a graphics context is no longer in use anywhere (i.e. it has 
  15268.  been freed as many times as it has been gotten) Tk_FreeGC will release it to 
  15269.  the X server and delete it from the database. 
  15270.  
  15271.  KEYWORDS 
  15272.  
  15273.  graphics context 
  15274.  
  15275.  
  15276. ΓòÉΓòÉΓòÉ 5.31. Tk_GetImage ΓòÉΓòÉΓòÉ
  15277.  
  15278.  NAME 
  15279.  
  15280. Tk_GetImage, Tk_RedrawImage, Tk_SizeOfImage, Tk_FreeImage - use an image in a 
  15281. widget 
  15282.  
  15283. SYNOPSIS 
  15284.  
  15285. #include <tk.h> 
  15286.  
  15287.  Tk_Image 
  15288.  Tk_GetImage(interp, tkwin, name, changeProc, clientData) 
  15289.  
  15290.  Tk_RedrawImage(image, imageX, imageY, width, height, drawable, drawableX, 
  15291. drawableY) 
  15292.  
  15293.  Tk_SizeOfImage(image, widthPtr, heightPtr) 
  15294.  
  15295.  Tk_FreeImage(image) 
  15296.  
  15297. ARGUMENTS 
  15298.  
  15299.  Tcl_Interp  *interp (in)  Place to leave error message. 
  15300.  
  15301.  Tk_Window  tkwin (in)  Window in which image will be used. 
  15302.  
  15303.  char  *name (in)  Name of image. 
  15304.  
  15305.  Tk_ImageChangedProc  *changeProc (in)  Procedure for Tk to invoke whenever 
  15306.            image content or size changes. 
  15307.  
  15308.  ClientData  clientData (in)  One-word value for Tk to pass to changeProc. 
  15309.  
  15310.  Tk_Image  image (in)  Token for image instance;  must have been returned by a 
  15311.            previous call to Tk_GetImage. 
  15312.  
  15313.  int  imageX (in)  X-coordinate of upper-left corner of region of image to 
  15314.            redisplay (measured in pixels from the image's upper-left corner). 
  15315.  
  15316.  int  imageY (in)  Y-coordinate of upper-left corner of region of image to 
  15317.            redisplay (measured in pixels from the image's upper-left corner). 
  15318.  
  15319.  int  width ((in))  Width of region of image to redisplay. 
  15320.  
  15321.  int  height ((in))  Height of region of image to redisplay. 
  15322.  
  15323.  Drawable  drawable (in)  Where to display image.  Must either be window 
  15324.            specified to Tk_GetImage or a pixmap compatible with that window. 
  15325.  
  15326.  int  drawableX (in)  Where to display image in drawable: this is the 
  15327.            x-coordinate in drawable where x-coordinate imageX of the image 
  15328.            should be displayed. 
  15329.  
  15330.  int  drawableY (in)  Where to display image in drawable: this is the 
  15331.            y-coordinate in drawable where y-coordinate imageY of the image 
  15332.            should be displayed. 
  15333.  
  15334.  int  widthPtr (out)  Store width of image (in pixels) here. 
  15335.  
  15336.  int  heightPtr (out)  Store height of image (in pixels) here. 
  15337.  
  15338.  DESCRIPTION 
  15339.  
  15340.  These procedures are invoked by widgets that wish to display images. 
  15341.  Tk_GetImage is invoked by a widget when it first decides to display an image. 
  15342.  name gives the name of the desired image and tkwin identifies the window where 
  15343.  the image will be displayed. Tk_GetImage looks up the image in the table of 
  15344.  existing images and returns a token for a new instance of the image. If the 
  15345.  image doesn't exist then Tk_GetImage returns NULL and leaves an error message 
  15346.  in interp->result. 
  15347.  
  15348.  When a widget wishes to actually display an image it must call 
  15349.  Tk_RedrawWidget, identifying the image (image), a region within the image to 
  15350.  redisplay (imageX, imageY, width, and height), and a place to display the 
  15351.  image (drawable, drawableX, and drawableY). Tk will then invoke the 
  15352.  appropriate image manager, which will display the requested portion of the 
  15353.  image before returning. 
  15354.  
  15355.  A widget can find out the dimensions of an image by calling Tk_SizeOfImage: 
  15356.  the width and height will be stored in the locations given by widthPtr and 
  15357.  heightPtr, respectively. 
  15358.  
  15359.  When a widget is finished with an image (e.g., the widget is being deleted or 
  15360.  it is going to use a different image instead of the current one), it must call 
  15361.  Tk_FreeImage to release the image instance. The widget should never again use 
  15362.  the image token after passing it to Tk_FreeImage. There must be exactly one 
  15363.  call to Tk_FreeImage for each call to Tk_GetImage. 
  15364.  
  15365.  If the contents or size of an image changes, then any widgets using the image 
  15366.  will need to find out about the changes so that they can redisplay themselves. 
  15367.  The changeProc and clientData arguments to Tk_GetImage are used for this 
  15368.  purpose. changeProc will be called by Tk whenever a change occurs in the 
  15369.  image;  it must match the following prototype: 
  15370.  
  15371.   typedef void Tk_ImageChangedProc(
  15372.          ClientData clientData,
  15373.          int x,
  15374.          int y,
  15375.          int width,
  15376.          int height,
  15377.          int imageWidth,
  15378.          int imageHeight);
  15379.  The clientData argument to changeProc is the same as the clientData argument 
  15380.  to Tk_GetImage. It is usually a pointer to the widget record for the widget or 
  15381.  some other data structure managed by the widget. The arguments x, y, width, 
  15382.  and height identify a region within the image that must be redisplayed; they 
  15383.  are specified in pixels measured from the upper-left corner of the image. The 
  15384.  arguments imageWidth and imageHeight give the image's (new) size. 
  15385.  
  15386.  SEE ALSO 
  15387.  
  15388.  Tk_CreateImageType 
  15389.  
  15390.  KEYWORDS 
  15391.  
  15392.  images, redisplay 
  15393.  
  15394.  
  15395. ΓòÉΓòÉΓòÉ 5.32. Tk_GetJoinStyle ΓòÉΓòÉΓòÉ
  15396.  
  15397.  NAME 
  15398.  
  15399. Tk_GetJoinStyle, Tk_NameOfJoinStyle - translate between strings and join styles 
  15400.  
  15401. SYNOPSIS 
  15402.  
  15403. #include <tk.h> 
  15404.  
  15405.  int 
  15406.  Tk_GetJoinStyle(interp, string, joinPtr) 
  15407.  
  15408.  char * 
  15409.  Tk_NameOfJoinStyle(join) 
  15410.  
  15411. ARGUMENTS 
  15412.  
  15413.  Tcl_Interp  *interp (in)  Interpreter to use for error reporting. 
  15414.  
  15415.  char  *string (in)  String containing name of join style: one of "bevel", 
  15416.            "miter", or "round". 
  15417.  
  15418.  int  *joinPtr (out)  Pointer to location in which to store X join style 
  15419.            corresponding to string. 
  15420.  
  15421.  int  join (in)  Join style: one of JoinBevel, JoinMiter, JoinRound. 
  15422.  
  15423.  DESCRIPTION 
  15424.  
  15425.  Tk_GetJoinStyle places in *joinPtr the X join style corresponding to string, 
  15426.  which will be one of JoinBevel, JoinMiter, or JoinRound. Join styles are 
  15427.  typically used in X graphics contexts to indicate how adjacent line segments 
  15428.  should be joined together. See the X documentation for information on what 
  15429.  each style implies. 
  15430.  
  15431.  Under normal circumstances the return value is TCL_OK and interp is unused. If 
  15432.  string doesn't contain a valid join style or an abbreviation of one of these 
  15433.  names, then an error message is stored in interp->result, TCL_ERROR is 
  15434.  returned, and *joinPtr is unmodified. 
  15435.  
  15436.  Tk_NameOfJoinStyle is the logical inverse of Tk_GetJoinStyle. Given a join 
  15437.  style such as JoinBevel it returns a statically-allocated string corresponding 
  15438.  to join. If join isn't a legal join style, then "unknown join style" is 
  15439.  returned. 
  15440.  
  15441.  KEYWORDS 
  15442.  
  15443.  bevel, join style, miter, round 
  15444.  
  15445.  
  15446. ΓòÉΓòÉΓòÉ 5.33. Tk_GetJustify ΓòÉΓòÉΓòÉ
  15447.  
  15448.  NAME 
  15449.  
  15450. Tk_GetJustify, Tk_NameOfJustify - translate between strings and justification 
  15451. styles 
  15452.  
  15453. SYNOPSIS 
  15454.  
  15455. #include <tk.h> 
  15456.  
  15457.  Tk_Justify 
  15458.  Tk_GetJustify(interp, string, justifyPtr) 
  15459.  
  15460.  char * 
  15461.  Tk_NameOfJustify(justify) 
  15462.  
  15463. ARGUMENTS 
  15464.  
  15465.  Tcl_Interp  *interp (in)  Interpreter to use for error reporting. 
  15466.  
  15467.  char  *string (in)  String containing name of justification style ("left", 
  15468.            "right", or "center"). 
  15469.  
  15470.  int  *justifyPtr (out)  Pointer to location in which to store justify value 
  15471.            corresponding to string. 
  15472.  
  15473.  Tk_Justify  justify (in)  Justification style (one of the values listed 
  15474.            below). 
  15475.  
  15476.  DESCRIPTION 
  15477.  
  15478.  Tk_GetJustify places in *justifyPtr the justify value corresponding to string. 
  15479.  This value will be one of the following: 
  15480.  
  15481.  TK_JUSTIFY_LEFT  Means that the text on each line should start at the left 
  15482.            edge of the line;  as a result, the right edges of lines may be 
  15483.            ragged. 
  15484.  
  15485.  TK_JUSTIFY_RIGHT  Means that the text on each line should end at the right 
  15486.            edge of the line;  as a result, the left edges of lines may be 
  15487.            ragged. 
  15488.  
  15489.  TK_JUSTIFY_CENTER  Means that the text on each line should be centered;  as a 
  15490.            result, both the left and right edges of lines may be ragged. 
  15491.  
  15492.  Under normal circumstances the return value is TCL_OK and interp is unused. If 
  15493.  string doesn't contain a valid justification style or an abbreviation of one 
  15494.  of these names, then an error message is stored in interp->result, TCL_ERROR 
  15495.  is returned, and *justifyPtr is unmodified. 
  15496.  
  15497.  Tk_NameOfJustify is the logical inverse of Tk_GetJustify. Given a justify 
  15498.  value it returns a statically-allocated string corresponding to justify. If 
  15499.  justify isn't a legal justify value, then "unknown justification style" is 
  15500.  returned. 
  15501.  
  15502.  KEYWORDS 
  15503.  
  15504.  center, fill, justification, string 
  15505.  
  15506.  
  15507. ΓòÉΓòÉΓòÉ 5.34. Tk_GetOption ΓòÉΓòÉΓòÉ
  15508.  
  15509.  NAME 
  15510.  
  15511. Tk_GetOption - retrieve an option from the option database 
  15512.  
  15513. SYNOPSIS 
  15514.  
  15515. #include <tk.h> 
  15516.  
  15517.  Tk_Uid 
  15518.  Tk_GetOption(tkwin, name, class) 
  15519.  
  15520. ARGUMENTS 
  15521.  
  15522.  Tk_Window  tkwin (in)  Token for window. 
  15523.  
  15524.  char  *name (in)  Name of desired option. 
  15525.  
  15526.  char  *class (in)  Class of desired option.  Null means there is no class for 
  15527.            this option;  do lookup based on name only. 
  15528.  
  15529.  DESCRIPTION 
  15530.  
  15531.  This procedure is invoked to retrieve an option from the database associated 
  15532.  with tkwin's main window.  If there is an option for tkwin that matches the 
  15533.  given name or class, then it is returned in the form of a Tk_Uid.  If multiple 
  15534.  options match name and class, then the highest-priority one is returned.  If 
  15535.  no option matches, then NULL is returned. 
  15536.  
  15537.  Tk_GetOption caches options related to tkwin so that successive calls for the 
  15538.  same tkwin will execute much more quickly than successive calls for different 
  15539.  windows. 
  15540.  
  15541.  KEYWORDS 
  15542.  
  15543.  class, name, option, retrieve 
  15544.  
  15545.  
  15546. ΓòÉΓòÉΓòÉ 5.35. Tk_GetPixels ΓòÉΓòÉΓòÉ
  15547.  
  15548.  NAME 
  15549.  
  15550. Tk_GetPixels, Tk_GetScreenMM - translate between strings and screen units 
  15551.  
  15552. SYNOPSIS 
  15553.  
  15554. #include <tk.h> 
  15555.  
  15556.  int 
  15557.  Tk_GetPixels(interp, tkwin, string, intPtr) 
  15558.  
  15559.  int 
  15560.  Tk_GetScreenMM(interp, tkwin, string, doublePtr) 
  15561.  
  15562. ARGUMENTS 
  15563.  
  15564.  Tcl_Interp  *interp (in)  Interpreter to use for error reporting. 
  15565.  
  15566.  Tk_Window  tkwin (in)  Window whose screen geometry determines the conversion 
  15567.            between absolute units and pixels. 
  15568.  
  15569.  char  *string (in)  String that specifies a distance on the screen. 
  15570.  
  15571.  int  *intPtr (out)  Pointer to location in which to store converted distance 
  15572.            in pixels. 
  15573.  
  15574.  double  *doublePtr (out)  Pointer to location in which to store converted 
  15575.            distance in millimeters. 
  15576.  
  15577.  DESCRIPTION 
  15578.  
  15579.  These two procedures take as argument a specification of distance on the 
  15580.  screen (string) and compute the corresponding distance either in integer 
  15581.  pixels or floating-point millimeters. In either case, string specifies a 
  15582.  screen distance as a floating-point number followed by one of the following 
  15583.  characters that indicates units: 
  15584.  
  15585.  <none>    The number specifies a distance in pixels. 
  15586.  
  15587.  c         The number specifies a distance in centimeters on the screen. 
  15588.  
  15589.  i         The number specifies a distance in inches on the screen. 
  15590.  
  15591.  m         The number specifies a distance in millimeters on the screen. 
  15592.  
  15593.  p         The number specifies a distance in printer's points (1/72 inch) on 
  15594.            the screen. 
  15595.  
  15596.  Tk_GetPixels converts string to the nearest even number of pixels and stores 
  15597.  that value at *intPtr. Tk_GetScreenMM converts string to millimeters and 
  15598.  stores the double-precision floating-point result at *doublePtr. 
  15599.  
  15600.  Both procedures return TCL_OK under normal circumstances. If an error occurs 
  15601.  (e.g. string contains a number followed by a character that isn't one of the 
  15602.  ones above) then TCL_ERROR is returned and an error message is left in 
  15603.  interp->result. 
  15604.  
  15605.  KEYWORDS 
  15606.  
  15607.  centimeters, convert, inches, millimeters, pixels, points, screen units 
  15608.  
  15609.  
  15610. ΓòÉΓòÉΓòÉ 5.36. Tk_GetPixmap ΓòÉΓòÉΓòÉ
  15611.  
  15612.  NAME 
  15613.  
  15614. Tk_GetPixmap, Tk_FreePixmap - allocate and free pixmaps 
  15615.  
  15616. SYNOPSIS 
  15617.  
  15618. #include <tk.h> 
  15619.  
  15620.  Pixmap 
  15621.  Tk_GetPixmap(display, d, width, height, depth) 
  15622.  
  15623.  Tk_FreePixmap(display, pixmap) 
  15624.  
  15625. ARGUMENTS 
  15626.  
  15627.  Display  *display (in)  X display for the pixmap. 
  15628.  
  15629.  Drawable  d (in)  Pixmap or window where the new pixmap will be used for 
  15630.            drawing. 
  15631.  
  15632.  int  width (in)  Width of pixmap. 
  15633.  
  15634.  int  height (in)  Height of pixmap. 
  15635.  
  15636.  int  depth (in)  Number of bits per pixel in pixmap. 
  15637.  
  15638.  Pixmap  pixmap (in)  Pixmap to destroy. 
  15639.  
  15640.  DESCRIPTION 
  15641.  
  15642.  These procedures are identical to the Xlib procedures XCreatePixmap and 
  15643.  XFreePixmap, except that they have extra code to manage X resource identifiers 
  15644.  so that identifiers for deleted pixmaps can be reused in the future. It is 
  15645.  important for Tk applications to use these procedures rather than 
  15646.  XCreatePixmap and XFreePixmap;  otherwise long-running applications may run 
  15647.  out of resource identifiers. 
  15648.  
  15649.  Tk_GetPixmap creates a pixmap suitable for drawing in d, with dimensions given 
  15650.  by width, height, and depth, and returns its identifier. Tk_FreePixmap 
  15651.  destroys the pixmap given by pixmap and makes its resource identifier 
  15652.  available for reuse. 
  15653.  
  15654.  KEYWORDS 
  15655.  
  15656.  pixmap, resource identifier 
  15657.  
  15658.  
  15659. ΓòÉΓòÉΓòÉ 5.37. Tk_GetRelief ΓòÉΓòÉΓòÉ
  15660.  
  15661.  NAME 
  15662.  
  15663. Tk_GetRelief, Tk_NameOfRelief - translate between strings and relief values 
  15664.  
  15665. SYNOPSIS 
  15666.  
  15667. #include <tk.h> 
  15668.  
  15669.  int 
  15670.  Tk_GetRelief(interp, name, reliefPtr) 
  15671.  
  15672.  char * 
  15673.  Tk_NameOfRelief(relief) 
  15674.  
  15675. ARGUMENTS 
  15676.  
  15677.  Tcl_Interp  *interp (in)  Interpreter to use for error reporting. 
  15678.  
  15679.  char  *name (in)  String containing relief name (one of "flat", "groove", 
  15680.            "raised", "ridge", or "sunken"). 
  15681.  
  15682.  int  *reliefPtr (out)  Pointer to location in which to store relief value 
  15683.            corresponding to name. 
  15684.  
  15685.  int  relief (in)  Relief value (one of TK_RELIEF_FLAT, TK_RELIEF_RAISED, 
  15686.            TK_RELIEF_SUNKEN, TK_RELIEF_GROOVE, or TK_RELIEF_RIDGE). 
  15687.  
  15688.  DESCRIPTION 
  15689.  
  15690.  Tk_GetRelief places in *reliefPtr the relief value corresponding to name. 
  15691.  This value will be one of TK_RELIEF_FLAT, TK_RELIEF_RAISED, TK_RELIEF_SUNKEN, 
  15692.  TK_RELIEF_GROOVE, or TK_RELIEF_RIDGE. Under normal circumstances the return 
  15693.  value is TCL_OK and interp is unused. If name doesn't contain one of the valid 
  15694.  relief names or an abbreviation of one of them, then an error message is 
  15695.  stored in interp->result, TCL_ERROR is returned, and *reliefPtr is unmodified. 
  15696.  
  15697.  Tk_NameOfRelief is the logical inverse of Tk_GetRelief. Given a relief value 
  15698.  it returns the corresponding string ("flat", "raised", "sunken", "groove", or 
  15699.  "ridge"). If relief isn't a legal relief value, then "unknown relief" is 
  15700.  returned. 
  15701.  
  15702.  KEYWORDS 
  15703.  
  15704.  name, relief, string 
  15705.  
  15706.  
  15707. ΓòÉΓòÉΓòÉ 5.38. Tk_GetRootCoords ΓòÉΓòÉΓòÉ
  15708.  
  15709.  NAME 
  15710.  
  15711. Tk_GetRootCoords - Compute root-window coordinates of window 
  15712.  
  15713. SYNOPSIS 
  15714.  
  15715. #include <tk.h> 
  15716.  
  15717.  Tk_GetRootCoords(tkwin, xPtr, yPtr) 
  15718.  
  15719. ARGUMENTS 
  15720.  
  15721.  Tk_Window  tkwin (in)  Token for window. 
  15722.  
  15723.  int  *xPtr (out)  Pointer to location in which to store root-window 
  15724.            x-coordinate corresponding to left edge of tkwin's border. 
  15725.  
  15726.  int  *yPtr (out)  Pointer to location in which to store root-window 
  15727.            y-coordinate corresponding to top edge of tkwin's border. 
  15728.  
  15729.  DESCRIPTION 
  15730.  
  15731.  This procedure scans through the structural information maintained by Tk to 
  15732.  compute the root-window coordinates corresponding to the upper-left corner of 
  15733.  tkwin's border.  If tkwin has no border, then Tk_GetRootCoords returns the 
  15734.  root-window coordinates corresponding to location (0,0) in tkwin. 
  15735.  Tk_GetRootCoords is relatively efficient, since it doesn't have to communicate 
  15736.  with the X server. 
  15737.  
  15738.  KEYWORDS 
  15739.  
  15740.  coordinates, root window 
  15741.  
  15742.  
  15743. ΓòÉΓòÉΓòÉ 5.39. Tk_GetScrollInfo ΓòÉΓòÉΓòÉ
  15744.  
  15745.  NAME 
  15746.  
  15747. Tk_GetScrollInfo - parse arguments for scrolling commands 
  15748.  
  15749. SYNOPSIS 
  15750.  
  15751. #include <tk.h> 
  15752.  
  15753.  int 
  15754.  Tk_GetScrollInfo(interp, argc, argv, dblPtr, intPtr) 
  15755.  
  15756. ARGUMENTS 
  15757.  
  15758.  Tcl_Interp  *interp (in)  Interpreter to use for error reporting. 
  15759.  
  15760.  int  argc (in)  Number of strings in argv array. 
  15761.  
  15762.  char  *argv[] (in)  Argument strings.  These represent the entire widget 
  15763.            command, of which the first word is typically the widget name and 
  15764.            the second word is typically xview or yview.  This procedure parses 
  15765.            arguments starting with argv[2]. 
  15766.  
  15767.  double  *dblPtr (out)  Filled in with fraction from moveto option, if any. 
  15768.  
  15769.  int  *intPtr (out)  Filled in with line or page count from scroll option, if 
  15770.            any. The value may be negative. 
  15771.  
  15772.  DESCRIPTION 
  15773.  
  15774.  Tk_GetScrollInfo parses the arguments expected by widget scrolling commands 
  15775.  such as xview and yview. It receives the entire list of words that make up a 
  15776.  widget command and parses the words starting with argv[2]. The words starting 
  15777.  with argv[2] must have one of the following forms: 
  15778.  
  15779.   moveto fraction
  15780.   scroll number units
  15781.   scroll number pages
  15782.  
  15783.  Any of the moveto, scroll, units, and pages keywords may be abbreviated. If 
  15784.  argv has the moveto form, TK_SCROLL_MOVETO is returned as result and *dblPtr 
  15785.  is filled in with the fraction argument to the command, which must be a proper 
  15786.  real value. If argv has the scroll form, TK_SCROLL_UNITS or TK_SCROLL_PAGES is 
  15787.  returned and *intPtr is filled in with the number value, which must be a 
  15788.  proper integer. If an error occurs in parsing the arguments, TK_SCROLL_ERROR 
  15789.  is returned and an error message is left in interp->result. 
  15790.  
  15791.  KEYWORDS 
  15792.  
  15793.  parse, scrollbar, scrolling command, xview, yview 
  15794.  
  15795.  
  15796. ΓòÉΓòÉΓòÉ 5.40. Tk_GetSelection ΓòÉΓòÉΓòÉ
  15797.  
  15798.  NAME 
  15799.  
  15800. Tk_GetSelection - retrieve the contents of a selection 
  15801.  
  15802. SYNOPSIS 
  15803.  
  15804. #include <tk.h> 
  15805.  
  15806.  int 
  15807.  Tk_GetSelection(interp, tkwin, selection, target, proc, clientData) 
  15808.  
  15809. ARGUMENTS 
  15810.  
  15811.  Tcl_Interp  *interp (in)  Interpreter to use for reporting errors. 
  15812.  
  15813.  Tk_Window  tkwin (in)  Window on whose behalf to retrieve the selection 
  15814.            (determines display from which to retrieve). 
  15815.  
  15816.  Atom  selection (in)  The name of the selection to be retrieved. 
  15817.  
  15818.  Atom  target (in)  Form in which to retrieve selection. 
  15819.  
  15820.  Tk_GetSelProc  *proc (in)  Procedure to invoke to process pieces of the 
  15821.            selection as they are retrieved. 
  15822.  
  15823.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  15824.  
  15825.  DESCRIPTION 
  15826.  
  15827.  Tk_GetSelection retrieves the selection specified by the atom selection in the 
  15828.  format specified by target.  The selection may actually be retrieved in 
  15829.  several pieces; as each piece is retrieved, proc is called to process the 
  15830.  piece.  Proc should have arguments and result that match the type 
  15831.  Tk_GetSelProc: 
  15832.  
  15833.   typedef int Tk_GetSelProc(
  15834.          ClientData clientData,
  15835.          Tcl_Interp *interp,
  15836.          char *portion);
  15837.  The clientData and interp parameters to proc will be copies of the 
  15838.  corresponding arguments to Tk_GetSelection.  Portion will be a pointer to a 
  15839.  string containing part or all of the selection.  For large selections, proc 
  15840.  will be called several times with successive portions of the selection.  The X 
  15841.  Inter-Client Communication Conventions Manual allows a selection to be 
  15842.  returned in formats other than strings, e.g. as an array of atoms or integers. 
  15843.  If this happens, Tk converts the selection back into a string before calling 
  15844.  proc.  If a selection is returned as an array of atoms, Tk converts it to a 
  15845.  string containing the atom names separated by white space.  For any other 
  15846.  format besides string, Tk converts a selection to a string containing 
  15847.  hexadecimal values separated by white space. 
  15848.  
  15849.  Tk_GetSelection returns to its caller when the selection has been completely 
  15850.  retrieved and processed by proc, or when a fatal error has occurred (e.g. the 
  15851.  selection owner didn't respond promptly).  Tk_GetSelection normally returns 
  15852.  TCL_OK;  if an error occurs, it returns TCL_ERROR and leaves an error message 
  15853.  in interp->result.  Proc should also return either TCL_OK or TCL_ERROR. If 
  15854.  proc encounters an error in dealing with the selection, it should leave an 
  15855.  error message in interp->result and return TCL_ERROR;  this will abort the 
  15856.  selection retrieval. 
  15857.  
  15858.  KEYWORDS 
  15859.  
  15860.  format, get, selection retrieval 
  15861.  
  15862.  
  15863. ΓòÉΓòÉΓòÉ 5.41. Tk_GetUid ΓòÉΓòÉΓòÉ
  15864.  
  15865.  NAME 
  15866.  
  15867. Tk_GetUid, Tk_Uid - convert from string to unique identifier 
  15868.  
  15869. SYNOPSIS 
  15870.  
  15871. #include <tk.h> 
  15872.  
  15873.  #typedef char *Tk_Uid 
  15874.  
  15875.  Tk_Uid 
  15876.  Tk_GetUid(string) 
  15877.  
  15878. ARGUMENTS 
  15879.  
  15880.  char  *string (in)  String for which the corresponding unique identifier is 
  15881.            desired. 
  15882.  
  15883.  DESCRIPTION 
  15884.  
  15885.  Tk_GetUid returns the unique identifier corresponding to string. Unique 
  15886.  identifiers are similar to atoms in Lisp, and are used in Tk to speed up 
  15887.  comparisons and searches.  A unique identifier (type Tk_Uid) is a string 
  15888.  pointer and may be used anywhere that a variable of type "char *" could be 
  15889.  used.  However, there is guaranteed to be exactly one unique identifier for 
  15890.  any given string value.  If Tk_GetUid is called twice, once with string a and 
  15891.  once with string b, and if a and b have the same string value (strcmp(a, b) == 
  15892.  0), then Tk_GetUid will return exactly the same Tk_Uid value for each call 
  15893.  (Tk_GetUid(a) == Tk_GetUid(b)). This means that variables of type Tk_Uid may 
  15894.  be compared directly (x == y) without having to call strcmp. In addition, the 
  15895.  return value from Tk_GetUid will have the same string value as its argument 
  15896.  (strcmp(Tk_GetUid(a), a) == 0). 
  15897.  
  15898.  KEYWORDS 
  15899.  
  15900.  atom, unique identifier 
  15901.  
  15902.  
  15903. ΓòÉΓòÉΓòÉ 5.42. Tk_GetVRootGeometry ΓòÉΓòÉΓòÉ
  15904.  
  15905.  NAME 
  15906.  
  15907. Tk_GetVRootGeometry - Get location and size of virtual root for window 
  15908.  
  15909. SYNOPSIS 
  15910.  
  15911. #include <tk.h> 
  15912.  
  15913.  Tk_GetVRootGeometry(tkwin, xPtr, yPtr, widthPtr, heightPtr) 
  15914.  
  15915. ARGUMENTS 
  15916.  
  15917.  Tk_Window  tkwin (in)  Token for window whose virtual root is to be queried. 
  15918.  
  15919.  int  xPtr (out)  Points to word in which to store x-offset of virtual root. 
  15920.  
  15921.  int  yPtr (out)  Points to word in which to store y-offset of virtual root. 
  15922.  
  15923.  int  widthPtr (out)  Points to word in which to store width of virtual root. 
  15924.  
  15925.  int  heightPtr (out)  Points to word in which to store height of virtual root. 
  15926.  
  15927.  DESCRIPTION 
  15928.  
  15929.  TkGetVRootGeometry returns geometry information about the virtual root window 
  15930.  associated with tkwin.  The "associated" virtual root is the one in which 
  15931.  tkwin's nearest top-level ancestor (or tkwin itself if it is a top-level 
  15932.  window) has been reparented by the window manager.  This window is identified 
  15933.  by a __SWM_ROOT or __WM_ROOT property placed on the top-level window by the 
  15934.  window manager. If tkwin is not associated with a virtual root (e.g. because 
  15935.  the window manager doesn't use virtual roots) then *xPtr and *yPtr will be set 
  15936.  to 0 and *widthPtr and *heightPtr will be set to the dimensions of the screen 
  15937.  containing tkwin. 
  15938.  
  15939.  KEYWORDS 
  15940.  
  15941.  geometry, height, location, virtual root, width, window manager 
  15942.  
  15943.  
  15944. ΓòÉΓòÉΓòÉ 5.43. Tk_GetVisual ΓòÉΓòÉΓòÉ
  15945.  
  15946.  NAME 
  15947.  
  15948. Tk_GetVisual - translate from string to visual 
  15949.  
  15950. SYNOPSIS 
  15951.  
  15952. #include <tk.h> 
  15953.  
  15954.  Visual * 
  15955.  Tk_GetVisual(interp, tkwin, string, depthPtr, colormapPtr) 
  15956.  
  15957. ARGUMENTS 
  15958.  
  15959.  Tcl_Interp  *interp (in)  Interpreter to use for error reporting. 
  15960.  
  15961.  Tk_Window  tkwin (in)  Token for window in which the visual will be used. 
  15962.  
  15963.  char  *string (in)  String that identifies the desired visual.  See below for 
  15964.            valid formats. 
  15965.  
  15966.  int  *depthPtr (out)  Depth of returned visual gets stored here. 
  15967.  
  15968.  Colormap  *colormapPtr (out)  If non-NULL then a suitable colormap for visual 
  15969.            is found and its identifier is stored here. 
  15970.  
  15971.  DESCRIPTION 
  15972.  
  15973.  Tk_GetVisual takes a string description of a visual and finds a suitable X 
  15974.  Visual for use in tkwin, if there is one. It returns a pointer to the X Visual 
  15975.  structure for the visual and stores the number of bits per pixel for it at 
  15976.  *depthPtr. If string is unrecognizable or if no suitable visual could be 
  15977.  found, then NULL is returned and Tk_GetVisual leaves an error message in 
  15978.  interp->result. If colormap is non-NULL then Tk_GetVisual also locates an 
  15979.  appropriate colormap for use with the result visual and stores its X 
  15980.  identifier at *colormapPtr. 
  15981.  
  15982.  The string argument specifies the desired visual in one of the following ways: 
  15983.  
  15984.  class depth  The string consists of a class name followed by an integer depth, 
  15985.            with any amount of white space (including none) in between. class 
  15986.            selects what sort of visual is desired and must be one of 
  15987.            directcolor, grayscale, greyscale, pseudocolor, staticcolor, 
  15988.            staticgray, staticgrey, or truecolor, or a unique abbreviation. 
  15989.            depth specifies how many bits per pixel are needed for the visual. 
  15990.            If possible, Tk_GetVisual will return a visual with this depth; if 
  15991.            there is no visual of the desired depth then Tk_GetVisual looks 
  15992.            first for a visual with greater depth, then one with less depth. 
  15993.  
  15994.  default   Use the default visual for tkwin's screen. 
  15995.  
  15996.  pathName  Use the visual for the window given by pathName. pathName must be 
  15997.            the name of a window on the same screen as tkwin. 
  15998.  
  15999.  number    Use the visual whose X identifier is number. 
  16000.  
  16001.  best ?depth?  Choose the "best possible" visual, using the following rules, in 
  16002.            decreasing order of priority: (a) a visual that has exactly the 
  16003.            desired depth is best, followed by a visual with greater depth than 
  16004.            requested (but as little extra as possible), followed by a visual 
  16005.            with less depth than requested (but as great a depth as possible); 
  16006.            (b) if no depth is specified, then the deepest available visual is 
  16007.            chosen; (c) pseudocolor is better than truecolor or directcolor, 
  16008.            which are better than staticcolor, which is better than staticgray 
  16009.            or grayscale; (d) the default visual for the screen is better than 
  16010.            any other visual. 
  16011.  
  16012.  CREDITS 
  16013.  
  16014.  The idea for Tk_GetVisual, and the first implementation, came from Paul 
  16015.  Mackerras. 
  16016.  
  16017.  KEYWORDS 
  16018.  
  16019.  colormap, screen, visual 
  16020.  
  16021.  
  16022. ΓòÉΓòÉΓòÉ 5.44. Tk_HandleEvent ΓòÉΓòÉΓòÉ
  16023.  
  16024.  NAME 
  16025.  
  16026. Tk_HandleEvent - invoke event handlers for window system events 
  16027.  
  16028. SYNOPSIS 
  16029.  
  16030. #include <tk.h> 
  16031.  
  16032.  Tk_HandleEvent(eventPtr) 
  16033.  
  16034. ARGUMENTS 
  16035.  
  16036.  XEvent  *eventPtr (in)  Pointer to X event to dispatch to relevant handler(s). 
  16037.  
  16038.  DESCRIPTION 
  16039.  
  16040.  Tk_HandleEvent is a lower-level procedure that deals with window events.  It 
  16041.  is called by Tk_ServiceEvent (and indirectly by Tk_DoOneEvent), and in a few 
  16042.  other cases within Tk. It makes callbacks to any window event handlers 
  16043.  (created by calls to Tk_CreateEventHandler) that match eventPtr and then 
  16044.  returns.  In some cases it may be useful for an application to bypass the Tk 
  16045.  event queue and call Tk_HandleEvent directly instead of calling Tk_QueueEvent 
  16046.  followed by Tk_ServiceEvent. 
  16047.  
  16048.  This procedure may be invoked recursively.  For example, it is possible to 
  16049.  invoke Tk_HandleEvent recursively from a handler called by Tk_HandleEvent. 
  16050.  This sort of operation is useful in some modal situations, such as when a 
  16051.  notifier has been popped up and an application wishes to wait for the user to 
  16052.  click a button in the notifier before doing anything else. 
  16053.  
  16054.  KEYWORDS 
  16055.  
  16056.  callback, event, handler, window 
  16057.  
  16058.  
  16059. ΓòÉΓòÉΓòÉ 5.45. Tk_IdToWindow ΓòÉΓòÉΓòÉ
  16060.  
  16061.  NAME 
  16062.  
  16063. Tk_IdToWindow - Find Tk's window information for an X window 
  16064.  
  16065. SYNOPSIS 
  16066.  
  16067. #include <tk.h> 
  16068.  
  16069.  Tk_Window 
  16070.  Tk_IdToWindow(display, window) 
  16071.  
  16072. ARGUMENTS 
  16073.  
  16074.  Display  *display (in)  X display containing the window. 
  16075.  
  16076.  Window  window (in)  X id for window. 
  16077.  
  16078.  DESCRIPTION 
  16079.  
  16080.  Given an X window identifier and the X display it corresponds to, this 
  16081.  procedure returns the corresponding Tk_Window handle. If there is no Tk_Window 
  16082.  corresponding to window then NULL is returned. 
  16083.  
  16084.  KEYWORDS 
  16085.  
  16086.  X window id 
  16087.  
  16088.  
  16089. ΓòÉΓòÉΓòÉ 5.46. Tk_ImageChanged ΓòÉΓòÉΓòÉ
  16090.  
  16091.  NAME 
  16092.  
  16093. Tk_ImageChanged - notify widgets that image needs to be redrawn 
  16094.  
  16095. SYNOPSIS 
  16096.  
  16097. #include <tk.h> 
  16098.  
  16099.  Tk_ImageChanged(imageMaster, x, y, width, height, imageWidth, imageHeight) 
  16100.  
  16101. ARGUMENTS 
  16102.  
  16103.  Tk_ImageMaster  imageMaster (in)  Token for image, which was passed to image's 
  16104.            createProc when the image was created. 
  16105.  
  16106.  int  x (in)  X-coordinate of upper-left corner of region that needs redisplay 
  16107.            (measured from upper-left corner of image). 
  16108.  
  16109.  int  y (in)  Y-coordinate of upper-left corner of region that needs redisplay 
  16110.            (measured from upper-left corner of image). 
  16111.  
  16112.  int  width (in)  Width of region that needs to be redrawn, in pixels. 
  16113.  
  16114.  int  height (in)  Height of region that needs to be redrawn, in pixels. 
  16115.  
  16116.  int  imageWidth (in)  Current width of image, in pixels. 
  16117.  
  16118.  int  imageHeight (in)  Current height of image, in pixels. 
  16119.  
  16120.  DESCRIPTION 
  16121.  
  16122.  An image manager calls Tk_ImageChanged for an image whenever anything happens 
  16123.  that requires the image to be redrawn. As a result of calling Tk_ImageChanged, 
  16124.  any widgets using the image are notified so that they can redisplay themselves 
  16125.  appropriately. The imageMaster argument identifies the image, and x, y, width, 
  16126.  and height specify a rectangular region within the image that needs to be 
  16127.  redrawn. imageWidth and imageHeight specify the image's (new) size. 
  16128.  
  16129.  An image manager should call Tk_ImageChanged during its createProc to specify 
  16130.  the image's initial size and to force redisplay if there are existing 
  16131.  instances for the image. If any of the pixel values in the image should change 
  16132.  later on, Tk_ImageChanged should be called again with x, y, width, and height 
  16133.  values that cover all the pixels that changed. If the size of the image should 
  16134.  change, then Tk_ImageChanged must be called to indicate the new size, even if 
  16135.  no pixels need to be redisplayed. 
  16136.  
  16137.  SEE ALSO 
  16138.  
  16139.  Tk_CreateImageType 
  16140.  
  16141.  KEYWORDS 
  16142.  
  16143.  images, redisplay, image size changes 
  16144.  
  16145.  
  16146. ΓòÉΓòÉΓòÉ 5.47. Tk_InternAtom ΓòÉΓòÉΓòÉ
  16147.  
  16148.  NAME 
  16149.  
  16150. Tk_InternAtom, Tk_GetAtomName - manage cache of X atoms 
  16151.  
  16152. SYNOPSIS 
  16153.  
  16154. #include <tk.h> 
  16155.  
  16156.  Atom 
  16157.  Tk_InternAtom(tkwin, name) 
  16158.  
  16159.  char * 
  16160.  Tk_GetAtomName(tkwin, atom) 
  16161.  
  16162. ARGUMENTS 
  16163.  
  16164.  Tk_Window  tkwin (in)  Token for window.  Used to map atom or name relative to 
  16165.            a particular display. 
  16166.  
  16167.  char  *name (in)  String name for which atom is desired. 
  16168.  
  16169.  Atom  atom (in)  Atom for which corresponding string name is desired. 
  16170.  
  16171.  DESCRIPTION 
  16172.  
  16173.  These procedures are similar to the Xlib procedures XInternAtom and 
  16174.  XGetAtomName.  Tk_InternAtom returns the atom identifier associated with 
  16175.  string given by name;  the atom identifier is only valid for the display 
  16176.  associated with tkwin. Tk_GetAtomName returns the string associated with atom 
  16177.  on tkwin's display.  The string returned by Tk_GetAtomName is in Tk's storage: 
  16178.  the caller need not free this space when finished with the string, and the 
  16179.  caller should not modify the contents of the returned string. If there is no 
  16180.  atom atom on tkwin's display, then Tk_GetAtomName returns the string "?bad 
  16181.  atom?". 
  16182.  
  16183.  Tk caches the information returned by Tk_InternAtom and Tk_GetAtomName so that 
  16184.  future calls for the same information can be serviced from the cache without 
  16185.  contacting the server.  Thus Tk_InternAtom and Tk_GetAtomName are generally 
  16186.  much faster than their Xlib counterparts, and they should be used in place of 
  16187.  the Xlib procedures. 
  16188.  
  16189.  KEYWORDS 
  16190.  
  16191.  atom, cache, display 
  16192.  
  16193.  
  16194. ΓòÉΓòÉΓòÉ 5.48. Tk_MainLoop ΓòÉΓòÉΓòÉ
  16195.  
  16196.  NAME 
  16197.  
  16198. Tk_MainLoop - loop for events until all windows are deleted 
  16199.  
  16200. SYNOPSIS 
  16201.  
  16202. #include <tk.h> 
  16203.  
  16204.  Tk_MainLoop() 
  16205.  
  16206. DESCRIPTION 
  16207.  
  16208. Tk_MainLoop is a procedure that loops repeatedly calling Tcl_DoOneEvent.  It 
  16209. returns only when there are no applications left in this process (i.e. no main 
  16210. windows exist anymore).  Most windowing applications will call Tk_MainLoop 
  16211. after initialization; the main execution of the application will consist 
  16212. entirely of callbacks invoked via Tcl_DoOneEvent. 
  16213.  
  16214. KEYWORDS 
  16215.  
  16216. application, event, main loop 
  16217.  
  16218.  
  16219. ΓòÉΓòÉΓòÉ 5.49. Tk_MainWindow ΓòÉΓòÉΓòÉ
  16220.  
  16221.  NAME 
  16222.  
  16223. Tk_MainWindow - find the main window for an application 
  16224.  
  16225. SYNOPSIS 
  16226.  
  16227. #include <tk.h> 
  16228.  
  16229.  Tk_Window 
  16230.  Tk_MainWindow(interp) 
  16231.  
  16232. ARGUMENTS 
  16233.  
  16234.  Tcl_Interp  *interp (in/out)  Interpreter associated with the application. 
  16235.  
  16236.  DESCRIPTION 
  16237.  
  16238.  If interp is associated with a Tk application then Tk_MainWindow returns the 
  16239.  application's main window. If there is no Tk application associated with 
  16240.  interp then Tk_MainWindow returns NULL and leaves an error message in 
  16241.  interp->result. 
  16242.  
  16243.  KEYWORDS 
  16244.  
  16245.  application, main window 
  16246.  
  16247.  
  16248. ΓòÉΓòÉΓòÉ 5.50. Tk_MaintainGeometry ΓòÉΓòÉΓòÉ
  16249.  
  16250.  NAME 
  16251.  
  16252. Tk_MaintainGeometry, Tk_UnmaintainGeometry - maintain geometry of one window 
  16253. relative to another 
  16254.  
  16255. SYNOPSIS 
  16256.  
  16257. #include <tk.h> 
  16258.  
  16259.  Tk_MaintainGeometry(slave, master, x, y, width, height) 
  16260.  
  16261.  Tk_UnmaintainGeometry(slave, master) 
  16262.  
  16263. ARGUMENTS 
  16264.  
  16265.  Tk_Window  slave (in)  Window whose geometry is to be controlled. 
  16266.  
  16267.  Tk_Window  master (in)  Window relative to which slave's geometry will be 
  16268.            controlled. 
  16269.  
  16270.  int  x (in)  Desired x-coordinate of slave in master, measured in pixels from 
  16271.            the inside of master's left border to the outside of slave's left 
  16272.            border. 
  16273.  
  16274.  int  y (in)  Desired y-coordinate of slave in master, measured in pixels from 
  16275.            the inside of master's top border to the outside of slave's top 
  16276.            border. 
  16277.  
  16278.  int  width (in)  Desired width for slave, in pixels. 
  16279.  
  16280.  int  height (in)  Desired height for slave, in pixels. 
  16281.  
  16282.  DESCRIPTION 
  16283.  
  16284.  Tk_MaintainGeometry and Tk_UnmaintainGeometry make it easier for geometry 
  16285.  managers to deal with slaves whose masters are not their parents. Three 
  16286.  problems arise if the master for a slave is not its parent: 
  16287.  
  16288.    1. The x- and y-position of the slave must be translated from the coordinate 
  16289.       system of the master to that of the parent before positioning the slave. 
  16290.  
  16291.    2. If the master window, or any of its ancestors up to the slave's parent, 
  16292.       is moved, then the slave must be repositioned within its parent in order 
  16293.       to maintain the correct position relative to the master. 
  16294.  
  16295.    3. If the master or one of its ancestors is mapped or unmapped, then the 
  16296.       slave must be mapped or unmapped to correspond. 
  16297.  
  16298.  None of these problems is an issue if the parent and master are the same.  For 
  16299.  example, if the master or one of its ancestors is unmapped, the slave is 
  16300.  automatically removed by the screen by X. 
  16301.  
  16302.  Tk_MaintainGeometry deals with these problems for slaves whose masters aren't 
  16303.  their parents. Tk_MaintainGeometry is typically called by a window manager 
  16304.  once it has decided where a slave should be positioned relative to its master. 
  16305.  Tk_MaintainGeometry translates the coordinates to the coordinate system of 
  16306.  slave's parent and then moves and resizes the slave appropriately. 
  16307.  Furthermore, it remembers the desired position and creates event handlers to 
  16308.  monitor the master and all of its ancestors up to (but not including) the 
  16309.  slave's parent. If any of these windows is moved, mapped, or unmapped, the 
  16310.  slave will be adjusted so that it is mapped only when the master is mapped and 
  16311.  its geometry relative to the master remains as specified by x, y, width, and 
  16312.  height. 
  16313.  
  16314.  When a window manager relinquishes control over a window, or if it decides 
  16315.  that it does not want the window to appear on the screen under any conditions, 
  16316.  it calls Tk_UnmaintainGeometry. Tk_UnmaintainGeometry unmaps the window and 
  16317.  cancels any previous calls to Tk_MaintainGeometry for the master-slave pair, 
  16318.  so that the slave's geometry and mapped state are no longer maintained 
  16319.  automatically. Tk_UnmaintainGeometry need not be called by a geometry manager 
  16320.  if the slave, the master, or any of the master's ancestors is destroyed:  Tk 
  16321.  will call it automatically. 
  16322.  
  16323.  If Tk_MaintainGeometry is called repeatedly for the same master-slave pair, 
  16324.  the information from the most recent call supersedes any older information. If 
  16325.  Tk_UnmaintainGeometry is called for a master-slave pair that is isn't 
  16326.  currently managed, the call has no effect. 
  16327.  
  16328.  KEYWORDS 
  16329.  
  16330.  geometry manager, map, master, parent, position, slave, unmap 
  16331.  
  16332.  
  16333. ΓòÉΓòÉΓòÉ 5.51. Tk_ManageGeometry ΓòÉΓòÉΓòÉ
  16334.  
  16335.  NAME 
  16336.  
  16337. Tk_ManageGeometry - arrange to handle geometry requests for a window 
  16338.  
  16339. SYNOPSIS 
  16340.  
  16341. #include <tk.h> 
  16342.  
  16343.  Tk_ManageGeometry(tkwin, mgrPtr, clientData) 
  16344.  
  16345. ARGUMENTS 
  16346.  
  16347.  Tk_Window  tkwin (in)  Token for window to be managed. 
  16348.  
  16349.  Tk_GeomMgr  *mgrPtr (in)  Pointer to data structure containing information 
  16350.            about the geometry manager, or NULL to indicate that tkwin's 
  16351.            geometry shouldn't be managed anymore. The data structure pointed to 
  16352.            by mgrPtr must be static: Tk keeps a reference to it as long as the 
  16353.            window is managed. 
  16354.  
  16355.  ClientData  clientData (in)  Arbitrary one-word value to pass to geometry 
  16356.            manager callbacks. 
  16357.  
  16358.  DESCRIPTION 
  16359.  
  16360.  Tk_ManageGeometry arranges for a particular geometry manager, described by the 
  16361.  mgrPtr argument, to control the geometry of a particular slave window, given 
  16362.  by tkwin. If tkwin was previously managed by some other geometry manager, the 
  16363.  previous manager loses control in favor of the new one. If mgrPtr is NULL, 
  16364.  geometry management is cancelled for tkwin. 
  16365.  
  16366.  The structure pointed to by mgrPtr contains information about the geometry 
  16367.  manager: 
  16368.  
  16369.   typedef struct {
  16370.          char *name;
  16371.          Tk_GeomRequestProc *requestProc;
  16372.          Tk_GeomLostSlaveProc *lostSlaveProc;
  16373.   } Tk_GeomMgr;
  16374.  The name field is the textual name for the geometry manager, such as pack or 
  16375.  place;  this value will be returned by the command winfo manager. 
  16376.  
  16377.  requestProc is a procedure in the geometry manager that will be invoked 
  16378.  whenever Tk_GeometryRequest is called by the slave to change its desired 
  16379.  geometry. requestProc should have arguments and results that match the type 
  16380.  Tk_GeomRequestProc: 
  16381.  
  16382.   typedef void Tk_GeomRequestProc(
  16383.          ClientData clientData,
  16384.          Tk_Window tkwin);
  16385.  The parameters to requestProc will be identical to the corresponding 
  16386.  parameters passed to Tk_ManageGeometry. clientData usually points to a data 
  16387.  structure containing application-specific information about how to manage 
  16388.  tkwin's geometry. 
  16389.  
  16390.  The lostSlaveProc field of mgrPtr points to another procedure in the geometry 
  16391.  manager. Tk will invoke lostSlaveProc if some other manager calls 
  16392.  Tk_ManageGeometry to claim tkwin away from the current geometry manager. 
  16393.  lostSlaveProc is not invoked if Tk_ManageGeometry is called with a NULL value 
  16394.  for mgrPtr (presumably the current geometry manager has made this call, so it 
  16395.  already knows that the window is no longer managed), nor is it called if 
  16396.  mgrPtr is the same as the window's current geometry manager. lostSlaveProc 
  16397.  should have arguments and results that match the following prototype: 
  16398.  
  16399.   typedef void Tk_GeomLostSlaveProc(
  16400.          ClientData clientData,
  16401.          Tk_Window tkwin);
  16402.  The parameters to lostSlaveProc will be identical to the corresponding 
  16403.  parameters passed to Tk_ManageGeometry. 
  16404.  
  16405.  KEYWORDS 
  16406.  
  16407.  callback, geometry, managed, request, unmanaged 
  16408.  
  16409.  
  16410. ΓòÉΓòÉΓòÉ 5.52. Tk_MapWindow ΓòÉΓòÉΓòÉ
  16411.  
  16412.  NAME 
  16413.  
  16414. Tk_MapWindow, Tk_UnmapWindow - map or unmap a window 
  16415.  
  16416. SYNOPSIS 
  16417.  
  16418. #include <tk.h> 
  16419.  
  16420.  Tk_Window 
  16421.  Tk_MapWindow(tkwin) 
  16422.  
  16423.  Tk_UnmapWindow(tkwin) 
  16424.  
  16425. ARGUMENTS 
  16426.  
  16427.  Tk_Window  tkwin (in)  Token for window. 
  16428.  
  16429.  DESCRIPTION 
  16430.  
  16431.  These procedures may be used to map and unmap windows managed by Tk. 
  16432.  Tk_MapWindow maps the window given by tkwin, and also creates an X window 
  16433.  corresponding to tkwin if it doesn't already exist.  See the Tk_CreateWindow 
  16434.  manual entry for information on deferred window creation. Tk_UnmapWindow 
  16435.  unmaps tkwin's window from the screen. 
  16436.  
  16437.  If tkwin is a child window (i.e. Tk_CreateChildWindow was used to create it), 
  16438.  then event handlers interested in map and unmap events are invoked 
  16439.  immediately.  If tkwin isn't an internal window, then the event handlers will 
  16440.  be invoked later, after X has seen the request and returned an event for it. 
  16441.  
  16442.  These procedures should be used in place of the X procedures XMapWindow and 
  16443.  XUnmapWindow, since they update Tk's local data structure for tkwin. 
  16444.  Applications using Tk should not invoke XMapWindow and XUnmapWindow directly. 
  16445.  
  16446.  KEYWORDS 
  16447.  
  16448.  map, unmap, window 
  16449.  
  16450.  
  16451. ΓòÉΓòÉΓòÉ 5.53. Tk_MoveToplevelWindow ΓòÉΓòÉΓòÉ
  16452.  
  16453.  NAME 
  16454.  
  16455. Tk_MoveToplevelWindow - Adjust the position of a top-level window 
  16456.  
  16457. SYNOPSIS 
  16458.  
  16459. #include <tk.h> 
  16460.  
  16461.  Tk_MoveToplevelWindow(tkwin, x, y) 
  16462.  
  16463. ARGUMENTS 
  16464.  
  16465.  Tk_Window  tkwin (in)  Token for top-level window to move. 
  16466.  
  16467.  int  x (in)  New x-coordinate for the top-left pixel of tkwin's border, or the 
  16468.            top-left pixel of the decorative border supplied for tkwin by the 
  16469.            window manager, if there is one. 
  16470.  
  16471.  int  y (in)  New y-coordinate for the top-left pixel of tkwin's border, or the 
  16472.            top-left pixel of the decorative border supplied for tkwin by the 
  16473.            window manager, if there is one. 
  16474.  
  16475.  DESCRIPTION 
  16476.  
  16477.  In general, a window should never set its own position;  this should be done 
  16478.  only by the geometry manger that is responsible for the window. For top-level 
  16479.  windows the window manager is effectively the geometry manager;  Tk provides 
  16480.  interface code between the application and the window manager to convey the 
  16481.  application's desires to the geometry manager.  The desired size for a 
  16482.  top-level window is conveyed using the usual Tk_GeometryRequest mechanism. 
  16483.  The procedure Tk_MoveToplevelWindow may be used by an application to request a 
  16484.  particular position for a top-level window;  this procedure is similar in 
  16485.  function to the wm geometry Tcl command except that negative offsets cannot be 
  16486.  specified.  It is invoked by widgets such as menus that want to appear at a 
  16487.  particular place on the screen. 
  16488.  
  16489.  When Tk_MoveToplevelWindow is called it doesn't immediately pass on the new 
  16490.  desired location to the window manager;  it defers this action until all other 
  16491.  outstanding work has been completed, using the Tk_DoWhenIdle mechanism. 
  16492.  
  16493.  KEYWORDS 
  16494.  
  16495.  position, top-level window, window manager 
  16496.  
  16497.  
  16498. ΓòÉΓòÉΓòÉ 5.54. Tk_Name ΓòÉΓòÉΓòÉ
  16499.  
  16500.  NAME 
  16501.  
  16502. Tk_Name, Tk_PathName, Tk_NameToWindow - convert between names and window tokens 
  16503.  
  16504. SYNOPSIS 
  16505.  
  16506. #include <tk.h> 
  16507.  
  16508.  Tk_Uid 
  16509.  Tk_Name(tkwin) 
  16510.  
  16511.  char * 
  16512.  Tk_PathName(tkwin) 
  16513.  
  16514.  Tk_Window 
  16515.  Tk_NameToWindow(interp, pathName, tkwin) 
  16516.  
  16517. ARGUMENTS 
  16518.  
  16519.  Tk_Window  tkwin (in)  Token for window. 
  16520.  
  16521.  Tcl_Interp  *interp (out)  Interpreter to use for error reporting. 
  16522.  
  16523.  char  *pathName (in)  Character string containing path name of window. 
  16524.  
  16525.  DESCRIPTION 
  16526.  
  16527.  Each window managed by Tk has two names, a short name that identifies a window 
  16528.  among children of the same parent, and a path name that identifies the window 
  16529.  uniquely among all the windows belonging to the same main window.  The path 
  16530.  name is used more often in Tk than the short name;  many commands, like bind, 
  16531.  expect path names as arguments. 
  16532.  
  16533.  The Tk_Name macro returns a window's short name, which is the same as the name 
  16534.  argument passed to Tk_CreateWindow when the window was created.  The value is 
  16535.  returned as a Tk_Uid, which may be used just like a string pointer but also 
  16536.  has the properties of a unique identifier (see the manual entry for Tk_GetUid 
  16537.  for details). 
  16538.  
  16539.  The Tk_PathName macro returns a hierarchical name for tkwin. Path names have a 
  16540.  structure similar to file names in Unix but with dots between elements instead 
  16541.  of slashes:  the main window for an application has the path name ".";  its 
  16542.  children have names like ".a" and ".b"; their children have names like ".a.aa" 
  16543.  and ".b.bb"; and so on.  A window is considered to be be a child of another 
  16544.  window for naming purposes if the second window was named as the first 
  16545.  window's parent when the first window was created. This is not always the same 
  16546.  as the X window hierarchy.  For example, a pop-up is created as a child of the 
  16547.  root window, but its logical parent will usually be a window within the 
  16548.  application. 
  16549.  
  16550.  The procedure Tk_NameToWindow returns the token for a window given its path 
  16551.  name (the pathName argument) and another window belonging to the same main 
  16552.  window (tkwin).  It normally returns a token for the named window, but if no 
  16553.  such window exists Tk_NameToWindow leaves an error message in interp->result 
  16554.  and returns NULL.  The tkwin argument to Tk_NameToWindow is needed because 
  16555.  path names are only unique within a single application hierarchy.  If, for 
  16556.  example, a single process has opened two main windows, each will have a 
  16557.  separate naming hierarchy and the same path name might appear in each of the 
  16558.  hierarchies.  Normally tkwin is the main window of the desired hierarchy, but 
  16559.  this need not be the case:  any window in the desired hierarchy may be used. 
  16560.  
  16561.  KEYWORDS 
  16562.  
  16563.  name, path name, token, window 
  16564.  
  16565.  
  16566. ΓòÉΓòÉΓòÉ 5.55. Tk_NameOfImage ΓòÉΓòÉΓòÉ
  16567.  
  16568.  NAME 
  16569.  
  16570. Tk_NameOfImage - Return name of image. 
  16571.  
  16572. SYNOPSIS 
  16573.  
  16574. #include <tk.h> 
  16575.  
  16576.  char * 
  16577.  Tk_NameOfImage(typePtr) 
  16578.  
  16579. ARGUMENTS 
  16580.  
  16581.  Tk_ImageMaster  *masterPtr (in)  Token for image, which was passed to image 
  16582.            manager's createProc when the image was created. 
  16583.  
  16584.  DESCRIPTION 
  16585.  
  16586.  This procedure is invoked by image managers to find out the name of an image. 
  16587.  Given the token for the image, it returns the string name for the image. 
  16588.  
  16589.  KEYWORDS 
  16590.  
  16591.  image manager, image name 
  16592.  
  16593.  
  16594. ΓòÉΓòÉΓòÉ 5.56. Tk_OwnSelection ΓòÉΓòÉΓòÉ
  16595.  
  16596.  NAME 
  16597.  
  16598. Tk_OwnSelection - make a window the owner of the primary selection 
  16599.  
  16600. SYNOPSIS 
  16601.  
  16602. #include <tk.h> 
  16603.  
  16604.  Tk_OwnSelection(tkwin, selection, proc, clientData) 
  16605.  
  16606. ARGUMENTS 
  16607.  
  16608.  Tk_Window  tkwin (in)  Window that is to become new selection owner. 
  16609.  
  16610.  Atom  selection (in)  The name of the selection to be owned, such as 
  16611.            XA_PRIMARY. 
  16612.  
  16613.  Tk_LostSelProc  *proc (in)  Procedure to invoke when tkwin loses selection 
  16614.            ownership later. 
  16615.  
  16616.  ClientData  clientData (in)  Arbitrary one-word value to pass to proc. 
  16617.  
  16618.  DESCRIPTION 
  16619.  
  16620.  Tk_OwnSelection arranges for tkwin to become the new owner of the selection 
  16621.  specified by the atom selection.  After this call completes, future requests 
  16622.  for the selection will be directed to handlers created for tkwin using 
  16623.  Tk_CreateSelHandler.  When tkwin eventually loses the selection ownership, 
  16624.  proc will be invoked so that the window can clean itself up (e.g. by 
  16625.  unhighlighting the selection).  Proc should have arguments and result that 
  16626.  match the type Tk_LostSelProc: 
  16627.  
  16628.   typedef void Tk_LostSelProc(ClientData clientData);
  16629.  The clientData parameter to proc is a copy of the clientData argument given to 
  16630.  Tk_OwnSelection, and is usually a pointer to a data structure containing 
  16631.  application-specific information about tkwin. 
  16632.  
  16633.  KEYWORDS 
  16634.  
  16635.  own, selection owner 
  16636.  
  16637.  
  16638. ΓòÉΓòÉΓòÉ 5.57. Tk_ParseArgv ΓòÉΓòÉΓòÉ
  16639.  
  16640.  NAME 
  16641.  
  16642. Tk_ParseArgv - process command-line options 
  16643.  
  16644. SYNOPSIS 
  16645.  
  16646. #include <tk.h> 
  16647.  
  16648.  int 
  16649.  Tk_ParseArgv(interp, tkwin, argcPtr, argv, argTable, flags) 
  16650.  
  16651. ARGUMENTS 
  16652.  
  16653.  Tcl_Interp  *interp (in)  Interpreter to use for returning error messages. 
  16654.  
  16655.  Tk_Window  tkwin (in)  Window to use when arguments specify Tk options.  If 
  16656.            NULL, then no Tk options will be processed. 
  16657.  
  16658.  int  argcPtr (in/out)  Pointer to number of arguments in argv;  gets modified 
  16659.            to hold number of unprocessed arguments that remain after the call. 
  16660.  
  16661.  char  **argv (in/out)  Command line arguments passed to main program. 
  16662.            Modified to hold unprocessed arguments that remain after the call. 
  16663.  
  16664.  Tk_ArgvInfo  *argTable (in)  Array of argument descriptors, terminated by 
  16665.            element with type TK_ARGV_END. 
  16666.  
  16667.  int  flags (in)  If non-zero, then it specifies one or more flags that control 
  16668.            the parsing of arguments.  Different flags may be OR'ed together. 
  16669.            The flags currently defined are TK_ARGV_DONT_SKIP_FIRST_ARG, 
  16670.            TK_ARGV_NO_ABBREV, TK_ARGV_NO_LEFTOVERS, and TK_ARGV_NO_DEFAULTS. 
  16671.  
  16672.  DESCRIPTION 
  16673.  
  16674.  Tk_ParseArgv processes an array of command-line arguments according to a table 
  16675.  describing the kinds of arguments that are expected. Each of the arguments in 
  16676.  argv is processed in turn:  if it matches one of the entries in argTable, the 
  16677.  argument is processed according to that entry and discarded.  The arguments 
  16678.  that do not match anything in argTable are copied down to the beginning of 
  16679.  argv (retaining their original order) and returned to the caller.  At the end 
  16680.  of the call Tk_ParseArgv sets *argcPtr to hold the number of arguments that 
  16681.  are left in argv, and argv[*argcPtr] will hold the value NULL.  Normally, 
  16682.  Tk_ParseArgv assumes that argv[0] is a command name, so it is treated like an 
  16683.  argument that doesn't match argTable and returned to the caller;  however, if 
  16684.  the TK_ARGV_DONT_SKIP_FIRST_ARG bit is set in flags then argv[0] will be 
  16685.  processed just like the other elements of argv. 
  16686.  
  16687.  Tk_ParseArgv normally returns the value TCL_OK.  If an error occurs while 
  16688.  parsing the arguments, then TCL_ERROR is returned and Tk_ParseArgv will leave 
  16689.  an error message in interp->result in the standard Tcl fashion.  In the event 
  16690.  of an error return, *argvPtr will not have been modified, but argv could have 
  16691.  been partially modified.  The possible causes of errors are explained below. 
  16692.  
  16693.  The argTable array specifies the kinds of arguments that are expected;  each 
  16694.  of its entries has the following structure: 
  16695.  
  16696.   typedef struct {
  16697.          char *key;
  16698.          int type;
  16699.          char *src;
  16700.          char *dst;
  16701.          char *help;
  16702.   } Tk_ArgvInfo;
  16703.  The key field is a string such as "-display" or "-bg" that is compared with 
  16704.  the values in argv.  Type indicates how to process an argument that matches 
  16705.  key (more on this below).  Src and dst are additional values used in 
  16706.  processing the argument.  Their exact usage depends on type, but typically src 
  16707.  indicates a value and dst indicates where to store the value.  The char * 
  16708.  declarations for src and dst are placeholders:  the actual types may be 
  16709.  different.  Lastly, help is a string giving a brief description of this 
  16710.  option;  this string is printed when users ask for help about command-line 
  16711.  options. 
  16712.  
  16713.  When processing an argument in argv, Tk_ParseArgv compares the argument to 
  16714.  each of the key's in argTable. Tk_ParseArgv selects the first specifier whose 
  16715.  key matches the argument exactly, if such a specifier exists.  Otherwise 
  16716.  Tk_ParseArgv selects a specifier for which the argument is a unique 
  16717.  abbreviation.  If the argument is a unique abbreviation for more than one 
  16718.  specifier, then an error is returned.  If there is no matching entry in 
  16719.  argTable, then the argument is skipped and returned to the caller. 
  16720.  
  16721.  Once a matching argument specifier is found, Tk_ParseArgv processes the 
  16722.  argument according to the type field of the specifier.  The argument that 
  16723.  matched key is called "the matching argument" in the descriptions below.  As 
  16724.  part of the processing, Tk_ParseArgv may also use the next argument in argv 
  16725.  after the matching argument, which is called "the following argument".  The 
  16726.  legal values for type, and the processing that they cause, are as follows: 
  16727.  
  16728.  TK_ARGV_END  Marks the end of the table.  The last entry in argTable must have 
  16729.            this type;  all of its other fields are ignored and it will never 
  16730.            match any arguments. 
  16731.  
  16732.  TK_ARGV_CONSTANT  Src is treated as an integer and dst is treated as a pointer 
  16733.            to an integer.  Src is stored at *dst. The matching argument is 
  16734.            discarded. 
  16735.  
  16736.  TK_ARGV_INT  The following argument must contain an integer string in the 
  16737.            format accepted by strtol (e.g. "0" and "0x" prefixes may be used to 
  16738.            specify octal or hexadecimal numbers, respectively).  Dst is treated 
  16739.            as a pointer to an integer;  the following argument is converted to 
  16740.            an integer value and stored at *dst.  Src is ignored.  The matching 
  16741.            and following arguments are discarded from argv. 
  16742.  
  16743.  TK_ARGV_FLOAT  The following argument must contain a floating-point number in 
  16744.            the format accepted by strtol. Dst is treated as the address of an 
  16745.            double-precision floating point value;  the following argument is 
  16746.            converted to a double-precision value and stored at *dst.  The 
  16747.            matching and following arguments are discarded from argv. 
  16748.  
  16749.  TK_ARGV_STRING  In this form, dst is treated as a pointer to a (char *); 
  16750.            Tk_ParseArgv stores at *dst a pointer to the following argument, and 
  16751.            discards the matching and following arguments from argv.  Src is 
  16752.            ignored. 
  16753.  
  16754.  TK_ARGV_UID  This form is similar to TK_ARGV_STRING, except that the argument 
  16755.            is turned into a Tk_Uid by calling Tk_GetUid. Dst is treated as a 
  16756.            pointer to a Tk_Uid; Tk_ParseArgv stores at *dst the Tk_Uid 
  16757.            corresponding to the following argument, and discards the matching 
  16758.            and following arguments from argv.  Src is ignored. 
  16759.  
  16760.  TK_ARGV_CONST_OPTION  This form causes a Tk option to be set (as if the option 
  16761.            command had been invoked).  The src field is treated as a pointer to 
  16762.            a string giving the value of an option, and dst is treated as a 
  16763.            pointer to the name of the option.  The matching argument is 
  16764.            discarded.  If tkwin is NULL, then argument specifiers of this type 
  16765.            are ignored (as if they did not exist). 
  16766.  
  16767.  TK_ARGV_OPTION_VALUE  This form is similar to TK_ARGV_CONST_OPTION, except 
  16768.            that the value of the option is taken from the following argument 
  16769.            instead of from src.  Dst is used as the name of the option. Src is 
  16770.            ignored.  The matching and following arguments are discarded.  If 
  16771.            tkwin is NULL, then argument specifiers of this type are ignored (as 
  16772.            if they did not exist). 
  16773.  
  16774.  TK_ARGV_OPTION_NAME_VALUE  In this case the following argument is taken as the 
  16775.            name of a Tk option and the argument after that is taken as the 
  16776.            value for that option.  Both src and dst are ignored.  All three 
  16777.            arguments are discarded from argv.  If tkwin is NULL, then argument 
  16778.            specifiers of this type are ignored (as if they did not exist). 
  16779.  
  16780.  TK_ARGV_HELP  When this kind of option is encountered, Tk_ParseArgv uses the 
  16781.            help fields of argTable to format a message describing all the valid 
  16782.            arguments.  The message is placed in interp->result and Tk_ParseArgv 
  16783.            returns TCL_ERROR.  When this happens, the caller normally prints 
  16784.            the help message and aborts.  If the key field of a TK_ARGV_HELP 
  16785.            specifier is NULL, then the specifier will never match any 
  16786.            arguments;  in this case the specifier simply provides extra 
  16787.            documentation, which will be included when some other TK_ARGV_HELP 
  16788.            entry causes help information to be returned. 
  16789.  
  16790.  TK_ARGV_REST  This option is used by programs or commands that allow the last 
  16791.            several of their options to be the name and/or options for some 
  16792.            other program.  If a TK_ARGV_REST argument is found, then 
  16793.            Tk_ParseArgv doesn't process any of the remaining arguments;  it 
  16794.            returns them all at the beginning of argv (along with any other 
  16795.            unprocessed arguments). In addition, Tk_ParseArgv treats dst as the 
  16796.            address of an integer value, and stores at *dst the index of the 
  16797.            first of the TK_ARGV_REST options in the returned argv.  This allows 
  16798.            the program to distinguish the TK_ARGV_REST options from other 
  16799.            unprocessed options that preceded the TK_ARGV_REST. 
  16800.  
  16801.  TK_ARGV_FUNC  For this kind of argument, src is treated as the address of a 
  16802.            procedure, which is invoked to process the following argument. The 
  16803.            procedure should have the following structure: 
  16804.  
  16805.                       int
  16806.                       func(dst, key, nextArg)
  16807.                              char *dst;
  16808.                              char *key;
  16809.                              char *nextArg;
  16810.                       {
  16811.                       }
  16812.            The dst and key parameters will contain the corresponding fields 
  16813.            from the argTable entry, and nextArg will point to the following 
  16814.            argument from argv (or NULL if there aren't any more arguments left 
  16815.            in argv). If func uses nextArg (so that Tk_ParseArgv should discard 
  16816.            it), then it should return 1.  Otherwise it should return 0 and 
  16817.            TkParseArgv will process the following argument in the normal 
  16818.            fashion.  In either event the matching argument is discarded. 
  16819.  
  16820.  TK_ARGV_GENFUNC  This form provides a more general procedural escape.  It 
  16821.            treats src as the address of a procedure, and passes that procedure 
  16822.            all of the remaining arguments.  The procedure should have the 
  16823.            following form: 
  16824.  
  16825.                       int
  16826.                       genfunc(dst, interp, key, argc, argv)
  16827.                              char *dst;
  16828.                              Tcl_Interp *interp;
  16829.                              char *key;
  16830.                              int argc;
  16831.                              char **argv;
  16832.                       {
  16833.                       }
  16834.            The dst and key parameters will contain the corresponding fields 
  16835.            from the argTable entry.  Interp will be the same as the interp 
  16836.            argument to Tcl_ParseArgv. Argc and argv refer to all of the options 
  16837.            after the matching one.  Genfunc should behave in a fashion similar 
  16838.            to Tk_ParseArgv:  parse as many of the remaining arguments as it 
  16839.            can, then return any that are left by compacting them to the 
  16840.            beginning of argv (starting at argv[0]).  Genfunc should return a 
  16841.            count of how many arguments are left in argv; Tk_ParseArgv will 
  16842.            process them.  If genfunc encounters an error then it should leave 
  16843.            an error message in interp->result, in the usual Tcl fashion, and 
  16844.            return -1;  when this happens Tk_ParseArgv will abort its processing 
  16845.            and return TCL_ERROR. 
  16846.  
  16847.  FLAGS 
  16848.  
  16849.  TK_ARGV_DONT_SKIP_FIRST_ARG  Tk_ParseArgv normally treats argv[0] as a program 
  16850.            or command name, and returns it to the caller just as if it hadn't 
  16851.            matched argTable.  If this flag is given, then argv[0] is not given 
  16852.            special treatment. 
  16853.  
  16854.  TK_ARGV_NO_ABBREV  Normally, Tk_ParseArgv accepts unique abbreviations for key 
  16855.            values in argTable.  If this flag is given then only exact matches 
  16856.            will be acceptable. 
  16857.  
  16858.  TK_ARGV_NO_LEFTOVERS  Normally, Tk_ParseArgv returns unrecognized arguments to 
  16859.            the caller.  If this bit is set in flags then Tk_ParseArgv will 
  16860.            return an error if it encounters any argument that doesn't match 
  16861.            argTable.  The only exception to this rule is argv[0], which will be 
  16862.            returned to the caller with no errors as long as 
  16863.            TK_ARGV_DONT_SKIP_FIRST_ARG isn't specified. 
  16864.  
  16865.  TK_ARGV_NO_DEFAULTS  Normally, Tk_ParseArgv searches an internal table of 
  16866.            standard argument specifiers in addition to argTable.  If this bit 
  16867.            is set in flags, then Tk_ParseArgv will use only argTable and not 
  16868.            its default table. 
  16869.  
  16870.  EXAMPLE 
  16871.  
  16872.  Here is an example definition of an argTable and some sample command lines 
  16873.  that use the options.  Note the effect on argc and argv;  arguments processed 
  16874.  by Tk_ParseArgv are eliminated from argv, and argc is updated to reflect 
  16875.  reduced number of arguments. 
  16876.  
  16877.   /*
  16878.    * Define and set default values for globals.
  16879.    */
  16880.   int debugFlag = 0;
  16881.   int numReps = 100;
  16882.   char defaultFileName[] = "out";
  16883.   char *fileName = defaultFileName;
  16884.   Boolean exec = FALSE;
  16885.  
  16886.   /*
  16887.    * Define option descriptions.
  16888.    */
  16889.   Tk_ArgvInfo argTable[] = {
  16890.          {"-X", TK_ARGV_CONSTANT, (char *) 1, (char *) &debugFlag,
  16891.                 "Turn on debugging printfs"},
  16892.          {"-N", TK_ARGV_INT, (char *) NULL, (char *) &numReps,
  16893.                 "Number of repetitions"},
  16894.          {"-of", TK_ARGV_STRING, (char *) NULL, (char *) &fileName,
  16895.                 "Name of file for output"},
  16896.          {"x", TK_ARGV_REST, (char *) NULL, (char *) &exec,
  16897.                 "File to exec, followed by any arguments (must be last argument)."},
  16898.          {(char *) NULL, TK_ARGV_END, (char *) NULL, (char *) NULL,
  16899.              (char *) NULL}
  16900.   };
  16901.  
  16902.   main(argc, argv)
  16903.          int argc;
  16904.          char *argv[];
  16905.   {
  16906.          ...
  16907.  
  16908.          if (Tk_ParseArgv(interp, tkwin, &argc, argv, argTable, 0) != TCL_OK) {
  16909.                 fprintf(stderr, "%s\n", interp->result);
  16910.                 exit(1);
  16911.          }
  16912.  
  16913.          /*
  16914.           * Remainder of the program.
  16915.           */
  16916.   }
  16917.  
  16918.  Note that default values can be assigned to variables named in argTable:  the 
  16919.  variables will only be overwritten if the particular arguments are present in 
  16920.  argv. Here are some example command lines and their effects. 
  16921.  
  16922.   prog -N 200 infile          # just sets the numReps variable to 200
  16923.   prog -of out200 infile      # sets fileName to reference "out200"
  16924.   prog -XN 10 infile          # sets the debug flag, also sets numReps
  16925.  In all of the above examples, argc will be set by Tk_ParseArgv to 2, argv[0] 
  16926.  will be "prog", argv[1] will be "infile", and argv[2] will be NULL. 
  16927.  
  16928.  KEYWORDS 
  16929.  
  16930.  arguments, command line, options 
  16931.  
  16932.  
  16933. ΓòÉΓòÉΓòÉ 5.58. Tk_QueueWindowEvent ΓòÉΓòÉΓòÉ
  16934.  
  16935.  NAME 
  16936.  
  16937. Tk_QueueWindowEvent - Add a window event to the Tcl event queue 
  16938.  
  16939. SYNOPSIS 
  16940.  
  16941. #include <tk.h> 
  16942.  
  16943.  Tk_QueueWindowEvent(eventPtr, position) 
  16944.  
  16945. ARGUMENTS 
  16946.  
  16947.  XEvent  *eventPtr (in)  An event to add to the event queue. 
  16948.  
  16949.  Tcl_QueuePosition  position (in)  Where to add the new event in the queue: 
  16950.            TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, or TCL_QUEUE_MARK. 
  16951.  
  16952.  DESCRIPTION 
  16953.  
  16954.  This procedure places a window event on Tcl's internal event queue for 
  16955.  eventual servicing.  It creates a Tcl_Event structure, copies the event into 
  16956.  that structure, and calls Tcl_QueueEvent to add the event to the queue. When 
  16957.  the event is eventually removed from the queue it is processed just like all 
  16958.  window events. 
  16959.  
  16960.  The position argument to Tk_QueueWindowEvent has the same significance as for 
  16961.  Tcl_QueueEvent;  see the documentation for Tcl_QueueEvent for details. 
  16962.  
  16963.  KEYWORDS 
  16964.  
  16965.  callback, clock, handler, modal timeout 
  16966.  
  16967.  
  16968. ΓòÉΓòÉΓòÉ 5.59. Tk_RestackWindow ΓòÉΓòÉΓòÉ
  16969.  
  16970.  NAME 
  16971.  
  16972. Tk_RestackWindow - Change a window's position in the stacking order 
  16973.  
  16974. SYNOPSIS 
  16975.  
  16976. #include <tk.h> 
  16977.  
  16978.  int 
  16979.  Tk_RestackWindow(tkwin, aboveBelow, other) 
  16980.  
  16981. ARGUMENTS 
  16982.  
  16983.  Tk_Window  tkwin (in)  Token for window to restack. 
  16984.  
  16985.  int  aboveBelow (in)  Indicates new position of tkwin relative to other; must 
  16986.            be Above or Below. 
  16987.  
  16988.  Tk_Window  other (in)  Tkwin will be repositioned just above or below this 
  16989.            window. Must be a sibling of tkwin or a descendant of a sibling. If 
  16990.            NULL then tkwin is restacked above or below all siblings. 
  16991.  
  16992.  DESCRIPTION 
  16993.  
  16994.  Tk_RestackWindow changes the stacking order of window relative to its 
  16995.  siblings. If other is specified as NULL then window is repositioned at the top 
  16996.  or bottom of its stacking order, depending on whether aboveBelow is Above or 
  16997.  Below. If other has a non-NULL value then window is repositioned just above or 
  16998.  below other. 
  16999.  
  17000.  The aboveBelow argument must have one of the symbolic values Above or Below. 
  17001.  Both of these values are defined by the include file <X11/Xlib.h>. 
  17002.  
  17003.  KEYWORDS 
  17004.  
  17005.  above, below, obscure, stacking order 
  17006.  
  17007.  
  17008. ΓòÉΓòÉΓòÉ 5.60. Tk_RestrictEvents ΓòÉΓòÉΓòÉ
  17009.  
  17010.  NAME 
  17011.  
  17012. Tk_RestrictEvents - filter and selectively delay X events 
  17013.  
  17014. SYNOPSIS 
  17015.  
  17016. #include <tk.h> 
  17017.  
  17018.  Tk_RestrictProc * 
  17019.  Tk_RestrictEvents(proc, clientData, prevClientDataPtr) 
  17020.  
  17021. ARGUMENTS 
  17022.  
  17023.  Tk_RestrictProc  *proc (in)  Predicate procedure to call to filter incoming X 
  17024.            events. NULL means do not restrict events at all. 
  17025.  
  17026.  ClientData  clientData (in)  Arbitrary argument to pass to proc. 
  17027.  
  17028.  ClientData  *prevClientDataPtr (out)  Pointer to place to save argument to 
  17029.            previous restrict procedure. 
  17030.  
  17031.  DESCRIPTION 
  17032.  
  17033.  This procedure is useful in certain situations where applications are only 
  17034.  prepared to receive certain X events.  After Tk_RestrictEvents is called, 
  17035.  Tk_DoOneEvent (and hence Tk_MainLoop) will filter X input events through proc. 
  17036.  Proc indicates whether a given event is to be processed immediately, deferred 
  17037.  until some later time (e.g. when the event restriction is lifted), or 
  17038.  discarded. Proc is a procedure with arguments and result that match the type 
  17039.  Tk_RestrictProc: 
  17040.  
  17041.   typedef Tk_RestrictAction Tk_RestrictProc(
  17042.          ClientData clientData,
  17043.          XEvent *eventPtr);
  17044.  The clientData argument is a copy of the clientData passed to 
  17045.  Tk_RestrictEvents; it may be used to provide proc with information it needs to 
  17046.  filter events.  The eventPtr points to an event under consideration.  Proc 
  17047.  returns a restrict action (enumerated type Tk_RestrictAction) that indicates 
  17048.  what Tk_DoOneEvent should do with the event.  If the return value is 
  17049.  TK_PROCESS_EVENT, then the event will be handled immediately. If the return 
  17050.  value is TK_DEFER_EVENT, then the event will be left on the event queue for 
  17051.  later processing.  If the return value is TK_DISCARD_EVENT, then the event 
  17052.  will be removed from the event queue and discarded without being processed. 
  17053.  
  17054.  Tk_RestrictEvents uses its return value and prevClientDataPtr to return 
  17055.  information about the current event restriction procedure (a NULL return value 
  17056.  means there are currently no restrictions). These values may be used to 
  17057.  restore the previous restriction state when there is no longer any need for 
  17058.  the current restriction. 
  17059.  
  17060.  There are very few places where Tk_RestrictEvents is needed. In most cases, 
  17061.  the best way to restrict events is by changing the bindings with the bind Tcl 
  17062.  command or by calling Tk_CreateEventHandler and Tk_DeleteEventHandler from C. 
  17063.  The main place where Tk_RestrictEvents must be used is when performing 
  17064.  synchronous actions (for example, if you need to wait for a particular event 
  17065.  to occur on a particular window but you don't want to invoke any handlers for 
  17066.  any other events).  The "obvious" solution in these situations is to call 
  17067.  XNextEvent or XWindowEvent, but these procedures cannot be used because Tk 
  17068.  keeps its own event queue that is separate from the X event queue.  Instead, 
  17069.  call Tk_RestrictEvents to set up a filter, then call Tk_DoOneEvent to retrieve 
  17070.  the desired event(s). 
  17071.  
  17072.  KEYWORDS 
  17073.  
  17074.  delay, event, filter, restriction 
  17075.  
  17076.  
  17077. ΓòÉΓòÉΓòÉ 5.61. Tk_SetAppName ΓòÉΓòÉΓòÉ
  17078.  
  17079.  NAME 
  17080.  
  17081. Tk_SetAppName - Set the name of an application for "send" commands 
  17082.  
  17083. SYNOPSIS 
  17084.  
  17085. #include <tk.h> 
  17086.  
  17087.  char * 
  17088.  Tk_SetAppName(tkwin, name) 
  17089.  
  17090. ARGUMENTS 
  17091.  
  17092.  Tk_Window  tkwin (in)  Token for window in application.  Used only to select a 
  17093.            particular application. 
  17094.  
  17095.  char  *name (in)  Name under which to register the application. 
  17096.  
  17097.  DESCRIPTION 
  17098.  
  17099.  Tk_SetAppName associates a name with a given application and records that 
  17100.  association on the display containing with the application's main window. 
  17101.  After this procedure has been invoked, other applications on the display will 
  17102.  be able to use the send command to invoke operations in the application. If 
  17103.  name is already in use by some other application on the display, then a new 
  17104.  name will be generated by appending " #2" to name;  if this name is also in 
  17105.  use, the number will be incremented until an unused name is found. The return 
  17106.  value from the procedure is a pointer to the name actually used. 
  17107.  
  17108.  If the application already has a name when Tk_SetAppName is called, then the 
  17109.  new name replaces the old name. 
  17110.  
  17111.  Tk_SetAppName also adds a send command to the application's interpreter, which 
  17112.  can be used to send commands from this application to others on any of the 
  17113.  displays where the application has windows. 
  17114.  
  17115.  The application's name registration persists until the interpreter is deleted 
  17116.  or the send command is deleted from interp, at which point the name is 
  17117.  automatically unregistered and the application becomes inaccessible via send. 
  17118.  The application can be made accessible again by calling Tk_SetAppName. 
  17119.  
  17120.  Tk_SetAppName is called automatically by Tk_Init, so applications don't 
  17121.  normally need to call it explicitly. 
  17122.  
  17123.  The command tk appname provides Tcl-level access to the functionality of 
  17124.  Tk_SetAppName. 
  17125.  
  17126.  KEYWORDS 
  17127.  
  17128.  application, name, register, send command 
  17129.  
  17130.  
  17131. ΓòÉΓòÉΓòÉ 5.62. Tk_SetClass ΓòÉΓòÉΓòÉ
  17132.  
  17133.  NAME 
  17134.  
  17135. Tk_SetClass, Tk_Class - set or retrieve a window's class 
  17136.  
  17137. SYNOPSIS 
  17138.  
  17139. #include <tk.h> 
  17140.  
  17141.  Tk_SetClass(tkwin, class) 
  17142.  
  17143.  Tk_Uid 
  17144.  Tk_Class(tkwin) 
  17145.  
  17146. ARGUMENTS 
  17147.  
  17148.  Tk_Window  tkwin (in)  Token for window. 
  17149.  
  17150.  char  *class (in)  New class name for window. 
  17151.  
  17152.  DESCRIPTION 
  17153.  
  17154.  Tk_SetClass is called to associate a class with a particular window.  The 
  17155.  class string identifies the type of the window;  all windows with the same 
  17156.  general class of behavior (button, menu, etc.) should have the same class.  By 
  17157.  convention all class names start with a capital letter, and there exists a Tcl 
  17158.  command with the same name as each class (except all in lower-case) which can 
  17159.  be used to create and manipulate windows of that class. A window's class 
  17160.  string is initialized to NULL when the window is created. 
  17161.  
  17162.  For main windows, Tk automatically propagates the name and class to the 
  17163.  WM_CLASS property used by window managers.  This happens either when a main 
  17164.  window is actually created (e.g. in Tk_MakeWindowExist), or when Tk_SetClass 
  17165.  is called, whichever occurs later.  If a main window has not been assigned a 
  17166.  class then Tk will not set the WM_CLASS property for the window. 
  17167.  
  17168.  Tk_Class is a macro that returns the current value of tkwin's class.  The 
  17169.  value is returned as a Tk_Uid, which may be used just like a string pointer 
  17170.  but also has the properties of a unique identifier (see the manual entry for 
  17171.  Tk_GetUid for details). If tkwin has not yet been given a class, then Tk_Class 
  17172.  will return NULL. 
  17173.  
  17174.  KEYWORDS 
  17175.  
  17176.  class, unique identifier, window, window manager 
  17177.  
  17178.  
  17179. ΓòÉΓòÉΓòÉ 5.63. Tk_SetGrid ΓòÉΓòÉΓòÉ
  17180.  
  17181.  NAME 
  17182.  
  17183. Tk_SetGrid, Tk_UnsetGrid - control the grid for interactive resizing 
  17184.  
  17185. SYNOPSIS 
  17186.  
  17187. #include <tk.h> 
  17188.  
  17189.  Tk_SetGrid(tkwin, reqWidth, reqHeight, widthInc, heightInc) 
  17190.  
  17191.  Tk_UnsetGrid(tkwin) 
  17192.  
  17193. ARGUMENTS 
  17194.  
  17195.  Tk_Window  tkwin (in)  Token for window. 
  17196.  
  17197.  int  reqWidth (in)  Width in grid units that corresponds to the pixel 
  17198.            dimension tkwin has requested via Tk_GeometryRequest. 
  17199.  
  17200.  int  reqHeight (in)  Height in grid units that corresponds to the pixel 
  17201.            dimension tkwin has requested via Tk_GeometryRequest. 
  17202.  
  17203.  int  widthInc (in)  Width of one grid unit, in pixels. 
  17204.  
  17205.  int  heightInc (in)  Height of one grid unit, in pixels. 
  17206.  
  17207.  DESCRIPTION 
  17208.  
  17209.  Tk_SetGrid turns on gridded geometry management for tkwin's toplevel window 
  17210.  and specifies the geometry of the grid. Tk_SetGrid is typically invoked by a 
  17211.  widget when its setGrid option is true. It restricts interactive resizing of 
  17212.  tkwin's toplevel window so that the space allocated to the toplevel is equal 
  17213.  to its requested size plus or minus even multiples of widthInc and heightInc. 
  17214.  Furthermore, the reqWidth and reqHeight values are passed to the window 
  17215.  manager so that it can report the window's size in grid units during 
  17216.  interactive resizes. If tkwin's configuration changes (e.g., the size of a 
  17217.  grid unit changes) then the widget should invoke Tk_SetGrid again with the new 
  17218.  information. 
  17219.  
  17220.  Tk_UnsetGrid cancels gridded geometry management for tkwin's toplevel window. 
  17221.  
  17222.  For each toplevel window there can be at most one internal window with 
  17223.  gridding enabled. If Tk_SetGrid or Tk_UnsetGrid is invoked when some other 
  17224.  window is already controlling gridding for tkwin's toplevel, the calls for the 
  17225.  new window have no effect. 
  17226.  
  17227.  See the wm manual entry for additional information on gridded geometry 
  17228.  management. 
  17229.  
  17230.  KEYWORDS 
  17231.  
  17232.  grid, window, window manager 
  17233.  
  17234.  
  17235. ΓòÉΓòÉΓòÉ 5.64. Tk_SetWindowVisual ΓòÉΓòÉΓòÉ
  17236.  
  17237.  NAME 
  17238.  
  17239. Tk_SetWindowVisual - change visual characteristics of window 
  17240.  
  17241. SYNOPSIS 
  17242.  
  17243. #include <tk.h> 
  17244.  
  17245.  int 
  17246.  Tk_SetWindowVisual(tkwin, visual, depth, colormap) 
  17247.  
  17248. ARGUMENTS 
  17249.  
  17250.  Tk_Window  tkwin (in)  Token for window. 
  17251.  
  17252.  Visual  *visual (in)  New visual type to use for tkwin. 
  17253.  
  17254.  int  depth (in)  Number of bits per pixel desired for tkwin. 
  17255.  
  17256.  Colormap  colormap (in)  New colormap for tkwin, which must be compatible with 
  17257.            visual and depth. 
  17258.  
  17259.  DESCRIPTION 
  17260.  
  17261.  When Tk creates a new window it assigns it the default visual characteristics 
  17262.  (visual, depth, and colormap) for its screen. Tk_SetWindowVisual may be called 
  17263.  to change them. Tk_SetWindowVisual must be called before the window has 
  17264.  actually been created in X (e.g. before Tk_MapWindow or Tk_MakeWindowExist has 
  17265.  been invoked for the window). The safest thing is to call Tk_SetWindowVisual 
  17266.  immediately after calling Tk_CreateWindow. If tkwin has already been created 
  17267.  before Tk_SetWindowVisual is called then it returns 0 and doesn't make any 
  17268.  changes;  otherwise it returns 1 to signify that the operation completed 
  17269.  successfully. 
  17270.  
  17271.  Note:  Tk_SetWindowVisual should not be called if you just want to change a 
  17272.  window's colormap without changing its visual or depth; call 
  17273.  Tk_SetWindowColormap instead. 
  17274.  
  17275.  KEYWORDS 
  17276.  
  17277.  colormap, depth, visual 
  17278.  
  17279.  
  17280. ΓòÉΓòÉΓòÉ 5.65. Tk_StrictMotif ΓòÉΓòÉΓòÉ
  17281.  
  17282.  NAME 
  17283.  
  17284. Tk_StrictMotif - Return value of tk_strictMotif variable 
  17285.  
  17286. SYNOPSIS 
  17287.  
  17288. #include <tk.h> 
  17289.  
  17290.  int 
  17291.  Tk_StrictMotif(tkwin) 
  17292.  
  17293. ARGUMENTS 
  17294.  
  17295.  Tk_Window  tkwin (in)  Token for window. 
  17296.  
  17297.  DESCRIPTION 
  17298.  
  17299.  This procedure returns the current value of the tk_strictMotif variable in the 
  17300.  interpreter associated with tkwin's application. The value is returned as an 
  17301.  integer that is either 0 or 1. 1 means that strict Motif compliance has been 
  17302.  requested, so anything that is not part of the Motif specification should be 
  17303.  avoided. 0 means that "Motif-like" is good enough, and extra features are 
  17304.  welcome. 
  17305.  
  17306.  This procedure uses a link to the Tcl variable to provide much faster access 
  17307.  to the variable's value than could be had by calling Tcl_GetVar. 
  17308.  
  17309.  KEYWORDS 
  17310.  
  17311.  Motif compliance, tk_strictMotif variable 
  17312.  
  17313.  
  17314. ΓòÉΓòÉΓòÉ 5.66. Tk_Init ΓòÉΓòÉΓòÉ
  17315.  
  17316.  NAME 
  17317.  
  17318. Tk_Init - add Tk to an interpreter and make a new Tk application. 
  17319.  
  17320. SYNOPSIS 
  17321.  
  17322. #include <tk.h> 
  17323.  
  17324.  int 
  17325.  Tk_Init(interp) 
  17326.  
  17327. ARGUMENTS 
  17328.  
  17329.  Tcl_Interp  *interp (in)  Interpreter in which to load Tk.  Tk should not 
  17330.            already be loaded in this interpreter. 
  17331.  
  17332.  DESCRIPTION 
  17333.  
  17334.  Tk_Init is the package initialization procedure for Tk. It is normally invoked 
  17335.  by the Tcl_AppInit procedure for an application or by the load command. 
  17336.  Tk_Init adds all of Tk's commands to interp and creates a new Tk application, 
  17337.  including its main window. If the initialization is successful Tk_Init returns 
  17338.  TCL_OK;  if there is an error it returns TCL_ERROR. Tk_Init also leaves a 
  17339.  result or error message in interp->result. 
  17340.  
  17341.  If there is a variable argv in interp, Tk_Init treats the contents of this 
  17342.  variable as a list of options for the new Tk application. The options may have 
  17343.  any of the forms documented for the wish application (in fact, wish uses 
  17344.  Tk_Init to process its command-line arguments). 
  17345.  
  17346.  KEYWORDS 
  17347.  
  17348.  application, initialization, load, main window 
  17349.  
  17350.  
  17351. ΓòÉΓòÉΓòÉ 5.67. Tk_Main ΓòÉΓòÉΓòÉ
  17352.  
  17353.  NAME 
  17354.  
  17355. Tk_Main - main program for Tk-based applications 
  17356.  
  17357. SYNOPSIS 
  17358.  
  17359. #include <tk.h> 
  17360.  
  17361.  Tk_Main(argc, argv, appInitProc) 
  17362.  
  17363. ARGUMENTS 
  17364.  
  17365.  int  argc (in)  Number of elements in argv. 
  17366.  
  17367.  char  *argv[] (in)  Array of strings containing command-line arguments. 
  17368.  
  17369.  Tcl_AppInitProc  *appInitProc (in)  Address of an application-specific 
  17370.            initialization procedure. The value for this argument is usually 
  17371.            Tcl_AppInit. 
  17372.  
  17373.  DESCRIPTION 
  17374.  
  17375.  Tk_Main acts as the main program for most Tk-based applications. Starting with 
  17376.  Tk 4.0 it is not called main anymore because it is part of the Tk library and 
  17377.  having a function main in a library (particularly a shared library) causes 
  17378.  problems on many systems. Having main in the Tk library would also make it 
  17379.  hard to use Tk in C++ programs, since C++ programs must have special C++ main 
  17380.  functions. 
  17381.  
  17382.  Normally each application contains a small main function that does nothing but 
  17383.  invoke Tk_Main. Tk_Main then does all the work of creating and running a 
  17384.  wish-like application. 
  17385.  
  17386.  When it is has finished its own initialization, but before it processes 
  17387.  commands, Tk_Main calls the procedure given by the appInitProc argument.  This 
  17388.  procedure provides a "hook" for the application to perform its own 
  17389.  initialization, such as defining application-specific commands.  The procedure 
  17390.  must have an interface that matches the type Tcl_AppInitProc: 
  17391.  
  17392.   typedef int Tcl_AppInitProc(Tcl_Interp *interp);
  17393.  AppInitProc is almost always a pointer to Tcl_AppInit; for more details on 
  17394.  this procedure, see the documentation for Tcl_AppInit. 
  17395.  
  17396.  KEYWORDS 
  17397.  
  17398.  application-specific initialization, command-line arguments, main program 
  17399.  
  17400.  
  17401. ΓòÉΓòÉΓòÉ 5.68. Tk_WindowId ΓòÉΓòÉΓòÉ
  17402.  
  17403.  NAME 
  17404.  
  17405. Tk_WindowId, Tk_Parent, Tk_Display, Tk_DisplayName, Tk_ScreenNumber, Tk_Screen, 
  17406. Tk_X, Tk_Y, Tk_Width, Tk_Height, Tk_Changes, Tk_Attributes, Tk_IsMapped, 
  17407. Tk_IsTopLevel,  Tk_ReqWidth, Tk_ReqHeight, Tk_InternalBorderWidth, Tk_Visual, 
  17408. Tk_Depth, Tk_Colormap  - retrieve information from Tk's local data structure 
  17409.  
  17410. SYNOPSIS 
  17411.  
  17412. #include <tk.h> 
  17413.  
  17414.  Window 
  17415.  Tk_WindowId(tkwin) 
  17416.  
  17417.  Tk_Window 
  17418.  Tk_Parent(tkwin) 
  17419.  
  17420.  Display * 
  17421.  Tk_Display(tkwin) 
  17422.  
  17423.  char * 
  17424.  Tk_DisplayName(tkwin) 
  17425.  
  17426.  int 
  17427.  Tk_ScreenNumber(tkwin) 
  17428.  
  17429.  Screen * 
  17430.  Tk_Screen(tkwin) 
  17431.  
  17432.  int 
  17433.  Tk_X(tkwin) 
  17434.  
  17435.  int 
  17436.  Tk_Y(tkwin) 
  17437.  
  17438.  int 
  17439.  Tk_Width(tkwin) 
  17440.  
  17441.  int 
  17442.  Tk_Height(tkwin) 
  17443.  
  17444.  XWindowChanges * 
  17445.  Tk_Changes(tkwin) 
  17446.  
  17447.  XSetWindowAttributes * 
  17448.  Tk_Attributes(tkwin) 
  17449.  
  17450.  int 
  17451.  Tk_IsMapped(tkwin) 
  17452.  
  17453.  int 
  17454.  Tk_IsTopLevel(tkwin) 
  17455.  
  17456.  int 
  17457.  Tk_ReqWidth(tkwin) 
  17458.  
  17459.  int 
  17460.  Tk_ReqHeight(tkwin) 
  17461.  
  17462.  int 
  17463.  Tk_InternalBorderWidth(tkwin) 
  17464.  
  17465.  Visual * 
  17466.  Tk_Visual(tkwin) 
  17467.  
  17468.  int 
  17469.  Tk_Depth(tkwin) 
  17470.  
  17471.  Colormap 
  17472.  Tk_Colormap(tkwin) 
  17473.  
  17474. ARGUMENTS 
  17475.  
  17476.  Tk_Window  tkwin (in)  Token for window. 
  17477.  
  17478.  DESCRIPTION 
  17479.  
  17480.  Tk_WindowID and the other names listed above are all macros that return fields 
  17481.  from Tk's local data structure for tkwin.  None of these macros requires any 
  17482.  interaction with the server;  it is safe to assume that all are fast. 
  17483.  
  17484.  Tk_WindowId returns the X identifier for tkwin, or NULL if no X window has 
  17485.  been created for tkwin yet. 
  17486.  
  17487.  Tk_Parent returns Tk's token for the logical parent of tkwin.  The parent is 
  17488.  the token that was specified when tkwin was created, or NULL for main windows. 
  17489.  
  17490.  Tk_Display returns a pointer to the Xlib display structure corresponding to 
  17491.  tkwin.  Tk_DisplayName returns an ASCII string identifying tkwin's display. 
  17492.  Tk_ScreenNumber returns the index of tkwin's screen among all the screens of 
  17493.  tkwin's display.  Tk_Screen returns a pointer to the Xlib structure 
  17494.  corresponding to tkwin's screen. 
  17495.  
  17496.  Tk_X, Tk_Y, Tk_Width, and Tk_Height return information about tkwin's location 
  17497.  within its parent and its size.  The location information refers to the 
  17498.  upper-left pixel in the window, or its border if there is one. The width and 
  17499.  height information refers to the interior size of the window, not including 
  17500.  any border.  Tk_Changes returns a pointer to a structure containing all of the 
  17501.  above information plus a few other fields.  Tk_Attributes returns a pointer to 
  17502.  an XSetWindowAttributes structure describing all of the attributes of the 
  17503.  tkwin's window, such as background pixmap, event mask, and so on (Tk keeps 
  17504.  track of all this information as it is changed by the application).  Note: it 
  17505.  is essential that applications use Tk procedures like Tk_ResizeWindow instead 
  17506.  of X procedures like XResizeWindow, so that Tk can keep its data structures 
  17507.  up-to-date. 
  17508.  
  17509.  Tk_IsMapped returns a non-zero value if tkwin is mapped and zero if tkwin 
  17510.  isn't mapped. 
  17511.  
  17512.  Tk_IsTopLevel returns a non-zero value if tkwin is a top-level window (its X 
  17513.  parent is the root window of the screen) and zero if tkwin isn't a top-level 
  17514.  window. 
  17515.  
  17516.  Tk_ReqWidth and Tk_ReqHeight return information about the window's requested 
  17517.  size.  These values correspond to the last call to Tk_GeometryRequest for 
  17518.  tkwin. 
  17519.  
  17520.  Tk_InternalBorderWidth returns the width of internal border that has been 
  17521.  requested for tkwin, or 0 if no internal border was requested.  The return 
  17522.  value is simply the last value passed to Tk_SetInternalBorder for tkwin. 
  17523.  
  17524.  Tk_Visual, Tk_Depth, and Tk_Colormap return information about the visual 
  17525.  characteristics of a window. Tk_Visual returns the visual type for the window, 
  17526.  Tk_Depth returns the number of bits per pixel, and Tk_Colormap returns the 
  17527.  current colormap for the window.  The visual characteristics are normally set 
  17528.  from the defaults for the window's screen, but they may be overridden by 
  17529.  calling Tk_SetWindowVisual. 
  17530.  
  17531.  KEYWORDS 
  17532.  
  17533.  attributes, colormap, depth, display, height, geometry manager, identifier, 
  17534.  mapped, requested size, screen, top-level, visual, width, window, x, y 
  17535.  
  17536.  
  17537. ΓòÉΓòÉΓòÉ 6. Tk Built-In Commands ΓòÉΓòÉΓòÉ
  17538.  
  17539.  
  17540. ΓòÉΓòÉΓòÉ 6.1. bell ΓòÉΓòÉΓòÉ
  17541.  
  17542.  NAME 
  17543.  
  17544. bell - Ring a display's bell 
  17545.  
  17546. SYNOPSIS 
  17547.  
  17548. bell ?-displayof window? 
  17549.  
  17550. DESCRIPTION 
  17551.  
  17552. This command rings the bell on the display for window and returns an empty 
  17553. string. If the -displayof option is omitted, the display of the application's 
  17554. main window is used by default. The command uses the current bell-related 
  17555. settings for the display, which may be modified with programs such as xset. 
  17556.  
  17557. This command also resets the screen saver for the screen.  Some screen savers 
  17558. will ignore this, but others will reset so that the screen becomes visible 
  17559. again. 
  17560.  
  17561. KEYWORDS 
  17562.  
  17563. beep, bell, ring 
  17564.  
  17565.  
  17566. ΓòÉΓòÉΓòÉ 6.2. bind ΓòÉΓòÉΓòÉ
  17567.  
  17568.  NAME 
  17569.  
  17570. bind - Arrange for X events to invoke Tcl scripts 
  17571.  
  17572. SYNOPSIS 
  17573.  
  17574. bind tag 
  17575.  bind tag sequence 
  17576.  bind tag sequence script 
  17577.  bind tag sequence +script 
  17578.  
  17579. INTRODUCTION 
  17580.  
  17581. The bind command associates Tcl scripts with X events. If all three arguments 
  17582. are specified, bind will arrange for script (a Tcl script) to be evaluated 
  17583. whenever the event(s) given by sequence occur in the window(s) identified by 
  17584. tag. If script is prefixed with a "+", then it is appended to any existing 
  17585. binding for sequence;  otherwise script replaces any existing binding. If 
  17586. script is an empty string then the current binding for sequence is destroyed, 
  17587. leaving sequence unbound. In all of the cases where a script argument is 
  17588. provided, bind returns an empty string. 
  17589.  
  17590. If sequence is specified without a script, then the script currently bound to 
  17591. sequence is returned, or an empty string is returned if there is no binding for 
  17592. sequence. If neither sequence nor script is specified, then the return value is 
  17593. a list whose elements are all the sequences for which there exist bindings for 
  17594. tag. 
  17595.  
  17596. The tag argument determines which window(s) the binding applies to. If tag 
  17597. begins with a dot, as in .a.b.c, then it must be the path name for a window; 
  17598. otherwise it may be an arbitrary string. Each window has an associated list of 
  17599. tags, and a binding applies to a particular window if its tag is among those 
  17600. specified for the window. Although the bindtags command may be used to assign 
  17601. an arbitrary set of binding tags to a window, the default binding tags provide 
  17602. the following behavior: 
  17603.  
  17604.      If a tag is the name of an internal window the binding applies to that 
  17605.       window. 
  17606.  
  17607.      If the tag is the name of a toplevel window the binding applies to the 
  17608.       toplevel window and all its internal windows. 
  17609.  
  17610.      If the tag is the name of a class of widgets, such as Button, the binding 
  17611.       applies to all widgets in that class; 
  17612.  
  17613.      If tag has the value all, the binding applies to all windows in the 
  17614.       application. 
  17615.  
  17616.  EVENT PATTERNS 
  17617.  
  17618.  The sequence argument specifies a sequence of one or more event patterns, with 
  17619.  optional white space between the patterns.  Each event pattern may take one of 
  17620.  three forms.  In the simplest case it is a single printing ASCII character, 
  17621.  such as a or [.  The character may not be a space character or the character 
  17622.  <.  This form of pattern matches a KeyPress event for the particular 
  17623.  character.  The second form of pattern is longer but more general. It has the 
  17624.  following syntax: 
  17625.  
  17626.   <modifier-modifier-type-detail>
  17627.  The entire event pattern is surrounded by angle brackets. Inside the angle 
  17628.  brackets are zero or more modifiers, an event type, and an extra piece of 
  17629.  information (detail) identifying a particular button or keysym.  Any of the 
  17630.  fields may be omitted, as long as at least one of type and detail is present. 
  17631.  The fields must be separated by white space or dashes. 
  17632.  
  17633.  The third form of pattern is used to specify a user-defined, named virtual 
  17634.  event.  It has the following syntax: 
  17635.  
  17636.   <<name>>
  17637.  The entire virtual event pattern is surrounded by double angle brackets. 
  17638.  Inside the angle brackets is the user-defined name of the virtual event. 
  17639.  Modifiers, such as Shift or Control, may not be combined with a virtual event 
  17640.  to modify it.  Bindings on a virtual event may be created before the virtual 
  17641.  event is defined, and if the definition of a virtual event changes 
  17642.  dynamically, all windows bound to that virtual event will respond immediately 
  17643.  to the new definition. 
  17644.  
  17645.  MODIFIERS 
  17646.  
  17647.  Modifiers consist of any of the following values: 
  17648.  
  17649.   Control                          Mod2, M2
  17650.   Shift                            Mod3, M3
  17651.   Lock                             Mod4, M4
  17652.   Button1, B1                      Mod5, M5
  17653.   Button2, B2                      Meta, M
  17654.   Button3, B3                      Alt
  17655.   Button4, B4                      Double
  17656.   Button5, B5                      Triple
  17657.   Mod1, M1
  17658.  Where more than one value is listed, separated by commas, the values are 
  17659.  equivalent. Most of the modifiers have the obvious X meanings. For example, 
  17660.  Button1 requires that button 1 be depressed when the event occurs. For a 
  17661.  binding to match a given event, the modifiers in the event must include all of 
  17662.  those specified in the event pattern. An event may also contain additional 
  17663.  modifiers not specified in the binding. For example, if button 1 is pressed 
  17664.  while the shift and control keys are down, the pattern <Control-Button-1> will 
  17665.  match the event, but <Mod1-Button-1> will not. If no modifiers are specified, 
  17666.  then any combination of modifiers may be present in the event. 
  17667.  
  17668.  Meta and M refer to whichever of the M1 through M5 modifiers is associated 
  17669.  with the meta key(s) on the keyboard (keysyms Meta_R and Meta_L). If there are 
  17670.  no meta keys, or if they are not associated with any modifiers, then Meta and 
  17671.  M will not match any events. Similarly, the Alt modifier refers to whichever 
  17672.  modifier is associated with the alt key(s) on the keyboard (keysyms Alt_L and 
  17673.  Alt_R). 
  17674.  
  17675.  The Double and Triple modifiers are a convenience for specifying double mouse 
  17676.  clicks and other repeated events. They cause a particular event pattern to be 
  17677.  repeated 2 or 3 times, and also place a time and space requirement on the 
  17678.  sequence:  for a sequence of events to match a Double or Triple pattern, all 
  17679.  of the events must occur close together in time and without substantial mouse 
  17680.  motion in between. For example, <Double-Button-1> is equivalent to 
  17681.  <Button-1><Button-1> with the extra time and space requirement. 
  17682.  
  17683.  EVENT TYPES 
  17684.  
  17685.  The type field may be any of the standard X event types, with a few extra 
  17686.  abbreviations.  Below is a list of all the valid types; where two names appear 
  17687.  together, they are synonyms. 
  17688.  
  17689.   ButtonPress, Button         Expose                      Map
  17690.   ButtonRelease               FocusIn                     Motion
  17691.   Circulate                   FocusOut                    Property
  17692.   Colormap                    Gravity                     Reparent
  17693.   Configure                   KeyPress, Key               Unmap
  17694.   Destroy                     KeyRelease                  Visibility
  17695.   Enter                       Leave                       Activate
  17696.   Deactivate
  17697.  
  17698.  The last part of a long event specification is detail.  In the case of a 
  17699.  ButtonPress or ButtonRelease event, it is the number of a button (1-5).  If a 
  17700.  button number is given, then only an event on that particular button will 
  17701.  match;  if no button number is given, then an event on any button will match. 
  17702.  Note:  giving a specific button number is different than specifying a button 
  17703.  modifier; in the first case, it refers to a button being pressed or released, 
  17704.  while in the second it refers to some other button that is already depressed 
  17705.  when the matching event occurs.  If a button number is given then type may be 
  17706.  omitted:  if will default to ButtonPress.  For example, the specifier <1> is 
  17707.  equivalent to <ButtonPress-1>. 
  17708.  
  17709.  If the event type is KeyPress or KeyRelease, then detail may be specified in 
  17710.  the form of an X keysym.  Keysyms are textual specifications for particular 
  17711.  keys on the keyboard; they include all the alphanumeric ASCII characters (e.g. 
  17712.  "a" is the keysym for the ASCII character "a"), plus descriptions for 
  17713.  non-alphanumeric characters ("comma" is the keysym for the comma character), 
  17714.  plus descriptions for all the non-ASCII keys on the keyboard ("Shift_L" is the 
  17715.  keysm for the left shift key, and "F1" is the keysym for the F1 function key, 
  17716.  if it exists).  The complete list of keysyms is not presented here;  it is 
  17717.  available in other X documentation and may vary from system to system. If 
  17718.  necessary, you can use the %K notation described below to print out the keysym 
  17719.  name for a particular key. If a keysym detail is given, then the type field 
  17720.  may be omitted;  it will default to KeyPress. For example, <Control-comma> is 
  17721.  equivalent to <Control-KeyPress-comma>. 
  17722.  
  17723.  BINDING SCRIPTS AND SUBSTITUTIONS 
  17724.  
  17725.  The script argument to bind is a Tcl script, which will be executed whenever 
  17726.  the given event sequence occurs. Command will be executed in the same 
  17727.  interpreter that the bind command was executed in, and it will run at global 
  17728.  level (only global variables will be accessible). If script contains any % 
  17729.  characters, then the script will not be executed directly.  Instead, a new 
  17730.  script will be generated by replacing each %, and the character following it, 
  17731.  with information from the current event.  The replacement depends on the 
  17732.  character following the %, as defined in the list below.  Unless otherwise 
  17733.  indicated, the replacement string is the decimal value of the given field from 
  17734.  the current event. Some of the substitutions are only valid for certain types 
  17735.  of events;  if they are used for other types of events the value substituted 
  17736.  is undefined. 
  17737.  
  17738.  %%        Replaced with a single percent. 
  17739.  
  17740.  %#        The number of the last client request processed by the server (the 
  17741.            serial field from the event).  Valid for all event types. 
  17742.  
  17743.  %a        The above field from the event, formatted as a hexadecimal number. 
  17744.            Valid only for Configure events. 
  17745.  
  17746.  %b        The number of the button that was pressed or released.  Valid only 
  17747.            for ButtonPress and ButtonRelease events. 
  17748.  
  17749.  %c        The count field from the event.  Valid only for Expose events. 
  17750.  
  17751.  %d        The detail field from the event.  The %d is replaced by a string 
  17752.            identifying the detail.  For Enter, Leave, FocusIn, and FocusOut 
  17753.            events, the string will be one of the following: 
  17754.  
  17755.                       NotifyAncestor                   NotifyNonlinearVirtual
  17756.                       NotifyDetailNone                 NotifyPointer
  17757.                       NotifyInferior                   NotifyPointerRoot
  17758.                       NotifyNonlinear                  NotifyVirtual
  17759.            For events other than these, the substituted string is undefined. 
  17760.  
  17761.  %f        The focus field from the event (0 or 1).  Valid only for Enter and 
  17762.            Leave events. 
  17763.  
  17764.  %h        The height field from the event.  Valid only for Configure and 
  17765.            Expose events. 
  17766.  
  17767.  %k        The keycode field from the event.  Valid only for KeyPress and 
  17768.            KeyRelease events. 
  17769.  
  17770.  %m        The mode field from the event.  The substituted string is one of 
  17771.            NotifyNormal, NotifyGrab, NotifyUngrab, or NotifyWhileGrabbed. 
  17772.            Valid only for Enter, FocusIn, FocusOut, and Leave events. 
  17773.  
  17774.  %o        The override_redirect field from the event.  Valid only for Map, 
  17775.            Reparent, and Configure events. 
  17776.  
  17777.  %p        The place field from the event, substituted as one of the strings 
  17778.            PlaceOnTop or PlaceOnBottom.  Valid only for Circulate events. 
  17779.  
  17780.  %s        The state field from the event.  For ButtonPress, ButtonRelease, 
  17781.            Enter, KeyPress, KeyRelease, Leave, and Motion events, a decimal 
  17782.            string is substituted.  For Visibility, one of the strings 
  17783.            VisibilityUnobscured, VisibilityPartiallyObscured, and 
  17784.            VisibilityFullyObscured is substituted. 
  17785.  
  17786.  %t        The time field from the event.  Valid only for events that contain a 
  17787.            time field. 
  17788.  
  17789.  %w        The width field from the event.  Valid only for Configure and Expose 
  17790.            events. 
  17791.  
  17792.  %x        The x field from the event.  Valid only for events containing an x 
  17793.            field. 
  17794.  
  17795.  %y        The y field from the event.  Valid only for events containing a y 
  17796.            field. 
  17797.  
  17798.  %A        Substitutes the ASCII character corresponding to the event, or the 
  17799.            empty string if the event doesn't correspond to an ASCII character 
  17800.            (e.g. the shift key was pressed).  XLookupString does all the work 
  17801.            of translating from the event to an ASCII character. Valid only for 
  17802.            KeyPress and KeyRelease events. 
  17803.  
  17804.  %B        The border_width field from the event.  Valid only for Configure 
  17805.            events. 
  17806.  
  17807.  %E        The send_event field from the event.  Valid for all event types. 
  17808.  
  17809.  %K        The keysym corresponding to the event, substituted as a textual 
  17810.            string.  Valid only for KeyPress and KeyRelease events. 
  17811.  
  17812.  %N        The keysym corresponding to the event, substituted as a decimal 
  17813.            number.  Valid only for KeyPress and KeyRelease events. 
  17814.  
  17815.  %R        The root window identifier from the event.  Valid only for events 
  17816.            containing a root field. 
  17817.  
  17818.  %S        The subwindow window identifier from the event, formatted as a 
  17819.            hexadecimal number. Valid only for events containing a subwindow 
  17820.            field. 
  17821.  
  17822.  %T        The type field from the event.  Valid for all event types. 
  17823.  
  17824.  %W        The path name of the window to which the event was reported (the 
  17825.            window field from the event).  Valid for all event types. 
  17826.  
  17827.  %X        The x_root field from the event. If a virtual-root window manager is 
  17828.            being used then the substituted value is the corresponding 
  17829.            x-coordinate in the virtual root. Valid only for ButtonPress, 
  17830.            ButtonRelease, KeyPress, KeyRelease, and Motion events. 
  17831.  
  17832.  %Y        The y_root field from the event. If a virtual-root window manager is 
  17833.            being used then the substituted value is the corresponding 
  17834.            y-coordinate in the virtual root. Valid only for ButtonPress, 
  17835.            ButtonRelease, KeyPress, KeyRelease, and Motion events. 
  17836.  
  17837.  The replacement string for a %-replacement is formatted as a proper Tcl list 
  17838.  element. This means that it will be surrounded with braces if it contains 
  17839.  spaces, or special characters such as $ and { may be preceded by backslashes. 
  17840.  This guarantees that the string will be passed through the Tcl parser when the 
  17841.  binding script is evaluated. Most replacements are numbers or well-defined 
  17842.  strings such as Above;  for these replacements no special formatting is ever 
  17843.  necessary. The most common case where reformatting occurs is for the %A 
  17844.  substitution.  For example, if script is 
  17845.  
  17846.   insert %A
  17847.  and the character typed is an open square bracket, then the script actually 
  17848.  executed will be 
  17849.  
  17850.   insert \[
  17851.  This will cause the insert to receive the original replacement string (open 
  17852.  square bracket) as its first argument. If the extra backslash hadn't been 
  17853.  added, Tcl would not have been able to parse the script correctly. 
  17854.  
  17855.  MULTIPLE MATCHES 
  17856.  
  17857.  It is possible for several bindings to match a given X event. If the bindings 
  17858.  are associated with different tag's, then each of the bindings will be 
  17859.  executed, in order. By default, a binding for the widget will be executed 
  17860.  first, followed by a class binding, a binding for its toplevel, and an all 
  17861.  binding. The bindtags command may be used to change this order for a 
  17862.  particular window or to associate additional binding tags with the window. 
  17863.  
  17864.  The continue and break commands may be used inside a binding script to control 
  17865.  the processing of matching scripts. If continue is invoked, then the current 
  17866.  binding script is terminated but Tk will continue processing binding scripts 
  17867.  associated with other tag's. If the break command is invoked within a binding 
  17868.  script, then that script terminates and no other scripts will be invoked for 
  17869.  the event. 
  17870.  
  17871.  If more than one binding matches a particular event and they have the same 
  17872.  tag, then the most specific binding is chosen and its script is evaluated. The 
  17873.  following tests are applied, in order, to determine which of several matching 
  17874.  sequences is more specific: (a) an event pattern that specifies a specific 
  17875.  button or key is more specific than one that doesn't; (b) a longer sequence 
  17876.  (in terms of number of events matched) is more specific than a shorter 
  17877.  sequence; (c) if the modifiers specified in one pattern are a subset of the 
  17878.  modifiers in another pattern, then the pattern with more modifiers is more 
  17879.  specific. (d) a virtual event whose physical pattern matches the sequence is 
  17880.  less specific than the same physical pattern that is not associated with a 
  17881.  virtual event. (e) given a sequence that matches two or more virtual events, 
  17882.  one of the virtual events will be chosen, but the order is undefined. 
  17883.  
  17884.  If the matching sequences contain more than one event, then tests (c)-(e) are 
  17885.  applied in order from the most recent event to the least recent event in the 
  17886.  sequences.  If these tests fail to determine a winner, then the most recently 
  17887.  registered sequence is the winner. 
  17888.  
  17889.  If there are two (or more) virtual events that are both triggered by the same 
  17890.  sequence, and both of those virtual events are bound to the same window tag, 
  17891.  then only one of the virtual events will be triggered, and it will be picked 
  17892.  at random: 
  17893.  
  17894.   event add <<Paste>> <Control-y>
  17895.   event add <<Paste>> <Button-2>
  17896.   event add <<Scroll>> <Button-2>
  17897.   bind Entry <<Paste>> {puts Paste}
  17898.   bind Entry <<Scroll>> {puts Scroll}
  17899.  If the user types Control-y, the <<Paste>> binding will be invoked, but if the 
  17900.  user presses button 2 then one of either the <<Paste>> or the <<Scroll>> 
  17901.  bindings will be invoked, but exactly which one gets invoked is undefined. 
  17902.  
  17903.  If an X event does not match any of the existing bindings, then the event is 
  17904.  ignored. An unbound event is not considered to be an error. 
  17905.  
  17906.  MULTI-EVENT SEQUENCES AND IGNORED EVENTS 
  17907.  
  17908.  When a sequence specified in a bind command contains more than one event 
  17909.  pattern, then its script is executed whenever the recent events (leading up to 
  17910.  and including the current event) match the given sequence.  This means, for 
  17911.  example, that if button 1 is clicked repeatedly the sequence 
  17912.  <Double-ButtonPress-1> will match each button press but the first. If 
  17913.  extraneous events that would prevent a match occur in the middle of an event 
  17914.  sequence then the extraneous events are ignored unless they are KeyPress or 
  17915.  ButtonPress events. For example, <Double-ButtonPress-1> will match a sequence 
  17916.  of presses of button 1, even though there will be ButtonRelease events (and 
  17917.  possibly Motion events) between the ButtonPress events. Furthermore, a 
  17918.  KeyPress event may be preceded by any number of other KeyPress events for 
  17919.  modifier keys without the modifier keys preventing a match. For example, the 
  17920.  event sequence aB will match a press of the a key, a release of the a key, a 
  17921.  press of the Shift key, and a press of the b key:  the press of Shift is 
  17922.  ignored because it is a modifier key. Finally, if several Motion events occur 
  17923.  in a row, only the last one is used for purposes of matching binding 
  17924.  sequences. 
  17925.  
  17926.  ERRORS 
  17927.  
  17928.  If an error occurs in executing the script for a binding then the bgerror 
  17929.  mechanism is used to report the error. The bgerror command will be executed at 
  17930.  global level (outside the context of any Tcl procedure). 
  17931.  
  17932.  SEE ALSO 
  17933.  
  17934.  bgerror 
  17935.  
  17936.  KEYWORDS 
  17937.  
  17938.  form, manual 
  17939.  
  17940.  
  17941. ΓòÉΓòÉΓòÉ 6.3. bindtags ΓòÉΓòÉΓòÉ
  17942.  
  17943.  NAME 
  17944.  
  17945. bindtags - Determine which bindings apply to a window, and order of evaluation 
  17946.  
  17947. SYNOPSIS 
  17948.  
  17949. bindtags window ?tagList? 
  17950.  
  17951. DESCRIPTION 
  17952.  
  17953. When a binding is created with the bind command, it is associated either with a 
  17954. particular window such as .a.b.c, a class name such as Button, the keyword all, 
  17955. or any other string. All of these forms are called binding tags. Each window 
  17956. contains a list of binding tags that determine how events are processed for the 
  17957. window. When an event occurs in a window, it is applied to each of the window's 
  17958. tags in order:  for each tag, the most specific binding that matches the given 
  17959. tag and event is executed. See the bind command for more information on the 
  17960. matching process. 
  17961.  
  17962. By default, each window has four binding tags consisting of the name of the 
  17963. window, the window's class name, the name of the window's nearest toplevel 
  17964. ancestor, and all, in that order. Toplevel windows have only three tags by 
  17965. default, since the toplevel name is the same as that of the window. The 
  17966. bindtags command allows the binding tags for a window to be read and modified. 
  17967.  
  17968. If bindtags is invoked with only one argument, then the current set of binding 
  17969. tags for window is returned as a list. If the tagList argument is specified to 
  17970. bindtags, then it must be a proper list; the tags for window are changed to the 
  17971. elements of the list. The elements of tagList may be arbitrary strings; 
  17972. however, any tag starting with a dot is treated as the name of a window;  if no 
  17973. window by that name exists at the time an event is processed, then the tag is 
  17974. ignored for that event. The order of the elements in tagList determines the 
  17975. order in which binding scripts are executed in response to events. For example, 
  17976. the command 
  17977.  
  17978. bindtags .b {all . Button .b}
  17979. reverses the order in which binding scripts will be evaluated for a button 
  17980. named .b so that all bindings are invoked first, following by bindings for .b's 
  17981. toplevel ("."), followed by class bindings, followed by bindings for .b. 
  17982.  
  17983. The bindtags command may be used to introduce arbitrary additional binding tags 
  17984. for a window, or to remove standard tags. For example, the command 
  17985.  
  17986. bindtags .b {.b TrickyButton . all}
  17987. replaces the Button tag for .b with TrickyButton. This means that the default 
  17988. widget bindings for buttons, which are associated with the Button tag, will no 
  17989. longer apply to .b, but any bindings associated with TrickyButton (perhaps some 
  17990. new button behavior) will apply. 
  17991.  
  17992. SEE ALSO 
  17993.  
  17994. bind 
  17995.  
  17996. KEYWORDS 
  17997.  
  17998. binding, event, tag 
  17999.  
  18000.  
  18001. ΓòÉΓòÉΓòÉ 6.4. bitmap ΓòÉΓòÉΓòÉ
  18002.  
  18003.  NAME 
  18004.  
  18005. bitmap - Images that display two colors 
  18006.  
  18007. SYNOPSIS 
  18008.  
  18009. image create bitmap ?name? ?options? 
  18010.  
  18011. DESCRIPTION 
  18012.  
  18013. A bitmap is an image whose pixels can display either of two colors or be 
  18014. transparent. A bitmap image is defined by four things:  a background color, a 
  18015. foreground color, and two bitmaps, called the source and the mask. Each of the 
  18016. bitmaps specifies 0/1 values for a rectangular array of pixels, and the two 
  18017. bitmaps must have the same dimensions. For pixels where the mask is zero, the 
  18018. image displays nothing, producing a transparent effect. For other pixels, the 
  18019. image displays the foreground color if the source data is one and the 
  18020. background color if the source data is zero. 
  18021.  
  18022. CREATING BITMAPS 
  18023.  
  18024. Like all images, bitmaps are created using the image create command. Bitmaps 
  18025. support the following options: 
  18026.  
  18027.  -background color  Specifies a background color for the image in any of the 
  18028.            standard ways accepted by Tk.  If this option is set to an empty 
  18029.            string then the background pixels will be transparent.  This effect 
  18030.            is achieved by using the source bitmap as the mask bitmap, ignoring 
  18031.            any -maskdata or -maskfile options. 
  18032.  
  18033.  -data string  Specifies the contents of the source bitmap as a string. The 
  18034.            string must adhere to X11 bitmap format (e.g., as generated by the 
  18035.            bitmap program). If both the -data and -file options are specified, 
  18036.            the -data option takes precedence. 
  18037.  
  18038.  -file name  name gives the name of a file whose contents define the source 
  18039.            bitmap. The file must adhere to X11 bitmap format (e.g., as 
  18040.            generated by the bitmap program). 
  18041.  
  18042.  -foreground color  Specifies a foreground color for the image in any of the 
  18043.            standard ways accepted by Tk. 
  18044.  
  18045.  -maskdata string  Specifies the contents of the mask as a string. The string 
  18046.            must adhere to X11 bitmap format (e.g., as generated by the bitmap 
  18047.            program). If both the -maskdata and -maskfile options are specified, 
  18048.            the -maskdata option takes precedence. 
  18049.  
  18050.  -maskfile name  name gives the name of a file whose contents define the mask. 
  18051.            The file must adhere to X11 bitmap format (e.g., as generated by the 
  18052.            bitmap program). 
  18053.  
  18054.  IMAGE COMMAND 
  18055.  
  18056.  When a bitmap image is created, Tk also creates a new command whose name is 
  18057.  the same as the image. This command may be used to invoke various operations 
  18058.  on the image. It has the following general form: 
  18059.  
  18060.   imageName option ?arg arg ...?
  18061.  Option and the args determine the exact behavior of the command.  The 
  18062.  following commands are possible for bitmap images: 
  18063.  
  18064.  imageName cget option  Returns the current value of the configuration option 
  18065.            given by option. Option may have any of the values accepted by the 
  18066.            image create bitmap command. 
  18067.  
  18068.  imageName configure ?option? ?value option value ...?  Query or modify the 
  18069.            configuration options for the image. If no option is specified, 
  18070.            returns a list describing all of the available options for imageName 
  18071.            (see Tk_ConfigureInfo for information on the format of this list). 
  18072.            If option is specified with no value, then the command returns a 
  18073.            list describing the one named option (this list will be identical to 
  18074.            the corresponding sublist of the value returned if no option is 
  18075.            specified).  If one or more option-value pairs are specified, then 
  18076.            the command modifies the given option(s) to have the given value(s); 
  18077.            in this case the command returns an empty string. Option may have 
  18078.            any of the values accepted by the image create bitmap command. 
  18079.  
  18080.  KEYWORDS 
  18081.  
  18082.  bitmap, image 
  18083.  
  18084.  
  18085. ΓòÉΓòÉΓòÉ 6.5. button ΓòÉΓòÉΓòÉ
  18086.  
  18087.  NAME 
  18088.  
  18089. button - Create and manipulate button widgets 
  18090.  
  18091. SYNOPSIS 
  18092.  
  18093. button pathName ?options? 
  18094.  
  18095. STANDARD OPTIONS 
  18096.  
  18097. -activebackground    -cursor              -highlightthickness  -takefocus
  18098. -activeforeground    -disabledforeground  -image               -text
  18099. -anchor              -font                -justify             -textvariable
  18100. -background          -foreground          -padx                -underline
  18101. -bitmap              -highlightbackground -pady                -wraplength
  18102. -borderwidth         -highlightcolor      -relief
  18103.  
  18104. See the options manual entry for detailed descriptions of the above options.
  18105.  
  18106. WIDGET-SPECIFIC OPTIONS 
  18107.  
  18108.   Command-Line Name:    -command
  18109.   Database Name:        command
  18110.   Database Class:       Command
  18111.  
  18112.            Specifies a Tcl command to associate with the button.  This command 
  18113.            is typically invoked when mouse button 1 is released over the button 
  18114.            window. 
  18115.  
  18116.   Command-Line Name:    -height
  18117.   Database Name:        height
  18118.   Database Class:       Height
  18119.  
  18120.            Specifies a desired height for the button. If an image or bitmap is 
  18121.            being displayed in the button then the value is in screen units 
  18122.            (i.e. any of the forms acceptable to Tk_GetPixels); for text it is 
  18123.            in lines of text. If this option isn't specified, the button's 
  18124.            desired height is computed from the size of the image or bitmap or 
  18125.            text being displayed in it. 
  18126.  
  18127.   Command-Line Name:    -state
  18128.   Database Name:        state
  18129.   Database Class:       State
  18130.  
  18131.            Specifies one of three states for the button:  normal, active, or 
  18132.            disabled.  In normal state the button is displayed using the 
  18133.            foreground and background options.  The active state is typically 
  18134.            used when the pointer is over the button.  In active state the 
  18135.            button is displayed using the activeForeground and activeBackground 
  18136.            options.  Disabled state means that the button should be 
  18137.            insensitive:  the default bindings will refuse to activate the 
  18138.            widget and will ignore mouse button presses. In this state the 
  18139.            disabledForeground and background options determine how the button 
  18140.            is displayed. 
  18141.  
  18142.   Command-Line Name:    -width
  18143.   Database Name:        width
  18144.   Database Class:       Width
  18145.  
  18146.            Specifies a desired width for the button. If an image or bitmap is 
  18147.            being displayed in the button then the value is in screen units 
  18148.            (i.e. any of the forms acceptable to Tk_GetPixels); for text it is 
  18149.            in characters. If this option isn't specified, the button's desired 
  18150.            width is computed from the size of the image or bitmap or text being 
  18151.            displayed in it. 
  18152.  
  18153.  DESCRIPTION 
  18154.  
  18155.  The button command creates a new window (given by the pathName argument) and 
  18156.  makes it into a button widget. Additional options, described above, may be 
  18157.  specified on the command line or in the option database to configure aspects 
  18158.  of the button such as its colors, font, text, and initial relief.  The button 
  18159.  command returns its pathName argument.  At the time this command is invoked, 
  18160.  there must not exist a window named pathName, but pathName's parent must 
  18161.  exist. 
  18162.  
  18163.  A button is a widget that displays a textual string, bitmap or image. If text 
  18164.  is displayed, it must all be in a single font, but it can occupy multiple 
  18165.  lines on the screen (if it contains newlines or if wrapping occurs because of 
  18166.  the wrapLength option) and one of the characters may optionally be underlined 
  18167.  using the underline option. It can display itself in either of three different 
  18168.  ways, according to the state option; it can be made to appear raised, sunken, 
  18169.  or flat; and it can be made to flash.  When a user invokes the button (by 
  18170.  pressing mouse button 1 with the cursor over the button), then the Tcl command 
  18171.  specified in the -command option is invoked. 
  18172.  
  18173.  WIDGET COMMAND 
  18174.  
  18175.  The button command creates a new Tcl command whose name is pathName.  This 
  18176.  command may be used to invoke various operations on the widget.  It has the 
  18177.  following general form: 
  18178.  
  18179.   pathName option ?arg arg ...?
  18180.  Option and the args determine the exact behavior of the command.  The 
  18181.  following commands are possible for button widgets: 
  18182.  
  18183.  pathName cget option  Returns the current value of the configuration option 
  18184.            given by option. Option may have any of the values accepted by the 
  18185.            button command. 
  18186.  
  18187.  pathName configure ?option? ?value option value ...?  Query or modify the 
  18188.            configuration options of the widget. If no option is specified, 
  18189.            returns a list describing all of the available options for pathName 
  18190.            (see Tk_ConfigureInfo for information on the format of this list). 
  18191.            If option is specified with no value, then the command returns a 
  18192.            list describing the one named option (this list will be identical to 
  18193.            the corresponding sublist of the value returned if no option is 
  18194.            specified).  If one or more option-value pairs are specified, then 
  18195.            the command modifies the given widget option(s) to have the given 
  18196.            value(s);  in this case the command returns an empty string. Option 
  18197.            may have any of the values accepted by the button command. 
  18198.  
  18199.  pathName flash  Flash the button.  This is accomplished by redisplaying the 
  18200.            button several times, alternating between active and normal colors. 
  18201.            At the end of the flash the button is left in the same normal/active 
  18202.            state as when the command was invoked. This command is ignored if 
  18203.            the button's state is disabled. 
  18204.  
  18205.  pathName invoke  Invoke the Tcl command associated with the button, if there 
  18206.            is one. The return value is the return value from the Tcl command, 
  18207.            or an empty string if there is no command associated with the 
  18208.            button. This command is ignored if the button's state is disabled. 
  18209.  
  18210.  DEFAULT BINDINGS 
  18211.  
  18212.  Tk automatically creates class bindings for buttons that give them the 
  18213.  following default behavior: 
  18214.  
  18215.    1. A button activates whenever the mouse passes over it and deactivates 
  18216.       whenever the mouse leaves the button. 
  18217.  
  18218.    2. A button's relief is changed to sunken whenever mouse button 1 is pressed 
  18219.       over the button, and the relief is restored to its original value when 
  18220.       button 1 is later released. 
  18221.  
  18222.    3. If mouse button 1 is pressed over a button and later released over the 
  18223.       button, the button is invoked.  However, if the mouse is not over the 
  18224.       button when button 1 is released, then no invocation occurs. 
  18225.  
  18226.    4. When a button has the input focus, the space key causes the button to be 
  18227.       invoked. 
  18228.  
  18229.  If the button's state is disabled then none of the above actions occur:  the 
  18230.  button is completely non-responsive. 
  18231.  
  18232.  The behavior of buttons can be changed by defining new bindings for individual 
  18233.  widgets or by redefining the class bindings. 
  18234.  
  18235.  KEYWORDS 
  18236.  
  18237.  button, widget 
  18238.  
  18239.  
  18240. ΓòÉΓòÉΓòÉ 6.6. canvas ΓòÉΓòÉΓòÉ
  18241.  
  18242.  NAME 
  18243.  
  18244. canvas - Create and manipulate canvas widgets 
  18245.  
  18246. SYNOPSIS 
  18247.  
  18248. canvas pathName ?options? 
  18249.  
  18250. STANDARD OPTIONS 
  18251.  
  18252. -background          -highlightthickness  -insertwidth         -takefocus
  18253. -borderwidth         -insertbackground    -relief              -xscrollcommand
  18254. -cursor              -insertborderwidth   -selectbackground    -yscrollcommand
  18255. -highlightbackground -insertofftime       -selectborderwidth
  18256. -highlightcolor      -insertontime        -selectforeground
  18257.  
  18258. See the options manual entry for detailed descriptions of the above options.
  18259.  
  18260. WIDGET-SPECIFIC OPTIONS 
  18261.  
  18262.   Command-Line Name:    -closeenough
  18263.   Database Name:        closeEnough
  18264.   Database Class:       CloseEnough
  18265.  
  18266.            Specifies a floating-point value indicating how close the mouse 
  18267.            cursor must be to an item before it is considered to be "inside" the 
  18268.            item. Defaults to 1.0. 
  18269.  
  18270.   Command-Line Name:    -confine
  18271.   Database Name:        confine
  18272.   Database Class:       Confine
  18273.  
  18274.            Specifies a boolean value that indicates whether or not it should be 
  18275.            allowable to set the canvas's view outside the region defined by the 
  18276.            scrollRegion argument. Defaults to true, which means that the view 
  18277.            will be constrained within the scroll region. 
  18278.  
  18279.   Command-Line Name:    -height
  18280.   Database Name:        height
  18281.   Database Class:       Height
  18282.  
  18283.            Specifies a desired window height that the canvas widget should 
  18284.            request from its geometry manager.  The value may be specified in 
  18285.            any of the forms described in the COORDINATES section below. 
  18286.  
  18287.   Command-Line Name:    -scrollregion
  18288.   Database Name:        scrollRegion
  18289.   Database Class:       ScrollRegion
  18290.  
  18291.            Specifies a list with four coordinates describing the left, top, 
  18292.            right, and bottom coordinates of a rectangular region. This region 
  18293.            is used for scrolling purposes and is considered to be the boundary 
  18294.            of the information in the canvas. Each of the coordinates may be 
  18295.            specified in any of the forms given in the COORDINATES section 
  18296.            below. 
  18297.  
  18298.   Command-Line Name:    -width
  18299.   Database Name:        width
  18300.   Database Class:       width
  18301.  
  18302.            Specifies a desired window width that the canvas widget should 
  18303.            request from its geometry manager.  The value may be specified in 
  18304.            any of the forms described in the COORDINATES section below. 
  18305.  
  18306.   Command-Line Name:    -xscrollincrement
  18307.   Database Name:        xScrollIncrement
  18308.   Database Class:       ScrollIncrement
  18309.  
  18310.            Specifies an increment for horizontal scrolling, in any of the usual 
  18311.            forms permitted for screen distances.  If the value of this option 
  18312.            is greater than zero, the horizontal view in the window will be 
  18313.            constrained so that the canvas x coordinate at the left edge of the 
  18314.            window is always an even multiple of xScrollIncrement;  furthermore, 
  18315.            the units for scrolling (e.g., the change in view when the left and 
  18316.            right arrows of a scrollbar are selected) will also be 
  18317.            xScrollIncrement.  If the value of this option is less than or equal 
  18318.            to zero, then horizontal scrolling is unconstrained. 
  18319.  
  18320.   Command-Line Name:    -yscrollincrement
  18321.   Database Name:        yScrollIncrement
  18322.   Database Class:       ScrollIncrement
  18323.  
  18324.            Specifies an increment for vertical scrolling, in any of the usual 
  18325.            forms permitted for screen distances.  If the value of this option 
  18326.            is greater than zero, the vertical view in the window will be 
  18327.            constrained so that the canvas y coordinate at the top edge of the 
  18328.            window is always an even multiple of yScrollIncrement;  furthermore, 
  18329.            the units for scrolling (e.g., the change in view when the top and 
  18330.            bottom arrows of a scrollbar are selected) will also be 
  18331.            yScrollIncrement.  If the value of this option is less than or equal 
  18332.            to zero, then vertical scrolling is unconstrained. 
  18333.  
  18334.  INTRODUCTION 
  18335.  
  18336.  The canvas command creates a new window (given by the pathName argument) and 
  18337.  makes it into a canvas widget. Additional options, described above, may be 
  18338.  specified on the command line or in the option database to configure aspects 
  18339.  of the canvas such as its colors and 3-D relief. The canvas command returns 
  18340.  its pathName argument.  At the time this command is invoked, there must not 
  18341.  exist a window named pathName, but pathName's parent must exist. 
  18342.  
  18343.  Canvas widgets implement structured graphics. A canvas displays any number of 
  18344.  items, which may be things like rectangles, circles, lines, and text. Items 
  18345.  may be manipulated (e.g. moved or re-colored) and commands may be associated 
  18346.  with items in much the same way that the bind command allows commands to be 
  18347.  bound to widgets.  For example, a particular command may be associated with 
  18348.  the <Button-1> event so that the command is invoked whenever button 1 is 
  18349.  pressed with the mouse cursor over an item. This means that items in a canvas 
  18350.  can have behaviors defined by the Tcl scripts bound to them. 
  18351.  
  18352.  DISPLAY LIST 
  18353.  
  18354.  The items in a canvas are ordered for purposes of display, with the first item 
  18355.  in the display list being displayed first, followed by the next item in the 
  18356.  list, and so on. Items later in the display list obscure those that are 
  18357.  earlier in the display list and are sometimes referred to as being "on top" of 
  18358.  earlier items. When a new item is created it is placed at the end of the 
  18359.  display list, on top of everything else. Widget commands may be used to 
  18360.  re-arrange the order of the display list. 
  18361.  
  18362.  ITEM IDS AND TAGS 
  18363.  
  18364.  Items in a canvas widget may be named in either of two ways: by id or by tag. 
  18365.  Each item has a unique identifying number which is assigned to that item when 
  18366.  it is created.  The id of an item never changes and id numbers are never 
  18367.  re-used within the lifetime of a canvas widget. 
  18368.  
  18369.  Each item may also have any number of tags associated with it.  A tag is just 
  18370.  a string of characters, and it may take any form except that of an integer. 
  18371.  For example, "x123" is OK but "123" isn't. The same tag may be associated with 
  18372.  many different items. This is commonly done to group items in various 
  18373.  interesting ways;  for example, all selected items might be given the tag 
  18374.  "selected". 
  18375.  
  18376.  The tag all is implicitly associated with every item in the canvas;  it may be 
  18377.  used to invoke operations on all the items in the canvas. 
  18378.  
  18379.  The tag current is managed automatically by Tk; it applies to the current 
  18380.  item, which is the topmost item whose drawn area covers the position of the 
  18381.  mouse cursor. If the mouse is not in the canvas widget or is not over an item, 
  18382.  then no item has the current tag. 
  18383.  
  18384.  When specifying items in canvas widget commands, if the specifier is an 
  18385.  integer then it is assumed to refer to the single item with that id. If the 
  18386.  specifier is not an integer, then it is assumed to refer to all of the items 
  18387.  in the canvas that have a tag matching the specifier. The symbol tagOrId is 
  18388.  used below to indicate that an argument specifies either an id that selects a 
  18389.  single item or a tag that selects zero or more items. Some widget commands 
  18390.  only operate on a single item at a time;  if tagOrId is specified in a way 
  18391.  that names multiple items, then the normal behavior is for the command to use 
  18392.  the first (lowest) of these items in the display list that is suitable for the 
  18393.  command. Exceptions are noted in the widget command descriptions below. 
  18394.  
  18395.  COORDINATES 
  18396.  
  18397.  All coordinates related to canvases are stored as floating-point numbers. 
  18398.  Coordinates and distances are specified in screen units, which are 
  18399.  floating-point numbers optionally followed by one of several letters. If no 
  18400.  letter is supplied then the distance is in pixels. If the letter is m then the 
  18401.  distance is in millimeters on the screen;  if it is c then the distance is in 
  18402.  centimeters; i means inches, and p means printers points (1/72 inch). Larger 
  18403.  y-coordinates refer to points lower on the screen;  larger x-coordinates refer 
  18404.  to points farther to the right. 
  18405.  
  18406.  TRANSFORMATIONS 
  18407.  
  18408.  Normally the origin of the canvas coordinate system is at the upper-left 
  18409.  corner of the window containing the canvas. It is possible to adjust the 
  18410.  origin of the canvas coordinate system relative to the origin of the window 
  18411.  using the xview and yview widget commands;  this is typically used for 
  18412.  scrolling. Canvases do not support scaling or rotation of the canvas 
  18413.  coordinate system relative to the window coordinate system. 
  18414.  
  18415.  Individual items may be moved or scaled using widget commands described below, 
  18416.  but they may not be rotated. 
  18417.  
  18418.  INDICES 
  18419.  
  18420.  Text items support the notion of an index for identifying particular positions 
  18421.  within the item. Indices are used for commands such as inserting text, 
  18422.  deleting a range of characters, and setting the insertion cursor position. An 
  18423.  index may be specified in any of a number of ways, and different types of 
  18424.  items may support different forms for specifying indices. Text items support 
  18425.  the following forms for an index;  if you define new types of text-like items, 
  18426.  it would be advisable to support as many of these forms as practical. Note 
  18427.  that it is possible to refer to the character just after the last one in the 
  18428.  text item;  this is necessary for such tasks as inserting new text at the end 
  18429.  of the item. 
  18430.  
  18431.  number    A decimal number giving the position of the desired character within 
  18432.            the text item. 0 refers to the first character, 1 to the next 
  18433.            character, and so on. A number less than 0 is treated as if it were 
  18434.            zero, and a number greater than the length of the text item is 
  18435.            treated as if it were equal to the length of the text item. 
  18436.  
  18437.  end       Refers to the character just after the last one in the item (same as 
  18438.            the number of characters in the item). 
  18439.  
  18440.  insert    Refers to the character just before which the insertion cursor is 
  18441.            drawn in this item. 
  18442.  
  18443.  sel.first  Refers to the first selected character in the item. If the 
  18444.            selection isn't in this item then this form is illegal. 
  18445.  
  18446.  sel.last  Refers to the last selected character in the item. If the selection 
  18447.            isn't in this item then this form is illegal. 
  18448.  
  18449.  @x,y      Refers to the character at the point given by x and y, where x and y 
  18450.            are specified in the coordinate system of the canvas. If x and y lie 
  18451.            outside the coordinates covered by the text item, then they refer to 
  18452.            the first or last character in the line that is closest to the given 
  18453.            point. 
  18454.  
  18455.  WIDGET COMMAND 
  18456.  
  18457.  The canvas command creates a new Tcl command whose name is pathName.  This 
  18458.  command may be used to invoke various operations on the widget.  It has the 
  18459.  following general form: 
  18460.  
  18461.   pathName option ?arg arg ...?
  18462.  Option and the args determine the exact behavior of the command. The following 
  18463.  widget commands are possible for canvas widgets: 
  18464.  
  18465.  pathName addtag tag searchSpec ?arg arg ...?  For each item that meets the 
  18466.            constraints specified by searchSpec and the args, add tag to the 
  18467.            list of tags associated with the item if it isn't already present on 
  18468.            that list. It is possible that no items will satisfy the constraints 
  18469.            given by searchSpec and args, in which case the command has no 
  18470.            effect. This command returns an empty string as result. SearchSpec 
  18471.            and arg's may take any of the following forms: 
  18472.  
  18473.            above tagOrId  Selects the item just after (above) the one given by 
  18474.                           tagOrId in the display list. If tagOrId denotes more 
  18475.                           than one item, then the last (topmost) of these items 
  18476.                           in the display list is used. 
  18477.  
  18478.            all            Selects all the items in the canvas. 
  18479.  
  18480.            below tagOrId  Selects the item just before (below) the one given by 
  18481.                           tagOrId in the display list. If tagOrId denotes more 
  18482.                           than one item, then the first (lowest) of these items 
  18483.                           in the display list is used. 
  18484.  
  18485.            closest x y ?halo? ?start?  Selects the item closest to the point 
  18486.                           given by x and y. If more than one item is at the 
  18487.                           same closest distance (e.g. two items overlap the 
  18488.                           point), then the top-most of these items (the last 
  18489.                           one in the display list) is used. If halo is 
  18490.                           specified, then it must be a non-negative value. Any 
  18491.                           item closer than halo to the point is considered to 
  18492.                           overlap it. The start argument may be used to step 
  18493.                           circularly through all the closest items. If start is 
  18494.                           specified, it names an item using a tag or id (if by 
  18495.                           tag, it selects the first item in the display list 
  18496.                           with the given tag). Instead of selecting the topmost 
  18497.                           closest item, this form will select the topmost 
  18498.                           closest item that is below start in the display list; 
  18499.                           if no such item exists, then the selection behaves as 
  18500.                           if the start argument had not been specified. 
  18501.  
  18502.            enclosed x1 y1 x2 y2  Selects all the items completely enclosed 
  18503.                           within the rectangular region given by x1, y1, x2, 
  18504.                           and y2. X1 must be no greater then x2 and y1 must be 
  18505.                           no greater than y2. 
  18506.  
  18507.            overlapping x1 y1 x2 y2  Selects all the items that overlap or are 
  18508.                           enclosed within the rectangular region given by x1, 
  18509.                           y1, x2, and y2. X1 must be no greater then x2 and y1 
  18510.                           must be no greater than y2. 
  18511.  
  18512.            withtag tagOrId  Selects all the items given by tagOrId. 
  18513.  
  18514.  pathName bbox tagOrId ?tagOrId tagOrId ...?  Returns a list with four elements 
  18515.            giving an approximate bounding box for all the items named by the 
  18516.            tagOrId arguments. The list has the form "x1 y1 x2 y2" such that the 
  18517.            drawn areas of all the named elements are within the region bounded 
  18518.            by x1 on the left, x2 on the right, y1 on the top, and y2 on the 
  18519.            bottom. The return value may overestimate the actual bounding box by 
  18520.            a few pixels. If no items match any of the tagOrId arguments or if 
  18521.            the matching items have empty bounding boxes (i.e. they have nothing 
  18522.            to display) then an empty string is returned. 
  18523.  
  18524.  pathName bind tagOrId ?sequence? ?command?  This command associates command 
  18525.            with all the items given by tagOrId such that whenever the event 
  18526.            sequence given by sequence occurs for one of the items the command 
  18527.            will be invoked. This widget command is similar to the bind command 
  18528.            except that it operates on items in a canvas rather than entire 
  18529.            widgets. See the bind manual entry for complete details on the 
  18530.            syntax of sequence and the substitutions performed on command before 
  18531.            invoking it. If all arguments are specified then a new binding is 
  18532.            created, replacing any existing binding for the same sequence and 
  18533.            tagOrId (if the first character of command is "+" then command 
  18534.            augments an existing binding rather than replacing it). In this case 
  18535.            the return value is an empty string. If command is omitted then the 
  18536.            command returns the command associated with tagOrId and sequence (an 
  18537.            error occurs if there is no such binding). If both command and 
  18538.            sequence are omitted then the command returns a list of all the 
  18539.            sequences for which bindings have been defined for tagOrId. 
  18540.  
  18541.            The only events for which bindings may be specified are those 
  18542.            related to the mouse and keyboard, such as Enter, Leave, 
  18543.            ButtonPress, Motion, and KeyPress. The handling of events in 
  18544.            canvases uses the current item defined in ITEM IDS AND TAGS above. 
  18545.            Enter and Leave events trigger for an item when it becomes the 
  18546.            current item or ceases to be the current item;  note that these 
  18547.            events are different than Enter and Leave events for windows. 
  18548.            Mouse-related events are directed to the current item, if any. 
  18549.            Keyboard-related events are directed to the focus item, if any (see 
  18550.            the focus widget command below for more on this). 
  18551.  
  18552.            It is possible for multiple bindings to match a particular event. 
  18553.            This could occur, for example, if one binding is associated with the 
  18554.            item's id and another is associated with one of the item's tags. 
  18555.            When this occurs, all of the matching bindings are invoked. A 
  18556.            binding associated with the all tag is invoked first, followed by 
  18557.            one binding for each of the item's tags (in order), followed by a 
  18558.            binding associated with the item's id. If there are multiple 
  18559.            matching bindings for a single tag, then only the most specific 
  18560.            binding is invoked. A continue command in a binding script 
  18561.            terminates that script, and a break command terminates that script 
  18562.            and skips any remaining scripts for the event, just as for the bind 
  18563.            command. 
  18564.  
  18565.            If bindings have been created for a canvas window using the bind 
  18566.            command, then they are invoked in addition to bindings created for 
  18567.            the canvas's items using the bind widget command. The bindings for 
  18568.            items will be invoked before any of the bindings for the window as a 
  18569.            whole. 
  18570.  
  18571.  pathName canvasx screenx ?gridspacing?  Given a window x-coordinate in the 
  18572.            canvas screenx, this command returns the canvas x-coordinate that is 
  18573.            displayed at that location. If gridspacing is specified, then the 
  18574.            canvas coordinate is rounded to the nearest multiple of gridspacing 
  18575.            units. 
  18576.  
  18577.  pathName canvasy screeny ?gridspacing?  Given a window y-coordinate in the 
  18578.            canvas screeny this command returns the canvas y-coordinate that is 
  18579.            displayed at that location. If gridspacing is specified, then the 
  18580.            canvas coordinate is rounded to the nearest multiple of gridspacing 
  18581.            units. 
  18582.  
  18583.  pathName cget option  Returns the current value of the configuration option 
  18584.            given by option. Option may have any of the values accepted by the 
  18585.            canvas command. 
  18586.  
  18587.  pathName configure ?option? ?value? ?option value ...?  Query or modify the 
  18588.            configuration options of the widget. If no option is specified, 
  18589.            returns a list describing all of the available options for pathName 
  18590.            (see Tk_ConfigureInfo for information on the format of this list). 
  18591.            If option is specified with no value, then the command returns a 
  18592.            list describing the one named option (this list will be identical to 
  18593.            the corresponding sublist of the value returned if no option is 
  18594.            specified).  If one or more option-value pairs are specified, then 
  18595.            the command modifies the given widget option(s) to have the given 
  18596.            value(s);  in this case the command returns an empty string. Option 
  18597.            may have any of the values accepted by the canvas command. 
  18598.  
  18599.  pathName coords tagOrId ?x0 y0 ...?  Query or modify the coordinates that 
  18600.            define an item. If no coordinates are specified, this command 
  18601.            returns a list whose elements are the coordinates of the item named 
  18602.            by tagOrId. If coordinates are specified, then they replace the 
  18603.            current coordinates for the named item. If tagOrId refers to 
  18604.            multiple items, then the first one in the display list is used. 
  18605.  
  18606.  pathName create type x y ?x y ...? ?option value ...?  Create a new item in 
  18607.            pathName of type type. The exact format of the arguments after type 
  18608.            depends on type, but usually they consist of the coordinates for one 
  18609.            or more points, followed by specifications for zero or more item 
  18610.            options. See the subsections on individual item types below for more 
  18611.            on the syntax of this command. This command returns the id for the 
  18612.            new item. 
  18613.  
  18614.  pathName dchars tagOrId first ?last?  For each item given by tagOrId, delete 
  18615.            the characters in the range given by first and last, inclusive. If 
  18616.            some of the items given by tagOrId don't support text operations, 
  18617.            then they are ignored. First and last are indices of characters 
  18618.            within the item(s) as described in INDICES above. If last is 
  18619.            omitted, it defaults to first. This command returns an empty string. 
  18620.  
  18621.  pathName delete ?tagOrId tagOrId ...?  Delete each of the items given by each 
  18622.            tagOrId, and return an empty string. 
  18623.  
  18624.  pathName dtag tagOrId ?tagToDelete?  For each of the items given by tagOrId, 
  18625.            delete the tag given by tagToDelete from the list of those 
  18626.            associated with the item. If an item doesn't have the tag 
  18627.            tagToDelete then the item is unaffected by the command. If 
  18628.            tagToDelete is omitted then it defaults to tagOrId. This command 
  18629.            returns an empty string. 
  18630.  
  18631.  pathName find searchCommand ?arg arg ...?  This command returns a list 
  18632.            consisting of all the items that meet the constraints specified by 
  18633.            searchCommand and arg's. SearchCommand and args have any of the 
  18634.            forms accepted by the addtag command. 
  18635.  
  18636.  pathName focus ?tagOrId?  Set the keyboard focus for the canvas widget to the 
  18637.            item given by tagOrId. If tagOrId refers to several items, then the 
  18638.            focus is set to the first such item in the display list that 
  18639.            supports the insertion cursor. If tagOrId doesn't refer to any 
  18640.            items, or if none of them support the insertion cursor, then the 
  18641.            focus isn't changed. If tagOrId is an empty string, then the focus 
  18642.            item is reset so that no item has the focus. If tagOrId is not 
  18643.            specified then the command returns the id for the item that 
  18644.            currently has the focus, or an empty string if no item has the 
  18645.            focus. 
  18646.  
  18647.            Once the focus has been set to an item, the item will display the 
  18648.            insertion cursor and all keyboard events will be directed to that 
  18649.            item. The focus item within a canvas and the focus window on the 
  18650.            screen (set with the focus command) are totally independent: a given 
  18651.            item doesn't actually have the input focus unless (a) its canvas is 
  18652.            the focus window and (b) the item is the focus item within the 
  18653.            canvas. In most cases it is advisable to follow the focus widget 
  18654.            command with the focus command to set the focus window to the canvas 
  18655.            (if it wasn't there already). 
  18656.  
  18657.  pathName gettags tagOrId  Return a list whose elements are the tags associated 
  18658.            with the item given by tagOrId. If tagOrId refers to more than one 
  18659.            item, then the tags are returned from the first such item in the 
  18660.            display list. If tagOrId doesn't refer to any items, or if the item 
  18661.            contains no tags, then an empty string is returned. 
  18662.  
  18663.  pathName icursor tagOrId index  Set the position of the insertion cursor for 
  18664.            the item(s) given by tagOrId to just before the character whose 
  18665.            position is given by index. If some or all of the items given by 
  18666.            tagOrId don't support an insertion cursor then this command has no 
  18667.            effect on them. See INDICES above for a description of the legal 
  18668.            forms for index. Note:  the insertion cursor is only displayed in an 
  18669.            item if that item currently has the keyboard focus (see the widget 
  18670.            command focus, below), but the cursor position may be set even when 
  18671.            the item doesn't have the focus. This command returns an empty 
  18672.            string. 
  18673.  
  18674.  pathName index tagOrId index  This command returns a decimal string giving the 
  18675.            numerical index within tagOrId corresponding to index. Index gives a 
  18676.            textual description of the desired position as described in INDICES 
  18677.            above. The return value is guaranteed to lie between 0 and the 
  18678.            number of characters within the item, inclusive. If tagOrId refers 
  18679.            to multiple items, then the index is processed in the first of these 
  18680.            items that supports indexing operations (in display list order). 
  18681.  
  18682.  pathName insert tagOrId beforeThis string  For each of the items given by 
  18683.            tagOrId, if the item supports text insertion then string is inserted 
  18684.            into the item's text just before the character whose index is 
  18685.            beforeThis. See INDICES above for information about the forms 
  18686.            allowed for beforeThis. This command returns an empty string. 
  18687.  
  18688.  pathName itemcget tagOrId option  Returns the current value of the 
  18689.            configuration option for the item given by tagOrId whose name is 
  18690.            option. This command is similar to the cget widget command except 
  18691.            that it applies to a particular item rather than the widget as a 
  18692.            whole. Option may have any of the values accepted by the create 
  18693.            widget command when the item was created. If tagOrId is a tag that 
  18694.            refers to more than one item, the first (lowest) such item is used. 
  18695.  
  18696.  pathName itemconfigure tagOrId ?option? ?value? ?option value ...?  This 
  18697.            command is similar to the configure widget command except that it 
  18698.            modifies item-specific options for the items given by tagOrId 
  18699.            instead of modifying options for the overall canvas widget. If no 
  18700.            option is specified, returns a list describing all of the available 
  18701.            options for the first item given by tagOrId (see Tk_ConfigureInfo 
  18702.            for information on the format of this list).  If option is specified 
  18703.            with no value, then the command returns a list describing the one 
  18704.            named option (this list will be identical to the corresponding 
  18705.            sublist of the value returned if no option is specified).  If one or 
  18706.            more option-value pairs are specified, then the command modifies the 
  18707.            given widget option(s) to have the given value(s) in each of the 
  18708.            items given by tagOrId;  in this case the command returns an empty 
  18709.            string. The options and values are the same as those permissible in 
  18710.            the create widget command when the item(s) were created; see the 
  18711.            sections describing individual item types below for details on the 
  18712.            legal options. 
  18713.  
  18714.  pathName lower tagOrId ?belowThis?  Move all of the items given by tagOrId to 
  18715.            a new position in the display list just before the item given by 
  18716.            belowThis. If tagOrId refers to more than one item then all are 
  18717.            moved but the relative order of the moved items will not be changed. 
  18718.            BelowThis is a tag or id;  if it refers to more than one item then 
  18719.            the first (lowest) of these items in the display list is used as the 
  18720.            destination location for the moved items. This command returns an 
  18721.            empty string. 
  18722.  
  18723.  pathName move tagOrId xAmount yAmount  Move each of the items given by tagOrId 
  18724.            in the canvas coordinate space by adding xAmount to the x-coordinate 
  18725.            of each point associated with the item and yAmount to the 
  18726.            y-coordinate of each point associated with the item. This command 
  18727.            returns an empty string. 
  18728.  
  18729.  pathName postscript ?option value option value ...?  Generate a Postscript 
  18730.            representation for part or all of the canvas. If the -file option is 
  18731.            specified then the Postscript is written to a file and an empty 
  18732.            string is returned;  otherwise the Postscript is returned as the 
  18733.            result of the command. The Postscript is created in Encapsulated 
  18734.            Postscript form using version 3.0 of the Document Structuring 
  18735.            Conventions. Note: by default Postscript is only generated for 
  18736.            information that appears in the canvas's window on the screen.  If 
  18737.            the canvas is freshly created it may still have its initial size of 
  18738.            1x1 pixel so nothing will appear in the Postscript.  To get around 
  18739.            this problem either invoke the "update" command to wait for the 
  18740.            canvas window to reach its final size, or else use the -width and 
  18741.            -height options to specify the area of the canvas to print. The 
  18742.            option-value argument pairs provide additional information to 
  18743.            control the generation of Postscript.  The following options are 
  18744.            supported: 
  18745.  
  18746.            -colormap varName  VarName must be the name of an array variable 
  18747.                           that specifies a color mapping to use in the 
  18748.                           Postscript. Each element of varName must consist of 
  18749.                           Postscript code to set a particular color value (e.g. 
  18750.                           "1.0 1.0 0.0 setrgbcolor"). When outputting color 
  18751.                           information in the Postscript, Tk checks to see if 
  18752.                           there is an element of varName with the same name as 
  18753.                           the color. If so, Tk uses the value of the element as 
  18754.                           the Postscript command to set the color. If this 
  18755.                           option hasn't been specified, or if there isn't an 
  18756.                           entry in varName for a given color, then Tk uses the 
  18757.                           red, green, and blue intensities from the X color. 
  18758.  
  18759.            -colormode mode  Specifies how to output color information.  Mode 
  18760.                           must be either color (for full color output), gray 
  18761.                           (convert all colors to their gray-scale equivalents) 
  18762.                           or mono (convert all colors to black or white). 
  18763.  
  18764.            -file fileName  Specifies the name of the file in which to write the 
  18765.                           Postscript. If this option isn't specified then the 
  18766.                           Postscript is returned as the result of the command 
  18767.                           instead of being written to a file. 
  18768.  
  18769.            -fontmap varName  VarName must be the name of an array variable that 
  18770.                           specifies a font mapping to use in the Postscript. 
  18771.                           Each element of varName must consist of a Tcl list 
  18772.                           with two elements, which are the name and point size 
  18773.                           of a Postscript font. When outputting Postscript 
  18774.                           commands for a particular font, Tk checks to see if 
  18775.                           varName contains an element with the same name as the 
  18776.                           font. If there is such an element, then the font 
  18777.                           information contained in that element is used in the 
  18778.                           Postscript. Otherwise Tk attempts to guess what 
  18779.                           Postscript font to use. Tk's guesses generally only 
  18780.                           work for well-known fonts such as Times and Helvetica 
  18781.                           and Courier, and only if the X font name does not 
  18782.                           omit any dashes up through the point size. For 
  18783.                           example, -*-Courier-Bold-R-Normal--*-120-* will work 
  18784.                           but *Courier-Bold-R-Normal*120* will not;  Tk needs 
  18785.                           the dashes to parse the font name). 
  18786.  
  18787.            -height size   Specifies the height of the area of the canvas to 
  18788.                           print. Defaults to the height of the canvas window. 
  18789.  
  18790.            -pageanchor anchor  Specifies which point of the printed area of the 
  18791.                           canvas should appear over the positioning point on 
  18792.                           the page (which is given by the -pagex and -pagey 
  18793.                           options). For example, -pageanchor n means that the 
  18794.                           top center of the area of the canvas being printed 
  18795.                           (as it appears in the canvas window) should be over 
  18796.                           the positioning point. Defaults to center. 
  18797.  
  18798.            -pageheight size  Specifies that the Postscript should be scaled in 
  18799.                           both x and y so that the printed area is size high on 
  18800.                           the Postscript page. Size consists of a 
  18801.                           floating-point number followed by c for centimeters, 
  18802.                           i for inches, m for millimeters, or p or nothing for 
  18803.                           printer's points (1/72 inch). Defaults to the height 
  18804.                           of the printed area on the screen. If both 
  18805.                           -pageheight and -pagewidth are specified then the 
  18806.                           scale factor from -pagewidth is used (non-uniform 
  18807.                           scaling is not implemented). 
  18808.  
  18809.            -pagewidth size  Specifies that the Postscript should be scaled in 
  18810.                           both x and y so that the printed area is size wide on 
  18811.                           the Postscript page. Size has the same form as for 
  18812.                           -pageheight. Defaults to the width of the printed 
  18813.                           area on the screen. If both -pageheight and 
  18814.                           -pagewidth are specified then the scale factor from 
  18815.                           -pagewidth  is used (non-uniform scaling is not 
  18816.                           implemented). 
  18817.  
  18818.            -pagex position  Position gives the x-coordinate of the positioning 
  18819.                           point on the Postscript page, using any of the forms 
  18820.                           allowed for -pageheight. Used in conjunction with the 
  18821.                           -pagey and -pageanchor options to determine where the 
  18822.                           printed area appears on the Postscript page. Defaults 
  18823.                           to the center of the page. 
  18824.  
  18825.            -pagey position  Position gives the y-coordinate of the positioning 
  18826.                           point on the Postscript page, using any of the forms 
  18827.                           allowed for -pageheight. Used in conjunction with the 
  18828.                           -pagex and -pageanchor options to determine where the 
  18829.                           printed area appears on the Postscript page. Defaults 
  18830.                           to the center of the page. 
  18831.  
  18832.            -rotate boolean  Boolean specifies whether the printed area is to be 
  18833.                           rotated 90 degrees. In non-rotated output the x-axis 
  18834.                           of the printed area runs along the short dimension of 
  18835.                           the page ("portrait" orientation); in rotated output 
  18836.                           the x-axis runs along the long dimension of the page 
  18837.                           ("landscape" orientation). Defaults to non-rotated. 
  18838.  
  18839.            -width size    Specifies the width of the area of the canvas to 
  18840.                           print. Defaults to the width of the canvas window. 
  18841.  
  18842.            -x position    Specifies the x-coordinate of the left edge of the 
  18843.                           area of the canvas that is to be printed, in canvas 
  18844.                           coordinates, not window coordinates. Defaults to the 
  18845.                           coordinate of the left edge of the window. 
  18846.  
  18847.            -y position    Specifies the y-coordinate of the top edge of the 
  18848.                           area of the canvas that is to be printed, in canvas 
  18849.                           coordinates, not window coordinates. Defaults to the 
  18850.                           coordinate of the top edge of the window. 
  18851.  
  18852.  pathName raise tagOrId ?aboveThis?  Move all of the items given by tagOrId to 
  18853.            a new position in the display list just after the item given by 
  18854.            aboveThis. If tagOrId refers to more than one item then all are 
  18855.            moved but the relative order of the moved items will not be changed. 
  18856.            AboveThis is a tag or id;  if it refers to more than one item then 
  18857.            the last ( topmost) of these items in the display list is used as 
  18858.            the destination location for the moved items. This command returns 
  18859.            an empty string. 
  18860.  
  18861.  pathName scale tagOrId xOrigin yOrigin xScale yScale  Rescale all of the items 
  18862.            given by tagOrId in canvas coordinate space. XOrigin and yOrigin 
  18863.            identify the origin for the scaling operation and xScale and yScale 
  18864.            identify the scale factors for x- and y-coordinates, respectively (a 
  18865.            scale factor of 1.0 implies no change to that coordinate). For each 
  18866.            of the points defining each item, the x-coordinate is adjusted to 
  18867.            change the distance from xOrigin by a factor of xScale. Similarly, 
  18868.            each y-coordinate is adjusted to change the distance from yOrigin by 
  18869.            a factor of yScale. This command returns an empty string. 
  18870.  
  18871.  pathName scan option args  This command is used to implement scanning on 
  18872.            canvases.  It has two forms, depending on option: 
  18873.  
  18874.            pathName scan mark x y  Records x and y and the canvas's current 
  18875.                           view;  used in conjunction with later scan dragto 
  18876.                           commands. Typically this command is associated with a 
  18877.                           mouse button press in the widget and x and y are the 
  18878.                           coordinates of the mouse.  It returns an empty 
  18879.                           string. 
  18880.  
  18881.            pathName scan dragto x y.  This command computes the difference 
  18882.                           between its x and y arguments (which are typically 
  18883.                           mouse coordinates) and the x and y arguments to the 
  18884.                           last scan mark command for the widget. It then 
  18885.                           adjusts the view by 10 times the difference in 
  18886.                           coordinates.  This command is typically associated 
  18887.                           with mouse motion events in the widget, to produce 
  18888.                           the effect of dragging the canvas at high speed 
  18889.                           through its window.  The return value is an empty 
  18890.                           string. 
  18891.  
  18892.  pathName select option ?tagOrId arg?  Manipulates the selection in one of 
  18893.            several ways, depending on option. The command may take any of the 
  18894.            forms described below. In all of the descriptions below, tagOrId 
  18895.            must refer to an item that supports indexing and selection;  if it 
  18896.            refers to multiple items then the first of these that supports 
  18897.            indexing and the selection is used. Index gives a textual 
  18898.            description of a position within tagOrId, as described in INDICES 
  18899.            above. 
  18900.  
  18901.            pathName select adjust tagOrId index  Locate the end of the 
  18902.                           selection in tagOrId nearest to the character given 
  18903.                           by index, and adjust that end of the selection to be 
  18904.                           at index (i.e. including but not going beyond index). 
  18905.                           The other end of the selection is made the anchor 
  18906.                           point for future select to commands. If the selection 
  18907.                           isn't currently in tagOrId then this command behaves 
  18908.                           the same as the select to widget command. Returns an 
  18909.                           empty string. 
  18910.  
  18911.            pathName select clear  Clear the selection if it is in this widget. 
  18912.                           If the selection isn't in this widget then the 
  18913.                           command has no effect. Returns an empty string. 
  18914.  
  18915.            pathName select from tagOrId index  Set the selection anchor point 
  18916.                           for the widget to be just before the character given 
  18917.                           by index in the item given by tagOrId. This command 
  18918.                           doesn't change the selection;  it just sets the fixed 
  18919.                           end of the selection for future select to commands. 
  18920.                           Returns an empty string. 
  18921.  
  18922.            pathName select item  Returns the id of the selected item, if the 
  18923.                           selection is in an item in this canvas. If the 
  18924.                           selection is not in this canvas then an empty string 
  18925.                           is returned. 
  18926.  
  18927.            pathName select to tagOrId index  Set the selection to consist of 
  18928.                           those characters of tagOrId between the selection 
  18929.                           anchor point and index. The new selection will 
  18930.                           include the character given by index; it will include 
  18931.                           the character given by the anchor point only if index 
  18932.                           is greater than or equal to the anchor point. The 
  18933.                           anchor point is determined by the most recent select 
  18934.                           adjust or select from command for this widget. If the 
  18935.                           selection anchor point for the widget isn't currently 
  18936.                           in tagOrId, then it is set to the same character 
  18937.                           given by index. Returns an empty string. 
  18938.  
  18939.  pathName type tagOrId  Returns the type of the item given by tagOrId, such as 
  18940.            rectangle or text. If tagOrId refers to more than one item, then the 
  18941.            type of the first item in the display list is returned. If tagOrId 
  18942.            doesn't refer to any items at all then an empty string is returned. 
  18943.  
  18944.  pathName xview  ?args?  This command is used to query and change the 
  18945.            horizontal position of the information displayed in the canvas's 
  18946.            window. It can take any of the following forms: 
  18947.  
  18948.            pathName xview  Returns a list containing two elements. Each element 
  18949.                           is a real fraction between 0 and 1;  together they 
  18950.                           describe the horizontal span that is visible in the 
  18951.                           window. For example, if the first element is .2 and 
  18952.                           the second element is .6, 20% of the canvas's area 
  18953.                           (as defined by the -scrollregion option) is 
  18954.                           off-screen to the left, the middle 40% is visible in 
  18955.                           the window, and 40% of the canvas is off-screen to 
  18956.                           the right. These are the same values passed to 
  18957.                           scrollbars via the -xscrollcommand option. 
  18958.  
  18959.            pathName xview moveto fraction  Adjusts the view in the window so 
  18960.                           that fraction of the total width of the canvas is 
  18961.                           off-screen to the left. Fraction must be a fraction 
  18962.                           between 0 and 1. 
  18963.  
  18964.            pathName xview scroll number what  This command shifts the view in 
  18965.                           the window left or right according to number and 
  18966.                           what. Number must be an integer. What must be either 
  18967.                           units or pages or an abbreviation of one of these. If 
  18968.                           what is units, the view adjusts left or right in 
  18969.                           units of the xScrollIncrement option, if it is 
  18970.                           greater than zero, or in units of one-tenth the 
  18971.                           window's width otherwise. If what is pages then the 
  18972.                           view adjusts in units of nine-tenths the window's 
  18973.                           width. If number is negative then information farther 
  18974.                           to the left becomes visible;  if it is positive then 
  18975.                           information farther to the right becomes visible. 
  18976.  
  18977.  pathName yview ?args?  This command is used to query and change the vertical 
  18978.            position of the information displayed in the canvas's window. It can 
  18979.            take any of the following forms: 
  18980.  
  18981.            pathName yview  Returns a list containing two elements. Each element 
  18982.                           is a real fraction between 0 and 1;  together they 
  18983.                           describe the vertical span that is visible in the 
  18984.                           window. For example, if the first element is .6 and 
  18985.                           the second element is 1.0, the lowest 40% of the 
  18986.                           canvas's area (as defined by the -scrollregion 
  18987.                           option) is visible in the window. These are the same 
  18988.                           values passed to scrollbars via the -yscrollcommand 
  18989.                           option. 
  18990.  
  18991.            pathName yview moveto fraction  Adjusts the view in the window so 
  18992.                           that fraction of the canvas's area is off-screen to 
  18993.                           the top. Fraction is a fraction between 0 and 1. 
  18994.  
  18995.            pathName yview scroll number what  This command adjusts the view in 
  18996.                           the window up or down according to number and what. 
  18997.                           Number must be an integer. What must be either units 
  18998.                           or pages. If what is units, the view adjusts up or 
  18999.                           down in units of the yScrollIncrement option, if it 
  19000.                           is greater than zero, or in units of one-tenth the 
  19001.                           window's height otherwise. If what is pages then the 
  19002.                           view adjusts in units of nine-tenths the window's 
  19003.                           height. If number is negative then higher information 
  19004.                           becomes visible;  if it is positive then lower 
  19005.                           information becomes visible. 
  19006.  
  19007.  OVERVIEW OF ITEM TYPES 
  19008.  
  19009.  The sections below describe the various types of items supported by canvas 
  19010.  widgets.  Each item type is characterized by two things: first, the form of 
  19011.  the create command used to create instances of the type;  and second, a set of 
  19012.  configuration options for items of that type, which may be used in the create 
  19013.  and itemconfigure widget commands. Most items don't support indexing or 
  19014.  selection or the commands related to them, such as index and insert. Where 
  19015.  items do support these facilities, it is noted explicitly in the descriptions 
  19016.  below (at present, only text items provide this support). 
  19017.  
  19018.  ARC ITEMS 
  19019.  
  19020.  Items of type arc appear on the display as arc-shaped regions. An arc is a 
  19021.  section of an oval delimited by two angles (specified by the -start and 
  19022.  -extent options) and displayed in one of several ways (specified by the -style 
  19023.  option). Arcs are created with widget commands of the following form: 
  19024.  
  19025.   pathName create arc x1 y1 x2 y2 ?option value option value ...?
  19026.  The arguments x1, y1, x2, and y2 give the coordinates of two diagonally 
  19027.  opposite corners of a rectangular region enclosing the oval that defines the 
  19028.  arc. After the coordinates there may be any number of option-value pairs, each 
  19029.  of which sets one of the configuration options for the item.  These same 
  19030.  option-value pairs may be used in itemconfigure widget commands to change the 
  19031.  item's configuration. The following options are supported for arcs: 
  19032.  
  19033.  -extent degrees  Specifies the size of the angular range occupied by the arc. 
  19034.            The arc's range extends for degrees degrees counter-clockwise from 
  19035.            the starting angle given by the -start option. Degrees may be 
  19036.            negative. If it is greater than 360 or less than -360, then degrees 
  19037.            modulo 360 is used as the extent. 
  19038.  
  19039.  -fill color  Fill the region of the arc with color. Color may have any of the 
  19040.            forms accepted by Tk_GetColor. If color is an empty string (the 
  19041.            default), then then the arc will not be filled. 
  19042.  
  19043.  -outline color  Color specifies a color to use for drawing the arc's outline; 
  19044.            it may have any of the forms accepted by Tk_GetColor. This option 
  19045.            defaults to black.  If color is specified as an empty string then no 
  19046.            outline is drawn for the arc. 
  19047.  
  19048.  -outlinestipple bitmap  Indicates that the outline for the arc should be drawn 
  19049.            with a stipple pattern; bitmap specifies the stipple pattern to use, 
  19050.            in any of the forms accepted by Tk_GetBitmap. If the -outline option 
  19051.            hasn't been specified then this option has no effect. If bitmap is 
  19052.            an empty string (the default), then the outline is drawn in a solid 
  19053.            fashion. 
  19054.  
  19055.  -start degrees  Specifies the beginning of the angular range occupied by the 
  19056.            arc. Degrees is given in units of degrees measured counter-clockwise 
  19057.            from the 3-o'clock position;  it may be either positive or negative. 
  19058.  
  19059.  -stipple bitmap  Indicates that the arc should be filled in a stipple pattern; 
  19060.            bitmap specifies the stipple pattern to use, in any of the forms 
  19061.            accepted by Tk_GetBitmap. If the -fill option hasn't been specified 
  19062.            then this option has no effect. If bitmap is an empty string (the 
  19063.            default), then filling is done in a solid fashion. 
  19064.  
  19065.  -style type  Specifies how to draw the arc.  If type is pieslice (the default) 
  19066.            then the arc's region is defined by a section of the oval's 
  19067.            perimeter plus two line segments, one between the center of the oval 
  19068.            and each end of the perimeter section. If type is chord then the 
  19069.            arc's region is defined by a section of the oval's perimeter plus a 
  19070.            single line segment connecting the two end points of the perimeter 
  19071.            section. If type is arc then the arc's region consists of a section 
  19072.            of the perimeter alone. In this last case the -fill option is 
  19073.            ignored. 
  19074.  
  19075.  -tags tagList  Specifies a set of tags to apply to the item. TagList consists 
  19076.            of a list of tag names, which replace any existing tags for the 
  19077.            item. TagList may be an empty list. 
  19078.  
  19079.  -width outlineWidth  Specifies the width of the outline to be drawn around the 
  19080.            arc's region, in any of the forms described in the COORDINATES 
  19081.            section above. If the -outline option has been specified as an empty 
  19082.            string then this option has no effect. Wide outlines will be drawn 
  19083.            centered on the edges of the arc's region. This option defaults to 
  19084.            1.0. 
  19085.  
  19086.  BITMAP ITEMS 
  19087.  
  19088.  Items of type bitmap appear on the display as images with two colors, 
  19089.  foreground and background. Bitmaps are created with widget commands of the 
  19090.  following form: 
  19091.  
  19092.   pathName create bitmap x y ?option value option value ...?
  19093.  The arguments x and y specify the coordinates of a point used to position the 
  19094.  bitmap on the display (see the -anchor option below for more information on 
  19095.  how bitmaps are displayed). After the coordinates there may be any number of 
  19096.  option-value pairs, each of which sets one of the configuration options for 
  19097.  the item.  These same option-value pairs may be used in itemconfigure widget 
  19098.  commands to change the item's configuration. The following options are 
  19099.  supported for bitmaps: 
  19100.  
  19101.  -anchor anchorPos  AnchorPos tells how to position the bitmap relative to the 
  19102.            positioning point for the item;  it may have any of the forms 
  19103.            accepted by Tk_GetAnchor.  For example, if anchorPos is center then 
  19104.            the bitmap is centered on the point;  if anchorPos is n then the 
  19105.            bitmap will be drawn so that its top center point is at the 
  19106.            positioning point. This option defaults to center. 
  19107.  
  19108.  -background color  Specifies a color to use for each of the bitmap pixels 
  19109.            whose value is 0. Color may have any of the forms accepted by 
  19110.            Tk_GetColor. If this option isn't specified, or if it is specified 
  19111.            as an empty string, then nothing is displayed where the bitmap 
  19112.            pixels are 0;  this produces a transparent effect. 
  19113.  
  19114.  -bitmap bitmap  Specifies the bitmap to display in the item. Bitmap may have 
  19115.            any of the forms accepted by Tk_GetBitmap. 
  19116.  
  19117.  -foreground color  Specifies a color to use for each of the bitmap pixels 
  19118.            whose value is 1. Color may have any of the forms accepted by 
  19119.            Tk_GetColor and defaults to black. 
  19120.  
  19121.  -tags tagList  Specifies a set of tags to apply to the item. TagList consists 
  19122.            of a list of tag names, which replace any existing tags for the 
  19123.            item. TagList may be an empty list. 
  19124.  
  19125.  IMAGE ITEMS 
  19126.  
  19127.  Items of type image are used to display images on a canvas. Images are created 
  19128.  with widget commands of the following form: 
  19129.  
  19130.   pathName create image x y ?option value option value ...?
  19131.  The arguments x and y specify the coordinates of a point used to position the 
  19132.  image on the display (see the -anchor option below for more information). 
  19133.  After the coordinates there may be any number of option-value pairs, each of 
  19134.  which sets one of the configuration options for the item.  These same 
  19135.  option-value pairs may be used in itemconfigure widget commands to change the 
  19136.  item's configuration. The following options are supported for images: 
  19137.  
  19138.  -anchor anchorPos  AnchorPos tells how to position the image relative to the 
  19139.            positioning point for the item;  it may have any of the forms 
  19140.            accepted by Tk_GetAnchor.  For example, if anchorPos is center then 
  19141.            the image is centered on the point;  if anchorPos is n then the 
  19142.            image will be drawn so that its top center point is at the 
  19143.            positioning point. This option defaults to center. 
  19144.  
  19145.  -image name  Specifies the name of the image to display in the item. This 
  19146.            image must have been created previously with the image create 
  19147.            command. 
  19148.  
  19149.  -tags tagList  Specifies a set of tags to apply to the item. TagList consists 
  19150.            of a list of tag names, which replace any existing tags for the 
  19151.            item;  it may be an empty list. 
  19152.  
  19153.  LINE ITEMS 
  19154.  
  19155.  Items of type line appear on the display as one or more connected line 
  19156.  segments or curves. Lines are created with widget commands of the following 
  19157.  form: 
  19158.  
  19159.   pathName create line x1 y1... xn yn ?option value option value ...?
  19160.  The arguments x1 through yn give the coordinates for a series of two or more 
  19161.  points that describe a series of connected line segments. After the 
  19162.  coordinates there may be any number of option-value pairs, each of which sets 
  19163.  one of the configuration options for the item.  These same option-value pairs 
  19164.  may be used in itemconfigure widget commands to change the item's 
  19165.  configuration. The following options are supported for lines: 
  19166.  
  19167.  -arrow where  Indicates whether or not arrowheads are to be drawn at one or 
  19168.            both ends of the line. Where must have one of the values none (for 
  19169.            no arrowheads), first (for an arrowhead at the first point of the 
  19170.            line), last (for an arrowhead at the last point of the line), or 
  19171.            both (for arrowheads at both ends). This option defaults to none. 
  19172.  
  19173.  -arrowshape shape  This option indicates how to draw arrowheads. The shape 
  19174.            argument must be a list with three elements, each specifying a 
  19175.            distance in any of the forms described in the COORDINATES section 
  19176.            above. The first element of the list gives the distance along the 
  19177.            line from the neck of the arrowhead to its tip. The second element 
  19178.            gives the distance along the line from the trailing points of the 
  19179.            arrowhead to the tip, and the third element gives the distance from 
  19180.            the outside edge of the line to the trailing points. If this option 
  19181.            isn't specified then Tk picks a "reasonable" shape. 
  19182.  
  19183.  -capstyle style  Specifies the ways in which caps are to be drawn at the 
  19184.            endpoints of the line. Style may have any of the forms accepted by 
  19185.            Tk_GetCapStyle (butt, projecting, or round). If this option isn't 
  19186.            specified then it defaults to butt. Where arrowheads are drawn the 
  19187.            cap style is ignored. 
  19188.  
  19189.  -fill color  Color specifies a color to use for drawing the line; it may have 
  19190.            any of the forms acceptable to Tk_GetColor.  It may also be an empty 
  19191.            string, in which case the line will be transparent. This option 
  19192.            defaults to black. 
  19193.  
  19194.  -joinstyle style  Specifies the ways in which joints are to be drawn at the 
  19195.            vertices of the line. Style may have any of the forms accepted by 
  19196.            Tk_GetCapStyle (bevel, miter, or round). If this option isn't 
  19197.            specified then it defaults to miter. If the line only contains two 
  19198.            points then this option is irrelevant. 
  19199.  
  19200.  -smooth boolean  Boolean must have one of the forms accepted by Tk_GetBoolean. 
  19201.            It indicates whether or not the line should be drawn as a curve. If 
  19202.            so, the line is rendered as a set of Bezier splines: one spline is 
  19203.            drawn for the first and second line segments, one for the second and 
  19204.            third, and so on.  Straight-line segments can be generated within a 
  19205.            curve by duplicating the end-points of the desired line segment. 
  19206.  
  19207.  -splinesteps number  Specifies the degree of smoothness desired for curves: 
  19208.            each spline will be approximated with number line segments.  This 
  19209.            option is ignored unless the -smooth option is true. 
  19210.  
  19211.  -stipple bitmap  Indicates that the line should be filled in a stipple 
  19212.            pattern; bitmap specifies the stipple pattern to use, in any of the 
  19213.            forms accepted by Tk_GetBitmap. If bitmap is an empty string (the 
  19214.            default), then filling is done in a solid fashion. 
  19215.  
  19216.  -tags tagList  Specifies a set of tags to apply to the item. TagList consists 
  19217.            of a list of tag names, which replace any existing tags for the 
  19218.            item. TagList may be an empty list. 
  19219.  
  19220.  -width lineWidth  LineWidth specifies the width of the line, in any of the 
  19221.            forms described in the COORDINATES section above. Wide lines will be 
  19222.            drawn centered on the path specified by the points. If this option 
  19223.            isn't specified then it defaults to 1.0. 
  19224.  
  19225.  OVAL ITEMS 
  19226.  
  19227.  Items of type oval appear as circular or oval regions on the display.  Each 
  19228.  oval may have an outline, a fill, or both.  Ovals are created with widget 
  19229.  commands of the following form: 
  19230.  
  19231.   pathName create oval x1 y1 x2 y2 ?option value option value ...?
  19232.  The arguments x1, y1, x2, and y2 give the coordinates of two diagonally 
  19233.  opposite corners of a rectangular region enclosing the oval. The oval will 
  19234.  include the top and left edges of the rectangle not the lower or right edges. 
  19235.  If the region is square then the resulting oval is circular; otherwise it is 
  19236.  elongated in shape. After the coordinates there may be any number of 
  19237.  option-value pairs, each of which sets one of the configuration options for 
  19238.  the item.  These same option-value pairs may be used in itemconfigure widget 
  19239.  commands to change the item's configuration. The following options are 
  19240.  supported for ovals: 
  19241.  
  19242.  -fill color  Fill the area of the oval with color. Color may have any of the 
  19243.            forms accepted by Tk_GetColor. If color is an empty string (the 
  19244.            default), then then the oval will not be filled. 
  19245.  
  19246.  -outline color  Color specifies a color to use for drawing the oval's outline; 
  19247.            it may have any of the forms accepted by Tk_GetColor. This option 
  19248.            defaults to black. If color is an empty string then no outline will 
  19249.            be drawn for the oval. 
  19250.  
  19251.  -stipple bitmap  Indicates that the oval should be filled in a stipple 
  19252.            pattern; bitmap specifies the stipple pattern to use, in any of the 
  19253.            forms accepted by Tk_GetBitmap. If the -fill option hasn't been 
  19254.            specified then this option has no effect. If bitmap is an empty 
  19255.            string (the default), then filling is done in a solid fashion. 
  19256.  
  19257.  -tags tagList  Specifies a set of tags to apply to the item. TagList consists 
  19258.            of a list of tag names, which replace any existing tags for the 
  19259.            item. TagList may be an empty list. 
  19260.  
  19261.  -width outlineWidth  outlineWidth specifies the width of the outline to be 
  19262.            drawn around the oval, in any of the forms described in the 
  19263.            COORDINATES section above. If the -outline option hasn't been 
  19264.            specified then this option has no effect. Wide outlines are drawn 
  19265.            centered on the oval path defined by x1, y1, x2, and y2. This option 
  19266.            defaults to 1.0. 
  19267.  
  19268.  POLYGON ITEMS 
  19269.  
  19270.  Items of type polygon appear as polygonal or curved filled regions on the 
  19271.  display. Polygons are created with widget commands of the following form: 
  19272.  
  19273.   pathName create polygon x1 y1 ... xn yn ?option value option value ...?
  19274.  The arguments x1 through yn specify the coordinates for three or more points 
  19275.  that define a closed polygon. The first and last points may be the same; 
  19276.  whether they are or not, Tk will draw the polygon as a closed polygon. After 
  19277.  the coordinates there may be any number of option-value pairs, each of which 
  19278.  sets one of the configuration options for the item.  These same option-value 
  19279.  pairs may be used in itemconfigure widget commands to change the item's 
  19280.  configuration. The following options are supported for polygons: 
  19281.  
  19282.  -fill color  Color specifies a color to use for filling the area of the 
  19283.            polygon; it may have any of the forms acceptable to Tk_GetColor. If 
  19284.            color is an empty string then the polygon will be transparent. This 
  19285.            option defaults to black. 
  19286.  
  19287.  -outline color  Color specifies a color to use for drawing the polygon's 
  19288.            outline;  it may have any of the forms accepted by Tk_GetColor. If 
  19289.            color is an empty string then no outline will be drawn for the 
  19290.            polygon. This option defaults to empty (no outline). 
  19291.  
  19292.  -smooth boolean  Boolean must have one of the forms accepted by Tk_GetBoolean 
  19293.            It indicates whether or not the polygon should be drawn with a 
  19294.            curved perimeter. If so, the outline of the polygon becomes a set of 
  19295.            Bezier splines, one spline for the first and second line segments, 
  19296.            one for the second and third, and so on.  Straight-line segments can 
  19297.            be generated in a smoothed polygon by duplicating the end-points of 
  19298.            the desired line segment. 
  19299.  
  19300.  -splinesteps number  Specifies the degree of smoothness desired for curves: 
  19301.            each spline will be approximated with number line segments.  This 
  19302.            option is ignored unless the -smooth option is true. 
  19303.  
  19304.  -stipple bitmap  Indicates that the polygon should be filled in a stipple 
  19305.            pattern; bitmap specifies the stipple pattern to use, in any of the 
  19306.            forms accepted by Tk_GetBitmap. If bitmap is an empty string (the 
  19307.            default), then filling is done in a solid fashion. 
  19308.  
  19309.  -tags tagList  Specifies a set of tags to apply to the item. TagList consists 
  19310.            of a list of tag names, which replace any existing tags for the 
  19311.            item. TagList may be an empty list. 
  19312.  
  19313.  -width outlineWidth  OutlineWidth specifies the width of the outline to be 
  19314.            drawn around the polygon, in any of the forms described in the 
  19315.            COORDINATES section above. If the -outline option hasn't been 
  19316.            specified then this option has no effect.  This option defaults to 
  19317.            1.0. 
  19318.  
  19319.  Polygon items are different from other items such as rectangles, ovals and 
  19320.  arcs in that interior points are considered to be "inside" a polygon (e.g. for 
  19321.  purposes of the find closest and find overlapping widget commands) even if it 
  19322.  is not filled. For most other item types, an interior point is considered to 
  19323.  be inside the item only if the item is filled or if it has neither a fill nor 
  19324.  an outline.  If you would like an unfilled polygon whose interior points are 
  19325.  not considered to be inside the polygon, use a line item instead. 
  19326.  
  19327.  RECTANGLE ITEMS 
  19328.  
  19329.  Items of type rectangle appear as rectangular regions on the display.  Each 
  19330.  rectangle may have an outline, a fill, or both.  Rectangles are created with 
  19331.  widget commands of the following form: 
  19332.  
  19333.   pathName create rectangle x1 y1 x2 y2 ?option value option value ...?
  19334.  The arguments x1, y1, x2, and y2 give the coordinates of two diagonally 
  19335.  opposite corners of the rectangle (the rectangle will include its upper and 
  19336.  left edges but not its lower or right edges). After the coordinates there may 
  19337.  be any number of option-value pairs, each of which sets one of the 
  19338.  configuration options for the item.  These same option-value pairs may be used 
  19339.  in itemconfigure widget commands to change the item's configuration. The 
  19340.  following options are supported for rectangles: 
  19341.  
  19342.  -fill color  Fill the area of the rectangle with color, which may be specified 
  19343.            in any of the forms accepted by Tk_GetColor. If color is an empty 
  19344.            string (the default), then the rectangle will not be filled. 
  19345.  
  19346.  -outline color  Draw an outline around the edge of the rectangle in color. 
  19347.            Color may have any of the forms accepted by Tk_GetColor. This option 
  19348.            defaults to black. If color is an empty string then no outline will 
  19349.            be drawn for the rectangle. 
  19350.  
  19351.  -stipple bitmap  Indicates that the rectangle should be filled in a stipple 
  19352.            pattern; bitmap specifies the stipple pattern to use, in any of the 
  19353.            forms accepted by Tk_GetBitmap. If the -fill option hasn't been 
  19354.            specified then this option has no effect. If bitmap is an empty 
  19355.            string (the default), then filling is done in a solid fashion. 
  19356.  
  19357.  -tags tagList  Specifies a set of tags to apply to the item. TagList consists 
  19358.            of a list of tag names, which replace any existing tags for the 
  19359.            item. TagList may be an empty list. 
  19360.  
  19361.  -width outlineWidth  OutlineWidth specifies the width of the outline to be 
  19362.            drawn around the rectangle, in any of the forms described in the 
  19363.            COORDINATES section above. If the -outline option hasn't been 
  19364.            specified then this option has no effect. Wide outlines are drawn 
  19365.            centered on the rectangular path defined by x1, y1, x2, and y2. This 
  19366.            option defaults to 1.0. 
  19367.  
  19368.  TEXT ITEMS 
  19369.  
  19370.  A text item displays a string of characters on the screen in one or more 
  19371.  lines. Text items support indexing and selection, along with the following 
  19372.  text-related canvas widget commands:  dchars, focus, icursor, index, insert, 
  19373.  select. Text items are created with widget commands of the following form: 
  19374.  
  19375.   pathName create text x y ?option value option value ...?
  19376.  The arguments x and y specify the coordinates of a point used to position the 
  19377.  text on the display (see the options below for more information on how text is 
  19378.  displayed). After the coordinates there may be any number of option-value 
  19379.  pairs, each of which sets one of the configuration options for the item. 
  19380.  These same option-value pairs may be used in itemconfigure widget commands to 
  19381.  change the item's configuration. The following options are supported for text 
  19382.  items: 
  19383.  
  19384.  -anchor anchorPos  AnchorPos tells how to position the text relative to the 
  19385.            positioning point for the text;  it may have any of the forms 
  19386.            accepted by Tk_GetAnchor.  For example, if anchorPos is center then 
  19387.            the text is centered on the point;  if anchorPos is n then the text 
  19388.            will be drawn such that the top center point of the rectangular 
  19389.            region occupied by the text will be at the positioning point. This 
  19390.            option defaults to center. 
  19391.  
  19392.  -fill color  Color specifies a color to use for filling the text characters; 
  19393.            it may have any of the forms accepted by Tk_GetColor. If this option 
  19394.            isn't specified then it defaults to black. 
  19395.  
  19396.  -font fontName  Specifies the font to use for the text item. FontName may be 
  19397.            any string acceptable to Tk_GetFontStruct. If this option isn't 
  19398.            specified, it defaults to a system-dependent font. 
  19399.  
  19400.  -justify how  Specifies how to justify the text within its bounding region. 
  19401.            How must be one of the values left, right, or center. This option 
  19402.            will only matter if the text is displayed as multiple lines. If the 
  19403.            option is omitted, it defaults to left. 
  19404.  
  19405.  -stipple bitmap  Indicates that the text should be drawn in a stippled pattern 
  19406.            rather than solid; bitmap specifies the stipple pattern to use, in 
  19407.            any of the forms accepted by Tk_GetBitmap. If bitmap is an empty 
  19408.            string (the default) then the text is drawn in a solid fashion. 
  19409.  
  19410.  -tags tagList  Specifies a set of tags to apply to the item. TagList consists 
  19411.            of a list of tag names, which replace any existing tags for the 
  19412.            item. TagList may be an empty list. 
  19413.  
  19414.  -text string  String specifies the characters to be displayed in the text 
  19415.            item. Newline characters cause line breaks. The characters in the 
  19416.            item may also be changed with the insert and delete widget commands. 
  19417.            This option defaults to an empty string. 
  19418.  
  19419.  -width lineLength  Specifies a maximum line length for the text, in any of the 
  19420.            forms described in the COORDINATES section above. If this option is 
  19421.            zero (the default) the text is broken into lines only at newline 
  19422.            characters. However, if this option is non-zero then any line that 
  19423.            would be longer than lineLength is broken just before a space 
  19424.            character to make the line shorter than lineLength;  the space 
  19425.            character is treated as if it were a newline character. 
  19426.  
  19427.  WINDOW ITEMS 
  19428.  
  19429.  Items of type window cause a particular window to be displayed at a given 
  19430.  position on the canvas. Window items are created with widget commands of the 
  19431.  following form: 
  19432.  
  19433.   pathName create window x y ?option value option value ...?
  19434.  The arguments x and y specify the coordinates of a point used to position the 
  19435.  window on the display (see the -anchor option below for more information on 
  19436.  how bitmaps are displayed). After the coordinates there may be any number of 
  19437.  option-value pairs, each of which sets one of the configuration options for 
  19438.  the item.  These same option-value pairs may be used in itemconfigure widget 
  19439.  commands to change the item's configuration. The following options are 
  19440.  supported for window items: 
  19441.  
  19442.  -anchor anchorPos  AnchorPos tells how to position the window relative to the 
  19443.            positioning point for the item;  it may have any of the forms 
  19444.            accepted by Tk_GetAnchor.  For example, if anchorPos is center then 
  19445.            the window is centered on the point;  if anchorPos is n then the 
  19446.            window will be drawn so that its top center point is at the 
  19447.            positioning point. This option defaults to center. 
  19448.  
  19449.  -height pixels  Specifies the height to assign to the item's window. Pixels 
  19450.            may have any of the forms described in the COORDINATES section 
  19451.            above. If this option isn't specified, or if it is specified as an 
  19452.            empty string, then the window is given whatever height it requests 
  19453.            internally. 
  19454.  
  19455.  -tags tagList  Specifies a set of tags to apply to the item. TagList consists 
  19456.            of a list of tag names, which replace any existing tags for the 
  19457.            item. TagList may be an empty list. 
  19458.  
  19459.  -width pixels  Specifies the width to assign to the item's window. Pixels may 
  19460.            have any of the forms described in the COORDINATES section above. If 
  19461.            this option isn't specified, or if it is specified as an empty 
  19462.            string, then the window is given whatever width it requests 
  19463.            internally. 
  19464.  
  19465.  -window pathName  Specifies the window to associate with this item. The window 
  19466.            specified by pathName must either be a child of the canvas widget or 
  19467.            a child of some ancestor of the canvas widget. PathName may not 
  19468.            refer to a top-level window. 
  19469.  
  19470.  APPLICATION-DEFINED ITEM TYPES 
  19471.  
  19472.  It is possible for individual applications to define new item types for canvas 
  19473.  widgets using C code. See the documentation for Tk_CreateItemType. 
  19474.  
  19475.  BINDINGS 
  19476.  
  19477.  In the current implementation, new canvases are not given any default 
  19478.  behavior:  you'll have to execute explicit Tcl commands to give the canvas its 
  19479.  behavior. 
  19480.  
  19481.  CREDITS 
  19482.  
  19483.  Tk's canvas widget is a blatant ripoff of ideas from Joel Bartlett's ezd 
  19484.  program.  Ezd provides structured graphics in a Scheme environment and 
  19485.  preceded canvases by a year or two.  Its simple mechanisms for placing and 
  19486.  animating graphical objects inspired the functions of canvases. 
  19487.  
  19488.  KEYWORDS 
  19489.  
  19490.  canvas, widget 
  19491.  
  19492.  
  19493. ΓòÉΓòÉΓòÉ 6.7. checkbutton ΓòÉΓòÉΓòÉ
  19494.  
  19495.  NAME 
  19496.  
  19497. checkbutton - Create and manipulate checkbutton widgets 
  19498.  
  19499. SYNOPSIS 
  19500.  
  19501. checkbutton pathName ?options? 
  19502.  
  19503. STANDARD OPTIONS 
  19504.  
  19505. -activebackground    -cursor              -highlightthickness  -takefocus
  19506. -activeforeground    -disabledforeground  -image               -text
  19507. -anchor              -font                -justify             -textvariable
  19508. -background          -foreground          -padx                -underline
  19509. -bitmap              -highlightbackground -pady                -wraplength
  19510. -borderwidth         -highlightcolor      -relief
  19511.  
  19512. See the options manual entry for detailed descriptions of the above options.
  19513.  
  19514. WIDGET-SPECIFIC OPTIONS 
  19515.  
  19516.   Command-Line Name:    -command
  19517.   Database Name:        command
  19518.   Database Class:       Command
  19519.  
  19520.            Specifies a Tcl command to associate with the button.  This command 
  19521.            is typically invoked when mouse button 1 is released over the button 
  19522.            window.  The button's global variable (-variable option) will be 
  19523.            updated before the command is invoked. 
  19524.  
  19525.   Command-Line Name:    -height
  19526.   Database Name:        height
  19527.   Database Class:       Height
  19528.  
  19529.            Specifies a desired height for the button. If an image or bitmap is 
  19530.            being displayed in the button then the value is in screen units 
  19531.            (i.e. any of the forms acceptable to Tk_GetPixels); for text it is 
  19532.            in lines of text. If this option isn't specified, the button's 
  19533.            desired height is computed from the size of the image or bitmap or 
  19534.            text being displayed in it. 
  19535.  
  19536.   Command-Line Name:    -indicatoron
  19537.   Database Name:        indicatorOn
  19538.   Database Class:       IndicatorOn
  19539.  
  19540.            Specifies whether or not the indicator should be drawn.  Must be a 
  19541.            proper boolean value.  If false, the relief option is ignored and 
  19542.            the widget's relief is always sunken if the widget is selected and 
  19543.            raised otherwise. 
  19544.  
  19545.   Command-Line Name:    -offvalue
  19546.   Database Name:        offValue
  19547.   Database Class:       Value
  19548.  
  19549.            Specifies value to store in the button's associated variable 
  19550.            whenever this button is deselected.  Defaults to "0". 
  19551.  
  19552.   Command-Line Name:    -onvalue
  19553.   Database Name:        onValue
  19554.   Database Class:       Value
  19555.  
  19556.            Specifies value to store in the button's associated variable 
  19557.            whenever this button is selected.  Defaults to "1". 
  19558.  
  19559.   Command-Line Name:    -selectcolor
  19560.   Database Name:        selectColor
  19561.   Database Class:       Background
  19562.  
  19563.            Specifies a background color to use when the button is selected. If 
  19564.            indicatorOn is true then the color applicies to the indicator. If 
  19565.            indicatorOn is false, this color is used as the background for the 
  19566.            entire widget, in place of background or activeBackground, whenever 
  19567.            the widget is selected. If specified as an empty string then no 
  19568.            special color is used for displaying when the widget is selected. 
  19569.  
  19570.   Command-Line Name:    -selectimage
  19571.   Database Name:        selectImage
  19572.   Database Class:       SelectImage
  19573.  
  19574.            Specifies an image to display (in place of the image option) when 
  19575.            the checkbutton is selected. This option is ignored unless the image 
  19576.            option has been specified. 
  19577.  
  19578.   Command-Line Name:    -state
  19579.   Database Name:        state
  19580.   Database Class:       State
  19581.  
  19582.            Specifies one of three states for the checkbutton:  normal, active, 
  19583.            or disabled.  In normal state the checkbutton is displayed using the 
  19584.            foreground and background options.  The active state is typically 
  19585.            used when the pointer is over the checkbutton.  In active state the 
  19586.            checkbutton is displayed using the activeForeground and 
  19587.            activeBackground options.  Disabled state means that the checkbutton 
  19588.            should be insensitive:  the default bindings will refuse to activate 
  19589.            the widget and will ignore mouse button presses. In this state the 
  19590.            disabledForeground and background options determine how the 
  19591.            checkbutton is displayed. 
  19592.  
  19593.   Command-Line Name:    -variable
  19594.   Database Name:        variable
  19595.   Database Class:       Variable
  19596.  
  19597.            Specifies name of global variable to set to indicate whether or not 
  19598.            this button is selected.  Defaults to the name of the button within 
  19599.            its parent (i.e. the last element of the button window's path name). 
  19600.  
  19601.   Command-Line Name:    -width
  19602.   Database Name:        width
  19603.   Database Class:       Width
  19604.  
  19605.            Specifies a desired width for the button. If an image or bitmap is 
  19606.            being displayed in the button then the value is in screen units 
  19607.            (i.e. any of the forms acceptable to Tk_GetPixels); for text it is 
  19608.            in characters. If this option isn't specified, the button's desired 
  19609.            width is computed from the size of the image or bitmap or text being 
  19610.            displayed in it. 
  19611.  
  19612.  DESCRIPTION 
  19613.  
  19614.  The checkbutton command creates a new window (given by the pathName argument) 
  19615.  and makes it into a checkbutton widget. Additional options, described above, 
  19616.  may be specified on the command line or in the option database to configure 
  19617.  aspects of the checkbutton such as its colors, font, text, and initial relief. 
  19618.  The checkbutton command returns its pathName argument.  At the time this 
  19619.  command is invoked, there must not exist a window named pathName, but 
  19620.  pathName's parent must exist. 
  19621.  
  19622.  A checkbutton is a widget that displays a textual string, bitmap or image and 
  19623.  a square called an indicator. If text is displayed, it must all be in a single 
  19624.  font, but it can occupy multiple lines on the screen (if it contains newlines 
  19625.  or if wrapping occurs because of the wrapLength option) and one of the 
  19626.  characters may optionally be underlined using the underline option. A 
  19627.  checkbutton has all of the behavior of a simple button, including the 
  19628.  following: it can display itself in either of three different ways, according 
  19629.  to the state option; it can be made to appear raised, sunken, or flat; it can 
  19630.  be made to flash; and it invokes a Tcl command whenever mouse button 1 is 
  19631.  clicked over the checkbutton. 
  19632.  
  19633.  In addition, checkbuttons can be selected. If a checkbutton is selected then 
  19634.  the indicator is normally drawn with a sunken relief and a special color, and 
  19635.  a Tcl variable associated with the checkbutton is set to a particular value 
  19636.  (normally 1). If the checkbutton is not selected, then the indicator is drawn 
  19637.  with a raised relief and no special color, and the associated variable is set 
  19638.  to a different value (typically 0). By default, the name of the variable 
  19639.  associated with a checkbutton is the same as the name used to create the 
  19640.  checkbutton. The variable name, and the "on" and "off" values stored in it, 
  19641.  may be modified with options on the command line or in the option database. 
  19642.  Configuration options may also be used to modify the way the indicator is 
  19643.  displayed (or whether it is displayed at all). By default a checkbutton is 
  19644.  configured to select and deselect itself on alternate button clicks. In 
  19645.  addition, each checkbutton monitors its associated variable and automatically 
  19646.  selects and deselects itself when the variables value changes to and from the 
  19647.  button's "on" value. 
  19648.  
  19649.  WIDGET COMMAND 
  19650.  
  19651.  The checkbutton command creates a new Tcl command whose name is pathName. 
  19652.  This command may be used to invoke various operations on the widget.  It has 
  19653.  the following general form: 
  19654.  
  19655.   pathName option ?arg arg ...?
  19656.  Option and the args determine the exact behavior of the command.  The 
  19657.  following commands are possible for checkbutton widgets: 
  19658.  
  19659.  pathName cget option  Returns the current value of the configuration option 
  19660.            given by option. Option may have any of the values accepted by the 
  19661.            checkbutton command. 
  19662.  
  19663.  pathName configure ?option? ?value option value ...?  Query or modify the 
  19664.            configuration options of the widget. If no option is specified, 
  19665.            returns a list describing all of the available options for pathName 
  19666.            (see Tk_ConfigureInfo for information on the format of this list). 
  19667.            If option is specified with no value, then the command returns a 
  19668.            list describing the one named option (this list will be identical to 
  19669.            the corresponding sublist of the value returned if no option is 
  19670.            specified).  If one or more option-value pairs are specified, then 
  19671.            the command modifies the given widget option(s) to have the given 
  19672.            value(s);  in this case the command returns an empty string. Option 
  19673.            may have any of the values accepted by the checkbutton command. 
  19674.  
  19675.  pathName deselect  Deselects the checkbutton and sets the associated variable 
  19676.            to its "off" value. 
  19677.  
  19678.  pathName flash  Flashes the checkbutton.  This is accomplished by redisplaying 
  19679.            the checkbutton several times, alternating between active and normal 
  19680.            colors.  At the end of the flash the checkbutton is left in the same 
  19681.            normal/active state as when the command was invoked. This command is 
  19682.            ignored if the checkbutton's state is disabled. 
  19683.  
  19684.  pathName invoke  Does just what would have happened if the user invoked the 
  19685.            checkbutton with the mouse: toggle the selection state of the button 
  19686.            and invoke the Tcl command associated with the checkbutton, if there 
  19687.            is one. The return value is the return value from the Tcl command, 
  19688.            or an empty string if there is no command associated with the 
  19689.            checkbutton. This command is ignored if the checkbutton's state is 
  19690.            disabled. 
  19691.  
  19692.  pathName select  Selects the checkbutton and sets the associated variable to 
  19693.            its "on" value. 
  19694.  
  19695.  pathName toggle  Toggles the selection state of the button, redisplaying it 
  19696.            and modifying its associated variable to reflect the new state. 
  19697.  
  19698.  BINDINGS 
  19699.  
  19700.  Tk automatically creates class bindings for checkbuttons that give them the 
  19701.  following default behavior: 
  19702.  
  19703.    1. A checkbutton activates whenever the mouse passes over it and deactivates 
  19704.       whenever the mouse leaves the checkbutton. 
  19705.  
  19706.    2. When mouse button 1 is pressed over a checkbutton it is invoked (its 
  19707.       selection state toggles and the command associated with the button is 
  19708.       invoked, if there is one). 
  19709.  
  19710.    3. When a checkbutton has the input focus, the space key causes the 
  19711.       checkbutton to be invoked. 
  19712.  
  19713.  If the checkbutton's state is disabled then none of the above actions occur: 
  19714.  the checkbutton is completely non-responsive. 
  19715.  
  19716.  The behavior of checkbuttons can be changed by defining new bindings for 
  19717.  individual widgets or by redefining the class bindings. 
  19718.  
  19719.  KEYWORDS 
  19720.  
  19721.  checkbutton, widget 
  19722.  
  19723.  
  19724. ΓòÉΓòÉΓòÉ 6.8. tk_chooseColor ΓòÉΓòÉΓòÉ
  19725.  
  19726.  NAME 
  19727.  
  19728. tk_chooseColor - pops up a dialog box for the user to select a color. 
  19729.  
  19730. SYNOPSIS 
  19731.  
  19732. tk_chooseColor ?option value ...? 
  19733.  
  19734. DESCRIPTION 
  19735.  
  19736. The procedure tk_chooseColor pops up a dialog box for the user to select a 
  19737. color. The following option-value pairs are possible as command line arguments: 
  19738.  
  19739.  -initialcolor color  Specifies the color to display in the color dialog when 
  19740.            it pops up. color must be in a form acceptable to the Tk_GetColor 
  19741.            function. 
  19742.  
  19743.  -parent window  Makes window the logical parent of the color dialog. The color 
  19744.            dialog is displayed on top of its parent window. 
  19745.  
  19746.  -title titleString  Specifies a string to display as the title of the dialog 
  19747.            box. If this option is not specified, then a default title will be 
  19748.            displayed. 
  19749.  
  19750.  If the user selects a color, tk_chooseColor will return the name of the color 
  19751.  in a form acceptable to Tk_GetColor.  If the user cancels the operation, both 
  19752.  commands will return the empty string. 
  19753.  
  19754.  EXAMPLE 
  19755.  
  19756.   button .b -fg [tk_chooseColor -initialcolor gray -title "Choose color"]
  19757.  
  19758.  KEYWORDS 
  19759.  
  19760.  color selection dialog 
  19761.  
  19762.  
  19763. ΓòÉΓòÉΓòÉ 6.9. clipboard ΓòÉΓòÉΓòÉ
  19764.  
  19765.  NAME 
  19766.  
  19767. clipboard - Manipulate Tk clipboard 
  19768.  
  19769. SYNOPSIS 
  19770.  
  19771. clipboard option ?arg arg ...? 
  19772.  
  19773. DESCRIPTION 
  19774.  
  19775. This command provides a Tcl interface to the Tk clipboard, which stores data 
  19776. for later retrieval using the selection mechanism. In order to copy data into 
  19777. the clipboard, clipboard clear must be called, followed by a sequence of one or 
  19778. more calls to clipboard append.  To ensure that the clipboard is updated 
  19779. atomically, all appends should be completed before returning to the event loop. 
  19780.  
  19781. The first argument to clipboard determines the format of the rest of the 
  19782. arguments and the behavior of the command.  The following forms are currently 
  19783. supported: 
  19784.  
  19785.  clipboard clear ?-displayof window?  Claims ownership of the clipboard on 
  19786.            window's display and removes any previous contents.  Window defaults 
  19787.            to ".".  Returns an empty string. 
  19788.  
  19789.  clipboard append ?-displayof window? ?-format format? ?-type type? ?--? data 
  19790.            Appends data to the clipboard on window's display in the form given 
  19791.            by type with the representation given by format and claims ownership 
  19792.            of the clipboard on window's display. 
  19793.  
  19794.            Type specifies the form in which the selection is to be returned 
  19795.            (the desired "target" for conversion, in ICCCM terminology), and 
  19796.            should be an atom name such as STRING or FILE_NAME; see the 
  19797.            Inter-Client Communication Conventions Manual for complete details. 
  19798.            Type defaults to STRING. 
  19799.  
  19800.            The format argument specifies the representation that should be used 
  19801.            to transmit the selection to the requester (the second column of 
  19802.            Table 2 of the ICCCM), and defaults to STRING.  If format is STRING, 
  19803.            the selection is transmitted as 8-bit ASCII characters.  If format 
  19804.            is ATOM, then the data is divided into fields separated by white 
  19805.            space; each field is converted to its atom value, and the 32-bit 
  19806.            atom value is transmitted instead of the atom name.  For any other 
  19807.            format,  data is divided into fields separated by white space and 
  19808.            each field is converted to a 32-bit integer; an array of integers is 
  19809.            transmitted to the selection requester.  Note that strings passed to 
  19810.            clipboard append are concatenated before conversion, so the caller 
  19811.            must take care to ensure appropriate spacing across string 
  19812.            boundaries.  All items appended to the clipboard with the same type 
  19813.            must have the same format. 
  19814.  
  19815.            The format argument is needed only for compatibility with clipboard 
  19816.            requesters that don't use Tk.  If the Tk toolkit is being used to 
  19817.            retrieve the CLIPBOARD selection then the value is converted back to 
  19818.            a string at the requesting end, so format is irrelevant. 
  19819.  
  19820.            A -- argument may be specified to mark the end of options:  the next 
  19821.            argument will always be used as data. This feature may be convenient 
  19822.            if, for example, data starts with a -. 
  19823.  
  19824.  KEYWORDS 
  19825.  
  19826.  clear, format, clipboard, append, selection, type 
  19827.  
  19828.  
  19829. ΓòÉΓòÉΓòÉ 6.10. destroy ΓòÉΓòÉΓòÉ
  19830.  
  19831.  NAME 
  19832.  
  19833. destroy - Destroy one or more windows 
  19834.  
  19835. SYNOPSIS 
  19836.  
  19837. destroy ?window window ...? 
  19838.  
  19839. DESCRIPTION 
  19840.  
  19841. This command deletes the windows given by the window arguments, plus all of 
  19842. their descendants. If a window "." is deleted then the entire application will 
  19843. be destroyed. The windows are destroyed in order, and if an error occurs in 
  19844. destroying a window the command aborts without destroying the remaining 
  19845. windows. 
  19846.  
  19847. KEYWORDS 
  19848.  
  19849. application, destroy, window 
  19850.  
  19851.  
  19852. ΓòÉΓòÉΓòÉ 6.11. tk_dialog ΓòÉΓòÉΓòÉ
  19853.  
  19854.  NAME 
  19855.  
  19856. tk_dialog - Create modal dialog and wait for response 
  19857.  
  19858. SYNOPSIS 
  19859.  
  19860. tk_dialog window title text bitmap default string string ... 
  19861.  
  19862. DESCRIPTION 
  19863.  
  19864. This procedure is part of the Tk script library. Its arguments describe a 
  19865. dialog box: 
  19866.  
  19867.  window    Name of top-level window to use for dialog.  Any existing window by 
  19868.            this name is destroyed. 
  19869.  
  19870.  title     Text to appear in the window manager's title bar for the dialog. 
  19871.  
  19872.  text      Message to appear in the top portion of the dialog box. 
  19873.  
  19874.  bitmap    If non-empty, specifies a bitmap to display in the top portion of 
  19875.            the dialog, to the left of the text. If this is an empty string then 
  19876.            no bitmap is displayed in the dialog. 
  19877.  
  19878.  default   If this is an integer greater than or equal to zero, then it gives 
  19879.            the index of the button that is to be the default button for the 
  19880.            dialog (0 for the leftmost button, and so on). If less than zero or 
  19881.            an empty string then there won't be any default button. 
  19882.  
  19883.  string    There will be one button for each of these arguments. Each string 
  19884.            specifies text to display in a button, in order from left to right. 
  19885.  
  19886.  After creating a dialog box, tk_dialog waits for the user to select one of the 
  19887.  buttons either by clicking on the button with the mouse or by typing return to 
  19888.  invoke the default button (if any). Then it returns the index of the selected 
  19889.  button:  0 for the leftmost button, 1 for the button next to it, and so on. If 
  19890.  the dialog's window is destroyed before the user selects one of the buttons, 
  19891.  then -1 is returned. 
  19892.  
  19893.  While waiting for the user to respond, tk_dialog sets a local grab.  This 
  19894.  prevents the user from interacting with the application in any way except to 
  19895.  invoke the dialog box. 
  19896.  
  19897.  KEYWORDS 
  19898.  
  19899.  bitmap, dialog, modal 
  19900.  
  19901.  
  19902. ΓòÉΓòÉΓòÉ 6.12. entry ΓòÉΓòÉΓòÉ
  19903.  
  19904.  NAME 
  19905.  
  19906. entry - Create and manipulate entry widgets 
  19907.  
  19908. SYNOPSIS 
  19909.  
  19910. entry pathName ?options? 
  19911.  
  19912. STANDARD OPTIONS 
  19913.  
  19914. -background          -highlightbackground -insertontime        -selectforeground
  19915. -borderwidth         -highlightcolor      -insertwidth         -takefocus
  19916. -cursor              -highlightthickness  -justify             -textvariable
  19917. -exportselection     -insertbackground    -relief              -xscrollcommand
  19918. -font                -insertborderwidth   -selectbackground
  19919. -foreground          -insertofftime       -selectborderwidth
  19920.  
  19921. See the options manual entry for detailed descriptions of the above options.
  19922.  
  19923. WIDGET-SPECIFIC OPTIONS 
  19924.  
  19925.   Command-Line Name:    -show
  19926.   Database Name:        show
  19927.   Database Class:       Show
  19928.  
  19929.            If this option is specified, then the true contents of the entry are 
  19930.            not displayed in the window. Instead, each character in the entry's 
  19931.            value will be displayed as the first character in the value of this 
  19932.            option, such as "*". This is useful, for example, if the entry is to 
  19933.            be used to enter a password. If characters in the entry are selected 
  19934.            and copied elsewhere, the information copied will be what is 
  19935.            displayed, not the true contents of the entry. 
  19936.  
  19937.   Command-Line Name:    -state
  19938.   Database Name:        state
  19939.   Database Class:       State
  19940.  
  19941.            Specifies one of two states for the entry:  normal or disabled. If 
  19942.            the entry is disabled then the value may not be changed using widget 
  19943.            commands and no insertion cursor will be displayed, even if the 
  19944.            input focus is in the widget. 
  19945.  
  19946.   Command-Line Name:    -width
  19947.   Database Name:        width
  19948.   Database Class:       Width
  19949.  
  19950.            Specifies an integer value indicating the desired width of the entry 
  19951.            window, in average-size characters of the widget's font. If the 
  19952.            value is less than or equal to zero, the widget picks a size just 
  19953.            large enough to hold its current text. 
  19954.  
  19955.  DESCRIPTION 
  19956.  
  19957.  The entry command creates a new window (given by the pathName argument) and 
  19958.  makes it into an entry widget. Additional options, described above, may be 
  19959.  specified on the command line or in the option database to configure aspects 
  19960.  of the entry such as its colors, font, and relief.  The entry command returns 
  19961.  its pathName argument.  At the time this command is invoked, there must not 
  19962.  exist a window named pathName, but pathName's parent must exist. 
  19963.  
  19964.  An entry is a widget that displays a one-line text string and allows that 
  19965.  string to be edited using widget commands described below, which are typically 
  19966.  bound to keystrokes and mouse actions. When first created, an entry's string 
  19967.  is empty. A portion of the entry may be selected as described below. If an 
  19968.  entry is exporting its selection (see the exportSelection option), then it 
  19969.  will observe the standard X11 protocols for handling the selection;  entry 
  19970.  selections are available as type STRING. Entries also observe the standard Tk 
  19971.  rules for dealing with the input focus.  When an entry has the input focus it 
  19972.  displays an insertion cursor to indicate where new characters will be 
  19973.  inserted. 
  19974.  
  19975.  Entries are capable of displaying strings that are too long to fit entirely 
  19976.  within the widget's window.  In this case, only a portion of the string will 
  19977.  be displayed;  commands described below may be used to change the view in the 
  19978.  window.  Entries use the standard xScrollCommand mechanism for interacting 
  19979.  with scrollbars (see the description of the xScrollCommand option for 
  19980.  details).  They also support scanning, as described below. 
  19981.  
  19982.  WIDGET COMMAND 
  19983.  
  19984.  The entry command creates a new Tcl command whose name is pathName.  This 
  19985.  command may be used to invoke various operations on the widget.  It has the 
  19986.  following general form: 
  19987.  
  19988.   pathName option ?arg arg ...?
  19989.  Option and the args determine the exact behavior of the command. 
  19990.  
  19991.  Many of the widget commands for entries take one or more indices as arguments. 
  19992.  An index specifies a particular character in the entry's string, in any of the 
  19993.  following ways: 
  19994.  
  19995.  number    Specifies the character as a numerical index, where 0 corresponds to 
  19996.            the first character in the string. 
  19997.  
  19998.  anchor    Indicates the anchor point for the selection, which is set with the 
  19999.            select from and select adjust widget commands. 
  20000.  
  20001.  end       Indicates the character just after the last one in the entry's 
  20002.            string. This is equivalent to specifying a numerical index equal to 
  20003.            the length of the entry's string. 
  20004.  
  20005.  insert    Indicates the character adjacent to and immediately following the 
  20006.            insertion cursor. 
  20007.  
  20008.  sel.first  Indicates the first character in the selection.  It is an error to 
  20009.            use this form if the selection isn't in the entry window. 
  20010.  
  20011.  sel.last  Indicates the character just after the last one in the selection. It 
  20012.            is an error to use this form if the selection isn't in the entry 
  20013.            window. 
  20014.  
  20015.  @number   In this form, number is treated as an x-coordinate in the entry's 
  20016.            window;  the character spanning that x-coordinate is used. For 
  20017.            example, "@0" indicates the left-most character in the window. 
  20018.  
  20019.  Abbreviations may be used for any of the forms above, e.g. "e" or "sel.f".  In 
  20020.  general, out-of-range indices are automatically rounded to the nearest legal 
  20021.  value. 
  20022.  
  20023.  The following commands are possible for entry widgets: 
  20024.  
  20025.  pathName bbox index  Returns a list of four numbers describing the bounding 
  20026.            box of the character given by index. The first two elements of the 
  20027.            list give the x and y coordinates of the upper-left corner of the 
  20028.            screen area covered by the character (in pixels relative to the 
  20029.            widget) and the last two elements give the width and height of the 
  20030.            character, in pixels. The bounding box may refer to a region outside 
  20031.            the visible area of the window. 
  20032.  
  20033.  pathName cget option  Returns the current value of the configuration option 
  20034.            given by option. Option may have any of the values accepted by the 
  20035.            entry command. 
  20036.  
  20037.  pathName configure ?option? ?value option value ...?  Query or modify the 
  20038.            configuration options of the widget. If no option is specified, 
  20039.            returns a list describing all of the available options for pathName 
  20040.            (see Tk_ConfigureInfo for information on the format of this list). 
  20041.            If option is specified with no value, then the command returns a 
  20042.            list describing the one named option (this list will be identical to 
  20043.            the corresponding sublist of the value returned if no option is 
  20044.            specified).  If one or more option-value pairs are specified, then 
  20045.            the command modifies the given widget option(s) to have the given 
  20046.            value(s);  in this case the command returns an empty string. Option 
  20047.            may have any of the values accepted by the entry command. 
  20048.  
  20049.  pathName delete first ?last?  Delete one or more elements of the entry. First 
  20050.            is the index of the first character to delete, and last is the index 
  20051.            of the character just after the last one to delete. If last isn't 
  20052.            specified it defaults to first+1, i.e. a single character is 
  20053.            deleted. This command returns an empty string. 
  20054.  
  20055.  pathName get  Returns the entry's string. 
  20056.  
  20057.  pathName icursor index  Arrange for the insertion cursor to be displayed just 
  20058.            before the character given by index.  Returns an empty string. 
  20059.  
  20060.  pathName index index  Returns the numerical index corresponding to index. 
  20061.  
  20062.  pathName insert index string  Insert the characters of string just before the 
  20063.            character indicated by index.  Returns an empty string. 
  20064.  
  20065.  pathName scan option args  This command is used to implement scanning on 
  20066.            entries.  It has two forms, depending on option: 
  20067.  
  20068.            pathName scan mark x  Records x and the current view in the entry 
  20069.                           window;  used in conjunction with later scan dragto 
  20070.                           commands.  Typically this command is associated with 
  20071.                           a mouse button press in the widget.  It returns an 
  20072.                           empty string. 
  20073.  
  20074.            pathName scan dragto x  This command computes the difference between 
  20075.                           its x argument and the x argument to the last scan 
  20076.                           mark command for the widget.  It then adjusts the 
  20077.                           view left or right by 10 times the difference in 
  20078.                           x-coordinates.  This command is typically associated 
  20079.                           with mouse motion events in the widget, to produce 
  20080.                           the effect of dragging the entry at high speed 
  20081.                           through the window.  The return value is an empty 
  20082.                           string. 
  20083.  
  20084.  pathName selection option arg  This command is used to adjust the selection 
  20085.            within an entry.  It has several forms, depending on option: 
  20086.  
  20087.            pathName selection adjust index  Locate the end of the selection 
  20088.                           nearest to the character given by index, and adjust 
  20089.                           that end of the selection to be at index (i.e 
  20090.                           including but not going beyond index).  The other end 
  20091.                           of the selection is made the anchor point for future 
  20092.                           select to commands.  If the selection isn't currently 
  20093.                           in the entry, then a new selection is created to 
  20094.                           include the characters between index and the most 
  20095.                           recent selection anchor point, inclusive. Returns an 
  20096.                           empty string. 
  20097.  
  20098.            pathName selection clear  Clear the selection if it is currently in 
  20099.                           this widget.  If the selection isn't in this widget 
  20100.                           then the command has no effect. Returns an empty 
  20101.                           string. 
  20102.  
  20103.            pathName selection from index  Set the selection anchor point to 
  20104.                           just before the character given by index.  Doesn't 
  20105.                           change the selection. Returns an empty string. 
  20106.  
  20107.            pathName selection present  Returns 1 if there is are characters 
  20108.                           selected in the entry, 0 if nothing is selected. 
  20109.  
  20110.            pathName selection range start end  Sets the selection to include 
  20111.                           the characters starting with the one indexed by start 
  20112.                           and ending with the one just before end. If end 
  20113.                           refers to the same character as start or an earlier 
  20114.                           one, then the entry's selection is cleared. 
  20115.  
  20116.            pathName selection to index  If index is before the anchor point, 
  20117.                           set the selection to the characters from index up to 
  20118.                           but not including the anchor point. If index is the 
  20119.                           same as the anchor point, do nothing. If index is 
  20120.                           after the anchor point, set the selection to the 
  20121.                           characters from the anchor point up to but not 
  20122.                           including index. The anchor point is determined by 
  20123.                           the most recent select from or select adjust command 
  20124.                           in this widget. If the selection isn't in this widget 
  20125.                           then a new selection is created using the most recent 
  20126.                           anchor point specified for the widget. Returns an 
  20127.                           empty string. 
  20128.  
  20129.  pathName xview args  This command is used to query and change the horizontal 
  20130.            position of the text in the widget's window.  It can take any of the 
  20131.            following forms: 
  20132.  
  20133.            pathName xview  Returns a list containing two elements. Each element 
  20134.                           is a real fraction between 0 and 1;  together they 
  20135.                           describe the horizontal span that is visible in the 
  20136.                           window. For example, if the first element is .2 and 
  20137.                           the second element is .6, 20% of the entry's text is 
  20138.                           off-screen to the left, the middle 40% is visible in 
  20139.                           the window, and 40% of the text is off-screen to the 
  20140.                           right. These are the same values passed to scrollbars 
  20141.                           via the -xscrollcommand option. 
  20142.  
  20143.            pathName xview index  Adjusts the view in the window so that the 
  20144.                           character given by index is displayed at the left 
  20145.                           edge of the window. 
  20146.  
  20147.            pathName xview moveto fraction  Adjusts the view in the window so 
  20148.                           that the character fraction of the way through the 
  20149.                           text appears at the left edge of the window. Fraction 
  20150.                           must be a fraction between 0 and 1. 
  20151.  
  20152.            pathName xview scroll number what  This command shifts the view in 
  20153.                           the window left or right according to number and 
  20154.                           what. Number must be an integer. What must be either 
  20155.                           units or pages or an abbreviation of one of these. If 
  20156.                           what is units, the view adjusts left or right by 
  20157.                           number average-width characters on the display;  if 
  20158.                           it is pages then the view adjusts by number 
  20159.                           screenfuls. If number is negative then characters 
  20160.                           farther to the left become visible;  if it is 
  20161.                           positive then characters farther to the right become 
  20162.                           visible. 
  20163.  
  20164.  DEFAULT BINDINGS 
  20165.  
  20166.  Tk automatically creates class bindings for entries that give them the 
  20167.  following default behavior. In the descriptions below, "word" refers to a 
  20168.  contiguous group of letters, digits, or "_" characters, or any single 
  20169.  character other than these. 
  20170.  
  20171.    1. Clicking mouse button 1 positions the insertion cursor just before the 
  20172.       character underneath the mouse cursor, sets the input focus to this 
  20173.       widget, and clears any selection in the widget. Dragging with mouse 
  20174.       button 1 strokes out a selection between the insertion cursor and the 
  20175.       character under the mouse. 
  20176.  
  20177.    2. Double-clicking with mouse button 1 selects the word under the mouse and 
  20178.       positions the insertion cursor at the beginning of the word. Dragging 
  20179.       after a double click will stroke out a selection consisting of whole 
  20180.       words. 
  20181.  
  20182.    3. Triple-clicking with mouse button 1 selects all of the text in the entry 
  20183.       and positions the insertion cursor before the first character. 
  20184.  
  20185.    4. The ends of the selection can be adjusted by dragging with mouse button 1 
  20186.       while the Shift key is down;  this will adjust the end of the selection 
  20187.       that was nearest to the mouse cursor when button 1 was pressed. If the 
  20188.       button is double-clicked before dragging then the selection will be 
  20189.       adjusted in units of whole words. 
  20190.  
  20191.    5. Clicking mouse button 1 with the Control key down will position the 
  20192.       insertion cursor in the entry without affecting the selection. 
  20193.  
  20194.    6. If any normal printing characters are typed in an entry, they are 
  20195.       inserted at the point of the insertion cursor. 
  20196.  
  20197.    7. The view in the entry can be adjusted by dragging with mouse button 2. If 
  20198.       mouse button 2 is clicked without moving the mouse, the selection is 
  20199.       copied into the entry at the position of the mouse cursor. 
  20200.  
  20201.    8. If the mouse is dragged out of the entry on the left or right sides while 
  20202.       button 1 is pressed, the entry will automatically scroll to make more 
  20203.       text visible (if there is more text off-screen on the side where the 
  20204.       mouse left the window). 
  20205.  
  20206.    9. The Left and Right keys move the insertion cursor one character to the 
  20207.       left or right;  they also clear any selection in the entry and set the 
  20208.       selection anchor. If Left or Right is typed with the Shift key down, then 
  20209.       the insertion cursor moves and the selection is extended to include the 
  20210.       new character. Control-Left and Control-Right move the insertion cursor 
  20211.       by words, and Control-Shift-Left and Control-Shift-Right move the 
  20212.       insertion cursor by words and also extend the selection. Control-b and 
  20213.       Control-f behave the same as Left and Right, respectively. Meta-b and 
  20214.       Meta-f behave the same as Control-Left and Control-Right, respectively. 
  20215.  
  20216.   10. The Home key, or Control-a, will move the insertion cursor to the 
  20217.       beginning of the entry and clear any selection in the entry. Shift-Home 
  20218.       moves the insertion cursor to the beginning of the entry and also extends 
  20219.       the selection to that point. 
  20220.  
  20221.   11. The End key, or Control-e, will move the insertion cursor to the end of 
  20222.       the entry and clear any selection in the entry. Shift-End moves the 
  20223.       cursor to the end and extends the selection to that point. 
  20224.  
  20225.   12. The Select key and Control-Space set the selection anchor to the position 
  20226.       of the insertion cursor.  They don't affect the current selection. 
  20227.       Shift-Select and Control-Shift-Space adjust the selection to the current 
  20228.       position of the insertion cursor, selecting from the anchor to the 
  20229.       insertion cursor if there was not any selection previously. 
  20230.  
  20231.   13. Control-/ selects all the text in the entry. 
  20232.  
  20233.   14. Control-\ clears any selection in the entry. 
  20234.  
  20235.   15. The F16 key (labelled Copy on many Sun workstations) or Meta-w copies the 
  20236.       selection in the widget to the clipboard, if there is a selection. 
  20237.  
  20238.   16. The F20 key (labelled Cut on many Sun workstations) or Control-w copies 
  20239.       the selection in the widget to the clipboard and deletes the selection. 
  20240.       If there is no selection in the widget then these keys have no effect. 
  20241.  
  20242.   17. The F18 key (labelled Paste on many Sun workstations) or Control-y 
  20243.       inserts the contents of the clipboard at the position of the insertion 
  20244.       cursor. 
  20245.  
  20246.   18. The Delete key deletes the selection, if there is one in the entry. If 
  20247.       there is no selection, it deletes the character to the right of the 
  20248.       insertion cursor. 
  20249.  
  20250.   19. The BackSpace key and Control-h delete the selection, if there is one in 
  20251.       the entry. If there is no selection, it deletes the character to the left 
  20252.       of the insertion cursor. 
  20253.  
  20254.   20. Control-d deletes the character to the right of the insertion cursor. 
  20255.  
  20256.   21. Meta-d deletes the word to the right of the insertion cursor. 
  20257.  
  20258.   22. Control-k deletes all the characters to the right of the insertion 
  20259.       cursor. 
  20260.  
  20261.   23. Control-w deletes the word to the left of the insertion cursor. 
  20262.  
  20263.   24. Control-t reverses the order of the two characters to the right of the 
  20264.       insertion cursor. 
  20265.  
  20266.  If the entry is disabled using the -state option, then the entry's view can 
  20267.  still be adjusted and text in the entry can still be selected, but no 
  20268.  insertion cursor will be displayed and no text modifications will take place. 
  20269.  
  20270.  The behavior of entries can be changed by defining new bindings for individual 
  20271.  widgets or by redefining the class bindings. 
  20272.  
  20273.  KEYWORDS 
  20274.  
  20275.  entry, widget 
  20276.  
  20277.  
  20278. ΓòÉΓòÉΓòÉ 6.13. event ΓòÉΓòÉΓòÉ
  20279.  
  20280.  NAME 
  20281.  
  20282. event - Miscellaneous event facilities: define virtual events and generate 
  20283. events 
  20284.  
  20285. SYNOPSIS 
  20286.  
  20287. event option ?arg arg ...? 
  20288.  
  20289. DESCRIPTION 
  20290.  
  20291. The event command provides several facilities for dealing with window system 
  20292. events, such as defining virtual events and synthesizing events.  The command 
  20293. has several different forms, determined by the first argument.  The following 
  20294. forms are currently supported: 
  20295.  
  20296.  event add <<virtual>> sequence ?sequence ...?  Associates the virtual event 
  20297.            virtual with the physical event sequence(s) given by the sequence 
  20298.            arguments, so that the virtual event will trigger whenever any one 
  20299.            of the sequences occurs. Virtual may be any string value and 
  20300.            sequence may have any of the values allowed for the sequence 
  20301.            argument to the bind command. If virtual is already defined, the new 
  20302.            physical event sequences add to the existing sequences for the 
  20303.            event. 
  20304.  
  20305.  event delete <<virtual>> ?sequence sequence ...?  Deletes each of the 
  20306.            sequences from those associated with the virtual event given by 
  20307.            virtual. Virtual may be any string value and sequence may have any 
  20308.            of the values allowed for the sequence argument to the bind command. 
  20309.            Any sequences not currently associated with virtual are ignored. If 
  20310.            no sequence argument is provided, all physical event sequences are 
  20311.            removed for virtual, so that the virtual event will not trigger 
  20312.            anymore. 
  20313.  
  20314.  event generate window event ?option value option value ...?  Generates a 
  20315.            window event and arranges for it to be processed just as if it had 
  20316.            come from the window system. Window gives the path name of the 
  20317.            window for which the event will be generated, and event provides a 
  20318.            basic description of the event, such as <Shift-Button-2> or 
  20319.            <<Paste>>. Event may have any of the forms allowed for the sequence 
  20320.            argument of the bind command except that it must consist of a single 
  20321.            event pattern, not a sequence. Option-value pairs may be used to 
  20322.            specify additional attributes of the event, such as the x and y 
  20323.            mouse position;  see EVENT FIELDS below.  If the -when option is not 
  20324.            specified, the event is processed immediately:  all of the handlers 
  20325.            for the event will complete before the event generate command 
  20326.            returns. If the -when option is specified then it determines when 
  20327.            the event is processed. 
  20328.  
  20329.  event info ?<<virtual>>?  Returns information about virtual events. If the 
  20330.            <<virtual>> argument is omitted, the return value is a list of all 
  20331.            the virtual events that are currently defined. If <<virtual>> is 
  20332.            specified then the return value is a list whose elements are the 
  20333.            physical event sequences currently defined for the given virtual 
  20334.            event;  if the virtual event is not defined then an empty string is 
  20335.            returned. 
  20336.  
  20337.  EVENT FIELDS 
  20338.  
  20339.  The following options are supported for the event generate command.  These 
  20340.  correspond to the "%" expansions allowed in binding scripts for the bind 
  20341.  command. 
  20342.  
  20343.  -above window  Window specifies the above field for the event, either as a 
  20344.            window path name or as an integer window id. Valid for Configure 
  20345.            events. Corresponds to the %a substitution for binding scripts. 
  20346.  
  20347.  -borderwidth size  Size must be a screen distance;  it specifies the 
  20348.            border_width field for the event. Valid for Configure events. 
  20349.            Corresponds to the %B substitution for binding scripts. 
  20350.  
  20351.  -button number  Number must be an integer;  it specifies the detail field for 
  20352.            a ButtonPress or ButtonRelease event, overriding any button  number 
  20353.            provided in the base event argument. Corresponds to the %b 
  20354.            substitution for binding scripts. 
  20355.  
  20356.  -count number  Number must be an integer;  it specifies the count field for 
  20357.            the event.  Valid for Expose events. Corresponds to the %c 
  20358.            substitution for binding scripts. 
  20359.  
  20360.  -detail detail  Detail specifies the detail field for the event and must be 
  20361.            one of the following: 
  20362.  
  20363.                       NotifyAncestor                   NotifyNonlinearVirtual
  20364.                       NotifyDetailNone                 NotifyPointer
  20365.                       NotifyInferior                   NotifyPointerRoot
  20366.                       NotifyNonlinear                  NotifyVirtual
  20367.            Valid for Enter, Leave, FocusIn and FocusOut events. Corresponds to 
  20368.            the %d substitution for binding scripts. 
  20369.  
  20370.  -focus boolean  Boolean must be a boolean value;  it specifies the focus field 
  20371.            for the event. Valid for Enter and Leave events. Corresponds to the 
  20372.            %f substitution for binding scripts. 
  20373.  
  20374.  -height size  Size must be a screen distance;  it specifies the height field 
  20375.            for the event.  Valid for Configure events. Corresponds to the %h 
  20376.            substitution for binding scripts. 
  20377.  
  20378.  -keycode number  Number  must be an integer;  it specifies the keycode field 
  20379.            for the event. Valid for KeyPress and KeyRelease events. Corresponds 
  20380.            to the %k substitution for binding scripts. 
  20381.  
  20382.  -keysym name  Name must be the name of a valid keysym, such as g, space, or 
  20383.            Return;  its corresponding keycode value is used as the keycode 
  20384.            field for event, overriding any detail specified in the base event 
  20385.            argument. Valid for KeyPress and KeyRelease events. Corresponds to 
  20386.            the %K substitution for binding scripts. 
  20387.  
  20388.  -mode notify  Notify specifies the mode field for the event and must be one of 
  20389.            NotifyNormal, NotifyGrab, NotifyUngrab, or NotifyWhileGrabbed. Valid 
  20390.            for Enter, Leave, FocusIn, and FocusOut events. Corresponds to the 
  20391.            %m substitution for binding scripts. 
  20392.  
  20393.  -override boolean  Boolean must be a boolean value;  it specifies the 
  20394.            override_redirect field for the event. Valid for Map, Reparent, and 
  20395.            Configure events. Corresponds to the %o substitution for binding 
  20396.            scripts. 
  20397.  
  20398.  -place where  Where specifies the place field for the event;  it must be 
  20399.            either PlaceOnTop or PlaceOnBottom. Valid for Circulate events. 
  20400.            Corresponds to the %p substitution for binding scripts. 
  20401.  
  20402.  -root window  Window must be either a window path name or an integer window 
  20403.            identifier;  it specifies the root field for the event. Valid for 
  20404.            KeyPress, KeyRelease, ButtonPress, ButtonRelease, Enter, Leave, and 
  20405.            Motion events. Corresponds to the %R substitution for binding 
  20406.            scripts. 
  20407.  
  20408.  -rootx coord  Coord must be a screen distance;  it specifies the x_root field 
  20409.            for the event. Valid for KeyPress, KeyRelease, ButtonPress, 
  20410.            ButtonRelease, Enter, Leave, and Motion events.  Corresponds to the 
  20411.            %X substitution for binding scripts. 
  20412.  
  20413.  -rooty coord  Coord must be a screen distance;  it specifies th y_root field 
  20414.            for the event. Valid for KeyPress, KeyRelease, ButtonPress, 
  20415.            ButtonRelease, Enter, Leave, and Motion events. Corresponds to the 
  20416.            %Y substitution for binding scripts. 
  20417.  
  20418.  -sendevent boolean  Boolean must be a boolean value;  it specifies the 
  20419.            send_event field for the event.  Valid for all events.  Corresponds 
  20420.            to the %E substitution for binding scripts. 
  20421.  
  20422.  -serial number  Number must be an integer;  it specifies the serial field for 
  20423.            the event.  Valid for all events. Corresponds to the %# substitution 
  20424.            for binding scripts. 
  20425.  
  20426.  -state state  State specifies the state field for the event. For KeyPress, 
  20427.            KeyRelease, ButtonPress, ButtonRelease, Enter, Leave, and Motion 
  20428.            events it must be an integer value. For Visibility events it must be 
  20429.            one of VisibilityUnobscured, VisibilityPartiallyObscured, or 
  20430.            VisibilityFullyObscured. This option overrides any modifiers such as 
  20431.            Meta or Control specified in the base event. Corresponds to the %s 
  20432.            substitution for binding scripts. 
  20433.  
  20434.  -subwindow window  Window specifies the subwindow field for the event, either 
  20435.            as a path name for a Tk widget or as an integer window identifier. 
  20436.            Valid for KeyPress, KeyRelease, ButtonPress, ButtonRelease, Enter, 
  20437.            Leave, and Motion events. Similar to %S substitution for binding 
  20438.            scripts. 
  20439.  
  20440.  -time integer  Integer must be an integer value;  it specifies the time field 
  20441.            for the event. Valid for KeyPress, KeyRelease, ButtonPress, 
  20442.            ButtonRelease, Enter, Leave, Motion, and Property events. 
  20443.            Corresponds to the %t substitution for binding scripts. 
  20444.  
  20445.  -width size  Size must be a screen distance;  it specifies the width field for 
  20446.            the event. Valid for Configure events. Corresponds to the %w 
  20447.            substitution for binding scripts. 
  20448.  
  20449.  -when when  When determines when the event will be processed;  it must have 
  20450.            one of the following values: 
  20451.  
  20452.            now            Process the event immediately, before the command 
  20453.                           returns. This also happens if the -when option is 
  20454.                           omitted. 
  20455.  
  20456.            tail           Place the event on Tcl's event queue behind any 
  20457.                           events already queued for this application. 
  20458.  
  20459.            head           Place the event at the front of Tcl's event queue, so 
  20460.                           that it will be handled before any other events 
  20461.                           already queued. 
  20462.  
  20463.            mark           Place the event at the front of Tcl's event queue but 
  20464.                           behind any other events already queued with -when 
  20465.                           mark. This option is useful when generating a series 
  20466.                           of events that should be processed in order but at 
  20467.                           the front of the queue. 
  20468.  
  20469.  -x coord  Coord must be a screen distance;  it specifies the x field for the 
  20470.            event. Valid for KeyPress, KeyRelease, ButtonPress, ButtonRelease, 
  20471.            Motion, Enter, Leave, Expose, Configure, Gravity, and Reparent 
  20472.            events. Corresponds to the the %x substitution for binding scripts. 
  20473.  
  20474.  -y coord  Coord must be a screen distance;  it specifies the y field for the 
  20475.            event. Valid for KeyPress, KeyRelease, ButtonPress, ButtonRelease, 
  20476.            Motion, Enter, Leave, Expose, Configure, Gravity, and Reparent 
  20477.            events. Corresponds to the the %y substitution for binding scripts. 
  20478.  
  20479.  Any options that are not specified when generating an event are filled with 
  20480.  the value 0, except for serial, which is filled with the next X event serial 
  20481.  number. 
  20482.  
  20483.  VIRTUAL EVENT EXAMPLES 
  20484.  
  20485.  In order for a virtual event binding to trigger, two things must happen. 
  20486.  First, the virtual event must be defined with the event add command.  Second, 
  20487.  a binding must be created for the virtual event with the bind command. 
  20488.  Consider the following virtual event definitions: 
  20489.  
  20490.   event add <<Paste>> <Control-y>
  20491.   event add <<Paste>> <Button-2>
  20492.   event add <<Save>> <Control-X><Control-S>
  20493.   event add <<Save>> <Shift-F12>
  20494.  In the bind command, a virtual event can be bound like any other builtin event 
  20495.  type as follows: 
  20496.  
  20497.   bind Entry <<Paste>> {%W insert [selection get]}
  20498.  The double angle brackets are used to specify that a virtual event is being 
  20499.  bound.  If the user types Control-y or presses button 2, or if a <<Paste>> 
  20500.  virtual event is synthesized with event generate, then the <<Paste>> binding 
  20501.  will be invoked. 
  20502.  
  20503.  If a virtual binding has the exact same sequence as a separate physical 
  20504.  binding, then the physical binding will take precedence. Consider the 
  20505.  following example: 
  20506.  
  20507.   event add <<Paste>> <Control-y> <Meta-Control-y>
  20508.   bind Entry <Control-y> {puts Control-y}
  20509.   bind Entry <<Paste>> {puts Paste}
  20510.  When the user types Control-y the <Control-y> binding will be invoked, because 
  20511.  a physical event is considered more specific than a virtual event, all other 
  20512.  things being equal. However, when the user types Meta-Control-y the <<Paste>> 
  20513.  binding will be invoked, because the Meta modifier in the physical pattern 
  20514.  associated with the virtual binding is more specific than the <Control-y> 
  20515.  sequence for the physical event. 
  20516.  
  20517.  Bindings on a virtual event may be created before the virtual event exists. 
  20518.  Indeed, the virtual event never actually needs to be defined, for instance, on 
  20519.  platforms where the specific virtual event would meaningless or ungeneratable. 
  20520.  
  20521.  When a definition of a virtual event changes at run time, all windows will 
  20522.  respond immediately to the new definition. Starting from the preceding 
  20523.  example, if the following code is executed: 
  20524.  
  20525.   bind <Entry> <Control-y> {}
  20526.   event add <<Paste>> <Key-F6>
  20527.  the behavior will change such in two ways.  First, the shadowed <<Paste>> 
  20528.  binding will emerge. Typing Control-y will no longer invoke the <Control-y> 
  20529.  binding, but instead invoke the virtual event <<Paste>>.  Second, pressing the 
  20530.  F6 key will now also invoke the <<Paste>> binding. 
  20531.  
  20532.  SEE ALSO 
  20533.  
  20534.  bind 
  20535.  
  20536.  KEYWORDS 
  20537.  
  20538.  event, binding, define, handle, virtual event 
  20539.  
  20540.  
  20541. ΓòÉΓòÉΓòÉ 6.14. focus ΓòÉΓòÉΓòÉ
  20542.  
  20543.  NAME 
  20544.  
  20545. focus - Manage the input focus 
  20546.  
  20547. SYNOPSIS 
  20548.  
  20549. focus 
  20550.  focus window 
  20551.  focus option ?arg arg ...? 
  20552.  
  20553. DESCRIPTION 
  20554.  
  20555. The focus command is used to manage the Tk input focus. At any given time, one 
  20556. window on each display is designated as the focus window;  any key press or key 
  20557. release events for the display are sent to that window. It is normally up to 
  20558. the window manager to redirect the focus among the top-level windows of a 
  20559. display.  For example, some window managers automatically set the input focus 
  20560. to a top-level window whenever the mouse enters it;  others redirect the input 
  20561. focus only when the user clicks on a window. Usually the window manager will 
  20562. set the focus only to top-level windows, leaving it up to the application to 
  20563. redirect the focus among the children of the top-level. 
  20564.  
  20565. Tk remembers one focus window for each top-level (the most recent descendant of 
  20566. that top-level to receive the focus);  when the window manager gives the focus 
  20567. to a top-level, Tk automatically redirects it to the remembered window.  Within 
  20568. a top-level Tk uses an explicit focus model by default.  Moving the mouse 
  20569. within a top-level does not normally change the focus;  the focus changes only 
  20570. when a widget decides explicitly to claim the focus (e.g., because of a button 
  20571. click), or when the user types a key such as Tab that moves the focus. 
  20572.  
  20573. The Tcl procedure tk_focusFollowsMouse may be invoked to create an implicit 
  20574. focus model:  it reconfigures Tk so that the focus is set to a window whenever 
  20575. the mouse enters it. The Tcl procedures tk_focusNext and tk_focusPrev implement 
  20576. a focus order among the windows of a top-level;  they are used in the default 
  20577. bindings for Tab and Shift-Tab, among other things. 
  20578.  
  20579. The focus command can take any of the following forms: 
  20580.  
  20581.  focus     Returns the path name of the focus window on the display containing 
  20582.            the application's main window,  or an empty string if no window in 
  20583.            this application has the focus on that display.  Note:  it is better 
  20584.            to specify the display explicitly using -displayof (see below) so 
  20585.            that the code will work in applications using multiple displays. 
  20586.  
  20587.  focus window  If the application currently has the input focus on window's 
  20588.            display, this command resets the input focus for window's display to 
  20589.            window and returns an empty string. If the application doesn't 
  20590.            currently have the  input focus on window's display, window will be 
  20591.            remembered as the focus for its top-level;  the next time the focus 
  20592.            arrives at the top-level, Tk will redirect it to window. If window 
  20593.            is an empty string then the command does nothing. 
  20594.  
  20595.  focus -displayof window  Returns the name of the focus window on the display 
  20596.            containing window. If the focus window for window's display isn't in 
  20597.            this application, the return value is an empty string. 
  20598.  
  20599.  focus -force window  Sets the focus of window's display to window, even if the 
  20600.            application doesn't currently have the input focus for the display. 
  20601.            This command should be used sparingly, if at all. In normal usage, 
  20602.            an application should not claim the focus for itself;  instead, it 
  20603.            should wait for the window manager to give it the focus. If window 
  20604.            is an empty string then the command does nothing. 
  20605.  
  20606.  focus -lastfor window  Returns the name of the most recent window to have the 
  20607.            input focus among all the windows in the same top-level as window. 
  20608.            If no window in that top-level has ever had the input focus, or if 
  20609.            the most recent focus window has been deleted, then the name of the 
  20610.            top-level is returned.  The return value is the window that will 
  20611.            receive the input focus the next time the window manager gives the 
  20612.            focus to the top-level. 
  20613.  
  20614.  QUIRKS 
  20615.  
  20616.  When an internal window receives the input focus, Tk doesn't actually set the 
  20617.  X focus to that window;  as far as X is concerned, the focus will stay on the 
  20618.  top-level window containing the window with the focus. However, Tk generates 
  20619.  FocusIn and FocusOut events just as if the X focus were on the internal 
  20620.  window.  This approach gets around a number of problems that would occur if 
  20621.  the X focus were actually moved; the fact that the X focus is on the top-level 
  20622.  is invisible unless you use C code to query the X server directly. 
  20623.  
  20624.  KEYWORDS 
  20625.  
  20626.  events, focus, keyboard, top-level, window manager 
  20627.  
  20628.  
  20629. ΓòÉΓòÉΓòÉ 6.15. tk_focusNext ΓòÉΓòÉΓòÉ
  20630.  
  20631.  NAME 
  20632.  
  20633. tk_focusNext, tk_focusPrev, tk_focusFollowsMouse - Utility procedures for 
  20634. managing the input focus. 
  20635.  
  20636. SYNOPSIS 
  20637.  
  20638. tk_focusNext window 
  20639.  tk_focusPrev window 
  20640.  tk_focusFollowsMouse 
  20641.  
  20642. DESCRIPTION 
  20643.  
  20644. tk_focusNext is a utility procedure used for keyboard traversal. It returns the 
  20645. "next" window after window in focus order. The focus order is determined by the 
  20646. stacking order of windows and the structure of the window hierarchy. Among 
  20647. siblings, the focus order is the same as the stacking order, with the lowest 
  20648. window being first. If a window has children, the window is visited first, 
  20649. followed by its children (recursively), followed by its next sibling. Top-level 
  20650. windows other than window are skipped, so that tk_focusNext never returns a 
  20651. window in a different top-level from window. 
  20652.  
  20653. After computing the next window, tk_focusNext examines the window's -takefocus 
  20654. option to see whether it should be skipped. If so, tk_focusNext continues on to 
  20655. the next window in the focus order, until it eventually finds a window that 
  20656. will accept the focus or returns back to window. 
  20657.  
  20658. tk_focusPrev is similar to tk_focusNext except that it returns the window just 
  20659. before window in the focus order. 
  20660.  
  20661. tk_focusFollowsMouse changes the focus model for the application to an implicit 
  20662. one where the window under the mouse gets the focus. After this procedure is 
  20663. called, whenever the mouse enters a window Tk will automatically give it the 
  20664. input focus. The focus command may be used to move the focus to a window other 
  20665. than the one under the mouse, but as soon as the mouse moves into a new window 
  20666. the focus will jump to that window. Note: at present there is no built-in 
  20667. support for returning the application to an explicit focus model;  to do this 
  20668. you'll have to write a script that deletes the bindings created by 
  20669. tk_focusFollowsMouse. 
  20670.  
  20671. KEYWORDS 
  20672.  
  20673. focus, keyboard traversal, top-level 
  20674.  
  20675.  
  20676. ΓòÉΓòÉΓòÉ 6.16. frame ΓòÉΓòÉΓòÉ
  20677.  
  20678.  NAME 
  20679.  
  20680. frame - Create and manipulate frame widgets 
  20681.  
  20682. SYNOPSIS 
  20683.  
  20684. frame pathName ?options? 
  20685.  
  20686. STANDARD OPTIONS 
  20687.  
  20688. -borderwidth         -highlightbackground -highlightthickness  -takefocus
  20689. -cursor              -highlightcolor      -relief
  20690.  
  20691. See the options manual entry for detailed descriptions of the above options.
  20692.  
  20693. WIDGET-SPECIFIC OPTIONS 
  20694.  
  20695.   Command-Line Name:    -background
  20696.   Database Name:        background
  20697.   Database Class:       Background
  20698.  
  20699.            This option is the same as the standard background option except 
  20700.            that its value may also be specified as an empty string. In this 
  20701.            case, the widget will display no background or border, and no colors 
  20702.            will be consumed from its colormap for its background and border. 
  20703.  
  20704.   Command-Line Name:    -class
  20705.   Database Name:        class
  20706.   Database Class:       Class
  20707.  
  20708.            Specifies a class for the window. This class will be used when 
  20709.            querying the option database for the window's other options, and it 
  20710.            will also be used later for other purposes such as bindings. The 
  20711.            class option may not be changed with the configure widget command. 
  20712.  
  20713.   Command-Line Name:    -colormap
  20714.   Database Name:        colormap
  20715.   Database Class:       Colormap
  20716.  
  20717.            Specifies a colormap to use for the window. The value may be either 
  20718.            new, in which case a new colormap is created for the window and its 
  20719.            children, or the name of another window (which must be on the same 
  20720.            screen and have the same visual as pathName), in which case the new 
  20721.            window will use the colormap from the specified window. If the 
  20722.            colormap option is not specified, the new window uses the same 
  20723.            colormap as its parent. This option may not be changed with the 
  20724.            configure widget command. 
  20725.  
  20726.   Command-Line Name:    -height
  20727.   Database Name:        height
  20728.   Database Class:       Height
  20729.  
  20730.            Specifies the desired height for the window in any of the forms 
  20731.            acceptable to Tk_GetPixels. If this option is less than or equal to 
  20732.            zero then the window will not request any size at all. 
  20733.  
  20734.   Command-Line Name:    -visual
  20735.   Database Name:        visual
  20736.   Database Class:       Visual
  20737.  
  20738.            Specifies visual information for the new window in any of the forms 
  20739.            accepted by Tk_GetVisual. If this option is not specified, the new 
  20740.            window will use the same visual as its parent. The visual option may 
  20741.            not be modified with the configure widget command. 
  20742.  
  20743.   Command-Line Name:    -width
  20744.   Database Name:        width
  20745.   Database Class:       Width
  20746.  
  20747.            Specifies the desired width for the window in any of the forms 
  20748.            acceptable to Tk_GetPixels. If this option is less than or equal to 
  20749.            zero then the window will not request any size at all. 
  20750.  
  20751.  DESCRIPTION 
  20752.  
  20753.  The frame command creates a new window (given by the pathName argument) and 
  20754.  makes it into a frame widget. Additional options, described above, may be 
  20755.  specified on the command line or in the option database to configure aspects 
  20756.  of the frame such as its background color and relief.  The frame command 
  20757.  returns the path name of the new window. 
  20758.  
  20759.  A frame is a simple widget.  Its primary purpose is to act as a spacer or 
  20760.  container for complex window layouts.  The only features of a frame are its 
  20761.  background color and an optional 3-D border to make the frame appear raised or 
  20762.  sunken. 
  20763.  
  20764.  WIDGET COMMAND 
  20765.  
  20766.  The frame command creates a new Tcl command whose name is the same as the path 
  20767.  name of the frame's window.  This command may be used to invoke various 
  20768.  operations on the widget.  It has the following general form: 
  20769.  
  20770.   pathName option ?arg arg ...?
  20771.  PathName is the name of the command, which is the same as the frame widget's 
  20772.  path name.  Option and the args determine the exact behavior of the command. 
  20773.  The following commands are possible for frame widgets: 
  20774.  
  20775.  pathName cget option  Returns the current value of the configuration option 
  20776.            given by option. Option may have any of the values accepted by the 
  20777.            frame command. 
  20778.  
  20779.  pathName configure ?option? ?value option value ...?  Query or modify the 
  20780.            configuration options of the widget. If no option is specified, 
  20781.            returns a list describing all of the available options for pathName 
  20782.            (see Tk_ConfigureInfo for information on the format of this list). 
  20783.            If option is specified with no value, then the command returns a 
  20784.            list describing the one named option (this list will be identical to 
  20785.            the corresponding sublist of the value returned if no option is 
  20786.            specified).  If one or more option-value pairs are specified, then 
  20787.            the command modifies the given widget option(s) to have the given 
  20788.            value(s);  in this case the command returns an empty string. Option 
  20789.            may have any of the values accepted by the frame command. 
  20790.  
  20791.  BINDINGS 
  20792.  
  20793.  When a new frame is created, it has no default event bindings: frames are not 
  20794.  intended to be interactive. 
  20795.  
  20796.  KEYWORDS 
  20797.  
  20798.  frame, widget 
  20799.  
  20800.  
  20801. ΓòÉΓòÉΓòÉ 6.17. tk_getOpenFile ΓòÉΓòÉΓòÉ
  20802.  
  20803.  NAME 
  20804.  
  20805. tk_getOpenFile, tk_getSaveFile - pop up a dialog box for the user to select a 
  20806. file to open or save. 
  20807.  
  20808. SYNOPSIS 
  20809.  
  20810. tk_getOpenFile ?option value ...? 
  20811.  tk_getSaveFile ?option value ...? 
  20812.  
  20813. DESCRIPTION 
  20814.  
  20815. The procedures tk_getOpenFile and tk_getSaveFile pop up a dialog box for the 
  20816. user to select a file to open or save. The tk_getOpenFile command is usually 
  20817. associated with the Open command in the File menu. Its purpose is for the user 
  20818. to select an existing file only. If the user enters an non-existent file, the 
  20819. dialog box gives the user an error prompt and requires the user to give an 
  20820. alternative selection. If an application allows the user to create new files, 
  20821. it should do so by providing a separate New menu command. 
  20822.  
  20823. The tk_getSaveFile command is usually associated with the Save as command in 
  20824. the File menu. If the user enters a file that already exists, the dialog box 
  20825. prompts the user for confirmation whether the existing file should be 
  20826. overwritten or not. 
  20827.  
  20828. The following option-value pairs are possible as command line arguments to 
  20829. these two commands: 
  20830.  
  20831.  -defaultextension extension  Specifies a string that will be appended to the 
  20832.            filename if the user enters a filename without an extension. The 
  20833.            defaut value is the empty string, which means no extension will be 
  20834.            appended to the filename in any case. This option is ignored on the 
  20835.            Macintosh platform, which does not require extensions to filenames. 
  20836.  
  20837.  -filetypes filePatternList  If a File types listbox exists in the file dialog 
  20838.            on the particular platform, this option gives the filetypes in this 
  20839.            listbox. When the user choose a filetype in the listbox, only the 
  20840.            files of that type are listed. If this option is unspecified, or if 
  20841.            it is set to the empty list, or if the File types listbox is not 
  20842.            supported by the particular platform then all files are listed 
  20843.            regardless of their types. See the section SPECIFYING FILE PATTERNS 
  20844.            below for a discussion on the contents of filePatternList. 
  20845.  
  20846.  -initialdir directory  Specifies that the files in directory should be 
  20847.            displayed when the dialog pops up. If this parameter is not 
  20848.            specified, then the files in the current working directory are 
  20849.            displayed.  This option may not always work on the Macintosh.  This 
  20850.            is not a bug. Rather, the General Controls control panel on the Mac 
  20851.            allows the end user to override the application default directory. 
  20852.  
  20853.  -initialfile filename  Specifies a filename to be displayed in the dialog when 
  20854.            it pops up. This option is ignored by the tk_getOpenFile command. 
  20855.  
  20856.  -parent window  Makes window the logical parent of the file dialog. The file 
  20857.            dialog is displayed on top of its parent window. 
  20858.  
  20859.  -title titleString  Specifies a string to display as the title of the dialog 
  20860.            box. If this option is not specified, then a default title is 
  20861.            displayed. This option is ignored on the Macintosh platform. 
  20862.  
  20863.  If the user selects a file, both tk_getOpenFile and tk_getSaveFile return the 
  20864.  full pathname of this file. If the user cancels the operation, both commands 
  20865.  return the empty string. 
  20866.  
  20867.  SPECIFYING FILE PATTERNS 
  20868.  
  20869.   The filePatternList value given by the -filetypes option is a list of file 
  20870.  patterns. Each file pattern is a list of the form 
  20871.  
  20872.   typeName {extension ?extension ...?} ?{macType ?macType ...?}?
  20873.  typeName is the name of the file type described by this file pattern and is 
  20874.  the text string that appears in the File types listbox. extension is a file 
  20875.  extension for this file pattern. macType is a four-character Macintosh file 
  20876.  type. The list of macTypes is optional and may be omitted for applications 
  20877.  that do not need to execute on the Macintosh platform. 
  20878.  
  20879.  Several file patterns may have the same typeName, in which case they refer to 
  20880.  the same file type and share the same entry in the listbox. When the user 
  20881.  selects an entry in the listbox, all the files that match at least one of the 
  20882.  file patterns corresponding to that entry are listed. Usually, each file 
  20883.  pattern corresponds to a distinct type of file. The use of more than one file 
  20884.  patterns for one type of file is necessary on the Macintosh platform only. 
  20885.  
  20886.  On the Macintosh platform, a file matches a file pattern if its name matches 
  20887.  at least one of the extension(s) AND it belongs to at least one of the 
  20888.  macType(s) of the file pattern. For example, the C Source Files file pattern 
  20889.  in the sample code matches with files that have a .c extension AND belong to 
  20890.  the macType TEXT. To use the OR rule instead, you can use two file patterns, 
  20891.  one with the extensions only and the other with the macType only. The GIF 
  20892.  Files file type in the sample code matches files that EITHER have a .gif 
  20893.  extension OR belong to the macType GIFF. 
  20894.  
  20895.  On the Unix and Windows platforms, a file matches a file pattern if its name 
  20896.  matches at at least one of the extension(s) of the file pattern. The macTypes 
  20897.  are ignored. 
  20898.  
  20899.  SPECIFYING EXTENSIONS 
  20900.  
  20901.  On the Unix and Macintosh platforms, extensions are matched using glob-style 
  20902.  pattern matching. On the Windows platforms, extensions are matched by the 
  20903.  underlying operating system. The types of possible extensions are: (1) the 
  20904.  special extension * matches any file; (2) the special extension "" matches any 
  20905.  files that do not have an extension (i.e., the filename contains no full stop 
  20906.  character); (3) any character string that does not contain any wild card 
  20907.  characters (* and ?). 
  20908.  
  20909.  Due to the different pattern matching rules on the various platforms, to 
  20910.  ensure portability, wild card characters are not allowed in the extensions, 
  20911.  except as in the special extension *. Extensions without a full stop character 
  20912.  (e.g, ~) are allowed but may not work on all platforms. 
  20913.  
  20914.  EXAMPLE 
  20915.  
  20916.   set types {
  20917.       {{Text Files}       {.txt}        }
  20918.       {{TCL Scripts}      {.tcl}        }
  20919.       {{C Source Files}   {.c}      TEXT}
  20920.       {{GIF Files}        {.gif}        }
  20921.       {{GIF Files}        {}        GIFF}
  20922.       {{All Files}        *             }
  20923.   }
  20924.   set filename [tk_getOpenFile -filetypes $types]
  20925.  
  20926.   if {$filename != ""} {
  20927.       # Open the file ...
  20928.   }
  20929.  
  20930.  KEYWORDS 
  20931.  
  20932.  file selection dialog 
  20933.  
  20934.  
  20935. ΓòÉΓòÉΓòÉ 6.18. grab ΓòÉΓòÉΓòÉ
  20936.  
  20937.  NAME 
  20938.  
  20939. grab - Confine pointer and keyboard events to a window sub-tree 
  20940.  
  20941. SYNOPSIS 
  20942.  
  20943. grab ?-global? window 
  20944.  grab option ?arg arg ...? 
  20945.  
  20946. DESCRIPTION 
  20947.  
  20948. This command implements simple pointer and keyboard grabs for Tk. Tk's grabs 
  20949. are different than the grabs described in the Xlib documentation. When a grab 
  20950. is set for a particular window, Tk restricts all pointer events to the grab 
  20951. window and its descendants in Tk's window hierarchy. Whenever the pointer is 
  20952. within the grab window's subtree, the pointer will behave exactly the same as 
  20953. if there had been no grab at all and all events will be reported in the normal 
  20954. fashion. When the pointer is outside window's tree, button presses and releases 
  20955. and mouse motion events are reported to window, and window entry and window 
  20956. exit events are ignored. The grab subtree "owns" the pointer: windows outside 
  20957. the grab subtree will be visible on the screen but they will be insensitive 
  20958. until the grab is released. The tree of windows underneath the grab window can 
  20959. include top-level windows, in which case all of those top-level windows and 
  20960. their descendants will continue to receive mouse events during the grab. 
  20961.  
  20962. Two forms of grabs are possible:  local and global. A local grab affects only 
  20963. the grabbing application:  events will be reported to other applications as if 
  20964. the grab had never occurred. Grabs are local by default. A global grab locks 
  20965. out all applications on the screen, so that only the given subtree of the 
  20966. grabbing application will be sensitive to pointer events (mouse button presses, 
  20967. mouse button releases, pointer motions, window entries, and window exits). 
  20968. During global grabs the window manager will not receive pointer events either. 
  20969.  
  20970. During local grabs, keyboard events (key presses and key releases) are 
  20971. delivered as usual:  the window manager controls which application receives 
  20972. keyboard events, and if they are sent to any window in the grabbing application 
  20973. then they are redirected to the focus window. During a global grab Tk grabs the 
  20974. keyboard so that all keyboard events are always sent to the grabbing 
  20975. application. The focus command is still used to determine which window in the 
  20976. application receives the keyboard events. The keyboard grab is released when 
  20977. the grab is released. 
  20978.  
  20979. Grabs apply to particular displays.  If an application has windows on multiple 
  20980. displays then it can establish a separate grab on each display. The grab on a 
  20981. particular display affects only the windows on that display. It is possible for 
  20982. different applications on a single display to have simultaneous local grabs, 
  20983. but only one application can have a global grab on a given display at once. 
  20984.  
  20985. The grab command can take any of the following forms: 
  20986.  
  20987.  grab ?-global? window  Same as grab set, described below. 
  20988.  
  20989.  grab current ?window?  If window is specified, returns the name of the current 
  20990.            grab window in this application for window's display, or an empty 
  20991.            string if there is no such window. If window is omitted, the command 
  20992.            returns a list whose elements are all of the windows grabbed by this 
  20993.            application for all displays, or an empty string if the application 
  20994.            has no grabs. 
  20995.  
  20996.  grab release window  Releases the grab on window if there is one, otherwise 
  20997.            does nothing.  Returns an empty string. 
  20998.  
  20999.  grab set ?-global? window  Sets a grab on window.  If -global is specified 
  21000.            then the grab is global, otherwise it is local. If a grab was 
  21001.            already in effect for this application on window's display then it 
  21002.            is automatically released. If there is already a grab on window and 
  21003.            it has the same global/local form as the requested grab, then the 
  21004.            command does nothing.  Returns an empty string. 
  21005.  
  21006.  grab status window  Returns none if no grab is currently set on window, local 
  21007.            if a local grab is set on window, and global if a global grab is 
  21008.            set. 
  21009.  
  21010.  BUGS 
  21011.  
  21012.  It took an incredibly complex and gross implementation to produce the simple 
  21013.  grab effect described above. Given the current implementation, it isn't safe 
  21014.  for applications to use the Xlib grab facilities at all except through the Tk 
  21015.  grab procedures. If applications try to manipulate X's grab mechanisms 
  21016.  directly, things will probably break. 
  21017.  
  21018.  If a single process is managing several different Tk applications, only one of 
  21019.  those applications can have a local grab for a given display at any given 
  21020.  time.  If the applications are in different processes, this restriction 
  21021.  doesn't exist. 
  21022.  
  21023.  KEYWORDS 
  21024.  
  21025.  grab, keyboard events, pointer events, window 
  21026.  
  21027.  
  21028. ΓòÉΓòÉΓòÉ 6.19. grid ΓòÉΓòÉΓòÉ
  21029.  
  21030.  NAME 
  21031.  
  21032. grid - Geometry manager that arranges widgets in a grid 
  21033.  
  21034. SYNOPSIS 
  21035.  
  21036. grid option arg ?arg ...? 
  21037.  
  21038. DESCRIPTION 
  21039.  
  21040. The grid command is used to communicate with the grid geometry manager that 
  21041. arranges widgets in rows and columns inside of another window, called the 
  21042. geometry master (or master window). The grid command can have any of several 
  21043. forms, depending on the option argument: 
  21044.  
  21045.  grid slave ?slave ...? ?options?  If the first argument to grid is a window 
  21046.            name (any value starting with "."), then the command is processed in 
  21047.            the same way as grid configure. 
  21048.  
  21049.  grid bbox master ?column row? ?column2 row2?  With no arguments, the bounding 
  21050.            box (in pixels) of the grid is returned. The return value consists 
  21051.            of 4 integers.  The first two are the pixel offset from the master 
  21052.            window (x then y) of the top-left corner of the grid, and the second 
  21053.            two integers are the width and height of the grid, also in pixels. 
  21054.            If a single column and row is specified on the command line, then 
  21055.            the bounding box for that cell is returned, where the top left cell 
  21056.            is numbered from zero.  If both column and row arguments are 
  21057.            specified, then the bounding box spanning the rows and columns 
  21058.            indicated is returned. 
  21059.  
  21060.  grid columnconfigure master index ?-option value...?  Query or set the column 
  21061.            properties of the index column of the geometry master, master. The 
  21062.            valid options are -minsize, -weight and -pad. The -minsize option 
  21063.            sets the minimum size, in screen units, that will be permitted for 
  21064.            this column. The -weight option (an integer value) sets the relative 
  21065.            weight for apportioning any extra spaces among columns. A weight of 
  21066.            zero (0) indicates the column will not deviate from its requested 
  21067.            size.  A column whose weight is two will grow at twice the rate as a 
  21068.            column of weight one when extra space is allocated to the layout. 
  21069.            The -pad option specifies the number of screen units that will be 
  21070.            added to the largest window contained completely in that column when 
  21071.            the grid geometry manager requests a size from the containing 
  21072.            window. If only an option is specified, with no value, the current 
  21073.            value of that option is returned. If only the master window and 
  21074.            index is specified, all the current settings are returned in an list 
  21075.            of "-option value" pairs. 
  21076.  
  21077.  grid configure slave ?slave ...? ?options?  The arguments consist of the names 
  21078.            of one or more slave windows followed by pairs of arguments that 
  21079.            specify how to manage the slaves. The characters -,  x and ^, can be 
  21080.            specified instead of a window name to alter the default location of 
  21081.            a slave, as described in the "RELATIVE PLACEMENT" section, below. 
  21082.            The following options are supported: 
  21083.  
  21084.            -column n      Insert the slave so that it occupies the nth column 
  21085.                           in the grid. Column numbers start with 0.  If this 
  21086.                           option is not supplied, then the slave is arranged 
  21087.                           just to the right of previous slave specified on this 
  21088.                           call to grid, or column "0" if it is the first slave. 
  21089.                           For each x that immediately precedes the slave, the 
  21090.                           column position is incremented by one.  Thus the x 
  21091.                           represents a blank column for this row in the grid. 
  21092.  
  21093.            -columnspan n  Insert the slave so that it occupies n columns in the 
  21094.                           grid. The default is one column, unless the window 
  21095.                           name is followed by a -, in which case the columnspan 
  21096.                           is incremented once for each immediately following -. 
  21097.  
  21098.            -in other      Insert the slave(s) in the master window given by 
  21099.                           other.  The default is the first slave's parent 
  21100.                           window. 
  21101.  
  21102.            -ipadx amount  The amount specifies how much horizontal internal 
  21103.                           padding to leave on each side of the slave(s).  This 
  21104.                           is space is added inside the slave(s) border. The 
  21105.                           amount must be a valid screen distance, such as 2 or 
  21106.                           .5c. It defaults to 0. 
  21107.  
  21108.            -ipady amount  The amount specifies how much vertical internal 
  21109.                           padding to leave on on the top and bottom of the 
  21110.                           slave(s). This space is added inside the slave(s) 
  21111.                           border. The amount  defaults to 0. 
  21112.  
  21113.            -padx amount   The amount specifies how much horizontal external 
  21114.                           padding to leave on each side of the slave(s), in 
  21115.                           screen units. The amount defaults to 0. This space is 
  21116.                           added outside the slave(s) border. 
  21117.  
  21118.            -pady amount   The amount specifies how much vertical external 
  21119.                           padding to leave on the top and bottom of the 
  21120.                           slave(s), in screen units. The amount defaults to 0. 
  21121.                           This space is added outside the slave(s) border. 
  21122.  
  21123.            -row n         Insert the slave so that it occupies the nth row in 
  21124.                           the grid. Row numbers start with 0.  If this option 
  21125.                           is not supplied, then the slave is arranged on the 
  21126.                           same row as the previous slave specified on this call 
  21127.                           to grid, or the first unoccupied row if this is the 
  21128.                           first slave. 
  21129.  
  21130.            -rowspan n     Insert the slave so that it occupies n rows in the 
  21131.                           grid. The default is one row.  If the next grid 
  21132.                           command contains ^ characters instead of slaves that 
  21133.                           line up with the columns of this slave, then the 
  21134.                           rowspan of this slave is extended by one. 
  21135.  
  21136.            -sticky style  If a slave's cell is larger than its requested 
  21137.                           dimensions, this option may be used to position (or 
  21138.                           stretch) the slave within its cell. Style  is a 
  21139.                           string that contains zero or more of the characters 
  21140.                           n, s, e or w. The string can optionally contains 
  21141.                           spaces or commas, but they are ignored.  Each letter 
  21142.                           refers to a side (north, south, east, or west) that 
  21143.                           the slave will "stick" to.  If both n and s (or e and 
  21144.                           w) are specified, the slave will be stretched to fill 
  21145.                           the entire height (or width) of its cavity.  The 
  21146.                           sticky option subsumes the combination of -anchor and 
  21147.                           -fill that is used by pack. The default is {}, which 
  21148.                           causes the slave to be centered in its cavity, at its 
  21149.                           requested size. 
  21150.  
  21151.            If any of the slaves are already managed by the geometry manager 
  21152.            then any unspecified options for them retain their previous values 
  21153.            rather than receiving default values. 
  21154.  
  21155.  grid forget slave ?slave ...?  Removes each of the slaves from grid for its 
  21156.            master and unmaps their windows. The slaves will no longer be 
  21157.            managed by the grid geometry manager. The configuration options for 
  21158.            that window are forgotten, so that if the slave is managed once more 
  21159.            by the grid geometry manager, the initial default settings are used. 
  21160.  
  21161.  grid info slave  Returns a list whose elements are the current configuration 
  21162.            state of the slave given by slave in the same option-value form that 
  21163.            might be specified to grid configure. The first two elements of the 
  21164.            list are "-in master" where master is the slave's master. 
  21165.  
  21166.  grid location master x y  Given  x and y values in screen units relative to 
  21167.            the master window, the column and row number at that x and y 
  21168.            location is returned. For locations that are above or to the left of 
  21169.            the grid, -1 is returned. 
  21170.  
  21171.  grid propagate master ?boolean?  If boolean has a true boolean value such as 1 
  21172.            or on then propagation is enabled for master, which must be a window 
  21173.            name (see "GEOMETRY PROPAGATION" below). If boolean has a false 
  21174.            boolean value then propagation is disabled for master. In either of 
  21175.            these cases an empty string is returned. If boolean is omitted then 
  21176.            the command returns 0 or 1 to indicate whether propagation is 
  21177.            currently enabled for master. Propagation is enabled by default. 
  21178.  
  21179.  grid rowconfigure master index ?-option value...?  Query or set the row 
  21180.            properties of the index row of the geometry master, master. The 
  21181.            valid options are -minsize, -weight and -pad. The -minsize option 
  21182.            sets the minimum size, in screen units, that will be permitted for 
  21183.            this row. The -weight option (an integer value) sets the relative 
  21184.            weight for apportioning any extra spaces among rows. A weight of 
  21185.            zero (0) indicates the row will not deviate from its requested size. 
  21186.            A row whose weight is two will grow at twice the rate as a row of 
  21187.            weight one when extra space is allocated to the layout. The -pad 
  21188.            option specifies the number of screen units that will be added to 
  21189.            the largest window contained completely in that row when the grid 
  21190.            geometry manager requests a size from the containing window. If only 
  21191.            an option is specified, with no value, the current value of that 
  21192.            option is returned. If only the master window and index is 
  21193.            specified, all the current settings are returned in an list of 
  21194.            "-option value" pairs. 
  21195.  
  21196.  grid remove slave ?slave ...?  Removes each of the slaves from grid for its 
  21197.            master and unmaps their windows. The slaves will no longer be 
  21198.            managed by the grid geometry manager. However, the configuration 
  21199.            options for that window are remembered, so that if the slave is 
  21200.            managed once more by the grid geometry manager, the previous values 
  21201.            are retained. 
  21202.  
  21203.  grid size master  Returns the size of the grid (in columns then rows) for 
  21204.            master. The size is determined either by the slave occupying the 
  21205.            largest row or column, or the largest column or row with a minsize, 
  21206.            weight, or pad that is non-zero. 
  21207.  
  21208.  grid slaves master ?-option value?  If no options are supplied, a list of all 
  21209.            of the slaves in master are returned, most recently manages first. 
  21210.            Option can be either -row or -column which causes only the slaves in 
  21211.            the row (or column) specified by value to be returned. 
  21212.  
  21213.  RELATIVE PLACEMENT 
  21214.  
  21215.  The grid command contains a limited set of capabilities that permit layouts to 
  21216.  be created without specifying the row and column information for each slave. 
  21217.  This permits slaves to be rearranged, added, or removed without the need to 
  21218.  explicitly specify row and column information. When no column or row 
  21219.  information is specified for a slave, default values are chosen for column, 
  21220.  row, columnspan and rowspan at the time the slave is managed. The values are 
  21221.  chosen based upon the current layout of the grid, the position of the slave 
  21222.  relative to other slaves in the same grid command, and the presence of the 
  21223.  characters -, ^, and ^ in grid command where slave names are normally 
  21224.  expected. 
  21225.  
  21226.  -         This increases the columnspan of the slave to the left.  Several -'s 
  21227.            in a row will successively increase the columnspan. A - may not 
  21228.            follow a ^ or a x. 
  21229.  
  21230.  x         This leaves an empty column between the slave on the left and the 
  21231.            slave on the right. 
  21232.  
  21233.  ^         This extends the rowspan of the slave above the ^'s in the grid. 
  21234.            The number of ^'s in a row must match the number of columns spanned 
  21235.            by the slave above it. 
  21236.  
  21237.  THE GRID ALGORITHM 
  21238.  
  21239.  The grid geometry manager lays out its slaves in three steps. In the first 
  21240.  step, the minimum size needed to fit all of the slaves is computed, then (if 
  21241.  propagation is turned on), a request is made of the master window to become 
  21242.  that size. In the second step, the requested size is compared against the 
  21243.  actual size of the master.  If the sizes are different, then spaces is added 
  21244.  to or taken away from the layout as needed. For the final step, each slave is 
  21245.  positioned in its row(s) and column(s) based on the setting of its sticky 
  21246.  flag. 
  21247.  
  21248.  To compute the minimum size of a layout, the grid geometry manager first looks 
  21249.  at all slaves whose columnspan and rowspan values are one, and computes the 
  21250.  nominal size of each row or column to be either the minsize for that row or 
  21251.  column, or the sum of the padding plus the size of the largest slave, 
  21252.  whichever is greater.  Then the slaves whose rowspans or columnspans are 
  21253.  greater than one are examined.  If a group of rows or columns need to be 
  21254.  increased in size in order to accommodate these slaves, then extra space is 
  21255.  added to each row or column in the group according to its weight.  For each 
  21256.  group whose weights are all zero, the additional space is apportioned equally. 
  21257.  
  21258.  For masters whose size is larger than the requested layout, the additional 
  21259.  space is apportioned according to the row and column weights.  If all of the 
  21260.  weights are zero, the layout is centered within its master. For masters whose 
  21261.  size is smaller than the requested layout, space is taken away from columns 
  21262.  and rows according to their weights.  However, once a column or row shrinks to 
  21263.  its minsize, its weight is taken to be zero. If more space needs to be removed 
  21264.  from a layout than would be permitted, as when all the rows or columns are at 
  21265.  there minimum sizes, the layout is clipped on the bottom and right. 
  21266.  
  21267.  GEOMETRY PROPAGATION 
  21268.  
  21269.  The grid geometry manager normally computes how large a master must be to just 
  21270.  exactly meet the needs of its slaves, and it sets the requested width and 
  21271.  height of the master to these dimensions. This causes geometry information to 
  21272.  propagate up through a window hierarchy to a top-level window so that the 
  21273.  entire sub-tree sizes itself to fit the needs of the leaf windows. However, 
  21274.  the grid propagate command may be used to turn off propagation for one or more 
  21275.  masters. If propagation is disabled then grid will not set the requested width 
  21276.  and height of the master window. This may be useful if, for example, you wish 
  21277.  for a master window to have a fixed size that you specify. 
  21278.  
  21279.  RESTRICTIONS ON MASTER WINDOWS 
  21280.  
  21281.  The master for each slave must either be the slave's parent (the default) or a 
  21282.  descendant of the slave's parent. This restriction is necessary to guarantee 
  21283.  that the slave can be placed over any part of its master that is visible 
  21284.  without danger of the slave being clipped by its parent. In addition, all 
  21285.  slaves in one call to grid must have the same master. 
  21286.  
  21287.  STACKING ORDER 
  21288.  
  21289.  If the master for a slave is not its parent then you must make sure that the 
  21290.  slave is higher in the stacking order than the master. Otherwise the master 
  21291.  will obscure the slave and it will appear as if the slave hasn't been managed 
  21292.  correctly. The easiest way to make sure the slave is higher than the master is 
  21293.  to create the master window first:  the most recently created window will be 
  21294.  highest in the stacking order. 
  21295.  
  21296.  CREDITS 
  21297.  
  21298.  The grid command is based on ideas taken from the GridBag geometry manager 
  21299.  written by Doug. Stein, and the blt_table geometry manager, written by George 
  21300.  Howlett. 
  21301.  
  21302.  KEYWORDS 
  21303.  
  21304.  geometry manager, location, grid, cell, propagation, size, pack 
  21305.  
  21306.  
  21307. ΓòÉΓòÉΓòÉ 6.20. image ΓòÉΓòÉΓòÉ
  21308.  
  21309.  NAME 
  21310.  
  21311. image - Create and manipulate images 
  21312.  
  21313. SYNOPSIS 
  21314.  
  21315. image option ?arg arg ...? 
  21316.  
  21317. DESCRIPTION 
  21318.  
  21319. The image command is used to create, delete, and query images. It can take 
  21320. several different forms, depending on the option argument.  The legal forms 
  21321. are: 
  21322.  
  21323.  image create type ?name? ?option value ...?  Creates a new image and returns 
  21324.            its name. type specifies the type of the image, which must be one of 
  21325.            the types currently defined (e.g., bitmap). name specifies the name 
  21326.            for the image;  if it is omitted then Tk picks a name of the form 
  21327.            imagex, where x is an integer. There may be any number of 
  21328.            option-value pairs, which provide configuration options for the new 
  21329.            image. The legal set of options is defined separately for each image 
  21330.            type;  see below for details on the options for built-in image 
  21331.            types. If an image already exists by the given name then it is 
  21332.            replaced with the new image and any instances of that image will 
  21333.            redisplay with the new contents. 
  21334.  
  21335.  image delete ?name name ...?  Deletes each of the named images and returns an 
  21336.            empty string. If there are instances of the images displayed in 
  21337.            widgets, the images won't actually be deleted until all of the 
  21338.            instances are released. However, the association between the 
  21339.            instances and the image manager will be dropped. Existing instances 
  21340.            will retain their sizes but redisplay as empty areas. If a deleted 
  21341.            image is recreated with another call to image create, the existing 
  21342.            instances will use the new image. 
  21343.  
  21344.  image height name  Returns a decimal string giving the height of image name in 
  21345.            pixels. 
  21346.  
  21347.  image names  Returns a list containing the names of all existing images. 
  21348.  
  21349.  image type name  Returns the type of image name (the value of the type 
  21350.            argument to image create when the image was created). 
  21351.  
  21352.  image types  Returns a list whose elements are all of the valid image types 
  21353.            (i.e., all of the values that may be supplied for the type argument 
  21354.            to image create). 
  21355.  
  21356.  image width name  Returns a decimal string giving the width of image name in 
  21357.            pixels. 
  21358.  
  21359.  BUILT-IN IMAGE TYPES 
  21360.  
  21361.  The following image types are defined by Tk so they will be available in any 
  21362.  Tk application. Individual applications or extensions may define additional 
  21363.  types. 
  21364.  
  21365.  bitmap    Each pixel in the image displays a foreground color, a background 
  21366.            color, or nothing. See the bitmap manual entry for more information. 
  21367.  
  21368.  photo     Displays a variety of full-color images, using dithering to 
  21369.            approximate colors on displays with limited color capabilities. See 
  21370.            the photo manual entry for more information. 
  21371.  
  21372.  KEYWORDS 
  21373.  
  21374.  height, image, types of images, width 
  21375.  
  21376.  
  21377. ΓòÉΓòÉΓòÉ 6.21. label ΓòÉΓòÉΓòÉ
  21378.  
  21379.  NAME 
  21380.  
  21381. label - Create and manipulate label widgets 
  21382.  
  21383. SYNOPSIS 
  21384.  
  21385. label pathName ?options? 
  21386.  
  21387. STANDARD OPTIONS 
  21388.  
  21389. -anchor              -font                -image               -takefocus
  21390. -background          -foreground          -justify             -text
  21391. -bitmap              -highlightbackground -padx                -textvariable
  21392. -borderwidth         -highlightcolor      -pady                -underline
  21393. -cursor              -highlightthickness  -relief              -wraplength
  21394.  
  21395. See the options manual entry for detailed descriptions of the above options.
  21396.  
  21397. WIDGET-SPECIFIC OPTIONS 
  21398.  
  21399.   Command-Line Name:    -height
  21400.   Database Name:        height
  21401.   Database Class:       Height
  21402.  
  21403.            Specifies a desired height for the label. If an image or bitmap is 
  21404.            being displayed in the label then the value is in screen units (i.e. 
  21405.            any of the forms acceptable to Tk_GetPixels); for text it is in 
  21406.            lines of text. If this option isn't specified, the label's desired 
  21407.            height is computed from the size of the image or bitmap or text 
  21408.            being displayed in it. 
  21409.  
  21410.   Command-Line Name:    -width
  21411.   Database Name:        width
  21412.   Database Class:       Width
  21413.  
  21414.            Specifies a desired width for the label. If an image or bitmap is 
  21415.            being displayed in the label then the value is in screen units (i.e. 
  21416.            any of the forms acceptable to Tk_GetPixels); for text it is in 
  21417.            characters. If this option isn't specified, the label's desired 
  21418.            width is computed from the size of the image or bitmap or text being 
  21419.            displayed in it. 
  21420.  
  21421.  DESCRIPTION 
  21422.  
  21423.  The label command creates a new window (given by the pathName argument) and 
  21424.  makes it into a label widget. Additional options, described above, may be 
  21425.  specified on the command line or in the option database to configure aspects 
  21426.  of the label such as its colors, font, text, and initial relief.  The label 
  21427.  command returns its pathName argument.  At the time this command is invoked, 
  21428.  there must not exist a window named pathName, but pathName's parent must 
  21429.  exist. 
  21430.  
  21431.  A label is a widget that displays a textual string, bitmap or image. If text 
  21432.  is displayed, it must all be in a single font, but it can occupy multiple 
  21433.  lines on the screen (if it contains newlines or if wrapping occurs because of 
  21434.  the wrapLength option) and one of the characters may optionally be underlined 
  21435.  using the underline option. The label can be manipulated in a few simple ways, 
  21436.  such as changing its relief or text, using the commands described below. 
  21437.  
  21438.  WIDGET COMMAND 
  21439.  
  21440.  The label command creates a new Tcl command whose name is pathName.  This 
  21441.  command may be used to invoke various operations on the widget.  It has the 
  21442.  following general form: 
  21443.  
  21444.   pathName option ?arg arg ...?
  21445.  Option and the args determine the exact behavior of the command.  The 
  21446.  following commands are possible for label widgets: 
  21447.  
  21448.  pathName cget option  Returns the current value of the configuration option 
  21449.            given by option. Option may have any of the values accepted by the 
  21450.            label command. 
  21451.  
  21452.  pathName configure ?option? ?value option value ...?  Query or modify the 
  21453.            configuration options of the widget. If no option is specified, 
  21454.            returns a list describing all of the available options for pathName 
  21455.            (see Tk_ConfigureInfo for information on the format of this list). 
  21456.            If option is specified with no value, then the command returns a 
  21457.            list describing the one named option (this list will be identical to 
  21458.            the corresponding sublist of the value returned if no option is 
  21459.            specified).  If one or more option-value pairs are specified, then 
  21460.            the command modifies the given widget option(s) to have the given 
  21461.            value(s);  in this case the command returns an empty string. Option 
  21462.            may have any of the values accepted by the label command. 
  21463.  
  21464.  BINDINGS 
  21465.  
  21466.  When a new label is created, it has no default event bindings: labels are not 
  21467.  intended to be interactive. 
  21468.  
  21469.  KEYWORDS 
  21470.  
  21471.  label, widget 
  21472.  
  21473.  
  21474. ΓòÉΓòÉΓòÉ 6.22. listbox ΓòÉΓòÉΓòÉ
  21475.  
  21476.  NAME 
  21477.  
  21478. listbox - Create and manipulate listbox widgets 
  21479.  
  21480. SYNOPSIS 
  21481.  
  21482. listbox pathName ?options? 
  21483.  
  21484. STANDARD OPTIONS 
  21485.  
  21486. -background          -foreground          -relief              -takefocus
  21487. -borderwidth         -height              -selectbackground    -width
  21488. -cursor              -highlightbackground -selectborderwidth   -xscrollcommand
  21489. -exportselection     -highlightcolor      -selectforeground    -yscrollcommand
  21490. -font                -highlightthickness  -setgrid
  21491.  
  21492. See the options manual entry for detailed descriptions of the above options.
  21493.  
  21494. WIDGET-SPECIFIC OPTIONS 
  21495.  
  21496.   Command-Line Name:    -height
  21497.   Database Name:        height
  21498.   Database Class:       Height
  21499.  
  21500.            Specifies the desired height for the window, in lines. If zero or 
  21501.            less, then the desired height for the window is made just large 
  21502.            enough to hold all the elements in the listbox. 
  21503.  
  21504.   Command-Line Name:    -selectmode
  21505.   Database Name:        selectMode
  21506.   Database Class:       SelectMode
  21507.  
  21508.            Specifies one of several styles for manipulating the selection. The 
  21509.            value of the option may be arbitrary, but the default bindings 
  21510.            expect it to be either single, browse, multiple, or extended;  the 
  21511.            default value is browse. 
  21512.  
  21513.   Command-Line Name:    -width
  21514.   Database Name:        width
  21515.   Database Class:       Width
  21516.  
  21517.            Specifies the desired width for the window in characters. If the 
  21518.            font doesn't have a uniform width then the width of the character 
  21519.            "0" is used in translating from character units to screen units. If 
  21520.            zero or less, then the desired width for the window is made just 
  21521.            large enough to hold all the elements in the listbox. 
  21522.  
  21523.  DESCRIPTION 
  21524.  
  21525.  The listbox command creates a new window (given by the pathName argument) and 
  21526.  makes it into a listbox widget. Additional options, described above, may be 
  21527.  specified on the command line or in the option database to configure aspects 
  21528.  of the listbox such as its colors, font, text, and relief.  The listbox 
  21529.  command returns its pathName argument.  At the time this command is invoked, 
  21530.  there must not exist a window named pathName, but pathName's parent must 
  21531.  exist. 
  21532.  
  21533.  A listbox is a widget that displays a list of strings, one per line. When 
  21534.  first created, a new listbox has no elements. Elements may be added or deleted 
  21535.  using widget commands described below.  In addition, one or more elements may 
  21536.  be selected as described below. If a listbox is exporting its selection (see 
  21537.  exportSelection option), then it will observe the standard X11 protocols for 
  21538.  handling the selection. Listbox selections are available as type STRING; the 
  21539.  value of the selection will be the text of the selected elements, with 
  21540.  newlines separating the elements. 
  21541.  
  21542.  It is not necessary for all the elements to be displayed in the listbox window 
  21543.  at once;  commands described below may be used to change the view in the 
  21544.  window.  Listboxes allow scrolling in both directions using the standard 
  21545.  xScrollCommand and yScrollCommand options. They also support scanning, as 
  21546.  described below. 
  21547.  
  21548.  INDICES 
  21549.  
  21550.  Many of the widget commands for listboxes take one or more indices as 
  21551.  arguments. An index specifies a particular element of the listbox, in any of 
  21552.  the following ways: 
  21553.  
  21554.  number    Specifies the element as a numerical index, where 0 corresponds to 
  21555.            the first element in the listbox. 
  21556.  
  21557.  active    Indicates the element that has the location cursor.  This element 
  21558.            will be displayed with an underline when the listbox has the 
  21559.            keyboard focus, and it is specified with the activate widget 
  21560.            command. 
  21561.  
  21562.  anchor    Indicates the anchor point for the selection, which is set with the 
  21563.            selection anchor widget command. 
  21564.  
  21565.  end       Indicates the end of the listbox. For some commands this means just 
  21566.            after the last element; for other commands it means the last 
  21567.            element. 
  21568.  
  21569.  @x,y      Indicates the element that covers the point in the listbox window 
  21570.            specified by x and y (in pixel coordinates).  If no element covers 
  21571.            that point, then the closest element to that point is used. 
  21572.  
  21573.  In the widget command descriptions below, arguments named index, first, and 
  21574.  last always contain text indices in one of the above forms. 
  21575.  
  21576.  WIDGET COMMAND 
  21577.  
  21578.  The listbox command creates a new Tcl command whose name is pathName.  This 
  21579.  command may be used to invoke various operations on the widget.  It has the 
  21580.  following general form: 
  21581.  
  21582.   pathName option ?arg arg ...?
  21583.  Option and the args determine the exact behavior of the command.  The 
  21584.  following commands are possible for listbox widgets: 
  21585.  
  21586.  pathName activate index  Sets the active element to the one indicated by 
  21587.            index. The active element is drawn with an underline when the widget 
  21588.            has the input focus, and its index may be retrieved with the index 
  21589.            active. 
  21590.  
  21591.  pathName bbox index  Returns a list of four numbers describing the bounding 
  21592.            box of the text in the element given by index. The first two 
  21593.            elements of the list give the x and y coordinates of the upper-left 
  21594.            corner of the screen area covered by the text (specified in pixels 
  21595.            relative to the widget) and the last two elements give the width and 
  21596.            height of the area, in pixels. If no part of the element given by 
  21597.            index is visible on the screen then the result is an empty string; 
  21598.            if the element is partially visible, the result gives the full area 
  21599.            of the element, including any parts that are not visible. 
  21600.  
  21601.  pathName cget option  Returns the current value of the configuration option 
  21602.            given by option. Option may have any of the values accepted by the 
  21603.            listbox command. 
  21604.  
  21605.  pathName configure ?option? ?value option value ...?  Query or modify the 
  21606.            configuration options of the widget. If no option is specified, 
  21607.            returns a list describing all of the available options for pathName 
  21608.            (see Tk_ConfigureInfo for information on the format of this list). 
  21609.            If option is specified with no value, then the command returns a 
  21610.            list describing the one named option (this list will be identical to 
  21611.            the corresponding sublist of the value returned if no option is 
  21612.            specified).  If one or more option-value pairs are specified, then 
  21613.            the command modifies the given widget option(s) to have the given 
  21614.            value(s);  in this case the command returns an empty string. Option 
  21615.            may have any of the values accepted by the listbox command. 
  21616.  
  21617.  pathName curselection  Returns a list containing the numerical indices of all 
  21618.            of the elements in the listbox that are currently selected. If there 
  21619.            are no elements selected in the listbox then an empty string is 
  21620.            returned. 
  21621.  
  21622.  pathName delete first ?last?  Deletes one or more elements of the listbox. 
  21623.            First and last are indices specifying the first and last elements in 
  21624.            the range to delete.  If last isn't specified it defaults to first, 
  21625.            i.e. a single element is deleted. 
  21626.  
  21627.  pathName get first ?last?  If last is omitted, returns the contents of the 
  21628.            listbox element indicated by first. If last is specified, the 
  21629.            command returns a list whose elements are all of the listbox 
  21630.            elements between first and last, inclusive. Both first and last may 
  21631.            have any of the standard forms for indices. 
  21632.  
  21633.  pathName index index  Returns a decimal string giving the integer index value 
  21634.            that corresponds to index. 
  21635.  
  21636.  pathName insert index ?element element ...?  Inserts zero or more new elements 
  21637.            in the list just before the element given by index.  If index is 
  21638.            specified as end then the new elements are added to the end of the 
  21639.            list.  Returns an empty string. 
  21640.  
  21641.  pathName nearest y  Given a y-coordinate within the listbox window, this 
  21642.            command returns the index of the (visible) listbox element nearest 
  21643.            to that y-coordinate. 
  21644.  
  21645.  pathName scan option args  This command is used to implement scanning on 
  21646.            listboxes.  It has two forms, depending on option: 
  21647.  
  21648.            pathName scan mark x y  Records x and y and the current view in the 
  21649.                           listbox window;  used in conjunction with later scan 
  21650.                           dragto commands. Typically this command is associated 
  21651.                           with a mouse button press in the widget.  It returns 
  21652.                           an empty string. 
  21653.  
  21654.            pathName scan dragto x y.  This command computes the difference 
  21655.                           between its x and y arguments and the x and y 
  21656.                           arguments to the last scan mark command for the 
  21657.                           widget. It then adjusts the view by 10 times the 
  21658.                           difference in coordinates.  This command is typically 
  21659.                           associated with mouse motion events in the widget, to 
  21660.                           produce the effect of dragging the list at high speed 
  21661.                           through the window.  The return value is an empty 
  21662.                           string. 
  21663.  
  21664.  pathName see index  Adjust the view in the listbox so that the element given 
  21665.            by index is visible. If the element is already visible then the 
  21666.            command has no effect; if the element is near one edge of the window 
  21667.            then the listbox scrolls to bring the element into view at the edge; 
  21668.            otherwise the listbox scrolls to center the element. 
  21669.  
  21670.  pathName selection option arg  This command is used to adjust the selection 
  21671.            within a listbox.  It has several forms, depending on option: 
  21672.  
  21673.            pathName selection anchor index  Sets the selection anchor to the 
  21674.                           element given by index. The selection anchor is the 
  21675.                           end of the selection that is fixed while dragging out 
  21676.                           a selection with the mouse. The index anchor may be 
  21677.                           used to refer to the anchor element. 
  21678.  
  21679.            pathName selection clear first ?last?  If any of the elements 
  21680.                           between first and last (inclusive) are selected, they 
  21681.                           are deselected. The selection state is not changed 
  21682.                           for elements outside this range. 
  21683.  
  21684.            pathName selection includes index  Returns 1 if the element 
  21685.                           indicated by index is currently selected, 0 if it 
  21686.                           isn't. 
  21687.  
  21688.            pathName selection set first ?last?  Selects all of the elements in 
  21689.                           the range between first and last, inclusive, without 
  21690.                           affecting the selection state of elements outside 
  21691.                           that range. 
  21692.  
  21693.  pathName size  Returns a decimal string indicating the total number of 
  21694.            elements in the listbox. 
  21695.  
  21696.  pathName xview args  This command is used to query and change the horizontal 
  21697.            position of the information in the widget's window.  It can take any 
  21698.            of the following forms: 
  21699.  
  21700.            pathName xview  Returns a list containing two elements. Each element 
  21701.                           is a real fraction between 0 and 1;  together they 
  21702.                           describe the horizontal span that is visible in the 
  21703.                           window. For example, if the first element is .2 and 
  21704.                           the second element is .6, 20% of the listbox's text 
  21705.                           is off-screen to the left, the middle 40% is visible 
  21706.                           in the window, and 40% of the text is off-screen to 
  21707.                           the right. These are the same values passed to 
  21708.                           scrollbars via the -xscrollcommand option. 
  21709.  
  21710.            pathName xview index  Adjusts the view in the window so that the 
  21711.                           character position given by index is displayed at the 
  21712.                           left edge of the window. Character positions are 
  21713.                           defined by the width of the character 0. 
  21714.  
  21715.            pathName xview moveto fraction  Adjusts the view in the window so 
  21716.                           that fraction of the total width of the listbox text 
  21717.                           is off-screen to the left. fraction must be a 
  21718.                           fraction between 0 and 1. 
  21719.  
  21720.            pathName xview scroll number what  This command shifts the view in 
  21721.                           the window left or right according to number and 
  21722.                           what. Number must be an integer. What must be either 
  21723.                           units or pages or an abbreviation of one of these. If 
  21724.                           what is units, the view adjusts left or right by 
  21725.                           number character units (the width of the 0 character) 
  21726.                           on the display;  if it is pages then the view adjusts 
  21727.                           by number screenfuls. If number is negative then 
  21728.                           characters farther to the left become visible;  if it 
  21729.                           is positive then characters farther to the right 
  21730.                           become visible. 
  21731.  
  21732.  pathName yview ?args?  This command is used to query and change the vertical 
  21733.            position of the text in the widget's window. It can take any of the 
  21734.            following forms: 
  21735.  
  21736.            pathName yview  Returns a list containing two elements, both of 
  21737.                           which are real fractions between 0 and 1. The first 
  21738.                           element gives the position of the listbox element at 
  21739.                           the top of the window, relative to the listbox as a 
  21740.                           whole (0.5 means it is halfway through the listbox, 
  21741.                           for example). The second element gives the position 
  21742.                           of the listbox element just after the last one in the 
  21743.                           window, relative to the listbox as a whole. These are 
  21744.                           the same values passed to scrollbars via the 
  21745.                           -yscrollcommand option. 
  21746.  
  21747.            pathName yview index  Adjusts the view in the window so that the 
  21748.                           element given by index is displayed at the top of the 
  21749.                           window. 
  21750.  
  21751.            pathName yview moveto fraction  Adjusts the view in the window so 
  21752.                           that the element given by fraction appears at the top 
  21753.                           of the window. Fraction is a fraction between 0 and 
  21754.                           1;  0 indicates the first element in the listbox, 
  21755.                           0.33 indicates the element one-third the way through 
  21756.                           the listbox, and so on. 
  21757.  
  21758.            pathName yview scroll number what  This command adjusts the view in 
  21759.                           the window up or down according to number and what. 
  21760.                           Number must be an integer. What must be either units 
  21761.                           or pages. If what is units, the view adjusts up or 
  21762.                           down by number lines;  if it is pages then the view 
  21763.                           adjusts by number screenfuls. If number is negative 
  21764.                           then earlier elements become visible;  if it is 
  21765.                           positive then later elements become visible. 
  21766.  
  21767.  DEFAULT BINDINGS 
  21768.  
  21769.  Tk automatically creates class bindings for listboxes that give them 
  21770.  Motif-like behavior.  Much of the behavior of a listbox is determined by its 
  21771.  selectMode option, which selects one of four ways of dealing with the 
  21772.  selection. 
  21773.  
  21774.  If the selection mode is single or browse, at most one element can be selected 
  21775.  in the listbox at once. In both modes, clicking button 1 on an element selects 
  21776.  it and deselects any other selected item. In browse mode it is also possible 
  21777.  to drag the selection with button 1. 
  21778.  
  21779.  If the selection mode is multiple or extended, any number of elements may be 
  21780.  selected at once, including discontiguous ranges.  In multiple mode, clicking 
  21781.  button 1 on an element toggles its selection state without affecting any other 
  21782.  elements. In extended mode, pressing button 1 on an element selects it, 
  21783.  deselects everything else, and sets the anchor to the element under the mouse; 
  21784.  dragging the mouse with button 1 down extends the selection to include all the 
  21785.  elements between the anchor and the element under the mouse, inclusive. 
  21786.  
  21787.  Most people will probably want to use browse mode for single selections and 
  21788.  extended mode for multiple selections; the other modes appear to be useful 
  21789.  only in special situations. 
  21790.  
  21791.  In addition to the above behavior, the following additional behavior is 
  21792.  defined by the default bindings: 
  21793.  
  21794.    1. In extended mode, the selected range can be adjusted by pressing button 1 
  21795.       with the Shift key down:  this modifies the selection to consist of the 
  21796.       elements between the anchor and the element under the mouse, inclusive. 
  21797.       The un-anchored end of this new selection can also be dragged with the 
  21798.       button down. 
  21799.  
  21800.    2. In extended mode, pressing button 1 with the Control key down starts a 
  21801.       toggle operation: the anchor is set to the element under the mouse, and 
  21802.       its selection state is reversed.  The selection state of other elements 
  21803.       isn't changed. If the mouse is dragged with button 1 down, then the 
  21804.       selection state of all elements between the anchor and the element under 
  21805.       the mouse is set to match that of the anchor element;  the selection 
  21806.       state of all other elements remains what it was before the toggle 
  21807.       operation began. 
  21808.  
  21809.    3. If the mouse leaves the listbox window with button 1 down, the window 
  21810.       scrolls away from the mouse, making information visible that used to be 
  21811.       off-screen on the side of the mouse. The scrolling continues until the 
  21812.       mouse re-enters the window, the button is released, or the end of the 
  21813.       listbox is reached. 
  21814.  
  21815.    4. Mouse button 2 may be used for scanning. If it is pressed and dragged 
  21816.       over the listbox, the contents of the listbox drag at high speed in the 
  21817.       direction the mouse moves. 
  21818.  
  21819.    5. If the Up or Down key is pressed, the location cursor (active element) 
  21820.       moves up or down one element. If the selection mode is browse or extended 
  21821.       then the new active element is also selected and all other elements are 
  21822.       deselected. In extended mode the new active element becomes the selection 
  21823.       anchor. 
  21824.  
  21825.    6. In extended mode, Shift-Up and Shift-Down move the location cursor 
  21826.       (active element) up or down one element and also extend the selection to 
  21827.       that element in a fashion similar to dragging with mouse button 1. 
  21828.  
  21829.    7. The Left and Right keys scroll the listbox view left and right by the 
  21830.       width of the character 0. Control-Left and Control-Right scroll the 
  21831.       listbox view left and right by the width of the window. Control-Prior and 
  21832.       Control-Next also scroll left and right by the width of the window. 
  21833.  
  21834.    8. The Prior and Next keys scroll the listbox view up and down by one page 
  21835.       (the height of the window). 
  21836.  
  21837.    9. The Home and End keys scroll the listbox horizontally to the left and 
  21838.       right edges, respectively. 
  21839.  
  21840.   10. Control-Home sets the location cursor to the the first element in the 
  21841.       listbox, selects that element, and deselects everything else in the 
  21842.       listbox. 
  21843.  
  21844.   11. Control-End sets the location cursor to the the last element in the 
  21845.       listbox, selects that element, and deselects everything else in the 
  21846.       listbox. 
  21847.  
  21848.   12. In extended mode, Control-Shift-Home extends the selection to the first 
  21849.       element in the listbox and Control-Shift-End extends the selection to the 
  21850.       last element. 
  21851.  
  21852.   13. In multiple mode, Control-Shift-Home moves the location cursor to the 
  21853.       first element in the listbox and Control-Shift-End moves the location 
  21854.       cursor to the last element. 
  21855.  
  21856.   14. The space and Select keys make a selection at the location cursor (active 
  21857.       element) just as if mouse button 1 had been pressed over this element. 
  21858.  
  21859.   15. In extended mode, Control-Shift-space and Shift-Select extend the 
  21860.       selection to the active element just as if button 1 had been pressed with 
  21861.       the Shift key down. 
  21862.  
  21863.   16. In extended mode, the Escape key cancels the most recent selection and 
  21864.       restores all the elements in the selected range to their previous 
  21865.       selection state. 
  21866.  
  21867.   17. Control-slash selects everything in the widget, except in single and 
  21868.       browse modes, in which case it selects the active element and deselects 
  21869.       everything else. 
  21870.  
  21871.   18. Control-backslash deselects everything in the widget, except in browse 
  21872.       mode where it has no effect. 
  21873.  
  21874.   19. The F16 key (labelled Copy on many Sun workstations) or Meta-w copies the 
  21875.       selection in the widget to the clipboard, if there is a selection. 
  21876.  
  21877.  The behavior of listboxes can be changed by defining new bindings for 
  21878.  individual widgets or by redefining the class bindings. 
  21879.  
  21880.  KEYWORDS 
  21881.  
  21882.  listbox, widget 
  21883.  
  21884.  
  21885. ΓòÉΓòÉΓòÉ 6.23. lower ΓòÉΓòÉΓòÉ
  21886.  
  21887.  NAME 
  21888.  
  21889. lower - Change a window's position in the stacking order 
  21890.  
  21891. SYNOPSIS 
  21892.  
  21893. lower window ?belowThis? 
  21894.  
  21895. DESCRIPTION 
  21896.  
  21897. If the belowThis argument is omitted then the command lowers window so that it 
  21898. is below all of its siblings in the stacking order (it will be obscured by any 
  21899. siblings that overlap it and will not obscure any siblings). If belowThis is 
  21900. specified then it must be the path name of a window that is either a sibling of 
  21901. window or the descendant of a sibling of window. In this case the lower command 
  21902. will insert window into the stacking order just below belowThis (or the 
  21903. ancestor of belowThis that is a sibling of window); this could end up either 
  21904. raising or lowering window. 
  21905.  
  21906. SEE ALSO 
  21907.  
  21908. raise 
  21909.  
  21910. KEYWORDS 
  21911.  
  21912. lower, obscure, stacking order 
  21913.  
  21914.  
  21915. ΓòÉΓòÉΓòÉ 6.24. menu ΓòÉΓòÉΓòÉ
  21916.  
  21917.  NAME 
  21918.  
  21919. menu - Create and manipulate menu widgets 
  21920.  
  21921. SYNOPSIS 
  21922.  
  21923. menu pathName ?options? 
  21924.  
  21925. STANDARD OPTIONS 
  21926.  
  21927. -activebackground    -background          -disabledforeground  -relief
  21928. -activeborderwidth   -borderwidth         -font                -takefocus
  21929. -activeforeground    -cursor              -foreground
  21930.  
  21931. See the options manual entry for detailed descriptions of the above options.
  21932.  
  21933. WIDGET-SPECIFIC OPTIONS 
  21934.  
  21935.   Command-Line Name:    -postcommand
  21936.   Database Name:        postCommand
  21937.   Database Class:       Command
  21938.  
  21939.            If this option is specified then it provides a Tcl command to 
  21940.            execute each time the menu is posted.  The command is invoked by the 
  21941.            post widget command before posting the menu. 
  21942.  
  21943.   Command-Line Name:    -selectcolor
  21944.   Database Name:        selectColor
  21945.   Database Class:       Background
  21946.  
  21947.            For menu entries that are check buttons or radio buttons, this 
  21948.            option specifies the color to display in the indicator when the 
  21949.            check button or radio button is selected. 
  21950.  
  21951.   Command-Line Name:    -tearoff
  21952.   Database Name:        tearOff
  21953.   Database Class:       TearOff
  21954.  
  21955.            This option must have a proper boolean value, which specifies 
  21956.            whether or not the menu should include a tear-off entry at the top. 
  21957.            If so, it will exist as entry 0 of the menu and the other entries 
  21958.            will number starting at 1.  The default menu bindings arrange for 
  21959.            the menu to be torn off when the tear-off entry is invoked. 
  21960.  
  21961.   Command-Line Name:    -tearoffcommand
  21962.   Database Name:        tearOffCommand
  21963.   Database Class:       TearOffCommand
  21964.  
  21965.            If this option has a non-empty value, then it specifies a Tcl 
  21966.            command to invoke whenever the menu is torn off.  The actual command 
  21967.            will consist of the value of this option, followed by a space, 
  21968.            followed by the name of the menu window, followed by a space, 
  21969.            followed by the name of the name of the torn off menu window.  For 
  21970.            example, if the option's is "a b" and menu .x.y is torn off to 
  21971.            create a new menu .x.tearoff1, then the command "a b .x.y 
  21972.            .x.tearoff1" will be invoked. 
  21973.  
  21974.   Command-Line Name:    -transient
  21975.   Database Name:        transient
  21976.   Database Class:       Transient
  21977.  
  21978.            This option must have a boolean value.  True means that the menu is 
  21979.            used on a transient basis, e.g. as a pop-up, pull-down, or cascaded 
  21980.            menu.  False means that the menu will be displayed on the screen 
  21981.            continuously, for example as a torn-off menu. If the option is true, 
  21982.            no window manager border will be displayed around the menu and 
  21983.            redisplay will be optimized using X's "save under" facility. 
  21984.  
  21985.  INTRODUCTION 
  21986.  
  21987.  The menu command creates a new top-level window (given by the pathName 
  21988.  argument) and makes it into a menu widget. Additional options, described 
  21989.  above, may be specified on the command line or in the option database to 
  21990.  configure aspects of the menu such as its colors and font. The menu command 
  21991.  returns its pathName argument.  At the time this command is invoked, there 
  21992.  must not exist a window named pathName, but pathName's parent must exist. 
  21993.  
  21994.  A menu is a widget that displays a collection of one-line entries arranged in 
  21995.  a column.  There exist several different types of entries, each with different 
  21996.  properties.  Entries of different types may be combined in a single menu. 
  21997.  Menu entries are not the same as entry widgets.  In fact, menu entries are not 
  21998.  even distinct widgets; the entire menu is one widget. 
  21999.  
  22000.  Menu entries are displayed with up to three separate fields. The main field is 
  22001.  a label in the form of a text string, a bitmap, or an image, controlled by the 
  22002.  -label, -bitmap, and -image options for the entry. If the  -accelerator option 
  22003.  is specified for an entry then a second textual field is displayed to the 
  22004.  right of the label.  The accelerator typically describes a keystroke sequence 
  22005.  that may be typed in the application to cause the same result as invoking the 
  22006.  menu entry. The third field is an indicator.  The indicator is present only 
  22007.  for checkbutton or radiobutton entries.  It indicates whether the entry is 
  22008.  selected or not, and is displayed to the left of the entry's string. 
  22009.  
  22010.  In normal use, an entry becomes active (displays itself differently) whenever 
  22011.  the mouse pointer is over the entry.  If a mouse button is released over the 
  22012.  entry then the entry is invoked. The effect of invocation is different for 
  22013.  each type of entry; these effects are described below in the sections on 
  22014.  individual entries. 
  22015.  
  22016.  Entries may be disabled, which causes their labels and accelerators to be 
  22017.  displayed with dimmer colors. The default menu bindings will not allow a 
  22018.  disabled entry to be activated or invoked. Disabled entries may be re-enabled, 
  22019.  at which point it becomes possible to activate and invoke them again. 
  22020.  
  22021.  COMMAND ENTRIES 
  22022.  
  22023.  The most common kind of menu entry is a command entry, which behaves much like 
  22024.  a button widget.  When a command entry is invoked, a Tcl command is executed. 
  22025.  The Tcl command is specified with the -command option. 
  22026.  
  22027.  SEPARATOR ENTRIES 
  22028.  
  22029.  A separator is an entry that is displayed as a horizontal dividing line.  A 
  22030.  separator may not be activated or invoked, and it has no behavior other than 
  22031.  its display appearance. 
  22032.  
  22033.  CHECKBUTTON ENTRIES 
  22034.  
  22035.  A checkbutton menu entry behaves much like a checkbutton widget. When it is 
  22036.  invoked it toggles back and forth between the selected and deselected states. 
  22037.  When the entry is selected, a particular value is stored in a particular 
  22038.  global variable (as determined by the -onvalue and -variable options for the 
  22039.  entry);  when the entry is deselected another value (determined by the 
  22040.  -offvalue option) is stored in the global variable. An indicator box is 
  22041.  displayed to the left of the label in a checkbutton entry.  If the entry is 
  22042.  selected then the indicator's center is displayed in the color given by the 
  22043.  -selectcolor option for the entry; otherwise the indicator's center is 
  22044.  displayed in the background color for the menu.  If a -command option is 
  22045.  specified for a checkbutton entry, then its value is evaluated as a Tcl 
  22046.  command each time the entry is invoked;  this happens after toggling the 
  22047.  entry's selected state. 
  22048.  
  22049.  RADIOBUTTON ENTRIES 
  22050.  
  22051.  A radiobutton menu entry behaves much like a radiobutton widget. Radiobutton 
  22052.  entries are organized in groups of which only one entry may be selected at a 
  22053.  time.  Whenever a particular entry becomes selected it stores a particular 
  22054.  value into a particular global variable (as determined by the -value and 
  22055.  -variable options for the entry).  This action causes any previously-selected 
  22056.  entry in the same group to deselect itself. Once an entry has become selected, 
  22057.  any change to the entry's associated variable will cause the entry to deselect 
  22058.  itself. Grouping of radiobutton entries is determined by their associated 
  22059.  variables:  if two entries have the same associated variable then they are in 
  22060.  the same group. An indicator diamond is displayed to the left of the label in 
  22061.  each radiobutton entry.  If the entry is selected then the indicator's center 
  22062.  is displayed in the color given by the -selectcolor option for the entry; 
  22063.  otherwise the indicator's center is displayed in the background color for the 
  22064.  menu.  If a -command option is specified for a radiobutton entry, then its 
  22065.  value is evaluated as a Tcl command each time the entry is invoked;  this 
  22066.  happens after selecting the entry. 
  22067.  
  22068.  CASCADE ENTRIES 
  22069.  
  22070.  A cascade entry is one with an associated menu (determined by the -menu 
  22071.  option).  Cascade entries allow the construction of cascading menus. The 
  22072.  postcascade widget command can be used to post and unpost the associated menu 
  22073.  just to the right of the cascade entry. The associated menu must be a child of 
  22074.  the menu containing the cascade entry (this is needed in order for menu 
  22075.  traversal to work correctly). 
  22076.  
  22077.  A cascade entry posts its associated menu by invoking a Tcl command of the 
  22078.  form 
  22079.  
  22080.   menu post x y
  22081.  where menu is the path name of the associated menu, and x and y are the 
  22082.  root-window coordinates of the upper-right corner of the cascade entry. The 
  22083.  lower-level menu is unposted by executing a Tcl command with the form 
  22084.  
  22085.   menu unpost
  22086.  where menu is the name of the associated menu. 
  22087.  
  22088.  If a -command option is specified for a cascade entry then it is evaluated as 
  22089.  a Tcl command whenever the entry is invoked. 
  22090.  
  22091.  TEAR-OFF ENTRIES 
  22092.  
  22093.  A tear-off entry appears at the top of the menu if enabled with the tearOff 
  22094.  option.  It is not like other menu entries in that it cannot be created with 
  22095.  the add widget command and cannot be deleted with the delete widget command. 
  22096.  When a tear-off entry is created it appears as a dashed line at the top of the 
  22097.  menu.  Under the default bindings, invoking the tear-off entry causes a 
  22098.  torn-off copy to be made of the menu and all of its submenus. 
  22099.  
  22100.  WIDGET COMMAND 
  22101.  
  22102.  The menu command creates a new Tcl command whose name is pathName.  This 
  22103.  command may be used to invoke various operations on the widget.  It has the 
  22104.  following general form: 
  22105.  
  22106.   pathName option ?arg arg ...?
  22107.  Option and the args determine the exact behavior of the command. 
  22108.  
  22109.  Many of the widget commands for a menu take as one argument an indicator of 
  22110.  which entry of the menu to operate on.  These indicators are called indexes 
  22111.  and may be specified in any of the following forms: 
  22112.  
  22113.  number    Specifies the entry numerically, where 0 corresponds to the top-most 
  22114.            entry of the menu, 1 to the entry below it, and so on. 
  22115.  
  22116.  active    Indicates the entry that is currently active.  If no entry is active 
  22117.            then this form is equivalent to none.  This form may not be 
  22118.            abbreviated. 
  22119.  
  22120.  end       Indicates the bottommost entry in the menu.  If there are no entries 
  22121.            in the menu then this form is equivalent to none. This form may not 
  22122.            be abbreviated. 
  22123.  
  22124.  last      Same as end. 
  22125.  
  22126.  none      Indicates "no entry at all";  this is used most commonly with the 
  22127.            activate option to deactivate all the entries in the menu.  In most 
  22128.            cases the specification of none causes nothing to happen in the 
  22129.            widget command. This form may not be abbreviated. 
  22130.  
  22131.  @number   In this form, number is treated as a y-coordinate in the menu's 
  22132.            window;  the entry closest to that y-coordinate is used. For 
  22133.            example, "@0" indicates the top-most entry in the window. 
  22134.  
  22135.  pattern   If the index doesn't satisfy one of the above forms then this form 
  22136.            is used.  Pattern is pattern-matched against the label of each entry 
  22137.            in the menu, in order from the top down, until a matching entry is 
  22138.            found.  The rules of Tcl_StringMatch are used. 
  22139.  
  22140.  The following widget commands are possible for menu widgets: 
  22141.  
  22142.  pathName activate index  Change the state of the entry indicated by index to 
  22143.            active and redisplay it using its active colors. Any 
  22144.            previously-active entry is deactivated.  If index is specified as 
  22145.            none, or if the specified entry is disabled, then the menu ends up 
  22146.            with no active entry. Returns an empty string. 
  22147.  
  22148.  pathName add type ?option value option value ...?  Add a new entry to the 
  22149.            bottom of the menu.  The new entry's type is given by type and must 
  22150.            be one of cascade, checkbutton, command, radiobutton, or separator, 
  22151.            or a unique abbreviation of one of the above.  If additional 
  22152.            arguments are present, they specify any of the following options: 
  22153.  
  22154.            -activebackground value  Specifies a background color to use for 
  22155.                           displaying this entry when it is active. If this 
  22156.                           option is specified as an empty string (the default), 
  22157.                           then the activeBackground option for the overall menu 
  22158.                           is used. If the tk_strictMotif variable has been set 
  22159.                           to request strict Motif compliance, then this option 
  22160.                           is ignored and the -background option is used in its 
  22161.                           place. This option is not available for separator or 
  22162.                           tear-off entries. 
  22163.  
  22164.            -activeforeground value  Specifies a foreground color to use for 
  22165.                           displaying this entry when it is active. If this 
  22166.                           option is specified as an empty string (the default), 
  22167.                           then the activeForeground option for the overall menu 
  22168.                           is used. This option is not available for separator 
  22169.                           or tear-off entries. 
  22170.  
  22171.            -accelerator value  Specifies a string to display at the right side 
  22172.                           of the menu entry. Normally describes an accelerator 
  22173.                           keystroke sequence that may be typed to invoke the 
  22174.                           same function as the menu entry.  This option is not 
  22175.                           available for separator or tear-off entries. 
  22176.  
  22177.            -background value  Specifies a background color to use for 
  22178.                           displaying this entry when it is in the normal state 
  22179.                           (neither active nor disabled). If this option is 
  22180.                           specified as an empty string (the default), then the 
  22181.                           background option for the overall menu is used. This 
  22182.                           option is not available for separator or tear-off 
  22183.                           entries. 
  22184.  
  22185.            -bitmap value  Specifies a bitmap to display in the menu instead of 
  22186.                           a textual label, in any of the forms accepted by 
  22187.                           Tk_GetBitmap. This option overrides the -label option 
  22188.                           but may be reset to an empty string to enable a 
  22189.                           textual label to be displayed. If a -image option has 
  22190.                           been specified, it overrides -bitmap. This option is 
  22191.                           not available for separator or tear-off entries. 
  22192.  
  22193.            -command value  Specifies a Tcl command to execute when the menu 
  22194.                           entry is invoked. Not available for separator or 
  22195.                           tear-off entries. 
  22196.  
  22197.            -font value    Specifies the font to use when drawing the label or 
  22198.                           accelerator string in this entry. If this option is 
  22199.                           specified as an empty string (the default) then the 
  22200.                           font option for the overall menu is used. This option 
  22201.                           is not available for separator or tear-off entries. 
  22202.  
  22203.            -foreground value  Specifies a foreground color to use for 
  22204.                           displaying this entry when it is in the normal state 
  22205.                           (neither active nor disabled). If this option is 
  22206.                           specified as an empty string (the default), then the 
  22207.                           foreground option for the overall menu is used. This 
  22208.                           option is not available for separator or tear-off 
  22209.                           entries. 
  22210.  
  22211.            -image value   Specifies an image to display in the menu instead of 
  22212.                           a text string or bitmap The image must have been 
  22213.                           created by some previous invocation of image create. 
  22214.                           This option overrides the -label and -bitmap options 
  22215.                           but may be reset to an empty string to enable a 
  22216.                           textual or bitmap label to be displayed. This option 
  22217.                           is not available for separator or tear-off entries. 
  22218.  
  22219.            -indicatoron value  Available only for checkbutton and radiobutton 
  22220.                           entries. Value is a boolean that determines whether 
  22221.                           or not the indicator should be displayed. 
  22222.  
  22223.            -label value   Specifies a string to display as an identifying label 
  22224.                           in the menu entry.  Not available for separator or 
  22225.                           tear-off entries. 
  22226.  
  22227.            -menu value    Available only for cascade entries.  Specifies the 
  22228.                           path name of the submenu associated with this entry. 
  22229.                           The submenu must be a child of the menu. 
  22230.  
  22231.            -offvalue value  Available only for checkbutton entries.  Specifies 
  22232.                           the value to store in the entry's associated variable 
  22233.                           when the entry is deselected. 
  22234.  
  22235.            -onvalue value  Available only for checkbutton entries.  Specifies 
  22236.                           the value to store in the entry's associated variable 
  22237.                           when the entry is selected. 
  22238.  
  22239.            -selectcolor value  Available only for checkbutton and radiobutton 
  22240.                           entries. Specifies the color to display in the 
  22241.                           indicator when the entry is selected. If the value is 
  22242.                           an empty string (the default) then the selectColor 
  22243.                           option for the menu determines the indicator color. 
  22244.  
  22245.            -selectimage value  Available only for checkbutton and radiobutton 
  22246.                           entries. Specifies an image to display in the entry 
  22247.                           (in place of the -image option) when it is selected. 
  22248.                           Value is the name of an image, which must have been 
  22249.                           created by some previous invocation of image create. 
  22250.                           This option is ignored unless the -image option has 
  22251.                           been specified. 
  22252.  
  22253.            -state value   Specifies one of three states for the entry:  normal, 
  22254.                           active, or disabled.  In normal state the entry is 
  22255.                           displayed using the foreground option for the menu 
  22256.                           and the background option from the entry or the menu. 
  22257.                           The active state is typically used when the pointer 
  22258.                           is over the entry. In active state the entry is 
  22259.                           displayed using the activeForeground option for the 
  22260.                           menu along with the activebackground option from the 
  22261.                           entry.  Disabled state means that the entry should be 
  22262.                           insensitive:  the default bindings will refuse to 
  22263.                           activate or invoke the entry. In this state the entry 
  22264.                           is displayed according to the disabledForeground 
  22265.                           option for the menu and the background option from 
  22266.                           the entry. This option is not available for separator 
  22267.                           entries. 
  22268.  
  22269.            -underline value  Specifies the integer index of a character to 
  22270.                           underline in the entry. This option is also queried 
  22271.                           by the default bindings and used to implement 
  22272.                           keyboard traversal. 0 corresponds to the first 
  22273.                           character of the text displayed in the entry, 1 to 
  22274.                           the next character, and so on. If a bitmap or image 
  22275.                           is displayed in the entry then this option is 
  22276.                           ignored. This option is not available for separator 
  22277.                           or tear-off entries. 
  22278.  
  22279.            -value value   Available only for radiobutton entries.  Specifies 
  22280.                           the value to store in the entry's associated variable 
  22281.                           when the entry is selected. If an empty string is 
  22282.                           specified, then the -label option for the entry as 
  22283.                           the value to store in the variable. 
  22284.  
  22285.            -variable value  Available only for checkbutton and radiobutton 
  22286.                           entries.  Specifies the name of a global value to set 
  22287.                           when the entry is selected. For checkbutton entries 
  22288.                           the variable is also set when the entry is 
  22289.                           deselected.  For radiobutton entries, changing the 
  22290.                           variable causes the currently-selected entry to 
  22291.                           deselect itself. 
  22292.  
  22293.            The add widget command returns an empty string. 
  22294.  
  22295.  pathName cget option  Returns the current value of the configuration option 
  22296.            given by option. Option may have any of the values accepted by the 
  22297.            menu command. 
  22298.  
  22299.  pathName configure ?option? ?value option value ...?  Query or modify the 
  22300.            configuration options of the widget. If no option is specified, 
  22301.            returns a list describing all of the available options for pathName 
  22302.            (see Tk_ConfigureInfo for information on the format of this list). 
  22303.            If option is specified with no value, then the command returns a 
  22304.            list describing the one named option (this list will be identical to 
  22305.            the corresponding sublist of the value returned if no option is 
  22306.            specified).  If one or more option-value pairs are specified, then 
  22307.            the command modifies the given widget option(s) to have the given 
  22308.            value(s);  in this case the command returns an empty string. Option 
  22309.            may have any of the values accepted by the menu command. 
  22310.  
  22311.  pathName delete index1 ?index2?  Delete all of the menu entries between index1 
  22312.            and index2 inclusive. If index2 is omitted then it defaults to 
  22313.            index1. Attempts to delete a tear-off menu entry are ignored 
  22314.            (instead, you should change the tearOff option to remove the 
  22315.            tear-off entry). 
  22316.  
  22317.  pathName entrycget index option  Returns the current value of a configuration 
  22318.            option for the entry given by index. Option may have any of the 
  22319.            values accepted by the add widget command. 
  22320.  
  22321.  pathName entryconfigure index ?options?  This command is similar to the 
  22322.            configure command, except that it applies to the options for an 
  22323.            individual entry, whereas configure applies to the options for the 
  22324.            menu as a whole. Options may have any of the values accepted by the 
  22325.            add widget command.  If options are specified, options are modified 
  22326.            as indicated in the command and the command returns an empty string. 
  22327.            If no options are specified, returns a list describing the current 
  22328.            options for entry index (see Tk_ConfigureInfo for information on the 
  22329.            format of this list). 
  22330.  
  22331.  pathName index index  Returns the numerical index corresponding to index, or 
  22332.            none if index was specified as none. 
  22333.  
  22334.  pathName insert index type ?option value option value ...?  Same as the add 
  22335.            widget command except that it inserts the new entry just before the 
  22336.            entry given by index, instead of appending to the end of the menu. 
  22337.            The type, option, and value arguments have the same interpretation 
  22338.            as for the add widget command.  It is not possible to insert new 
  22339.            menu entries before the tear-off entry, if the menu has one. 
  22340.  
  22341.  pathName invoke index  Invoke the action of the menu entry.  See the sections 
  22342.            on the individual entries above for details on what happens.  If the 
  22343.            menu entry is disabled then nothing happens.  If the entry has a 
  22344.            command associated with it then the result of that command is 
  22345.            returned as the result of the invoke widget command.  Otherwise the 
  22346.            result is an empty string.  Note:  invoking a menu entry does not 
  22347.            automatically unpost the menu;  the default bindings normally take 
  22348.            care of this before invoking the invoke widget command. 
  22349.  
  22350.  pathName post x y  Arrange for the menu to be displayed on the screen at the 
  22351.            root-window coordinates given by x and y.  These coordinates are 
  22352.            adjusted if necessary to guarantee that the entire menu is visible 
  22353.            on the screen.  This command normally returns an empty string. If 
  22354.            the postCommand option has been specified, then its value is 
  22355.            executed as a Tcl script before posting the menu and the result of 
  22356.            that script is returned as the result of the post widget command. If 
  22357.            an error returns while executing the command, then the error is 
  22358.            returned without posting the menu. 
  22359.  
  22360.  pathName postcascade index  Posts the submenu associated with the cascade 
  22361.            entry given by index, and unposts any previously posted submenu. If 
  22362.            index doesn't correspond to a cascade entry, or if pathName isn't 
  22363.            posted, the command has no effect except to unpost any currently 
  22364.            posted submenu. 
  22365.  
  22366.  pathName type index  Returns the type of the menu entry given by index. This 
  22367.            is the type argument passed to the add widget command when the entry 
  22368.            was created, such as command or separator, or tearoff for a tear-off 
  22369.            entry. 
  22370.  
  22371.  pathName unpost  Unmap the window so that it is no longer displayed.  If a 
  22372.            lower-level cascaded menu is posted, unpost that menu.  Returns an 
  22373.            empty string. 
  22374.  
  22375.  pathName yposition index  Returns a decimal string giving the y-coordinate 
  22376.            within the menu window of the topmost pixel in the entry specified 
  22377.            by index. 
  22378.  
  22379.  MENU CONFIGURATIONS 
  22380.  
  22381.  The default bindings support four different ways of using menus: 
  22382.  
  22383.  Pulldown Menus  This is the most common case.  You create one menubutton 
  22384.            widget for each top-level menu, and typically you arrange a series 
  22385.            of menubuttons in a row in a menubar window.  You also create the 
  22386.            top-level menus and any cascaded submenus, and tie them together 
  22387.            with -menu options in menubuttons and cascade menu entries.  The 
  22388.            top-level menu must be a child of the menubutton, and each submenu 
  22389.            must be a child of the menu that refers to it.  Once you have done 
  22390.            this, the default bindings will allow users to traverse and invoke 
  22391.            the tree of menus via its menubutton;  see the menubutton manual 
  22392.            entry for details. 
  22393.  
  22394.  Popup Menus  Popup menus typically post in response to a mouse button press or 
  22395.            keystroke.  You create the popup menus and any cascaded submenus, 
  22396.            then you call the tk_popup procedure at the appropriate time to post 
  22397.            the top-level menu. 
  22398.  
  22399.  Option Menus  An option menu consists of a menubutton with an associated menu 
  22400.            that allows you to select one of several values.  The current value 
  22401.            is displayed in the menubutton and is also stored in a global 
  22402.            variable.  Use the tk_optionMenu procedure to create option 
  22403.            menubuttons and their menus. 
  22404.  
  22405.  Torn-off Menus  You create a torn-off menu by invoking the tear-off entry at 
  22406.            the top of an existing menu.  The default bindings will create a new 
  22407.            menu that is a copy of the original menu and leave it permanently 
  22408.            posted as a top-level window.  The torn-off menu behaves just the 
  22409.            same as the original menu. 
  22410.  
  22411.  DEFAULT BINDINGS 
  22412.  
  22413.  Tk automatically creates class bindings for menus that give them the following 
  22414.  default behavior: 
  22415.  
  22416.    1. When the mouse enters a menu, the entry underneath the mouse cursor 
  22417.       activates;  as the mouse moves around the menu, the active entry changes 
  22418.       to track the mouse. 
  22419.  
  22420.    2. When the mouse leaves a menu all of the entries in the menu deactivate, 
  22421.       except in the special case where the mouse moves from a menu to a 
  22422.       cascaded submenu. 
  22423.  
  22424.    3. When a button is released over a menu, the active entry (if any) is 
  22425.       invoked. The menu also unposts unless it is a torn-off menu. 
  22426.  
  22427.    4. The Space and Return keys invoke the active entry and unpost the menu. 
  22428.  
  22429.    5. If any of the entries in a menu have letters underlined with with 
  22430.       -underline option, then pressing one of the underlined letters (or its 
  22431.       upper-case or lower-case equivalent) invokes that entry and unposts the 
  22432.       menu. 
  22433.  
  22434.    6. The Escape key aborts a menu selection in progress without invoking any 
  22435.       entry.  It also unposts the menu unless it is a torn-off menu. 
  22436.  
  22437.    7. The Up and Down keys activate the next higher or lower entry in the menu. 
  22438.       When one end of the menu is reached, the active entry wraps around to the 
  22439.       other end. 
  22440.  
  22441.    8. The Left key moves to the next menu to the left. If the current menu is a 
  22442.       cascaded submenu, then the submenu is unposted and the current menu entry 
  22443.       becomes the cascade entry in the parent. If the current menu is a 
  22444.       top-level menu posted from a menubutton, then the current menubutton is 
  22445.       unposted and the next menubutton to the left is posted. Otherwise the key 
  22446.       has no effect. The left-right order of menubuttons is determined by their 
  22447.       stacking order:  Tk assumes that the lowest menubutton (which by default 
  22448.       is the first one created) is on the left. 
  22449.  
  22450.    9. The Right key moves to the next menu to the right. If the current entry 
  22451.       is a cascade entry, then the submenu is posted and the  current menu 
  22452.       entry becomes the first entry in the submenu. Otherwise, if the current 
  22453.       menu was posted from a menubutton, then the current menubutton is 
  22454.       unposted and the next menubutton to the right is posted. 
  22455.  
  22456.  Disabled menu entries are non-responsive:  they don't activate and they ignore 
  22457.  mouse button presses and releases. 
  22458.  
  22459.  The behavior of menus can be changed by defining new bindings for individual 
  22460.  widgets or by redefining the class bindings. 
  22461.  
  22462.  BUGS 
  22463.  
  22464.  At present it isn't possible to use the option database to specify values for 
  22465.  the options to individual entries. 
  22466.  
  22467.  KEYWORDS 
  22468.  
  22469.  menu, widget 
  22470.  
  22471.  
  22472. ΓòÉΓòÉΓòÉ 6.25. tk_menuBar ΓòÉΓòÉΓòÉ
  22473.  
  22474.  NAME 
  22475.  
  22476. tk_menuBar, tk_bindForTraversal - Obsolete support for menu bars 
  22477.  
  22478. SYNOPSIS 
  22479.  
  22480. tk_menuBar frame ?menu menu ...? 
  22481.  tk_bindForTraversal arg arg ... 
  22482.  
  22483. DESCRIPTION 
  22484.  
  22485. These procedures were used in Tk 3.6 and earlier releases to help manage 
  22486. pulldown menus and to implement keyboard traversal of menus. In Tk 4.0 and 
  22487. later releases they are no longer needed.  Stubs for these procedures have been 
  22488. retained for backward compatibility, but they have no effect.  You should 
  22489. remove calls to these procedures from your code, since eventually the 
  22490. procedures will go away. 
  22491.  
  22492. KEYWORDS 
  22493.  
  22494. keyboard traversal, menu, menu bar, post 
  22495.  
  22496.  
  22497. ΓòÉΓòÉΓòÉ 6.26. menubutton ΓòÉΓòÉΓòÉ
  22498.  
  22499.  NAME 
  22500.  
  22501. menubutton - Create and manipulate menubutton widgets 
  22502.  
  22503. SYNOPSIS 
  22504.  
  22505. menubutton pathName ?options? 
  22506.  
  22507. STANDARD OPTIONS 
  22508.  
  22509. -activebackground    -cursor              -highlightthickness  -takefocus
  22510. -activeforeground    -disabledforeground  -image               -text
  22511. -anchor              -font                -justify             -textvariable
  22512. -background          -foreground          -padx                -underline
  22513. -bitmap              -highlightbackground -pady                -wraplength
  22514. -borderwidth         -highlightcolor      -relief
  22515.  
  22516. See the options manual entry for detailed descriptions of the above options.
  22517.  
  22518. WIDGET-SPECIFIC OPTIONS 
  22519.  
  22520.   Command-Line Name:    -height
  22521.   Database Name:        height
  22522.   Database Class:       Height
  22523.  
  22524.            Specifies a desired height for the menubutton. If an image or bitmap 
  22525.            is being displayed in the menubutton then the value is in screen 
  22526.            units (i.e. any of the forms acceptable to Tk_GetPixels); for text 
  22527.            it is in lines of text. If this option isn't specified, the 
  22528.            menubutton's desired height is computed from the size of the image 
  22529.            or bitmap or text being displayed in it. 
  22530.  
  22531.   Command-Line Name:    -indicatoron
  22532.   Database Name:        indicatorOn
  22533.   Database Class:       IndicatorOn
  22534.  
  22535.            The value must be a proper boolean value.  If it is true then a 
  22536.            small indicator rectangle will be displayed on the right side of the 
  22537.            menubutton and the default menu bindings will treat this as an 
  22538.            option menubutton.  If false then no indicator will be displayed. 
  22539.  
  22540.   Command-Line Name:    -menu
  22541.   Database Name:        menu
  22542.   Database Class:       MenuName
  22543.  
  22544.            Specifies the path name of the menu associated with this menubutton. 
  22545.            The menu must be a child of the menubutton. 
  22546.  
  22547.   Command-Line Name:    -state
  22548.   Database Name:        state
  22549.   Database Class:       State
  22550.  
  22551.            Specifies one of three states for the menubutton:  normal, active, 
  22552.            or disabled.  In normal state the menubutton is displayed using the 
  22553.            foreground and background options.  The active state is typically 
  22554.            used when the pointer is over the menubutton.  In active state the 
  22555.            menubutton is displayed using the activeForeground and 
  22556.            activeBackground options.  Disabled state means that the menubutton 
  22557.            should be insensitive:  the default bindings will refuse to activate 
  22558.            the widget and will ignore mouse button presses. In this state the 
  22559.            disabledForeground and background options determine how the button 
  22560.            is displayed. 
  22561.  
  22562.   Command-Line Name:    -width
  22563.   Database Name:        width
  22564.   Database Class:       Width
  22565.  
  22566.            Specifies a desired width for the menubutton. If an image or bitmap 
  22567.            is being displayed in the menubutton then the value is in screen 
  22568.            units (i.e. any of the forms acceptable to Tk_GetPixels); for text 
  22569.            it is in characters. If this option isn't specified, the 
  22570.            menubutton's desired width is computed from the size of the image or 
  22571.            bitmap or text being displayed in it. 
  22572.  
  22573.  INTRODUCTION 
  22574.  
  22575.  The menubutton command creates a new window (given by the pathName argument) 
  22576.  and makes it into a menubutton widget. Additional options, described above, 
  22577.  may be specified on the command line or in the option database to configure 
  22578.  aspects of the menubutton such as its colors, font, text, and initial relief. 
  22579.  The menubutton command returns its pathName argument.  At the time this 
  22580.  command is invoked, there must not exist a window named pathName, but 
  22581.  pathName's parent must exist. 
  22582.  
  22583.  A menubutton is a widget that displays a textual string, bitmap, or image and 
  22584.  is associated with a menu widget. If text is displayed, it must all be in a 
  22585.  single font, but it can occupy multiple lines on the screen (if it contains 
  22586.  newlines or if wrapping occurs because of the wrapLength option) and one of 
  22587.  the characters may optionally be underlined using the underline option.  In 
  22588.  normal usage, pressing mouse button 1 over the menubutton causes the 
  22589.  associated menu to be posted just underneath the menubutton.  If the mouse is 
  22590.  moved over the menu before releasing the mouse button, the button release 
  22591.  causes the underlying menu entry to be invoked.  When the button is released, 
  22592.  the menu is unposted. 
  22593.  
  22594.  Menubuttons are typically organized into groups called menu bars that allow 
  22595.  scanning: if the mouse button is pressed over one menubutton (causing it to 
  22596.  post its menu) and the mouse is moved over another menubutton in the same menu 
  22597.  bar without releasing the mouse button, then the menu of the first menubutton 
  22598.  is unposted and the menu of the new menubutton is posted instead. 
  22599.  
  22600.  There are several interactions between menubuttons and menus;  see the menu 
  22601.  manual entry for information on various menu configurations, such as pulldown 
  22602.  menus and option menus. 
  22603.  
  22604.  WIDGET COMMAND 
  22605.  
  22606.  The menubutton command creates a new Tcl command whose name is pathName.  This 
  22607.  command may be used to invoke various operations on the widget.  It has the 
  22608.  following general form: 
  22609.  
  22610.   pathName option ?arg arg ...?
  22611.  Option and the args determine the exact behavior of the command.  The 
  22612.  following commands are possible for menubutton widgets: 
  22613.  
  22614.  pathName cget option  Returns the current value of the configuration option 
  22615.            given by option. Option may have any of the values accepted by the 
  22616.            menubutton command. 
  22617.  
  22618.  pathName configure ?option? ?value option value ...?  Query or modify the 
  22619.            configuration options of the widget. If no option is specified, 
  22620.            returns a list describing all of the available options for pathName 
  22621.            (see Tk_ConfigureInfo for information on the format of this list). 
  22622.            If option is specified with no value, then the command returns a 
  22623.            list describing the one named option (this list will be identical to 
  22624.            the corresponding sublist of the value returned if no option is 
  22625.            specified).  If one or more option-value pairs are specified, then 
  22626.            the command modifies the given widget option(s) to have the given 
  22627.            value(s);  in this case the command returns an empty string. Option 
  22628.            may have any of the values accepted by the menubutton command. 
  22629.  
  22630.  DEFAULT BINDINGS 
  22631.  
  22632.  Tk automatically creates class bindings for menubuttons that give them the 
  22633.  following default behavior: 
  22634.  
  22635.    1. A menubutton activates whenever the mouse passes over it and deactivates 
  22636.       whenever the mouse leaves it. 
  22637.  
  22638.    2. Pressing mouse button 1 over a menubutton posts the menubutton: its 
  22639.       relief changes to raised and its associated menu is posted under the 
  22640.       menubutton.  If the mouse is dragged down into the menu with the button 
  22641.       still down, and if the mouse button is then released over an entry in the 
  22642.       menu, the menubutton is unposted and the menu entry is invoked. 
  22643.  
  22644.    3. If button 1 is pressed over a menubutton and then released over that 
  22645.       menubutton, the menubutton stays posted: you can still move the mouse 
  22646.       over the menu and click button 1 on an entry to invoke it. Once a menu 
  22647.       entry has been invoked, the menubutton unposts itself. 
  22648.  
  22649.    4. If button 1 is pressed over a menubutton and then dragged over some other 
  22650.       menubutton, the original menubutton unposts itself and the new menubutton 
  22651.       posts. 
  22652.  
  22653.    5. If button 1 is pressed over a menubutton and released outside any 
  22654.       menubutton or menu, the menubutton unposts without invoking any menu 
  22655.       entry. 
  22656.  
  22657.    6. When a menubutton is posted, its associated menu claims the input focus 
  22658.       to allow keyboard traversal of the menu and its submenus. See the menu 
  22659.       manual entry for details on these bindings. 
  22660.  
  22661.    7. If the underline option has been specified for a menubutton then keyboard 
  22662.       traversal may be used to post the menubutton: Alt+x, where x is the 
  22663.       underlined character (or its lower-case or upper-case equivalent), may be 
  22664.       typed in any window under the menubutton's toplevel to post the 
  22665.       menubutton. 
  22666.  
  22667.    8. The F10 key may be typed in any window to post the first menubutton under 
  22668.       its toplevel window that isn't disabled. 
  22669.  
  22670.    9. If a menubutton has the input focus, the space and return keys post the 
  22671.       menubutton. 
  22672.  
  22673.  If the menubutton's state is disabled then none of the above actions occur: 
  22674.  the menubutton is completely non-responsive. 
  22675.  
  22676.  The behavior of menubuttons can be changed by defining new bindings for 
  22677.  individual widgets or by redefining the class bindings. 
  22678.  
  22679.  KEYWORDS 
  22680.  
  22681.  menubutton, widget 
  22682.  
  22683.  
  22684. ΓòÉΓòÉΓòÉ 6.27. message ΓòÉΓòÉΓòÉ
  22685.  
  22686.  NAME 
  22687.  
  22688. message - Create and manipulate message widgets 
  22689.  
  22690. SYNOPSIS 
  22691.  
  22692. message pathName ?options? 
  22693.  
  22694. STANDARD OPTIONS 
  22695.  
  22696. -anchor              -font                -highlightthickness  -takefocus
  22697. -background          -foreground          -padx                -text
  22698. -borderwidth         -highlightbackground -pady                -textvariable
  22699. -cursor              -highlightcolor      -relief              -width
  22700.  
  22701. See the options manual entry for detailed descriptions of the above options.
  22702.  
  22703. WIDGET-SPECIFIC OPTIONS 
  22704.  
  22705.   Command-Line Name:    -aspect
  22706.   Database Name:        aspect
  22707.   Database Class:       Aspect
  22708.  
  22709.            Specifies a non-negative integer value indicating desired aspect 
  22710.            ratio for the text.  The aspect ratio is specified as 
  22711.            100*width/height.  100 means the text should be as wide as it is 
  22712.            tall, 200 means the text should be twice as wide as it is tall, 50 
  22713.            means the text should be twice as tall as it is wide, and so on. 
  22714.            Used to choose line length for text if width option isn't specified. 
  22715.            Defaults to 150. 
  22716.  
  22717.   Command-Line Name:    -justify
  22718.   Database Name:        justify
  22719.   Database Class:       Justify
  22720.  
  22721.            Specifies how to justify lines of text. Must be one of left, center, 
  22722.            or right.  Defaults to left. This option works together with the 
  22723.            anchor, aspect, padX, padY, and width options to provide a variety 
  22724.            of arrangements of the text within the window. The aspect and width 
  22725.            options determine the amount of screen space needed to display the 
  22726.            text. The anchor, padX, and padY options determine where this 
  22727.            rectangular area is displayed within the widget's window, and the 
  22728.            justify option determines how each line is displayed within that 
  22729.            rectangular region. For example, suppose anchor is e and justify is 
  22730.            left, and that the message window is much larger than needed for the 
  22731.            text. The the text will displayed so that the left edges of all the 
  22732.            lines line up and the right edge of the longest line is padX from 
  22733.            the right side of the window;  the entire text block will be 
  22734.            centered in the vertical span of the window. 
  22735.  
  22736.   Command-Line Name:    -width
  22737.   Database Name:        width
  22738.   Database Class:       Width
  22739.  
  22740.            Specifies the length of lines in the window. The value may have any 
  22741.            of the forms acceptable to Tk_GetPixels. If this option has a value 
  22742.            greater than zero then the aspect option is ignored and the width 
  22743.            option determines the line length. If this option has a value less 
  22744.            than or equal to zero, then the aspect option determines the line 
  22745.            length. 
  22746.  
  22747.  DESCRIPTION 
  22748.  
  22749.  The message command creates a new window (given by the pathName argument) and 
  22750.  makes it into a message widget. Additional options, described above, may be 
  22751.  specified on the command line or in the option database to configure aspects 
  22752.  of the message such as its colors, font, text, and initial relief.  The 
  22753.  message command returns its pathName argument.  At the time this command is 
  22754.  invoked, there must not exist a window named pathName, but pathName's parent 
  22755.  must exist. 
  22756.  
  22757.  A message is a widget that displays a textual string.  A message widget has 
  22758.  three special features.  First, it breaks up its string into lines in order to 
  22759.  produce a given aspect ratio for the window.  The line breaks are chosen at 
  22760.  word boundaries wherever possible (if not even a single word would fit on a 
  22761.  line, then the word will be split across lines).  Newline characters in the 
  22762.  string will force line breaks;  they can be used, for example, to leave blank 
  22763.  lines in the display. 
  22764.  
  22765.  The second feature of a message widget is justification.  The text may be 
  22766.  displayed left-justified (each line starts at the left side of the window), 
  22767.  centered on a line-by-line basis, or right-justified (each line ends at the 
  22768.  right side of the window). 
  22769.  
  22770.  The third feature of a message widget is that it handles control characters 
  22771.  and non-printing characters specially.  Tab characters are replaced with 
  22772.  enough blank space to line up on the next 8-character boundary.  Newlines 
  22773.  cause line breaks.  Other control characters (ASCII code less than 0x20) and 
  22774.  characters not defined in the font are displayed as a four-character sequence 
  22775.  \xhh where hh is the two-digit hexadecimal number corresponding to the 
  22776.  character.  In the unusual case where the font doesn't contain all of the 
  22777.  characters in "0123456789abcdef\x" then control characters and undefined 
  22778.  characters are not displayed at all. 
  22779.  
  22780.  WIDGET COMMAND 
  22781.  
  22782.  The message command creates a new Tcl command whose name is pathName.  This 
  22783.  command may be used to invoke various operations on the widget.  It has the 
  22784.  following general form: 
  22785.  
  22786.   pathName option ?arg arg ...?
  22787.  Option and the args determine the exact behavior of the command.  The 
  22788.  following commands are possible for message widgets: 
  22789.  
  22790.  pathName cget option  Returns the current value of the configuration option 
  22791.            given by option. Option may have any of the values accepted by the 
  22792.            message command. 
  22793.  
  22794.  pathName configure ?option? ?value option value ...?  Query or modify the 
  22795.            configuration options of the widget. If no option is specified, 
  22796.            returns a list describing all of the available options for pathName 
  22797.            (see Tk_ConfigureInfo for information on the format of this list). 
  22798.            If option is specified with no value, then the command returns a 
  22799.            list describing the one named option (this list will be identical to 
  22800.            the corresponding sublist of the value returned if no option is 
  22801.            specified).  If one or more option-value pairs are specified, then 
  22802.            the command modifies the given widget option(s) to have the given 
  22803.            value(s);  in this case the command returns an empty string. Option 
  22804.            may have any of the values accepted by the message command. 
  22805.  
  22806.  DEFAULT BINDINGS 
  22807.  
  22808.  When a new message is created, it has no default event bindings: messages are 
  22809.  intended for output purposes only. 
  22810.  
  22811.  BUGS 
  22812.  
  22813.  Tabs don't work very well with text that is centered or right-justified. The 
  22814.  most common result is that the line is justified wrong. 
  22815.  
  22816.  KEYWORDS 
  22817.  
  22818.  message, widget 
  22819.  
  22820.  
  22821. ΓòÉΓòÉΓòÉ 6.28. tk_messageBox ΓòÉΓòÉΓòÉ
  22822.  
  22823.  NAME 
  22824.  
  22825. tk_messageBox - pops up a message window and waits for user response. 
  22826.  
  22827. SYNOPSIS 
  22828.  
  22829. tk_messageBox ?option value ...? 
  22830.  
  22831. DESCRIPTION 
  22832.  
  22833. This procedure creates and displays a message window with an 
  22834. application-specified message, an icon and a set of buttons.  Each of the 
  22835. buttons in the message window is identified by a unique symbolic name (see the 
  22836. -type options).  After the message window is popped up, tk_messageBox waits for 
  22837. the user to select one of the buttons. Then it returns the symbolic name of the 
  22838. selected button.  The following option-value pairs are supported: 
  22839.  
  22840.  -default name  Name gives the symbolic name of the default button for this 
  22841.            message window ('ok', 'cancel', and so on). See -type for a list of 
  22842.            the symbolic names.  If the message box has just one button it will 
  22843.            automatically be made the default, otherwise if this option is not 
  22844.            specified, there won't be any default button. 
  22845.  
  22846.  -icon iconImage  Specifies an icon to display. IconImage must be one of the 
  22847.            following: error, info, question or warning. If this option is not 
  22848.            specified, then no icon will be displayed. 
  22849.  
  22850.  -message string  Specifies the message to display in this message box. 
  22851.  
  22852.  -parent window  Makes window the logical parent of the message box. The 
  22853.            message box is displayed on top of its parent window. 
  22854.  
  22855.  -title titleString  Specifies a string to display as the title of the message 
  22856.            box. The default value is an empty string. 
  22857.  
  22858.  -type predefinedType  Arranges for a predefined set of buttons to be 
  22859.            displayed. The following values are possible for predefinedType: 
  22860.  
  22861.            abortretryignore  Displays three buttons whose symbolic names are 
  22862.                           abort, retry and ignore. 
  22863.  
  22864.            ok             Displays one button whose symbolic name is ok. 
  22865.  
  22866.            okcancel       Displays two buttons whose symbolic names are ok and 
  22867.                           cancel. 
  22868.  
  22869.            retrycancel    Displays two buttons whose symbolic names are retry 
  22870.                           and cancel. 
  22871.  
  22872.            yesno          Displays two buttons whose symbolic names are yes and 
  22873.                           no. 
  22874.  
  22875.            yesnocancel    Displays three buttons whose symbolic names are yes, 
  22876.                           no and cancel. 
  22877.  
  22878.  EXAMPLE 
  22879.  
  22880.   set answer [tk_messageBox -message "Really quit?" -type yesno -icon question]
  22881.   case $answer {
  22882.       yes exit
  22883.       no {tk_messageBox -message "I know you like this application!" -type ok}
  22884.   }
  22885.  
  22886.  KEYWORDS 
  22887.  
  22888.  message box 
  22889.  
  22890.  
  22891. ΓòÉΓòÉΓòÉ 6.29. option ΓòÉΓòÉΓòÉ
  22892.  
  22893.  NAME 
  22894.  
  22895. option - Add/retrieve window options to/from the option database 
  22896.  
  22897. SYNOPSIS 
  22898.  
  22899. option add pattern value ?priority? 
  22900.  option clear 
  22901.  option get window name class 
  22902.  option readfile fileName ?priority? 
  22903.  
  22904. DESCRIPTION 
  22905.  
  22906. The option command allows you to add entries to the Tk option database or to 
  22907. retrieve options from the database.  The add form of the command adds a new 
  22908. option to the database. Pattern contains the option being specified, and 
  22909. consists of names and/or classes separated by asterisks or dots, in the usual X 
  22910. format.  Value contains a text string to associate with pattern;  this is the 
  22911. value that will be returned in calls to Tk_GetOption or by invocations of the 
  22912. option get command.  If priority is specified, it indicates the priority level 
  22913. for this option (see below for legal values);  it defaults to interactive. This 
  22914. command always returns an empty string. 
  22915.  
  22916. The option clear command clears the option database.  Default options (from the 
  22917. RESOURCE_MANAGER property or the .Xdefaults file) will be reloaded 
  22918. automatically the next time an option is added to the database or removed from 
  22919. it.  This command always returns an empty string. 
  22920.  
  22921. The option get command returns the value of the option specified for window 
  22922. under name and class.  If several entries in the option database match window, 
  22923. name, and class, then the command returns whichever was created with highest 
  22924. priority level.  If there are several matching entries at the same priority 
  22925. level, then it returns whichever entry was most recently entered into the 
  22926. option database.  If there are no matching entries, then the empty string is 
  22927. returned. 
  22928.  
  22929. The readfile form of the command reads fileName, which should have the standard 
  22930. format for an X resource database such as .Xdefaults, and adds all the options 
  22931. specified in that file to the option database.  If priority is specified, it 
  22932. indicates the priority level at which to enter the options;  priority defaults 
  22933. to interactive. 
  22934.  
  22935. The priority arguments to the option command are normally specified 
  22936. symbolically using one of the following values: 
  22937.  
  22938.  widgetDefault  Level 20.  Used for default values hard-coded into widgets. 
  22939.  
  22940.  startupFile  Level 40.  Used for options specified in application-specific 
  22941.            startup files. 
  22942.  
  22943.  userDefault  Level 60.  Used for options specified in user-specific defaults 
  22944.            files, such as .Xdefaults, resource databases loaded into the X 
  22945.            server, or user-specific startup files. 
  22946.  
  22947.  interactive  Level 80.  Used for options specified interactively after the 
  22948.            application starts running.  If priority isn't specified, it 
  22949.            defaults to this level. 
  22950.  
  22951.  Any of the above keywords may be abbreviated.  In addition, priorities may be 
  22952.  specified numerically using integers between 0 and 100, inclusive.  The 
  22953.  numeric form is probably a bad idea except for new priority levels other than 
  22954.  the ones given above. 
  22955.  
  22956.  KEYWORDS 
  22957.  
  22958.  database, option, priority, retrieve 
  22959.  
  22960.  
  22961. ΓòÉΓòÉΓòÉ 6.30. tk_optionMenu ΓòÉΓòÉΓòÉ
  22962.  
  22963.  NAME 
  22964.  
  22965. tk_optionMenu - Create an option menubutton and its menu 
  22966.  
  22967. SYNOPSIS 
  22968.  
  22969. tk_optionMenu w varName value ?value value ...? 
  22970.  
  22971. DESCRIPTION 
  22972.  
  22973. This procedure creates an option menubutton whose name is w, plus an associated 
  22974. menu. Together they allow the user to select one of the values given by the 
  22975. value arguments. The current value will be stored in the global variable whose 
  22976. name is given by varName and it will also be displayed as the label in the 
  22977. option menubutton. The user can click on the menubutton to display a menu 
  22978. containing all of the values and thereby select a new value. Once a new value 
  22979. is selected, it will be stored in the variable and appear in the option 
  22980. menubutton. The current value can also be changed by setting the variable. 
  22981.  
  22982. The return value from tk_optionMenu is the name of the menu associated with w, 
  22983. so that the caller can change its configuration options or manipulate it in 
  22984. other ways. 
  22985.  
  22986. KEYWORDS 
  22987.  
  22988. option menu 
  22989.  
  22990.  
  22991. ΓòÉΓòÉΓòÉ 6.31. options ΓòÉΓòÉΓòÉ
  22992.  
  22993.  NAME 
  22994.  
  22995. options - Standard options supported by widgets 
  22996.  
  22997. DESCRIPTION 
  22998.  
  22999. This manual entry describes the common configuration options supported by 
  23000. widgets in the Tk toolkit.  Every widget does not necessarily support every 
  23001. option (see the manual entries for individual widgets for a list of the 
  23002. standard options supported by that widget), but if a widget does support an 
  23003. option with one of the names listed below, then the option has exactly the 
  23004. effect described below. 
  23005.  
  23006. In the descriptions below, "Command-Line Name" refers to the switch used in 
  23007. class commands and configure widget commands to set this value.  For example, 
  23008. if an option's command-line switch is -foreground and there exists a widget 
  23009. .a.b.c, then the command 
  23010.  
  23011. .a.b.c  configure  -foreground black
  23012. may be used to specify the value black for the option in the the widget .a.b.c. 
  23013. Command-line switches may be abbreviated, as long as the abbreviation is 
  23014. unambiguous. "Database Name" refers to the option's name in the option database 
  23015. (e.g. in .Xdefaults files).  "Database Class" refers to the option's class 
  23016. value in the option database. 
  23017.  
  23018.   Command-Line Name:    -activebackground
  23019.   Database Name:        activeBackground
  23020.   Database Class:       Foreground
  23021.  
  23022.            Specifies background color to use when drawing active elements. An 
  23023.            element (a widget or portion of a widget) is active if the mouse 
  23024.            cursor is positioned over the element and pressing a mouse button 
  23025.            will cause some action to occur. If strict Motif compliance has been 
  23026.            requested by setting the tk_strictMotif variable, this option will 
  23027.            normally be ignored;  the normal background color will be used 
  23028.            instead. 
  23029.  
  23030.   Command-Line Name:    -activeborderwidth
  23031.   Database Name:        activeBorderWidth
  23032.   Database Class:       BorderWidth
  23033.  
  23034.            Specifies a non-negative value indicating the width of the 3-D 
  23035.            border drawn around active elements.  See above for definition of 
  23036.            active elements. The value may have any of the forms acceptable to 
  23037.            Tk_GetPixels. This option is typically only available in widgets 
  23038.            displaying more than one element at a time (e.g. menus but not 
  23039.            buttons). 
  23040.  
  23041.   Command-Line Name:    -activeforeground
  23042.   Database Name:        activeForeground
  23043.   Database Class:       Background
  23044.  
  23045.            Specifies foreground color to use when drawing active elements. See 
  23046.            above for definition of active elements. 
  23047.  
  23048.   Command-Line Name:    -anchor
  23049.   Database Name:        anchor
  23050.   Database Class:       Anchor
  23051.  
  23052.            Specifies how the information in a widget (e.g. text or a bitmap) is 
  23053.            to be displayed in the widget. Must be one of the values n, ne, e, 
  23054.            se, s, sw, w, nw, or center. For example, nw means display the 
  23055.            information such that its top-left corner is at the top-left corner 
  23056.            of the widget. 
  23057.  
  23058.   Command-Line Name:    -background or -bg
  23059.   Database Name:        background
  23060.   Database Class:       Background
  23061.  
  23062.            Specifies the normal background color to use when displaying the 
  23063.            widget. 
  23064.  
  23065.   Command-Line Name:    -bitmap
  23066.   Database Name:        bitmap
  23067.   Database Class:       Bitmap
  23068.  
  23069.            Specifies a bitmap to display in the widget, in any of the forms 
  23070.            acceptable to Tk_GetBitmap. The exact way in which the bitmap is 
  23071.            displayed may be affected by other options such as anchor or 
  23072.            justify. Typically, if this option is specified then it overrides 
  23073.            other options that specify a textual value to display in the widget; 
  23074.            the bitmap option may be reset to an empty string to re-enable a 
  23075.            text display. In widgets that support both bitmap and image options, 
  23076.            image will usually override bitmap. 
  23077.  
  23078.   Command-Line Name:    -borderwidth or -bd
  23079.   Database Name:        borderWidth
  23080.   Database Class:       BorderWidth
  23081.  
  23082.            Specifies a non-negative value indicating the width of the 3-D 
  23083.            border to draw around the outside of the widget (if such a border is 
  23084.            being drawn;  the relief option typically determines this).  The 
  23085.            value may also be used when drawing 3-D effects in the interior of 
  23086.            the widget. The value may have any of the forms acceptable to 
  23087.            Tk_GetPixels. 
  23088.  
  23089.   Command-Line Name:    -cursor
  23090.   Database Name:        cursor
  23091.   Database Class:       Cursor
  23092.  
  23093.            Specifies the mouse cursor to be used for the widget. The value may 
  23094.            have any of the forms acceptable to Tk_GetCursor. 
  23095.  
  23096.   Command-Line Name:    -disabledforeground
  23097.   Database Name:        disabledForeground
  23098.   Database Class:       DisabledForeground
  23099.  
  23100.            Specifies foreground color to use when drawing a disabled element. 
  23101.            If the option is specified as an empty string (which is typically 
  23102.            the case on monochrome displays), disabled elements are drawn with 
  23103.            the normal foreground color but they are dimmed by drawing them with 
  23104.            a stippled fill pattern. 
  23105.  
  23106.   Command-Line Name:    -exportselection
  23107.   Database Name:        exportSelection
  23108.   Database Class:       ExportSelection
  23109.  
  23110.            Specifies whether or not a selection in the widget should also be 
  23111.            the X selection. The value may have any of the forms accepted by 
  23112.            Tcl_GetBoolean, such as true, false, 0, 1, yes, or no. If the 
  23113.            selection is exported, then selecting in the widget deselects the 
  23114.            current X selection, selecting outside the widget deselects any 
  23115.            widget selection, and the widget will respond to selection retrieval 
  23116.            requests when it has a selection.  The default is usually for 
  23117.            widgets to export selections. 
  23118.  
  23119.   Command-Line Name:    -font
  23120.   Database Name:        font
  23121.   Database Class:       Font
  23122.  
  23123.            Specifies the font to use when drawing text inside the widget. 
  23124.  
  23125.   Command-Line Name:    -foreground or -fg
  23126.   Database Name:        foreground
  23127.   Database Class:       Foreground
  23128.  
  23129.            Specifies the normal foreground color to use when displaying the 
  23130.            widget. 
  23131.  
  23132.   Command-Line Name:    -geometry
  23133.   Database Name:        geometry
  23134.   Database Class:       Geometry
  23135.  
  23136.            Specifies the desired geometry for the widget's window, in the form 
  23137.            widthxheight, where width is the desired width of the window and 
  23138.            height is the desired height.  The units for width and height depend 
  23139.            on the particular widget.  For widgets displaying text the units are 
  23140.            usually the size of the characters in the font being displayed;  for 
  23141.            other widgets the units are usually pixels. 
  23142.  
  23143.   Command-Line Name:    -highlightbackground
  23144.   Database Name:        highlightBackground
  23145.   Database Class:       HighlightBackground
  23146.  
  23147.            Specifies the color to display in the traversal highlight region 
  23148.            when the widget does not have the input focus. 
  23149.  
  23150.   Command-Line Name:    -highlightcolor
  23151.   Database Name:        highlightColor
  23152.   Database Class:       HighlightColor
  23153.  
  23154.            Specifies the color to use for the traversal highlight rectangle 
  23155.            that is drawn around the widget when it has the input focus. 
  23156.  
  23157.   Command-Line Name:    -highlightthickness
  23158.   Database Name:        highlightThickness
  23159.   Database Class:       HighlightThickness
  23160.  
  23161.            Specifies a non-negative value indicating the width of the highlight 
  23162.            rectangle to draw around the outside of the widget when it has the 
  23163.            input focus. The value may have any of the forms acceptable to 
  23164.            Tk_GetPixels. If the value is zero, no focus highlight is drawn 
  23165.            around the widget. 
  23166.  
  23167.   Command-Line Name:    -image
  23168.   Database Name:        image
  23169.   Database Class:       Image
  23170.  
  23171.            Specifies an image to display in the widget, which must have been 
  23172.            created with the image create command. Typically, if the image 
  23173.            option is specified then it overrides other options that specify a 
  23174.            bitmap or textual value to display in the widget; the image option 
  23175.            may be reset to an empty string to re-enable a bitmap or text 
  23176.            display. 
  23177.  
  23178.   Command-Line Name:    -insertbackground
  23179.   Database Name:        insertBackground
  23180.   Database Class:       Foreground
  23181.  
  23182.            Specifies the color to use as background in the area covered by the 
  23183.            insertion cursor.  This color will normally override either the 
  23184.            normal background for the widget (or the selection background if the 
  23185.            insertion cursor happens to fall in the selection). 
  23186.  
  23187.   Command-Line Name:    -insertborderwidth
  23188.   Database Name:        insertBorderWidth
  23189.   Database Class:       BorderWidth
  23190.  
  23191.            Specifies a non-negative value indicating the width of the 3-D 
  23192.            border to draw around the insertion cursor. The value may have any 
  23193.            of the forms acceptable to Tk_GetPixels. 
  23194.  
  23195.   Command-Line Name:    -insertofftime
  23196.   Database Name:        insertOffTime
  23197.   Database Class:       OffTime
  23198.  
  23199.            Specifies a non-negative integer value indicating the number of 
  23200.            milliseconds the insertion cursor should remain "off" in each blink 
  23201.            cycle. If this option is zero then the cursor doesn't blink:  it is 
  23202.            on all the time. 
  23203.  
  23204.   Command-Line Name:    -insertontime
  23205.   Database Name:        insertOnTime
  23206.   Database Class:       OnTime
  23207.  
  23208.            Specifies a non-negative integer value indicating the number of 
  23209.            milliseconds the insertion cursor should remain "on" in each blink 
  23210.            cycle. 
  23211.  
  23212.   Command-Line Name:    -insertwidth
  23213.   Database Name:        insertWidth
  23214.   Database Class:       InsertWidth
  23215.  
  23216.            Specifies a  value indicating the total width of the insertion 
  23217.            cursor. The value may have any of the forms acceptable to 
  23218.            Tk_GetPixels. If a border has been specified for the insertion 
  23219.            cursor (using the insertBorderWidth option), the border will be 
  23220.            drawn inside the width specified by the insertWidth option. 
  23221.  
  23222.   Command-Line Name:    -jump
  23223.   Database Name:        jump
  23224.   Database Class:       Jump
  23225.  
  23226.            For widgets with a slider that can be dragged to adjust a value, 
  23227.            such as scrollbars, this option determines when notifications are 
  23228.            made about changes in the value. The option's value must be a 
  23229.            boolean of the form accepted by Tcl_GetBoolean. If the value is 
  23230.            false, updates are made continuously as the slider is dragged. If 
  23231.            the value is true, updates are delayed until the mouse button is 
  23232.            released to end the drag;  at that point a single notification is 
  23233.            made (the value "jumps" rather than changing smoothly). 
  23234.  
  23235.   Command-Line Name:    -justify
  23236.   Database Name:        justify
  23237.   Database Class:       Justify
  23238.  
  23239.            When there are multiple lines of text displayed in a widget, this 
  23240.            option determines how the lines line up with each other. Must be one 
  23241.            of left, center, or right. Left means that the lines' left edges all 
  23242.            line up, center means that the lines' centers are aligned, and right 
  23243.            means that the lines' right edges line up. 
  23244.  
  23245.   Command-Line Name:    -orient
  23246.   Database Name:        orient
  23247.   Database Class:       Orient
  23248.  
  23249.            For widgets that can lay themselves out with either a horizontal or 
  23250.            vertical orientation, such as scrollbars, this option specifies 
  23251.            which orientation should be used.  Must be either horizontal or 
  23252.            vertical or an abbreviation of one of these. 
  23253.  
  23254.   Command-Line Name:    -padx
  23255.   Database Name:        padX
  23256.   Database Class:       Pad
  23257.  
  23258.            Specifies a non-negative value indicating how much extra space to 
  23259.            request for the widget in the X-direction. The value may have any of 
  23260.            the forms acceptable to Tk_GetPixels. When computing how large a 
  23261.            window it needs, the widget will add this amount to the width it 
  23262.            would normally need (as determined by the width of the things 
  23263.            displayed in the widget);  if the geometry manager can satisfy this 
  23264.            request, the widget will end up with extra internal space to the 
  23265.            left and/or right of what it displays inside. Most widgets only use 
  23266.            this option for padding text:  if they are displaying a bitmap or 
  23267.            image, then they usually ignore padding options. 
  23268.  
  23269.   Command-Line Name:    -pady
  23270.   Database Name:        padY
  23271.   Database Class:       Pad
  23272.  
  23273.            Specifies a non-negative value indicating how much extra space to 
  23274.            request for the widget in the Y-direction. The value may have any of 
  23275.            the forms acceptable to Tk_GetPixels. When computing how large a 
  23276.            window it needs, the widget will add this amount to the height it 
  23277.            would normally need (as determined by the height of the things 
  23278.            displayed in the widget);  if the geometry manager can satisfy this 
  23279.            request, the widget will end up with extra internal space above 
  23280.            and/or below what it displays inside. Most widgets only use this 
  23281.            option for padding text:  if they are displaying a bitmap or image, 
  23282.            then they usually ignore padding options. 
  23283.  
  23284.   Command-Line Name:    -relief
  23285.   Database Name:        relief
  23286.   Database Class:       Relief
  23287.  
  23288.            Specifies the 3-D effect desired for the widget.  Acceptable values 
  23289.            are raised, sunken, flat, ridge, and groove. The value indicates how 
  23290.            the interior of the widget should appear relative to its exterior; 
  23291.            for example, raised means the interior of the widget should appear 
  23292.            to protrude from the screen, relative to the exterior of the widget. 
  23293.  
  23294.   Command-Line Name:    -repeatdelay
  23295.   Database Name:        repeatDelay
  23296.   Database Class:       RepeatDelay
  23297.  
  23298.            Specifies the number of milliseconds a button or key must be held 
  23299.            down before it begins to auto-repeat.  Used, for example, on the up- 
  23300.            and down-arrows in scrollbars. 
  23301.  
  23302.   Command-Line Name:    -repeatinterval
  23303.   Database Name:        repeatInterval
  23304.   Database Class:       RepeatInterval
  23305.  
  23306.            Used in conjunction with repeatDelay:  once auto-repeat begins, this 
  23307.            option determines the number of milliseconds between auto-repeats. 
  23308.  
  23309.   Command-Line Name:    -selectbackground
  23310.   Database Name:        selectBackground
  23311.   Database Class:       Foreground
  23312.  
  23313.            Specifies the background color to use when displaying selected 
  23314.            items. 
  23315.  
  23316.   Command-Line Name:    -selectborderwidth
  23317.   Database Name:        selectBorderWidth
  23318.   Database Class:       BorderWidth
  23319.  
  23320.            Specifies a non-negative value indicating the width of the 3-D 
  23321.            border to draw around selected items. The value may have any of the 
  23322.            forms acceptable to Tk_GetPixels. 
  23323.  
  23324.   Command-Line Name:    -selectforeground
  23325.   Database Name:        selectForeground
  23326.   Database Class:       Background
  23327.  
  23328.            Specifies the foreground color to use when displaying selected 
  23329.            items. 
  23330.  
  23331.   Command-Line Name:    -setgrid
  23332.   Database Name:        setGrid
  23333.   Database Class:       SetGrid
  23334.  
  23335.            Specifies a boolean value that determines whether this widget 
  23336.            controls the resizing grid for its top-level window. This option is 
  23337.            typically used in text widgets, where the information in the widget 
  23338.            has a natural size (the size of a character) and it makes sense for 
  23339.            the window's dimensions to be integral numbers of these units. These 
  23340.            natural window sizes form a grid. If the setGrid option is set to 
  23341.            true then the widget will communicate with the window manager so 
  23342.            that when the user interactively resizes the top-level window that 
  23343.            contains the widget, the dimensions of the window will be displayed 
  23344.            to the user in grid units and the window size will be constrained to 
  23345.            integral numbers of grid units. See the section GRIDDED GEOMETRY 
  23346.            MANAGEMENT in the wm manual entry for more details. 
  23347.  
  23348.   Command-Line Name:    -takefocus
  23349.   Database Name:        takeFocus
  23350.   Database Class:       TakeFocus
  23351.  
  23352.            Determines whether the window accepts the focus during keyboard 
  23353.            traversal (e.g., Tab and Shift-Tab). Before setting the focus to a 
  23354.            window, the traversal scripts consult the value of the takeFocus 
  23355.            option. A value of 0 means that the window should be skipped 
  23356.            entirely during keyboard traversal. 1 means that the window should 
  23357.            receive the input focus as long as it is viewable (it and all of its 
  23358.            ancestors are mapped). An empty value for the option means that the 
  23359.            traversal scripts make the decision about whether or not to focus on 
  23360.            the window:  the current algorithm is to skip the window if it is 
  23361.            disabled, if it has no key bindings, or if it is not viewable. If 
  23362.            the value has any other form, then the traversal scripts take the 
  23363.            value, append the name of the window to it (with a separator space), 
  23364.            and evaluate the resulting string as a Tcl script. The script must 
  23365.            return 0, 1, or an empty string:  a 0 or 1 value specifies whether 
  23366.            the window will receive the input focus, and an empty string results 
  23367.            in the default decision described above. Note: this interpretation 
  23368.            of the option is defined entirely by the Tcl scripts that implement 
  23369.            traversal:  the widget implementations ignore the option entirely, 
  23370.            so you can change its meaning if you redefine the keyboard traversal 
  23371.            scripts. 
  23372.  
  23373.   Command-Line Name:    -text
  23374.   Database Name:        text
  23375.   Database Class:       Text
  23376.  
  23377.            Specifies a string to be displayed inside the widget.  The way in 
  23378.            which the string is displayed depends on the particular widget and 
  23379.            may be determined by other options, such as anchor or justify. 
  23380.  
  23381.   Command-Line Name:    -textvariable
  23382.   Database Name:        textVariable
  23383.   Database Class:       Variable
  23384.  
  23385.            Specifies the name of a variable.  The value of the variable is a 
  23386.            text string to be displayed inside the widget;  if the variable 
  23387.            value changes then the widget will automatically update itself to 
  23388.            reflect the new value. The way in which the string is displayed in 
  23389.            the widget depends on the particular widget and may be determined by 
  23390.            other options, such as anchor or justify. 
  23391.  
  23392.   Command-Line Name:    -troughcolor
  23393.   Database Name:        troughColor
  23394.   Database Class:       Background
  23395.  
  23396.            Specifies the color to use for the rectangular trough areas in 
  23397.            widgets such as scrollbars and scales. 
  23398.  
  23399.   Command-Line Name:    -underline
  23400.   Database Name:        underline
  23401.   Database Class:       Underline
  23402.  
  23403.            Specifies the integer index of a character to underline in the 
  23404.            widget. This option is used by the default bindings to implement 
  23405.            keyboard traversal for menu buttons and menu entries. 0 corresponds 
  23406.            to the first character of the text displayed in the widget, 1 to the 
  23407.            next character, and so on. 
  23408.  
  23409.   Command-Line Name:    -wraplength
  23410.   Database Name:        wrapLength
  23411.   Database Class:       WrapLength
  23412.  
  23413.            For widgets that can perform word-wrapping, this option specifies 
  23414.            the maximum line length. Lines that would exceed this length are 
  23415.            wrapped onto the next line, so that no line is longer than the 
  23416.            specified length. The value may be specified in any of the standard 
  23417.            forms for screen distances. If this value is less than or equal to 0 
  23418.            then no wrapping is done:  lines will break only at newline 
  23419.            characters in the text. 
  23420.  
  23421.   Command-Line Name:    -xscrollcommand
  23422.   Database Name:        xScrollCommand
  23423.   Database Class:       ScrollCommand
  23424.  
  23425.            Specifies the prefix for a command used to communicate with 
  23426.            horizontal scrollbars. When the view in the widget's window changes 
  23427.            (or whenever anything else occurs that could change the display in a 
  23428.            scrollbar, such as a change in the total size of the widget's 
  23429.            contents), the widget will generate a Tcl command by concatenating 
  23430.            the scroll command and two numbers. Each of the numbers is a 
  23431.            fraction between 0 and 1, which indicates a position in the 
  23432.            document.  0 indicates the beginning of the document, 1 indicates 
  23433.            the end, .333 indicates a position one third the way through the 
  23434.            document, and so on. The first fraction indicates the first 
  23435.            information in the document that is visible in the window, and the 
  23436.            second fraction indicates the information just after the last 
  23437.            portion that is visible. The command is then passed to the Tcl 
  23438.            interpreter for execution.  Typically the xScrollCommand option 
  23439.            consists of the path name of a scrollbar widget followed by "set", 
  23440.            e.g. ".x.scrollbar set":  this will cause the scrollbar to be 
  23441.            updated whenever the view in the window changes. If this option is 
  23442.            not specified, then no command will be executed. 
  23443.  
  23444.   Command-Line Name:    -yscrollcommand
  23445.   Database Name:        yScrollCommand
  23446.   Database Class:       ScrollCommand
  23447.  
  23448.            Specifies the prefix for a command used to communicate with vertical 
  23449.            scrollbars.  This option is treated in the same way as the 
  23450.            xScrollCommand option, except that it is used for vertical 
  23451.            scrollbars and is provided by widgets that support vertical 
  23452.            scrolling. See the description of xScrollCommand for details on how 
  23453.            this option is used. 
  23454.  
  23455.  KEYWORDS 
  23456.  
  23457.  class, name, standard option, switch 
  23458.  
  23459.  
  23460. ΓòÉΓòÉΓòÉ 6.32. pack-old ΓòÉΓòÉΓòÉ
  23461.  
  23462.  NAME 
  23463.  
  23464. pack - Obsolete syntax for packer geometry manager 
  23465.  
  23466. SYNOPSIS 
  23467.  
  23468. pack after sibling window options ?window options ...? 
  23469.  pack append parent window options ?window options ...? 
  23470.  pack before sibling window options ?window options ...? 
  23471.  pack unpack window 
  23472.  
  23473. DESCRIPTION 
  23474.  
  23475. Note: this manual entry describes the syntax for the pack command as it existed 
  23476. before Tk version 3.3. Although this syntax continues to be supported for 
  23477. backward compatibility, it is obsolete and should not be used anymore. At some 
  23478. point in the future it may cease to be supported. 
  23479.  
  23480. The packer is a geometry manager that arranges the children of a parent by 
  23481. packing them in order around the edges of the parent.  The first child is 
  23482. placed against one side of the window, occupying the entire span of the window 
  23483. along that side.  This reduces the space remaining for other children as if the 
  23484. side had been moved in by the size of the first child. Then the next child is 
  23485. placed against one side of the remaining cavity, and so on until all children 
  23486. have been placed or there is no space left in the cavity. 
  23487.  
  23488. The before, after, and append forms of the pack command are used to insert one 
  23489. or more children into the packing order for their parent.  The before form 
  23490. inserts the children before window sibling in the order;  all of the other 
  23491. windows must be siblings of sibling.  The after form inserts the windows after 
  23492. sibling, and the append form appends one or more windows to the end of the 
  23493. packing order for parent.  If a window named in any of these commands is 
  23494. already packed in its parent, it is removed from its current position in the 
  23495. packing order and repositioned as indicated by the command.  All of these 
  23496. commands return an empty string as result. 
  23497.  
  23498. The unpack form of the pack command removes window from the packing order of 
  23499. its parent and unmaps it.  After the execution of this command the packer will 
  23500. no longer manage window's geometry. 
  23501.  
  23502. The placement of each child is actually a four-step process; the options 
  23503. argument following each window consists of a list of one or more fields that 
  23504. govern the placement of that window.  In the discussion below, the term cavity 
  23505. refers to the space left in a parent when a particular child is placed (i.e. 
  23506. all the space that wasn't claimed by earlier children in the packing order). 
  23507. The term parcel refers to the space allocated to a particular child;  this is 
  23508. not necessarily the same as the child window's final geometry. 
  23509.  
  23510. The first step in placing a child is to determine which side of the cavity it 
  23511. will lie against.  Any one of the following options may be used to specify a 
  23512. side: 
  23513.  
  23514.  top       Position the child's parcel against the top of the cavity, occupying 
  23515.            the full width of the cavity. 
  23516.  
  23517.  bottom    Position the child's parcel against the bottom of the cavity, 
  23518.            occupying the full width of the cavity. 
  23519.  
  23520.  left      Position the child's parcel against the left side of the cavity, 
  23521.            occupying the full height of the cavity. 
  23522.  
  23523.  right     Position the child's parcel against the right side of the cavity, 
  23524.            occupying the full height of the cavity. 
  23525.  
  23526.  At most one of these options should be specified for any given window. If no 
  23527.  side is specified, then the default is top. 
  23528.  
  23529.  The second step is to decide on a parcel for the child.  For top and bottom 
  23530.  windows, the desired parcel width is normally the cavity width and the desired 
  23531.  parcel height is the window's requested height, as passed to 
  23532.  Tk_GeometryRequest. For left and right windows, the desired parcel height is 
  23533.  normally the cavity height and the desired width is the window's requested 
  23534.  width.  However, extra space may be requested for the window using any of the 
  23535.  following options: 
  23536.  
  23537.  padx num  Add num pixels to the window's requested width before computing the 
  23538.            parcel size as described above. 
  23539.  
  23540.  pady num  Add num pixels to the window's requested height before computing the 
  23541.            parcel size as described above. 
  23542.  
  23543.  expand    This option requests that the window's parcel absorb any extra space 
  23544.            left over in the parent's cavity after packing all the children. The 
  23545.            amount of space left over depends on the sizes requested by the 
  23546.            other children, and may be zero.  If several windows have all 
  23547.            specified expand then the extra width will be divided equally among 
  23548.            all the left and right windows that specified expand and the extra 
  23549.            height will be divided equally among all the top and bottom windows 
  23550.            that specified expand. 
  23551.  
  23552.  If the desired width or height for a parcel is larger than the corresponding 
  23553.  dimension of the cavity, then the cavity's dimension is used instead. 
  23554.  
  23555.  The third step in placing the window is to decide on the window's width and 
  23556.  height.  The default is for the window to receive either its requested width 
  23557.  and height or the those of the parcel, whichever is smaller.  If the parcel is 
  23558.  larger than the window's requested size, then the following options may be 
  23559.  used to expand the window to partially or completely fill the parcel: 
  23560.  
  23561.  fill      Set the window's size to equal the parcel size. 
  23562.  
  23563.  fillx     Increase the window's width to equal the parcel's width, but retain 
  23564.            the window's requested height. 
  23565.  
  23566.  filly     Increase the window's height to equal the parcel's height, but 
  23567.            retain the window's requested width. 
  23568.  
  23569.  The last step is to decide the window's location within its parcel. If the 
  23570.  window's size equals the parcel's size, then the window simply fills the 
  23571.  entire parcel.  If the parcel is larger than the window, then one of the 
  23572.  following options may be used to specify where the window should be positioned 
  23573.  within its parcel: 
  23574.  
  23575.  frame center  Center the window in its parcel.  This is the default if no 
  23576.            framing option is specified. 
  23577.  
  23578.  frame n   Position the window with its top edge centered on the top edge of 
  23579.            the parcel. 
  23580.  
  23581.  frame ne  Position the window with its upper-right corner at the upper-right 
  23582.            corner of the parcel. 
  23583.  
  23584.  frame e   Position the window with its right edge centered on the right edge 
  23585.            of the parcel. 
  23586.  
  23587.  frame se  Position the window with its lower-right corner at the lower-right 
  23588.            corner of the parcel. 
  23589.  
  23590.  frame s   Position the window with its bottom edge centered on the bottom edge 
  23591.            of the parcel. 
  23592.  
  23593.  frame sw  Position the window with its lower-left corner at the lower-left 
  23594.            corner of the parcel. 
  23595.  
  23596.  frame w   Position the window with its left edge centered on the left edge of 
  23597.            the parcel. 
  23598.  
  23599.  frame nw  Position the window with its upper-left corner at the upper-left 
  23600.            corner of the parcel. 
  23601.  
  23602.  The packer manages the mapped/unmapped state of all the packed children 
  23603.  windows.  It automatically maps the windows when it packs them, and it unmaps 
  23604.  any windows for which there was no space left in the cavity. 
  23605.  
  23606.  The packer makes geometry requests on behalf of the parent windows it manages. 
  23607.  For each parent window it requests a size large enough to accommodate all the 
  23608.  options specified by all the packed children, such that zero space would be 
  23609.  leftover for expand options. 
  23610.  
  23611.  KEYWORDS 
  23612.  
  23613.  geometry manager, location, packer, parcel, size 
  23614.  
  23615.  
  23616. ΓòÉΓòÉΓòÉ 6.33. pack ΓòÉΓòÉΓòÉ
  23617.  
  23618.  NAME 
  23619.  
  23620. pack - Geometry manager that packs around edges of cavity 
  23621.  
  23622. SYNOPSIS 
  23623.  
  23624. pack option arg ?arg ...? 
  23625.  
  23626. DESCRIPTION 
  23627.  
  23628. The pack command is used to communicate with the packer, a geometry manager 
  23629. that arranges the children of a parent by packing them in order around the 
  23630. edges of the parent. The pack command can have any of several forms, depending 
  23631. on the option argument: 
  23632.  
  23633.  pack slave ?slave ...? ?options?  If the first argument to pack is a window 
  23634.            name (any value starting with "."), then the command is processed in 
  23635.            the same way as pack configure. 
  23636.  
  23637.  pack configure slave ?slave ...? ?options?  The arguments consist of the names 
  23638.            of one or more slave windows followed by pairs of arguments that 
  23639.            specify how to manage the slaves. See "THE PACKER ALGORITHM" below 
  23640.            for details on how the options are used by the packer. The following 
  23641.            options are supported: 
  23642.  
  23643.            -after other   Other must the name of another window. Use its master 
  23644.                           as the master for the slaves, and insert the slaves 
  23645.                           just after other in the packing order. 
  23646.  
  23647.            -anchor anchor  Anchor must be a valid anchor position such as n or 
  23648.                           sw; it specifies where to position each slave in its 
  23649.                           parcel. Defaults to center. 
  23650.  
  23651.            -before other  Other must the name of another window. Use its master 
  23652.                           as the master for the slaves, and insert the slaves 
  23653.                           just before other in the packing order. 
  23654.  
  23655.            -expand boolean  Specifies whether the slaves should be expanded to 
  23656.                           consume extra space in their master. Boolean may have 
  23657.                           any proper boolean value, such as 1 or no. Defaults 
  23658.                           to 0. 
  23659.  
  23660.            -fill style    If a slave's parcel is larger than its requested 
  23661.                           dimensions, this option may be used to stretch the 
  23662.                           slave. Style must have one of the following values: 
  23663.  
  23664.                           none           Give the slave its requested 
  23665.                                          dimensions plus any internal padding 
  23666.                                          requested with -ipadx or -ipady.  This 
  23667.                                          is the default. 
  23668.  
  23669.                           x              Stretch the slave horizontally to fill 
  23670.                                          the entire width of its parcel (except 
  23671.                                          leave external padding as specified by 
  23672.                                          -padx). 
  23673.  
  23674.                           y              Stretch the slave vertically to fill 
  23675.                                          the entire height of its parcel 
  23676.                                          (except leave external padding as 
  23677.                                          specified by -pady). 
  23678.  
  23679.                           both           Stretch the slave both horizontally 
  23680.                                          and vertically. 
  23681.  
  23682.            -in other      Insert the slave(s) at the end of the packing order 
  23683.                           for the master window given by other. 
  23684.  
  23685.            -ipadx amount  Amount specifies how much horizontal internal padding 
  23686.                           to leave on each side of the slave(s). Amount must be 
  23687.                           a valid screen distance, such as 2 or .5c. It 
  23688.                           defaults to 0. 
  23689.  
  23690.            -ipady amount  Amount specifies how much vertical internal padding 
  23691.                           to leave on each side of the slave(s). Amount 
  23692.                           defaults to 0. 
  23693.  
  23694.            -padx amount   Amount specifies how much horizontal external padding 
  23695.                           to leave on each side of the slave(s). Amount 
  23696.                           defaults to 0. 
  23697.  
  23698.            -pady amount   Amount specifies how much vertical external padding 
  23699.                           to leave on each side of the slave(s). Amount 
  23700.                           defaults to 0. 
  23701.  
  23702.            -side side     Specifies which side of the master the slave(s) will 
  23703.                           be packed against. Must be left, right, top, or 
  23704.                           bottom. Defaults to top. 
  23705.  
  23706.            If no -in, -after or -before option is specified then each of the 
  23707.            slaves will be inserted at the end of the packing list for its 
  23708.            parent unless it is already managed by the packer (in which case it 
  23709.            will be left where it is). If one of these options is specified then 
  23710.            all the slaves will be inserted at the specified point. If any of 
  23711.            the slaves are already managed by the geometry manager then any 
  23712.            unspecified options for them retain their previous values rather 
  23713.            than receiving default values. 
  23714.  
  23715.  pack forget slave ?slave ...?  Removes each of the slaves from the packing 
  23716.            order for its master and unmaps their windows. The slaves will no 
  23717.            longer be managed by the packer. 
  23718.  
  23719.  pack info slave  Returns a list whose elements are the current configuration 
  23720.            state of the slave given by slave in the same option-value form that 
  23721.            might be specified to pack configure. The first two elements of the 
  23722.            list are "-in master" where master is the slave's master. 
  23723.  
  23724.  pack propagate master ?boolean?  If boolean has a true boolean value such as 1 
  23725.            or on then propagation is enabled for master, which must be a window 
  23726.            name (see "GEOMETRY PROPAGATION" below). If boolean has a false 
  23727.            boolean value then propagation is disabled for master. In either of 
  23728.            these cases an empty string is returned. If boolean is omitted then 
  23729.            the command returns 0 or 1 to indicate whether propagation is 
  23730.            currently enabled for master. Propagation is enabled by default. 
  23731.  
  23732.  pack slaves master  Returns a list of all of the slaves in the packing order 
  23733.            for master. The order of the slaves in the list is the same as their 
  23734.            order in the packing order. If master has no slaves then an empty 
  23735.            string is returned. 
  23736.  
  23737.  THE PACKER ALGORITHM 
  23738.  
  23739.  For each master the packer maintains an ordered list of slaves called the 
  23740.  packing list. The -in, -after, and -before configuration options are used to 
  23741.  specify the master for each slave and the slave's position in the packing 
  23742.  list. If none of these options is given for a slave then the slave is added to 
  23743.  the end of the packing list for its parent. 
  23744.  
  23745.  The packer arranges the slaves for a master by scanning the packing list in 
  23746.  order. At the time it processes each slave, a rectangular area within the 
  23747.  master is still unallocated. This area is called the cavity;  for the first 
  23748.  slave it is the entire area of the master. 
  23749.  
  23750.  For each slave the packer carries out the following steps: 
  23751.  
  23752.    1. The packer allocates a rectangular parcel for the slave along the side of 
  23753.       the cavity given by the slave's -side option. If the side is top or 
  23754.       bottom then the width of the parcel is the width of the cavity and its 
  23755.       height is the requested height of the slave plus the -ipady and -pady 
  23756.       options. For the left or right side the height of the parcel is the 
  23757.       height of the cavity and the width is the requested width of the slave 
  23758.       plus the -ipadx and -padx options. The parcel may be enlarged further 
  23759.       because of the -expand option (see "EXPANSION" below) 
  23760.  
  23761.    2. The packer chooses the dimensions of the slave. The width will normally 
  23762.       be the slave's requested width plus twice its -ipadx option and the 
  23763.       height will normally be the slave's requested height plus twice its 
  23764.       -ipady option. However, if the -fill option is x or both then the width 
  23765.       of the slave is expanded to fill the width of the parcel, minus twice the 
  23766.       -padx option. If the -fill option is y or both then the height of the 
  23767.       slave is expanded to fill the width of the parcel, minus twice the -pady 
  23768.       option. 
  23769.  
  23770.    3. The packer positions the slave over its parcel. If the slave is smaller 
  23771.       than the parcel then the -anchor option determines where in the parcel 
  23772.       the slave will be placed. If -padx or -pady is non-zero, then the given 
  23773.       amount of external padding will always be left between the slave and the 
  23774.       edges of the parcel. 
  23775.  
  23776.  Once a given slave has been packed, the area of its parcel is subtracted from 
  23777.  the cavity, leaving a smaller rectangular cavity for the next slave. If a 
  23778.  slave doesn't use all of its parcel, the unused space in the parcel will not 
  23779.  be used by subsequent slaves. If the cavity should become too small to meet 
  23780.  the needs of a slave then the slave will be given whatever space is left in 
  23781.  the cavity. If the cavity shrinks to zero size, then all remaining slaves on 
  23782.  the packing list will be unmapped from the screen until the master window 
  23783.  becomes large enough to hold them again. 
  23784.  
  23785.  EXPANSION 
  23786.  
  23787.  If a master window is so large that there will be extra space left over after 
  23788.  all of its slaves have been packed, then the extra space is distributed 
  23789.  uniformly among all of the slaves for which the -expand option is set. Extra 
  23790.  horizontal space is distributed among the expandable slaves whose -side is 
  23791.  left or right, and extra vertical space is distributed among the expandable 
  23792.  slaves whose -side is top or bottom. 
  23793.  
  23794.  GEOMETRY PROPAGATION 
  23795.  
  23796.  The packer normally computes how large a master must be to just exactly meet 
  23797.  the needs of its slaves, and it sets the requested width and height of the 
  23798.  master to these dimensions. This causes geometry information to propagate up 
  23799.  through a window hierarchy to a top-level window so that the entire sub-tree 
  23800.  sizes itself to fit the needs of the leaf windows. However, the pack propagate 
  23801.  command may be used to turn off propagation for one or more masters. If 
  23802.  propagation is disabled then the packer will not set the requested width and 
  23803.  height of the packer. This may be useful if, for example, you wish for a 
  23804.  master window to have a fixed size that you specify. 
  23805.  
  23806.  RESTRICTIONS ON MASTER WINDOWS 
  23807.  
  23808.  The master for each slave must either be the slave's parent (the default) or a 
  23809.  descendant of the slave's parent. This restriction is necessary to guarantee 
  23810.  that the slave can be placed over any part of its master that is visible 
  23811.  without danger of the slave being clipped by its parent. 
  23812.  
  23813.  PACKING ORDER 
  23814.  
  23815.  If the master for a slave is not its parent then you must make sure that the 
  23816.  slave is higher in the stacking order than the master. Otherwise the master 
  23817.  will obscure the slave and it will appear as if the slave hasn't been packed 
  23818.  correctly. The easiest way to make sure the slave is higher than the master is 
  23819.  to create the master window first:  the most recently created window will be 
  23820.  highest in the stacking order. Or, you can use the raise and lower commands to 
  23821.  change the stacking order of either the master or the slave. 
  23822.  
  23823.  KEYWORDS 
  23824.  
  23825.  geometry manager, location, packer, parcel, propagation, size 
  23826.  
  23827.  
  23828. ΓòÉΓòÉΓòÉ 6.34. tk_setPalette ΓòÉΓòÉΓòÉ
  23829.  
  23830.  NAME 
  23831.  
  23832. tk_setPalette, tk_bisque - Modify the Tk color palette 
  23833.  
  23834. SYNOPSIS 
  23835.  
  23836. tk_setPalette background 
  23837.  tk_setPalette name value ?name value ...? 
  23838.  tk_bisque 
  23839.  
  23840. DESCRIPTION 
  23841.  
  23842. The tk_setPalette procedure changes the color scheme for Tk. It does this by 
  23843. modifying the colors of existing widgets and by changing the option database so 
  23844. that future widgets will use the new color scheme. If tk_setPalette is invoked 
  23845. with a single argument, the argument is the name of a color to use as the 
  23846. normal background color;  tk_setPalette will compute a complete color palette 
  23847. from this background color. Alternatively, the arguments to tk_setPalette may 
  23848. consist of any number of name-value pairs, where the first argument of the pair 
  23849. is the name of an option in the Tk option database and the second argument is 
  23850. the new value to use for that option.  The following database names are 
  23851. currently supported: 
  23852.  
  23853. activeBackground      foreground            selectColor
  23854. activeForeground      highlightBackground   selectBackground
  23855. background            highlightColor        selectForeground
  23856. disabledForeground    insertBackground      troughColor
  23857. tk_setPalette tries to compute reasonable defaults for any options that you 
  23858. don't specify.  You can specify options other than the above ones and Tk will 
  23859. change those options on widgets as well.  This feature may be useful if you are 
  23860. using custom widgets with additional color options. 
  23861.  
  23862. Once it has computed the new value to use for each of the color options, 
  23863. tk_setPalette scans the widget hierarchy to modify the options of all existing 
  23864. widgets.  For each widget, it checks to see if any of the above options is 
  23865. defined for the widget.  If so, and if the option's current value is the 
  23866. default, then the value is changed;  if the option has a value other than the 
  23867. default, tk_setPalette will not change it.  The default for an option is the 
  23868. one provided by the widget ([lindex [$w configure $option] 3]) unless 
  23869. tk_setPalette has been run previously, in which case it is the value specified 
  23870. in the previous invocation of tk_setPalette. 
  23871.  
  23872. After modifying all the widgets in the application, tk_setPalette adds options 
  23873. to the option database to change the defaults for widgets created in the 
  23874. future.  The new options are added at priority widgetDefault, so they will be 
  23875. overridden by options from the .Xdefaults file or options specified on the 
  23876. command-line that creates a widget. 
  23877.  
  23878. The procedure tk_bisque is provided for backward compatibility: it restores the 
  23879. application's colors to the light brown ("bisque") color scheme used in Tk 3.6 
  23880. and earlier versions. 
  23881.  
  23882. KEYWORDS 
  23883.  
  23884. bisque, color, palette 
  23885.  
  23886.  
  23887. ΓòÉΓòÉΓòÉ 6.35. photo ΓòÉΓòÉΓòÉ
  23888.  
  23889.  NAME 
  23890.  
  23891. photo - Full-color images 
  23892.  
  23893. SYNOPSIS 
  23894.  
  23895. image create photo ?name? ?options? 
  23896.  
  23897. DESCRIPTION 
  23898.  
  23899. A photo is an image whose pixels can display any color or be transparent.  A 
  23900. photo image is stored internally in full color (24 bits per pixel), and is 
  23901. displayed using dithering if necessary.  Image data for a photo image can be 
  23902. obtained from a file or a string, or it can be supplied from C code through a 
  23903. procedural interface.  At present, only GIF and PPM/PGM formats are supported, 
  23904. but an interface exists to allow additional image file formats to be added 
  23905. easily.  A photo image is transparent in regions where no image data has been 
  23906. supplied. 
  23907.  
  23908. CREATING PHOTOS 
  23909.  
  23910. Like all images, photos are created using the image create command. Photos 
  23911. support the following options: 
  23912.  
  23913.  -data string  Specifies the contents of the image as a string.  The format of 
  23914.            the string must be one of those for which there is an image file 
  23915.            format handler that will accept string data.  If both the -data and 
  23916.            -file options are specified, the -file option takes precedence. 
  23917.  
  23918.  -format format-name  Specifies the name of the file format for the data 
  23919.            specified with the -data or -file option. 
  23920.  
  23921.  -file name  name gives the name of a file that is to be read to supply data 
  23922.            for the photo image.  The file format must be one of those for which 
  23923.            there is an image file format handler that can read data from a 
  23924.            file. 
  23925.  
  23926.  -gamma value  Specifies that the colors allocated for displaying this image in 
  23927.            a window should be corrected for a non-linear display with the 
  23928.            specified gamma exponent value.  (The intensity produced by most CRT 
  23929.            displays is a power function of the input value, to a good 
  23930.            approximation; gamma is the exponent and is typically around 2). The 
  23931.            value specified must be greater than zero.  The default value is one 
  23932.            (no correction).  In general, values greater than one will make the 
  23933.            image lighter, and values less than one will make it darker. 
  23934.  
  23935.  -height number  Specifies the height of the image, in pixels.  This option is 
  23936.            useful primarily in situations where the user wishes to build up the 
  23937.            contents of the image piece by piece.  A value of zero (the default) 
  23938.            allows the image to expand or shrink vertically to fit the data 
  23939.            stored in it. 
  23940.  
  23941.  -palette palette-spec  Specifies the resolution of the color cube to be 
  23942.            allocated for displaying this image, and thus the number of colors 
  23943.            used from the colormaps of the windows where it is displayed.  The 
  23944.            palette-spec string may be either a single decimal number, 
  23945.            specifying the number of shades of gray to use, or three decimal 
  23946.            numbers separated by slashes (/), specifying the number of shades of 
  23947.            red, green and blue to use, respectively.  If the first form (a 
  23948.            single number) is used, the image will be displayed in monochrome 
  23949.            (i.e., grayscale). 
  23950.  
  23951.  -width number  Specifies the width of the image, in pixels.   This option is 
  23952.            useful primarily in situations where the user wishes to build up the 
  23953.            contents of the image piece by piece.  A value of zero (the default) 
  23954.            allows the image to expand or shrink horizontally to fit the data 
  23955.            stored in it. 
  23956.  
  23957.  IMAGE COMMAND 
  23958.  
  23959.  When a photo image is created, Tk also creates a new command whose name is the 
  23960.  same as the image. This command may be used to invoke various operations on 
  23961.  the image. It has the following general form: 
  23962.  
  23963.   imageName option ?arg arg ...?
  23964.  Option and the args determine the exact behavior of the command. 
  23965.  
  23966.  Those options that write data to the image generally expand the size of the 
  23967.  image, if necessary, to accommodate the data written to the image, unless the 
  23968.  user has specified non-zero values for the -width and/or -height configuration 
  23969.  options, in which case the width and/or height, respectively, of the image 
  23970.  will not be changed. 
  23971.  
  23972.  The following commands are possible for photo images: 
  23973.  
  23974.  imageName blank  Blank the image; that is, set the entire image to have no 
  23975.            data, so it will be displayed as transparent, and the background of 
  23976.            whatever window it is displayed in will show through. 
  23977.  
  23978.  imageName cget option  Returns the current value of the configuration option 
  23979.            given by option. Option may have any of the values accepted by the 
  23980.            image create photo command. 
  23981.  
  23982.  imageName configure ?option? ?value option value ...?  Query or modify the 
  23983.            configuration options for the image. If no option is specified, 
  23984.            returns a list describing all of the available options for imageName 
  23985.            (see Tk_ConfigureInfo for information on the format of this list). 
  23986.            If option is specified with no value, then the command returns a 
  23987.            list describing the one named option (this list will be identical to 
  23988.            the corresponding sublist of the value returned if no option is 
  23989.            specified).  If one or more option-value pairs are specified, then 
  23990.            the command modifies the given option(s) to have the given value(s); 
  23991.            in this case the command returns an empty string. Option may have 
  23992.            any of the values accepted by the image create photo command. 
  23993.  
  23994.  imageName copy sourceImage ?option value(s) ...?  Copies a region from the 
  23995.            image called sourceImage (which must be a photo image) to the image 
  23996.            called imageName, possibly with pixel zooming and/or subsampling. 
  23997.            If no options are specified, this command copies the whole of 
  23998.            sourceImage into imageName, starting at coordinates (0,0) in 
  23999.            imageName.  The following options may be specified: 
  24000.  
  24001.            -from x1 y1 x2 y2  Specifies a rectangular sub-region of the source 
  24002.                           image to be copied. (x1,y1) and (x2,y2) specify 
  24003.                           diagonally opposite corners of the rectangle.  If x2 
  24004.                           and y2 are not specified, the default value is the 
  24005.                           bottom-right corner of the source image.  The pixels 
  24006.                           copied will include the left and top edges of the 
  24007.                           specified rectangle but not the bottom or right 
  24008.                           edges.  If the -from option is not given, the default 
  24009.                           is the whole source image. 
  24010.  
  24011.            -to x1 y1 x2 y2  Specifies a rectangular sub-region of the 
  24012.                           destination image to be affected.  (x1,y1) and 
  24013.                           (x2,y2) specify diagonally opposite corners of the 
  24014.                           rectangle.  If x2 and y2 are not specified, the 
  24015.                           default value is (x1,y1) plus the size of the source 
  24016.                           region (after subsampling and zooming, if specified). 
  24017.                           If x2 and y2 are specified, the source region will be 
  24018.                           replicated if necessary to fill the destination 
  24019.                           region in a tiled fashion. 
  24020.  
  24021.            -shrink        Specifies that the size of the destination image 
  24022.                           should be reduced, if necessary, so that the region 
  24023.                           being copied into is at the bottom-right corner of 
  24024.                           the image.  This option will not affect the width or 
  24025.                           height of the image if the user has specified a 
  24026.                           non-zero value for the -width or -height 
  24027.                           configuration option, respectively. 
  24028.  
  24029.            -zoom x y      Specifies that the source region should be magnified 
  24030.                           by a factor of x in the X direction and y in the Y 
  24031.                           direction.  If y is not given, the default value is 
  24032.                           the same as x.  With this option, each pixel in the 
  24033.                           source image will be expanded into a block of x x y 
  24034.                           pixels in the destination image, all the same color. 
  24035.                           x and y must be greater than 0. 
  24036.  
  24037.            -subsample x y  Specifies that the source image should be reduced in 
  24038.                           size by using only every xth pixel in the X direction 
  24039.                           and yth pixel in the Y direction.  Negative values 
  24040.                           will cause the image to be flipped about the Y or X 
  24041.                           axes, respectively.  If y is not given, the default 
  24042.                           value is the same as x. 
  24043.  
  24044.  imageName get x y  Returns the color of the pixel at coordinates (x,y) in the 
  24045.            image as a list of three integers between 0 and 255, representing 
  24046.            the red, green and blue components respectively. 
  24047.  
  24048.  imageName put data ?-to x1 y1 x2 y2?  Sets pixels in imageName to the colors 
  24049.            specified in data. data is used to form a two-dimensional array of 
  24050.            pixels that are then copied into the imageName.  data is structured 
  24051.            as a list of horizontal rows, from top to bottom, each of which is a 
  24052.            list of colors, listed from left to right.  Each color may be 
  24053.            specified by name (e.g., blue) or in hexadecimal form (e.g., 
  24054.            #2376af).  The -to option can be used to specify the area of 
  24055.            imageName to be affected.  If only x1 and y1 are given, the area 
  24056.            affected has its top-left corner at (x1,y1) and is the same size as 
  24057.            the array given in data.  If all four coordinates are given, they 
  24058.            specify diagonally opposite corners of the affected rectangle, and 
  24059.            the array given in data will be replicated as necessary in the X and 
  24060.            Y directions to fill the rectangle. 
  24061.  
  24062.  imageName read filename ?option value(s) ...?  Reads image data from the file 
  24063.            named filename into the image. This command first searches the list 
  24064.            of image file format handlers for a handler that can interpret the 
  24065.            data in filename, and then reads the image in filename into 
  24066.            imageName (the destination image).  The following options may be 
  24067.            specified: 
  24068.  
  24069.            -format format-name  Specifies the format of the image data in 
  24070.                           filename. Specifically, only image file format 
  24071.                           handlers whose names begin with format-name will be 
  24072.                           used while searching for an image data format handler 
  24073.                           to read the data. 
  24074.  
  24075.            -from x1 y1 x2 y2  Specifies a rectangular sub-region of the image 
  24076.                           file data to be copied to the destination image.  If 
  24077.                           only x1 and y1 are specified, the region extends from 
  24078.                           (x1,y1) to the bottom-right corner of the image in 
  24079.                           the image file.  If all four coordinates are 
  24080.                           specified, they specify diagonally opposite corners 
  24081.                           or the region. The default, if this option is not 
  24082.                           specified, is the whole of the image in the image 
  24083.                           file. 
  24084.  
  24085.            -shrink        If this option, the size of imageName will be 
  24086.                           reduced, if necessary, so that the region into which 
  24087.                           the image file data are read is at the bottom-right 
  24088.                           corner of the imageName.  This option will not affect 
  24089.                           the width or height of the image if the user has 
  24090.                           specified a non-zero value for the -width or -height 
  24091.                           configuration option, respectively. 
  24092.  
  24093.            -to x y        Specifies the coordinates of the top-left corner of 
  24094.                           the region of imageName into which data from filename 
  24095.                           are to be read. The default is (0,0). 
  24096.  
  24097.  imageName redither  The dithering algorithm used in displaying photo images 
  24098.            propagates quantization errors from one pixel to its neighbors. If 
  24099.            the image data for imageName is supplied in pieces, the dithered 
  24100.            image may not be exactly correct.  Normally the difference is not 
  24101.            noticeable, but if it is a problem, this command can be used to 
  24102.            recalculate the dithered image in each window where the image is 
  24103.            displayed. 
  24104.  
  24105.  imageName write filename ?option value(s) ...?  Writes image data from 
  24106.            imageName to a file named filename. The following options may be 
  24107.            specified: 
  24108.  
  24109.            -format format-name  Specifies the name of the image file format 
  24110.                           handler to be used to write the data to the file. 
  24111.                           Specifically, this subcommand searches for the first 
  24112.                           handler whose name matches a initial substring of 
  24113.                           format-name and which has the capability to write an 
  24114.                           image file.  If this option is not given, this 
  24115.                           subcommand uses the first handler that has the 
  24116.                           capability to write an image file. 
  24117.  
  24118.            -from x1 y1 x2 y2  Specifies a rectangular region of imageName to be 
  24119.                           written to the image file.  If only x1 and y1 are 
  24120.                           specified, the region extends from (x1,y1) to the 
  24121.                           bottom-right corner of imageName.  If all four 
  24122.                           coordinates are given, they specify diagonally 
  24123.                           opposite corners of the rectangular region.  The 
  24124.                           default, if this option is not given, is the whole 
  24125.                           image. 
  24126.  
  24127.  IMAGE FORMATS 
  24128.  
  24129.  The photo image code is structured to allow handlers for additional image file 
  24130.  formats to be added easily.  The photo image code maintains a list of these 
  24131.  handlers.  Handlers are added to the list by registering them with a call to 
  24132.  Tk_CreatePhotoImageFormat.  The standard Tk distribution comes with handlers 
  24133.  for PPM/PGM and GIF formats, which are automatically registered on 
  24134.  initialization. 
  24135.  
  24136.  When reading an image file or processing string data specified with the -data 
  24137.  configuration option, the photo image code invokes each handler in turn until 
  24138.  one is found that claims to be able to read the data in the file or string. 
  24139.  Usually this will find the correct handler, but if it doesn't, the user may 
  24140.  give a format name with the -format option to specify which handler to use. 
  24141.  In fact the photo image code will try those handlers whose names begin with 
  24142.  the string specified for the -format option (the comparison is 
  24143.  case-insensitive).  For example, if the user specifies -format gif, then a 
  24144.  handler named GIF87 or GIF89 may be invoked, but a handler named JPEG may not 
  24145.  (assuming that such handlers had been registered). 
  24146.  
  24147.  When writing image data to a file, the processing of the -format option is 
  24148.  slightly different: the string value given for the -format option must begin 
  24149.  with the complete name of the requested handler, and may contain additional 
  24150.  information following that, which the handler can use, for example, to specify 
  24151.  which variant to use of the formats supported by the handler. 
  24152.  
  24153.  COLOR ALLOCATION 
  24154.  
  24155.  When a photo image is displayed in a window, the photo image code allocates 
  24156.  colors to use to display the image and dithers the image, if necessary, to 
  24157.  display a reasonable approximation to the image using the colors that are 
  24158.  available.  The colors are allocated as a color cube, that is, the number of 
  24159.  colors allocated is the product of the number of shades of red, green and 
  24160.  blue. 
  24161.  
  24162.  Normally, the number of colors allocated is chosen based on the depth of the 
  24163.  window.  For example, in an 8-bit PseudoColor window, the photo image code 
  24164.  will attempt to allocate seven shades of red, seven shades of green and four 
  24165.  shades of blue, for a total of 198 colors.  In a 1-bit StaticGray (monochrome) 
  24166.  window, it will allocate two colors, black and white.  In a 24-bit DirectColor 
  24167.  or TrueColor window, it will allocate 256 shades each of red, green and blue. 
  24168.  Fortunately, because of the way that pixel values can be combined in 
  24169.  DirectColor and TrueColor windows, this only requires 256 colors to be 
  24170.  allocated.  If not all of the colors can be allocated, the photo image code 
  24171.  reduces the number of shades of each primary color and tries again. 
  24172.  
  24173.  The user can exercise some control over the number of colors that a photo 
  24174.  image uses with the -palette configuration option.  If this option is used, it 
  24175.  specifies the maximum number of shades of each primary color to try to 
  24176.  allocate.  It can also be used to force the image to be displayed in shades of 
  24177.  gray, even on a color display, by giving a single number rather than three 
  24178.  numbers separated by slashes. 
  24179.  
  24180.  CREDITS 
  24181.  
  24182.  The photo image type was designed and implemented by Paul Mackerras, based on 
  24183.  his earlier photo widget and some suggestions from John Ousterhout. 
  24184.  
  24185.  KEYWORDS 
  24186.  
  24187.  photo, image, color 
  24188.  
  24189.  
  24190. ΓòÉΓòÉΓòÉ 6.36. place ΓòÉΓòÉΓòÉ
  24191.  
  24192.  NAME 
  24193.  
  24194. place - Geometry manager for fixed or rubber-sheet placement 
  24195.  
  24196. SYNOPSIS 
  24197.  
  24198. place window option value ?option value ...? 
  24199.  place configure window option value ?option value ...? 
  24200.  place forget window 
  24201.  place info window 
  24202.  place slaves window 
  24203.  
  24204. DESCRIPTION 
  24205.  
  24206. The placer is a geometry manager for Tk. It provides simple fixed placement of 
  24207. windows, where you specify the exact size and location of one window, called 
  24208. the slave, within another window, called the master. The placer also provides 
  24209. rubber-sheet placement, where you specify the size and location of the slave in 
  24210. terms of the dimensions of the master, so that the slave changes size and 
  24211. location in response to changes in the size of the master. Lastly, the placer 
  24212. allows you to mix these styles of placement so that, for example, the slave has 
  24213. a fixed width and height but is centered inside the master. 
  24214.  
  24215. If the first argument to the place command is a window path name or configure 
  24216. then the command arranges for the placer to manage the geometry of a slave 
  24217. whose path name is window. The remaining arguments consist of one or more 
  24218. option-value pairs that specify the way in which window's geometry is managed. 
  24219. If the placer is already managing window, then the option-value pairs modify 
  24220. the configuration for window. In this form the place command returns an empty 
  24221. string as result. The following option-value pairs are supported: 
  24222.  
  24223.  -in master  Master specifes the path name of the window relative to which 
  24224.            window is to be placed. Master must either be window's parent or a 
  24225.            descendant of window's parent. In addition, master and window must 
  24226.            both be descendants of the same top-level window. These restrictions 
  24227.            are necessary to guarantee that window is visible whenever master is 
  24228.            visible. If this option isn't specified then the master defaults to 
  24229.            window's parent. 
  24230.  
  24231.  -x location  Location specifies the x-coordinate within the master window of 
  24232.            the anchor point for window. The location is specified in screen 
  24233.            units (i.e. any of the forms accepted by Tk_GetPixels) and need not 
  24234.            lie within the bounds of the master window. 
  24235.  
  24236.  -relx location  Location specifies the x-coordinate within the master window 
  24237.            of the anchor point for window. In this case the location is 
  24238.            specified in a relative fashion as a floating-point number:  0.0 
  24239.            corresponds to the left edge of the master and 1.0 corresponds to 
  24240.            the right edge of the master. Location need not be in the range 
  24241.            0.0-1.0. If both -x and -relx are specified for a slave then their 
  24242.            values are summed.  For example, -relx 0.5 -x -2 positions the left 
  24243.            edge of the slave 2 pixels to the left of the center of its master. 
  24244.  
  24245.  -y location  Location specifies the y-coordinate within the master window of 
  24246.            the anchor point for window. The location is specified in screen 
  24247.            units (i.e. any of the forms accepted by Tk_GetPixels) and need not 
  24248.            lie within the bounds of the master window. 
  24249.  
  24250.  -rely location  Location specifies the y-coordinate within the master window 
  24251.            of the anchor point for window. In this case the value is specified 
  24252.            in a relative fashion as a floating-point number:  0.0 corresponds 
  24253.            to the top edge of the master and 1.0 corresponds to the bottom edge 
  24254.            of the master. Location need not be in the range 0.0-1.0. If both -y 
  24255.            and -rely are specified for a slave then their values are summed. 
  24256.            For example, -rely 0.5 -x 3 positions the top edge of the slave 3 
  24257.            pixels below the center of its master. 
  24258.  
  24259.  -anchor where  Where specifies which point of window is to be positioned at 
  24260.            the (x,y) location selected by the -x, -y, -relx, and -rely options. 
  24261.            The anchor point is in terms of the outer area of window including 
  24262.            its border, if any. Thus if where is se then the lower-right corner 
  24263.            of window's border will appear at the given (x,y) location in the 
  24264.            master. The anchor position defaults to nw. 
  24265.  
  24266.  -width size  Size specifies the width for window in screen units (i.e. any of 
  24267.            the forms accepted by Tk_GetPixels). The width will be the outer 
  24268.            width of window including its border, if any. If size is an empty 
  24269.            string, or if no -width or -relwidth option is specified, then the 
  24270.            width requested internally by the window will be used. 
  24271.  
  24272.  -relwidth size  Size specifies the width for window. In this case the width is 
  24273.            specified as a floating-point number relative to the width of the 
  24274.            master: 0.5 means window will be half as wide as the master, 1.0 
  24275.            means window will have the same width as the master, and so on. If 
  24276.            both -width and -relwidth are specified for a slave, their values 
  24277.            are summed.  For example, -relwidth 1.0 -width 5 makes the slave 5 
  24278.            pixels wider than the master. 
  24279.  
  24280.  -height size  Size specifies the height for window in screen units (i.e. any 
  24281.            of the forms accepted by Tk_GetPixels). The height will be the outer 
  24282.            dimension of window including its border, if any. If size is an 
  24283.            empty string, or if no -height or -relheight option is specified, 
  24284.            then the height requested internally by the window will be used. 
  24285.  
  24286.  -relheight size  Size specifies the height for window. In this case the height 
  24287.            is specified as a floating-point number relative to the height of 
  24288.            the master: 0.5 means window will be half as high as the master, 1.0 
  24289.            means window will have the same height as the master, and so on. If 
  24290.            both -height and -relheight are specified for a slave, their values 
  24291.            are summed.  For example, -relheight 1.0 -height -2 makes the slave 
  24292.            2 pixels shorter than the master. 
  24293.  
  24294.  -bordermode mode  Mode determines the degree to which borders within the 
  24295.            master are used in determining the placement of the slave. The 
  24296.            default and most common value is inside. In this case the placer 
  24297.            considers the area of the master to be the innermost area of the 
  24298.            master, inside any border: an option of -x 0 corresponds to an 
  24299.            x-coordinate just inside the border and an option of -relwidth 1.0 
  24300.            means window will fill the area inside the master's border. If mode 
  24301.            is outside then the placer considers the area of the master to 
  24302.            include its border; this mode is typically used when placing window 
  24303.            outside its master, as with the options -x 0 -y 0 -anchor ne. 
  24304.            Lastly, mode may be specified as ignore, in which case borders are 
  24305.            ignored:  the area of the master is considered to be its official X 
  24306.            area, which includes any internal border but no external border.  A 
  24307.            bordermode of ignore is probably not very useful. 
  24308.  
  24309.  If the same value is specified separately with two different options, such as 
  24310.  -x and -relx, then the most recent option is used and the older one is 
  24311.  ignored. 
  24312.  
  24313.  The place slaves command returns a list of all the slave windows for which 
  24314.  window is the master. If there are no slaves for window then an empty string 
  24315.  is returned. 
  24316.  
  24317.  The place forget command causes the placer to stop managing the geometry of 
  24318.  window.  As a side effect of this command window will be unmapped so that it 
  24319.  doesn't appear on the screen. If window isn't currently managed by the placer 
  24320.  then the command has no effect. Place forget returns an empty string as 
  24321.  result. 
  24322.  
  24323.  The place info command returns a list giving the current configuration of 
  24324.  window. The list consists of option-value pairs in exactly the same form as 
  24325.  might be specified to the place configure command. If the configuration of a 
  24326.  window has been retrieved with place info, that configuration can be restored 
  24327.  later by first using place forget to erase any existing information for the 
  24328.  window and then invoking place configure with the saved information. 
  24329.  
  24330.  FINE POINTS 
  24331.  
  24332.  It is not necessary for the master window to be the parent of the slave 
  24333.  window. This feature is useful in at least two situations. First, for complex 
  24334.  window layouts it means you can create a hierarchy of subwindows whose only 
  24335.  purpose is to assist in the layout of the parent. The "real children" of the 
  24336.  parent (i.e. the windows that are significant for the application's user 
  24337.  interface) can be children of the parent yet be placed inside the windows of 
  24338.  the geometry-management hierarchy. This means that the path names of the "real 
  24339.  children" don't reflect the geometry-management hierarchy and users can 
  24340.  specify options for the real children without being aware of the structure of 
  24341.  the geometry-management hierarchy. 
  24342.  
  24343.  A second reason for having a master different than the slave's parent is to 
  24344.  tie two siblings together. For example, the placer can be used to force a 
  24345.  window always to be positioned centered just below one of its siblings by 
  24346.  specifying the configuration 
  24347.  
  24348.   -in sibling -relx 0.5 -rely 1.0 -anchor n -bordermode outside
  24349.  Whenever the sibling is repositioned in the future, the slave will be 
  24350.  repositioned as well. 
  24351.  
  24352.  Unlike many other geometry managers (such as the packer) the placer does not 
  24353.  make any attempt to manipulate the geometry of the master windows or the 
  24354.  parents of slave windows (i.e. it doesn't set their requested sizes). To 
  24355.  control the sizes of these windows, make them windows like frames and canvases 
  24356.  that provide configuration options for this purpose. 
  24357.  
  24358.  KEYWORDS 
  24359.  
  24360.  geometry manager, height, location, master, place, rubber sheet, slave, width 
  24361.  
  24362.  
  24363. ΓòÉΓòÉΓòÉ 6.37. tk_popup ΓòÉΓòÉΓòÉ
  24364.  
  24365.  NAME 
  24366.  
  24367. tk_popup - Post a popup menu 
  24368.  
  24369. SYNOPSIS 
  24370.  
  24371. tk_popup menu x y ?entry? 
  24372.  
  24373. DESCRIPTION 
  24374.  
  24375. This procedure posts a menu at a given position on the screen and configures Tk 
  24376. so that the menu and its cascaded children can be traversed with the mouse or 
  24377. the keyboard. Menu is the name of a menu widget and x and y are the root 
  24378. coordinates at which to display the menu. If entry is omitted or an empty 
  24379. string, the menu's upper left corner is positioned at the given point. 
  24380. Otherwise entry gives the index of an entry in menu and the menu will be 
  24381. positioned so that the entry is positioned over the given point. 
  24382.  
  24383. KEYWORDS 
  24384.  
  24385. menu, popup 
  24386.  
  24387.  
  24388. ΓòÉΓòÉΓòÉ 6.38. radiobutton ΓòÉΓòÉΓòÉ
  24389.  
  24390.  NAME 
  24391.  
  24392. radiobutton - Create and manipulate radiobutton widgets 
  24393.  
  24394. SYNOPSIS 
  24395.  
  24396. radiobutton pathName ?options? 
  24397.  
  24398. STANDARD OPTIONS 
  24399.  
  24400. -activebackground    -cursor              -highlightthickness  -takefocus
  24401. -activeforeground    -disabledforeground  -image               -text
  24402. -anchor              -font                -justify             -textvariable
  24403. -background          -foreground          -padx                -underline
  24404. -bitmap              -highlightbackground -pady                -wraplength
  24405. -borderwidth         -highlightcolor      -relief
  24406.  
  24407. See the options manual entry for detailed descriptions of the above options.
  24408.  
  24409. WIDGET-SPECIFIC OPTIONS 
  24410.  
  24411.   Command-Line Name:    -command
  24412.   Database Name:        command
  24413.   Database Class:       Command
  24414.  
  24415.            Specifies a Tcl command to associate with the button.  This command 
  24416.            is typically invoked when mouse button 1 is released over the button 
  24417.            window.  The button's global variable (-variable option) will be 
  24418.            updated before the command is invoked. 
  24419.  
  24420.   Command-Line Name:    -height
  24421.   Database Name:        height
  24422.   Database Class:       Height
  24423.  
  24424.            Specifies a desired height for the button. If an image or bitmap is 
  24425.            being displayed in the button then the value is in screen units 
  24426.            (i.e. any of the forms acceptable to Tk_GetPixels); for text it is 
  24427.            in lines of text. If this option isn't specified, the button's 
  24428.            desired height is computed from the size of the image or bitmap or 
  24429.            text being displayed in it. 
  24430.  
  24431.   Command-Line Name:    -indicatoron
  24432.   Database Name:        indicatorOn
  24433.   Database Class:       IndicatorOn
  24434.  
  24435.            Specifies whether or not the indicator should be drawn.  Must be a 
  24436.            proper boolean value.  If false, the relief option is ignored and 
  24437.            the widget's relief is always sunken if the widget is selected and 
  24438.            raised otherwise. 
  24439.  
  24440.   Command-Line Name:    -selectcolor
  24441.   Database Name:        selectColor
  24442.   Database Class:       Background
  24443.  
  24444.            Specifies a background color to use when the button is selected. If 
  24445.            indicatorOn is true, the color applicies to the indicator. If 
  24446.            indicatorOn is false, this color is used as the background for the 
  24447.            entire widget, in place of background or activeBackground, whenever 
  24448.            the widget is selected. If specified as an empty string, no special 
  24449.            color is used for displaying when the widget is selected. 
  24450.  
  24451.   Command-Line Name:    -selectimage
  24452.   Database Name:        selectImage
  24453.   Database Class:       SelectImage
  24454.  
  24455.            Specifies an image to display (in place of the image option) when 
  24456.            the radiobutton is selected. This option is ignored unless the image 
  24457.            option has been specified. 
  24458.  
  24459.   Command-Line Name:    -state
  24460.   Database Name:        state
  24461.   Database Class:       State
  24462.  
  24463.            Specifies one of three states for the radiobutton:  normal, active, 
  24464.            or disabled.  In normal state the radiobutton is displayed using the 
  24465.            foreground and background options.  The active state is typically 
  24466.            used when the pointer is over the radiobutton.  In active state the 
  24467.            radiobutton is displayed using the activeForeground and 
  24468.            activeBackground options.  Disabled state means that the radiobutton 
  24469.            should be insensitive:  the default bindings will refuse to activate 
  24470.            the widget and will ignore mouse button presses. In this state the 
  24471.            disabledForeground and background options determine how the 
  24472.            radiobutton is displayed. 
  24473.  
  24474.   Command-Line Name:    -value
  24475.   Database Name:        value
  24476.   Database Class:       Value
  24477.  
  24478.            Specifies value to store in the button's associated variable 
  24479.            whenever this button is selected. 
  24480.  
  24481.   Command-Line Name:    -variable
  24482.   Database Name:        variable
  24483.   Database Class:       Variable
  24484.  
  24485.            Specifies name of global variable to set whenever this button is 
  24486.            selected.  Changes in this variable also cause the button to select 
  24487.            or deselect itself. Defaults to the value selectedButton. 
  24488.  
  24489.   Command-Line Name:    -width
  24490.   Database Name:        width
  24491.   Database Class:       Width
  24492.  
  24493.            Specifies a desired width for the button. If an image or bitmap is 
  24494.            being displayed in the button, the value is in screen units (i.e. 
  24495.            any of the forms acceptable to Tk_GetPixels); for text it is in 
  24496.            characters. If this option isn't specified, the button's desired 
  24497.            width is computed from the size of the image or bitmap or text being 
  24498.            displayed in it. 
  24499.  
  24500.  DESCRIPTION 
  24501.  
  24502.  The radiobutton command creates a new window (given by the pathName argument) 
  24503.  and makes it into a radiobutton widget. Additional options, described above, 
  24504.  may be specified on the command line or in the option database to configure 
  24505.  aspects of the radiobutton such as its colors, font, text, and initial relief. 
  24506.  The radiobutton command returns its pathName argument.  At the time this 
  24507.  command is invoked, there must not exist a window named pathName, but 
  24508.  pathName's parent must exist. 
  24509.  
  24510.  A radiobutton is a widget that displays a textual string, bitmap or image and 
  24511.  a diamond called an indicator. If text is displayed, it must all be in a 
  24512.  single font, but it can occupy multiple lines on the screen (if it contains 
  24513.  newlines or if wrapping occurs because of the wrapLength option) and one of 
  24514.  the characters may optionally be underlined using the underline option.  A 
  24515.  radiobutton has all of the behavior of a simple button: it can display itself 
  24516.  in either of three different ways, according to the state option; it can be 
  24517.  made to appear raised, sunken, or flat; it can be made to flash; and it 
  24518.  invokes a Tcl command whenever mouse button 1 is clicked over the check 
  24519.  button. 
  24520.  
  24521.  In addition, radiobuttons can be selected. If a radiobutton is selected, the 
  24522.  indicator is normally drawn with a sunken relief and a special color, and a 
  24523.  Tcl variable associated with the radiobutton is set to a particular value. If 
  24524.  the radiobutton is not selected, the indicator is drawn with a raised relief 
  24525.  and no special color. Typically, several radiobuttons share a single variable 
  24526.  and the value of the variable indicates which radiobutton is to be selected. 
  24527.  When a radiobutton is selected it sets the value of the variable to indicate 
  24528.  that fact;  each radiobutton also monitors the value of the variable and 
  24529.  automatically selects and deselects itself when the variable's value changes. 
  24530.  By default the variable selectedButton is used;  its contents give the name of 
  24531.  the button that is selected, or the empty string if no button associated with 
  24532.  that variable is selected. The name of the variable for a radiobutton, plus 
  24533.  the variable to be stored into it, may be modified with options on the command 
  24534.  line or in the option database. Configuration options may also be used to 
  24535.  modify the way the indicator is displayed (or whether it is displayed at all). 
  24536.  By default a radiobutton is configured to select itself on button clicks. 
  24537.  
  24538.  WIDGET COMMAND 
  24539.  
  24540.  The radiobutton command creates a new Tcl command whose name is pathName. 
  24541.  This command may be used to invoke various operations on the widget.  It has 
  24542.  the following general form: 
  24543.  
  24544.   pathName option ?arg arg ...?
  24545.  Option and the args determine the exact behavior of the command.  The 
  24546.  following commands are possible for radiobutton widgets: 
  24547.  
  24548.  pathName cget option  Returns the current value of the configuration option 
  24549.            given by option. Option may have any of the values accepted by the 
  24550.            radiobutton command. 
  24551.  
  24552.  pathName configure ?option? ?value option value ...?  Query or modify the 
  24553.            configuration options of the widget. If no option is specified, 
  24554.            returns a list describing all of the available options for pathName 
  24555.            (see Tk_ConfigureInfo for information on the format of this list). 
  24556.            If option is specified with no value, the command returns a list 
  24557.            describing the one named option (this list will be identical to the 
  24558.            corresponding sublist of the value returned if no option is 
  24559.            specified).  If one or more option-value pairs are specified, the 
  24560.            command modifies the given widget option(s) to have the given 
  24561.            value(s);  in this case the command returns an empty string. Option 
  24562.            may have any of the values accepted by the radiobutton command. 
  24563.  
  24564.  pathName deselect  Deselects the radiobutton and sets the associated variable 
  24565.            to an empty string. If this radiobutton was not currently selected, 
  24566.            the command has no effect. 
  24567.  
  24568.  pathName flash  Flashes the radiobutton.  This is accomplished by redisplaying 
  24569.            the radiobutton several times, alternating between active and normal 
  24570.            colors.  At the end of the flash the radiobutton is left in the same 
  24571.            normal/active state as when the command was invoked. This command is 
  24572.            ignored if the radiobutton's state is disabled. 
  24573.  
  24574.  pathName invoke  Does just what would have happened if the user invoked the 
  24575.            radiobutton with the mouse: selects the button and invokes its 
  24576.            associated Tcl command, if there is one. The return value is the 
  24577.            return value from the Tcl command, or an empty string if there is no 
  24578.            command associated with the radiobutton. This command is ignored if 
  24579.            the radiobutton's state is disabled. 
  24580.  
  24581.  pathName select  Selects the radiobutton and sets the associated variable to 
  24582.            the value corresponding to this widget. 
  24583.  
  24584.  BINDINGS 
  24585.  
  24586.  Tk automatically creates class bindings for radiobuttons that give them the 
  24587.  following default behavior: 
  24588.  
  24589.    1. The radiobutton activates whenever the mouse passes over it and 
  24590.       deactivates whenever the mouse leaves the radiobutton. 
  24591.  
  24592.    2. When mouse button 1 is pressed over a radiobutton it is invoked (it 
  24593.       becomes selected and the command associated with the button is invoked, 
  24594.       if there is one). 
  24595.  
  24596.    3. When a radiobutton has the input focus, the space key causes the 
  24597.       radiobutton to be invoked. 
  24598.  
  24599.  If the radiobutton's state is disabled then none of the above actions occur: 
  24600.  the radiobutton is completely non-responsive. 
  24601.  
  24602.  The behavior of radiobuttons can be changed by defining new bindings for 
  24603.  individual widgets or by redefining the class bindings. 
  24604.  
  24605.  KEYWORDS 
  24606.  
  24607.  radiobutton, widget 
  24608.  
  24609.  
  24610. ΓòÉΓòÉΓòÉ 6.39. raise ΓòÉΓòÉΓòÉ
  24611.  
  24612.  NAME 
  24613.  
  24614. raise - Change a window's position in the stacking order 
  24615.  
  24616. SYNOPSIS 
  24617.  
  24618. raise window ?aboveThis? 
  24619.  
  24620. DESCRIPTION 
  24621.  
  24622. If the aboveThis argument is omitted then the command raises window so that it 
  24623. is above all of its siblings in the stacking order (it will not be obscured by 
  24624. any siblings and will obscure any siblings that overlap it). If aboveThis is 
  24625. specified then it must be the path name of a window that is either a sibling of 
  24626. window or the descendant of a sibling of window. In this case the raise command 
  24627. will insert window into the stacking order just above aboveThis (or the 
  24628. ancestor of aboveThis that is a sibling of window); this could end up either 
  24629. raising or lowering window. 
  24630.  
  24631. SEE ALSO 
  24632.  
  24633. lower 
  24634.  
  24635. KEYWORDS 
  24636.  
  24637. obscure, raise, stacking order 
  24638.  
  24639.  
  24640. ΓòÉΓòÉΓòÉ 6.40. scale ΓòÉΓòÉΓòÉ
  24641.  
  24642.  NAME 
  24643.  
  24644. scale - Create and manipulate scale widgets 
  24645.  
  24646. SYNOPSIS 
  24647.  
  24648. scale pathName ?options? 
  24649.  
  24650. STANDARD OPTIONS 
  24651.  
  24652. -activebackground    -font                -highlightthickness  -repeatinterval
  24653. -background          -foreground          -orient              -takefocus
  24654. -borderwidth         -highlightbackground -relief              -troughcolor
  24655. -cursor              -highlightcolor      -repeatdelay
  24656.  
  24657. See the options manual entry for detailed descriptions of the above options.
  24658.  
  24659. WIDGET-SPECIFIC OPTIONS 
  24660.  
  24661.   Command-Line Name:    -bigincrement
  24662.   Database Name:        bigIncrement
  24663.   Database Class:       BigIncrement
  24664.  
  24665.            Some interactions with the scale cause its value to change by 
  24666.            "large" increments;  this option specifies the size of the large 
  24667.            increments.  If specified as 0, the large increments default to 1/10 
  24668.            the range of the scale. 
  24669.  
  24670.   Command-Line Name:    -command
  24671.   Database Name:        command
  24672.   Database Class:       Command
  24673.  
  24674.            Specifies the prefix of a Tcl command to invoke whenever the scale's 
  24675.            value is changed via a widget command. The actual command consists 
  24676.            of this option followed by a space and a real number indicating the 
  24677.            new value of the scale. 
  24678.  
  24679.   Command-Line Name:    -digits
  24680.   Database Name:        digits
  24681.   Database Class:       Digits
  24682.  
  24683.            An integer specifying how many significant digits should be retained 
  24684.            when converting the value of the scale to a string. If the number is 
  24685.            less than or equal to zero, then the scale picks the smallest value 
  24686.            that guarantees that every possible slider position prints as a 
  24687.            different string. 
  24688.  
  24689.   Command-Line Name:    -from
  24690.   Database Name:        from
  24691.   Database Class:       From
  24692.  
  24693.            A real value corresponding to the left or top end of the scale. 
  24694.  
  24695.   Command-Line Name:    -label
  24696.   Database Name:        label
  24697.   Database Class:       Label
  24698.  
  24699.            A string to display as a label for the scale.  For vertical scales 
  24700.            the label is displayed just to the right of the top end of the 
  24701.            scale.  For horizontal scales the label is displayed just above the 
  24702.            left end of the scale.  If the option is specified as an empty 
  24703.            string, no label is displayed. 
  24704.  
  24705.   Command-Line Name:    -length
  24706.   Database Name:        length
  24707.   Database Class:       Length
  24708.  
  24709.            Specifies the desired long dimension of the scale in screen units 
  24710.            (i.e. any of the forms acceptable to Tk_GetPixels). For vertical 
  24711.            scales this is the scale's height;  for horizontal scales it is the 
  24712.            scale's width. 
  24713.  
  24714.   Command-Line Name:    -resolution
  24715.   Database Name:        resolution
  24716.   Database Class:       Resolution
  24717.  
  24718.            A real value specifying the resolution for the scale. If this value 
  24719.            is greater than zero then the scale's value will always be rounded 
  24720.            to an even multiple of this value, as will tick marks and the 
  24721.            endpoints of the scale.  If the value is less than zero then no 
  24722.            rounding occurs.  Defaults to 1 (i.e., the value will be integral). 
  24723.  
  24724.   Command-Line Name:    -showvalue
  24725.   Database Name:        showValue
  24726.   Database Class:       ShowValue
  24727.  
  24728.            Specifies a boolean value indicating whether or not the current 
  24729.            value of the scale is to be displayed. 
  24730.  
  24731.   Command-Line Name:    -sliderlength
  24732.   Database Name:        sliderLength
  24733.   Database Class:       SliderLength
  24734.  
  24735.            Specfies the size of the slider, measured in screen units along the 
  24736.            slider's long dimension.  The value may be specified in any of the 
  24737.            forms acceptable to Tk_GetPixels. 
  24738.  
  24739.   Command-Line Name:    -sliderrelief
  24740.   Database Name:        sliderRelief
  24741.   Database Class:       SliderRelief
  24742.  
  24743.            Specifies the relief to use when drawing the slider, such as raised 
  24744.            or sunken. 
  24745.  
  24746.   Command-Line Name:    -state
  24747.   Database Name:        state
  24748.   Database Class:       State
  24749.  
  24750.            Specifies one of three states for the scale:  normal, active, or 
  24751.            disabled. If the scale is disabled then the value may not be changed 
  24752.            and the scale won't activate. If the scale is active, the slider is 
  24753.            displayed using the color specified by the activeBackground option. 
  24754.  
  24755.   Command-Line Name:    -tickinterval
  24756.   Database Name:        tickInterval
  24757.   Database Class:       TickInterval
  24758.  
  24759.            Must be a real value. Determines the spacing between numerical tick 
  24760.            marks displayed below or to the left of the slider. If 0, no tick 
  24761.            marks will be displayed. 
  24762.  
  24763.   Command-Line Name:    -to
  24764.   Database Name:        to
  24765.   Database Class:       To
  24766.  
  24767.            Specifies a real value corresponding to the right or bottom end of 
  24768.            the scale. This value may be either less than or greater than the 
  24769.            from option. 
  24770.  
  24771.   Command-Line Name:    -variable
  24772.   Database Name:        variable
  24773.   Database Class:       Variable
  24774.  
  24775.            Specifies the name of a global variable to link to the scale. 
  24776.            Whenever the value of the variable changes, the scale will update to 
  24777.            reflect this value. Whenever the scale is manipulated interactively, 
  24778.            the variable will be modified to reflect the scale's new value. 
  24779.  
  24780.   Command-Line Name:    -width
  24781.   Database Name:        width
  24782.   Database Class:       Width
  24783.  
  24784.            Specifies the desired narrow dimension of the trough in screen units 
  24785.            (i.e. any of the forms acceptable to Tk_GetPixels). For vertical 
  24786.            scales this is the trough's width;  for horizontal scales this is 
  24787.            the trough's height. 
  24788.  
  24789.  DESCRIPTION 
  24790.  
  24791.  The scale command creates a new window (given by the pathName argument) and 
  24792.  makes it into a scale widget. Additional options, described above, may be 
  24793.  specified on the command line or in the option database to configure aspects 
  24794.  of the scale such as its colors, orientation, and relief.  The scale command 
  24795.  returns its pathName argument.  At the time this command is invoked, there 
  24796.  must not exist a window named pathName, but pathName's parent must exist. 
  24797.  
  24798.  A scale is a widget that displays a rectangular trough and a small slider. 
  24799.  The trough corresponds to a range of real values (determined by the from, to, 
  24800.  and resolution options), and the position of the slider selects a particular 
  24801.  real value. The slider's position (and hence the scale's value) may be 
  24802.  adjusted with the mouse or keyboard as described in the BINDINGS section 
  24803.  below.  Whenever the scale's value is changed, a Tcl command is invoked (using 
  24804.  the command option) to notify other interested widgets of the change. In 
  24805.  addition, the value of the scale can be linked to a Tcl variable (using the 
  24806.  variable option), so that changes in either are reflected in the other. 
  24807.  
  24808.  Three annotations may be displayed in a scale widget:  a label appearing at 
  24809.  the top right of the widget (top left for horizontal scales), a number 
  24810.  displayed just to the left of the slider (just above the slider for horizontal 
  24811.  scales), and a collection of numerical tick marks just to the left of the 
  24812.  current value (just below the trough for horizontal scales).  Each of these 
  24813.  three annotations may be enabled or disabled using the configuration options. 
  24814.  
  24815.  WIDGET COMMAND 
  24816.  
  24817.  The scale command creates a new Tcl command whose name is pathName.  This 
  24818.  command may be used to invoke various operations on the widget.  It has the 
  24819.  following general form: 
  24820.  
  24821.   pathName option ?arg arg ...?
  24822.  Option and the args determine the exact behavior of the command.  The 
  24823.  following commands are possible for scale widgets: 
  24824.  
  24825.  pathName cget option  Returns the current value of the configuration option 
  24826.            given by option. Option may have any of the values accepted by the 
  24827.            scale command. 
  24828.  
  24829.  pathName configure ?option? ?value option value ...?  Query or modify the 
  24830.            configuration options of the widget. If no option is specified, 
  24831.            returns a list describing all of the available options for pathName 
  24832.            (see Tk_ConfigureInfo for information on the format of this list). 
  24833.            If option is specified with no value, then the command returns a 
  24834.            list describing the one named option (this list will be identical to 
  24835.            the corresponding sublist of the value returned if no option is 
  24836.            specified).  If one or more option-value pairs are specified, then 
  24837.            the command modifies the given widget option(s) to have the given 
  24838.            value(s);  in this case the command returns an empty string. Option 
  24839.            may have any of the values accepted by the scale command. 
  24840.  
  24841.  pathName coords ?value?  Returns a list whose elements are the x and y 
  24842.            coordinates of the point along the centerline of the trough that 
  24843.            corresponds to value. If value is omitted then the scale's current 
  24844.            value is used. 
  24845.  
  24846.  pathName get ?x y?  If x and y are omitted, returns the current value of the 
  24847.            scale.  If x and y are specified, they give pixel coordinates within 
  24848.            the widget;  the command returns the scale value corresponding to 
  24849.            the given pixel. Only one of x or y is used:  for horizontal scales 
  24850.            y is ignored, and for vertical scales x is ignored. 
  24851.  
  24852.  pathName identify x y  Returns a string indicating what part of the scale lies 
  24853.            under the coordinates given by x and y. A return value of slider 
  24854.            means that the point is over the slider;  trough1 means that the 
  24855.            point is over the portion of the slider above  or to the left of the 
  24856.            slider; and trough2 means that the point is over the portion of the 
  24857.            slider below or to the right of the slider. If the point isn't over 
  24858.            one of these elements, an empty string is returned. 
  24859.  
  24860.  pathName set value  This command is invoked to change the current value of the 
  24861.            scale, and hence the position at which the slider is displayed. 
  24862.            Value gives the new value for the scale. The command has no effect 
  24863.            if the scale is disabled. 
  24864.  
  24865.  BINDINGS 
  24866.  
  24867.  Tk automatically creates class bindings for scales that give them the 
  24868.  following default behavior. Where the behavior is different for vertical and 
  24869.  horizontal scales, the horizontal behavior is described in parentheses. 
  24870.  
  24871.    1. If button 1 is pressed in the trough, the scale's value will be 
  24872.       incremented or decremented by the value of the resolution option so that 
  24873.       the slider moves in the direction of the cursor. If the button is held 
  24874.       down, the action auto-repeats. 
  24875.  
  24876.    2. If button 1 is pressed over the slider, the slider can be dragged with 
  24877.       the mouse. 
  24878.  
  24879.    3. If button 1 is pressed in the trough with the Control key down, the 
  24880.       slider moves all the way to the end of its range, in the direction 
  24881.       towards the mouse cursor. 
  24882.  
  24883.    4. If button 2 is pressed, the scale's value is set to the mouse position. 
  24884.       If the mouse is dragged with button 2 down, the scale's value changes 
  24885.       with the drag. 
  24886.  
  24887.    5. The Up and Left keys move the slider up (left) by the value of the 
  24888.       resolution option. 
  24889.  
  24890.    6. The Down and Right keys move the slider down (right) by the value of the 
  24891.       resolution option. 
  24892.  
  24893.    7. Control-Up and Control-Left move the slider up (left) by the value of the 
  24894.       bigIncrement option. 
  24895.  
  24896.    8. Control-Down and Control-Right move the slider down (right) by the value 
  24897.       of the bigIncrement option. 
  24898.  
  24899.    9. Home moves the slider to the top (left) end of its range. 
  24900.  
  24901.   10. End moves the slider to the bottom (right) end of its range. 
  24902.  
  24903.  If the scale is disabled using the state option then none of the above 
  24904.  bindings have any effect. 
  24905.  
  24906.  The behavior of scales can be changed by defining new bindings for individual 
  24907.  widgets or by redefining the class bindings. 
  24908.  
  24909.  KEYWORDS 
  24910.  
  24911.  scale, slider, trough, widget 
  24912.  
  24913.  
  24914. ΓòÉΓòÉΓòÉ 6.41. scrollbar ΓòÉΓòÉΓòÉ
  24915.  
  24916.  NAME 
  24917.  
  24918. scrollbar - Create and manipulate scrollbar widgets 
  24919.  
  24920. SYNOPSIS 
  24921.  
  24922. scrollbar pathName ?options? 
  24923.  
  24924. STANDARD OPTIONS 
  24925.  
  24926. -activebackground    -highlightbackground -orient              -takefocus
  24927. -background          -highlightcolor      -relief              -troughcolor
  24928. -borderwidth         -highlightthickness  -repeatdelay
  24929. -cursor              -jump                -repeatinterval
  24930.  
  24931. See the options manual entry for detailed descriptions of the above options.
  24932.  
  24933. WIDGET-SPECIFIC OPTIONS 
  24934.  
  24935.   Command-Line Name:    -activerelief
  24936.   Database Name:        activeRelief
  24937.   Database Class:       ActiveRelief
  24938.  
  24939.            Specifies the relief to use when displaying the element that is 
  24940.            active, if any. Elements other than the active element are always 
  24941.            displayed with a raised relief. 
  24942.  
  24943.   Command-Line Name:    -command
  24944.   Database Name:        command
  24945.   Database Class:       Command
  24946.  
  24947.            Specifies the prefix of a Tcl command to invoke to change the view 
  24948.            in the widget associated with the scrollbar.  When a user requests a 
  24949.            view change by manipulating the scrollbar, a Tcl command is invoked. 
  24950.            The actual command consists of this option followed by additional 
  24951.            information as described later.  This option almost always has a 
  24952.            value such as .t xview or .t yview, consisting of the name of a 
  24953.            widget and either xview (if the scrollbar is for horizontal 
  24954.            scrolling) or yview (for vertical scrolling). All scrollable widgets 
  24955.            have xview and yview commands that take exactly the additional 
  24956.            arguments appended by the scrollbar as described in SCROLLING 
  24957.            COMMANDS below. 
  24958.  
  24959.   Command-Line Name:    -elementborderwidth
  24960.   Database Name:        elementBorderWidth
  24961.   Database Class:       BorderWidth
  24962.  
  24963.            Specifies the width of borders drawn around the internal elements of 
  24964.            the scrollbar (the two arrows and the slider).  The value may have 
  24965.            any of the forms acceptable to Tk_GetPixels. If this value is less 
  24966.            than zero, the value of the borderWidth option is used in its place. 
  24967.  
  24968.   Command-Line Name:    -width
  24969.   Database Name:        width
  24970.   Database Class:       Width
  24971.  
  24972.            Specifies the desired narrow dimension of the scrollbar window, not 
  24973.            including 3-D border, if any.  For vertical scrollbars this will be 
  24974.            the width and for horizontal scrollbars this will be the height. The 
  24975.            value may have any of the forms acceptable to Tk_GetPixels. 
  24976.  
  24977.  DESCRIPTION 
  24978.  
  24979.  The scrollbar command creates a new window (given by the pathName argument) 
  24980.  and makes it into a scrollbar widget. Additional options, described above, may 
  24981.  be specified on the command line or in the option database to configure 
  24982.  aspects of the scrollbar such as its colors, orientation, and relief. The 
  24983.  scrollbar command returns its pathName argument. At the time this command is 
  24984.  invoked, there must not exist a window named pathName, but pathName's parent 
  24985.  must exist. 
  24986.  
  24987.  A scrollbar is a widget that displays two arrows, one at each end of the 
  24988.  scrollbar, and a slider in the middle portion of the scrollbar. It provides 
  24989.  information about what is visible in an associated window that displays an 
  24990.  document of some sort (such as a file being edited or a drawing). The position 
  24991.  and size of the slider indicate which portion of the document is visible in 
  24992.  the associated window.  For example, if the slider in a vertical scrollbar 
  24993.  covers the top third of the area between the two arrows, it means that the 
  24994.  associated window displays the top third of its document. 
  24995.  
  24996.  Scrollbars can be used to adjust the view in the associated window by clicking 
  24997.  or dragging with the mouse.  See the BINDINGS section below for details. 
  24998.  
  24999.  ELEMENTS 
  25000.  
  25001.  A scrollbar displays five elements, which are referred to in the widget 
  25002.  commands for the scrollbar: 
  25003.  
  25004.  arrow1    The top or left arrow in the scrollbar. 
  25005.  
  25006.  trough1   The region between the slider and arrow1. 
  25007.  
  25008.  slider    The rectangle that indicates what is visible in the associated 
  25009.            widget. 
  25010.  
  25011.  trough2   The region between the slider and arrow2. 
  25012.  
  25013.  arrow2    The bottom or right arrow in the scrollbar. 
  25014.  
  25015.  WIDGET COMMAND 
  25016.  
  25017.  The scrollbar command creates a new Tcl command whose name is pathName.  This 
  25018.  command may be used to invoke various operations on the widget.  It has the 
  25019.  following general form: 
  25020.  
  25021.   pathName option ?arg arg ...?
  25022.  Option and the args determine the exact behavior of the command.  The 
  25023.  following commands are possible for scrollbar widgets: 
  25024.  
  25025.  pathName activate ?element?  Marks the element indicated by element as active, 
  25026.            which causes it to be displayed as specified by the activeBackground 
  25027.            and activeRelief options. The only element values understood by this 
  25028.            command are arrow1, slider, or arrow2. If any other value is 
  25029.            specified then no element of the scrollbar will be active. If 
  25030.            element is not specified, the command returns the name of the 
  25031.            element that is currently active, or an empty string if no element 
  25032.            is active. 
  25033.  
  25034.  pathName cget option  Returns the current value of the configuration option 
  25035.            given by option. Option may have any of the values accepted by the 
  25036.            scrollbar command. 
  25037.  
  25038.  pathName configure ?option? ?value option value ...?  Query or modify the 
  25039.            configuration options of the widget. If no option is specified, 
  25040.            returns a list describing all of the available options for pathName 
  25041.            (see Tk_ConfigureInfo for information on the format of this list). 
  25042.            If option is specified with no value, then the command returns a 
  25043.            list describing the one named option (this list will be identical to 
  25044.            the corresponding sublist of the value returned if no option is 
  25045.            specified).  If one or more option-value pairs are specified, then 
  25046.            the command modifies the given widget option(s) to have the given 
  25047.            value(s);  in this case the command returns an empty string. Option 
  25048.            may have any of the values accepted by the scrollbar command. 
  25049.  
  25050.  pathName delta deltaX deltaY  Returns a real number indicating the fractional 
  25051.            change in the scrollbar setting that corresponds to a given change 
  25052.            in slider position.  For example, if the scrollbar is horizontal, 
  25053.            the result indicates how much the scrollbar setting must change to 
  25054.            move the slider deltaX pixels to the right (deltaY is ignored in 
  25055.            this case). If the scrollbar is vertical, the result indicates how 
  25056.            much the scrollbar setting must change to move the slider deltaY 
  25057.            pixels down.  The arguments and the result may be zero or negative. 
  25058.  
  25059.  pathName fraction x y  Returns a real number between 0 and 1 indicating where 
  25060.            the point given by x and y lies in the trough area of the scrollbar. 
  25061.            The value 0 corresponds to the top or left of the trough, the value 
  25062.            1 corresponds to the bottom or right, 0.5 corresponds to the middle, 
  25063.            and so on. X and y must be pixel coordinates relative to the 
  25064.            scrollbar widget. If x and y refer to a point outside the trough, 
  25065.            the closest point in the trough is used. 
  25066.  
  25067.  pathName get  Returns the scrollbar settings in the form of a list whose 
  25068.            elements are the arguments to the most recent set widget command. 
  25069.  
  25070.  pathName identify x y  Returns the name of the element under the point given 
  25071.            by x and y (such as arrow1), or an empty string if the point does 
  25072.            not lie in any element of the scrollbar. X and y must be pixel 
  25073.            coordinates relative to the scrollbar widget. 
  25074.  
  25075.  pathName set first last  This command is invoked by the scrollbar's associated 
  25076.            widget to tell the scrollbar about the current view in the widget. 
  25077.            The command takes two arguments, each of which is a real fraction 
  25078.            between 0 and 1. The fractions describe the range of the document 
  25079.            that is visible in the associated widget. For example, if first is 
  25080.            0.2 and last is 0.4, it means that the first part of the document 
  25081.            visible in the window is 20% of the way through the document, and 
  25082.            the last visible part is 40% of the way through. 
  25083.  
  25084.  SCROLLING COMMANDS 
  25085.  
  25086.  When the user interacts with the scrollbar, for example by dragging the 
  25087.  slider, the scrollbar notifies the associated widget that it must change its 
  25088.  view. The scrollbar makes the notification by evaluating a Tcl command 
  25089.  generated from the scrollbar's -command option. The command may take any of 
  25090.  the following forms. In each case, prefix is the contents of the -command 
  25091.  option, which usually has a form like .t yview 
  25092.  
  25093.  prefix moveto fraction  Fraction is a real number between 0 and 1. The widget 
  25094.            should adjust its view so that the point given by fraction appears 
  25095.            at the beginning of the widget. If fraction is 0 it refers to the 
  25096.            beginning of the document.  1.0 refers to the end of the document, 
  25097.            0.333 refers to a point one-third of the way through the document, 
  25098.            and so on. 
  25099.  
  25100.  prefix scroll number unit  The widget should adjust its view by number units. 
  25101.            The units are defined in whatever way makes sense for the widget, 
  25102.            such as characters or lines in a text widget. Number is either 1, 
  25103.            which means one unit should scroll off the top or left of the 
  25104.            window, or -1, which means that one unit should scroll off the 
  25105.            bottom or right of the window. 
  25106.  
  25107.  prefix scroll number page  The widget should adjust its view by number pages. 
  25108.            It is up to the widget to define the meaning of a page;  typically 
  25109.            it is slightly less than what fits in the window, so that there is a 
  25110.            slight overlap between the old and new views. Number is either 1, 
  25111.            which means the next page should become visible, or -1, which means 
  25112.            that the previous page should become visible. 
  25113.  
  25114.  OLD COMMAND SYNTAX 
  25115.  
  25116.  In versions of Tk before 4.0, the set and get widget commands used a different 
  25117.  form. This form is still supported for backward compatibility, but it is 
  25118.  deprecated. In the old command syntax, the set widget command has the 
  25119.  following form: 
  25120.  
  25121.  pathName set totalUnits windowUnits firstUnit lastUnit  In this form the 
  25122.            arguments are all integers. TotalUnits gives the total size of the 
  25123.            object being displayed in the associated widget.  The meaning of one 
  25124.            unit depends on the associated widget;  for example, in a text 
  25125.            editor widget units might correspond to lines of text.  WindowUnits 
  25126.            indicates the total number of units that can fit in the associated 
  25127.            window at one time.  FirstUnit and lastUnit give the indices of the 
  25128.            first and last units currently visible in the associated window 
  25129.            (zero corresponds to the first unit of the object). 
  25130.  
  25131.  Under the old syntax the get widget command returns a list of four integers, 
  25132.  consisting of the totalUnits, windowUnits, firstUnit, and lastUnit values from 
  25133.  the last set widget command. 
  25134.  
  25135.  The commands generated by scrollbars also have a different form when the old 
  25136.  syntax is being used: 
  25137.  
  25138.  prefix unit  Unit is an integer that indicates what should appear at the top 
  25139.            or left of the associated widget's window. It has the same meaning 
  25140.            as the firstUnit and lastUnit arguments to the set widget command. 
  25141.  
  25142.  The most recent set widget command determines whether or not to use the old 
  25143.  syntax. If it is given two real arguments then the new syntax will be used in 
  25144.  the future, and if it is given four integer arguments then the old syntax will 
  25145.  be used. 
  25146.  
  25147.  BINDINGS 
  25148.  
  25149.  Tk automatically creates class bindings for scrollbars that give them the 
  25150.  following default behavior. If the behavior is different for vertical and 
  25151.  horizontal scrollbars, the horizontal behavior is described in parentheses. 
  25152.  
  25153.    1. Pressing button 1 over arrow1 causes the view in the associated widget to 
  25154.       shift up (left) by one unit so that the document appears to move down 
  25155.       (right) one unit. If the button is held down, the action auto-repeats. 
  25156.  
  25157.    2. Pressing button 1 over trough1 causes the view in the associated widget 
  25158.       to shift up (left) by one screenful so that the document appears to move 
  25159.       down (right) one screenful. If the button is held down, the action 
  25160.       auto-repeats. 
  25161.  
  25162.    3. Pressing button 1 over the slider and dragging causes the view to drag 
  25163.       with the slider. If the jump option is true, then the view doesn't drag 
  25164.       along with the slider;  it changes only when the mouse button is 
  25165.       released. 
  25166.  
  25167.    4. Pressing button 1 over trough2 causes the view in the associated widget 
  25168.       to shift down (right) by one screenful so that the document appears to 
  25169.       move up (left) one screenful. If the button is held down, the action 
  25170.       auto-repeats. 
  25171.  
  25172.    5. Pressing button 1 over arrow2 causes the view in the associated widget to 
  25173.       shift down (right) by one unit so that the document appears to move up 
  25174.       (left) one unit. If the button is held down, the action auto-repeats. 
  25175.  
  25176.    6. If button 2 is pressed over the trough or the slider, it sets the view to 
  25177.       correspond to the mouse position;  dragging the mouse with button 2 down 
  25178.       causes the view to drag with the mouse. If button 2 is pressed over one 
  25179.       of the arrows, it causes the same behavior as pressing button 1. 
  25180.  
  25181.    7. If button 1 is pressed with the Control key down, then if the mouse is 
  25182.       over arrow1 or trough1 the view changes to the very top (left) of the 
  25183.       document;  if the mouse is over arrow2 or trough2 the view changes to the 
  25184.       very bottom (right) of the document;  if the mouse is anywhere else then 
  25185.       the button press has no effect. 
  25186.  
  25187.    8. In vertical scrollbars the Up and Down keys have the same behavior as 
  25188.       mouse clicks over arrow1 and arrow2, respectively. In horizontal 
  25189.       scrollbars these keys have no effect. 
  25190.  
  25191.    9. In vertical scrollbars Control-Up and Control-Down have the same behavior 
  25192.       as mouse clicks over trough1 and trough2, respectively. In horizontal 
  25193.       scrollbars these keys have no effect. 
  25194.  
  25195.   10. In horizontal scrollbars the Up and Down keys have the same behavior as 
  25196.       mouse clicks over arrow1 and arrow2, respectively. In vertical scrollbars 
  25197.       these keys have no effect. 
  25198.  
  25199.   11. In horizontal scrollbars Control-Up and Control-Down have the same 
  25200.       behavior as mouse clicks over trough1 and trough2, respectively. In 
  25201.       vertical scrollbars these keys have no effect. 
  25202.  
  25203.   12. The Prior and Next keys have the same behavior as mouse clicks over 
  25204.       trough1 and trough2, respectively. 
  25205.  
  25206.   13. The Home key adjusts the view to the top (left edge) of the document. 
  25207.  
  25208.   14. The End key adjusts the view to the bottom (right edge) of the document. 
  25209.  
  25210.  KEYWORDS 
  25211.  
  25212.  scrollbar, widget 
  25213.  
  25214.  
  25215. ΓòÉΓòÉΓòÉ 6.42. selection ΓòÉΓòÉΓòÉ
  25216.  
  25217.  NAME 
  25218.  
  25219. selection - Manipulate the X selection 
  25220.  
  25221. SYNOPSIS 
  25222.  
  25223. selection option ?arg arg ...? 
  25224.  
  25225. DESCRIPTION 
  25226.  
  25227. This command provides a Tcl interface to the X selection mechanism and 
  25228. implements the full selection functionality described in the X Inter-Client 
  25229. Communication Conventions Manual (ICCCM). 
  25230.  
  25231. The first argument to selection determines the format of the rest of the 
  25232. arguments and the behavior of the command.  The following forms are currently 
  25233. supported: 
  25234.  
  25235.  selection clear ?-displayof window? ?-selection selection?  If selection 
  25236.            exists anywhere on window's display, clear it so that no window owns 
  25237.            the selection anymore.  Selection specifies the X selection that 
  25238.            should be cleared, and should be an atom name such as PRIMARY or 
  25239.            CLIPBOARD; see the Inter-Client Communication Conventions Manual for 
  25240.            complete details. Selection defaults to PRIMARY and window defaults 
  25241.            to ".". Returns an empty string. 
  25242.  
  25243.  selection get ?-displayof window? ?-selection selection? ?-type type? 
  25244.            Retrieves the value of selection from window's display and returns 
  25245.            it as a result.  Selection defaults to PRIMARY and window defaults 
  25246.            to ".". Type specifies the form in which the selection is to be 
  25247.            returned (the desired "target" for conversion, in ICCCM 
  25248.            terminology), and should be an atom name such as STRING or 
  25249.            FILE_NAME; see the Inter-Client Communication Conventions Manual for 
  25250.            complete details. Type defaults to STRING.  The selection owner may 
  25251.            choose to return the selection in any of several different 
  25252.            representation formats, such as STRING, ATOM, INTEGER, etc. (this 
  25253.            format is different than the selection type; see the ICCCM for all 
  25254.            the confusing details). If the selection is returned in a non-string 
  25255.            format, such as INTEGER or ATOM, the selection command converts it 
  25256.            to string format as a collection of fields separated by spaces: 
  25257.            atoms are converted to their textual names, and anything else is 
  25258.            converted to hexadecimal integers. 
  25259.  
  25260.  selection handle ?-selection selection? ?-type type? ?-format format? window 
  25261.  command   Creates a handler for selection requests, such that command will be 
  25262.            executed whenever selection is owned by window and someone attempts 
  25263.            to retrieve it in the form given by type (e.g. type is specified in 
  25264.            the selection get command). Selection defaults to PRIMARY, type 
  25265.            defaults to STRING, and format defaults to STRING.  If command is an 
  25266.            empty string then any existing handler for window, type, and 
  25267.            selection is removed. 
  25268.  
  25269.            When selection is requested, window is the selection owner, and type 
  25270.            is the requested type, command will be executed as a Tcl command 
  25271.            with two additional numbers appended to it (with space separators). 
  25272.            The two additional numbers are offset and maxBytes:  offset 
  25273.            specifies a starting character position in the selection and 
  25274.            maxBytes gives the maximum number of bytes to retrieve.  The command 
  25275.            should return a value consisting of at most maxBytes of the 
  25276.            selection, starting at position offset.  For very large selections 
  25277.            (larger than maxBytes) the selection will be retrieved using several 
  25278.            invocations of command with increasing offset values.  If command 
  25279.            returns a string whose length is less than maxBytes, the return 
  25280.            value is assumed to include all of the remainder of the selection; 
  25281.            if the length of command's result is equal to maxBytes then command 
  25282.            will be invoked again, until it eventually returns a result shorter 
  25283.            than maxBytes.  The value of maxBytes will always be relatively 
  25284.            large (thousands of bytes). 
  25285.  
  25286.            If command returns an error then the selection retrieval is rejected 
  25287.            just as if the selection didn't exist at all. 
  25288.  
  25289.            The format argument specifies the representation that should be used 
  25290.            to transmit the selection to the requester (the second column of 
  25291.            Table 2 of the ICCCM), and defaults to STRING.  If format is STRING, 
  25292.            the selection is transmitted as 8-bit ASCII characters (i.e. just in 
  25293.            the form returned by command).  If format is ATOM, then the return 
  25294.            value from command is divided into fields separated by white space; 
  25295.            each field is converted to its atom value, and the 32-bit atom value 
  25296.            is transmitted instead of the atom name. For any other format, the 
  25297.            return value from command is divided into fields separated by white 
  25298.            space and each field is converted to a 32-bit integer;  an array of 
  25299.            integers is transmitted to the selection requester. 
  25300.  
  25301.            The format argument is needed only for compatibility with selection 
  25302.            requesters that don't use Tk.  If Tk is being used to retrieve the 
  25303.            selection then the value is converted back to a string at the 
  25304.            requesting end, so format is irrelevant. 
  25305.  
  25306.  selection own ?-displayof window? ?-selection selection? 
  25307.  
  25308.  selection own ?-command command? ?-selection selection? window  The first form 
  25309.            of selection own returns the path name of the window in this 
  25310.            application that owns selection on the display containing window, or 
  25311.            an empty string if no window in this application owns the selection. 
  25312.            Selection defaults to PRIMARY and window defaults to ".". 
  25313.  
  25314.  The second form of selection own causes window to become the new owner of 
  25315.  selection on window's display, returning an empty string as result. The 
  25316.  existing owner, if any, is notified that it has lost the selection. If command 
  25317.  is specified, it is a Tcl script to execute when some other window claims 
  25318.  ownership of the selection away from window.  Selection defaults to PRIMARY. 
  25319.  
  25320.  KEYWORDS 
  25321.  
  25322.  clear, format, handler, ICCCM, own, selection, target, type 
  25323.  
  25324.  
  25325. ΓòÉΓòÉΓòÉ 6.43. send ΓòÉΓòÉΓòÉ
  25326.  
  25327.  NAME 
  25328.  
  25329. send - Execute a command in a different application 
  25330.  
  25331. SYNOPSIS 
  25332.  
  25333. send ?options? app cmd ?arg arg ...? 
  25334.  
  25335. DESCRIPTION 
  25336.  
  25337. This command arranges for cmd (and args) to be executed in the application 
  25338. named by app.  It returns the result or error from that command execution. App 
  25339. may be the name of any application whose main window is on the display 
  25340. containing the sender's main window;  it need not be within the same process. 
  25341. If no arg arguments are present, then the command to be executed is contained 
  25342. entirely within the cmd argument.  If one or more args are present, they are 
  25343. concatenated to form the command to be executed, just as for the eval command. 
  25344.  
  25345. If the initial arguments of the command begin with "-" they are treated as 
  25346. options.  The following options are currently defined: 
  25347.  
  25348.  -async    Requests asynchronous invocation.  In this case the send command 
  25349.            will complete immediately without waiting for cmd to complete in the 
  25350.            target application;  no result will be available and errors in the 
  25351.            sent command will be ignored. If the target application is in the 
  25352.            same process as the sending application then the -async option is 
  25353.            ignored. 
  25354.  
  25355.  -displayof pathName  Specifies that the target application's main window is on 
  25356.            the display of the window given by pathName, instead of the display 
  25357.            containing the application's main window. 
  25358.  
  25359.  --        Serves no purpose except to terminate the list of options.  This 
  25360.            option is needed only if app could contain a leading "-" character. 
  25361.  
  25362.  APPLICATION NAMES 
  25363.  
  25364.  The name of an application is set initially from the name of the program or 
  25365.  script that created the application. You can query and change the name of an 
  25366.  application with the tk appname command. 
  25367.  
  25368.  DISABLING SENDS 
  25369.  
  25370.  If the send command is removed from an application (e.g. with the command 
  25371.  rename send {}) then the application will not respond to incoming send 
  25372.  requests anymore,  nor will it be able to issue outgoing requests. 
  25373.  Communication can be reenabled by invoking the tk appname command. 
  25374.  
  25375.  SECURITY 
  25376.  
  25377.  The send command is potentially a serious security loophole, since any 
  25378.  application that can connect to your X server can send scripts to your 
  25379.  applications. These incoming scripts can use Tcl to read and write your files 
  25380.  and invoke subprocesses under your name. Host-based access control such as 
  25381.  that provided by xhost is particularly insecure, since it allows anyone with 
  25382.  an account on particular hosts to connect to your server, and if disabled it 
  25383.  allows anyone anywhere to connect to your server. In order to provide at least 
  25384.  a small amount of security, Tk checks the access control being used by the 
  25385.  server and rejects incoming sends unless (a) xhost-style access control is 
  25386.  enabled (i.e. only certain hosts can establish connections) and (b) the list 
  25387.  of enabled hosts is empty. This means that applications cannot connect to your 
  25388.  server unless they use some other form of authorization such as that provide 
  25389.  by xauth. 
  25390.  
  25391.  KEYWORDS 
  25392.  
  25393.  application, name, remote execution, security, send 
  25394.  
  25395.  
  25396. ΓòÉΓòÉΓòÉ 6.44. text ΓòÉΓòÉΓòÉ
  25397.  
  25398.  NAME 
  25399.  
  25400. text - Create and manipulate text widgets 
  25401.  
  25402. SYNOPSIS 
  25403.  
  25404. text pathName ?options? 
  25405.  
  25406. STANDARD OPTIONS 
  25407.  
  25408. -background          -highlightbackground -insertontime        -selectborderwidth
  25409. -borderwidth         -highlightcolor      -insertwidth         -selectforeground
  25410. -cursor              -highlightthickness  -padx                -setgrid
  25411. -exportselection     -insertbackground    -pady                -takefocus
  25412. -font                -insertborderwidth   -relief              -xscrollcommand
  25413. -foreground          -insertofftime       -selectbackground    -yscrollcommand
  25414.  
  25415. See the options manual entry for detailed descriptions of the above options.
  25416.  
  25417. WIDGET-SPECIFIC OPTIONS 
  25418.  
  25419.   Command-Line Name:    -height
  25420.   Database Name:        height
  25421.   Database Class:       Height
  25422.  
  25423.            Specifies the desired height for the window, in units of characters 
  25424.            in the font given by the -font option. Must be at least one. 
  25425.  
  25426.   Command-Line Name:    -spacing1
  25427.   Database Name:        spacing1
  25428.   Database Class:       Spacing1
  25429.  
  25430.            Requests additional space above each text line in the widget, using 
  25431.            any of the standard forms for screen distances. If a line wraps, 
  25432.            this option only applies to the first line on the display. This 
  25433.            option may be overriden with -spacing1 options in tags. 
  25434.  
  25435.   Command-Line Name:    -spacing2
  25436.   Database Name:        spacing2
  25437.   Database Class:       Spacing2
  25438.  
  25439.            For lines that wrap (so that they cover more than one line on the 
  25440.            display) this option specifies additional space to provide between 
  25441.            the display lines that represent a single line of text. The value 
  25442.            may have any of the standard forms for screen distances. This option 
  25443.            may be overriden with -spacing2 options in tags. 
  25444.  
  25445.   Command-Line Name:    -spacing3
  25446.   Database Name:        spacing3
  25447.   Database Class:       Spacing3
  25448.  
  25449.            Requests additional space below each text line in the widget, using 
  25450.            any of the standard forms for screen distances. If a line wraps, 
  25451.            this option only applies to the last line on the display. This 
  25452.            option may be overriden with -spacing3 options in tags. 
  25453.  
  25454.   Command-Line Name:    -state
  25455.   Database Name:        state
  25456.   Database Class:       State
  25457.  
  25458.            Specifies one of two states for the text:  normal or disabled. If 
  25459.            the text is disabled then characters may not be inserted or deleted 
  25460.            and no insertion cursor will be displayed, even if the input focus 
  25461.            is in the widget. 
  25462.  
  25463.   Command-Line Name:    -tabs
  25464.   Database Name:        tabs
  25465.   Database Class:       Tabs
  25466.  
  25467.            Specifies a set of tab stops for the window.  The option's value 
  25468.            consists of a list of screen distances giving the positions of the 
  25469.            tab stops.  Each position may optionally be followed in the next 
  25470.            list element by one of the keywords left, right, center, or numeric, 
  25471.            which specifies how to justify text relative to the tab stop.  Left 
  25472.            is the default; it causes the text following the tab character to be 
  25473.            positioned with its left edge at the tab position.  Right means that 
  25474.            the right edge of the text following the tab character is positioned 
  25475.            at the tab position, and center means that the text is centered at 
  25476.            the tab position. Numeric means that the decimal point in the text 
  25477.            is positioned at the tab position;  if there is no decimal point 
  25478.            then the least significant digit of the number is positioned just to 
  25479.            the left of the tab position;  if there is no number in the text 
  25480.            then the text is right-justified at the tab position. For example, 
  25481.            -tabs {2c left 4c 6c center} creates three tab stops at 
  25482.            two-centimeter intervals;  the first two use left justification and 
  25483.            the third uses center justification. If the list of tab stops does 
  25484.            not have enough elements to cover all of the tabs in a text line, 
  25485.            then Tk extrapolates new tab stops using the spacing and alignment 
  25486.            from the last tab stop in the list. The value of the tabs option may 
  25487.            be overridden by -tabs options in tags. If no -tabs option is 
  25488.            specified, or if it is specified as an empty list, then Tk uses 
  25489.            default tabs spaced every eight (average size) characters. 
  25490.  
  25491.   Command-Line Name:    -width
  25492.   Database Name:        width
  25493.   Database Class:       Width
  25494.  
  25495.            Specifies the desired width for the window in units of characters in 
  25496.            the font given by the -font option. If the font doesn't have a 
  25497.            uniform width then the width of the character " 0" is used in 
  25498.            translating from character units to screen units. 
  25499.  
  25500.   Command-Line Name:    -wrap
  25501.   Database Name:        wrap
  25502.   Database Class:       Wrap
  25503.  
  25504.            Specifies how to handle lines in the text that are too long to be 
  25505.            displayed in a single line of the text's window. The value must be 
  25506.            none or char or word. A wrap mode of none means that each line of 
  25507.            text appears as exactly one line on the screen;  extra characters 
  25508.            that don't fit on the screen are not displayed. In the other modes 
  25509.            each line of text will be broken up into several screen lines if 
  25510.            necessary to keep all the characters visible. In char mode a screen 
  25511.            line break may occur after any character; in word mode a line break 
  25512.            will only be made at word boundaries. 
  25513.  
  25514.  DESCRIPTION 
  25515.  
  25516.  The text command creates a new window (given by the pathName argument) and 
  25517.  makes it into a text widget. Additional options, described above, may be 
  25518.  specified on the command line or in the option database to configure aspects 
  25519.  of the text such as its default background color and relief.  The text command 
  25520.  returns the path name of the new window. 
  25521.  
  25522.  A text widget displays one or more lines of text and allows that text to be 
  25523.  edited. Text widgets support three different kinds of annotations on the text, 
  25524.  called tags, marks, and embedded windows. Tags allow different portions of the 
  25525.  text to be displayed with different fonts and colors. In addition, Tcl 
  25526.  commands can be associated with tags so that scripts are invoked when 
  25527.  particular actions such as keystrokes and mouse button presses occur in 
  25528.  particular ranges of the text. See TAGS below for more details. 
  25529.  
  25530.  The second form of annotation consists of marks, which are floating markers in 
  25531.  the text. Marks are used to keep track of various interesting positions in the 
  25532.  text as it is edited. See MARKS below for more details. 
  25533.  
  25534.  The third form of annotation allows arbitrary windows to be embedded in a text 
  25535.  widget. See EMBEDDED WINDOWS below for more details. 
  25536.  
  25537.  INDICES 
  25538.  
  25539.  Many of the widget commands for texts take one or more indices as arguments. 
  25540.  An index is a string used to indicate a particular place within a text, such 
  25541.  as a place to insert characters or one endpoint of a range of characters to 
  25542.  delete. Indices have the syntax 
  25543.  
  25544.   base modifier modifier modifier ...
  25545.  Where base gives a starting point and the modifiers adjust the index from the 
  25546.  starting point (e.g. move forward or backward one character).  Every index 
  25547.  must contain a base, but the modifiers are optional. 
  25548.  
  25549.  The base for an index must have one of the following forms: 
  25550.  
  25551.  line.char  Indicates char'th character on line line. Lines are numbered from 1 
  25552.            for consistency with other UNIX programs that use this numbering 
  25553.            scheme. Within a line, characters are numbered from 0. If char is 
  25554.            end then it refers to the newline character that ends the line. 
  25555.  
  25556.  @x,y      Indicates the character that covers the pixel whose x and y 
  25557.            coordinates within the text's window are x and y. 
  25558.  
  25559.  end       Indicates the end of the text (the character just after the last 
  25560.            newline). 
  25561.  
  25562.  mark      Indicates the character just after the mark whose name is mark. 
  25563.  
  25564.  tag.first  Indicates the first character in the text that has been tagged with 
  25565.            tag. This form generates an error if no characters are currently 
  25566.            tagged with tag. 
  25567.  
  25568.  tag.last  Indicates the character just after the last one in the text that has 
  25569.            been tagged with tag. This form generates an error if no characters 
  25570.            are currently tagged with tag. 
  25571.  
  25572.  pathName  Indicates the position of the embedded window whose name is 
  25573.            pathName. This form generates an error if there is no embedded 
  25574.            window by the given name. 
  25575.  
  25576.  If modifiers follow the base index, each one of them must have one of the 
  25577.  forms listed below.  Keywords such as chars and wordend may be abbreviated as 
  25578.  long as the abbreviation is unambiguous. 
  25579.  
  25580.  + count chars  Adjust the index forward by count characters, moving to later 
  25581.            lines in the text if necessary.  If there are fewer than count 
  25582.            characters in the text after the current index, then set the index 
  25583.            to the last character in the text. Spaces on either side of count 
  25584.            are optional. 
  25585.  
  25586.  - count chars  Adjust the index backward by count characters, moving to 
  25587.            earlier lines in the text if necessary.  If there are fewer than 
  25588.            count characters in the text before the current index, then set the 
  25589.            index to the first character in the text. Spaces on either side of 
  25590.            count are optional. 
  25591.  
  25592.  + count lines  Adjust the index forward by count lines, retaining the same 
  25593.            character position within the line.  If there are fewer than count 
  25594.            lines after the line containing the current index, then set the 
  25595.            index to refer to the same character position on the last line of 
  25596.            the text. Then, if the line is not long enough to contain a 
  25597.            character at the indicated character position, adjust the character 
  25598.            position to refer to the last character of the line (the newline). 
  25599.            Spaces on either side of count are optional. 
  25600.  
  25601.  - count lines  Adjust the index backward by count lines, retaining the same 
  25602.            character position within the line.  If there are fewer than count 
  25603.            lines before the line containing the current index, then set the 
  25604.            index to refer to the same character position on the first line of 
  25605.            the text. Then, if the line is not long enough to contain a 
  25606.            character at the indicated character position, adjust the character 
  25607.            position to refer to the last character of the line (the newline). 
  25608.            Spaces on either side of count are optional. 
  25609.  
  25610.  linestart  Adjust the index to refer to the first character on the line. 
  25611.  
  25612.  lineend   Adjust the index to refer to the last character on the line (the 
  25613.            newline). 
  25614.  
  25615.  wordstart  Adjust the index to refer to the first character of the word 
  25616.            containing the current index.  A word consists of any number of 
  25617.            adjacent characters that are letters, digits, or underscores, or a 
  25618.            single character that is not one of these. 
  25619.  
  25620.  wordend   Adjust the index to refer to the character just after the last one 
  25621.            of the word containing the current index.  If the current index 
  25622.            refers to the last character of the text then it is not modified. 
  25623.  
  25624.  If more than one modifier is present then they are applied in left-to-right 
  25625.  order.  For example, the index "end - 1 chars" refers to the next-to-last 
  25626.  character in the text and "insert wordstart - 1 c" refers to the character 
  25627.  just before the first one in the word containing the insertion cursor. 
  25628.  
  25629.  TAGS 
  25630.  
  25631.  The first form of annotation in text widgets is a tag. A tag is a textual 
  25632.  string that is associated with some of the characters in a text. Tags may 
  25633.  contain arbitrary characters, but it is probably best to avoid using the the 
  25634.  characters " " (space), +, or -: these characters have special meaning in 
  25635.  indices, so tags containing them can't be used as indices. There may be any 
  25636.  number of tags associated with characters in a text. Each tag may refer to a 
  25637.  single character, a range of characters, or several ranges of characters. An 
  25638.  individual character may have any number of tags associated with it. 
  25639.  
  25640.  A priority order is defined among tags, and this order is used in implementing 
  25641.  some of the tag-related functions described below. When a tag is defined (by 
  25642.  associating it with characters or setting its display options or binding 
  25643.  commands to it), it is given a priority higher than any existing tag. The 
  25644.  priority order of tags may be redefined using the "pathName tag raise" and 
  25645.  "pathName tag lower" widget commands. 
  25646.  
  25647.  Tags serve three purposes in text widgets. First, they control the way 
  25648.  information is displayed on the screen. By default, characters are displayed 
  25649.  as determined by the background, font, and foreground options for the text 
  25650.  widget. However, display options may be associated with individual tags using 
  25651.  the "pathName tag configure" widget command. If a character has been tagged, 
  25652.  then the display options associated with the tag override the default display 
  25653.  style. The following options are currently supported for tags: 
  25654.  
  25655.  -background color  Color specifies the background color to use for characters 
  25656.            associated with the tag. It may have any of the forms accepted by 
  25657.            Tk_GetColor. 
  25658.  
  25659.  -bgstipple bitmap  Bitmap specifies a bitmap that is used as a stipple pattern 
  25660.            for the background. It may have any of the forms accepted by 
  25661.            Tk_GetBitmap. If bitmap hasn't been specified, or if it is specified 
  25662.            as an empty string, then a solid fill will be used for the 
  25663.            background. 
  25664.  
  25665.  -borderwidth pixels  Pixels specifies the width of a 3-D border to draw around 
  25666.            the background. It may have any of the forms accepted by 
  25667.            Tk_GetPixels. This option is used in conjunction with the -relief 
  25668.            option to give a 3-D appearance to the background for characters; it 
  25669.            is ignored unless the -background option has been set for the tag. 
  25670.  
  25671.  -fgstipple bitmap  Bitmap specifies a bitmap that is used as a stipple pattern 
  25672.            when drawing text and other foreground information such as 
  25673.            underlines. It may have any of the forms accepted by Tk_GetBitmap. 
  25674.            If bitmap hasn't been specified, or if it is specified as an empty 
  25675.            string, then a solid fill will be used. 
  25676.  
  25677.  -font fontName  FontName is the name of a font to use for drawing characters. 
  25678.            It may have any of the forms accepted by Tk_GetFontStruct. 
  25679.  
  25680.  -foreground color  Color specifies the color to use when drawing text and 
  25681.            other foreground information such as underlines. It may have any of 
  25682.            the forms accepted by Tk_GetColor. 
  25683.  
  25684.  -justify justify  If the first character of a display line has a tag for which 
  25685.            this option has been specified, then justify determines how to 
  25686.            justify the line. It must be one of left, right, or center. If a 
  25687.            line wraps, then the justification for each line on the display is 
  25688.            determined by the first character of that display line. 
  25689.  
  25690.  -lmargin1 pixels  If the first character of a text line has a tag for which 
  25691.            this option has been specified, then pixels specifies how much the 
  25692.            line should be indented from the left edge of the window. Pixels may 
  25693.            have any of the standard forms for screen distances. If a line of 
  25694.            text wraps, this option only applies to the first line on the 
  25695.            display;  the -lmargin2 option controls the indentation for 
  25696.            subsequent lines. 
  25697.  
  25698.  -lmargin2 pixels  If the first character of a display line has a tag for which 
  25699.            this option has been specified, and if the display line is not the 
  25700.            first for its text line (i.e., the text line has wrapped), then 
  25701.            pixels specifies how much the line should be indented from the left 
  25702.            edge of the window. Pixels may have any of the standard forms for 
  25703.            screen distances. This option is only used when wrapping is enabled, 
  25704.            and it only applies to the second and later display lines for a text 
  25705.            line. 
  25706.  
  25707.  -offset pixels  Pixels specifies an amount by which the text's baseline should 
  25708.            be offset vertically from the baseline of the overall line, in 
  25709.            pixels. For example, a positive offset can be used for superscripts 
  25710.            and a negative offset can be used for subscripts. Pixels may have 
  25711.            any of the standard forms for screen distances. 
  25712.  
  25713.  -overstrike boolean  Specifies whether or not to draw a horizontal rule 
  25714.            through the middle of characters. Boolean may have any of the forms 
  25715.            accepted by Tk_GetBoolean. 
  25716.  
  25717.  -relief relief  Relief specifies the 3-D relief to use for drawing 
  25718.            backgrounds, in any of the forms accepted by Tk_GetRelief. This 
  25719.            option is used in conjunction with the -borderwidth option to give a 
  25720.            3-D appearance to the background for characters; it is ignored 
  25721.            unless the -background option has been set for the tag. 
  25722.  
  25723.  -rmargin pixels  If the first character of a display line has a tag for which 
  25724.            this option has been specified, then pixels specifies how wide a 
  25725.            margin to leave between the end of the line and the right edge of 
  25726.            the window. Pixels may have any of the standard forms for screen 
  25727.            distances. This option is only used when wrapping is enabled. If a 
  25728.            text line wraps, the right margin for each line on the display is 
  25729.            determined by the first character of that display line. 
  25730.  
  25731.  -spacing1 pixels  Pixels specifies how much additional space should be left 
  25732.            above each text line, using any of the standard forms for screen 
  25733.            distances. If a line wraps, this option only applies to the first 
  25734.            line on the display. 
  25735.  
  25736.  -spacing2 pixels  For lines that wrap, this option specifies how much 
  25737.            additional space to leave between the display lines for a single 
  25738.            text line. Pixels may have any of the standard forms for screen 
  25739.            distances. 
  25740.  
  25741.  -spacing3 pixels  Pixels specifies how much additional space should be left 
  25742.            below each text line, using any of the standard forms for screen 
  25743.            distances. If a line wraps, this option only applies to the last 
  25744.            line on the display. 
  25745.  
  25746.  -tabs tabList  TabList specifies a set of tab stops in the same form as for 
  25747.            the -tabs option for the text widget.  This option only applies to a 
  25748.            display line if it applies to the first character on that display 
  25749.            line. If this option is specified as an empty string, it cancels the 
  25750.            option, leaving it unspecified for the tag (the default). If the 
  25751.            option is specified as a non-empty string that is an empty list, 
  25752.            such as -tags { }, then it requests default 8-character tabs as 
  25753.            described for the tags widget option. 
  25754.  
  25755.  -underline boolean  Boolean specifies whether or not to draw an underline 
  25756.            underneath characters. It may have any of the forms accepted by 
  25757.            Tk_GetBoolean. 
  25758.  
  25759.  -wrap mode  Mode specifies how to handle lines that are wider than the text's 
  25760.            window. It has the same legal values as the -wrap option for the 
  25761.            text widget:  none, char, or word. If this tag option is specified, 
  25762.            it overrides the -wrap option for the text widget. 
  25763.  
  25764.  If a character has several tags associated with it, and if their display 
  25765.  options conflict, then the options of the highest priority tag are used. If a 
  25766.  particular display option hasn't been specified for a particular tag, or if it 
  25767.  is specified as an empty string, then that option will never be used;  the 
  25768.  next-highest-priority tag's option will used instead. If no tag specifies a 
  25769.  particular display option, then the default style for the widget will be used. 
  25770.  
  25771.  The second purpose for tags is event bindings. You can associate bindings with 
  25772.  a tag in much the same way you can associate bindings with a widget class: 
  25773.  whenever particular X events occur on characters with the given tag, a given 
  25774.  Tcl command will be executed. Tag bindings can be used to give behaviors to 
  25775.  ranges of characters; among other things, this allows hypertext-like features 
  25776.  to be implemented. For details, see the description of the tag bind widget 
  25777.  command below. 
  25778.  
  25779.  The third use for tags is in managing the selection. See THE SELECTION below. 
  25780.  
  25781.  MARKS 
  25782.  
  25783.  The second form of annotation in text widgets is a mark. Marks are used for 
  25784.  remembering particular places in a text. They are something like tags, in that 
  25785.  they have names and they refer to places in the file, but a mark isn't 
  25786.  associated with particular characters. Instead, a mark is associated with the 
  25787.  gap between two characters. Only a single position may be associated with a 
  25788.  mark at any given time. If the characters around a mark are deleted the mark 
  25789.  will still remain;  it will just have new neighbor characters. In contrast, if 
  25790.  the characters containing a tag are deleted then the tag will no longer have 
  25791.  an association with characters in the file. Marks may be manipulated with the 
  25792.  "pathName mark" widget command, and their current locations may be determined 
  25793.  by using the mark name as an index in widget commands. 
  25794.  
  25795.  Each mark also has a gravity, which is either left or right. The gravity for a 
  25796.  mark specifies what happens to the mark when text is inserted at the point of 
  25797.  the mark. If a mark has left gravity, then the mark is treated as if it were 
  25798.  attached to the character on its left, so the mark will remain to the left of 
  25799.  any text inserted at the mark position. If the mark has right gravity, new 
  25800.  text inserted at the mark position will appear to the right of the mark.  The 
  25801.  gravity for a mark defaults to right. 
  25802.  
  25803.  The name space for marks is different from that for tags:  the same name may 
  25804.  be used for both a mark and a tag, but they will refer to different things. 
  25805.  
  25806.  Two marks have special significance. First, the mark insert is associated with 
  25807.  the insertion cursor, as described under THE INSERTION CURSOR below. Second, 
  25808.  the mark current is associated with the character closest to the mouse and is 
  25809.  adjusted automatically to track the mouse position and any changes to the text 
  25810.  in the widget (one exception:  current is not updated in response to mouse 
  25811.  motions if a mouse button is down;  the update will be deferred until all 
  25812.  mouse buttons have been released). Neither of these special marks may be 
  25813.  deleted. 
  25814.  
  25815.  EMBEDDED WINDOWS 
  25816.  
  25817.  The third form of annotation in text widgets is an embedded window. Each 
  25818.  embedded window annotation causes a window to be displayed at a particular 
  25819.  point in  the text. There may be any number of embedded windows in a text 
  25820.  widget, and any widget may be used as an embedded window (subject to the usual 
  25821.  rules for geometry management, which require the text window to be the parent 
  25822.  of the embedded window or a descendant of its parent). The embedded window's 
  25823.  position on the screen will be updated as the text is modified or scrolled, 
  25824.  and it will be mapped and unmapped as it moves into and out of the visible 
  25825.  area of the text widget. Each embedded window occupies one character's worth 
  25826.  of index space in the text widget, and it may be referred to either by the 
  25827.  name of its embedded window or by its position in the widget's index space. If 
  25828.  the range of text containing the embedded window is deleted then the window is 
  25829.  destroyed. 
  25830.  
  25831.  When an embedded window is added to a text widget with the window create 
  25832.  widget command, several configuration options may be associated with it. These 
  25833.  options may be  modified later with the window configure widget command. The 
  25834.  following options are currently supported: 
  25835.  
  25836.  -align where  If the window is not as tall as the line in which it is 
  25837.            displayed, this option determines where the window is displayed in 
  25838.            the line. Where must have one of the values top (align the top of 
  25839.            the window with the top of the line), center (center the window 
  25840.            within the range of the line), bottom (align the bottom of the 
  25841.            window with the bottom of the line's area), or baseline (align the 
  25842.            bottom of the window with the baseline of the line). 
  25843.  
  25844.  -create script  Specifies a Tcl script that may be evaluated to create the 
  25845.            window for the annotation. If no -window option has been specified 
  25846.            for the annotation this script will be evaluated when the annotation 
  25847.            is about to be displayed on the screen. Script must create a window 
  25848.            for the annotation and return the name of that window as its result. 
  25849.            If the annotation's window should ever be deleted, script will be 
  25850.            evaluated again the next time the annotation is displayed. 
  25851.  
  25852.  -padx pixels  Pixels specifies the amount of extra space to leave on each side 
  25853.            of the embedded window. It may have any of the usual forms defined 
  25854.            for a screen distance. 
  25855.  
  25856.  -pady pixels  Pixels specifies the amount of extra space to leave on the top 
  25857.            and on the bottom of the embedded window. It may have any of the 
  25858.            usual forms defined for a screen distance. 
  25859.  
  25860.  -stretch boolean  If the requested height of the embedded window is less than 
  25861.            the height of the line in which it is displayed, this option can be 
  25862.            used to specify whether the window should be stretched vertically to 
  25863.            fill its line. If the -pady option has been specified as well, then 
  25864.            the requested padding will be retained even if the window is 
  25865.            stretched. 
  25866.  
  25867.  -window pathName  Specifies the name of a window to display in the annotation. 
  25868.  
  25869.  THE SELECTION 
  25870.  
  25871.  Text widgets support the standard X selection. Selection support is 
  25872.  implemented via tags. If the exportSelection option for the text widget is 
  25873.  true then the sel tag will be associated with the selection: 
  25874.  
  25875.    1. Whenever characters are tagged with sel the text widget will claim 
  25876.       ownership of the selection. 
  25877.  
  25878.    2. Attempts to retrieve the selection will be serviced by the text widget, 
  25879.       returning all the characters with the sel tag. 
  25880.  
  25881.    3. If the selection is claimed away by another application or by another 
  25882.       window within this application, then the sel tag will be removed from all 
  25883.       characters in the text. 
  25884.  
  25885.  The sel tag is automatically defined when a text widget is created, and it may 
  25886.  not be deleted with the "pathName tag delete" widget command.  Furthermore, 
  25887.  the selectBackground, selectBorderWidth, and selectForeground options for the 
  25888.  text widget are tied to the -background, -borderwidth, and -foreground options 
  25889.  for the sel tag:  changes in either will automatically be reflected in the 
  25890.  other. 
  25891.  
  25892.  THE INSERTION CURSOR 
  25893.  
  25894.  The mark named insert has special significance in text widgets. It is defined 
  25895.  automatically when a text widget is created and it may not be unset with the 
  25896.  "pathName mark unset" widget command. The insert mark represents the position 
  25897.  of the insertion cursor, and the insertion cursor will automatically be drawn 
  25898.  at this point whenever the text widget has the input focus. 
  25899.  
  25900.  WIDGET COMMAND 
  25901.  
  25902.  The text command creates a new Tcl command whose name is the same as the path 
  25903.  name of the text's window.  This command may be used to invoke various 
  25904.  operations on the widget.  It has the following general form: 
  25905.  
  25906.   pathName option ?arg arg ...?
  25907.  PathName is the name of the command, which is the same as the text widget's 
  25908.  path name.  Option and the args determine the exact behavior of the command. 
  25909.  The following commands are possible for text widgets: 
  25910.  
  25911.  pathName bbox index  Returns a list of four elements describing the screen 
  25912.            area of the character given by index. The first two elements of the 
  25913.            list give the x and y coordinates of the upper-left corner of the 
  25914.            area occupied by the character, and the last two elements give the 
  25915.            width and height of the area. If the character is only partially 
  25916.            visible on the screen, then the return value reflects just the 
  25917.            visible part. If the character is not visible on the screen then the 
  25918.            return value is an empty list. 
  25919.  
  25920.  pathName cget option  Returns the current value of the configuration option 
  25921.            given by option. Option may have any of the values accepted by the 
  25922.            text command. 
  25923.  
  25924.  pathName compare index1 op index2  Compares the indices given by index1 and 
  25925.            index2 according to the relational operator given by op, and returns 
  25926.            1 if the relationship is satisfied and 0 if it isn't. Op must be one 
  25927.            of the operators <, <=, ==, >=, >, or !=. If op is == then 1 is 
  25928.            returned if the two indices refer to the same character, if op is < 
  25929.            then 1 is returned if index1 refers to an earlier character in the 
  25930.            text than index2, and so on. 
  25931.  
  25932.  pathName configure ?option? ?value option value ...?  Query or modify the 
  25933.            configuration options of the widget. If no option is specified, 
  25934.            returns a list describing all of the available options for pathName 
  25935.            (see Tk_ConfigureInfo for information on the format of this list). 
  25936.            If option is specified with no value, then the command returns a 
  25937.            list describing the one named option (this list will be identical to 
  25938.            the corresponding sublist of the value returned if no option is 
  25939.            specified).  If one or more option-value pairs are specified, then 
  25940.            the command modifies the given widget option(s) to have the given 
  25941.            value(s);  in this case the command returns an empty string. Option 
  25942.            may have any of the values accepted by the text command. 
  25943.  
  25944.  pathName debug ?boolean?  If boolean is specified, then it must have one of 
  25945.            the true or false values accepted by Tcl_GetBoolean. If the value is 
  25946.            a true one then internal consistency checks will be turned on in the 
  25947.            B-tree code associated with text widgets. If boolean has a false 
  25948.            value then the debugging checks will be turned off. In either case 
  25949.            the command returns an empty string. If boolean is not specified 
  25950.            then the command returns on or off to indicate whether or not 
  25951.            debugging is turned on. There is a single debugging switch shared by 
  25952.            all text widgets:  turning debugging on or off in any widget turns 
  25953.            it on or off for all widgets. For widgets with large amounts of 
  25954.            text, the consistency checks may cause a noticeable slow-down. 
  25955.  
  25956.  pathName delete index1 ?index2?  Delete a range of characters from the text. 
  25957.            If both index1 and index2 are specified, then delete all the 
  25958.            characters starting with the one given by index1 and stopping just 
  25959.            before index2 (i.e. the character at index2 is not deleted). If 
  25960.            index2 doesn't specify a position later in the text than index1 then 
  25961.            no characters are deleted. If index2 isn't specified then the single 
  25962.            character at index1 is deleted. It is not allowable to delete 
  25963.            characters in a way that would leave the text without a newline as 
  25964.            the last character. The command returns an empty string. 
  25965.  
  25966.  pathName dlineinfo index  Returns a list with five elements describing the 
  25967.            area occupied by the display line containing index. The first two 
  25968.            elements of the list give the x and y coordinates of the upper-left 
  25969.            corner of the area occupied by the line, the third and fourth 
  25970.            elements give the width and height of the area, and the fifth 
  25971.            element gives the position of the baseline for the line, measured 
  25972.            down from the top of the area. All of this information is measured 
  25973.            in pixels. If the current wrap mode is none and the line extends 
  25974.            beyond the boundaries of the window, the area returned reflects the 
  25975.            entire area of the line, including the portions that are out of the 
  25976.            window. If the line is shorter than the full width of the window 
  25977.            then the area returned reflects just the portion of the line that is 
  25978.            occupied by characters and embedded windows. If the display line 
  25979.            containing index is not visible on the screen then the return value 
  25980.            is an empty list. 
  25981.  
  25982.  pathName dump ?switches? index1 ?index2?  Return the contents of the text 
  25983.            widget from index1 up to, but not including index2, including the 
  25984.            text and information about marks, tags, and embedded windows. If 
  25985.            index2 is not specified, then it defaults to one character past 
  25986.            index1.  The information is returned in the following format: 
  25987.  
  25988.  key1 value1 index1 key2 value2 index2 ... 
  25989.  
  25990.  The possible key values are text, mark, tagon, tagoff, and window.  The 
  25991.  corresponding value is the text, mark name, tag name, or window name. The 
  25992.  index information is the index of the start of the text, the mark, the tag 
  25993.  transition, or the window. One or more of the following switches (or 
  25994.  abbreviations thereof) may be specified to control the dump: 
  25995.  
  25996.  -all      Return information about all elements: text, marks, tags, and 
  25997.            windows. This is the default. 
  25998.  
  25999.  -command command  Instead of returning the information as the result of the 
  26000.            dump operation, invoke the command on each element of the text 
  26001.            widget within the range. The command has three arguments appended to 
  26002.            it before it is evaluated: the key, value, and index. 
  26003.  
  26004.  -mark     Include information about marks in the dump results. 
  26005.  
  26006.  -tag      Include information about tag transitions in the dump results. Tag 
  26007.            information is returned as tagon and tagoff elements that indicate 
  26008.            the begin and end of each range of each tag, respectively. 
  26009.  
  26010.  -text     Include information about text in the dump results.  The value is 
  26011.            the text up to the next element or the end of range indicated by 
  26012.            index2. A text element does not span newlines.  A multi-line block 
  26013.            of text that contains no marks or tag transitions will still be 
  26014.            dumped as a set of text seqments that each end with a newline.  The 
  26015.            newline is part of the value. 
  26016.  
  26017.  -window   Include information about embedded windows in the dump results. The 
  26018.            value of a window is its Tk pathname, unless the window has not been 
  26019.            created yet.  (It must have a create script.) In this case an empty 
  26020.            string is returned, and you must query the window by its index 
  26021.            position to get more information. 
  26022.  
  26023.  pathName get index1 ?index2?  Return a range of characters from the text. The 
  26024.            return value will be all the characters in the text starting with 
  26025.            the one whose index is index1 and ending just before the one whose 
  26026.            index is index2 (the character at index2 will not be returned). If 
  26027.            index2 is omitted then the single character at index1 is returned. 
  26028.            If there are no characters in the specified range (e.g. index1 is 
  26029.            past the end of the file or index2 is less than or equal to index1) 
  26030.            then an empty string is returned. If the specified range contains 
  26031.            embedded windows, no information about them is included in the 
  26032.            returned string. 
  26033.  
  26034.  pathName index index  Returns the position corresponding to index in the form 
  26035.            line.char where line is the line number and char is the character 
  26036.            number. Index may have any of the forms described under INDICES 
  26037.            above. 
  26038.  
  26039.  pathName insert index chars ?tagList chars tagList ...?  Inserts all of the 
  26040.            chars arguments just before the character at index. If index refers 
  26041.            to the end of the text (the character after the last newline) then 
  26042.            the new text is inserted just before the last newline instead. If 
  26043.            there is a single chars argument and no tagList, then the new text 
  26044.            will receive any tags that are present on both the character before 
  26045.            and the character after the insertion point; if a tag is present on 
  26046.            only one of these characters then it will not be applied to the new 
  26047.            text. If tagList is specified then it consists of a list of tag 
  26048.            names;  the new characters will receive all of the tags in this list 
  26049.            and no others, regardless of the tags present around the insertion 
  26050.            point. If multiple chars-tagList argument pairs are present, they 
  26051.            produce the same effect as if a separate insert widget command had 
  26052.            been issued for each pair, in order. The last tagList argument may 
  26053.            be omitted. 
  26054.  
  26055.  pathName mark option ?arg arg ...?  This command is used to manipulate marks. 
  26056.            The exact behavior of the command depends on the option argument 
  26057.            that follows the mark argument.  The following forms of the command 
  26058.            are currently supported: 
  26059.  
  26060.            pathName mark gravity markName ?direction?  If direction is not 
  26061.                           specified, returns left or right to indicate which of 
  26062.                           its adjacent characters markName is attached to. If 
  26063.                           direction is specified, it must be left or right; the 
  26064.                           gravity of markName is set to the given value. 
  26065.  
  26066.            pathName mark names  Returns a list whose elements are the names of 
  26067.                           all the marks that are currently set. 
  26068.  
  26069.            pathName mark next index  Returns the name of the next mark at or 
  26070.                           after index. If index is specified in numerical form, 
  26071.                           then the search for the next mark begins at that 
  26072.                           index. If index is the name of a mark, then the 
  26073.                           search for the next mark begins immediately after 
  26074.                           that mark. This can still return a mark at the same 
  26075.                           position if there are multiple marks at the same 
  26076.                           index. These semantics mean that the mark next 
  26077.                           operation can be used to step through all the marks 
  26078.                           in a text widget in the same order as the mark 
  26079.                           information returned by the dump operation. If a mark 
  26080.                           has been set to the special end index, then it 
  26081.                           appears to be after end with respect to the mark next 
  26082.                           operation. An empty string is returned if there are 
  26083.                           no marks after index. 
  26084.  
  26085.            pathName mark previous index  Returns the name of the mark at or 
  26086.                           before index. If index is specified in numerical 
  26087.                           form, then the search for the previous mark begins 
  26088.                           with the character just before that index. If index 
  26089.                           is the name of a mark, then the search for the next 
  26090.                           mark begins immediately before that mark. This can 
  26091.                           still return a mark at the same position if there are 
  26092.                           multiple marks at the same index. These semantics 
  26093.                           mean that the mark previous operation can be used to 
  26094.                           step through all the marks in a text widget in the 
  26095.                           reverse order as the mark information returned by the 
  26096.                           dump operation. An empty string is returned if there 
  26097.                           are no marks before index. 
  26098.  
  26099.            pathName mark set markName index  Sets the mark named markName to a 
  26100.                           position just before the character at index. If 
  26101.                           markName already exists, it is moved from its old 
  26102.                           position; if it doesn't exist, a new mark is created. 
  26103.                           This command returns an empty string. 
  26104.  
  26105.            pathName mark unset markName ?markName markName ...?  Remove the 
  26106.                           mark corresponding to each of the markName arguments. 
  26107.                           The removed marks will not be usable in indices and 
  26108.                           will not be returned by future calls to "pathName 
  26109.                           mark names". This command returns an empty string. 
  26110.  
  26111.  pathName scan option args  This command is used to implement scanning on 
  26112.            texts.  It has two forms, depending on option: 
  26113.  
  26114.            pathName scan mark x y  Records x and y and the current view in the 
  26115.                           text window, for use in conjunction with later scan 
  26116.                           dragto commands. Typically this command is associated 
  26117.                           with a mouse button press in the widget.  It returns 
  26118.                           an empty string. 
  26119.  
  26120.            pathName scan dragto x y  This command computes the difference 
  26121.                           between its x and y arguments and the x and y 
  26122.                           arguments to the last scan mark command for the 
  26123.                           widget. It then adjusts the view by 10 times the 
  26124.                           difference in coordinates. This command is typically 
  26125.                           associated with mouse motion events in the widget, to 
  26126.                           produce the effect of dragging the text at high speed 
  26127.                           through the window.  The return value is an empty 
  26128.                           string. 
  26129.  
  26130.  pathName search ?switches? pattern index ?stopIndex?  Searches the text in 
  26131.            pathName starting at index for a range of characters that matches 
  26132.            pattern. If a match is found, the index of the first character in 
  26133.            the match is returned as result;  otherwise an empty string is 
  26134.            returned. One or more of the following switches (or abbreviations 
  26135.            thereof) may be specified to control the search: 
  26136.  
  26137.            -forwards      The search will proceed forward through the text, 
  26138.                           finding the first matching range starting at or after 
  26139.                           the position given by index. This is the default. 
  26140.  
  26141.            -backwards     The search will proceed backward through the text, 
  26142.                           finding the matching range closest to index whose 
  26143.                           first character is before index. 
  26144.  
  26145.            -exact         Use exact matching:  the characters in the matching 
  26146.                           range must be identical to those in pattern. This is 
  26147.                           the default. 
  26148.  
  26149.            -regexp        Treat pattern as a regular expression and match it 
  26150.                           against the text using the rules for regular 
  26151.                           expressions (see the regexp command for details). 
  26152.  
  26153.            -nocase        Ignore case differences between the pattern and the 
  26154.                           text. 
  26155.  
  26156.            -count varName  The argument following -count gives the name of a 
  26157.                           variable; if a match is found, the number of 
  26158.                           characters in the matching range will be stored in 
  26159.                           the variable. 
  26160.  
  26161.            --             This switch has no effect except to terminate the 
  26162.                           list of switches: the next argument will be treated 
  26163.                           as pattern even if it starts with -. 
  26164.  
  26165.            The matching range must be entirely within a single line of text. 
  26166.            For regular expression matching the newlines are removed from the 
  26167.            ends of the lines before matching:  use the $ feature in regular 
  26168.            expressions to match the end of a line. For exact matching the 
  26169.            newlines are retained. If stopIndex is specified, the search stops 
  26170.            at that index: for forward searches, no match at or after stopIndex 
  26171.            will be considered;  for backward searches, no match earlier in the 
  26172.            text than stopIndex will be considered. If stopIndex is omitted, the 
  26173.            entire text will be searched: when the beginning or end of the text 
  26174.            is reached, the search continues at the other end until the starting 
  26175.            location is reached again;  if stopIndex is specified, no 
  26176.            wrap-around will occur. 
  26177.  
  26178.  pathName see index  Adjusts the view in the window so that the character given 
  26179.            by index is completely visible. If index is already visible then the 
  26180.            command does nothing. If index is a short distance out of view, the 
  26181.            command adjusts the view just enough to make index visible at the 
  26182.            edge of the window. If index is far out of view, then the command 
  26183.            centers index in the window. 
  26184.  
  26185.  pathName tag option ?arg arg ...?  This command is used to manipulate tags. 
  26186.            The exact behavior of the command depends on the option argument 
  26187.            that follows the tag argument.  The following forms of the command 
  26188.            are currently supported: 
  26189.  
  26190.            pathName tag add tagName index1 ?index2 index1 index2 ...? 
  26191.                           Associate the tag tagName with all of the characters 
  26192.                           starting with index1 and ending just before index2 
  26193.                           (the character at index2 isn't tagged). A single 
  26194.                           command may contain any number of index1-index2 
  26195.                           pairs. If the last index2 is omitted then the single 
  26196.                           character at index1 is tagged. If there are no 
  26197.                           characters in the specified range (e.g. index1 is 
  26198.                           past the end of the file or index2 is less than or 
  26199.                           equal to index1) then the command has no effect. 
  26200.  
  26201.            pathName tag bind tagName ?sequence? ?script?  This command 
  26202.                           associates script with the tag given by tagName. 
  26203.                           Whenever the event sequence given by sequence occurs 
  26204.                           for a character that has been tagged with tagName, 
  26205.                           the script will be invoked. This widget command is 
  26206.                           similar to the bind command except that it operates 
  26207.                           on characters in a text rather than entire widgets. 
  26208.                           See the bind manual entry for complete details on the 
  26209.                           syntax of sequence and the substitutions performed on 
  26210.                           script before invoking it. If all arguments are 
  26211.                           specified then a new binding is created, replacing 
  26212.                           any existing binding for the same sequence and 
  26213.                           tagName (if the first character of script is "+" then 
  26214.                           script augments an existing binding rather than 
  26215.                           replacing it). In this case the return value is an 
  26216.                           empty string. If script is omitted then the command 
  26217.                           returns the script associated with tagName and 
  26218.                           sequence (an error occurs if there is no such 
  26219.                           binding). If both script and sequence are omitted 
  26220.                           then the command returns a list of all the sequences 
  26221.                           for which bindings have been defined for tagName. 
  26222.  
  26223.                           The only events for which bindings may be specified 
  26224.                           are those related to the mouse and keyboard, such as 
  26225.                           Enter, Leave, ButtonPress, Motion, and KeyPress. 
  26226.                           Event bindings for a text widget use the current mark 
  26227.                           described under MARKS above. An Enter event triggers 
  26228.                           for a tag when the tag first becomes present on the 
  26229.                           current character, and a Leave event triggers for a 
  26230.                           tag when it ceases to be present on the current 
  26231.                           character. Enter and Leave events can happen either 
  26232.                           because the current mark moved or because the 
  26233.                           character at that position changed. Note that these 
  26234.                           events are different than Enter and Leave events for 
  26235.                           windows. Mouse and keyboard events are directed to 
  26236.                           the current character. 
  26237.  
  26238.                           It is possible for the current character to have 
  26239.                           multiple tags, and for each of them to have a binding 
  26240.                           for a particular event sequence. When this occurs, 
  26241.                           one binding is invoked for each tag, in order from 
  26242.                           lowest-priority to highest priority. If there are 
  26243.                           multiple matching bindings for a single tag, then the 
  26244.                           most specific binding is chosen (see the manual entry 
  26245.                           for the bind command for details). continue and break 
  26246.                           commands within binding scripts are processed in the 
  26247.                           same way as for bindings created with the bind 
  26248.                           command. 
  26249.  
  26250.                           If bindings are created for the widget as a whole 
  26251.                           using the bind command, then those bindings will 
  26252.                           supplement the tag bindings. The tag bindings will be 
  26253.                           invoked first, followed by bindings for the window as 
  26254.                           a whole. 
  26255.  
  26256.            pathName tag cget tagName option  This command returns the current 
  26257.                           value of the option named option associated with the 
  26258.                           tag given by tagName. Option may have any of the 
  26259.                           values accepted by the tag configure widget command. 
  26260.  
  26261.            pathName tag configure tagName ?option? ?value? ?option value ...? 
  26262.                           This command is similar to the configure widget 
  26263.                           command except that it modifies options associated 
  26264.                           with the tag given by tagName instead of modifying 
  26265.                           options for the overall text widget. If no option is 
  26266.                           specified, the command returns a list describing all 
  26267.                           of the available options for tagName (see 
  26268.                           Tk_ConfigureInfo for information on the format of 
  26269.                           this list). If option is specified with no value, 
  26270.                           then the command returns a list describing the one 
  26271.                           named option (this list will be identical to the 
  26272.                           corresponding sublist of the value returned if no 
  26273.                           option is specified). If one or more option-value 
  26274.                           pairs are specified, then the command modifies the 
  26275.                           given option(s) to have the given value(s) in 
  26276.                           tagName; in this case the command returns an empty 
  26277.                           string. See TAGS above for details on the options 
  26278.                           available for tags. 
  26279.  
  26280.            pathName tag delete tagName ?tagName ...?  Deletes all tag 
  26281.                           information for each of the tagName arguments. The 
  26282.                           command removes the tags from all characters in the 
  26283.                           file and also deletes any other information 
  26284.                           associated with the tags, such as bindings and 
  26285.                           display information. The command returns an empty 
  26286.                           string. 
  26287.  
  26288.            pathName tag lower tagName ?belowThis?  Changes the priority of tag 
  26289.                           tagName so that it is just lower in priority than the 
  26290.                           tag whose name is belowThis. If belowThis is omitted, 
  26291.                           then tagName's priority is changed to make it lowest 
  26292.                           priority of all tags. 
  26293.  
  26294.            pathName tag names ?index?  Returns a list whose elements are the 
  26295.                           names of all the tags that are active at the 
  26296.                           character position given by index. If index is 
  26297.                           omitted, then the return value will describe all of 
  26298.                           the tags that exist for the text (this includes all 
  26299.                           tags that have been named in a "pathName tag" widget 
  26300.                           command but haven't been deleted by a "pathName tag 
  26301.                           delete" widget command, even if no characters are 
  26302.                           currently marked with the tag). The list will be 
  26303.                           sorted in order from lowest priority to highest 
  26304.                           priority. 
  26305.  
  26306.            pathName tag nextrange tagName index1 ?index2?  This command 
  26307.                           searches the text for a range of characters tagged 
  26308.                           with tagName where the first character of the range 
  26309.                           is no earlier than the character at index1 and no 
  26310.                           later than the character just before index2 (a range 
  26311.                           starting at index2 will not be considered). If 
  26312.                           several matching ranges exist, the first one is 
  26313.                           chosen. The command's return value is a list 
  26314.                           containing two elements, which are the index of the 
  26315.                           first character of the range and the index of the 
  26316.                           character just after the last one in the range. If no 
  26317.                           matching range is found then the return value is an 
  26318.                           empty string. If index2 is not given then it defaults 
  26319.                           to the end of the text. 
  26320.  
  26321.            pathName tag prevrange tagName index1 ?index2?  This command 
  26322.                           searches the text for a range of characters tagged 
  26323.                           with tagName where the first character of the range 
  26324.                           is before the character at index1 and no earlier than 
  26325.                           the character at index2 (a range starting at index2 
  26326.                           will be considered). If several matching ranges 
  26327.                           exist, the one closest to index1 is chosen. The 
  26328.                           command's return value is a list containing two 
  26329.                           elements, which are the index of the first character 
  26330.                           of the range and the index of the character just 
  26331.                           after the last one in the range. If no matching range 
  26332.                           is found then the return value is an empty string. If 
  26333.                           index2 is not given then it defaults to the beginning 
  26334.                           of the text. 
  26335.  
  26336.            pathName tag raise tagName ?aboveThis?  Changes the priority of tag 
  26337.                           tagName so that it is just higher in priority than 
  26338.                           the tag whose name is aboveThis. If aboveThis is 
  26339.                           omitted, then tagName's priority is changed to make 
  26340.                           it highest priority of all tags. 
  26341.  
  26342.            pathName tag ranges tagName  Returns a list describing all of the 
  26343.                           ranges of text that have been tagged with tagName. 
  26344.                           The first two elements of the list describe the first 
  26345.                           tagged range in the text, the next two elements 
  26346.                           describe the second range, and so on. The first 
  26347.                           element of each pair contains the index of the first 
  26348.                           character of the range, and the second element of the 
  26349.                           pair contains the index of the character just after 
  26350.                           the last one in the range. If there are no characters 
  26351.                           tagged with tag then an empty string is returned. 
  26352.  
  26353.            pathName tag remove tagName index1 ?index2 index1 index2 ...? 
  26354.                           Remove the tag tagName from all of the characters 
  26355.                           starting at index1 and ending just before index2 (the 
  26356.                           character at index2 isn't affected). A single command 
  26357.                           may contain any number of index1-index2 pairs. If the 
  26358.                           last index2 is omitted then the single character at 
  26359.                           index1 is tagged. If there are no characters in the 
  26360.                           specified range (e.g. index1 is past the end of the 
  26361.                           file or index2 is less than or equal to index1) then 
  26362.                           the command has no effect. This command returns an 
  26363.                           empty string. 
  26364.  
  26365.  pathName window option ?arg arg ...?  This command is used to manipulate 
  26366.            embedded windows. The behavior of the command depends on the option 
  26367.            argument that follows the tag argument. The following forms of the 
  26368.            command are currently supported: 
  26369.  
  26370.            pathName window cget index option  Returns the value of a 
  26371.                           configuration option for an embedded window. Index 
  26372.                           identifies the embedded window, and option specifies 
  26373.                           a particular configuration option, which must be one 
  26374.                           of the ones listed in the section EMBEDDED WINDOWS. 
  26375.  
  26376.            pathName window configure index ?option value ...?  Query or modify 
  26377.                           the configuration options for an embedded window. If 
  26378.                           no option is specified, returns a list describing all 
  26379.                           of the available options for the embedded window at 
  26380.                           index (see Tk_ConfigureInfo for information on the 
  26381.                           format of this list). If option is specified with no 
  26382.                           value, then the command returns a list describing the 
  26383.                           one named option (this list will be identical to the 
  26384.                           corresponding sublist of the value returned if no 
  26385.                           option is specified). If one or more option-value 
  26386.                           pairs are specified, then the command modifies the 
  26387.                           given option(s) to have the given value(s);  in this 
  26388.                           case the command returns an empty string. See 
  26389.                           EMBEDDED WINDOWS for information on the options that 
  26390.                           are supported. 
  26391.  
  26392.            pathName window create index ?option value ...?  This command 
  26393.                           creates a new window annotation, which will appear in 
  26394.                           the text at the position given by index. Any number 
  26395.                           of option-value pairs may be specified to configure 
  26396.                           the annotation. See EMBEDDED WINDOWS for information 
  26397.                           on the options that are supported. Returns an empty 
  26398.                           string. 
  26399.  
  26400.            pathName window names  Returns a list whose elements are the names 
  26401.                           of all windows currently embedded in window. 
  26402.  
  26403.  pathName xview option args  This command is used to query and change the 
  26404.            horizontal position of the text in the widget's window.  It can take 
  26405.            any of the following forms: 
  26406.  
  26407.            pathName xview  Returns a list containing two elements. Each element 
  26408.                           is a real fraction between 0 and 1;  together they 
  26409.                           describe the portion of the document's horizontal 
  26410.                           span that is visible in the window. For example, if 
  26411.                           the first element is .2 and the second element is .6, 
  26412.                           20% of the text is off-screen to the left, the middle 
  26413.                           40% is visible in the window, and 40% of the text is 
  26414.                           off-screen to the right. The fractions refer only to 
  26415.                           the lines that are actually visible in the window: 
  26416.                           if the lines in the window are all very short, so 
  26417.                           that they are entirely visible, the returned 
  26418.                           fractions will be 0 and 1, even if there are other 
  26419.                           lines in the text that are much wider than the 
  26420.                           window. These are the same values passed to 
  26421.                           scrollbars via the -xscrollcommand option. 
  26422.  
  26423.            pathName xview moveto fraction  Adjusts the view in the window so 
  26424.                           that fraction of the horizontal span of the text is 
  26425.                           off-screen to the left. Fraction is a fraction 
  26426.                           between 0 and 1. 
  26427.  
  26428.            pathName xview scroll number what  This command shifts the view in 
  26429.                           the window left or right according to number and 
  26430.                           what. Number must be an integer. What must be either 
  26431.                           units or pages or an abbreviation of one of these. If 
  26432.                           what is units, the view adjusts left or right by 
  26433.                           number average-width characters on the display;  if 
  26434.                           it is pages then the view adjusts by number 
  26435.                           screenfuls. If number is negative then characters 
  26436.                           farther to the left become visible;  if it is 
  26437.                           positive then characters farther to the right become 
  26438.                           visible. 
  26439.  
  26440.  pathName yview ?args?  This command is used to query and change the vertical 
  26441.            position of the text in the widget's window. It can take any of the 
  26442.            following forms: 
  26443.  
  26444.            pathName yview  Returns a list containing two elements, both of 
  26445.                           which are real fractions between 0 and 1. The first 
  26446.                           element gives the position of the first character in 
  26447.                           the top line in the window, relative to the text as a 
  26448.                           whole (0.5 means it is halfway through the text, for 
  26449.                           example). The second element gives the position of 
  26450.                           the character just after the last one in the bottom 
  26451.                           line of the window, relative to the text as a whole. 
  26452.                           These are the same values passed to scrollbars via 
  26453.                           the -yscrollcommand option. 
  26454.  
  26455.            pathName yview moveto fraction  Adjusts the view in the window so 
  26456.                           that the character given by fraction appears on the 
  26457.                           top line of the window. Fraction is a fraction 
  26458.                           between 0 and 1;  0 indicates the first character in 
  26459.                           the text, 0.33 indicates the character one-third the 
  26460.                           way through the text, and so on. 
  26461.  
  26462.            pathName yview scroll number what  This command adjust the view in 
  26463.                           the window up or down according to number and what. 
  26464.                           Number must be an integer. What must be either units 
  26465.                           or pages. If what is units, the view adjusts up or 
  26466.                           down by number lines on the display;  if it is pages 
  26467.                           then the view adjusts by number screenfuls. If number 
  26468.                           is negative then earlier positions in the text become 
  26469.                           visible;  if it is positive then later positions in 
  26470.                           the text become visible. 
  26471.  
  26472.            pathName yview ?-pickplace? index  Changes the view in the widget's 
  26473.                           window to make index visible. If the -pickplace 
  26474.                           option isn't specified then index will appear at the 
  26475.                           top of the window. If -pickplace is specified then 
  26476.                           the widget chooses where index appears in the window: 
  26477.  
  26478.                             1. If index is already visible somewhere in the 
  26479.                                window then the command does nothing. 
  26480.  
  26481.                             2. If index is only a few lines off-screen above 
  26482.                                the window then it will be positioned at the top 
  26483.                                of the window. 
  26484.  
  26485.                             3. If index is only a few lines off-screen below 
  26486.                                the window then it will be positioned at the 
  26487.                                bottom of the window. 
  26488.  
  26489.                             4. Otherwise, index will be centered in the window. 
  26490.  
  26491.                           The -pickplace option has been obsoleted by the see 
  26492.                           widget command (see handles both x- and y-motion to 
  26493.                           make a location visible, whereas -pickplace only 
  26494.                           handles motion in y). 
  26495.  
  26496.            pathName yview number  This command makes the first character on the 
  26497.                           line after the one given by number visible at the top 
  26498.                           of the window. Number must be an integer. This 
  26499.                           command used to be used for scrolling, but now it is 
  26500.                           obsolete. 
  26501.  
  26502.  BINDINGS 
  26503.  
  26504.  Tk automatically creates class bindings for texts that give them the following 
  26505.  default behavior. In the descriptions below, "word" refers to a contiguous 
  26506.  group of letters, digits, or "_" characters, or any single character other 
  26507.  than these. 
  26508.  
  26509.    1. Clicking mouse button 1 positions the insertion cursor just before the 
  26510.       character underneath the mouse cursor, sets the input focus to this 
  26511.       widget, and clears any selection in the widget. Dragging with mouse 
  26512.       button 1 strokes out a selection between the insertion cursor and the 
  26513.       character under the mouse. 
  26514.  
  26515.    2. Double-clicking with mouse button 1 selects the word under the mouse and 
  26516.       positions the insertion cursor at the beginning of the word. Dragging 
  26517.       after a double click will stroke out a selection consisting of whole 
  26518.       words. 
  26519.  
  26520.    3. Triple-clicking with mouse button 1 selects the line under the mouse and 
  26521.       positions the insertion cursor at the beginning of the line. Dragging 
  26522.       after a triple click will stroke out a selection consisting of whole 
  26523.       lines. 
  26524.  
  26525.    4. The ends of the selection can be adjusted by dragging with mouse button 1 
  26526.       while the Shift key is down;  this will adjust the end of the selection 
  26527.       that was nearest to the mouse cursor when button 1 was pressed. If the 
  26528.       button is double-clicked before dragging then the selection will be 
  26529.       adjusted in units of whole words;  if it is triple-clicked then the 
  26530.       selection will be adjusted in units of whole lines. 
  26531.  
  26532.    5. Clicking mouse button 1 with the Control key down will reposition the 
  26533.       insertion cursor without affecting the selection. 
  26534.  
  26535.    6. If any normal printing characters are typed, they are inserted at the 
  26536.       point of the insertion cursor. 
  26537.  
  26538.    7. The view in the widget can be adjusted by dragging with mouse button 2. 
  26539.       If mouse button 2 is clicked without moving the mouse, the selection is 
  26540.       copied into the text at the position of the mouse cursor. The Insert key 
  26541.       also inserts the selection, but at the position of the insertion cursor. 
  26542.  
  26543.    8. If the mouse is dragged out of the widget while button 1 is pressed, the 
  26544.       entry will automatically scroll to make more text visible (if there is 
  26545.       more text off-screen on the side where the mouse left the window). 
  26546.  
  26547.    9. The Left and Right keys move the insertion cursor one character to the 
  26548.       left or right;  they also clear any selection in the text. If Left or 
  26549.       Right is typed with the Shift key down, then the insertion cursor moves 
  26550.       and the selection is extended to include the new character. Control-Left 
  26551.       and Control-Right move the insertion cursor by words, and 
  26552.       Control-Shift-Left and Control-Shift-Right move the insertion cursor by 
  26553.       words and also extend the selection. Control-b and Control-f behave the 
  26554.       same as Left and Right, respectively. Meta-b and Meta-f behave the same 
  26555.       as Control-Left and Control-Right, respectively. 
  26556.  
  26557.   10. The Up and Down keys move the insertion cursor one line up or down and 
  26558.       clear any selection in the text. If Up or Right is typed with the Shift 
  26559.       key down, then the insertion cursor moves and the selection is extended 
  26560.       to include the new character. Control-Up and Control-Down move the 
  26561.       insertion cursor by paragraphs (groups of lines separated by blank 
  26562.       lines), and Control-Shift-Up and Control-Shift-Down move the insertion 
  26563.       cursor by paragraphs and also extend the selection. Control-p and 
  26564.       Control-n behave the same as Up and Down, respectively. 
  26565.  
  26566.   11. The Next and Prior keys move the insertion cursor forward or backwards by 
  26567.       one screenful and clear any selection in the text. If the Shift key is 
  26568.       held down while Next or Prior is typed, then the selection is extended to 
  26569.       include the new character. Control-v moves the view down one screenful 
  26570.       without moving the insertion cursor or adjusting the selection. 
  26571.  
  26572.   12. Control-Next and Control-Prior scroll the view right or left by one page 
  26573.       without moving the insertion cursor or affecting the selection. 
  26574.  
  26575.   13. Home and Control-a move the insertion cursor to the beginning of its line 
  26576.       and clear any selection in the widget. Shift-Home moves the insertion 
  26577.       cursor to the beginning of the line and also extends the selection to 
  26578.       that point. 
  26579.  
  26580.   14. End and Control-e move the insertion cursor to the end of the line and 
  26581.       clear any selection in the widget. Shift-End moves the cursor to the end 
  26582.       of the line and extends the selection to that point. 
  26583.  
  26584.   15. Control-Home and Meta-< move the insertion cursor to the beginning of the 
  26585.       text and clear any selection in the widget. Control-Shift-Home moves the 
  26586.       insertion cursor to the beginning of the text and also extends the 
  26587.       selection to that point. 
  26588.  
  26589.   16. Control-End and Meta-> move the insertion cursor to the end of the text 
  26590.       and clear any selection in the widget. Control-Shift-End moves the cursor 
  26591.       to the end of the text and extends the selection to that point. 
  26592.  
  26593.   17. The Select key and Control-Space set the selection anchor to the position 
  26594.       of the insertion cursor.  They don't affect the current selection. 
  26595.       Shift-Select and Control-Shift-Space adjust the selection to the current 
  26596.       position of the insertion cursor, selecting from the anchor to the 
  26597.       insertion cursor if there was not any selection previously. 
  26598.  
  26599.   18. Control-/ selects the entire contents of the widget. 
  26600.  
  26601.   19. Control-\ clears any selection in the widget. 
  26602.  
  26603.   20. The F16 key (labelled Copy on many Sun workstations) or Meta-w copies the 
  26604.       selection in the widget to the clipboard, if there is a selection. 
  26605.  
  26606.   21. The F20 key (labelled Cut on many Sun workstations) or Control-w copies 
  26607.       the selection in the widget to the clipboard and deletes the selection. 
  26608.       If there is no selection in the widget then these keys have no effect. 
  26609.  
  26610.   22. The F18 key (labelled Paste on many Sun workstations) or Control-y 
  26611.       inserts the contents of the clipboard at the position of the insertion 
  26612.       cursor. 
  26613.  
  26614.   23. The Delete key deletes the selection, if there is one in the widget. If 
  26615.       there is no selection, it deletes the character to the right of the 
  26616.       insertion cursor. 
  26617.  
  26618.   24. Backspace and Control-h delete the selection, if there is one in the 
  26619.       widget. If there is no selection, they delete the character to the left 
  26620.       of the insertion cursor. 
  26621.  
  26622.   25. Control-d deletes the character to the right of the insertion cursor. 
  26623.  
  26624.   26. Meta-d deletes the word to the right of the insertion cursor. 
  26625.  
  26626.   27. Control-k deletes from the insertion cursor to the end of its line; if 
  26627.       the insertion cursor is already at the end of a line, then Control-k 
  26628.       deletes the newline character. 
  26629.  
  26630.   28. Control-o opens a new line by inserting a newline character in front of 
  26631.       the insertion cursor without moving the insertion cursor. 
  26632.  
  26633.   29. Meta-backspace and Meta-Delete delete the word to the left of the 
  26634.       insertion cursor. 
  26635.  
  26636.   30. Control-x deletes whatever is selected in the text widget. 
  26637.  
  26638.   31. Control-t reverses the order of the two characters to the right of the 
  26639.       insertion cursor. 
  26640.  
  26641.  If the widget is disabled using the -state option, then its view can still be 
  26642.  adjusted and text can still be selected, but no insertion cursor will be 
  26643.  displayed and no text modifications will take place. 
  26644.  
  26645.  The behavior of texts can be changed by defining new bindings for individual 
  26646.  widgets or by redefining the class bindings. 
  26647.  
  26648.  PERFORMANCE ISSUES 
  26649.  
  26650.  Text widgets should run efficiently under a variety of conditions.  The text 
  26651.  widget uses about 2-3 bytes of main memory for each byte of text, so texts 
  26652.  containing a megabyte or more should be practical on most workstations. Text 
  26653.  is represented internally with a modified B-tree structure that makes 
  26654.  operations relatively efficient even with large texts. Tags are included in 
  26655.  the B-tree structure in a way that allows tags to span large ranges or have 
  26656.  many disjoint smaller ranges without loss of efficiency. Marks are also 
  26657.  implemented in a way that allows large numbers of marks. In most cases it is 
  26658.  fine to have large numbers of unique tags, or a tag that has many distinct 
  26659.  ranges. 
  26660.  
  26661.  One performance problem can arise if you have hundreds or thousands of 
  26662.  different tags that all have the following characteristics: the first and last 
  26663.  ranges of each tag are near the beginning and end of the text, respectively, 
  26664.  or a single tag range covers most of the text widget. The cost of adding and 
  26665.  deleting tags like this is proportional to the number of other tags with the 
  26666.  same properties. In contrast, there is no problem with having thousands of 
  26667.  distinct tags if their overall ranges are localized and spread uniformly 
  26668.  throughout the text. 
  26669.  
  26670.  Very long text lines can be expensive, especially if they have many marks and 
  26671.  tags within them. 
  26672.  
  26673.  The display line with the insert cursor is redrawn each time the cursor 
  26674.  blinks, which causes a steady stream of graphics traffic. Set the 
  26675.  insertOffTime attribute to 0 avoid this. 
  26676.  
  26677.  KEYWORDS 
  26678.  
  26679.  text, widget 
  26680.  
  26681.  
  26682. ΓòÉΓòÉΓòÉ 6.45. tk ΓòÉΓòÉΓòÉ
  26683.  
  26684.  NAME 
  26685.  
  26686. tk - Manipulate Tk internal state 
  26687.  
  26688. SYNOPSIS 
  26689.  
  26690. tk option ?arg arg ...? 
  26691.  
  26692. DESCRIPTION 
  26693.  
  26694. The tk command provides access to miscellaneous elements of Tk's internal 
  26695. state. Most of the information manipulated by this command pertains to the 
  26696. application as a whole, or to a screen or display, rather than to a particular 
  26697. window. The command can take any of a number of different forms depending on 
  26698. the option argument.  The legal forms are: 
  26699.  
  26700.  tk appname ?newName?  If newName isn't specified, this command returns the 
  26701.            name of the application (the name that may be used in send commands 
  26702.            to communicate with the application). If newName is specified, then 
  26703.            the name of the application is changed to newName. If the given name 
  26704.            is already in use, then a suffix of the form " #2" or " #3" is 
  26705.            appended in order to make the name unique. The command's result is 
  26706.            the name actually chosen. newName should not start with a capital 
  26707.            letter. This will interfere with option processing, since names 
  26708.            starting with capitals are assumed to be classes;  as a result, Tk 
  26709.            may not be able to find some options for the application. If sends 
  26710.            have been disabled by deleting the send command, this command will 
  26711.            reenable them and recreate the send command. 
  26712.  
  26713.  KEYWORDS 
  26714.  
  26715.  application name, send 
  26716.  
  26717.  
  26718. ΓòÉΓòÉΓòÉ 6.46. tkerror ΓòÉΓòÉΓòÉ
  26719.  
  26720.  NAME 
  26721.  
  26722. tkerror - Command invoked to process background errors 
  26723.  
  26724. SYNOPSIS 
  26725.  
  26726. tkerror message 
  26727.  
  26728. DESCRIPTION 
  26729.  
  26730. Note: as of Tk 4.1 the tkerror command has been renamed to bgerror because the 
  26731. event loop (which is what usually invokes it) is now part of Tcl.  The changes 
  26732. are backward compatible, so that old uses of tkerror should still work, but you 
  26733. should modify your scripts to use bgerror instead of tkerror. Documentation for 
  26734. bgerror is available as part of Tcl's documentation. 
  26735.  
  26736. KEYWORDS 
  26737.  
  26738. background error, reporting 
  26739.  
  26740.  
  26741. ΓòÉΓòÉΓòÉ 6.47. tkvars ΓòÉΓòÉΓòÉ
  26742.  
  26743.  NAME 
  26744.  
  26745. tkvars - Variables used or set by Tk 
  26746.  
  26747. DESCRIPTION 
  26748.  
  26749. The following Tcl variables are either set or used by Tk at various times in 
  26750. its execution: 
  26751.  
  26752.  tk_library  This variable holds the file name for a directory containing a 
  26753.            library of Tcl scripts related to Tk.  These scripts include an 
  26754.            initialization file that is normally processed whenever a Tk 
  26755.            application starts up, plus other files containing procedures that 
  26756.            implement default behaviors for widgets. The initial value of 
  26757.            tcl_library is set when Tk is added to an interpreter;  this is done 
  26758.            by searching several different directories until one is found that 
  26759.            contains an appropriate Tk startup script. If the TK_LIBRARY 
  26760.            environment variable exists, then the directory it names is checked 
  26761.            first. If TK_LIBRARY isn't set or doesn't refer to an appropriate 
  26762.            directory, then Tk checks several other directories based on a 
  26763.            compiled-in default location, the location of the Tcl library 
  26764.            directory, the location of the binary containing the application, 
  26765.            and the current working directory. The variable can be modified by 
  26766.            an application to switch to a different library. 
  26767.  
  26768.  tk_patchLevel  Contains a decimal integer giving the current patch level for 
  26769.            Tk. The patch level is incremented for each new release or patch, 
  26770.            and it uniquely identifies an official version of Tk. 
  26771.  
  26772.  tkPriv    This variable is an array containing several pieces of information 
  26773.            that are private to Tk.  The elements of tkPriv are used by Tk 
  26774.            library procedures and default bindings. They should not be accessed 
  26775.            by any code outside Tk. 
  26776.  
  26777.  tk_strictMotif  This variable is set to zero by default. If an application 
  26778.            sets it to one, then Tk attempts to adhere as closely as possible to 
  26779.            Motif look-and-feel standards. For example, active elements such as 
  26780.            buttons and scrollbar sliders will not change color when the pointer 
  26781.            passes over them. 
  26782.  
  26783.  tk_version  Tk sets this variable in the interpreter for each application. The 
  26784.            variable holds the current version number of the Tk library in the 
  26785.            form major.minor.  Major and minor are integers.  The major version 
  26786.            number increases in any Tk release that includes changes that are 
  26787.            not backward compatible (i.e. whenever existing Tk applications and 
  26788.            scripts may have to change to work with the new release).  The minor 
  26789.            version number increases with each new release of Tk, except that it 
  26790.            resets to zero whenever the major version number changes. 
  26791.  
  26792.  KEYWORDS 
  26793.  
  26794.  variables, version 
  26795.  
  26796.  
  26797. ΓòÉΓòÉΓòÉ 6.48. tkwait ΓòÉΓòÉΓòÉ
  26798.  
  26799.  NAME 
  26800.  
  26801. tkwait - Wait for variable to change or window to be destroyed 
  26802.  
  26803. SYNOPSIS 
  26804.  
  26805. tkwait variable name 
  26806.  tkwait visibility name 
  26807.  tkwait window name 
  26808.  
  26809. DESCRIPTION 
  26810.  
  26811. The tkwait command waits for one of several things to happen, then it returns 
  26812. without taking any other actions. The return value is always an empty string. 
  26813. If the first argument is variable (or any abbreviation of it) then the second 
  26814. argument is the name of a global variable and the command waits for that 
  26815. variable to be modified. If the first argument is visibility (or any 
  26816. abbreviation of it) then the second argument is the name of a window and the 
  26817. tkwait command waits for a change in its visibility state (as indicated by the 
  26818. arrival of a VisibilityNotify event).  This form is typically used to wait for 
  26819. a newly-created window to appear on the screen before taking some action. If 
  26820. the first argument is window (or any abbreviation of it) then the second 
  26821. argument is the name of a window and the tkwait command waits for that window 
  26822. to be destroyed. This form is typically used to wait for a user to finish 
  26823. interacting with a dialog box before using the result of that interaction. 
  26824.  
  26825. While the tkwait command is waiting it processes events in the normal fashion, 
  26826. so the application will continue to respond to user interactions. If an event 
  26827. handler invokes tkwait again, the nested call to tkwait must complete before 
  26828. the outer call can complete. 
  26829.  
  26830. KEYWORDS 
  26831.  
  26832. variable, visibility, wait, window 
  26833.  
  26834.  
  26835. ΓòÉΓòÉΓòÉ 6.49. toplevel ΓòÉΓòÉΓòÉ
  26836.  
  26837.  NAME 
  26838.  
  26839. toplevel - Create and manipulate toplevel widgets 
  26840.  
  26841. SYNOPSIS 
  26842.  
  26843. toplevel pathName ?options? 
  26844.  
  26845. STANDARD OPTIONS 
  26846.  
  26847. -borderwidth         -highlightbackground -highlightthickness  -takefocus
  26848. -cursor              -highlightcolor      -relief
  26849.  
  26850. See the options manual entry for detailed descriptions of the above options.
  26851.  
  26852. WIDGET-SPECIFIC OPTIONS 
  26853.  
  26854.   Command-Line Name:    -background
  26855.   Database Name:        background
  26856.   Database Class:       Background
  26857.  
  26858.            This option is the same as the standard background option except 
  26859.            that its value may also be specified as an empty string. In this 
  26860.            case, the widget will display no background or border, and no colors 
  26861.            will be consumed from its colormap for its background and border. 
  26862.  
  26863.   Command-Line Name:    -class
  26864.   Database Name:        class
  26865.   Database Class:       Class
  26866.  
  26867.            Specifies a class for the window. This class will be used when 
  26868.            querying the option database for the window's other options, and it 
  26869.            will also be used later for other purposes such as bindings. The 
  26870.            class option may not be changed with the configure widget command. 
  26871.  
  26872.   Command-Line Name:    -colormap
  26873.   Database Name:        colormap
  26874.   Database Class:       Colormap
  26875.  
  26876.            Specifies a colormap to use for the window. The value may be either 
  26877.            new, in which case a new colormap is created for the window and its 
  26878.            children, or the name of another window (which must be on the same 
  26879.            screen and have the same visual as pathName), in which case the new 
  26880.            window will use the colormap from the specified window. If the 
  26881.            colormap option is not specified, the new window uses the default 
  26882.            colormap of its screen. This option may not be changed with the 
  26883.            configure widget command. 
  26884.  
  26885.   Command-Line Name:    -height
  26886.   Database Name:        height
  26887.   Database Class:       Height
  26888.  
  26889.            Specifies the desired height for the window in any of the forms 
  26890.            acceptable to Tk_GetPixels. If this option is less than or equal to 
  26891.            zero then the window will not request any size at all. 
  26892.  
  26893.   Command-Line Name:    -screen
  26894.   Database Name:
  26895.   Database Class:
  26896.  
  26897.            Specifies the screen on which to place the new window. Any valid 
  26898.            screen name may be used, even one associated with a different 
  26899.            display. Defaults to the same screen as its parent. This option is 
  26900.            special in that it may not be specified via the option database, and 
  26901.            it may not be modified with the configure widget command. 
  26902.  
  26903.   Command-Line Name:    -visual
  26904.   Database Name:        visual
  26905.   Database Class:       Visual
  26906.  
  26907.            Specifies visual information for the new window in any of the forms 
  26908.            accepted by Tk_GetVisual. If this option is not specified, the new 
  26909.            window will use the default visual for its screen. The visual option 
  26910.            may not be modified with the configure widget command. 
  26911.  
  26912.   Command-Line Name:    -width
  26913.   Database Name:        width
  26914.   Database Class:       Width
  26915.  
  26916.            Specifies the desired width for the window in any of the forms 
  26917.            acceptable to Tk_GetPixels. If this option is less than or equal to 
  26918.            zero then the window will not request any size at all. 
  26919.  
  26920.  DESCRIPTION 
  26921.  
  26922.  The toplevel command creates a new toplevel widget (given by the pathName 
  26923.  argument).  Additional options, described above, may be specified on the 
  26924.  command line or in the option database to configure aspects of the toplevel 
  26925.  such as its background color and relief.  The toplevel command returns the 
  26926.  path name of the new window. 
  26927.  
  26928.  A toplevel is similar to a frame except that it is created as a top-level 
  26929.  window:  its X parent is the root window of a screen rather than the logical 
  26930.  parent from its path name.  The primary purpose of a toplevel is to serve as a 
  26931.  container for dialog boxes and other collections of widgets.  The only visible 
  26932.  features of a toplevel are its background color and an optional 3-D border to 
  26933.  make the toplevel appear raised or sunken. 
  26934.  
  26935.  WIDGET COMMAND 
  26936.  
  26937.  The toplevel command creates a new Tcl command whose name is the same as the 
  26938.  path name of the toplevel's window.  This command may be used to invoke 
  26939.  various operations on the widget.  It has the following general form: 
  26940.  
  26941.   pathName option ?arg arg ...?
  26942.  PathName is the name of the command, which is the same as the toplevel 
  26943.  widget's path name.  Option and the args determine the exact behavior of the 
  26944.  command.  The following commands are possible for toplevel widgets: 
  26945.  
  26946.  pathName cget option  Returns the current value of the configuration option 
  26947.            given by option. Option may have any of the values accepted by the 
  26948.            toplevel command. 
  26949.  
  26950.  pathName configure ?option? ?value option value ...?  Query or modify the 
  26951.            configuration options of the widget. If no option is specified, 
  26952.            returns a list describing all of the available options for pathName 
  26953.            (see Tk_ConfigureInfo for information on the format of this list). 
  26954.            If option is specified with no value, then the command returns a 
  26955.            list describing the one named option (this list will be identical to 
  26956.            the corresponding sublist of the value returned if no option is 
  26957.            specified).  If one or more option-value pairs are specified, then 
  26958.            the command modifies the given widget option(s) to have the given 
  26959.            value(s);  in this case the command returns an empty string. Option 
  26960.            may have any of the values accepted by the toplevel command. 
  26961.  
  26962.  BINDINGS 
  26963.  
  26964.  When a new toplevel is created, it has no default event bindings: toplevels 
  26965.  are not intended to be interactive. 
  26966.  
  26967.  KEYWORDS 
  26968.  
  26969.  toplevel, widget 
  26970.  
  26971.  
  26972. ΓòÉΓòÉΓòÉ 6.50. winfo ΓòÉΓòÉΓòÉ
  26973.  
  26974.  NAME 
  26975.  
  26976. winfo - Return window-related information 
  26977.  
  26978. SYNOPSIS 
  26979.  
  26980. winfo option ?arg arg ...? 
  26981.  
  26982. DESCRIPTION 
  26983.  
  26984. The winfo command is used to retrieve information about windows managed by Tk. 
  26985. It can take any of a number of different forms, depending on the option 
  26986. argument.  The legal forms are: 
  26987.  
  26988.  winfo atom ?-displayof window? name  Returns a decimal string giving the 
  26989.            integer identifier for the atom whose name is name.  If no atom 
  26990.            exists with the name name then a new one is created. If the 
  26991.            -displayof option is given then the atom is looked up on the display 
  26992.            of window;  otherwise it is looked up on the display of the 
  26993.            application's main window. 
  26994.  
  26995.  winfo atomname ?-displayof window? id  Returns the textual name for the atom 
  26996.            whose integer identifier is id. If the -displayof option is given 
  26997.            then the identifier is looked up on the display of window; 
  26998.            otherwise it is looked up on the display of the application's main 
  26999.            window. This command is the inverse of the winfo atom command. It 
  27000.            generates an error if no such atom exists. 
  27001.  
  27002.  winfo cells window  Returns a decimal string giving the number of cells in the 
  27003.            color map for window. 
  27004.  
  27005.  winfo children window  Returns a list containing the path names of all the 
  27006.            children of window.  Top-level windows are returned as children of 
  27007.            their logical parents. 
  27008.  
  27009.  winfo class window  Returns the class name for window. 
  27010.  
  27011.  winfo colormapfull window  Returns 1 if the colormap for window is known to be 
  27012.            full, 0 otherwise.  The colormap for a window is "known" to be full 
  27013.            if the last attempt to allocate a new color on that window failed 
  27014.            and this application hasn't freed any colors in the colormap since 
  27015.            the failed allocation. 
  27016.  
  27017.  winfo containing ?-displayof window? rootX rootY  Returns the path name for 
  27018.            the window containing the point given by rootX and rootY. RootX and 
  27019.            rootY are specified in screen units (i.e. any form acceptable to 
  27020.            Tk_GetPixels) in the coordinate system of the root window (if a 
  27021.            virtual-root window manager is in use then the coordinate system of 
  27022.            the virtual root window is used). If the -displayof option is given 
  27023.            then the coordinates refer to the screen containing window; 
  27024.            otherwise they refer to the screen of the application's main window. 
  27025.            If no window in this application contains the point then an empty 
  27026.            string is returned. In selecting the containing window, children are 
  27027.            given higher priority than parents and among siblings the highest 
  27028.            one in the stacking order is chosen. 
  27029.  
  27030.  winfo depth window  Returns a decimal string giving the depth of window 
  27031.            (number of bits per pixel). 
  27032.  
  27033.  winfo exists window  Returns 1 if there exists a window named window, 0 if no 
  27034.            such window exists. 
  27035.  
  27036.  winfo fpixels window number  Returns a floating-point value giving the number 
  27037.            of pixels in window corresponding to the distance given by number. 
  27038.            Number may be specified in any of the forms acceptable to 
  27039.            Tk_GetScreenMM, such as "2.0c" or "1i". The return value may be 
  27040.            fractional;  for an integer value, use winfo pixels. 
  27041.  
  27042.  winfo geometry window  Returns the geometry for window, in the form 
  27043.            widthxheight+x+y.  All dimensions are in pixels. 
  27044.  
  27045.  winfo height window  Returns a decimal string giving window's height in 
  27046.            pixels. When a window is first created its height will be 1 pixel; 
  27047.            the height will eventually be changed by a geometry manager to 
  27048.            fulfill the window's needs. If you need the true height immediately 
  27049.            after creating a widget, invoke update to force the geometry manager 
  27050.            to arrange it, or use winfo reqheight to get the window's requested 
  27051.            height instead of its actual height. 
  27052.  
  27053.  winfo id window  Returns a hexadecimal string indicating the X identifier for 
  27054.            window. 
  27055.  
  27056.  winfo interps ?-displayof window?  Returns a list whose members are the names 
  27057.            of all Tcl interpreters (e.g. all Tk-based applications) currently 
  27058.            registered for a particular display. If the -displayof option is 
  27059.            given then the return value refers to the display of window; 
  27060.            otherwise it refers to the display of the application's main window. 
  27061.  
  27062.  winfo ismapped window  Returns 1 if window is currently mapped, 0 otherwise. 
  27063.  
  27064.  winfo manager window  Returns the name of the geometry manager currently 
  27065.            responsible for window, or an empty string if window isn't managed 
  27066.            by any geometry manager. The name is usually the name of the Tcl 
  27067.            command for the geometry manager, such as pack or place. If the 
  27068.            geometry manager is a widget, such as canvases or text, the name is 
  27069.            the widget's class command, such as canvas. 
  27070.  
  27071.  winfo name window  Returns window's name (i.e. its name within its parent, as 
  27072.            opposed to its full path name). The command winfo name . will return 
  27073.            the name of the application. 
  27074.  
  27075.  winfo parent window  Returns the path name of window's parent, or an empty 
  27076.            string if window is the main window of the application. 
  27077.  
  27078.  winfo pathname ?-displayof window? id  Returns the path name of the window 
  27079.            whose X identifier is id. Id must be a decimal, hexadecimal, or 
  27080.            octal integer and must correspond to a window in the invoking 
  27081.            application. If the -displayof option is given then the identifier 
  27082.            is looked up on the display of window;  otherwise it is looked up on 
  27083.            the display of the application's main window. 
  27084.  
  27085.  winfo pixels window number  Returns the number of pixels in window 
  27086.            corresponding to the distance given by number. Number may be 
  27087.            specified in any of the forms acceptable to Tk_GetPixels, such as 
  27088.            "2.0c" or "1i". The result is rounded to the nearest integer value; 
  27089.            for a fractional result, use winfo fpixels. 
  27090.  
  27091.  winfo pointerx window  If the mouse pointer is on the same screen as window, 
  27092.            returns the pointer's x coordinate, measured in pixels in the 
  27093.            screen's root window. If a virtual root window is in use on the 
  27094.            screen, the position is measured in the virtual root. If the mouse 
  27095.            pointer isn't on the same screen as window then -1 is returned. 
  27096.  
  27097.  winfo pointerxy window  If the mouse pointer is on the same screen as window, 
  27098.            returns a list with two elements, which are the pointer's x and y 
  27099.            coordinates measured in pixels in the screen's root window. If a 
  27100.            virtual root window is in use on the screen, the position is 
  27101.            computed in the virtual root. If the mouse pointer isn't on the same 
  27102.            screen as window then both of the returned coordinates are -1. 
  27103.  
  27104.  winfo pointery window  If the mouse pointer is on the same screen as window, 
  27105.            returns the pointer's y coordinate, measured in pixels in the 
  27106.            screen's root window. If a virtual root window is in use on the 
  27107.            screen, the position is computed in the virtual root. If the mouse 
  27108.            pointer isn't on the same screen as window then -1 is returned. 
  27109.  
  27110.  winfo reqheight window  Returns a decimal string giving window's requested 
  27111.            height, in pixels.  This is the value used by window's geometry 
  27112.            manager to compute its geometry. 
  27113.  
  27114.  winfo reqwidth window  Returns a decimal string giving window's requested 
  27115.            width, in pixels.  This is the value used by window's geometry 
  27116.            manager to compute its geometry. 
  27117.  
  27118.  winfo rgb window color  Returns a list containing three decimal values, which 
  27119.            are the red, green, and blue intensities that correspond to color in 
  27120.            the window given by window.  Color may be specified in any of the 
  27121.            forms acceptable for a color option. 
  27122.  
  27123.  winfo rootx window  Returns a decimal string giving the x-coordinate, in the 
  27124.            root window of the screen, of the upper-left corner of window's 
  27125.            border (or window if it has no border). 
  27126.  
  27127.  winfo rooty window  Returns a decimal string giving the y-coordinate, in the 
  27128.            root window of the screen, of the upper-left corner of window's 
  27129.            border (or window if it has no border). 
  27130.  
  27131.  winfo screen window  Returns the name of the screen associated with window, in 
  27132.            the form displayName.screenIndex. 
  27133.  
  27134.  winfo screencells window  Returns a decimal string giving the number of cells 
  27135.            in the default color map for window's screen. 
  27136.  
  27137.  winfo screendepth window  Returns a decimal string giving the depth of the 
  27138.            root window of window's screen (number of bits per pixel). 
  27139.  
  27140.  winfo screenheight window  Returns a decimal string giving the height of 
  27141.            window's screen, in pixels. 
  27142.  
  27143.  winfo screenmmheight window  Returns a decimal string giving the height of 
  27144.            window's screen, in millimeters. 
  27145.  
  27146.  winfo screenmmwidth window  Returns a decimal string giving the width of 
  27147.            window's screen, in millimeters. 
  27148.  
  27149.  winfo screenvisual window  Returns one of the following strings to indicate 
  27150.            the default visual class for window's screen: directcolor, 
  27151.            grayscale, pseudocolor, staticcolor, staticgray, or truecolor. 
  27152.  
  27153.  winfo screenwidth window  Returns a decimal string giving the width of 
  27154.            window's screen, in pixels. 
  27155.  
  27156.  winfo server window  Returns a string containing information about the server 
  27157.            for window's display.  The exact format of this string may vary from 
  27158.            platform to platform.  For X servers the string has the form 
  27159.            "XmajorRminor vendor vendorVersion" where major and minor are the 
  27160.            version and revision numbers provided by the server (e.g., X11R5), 
  27161.            vendor is the name of the vendor for the server, and vendorRelease 
  27162.            is an integer release number provided by the server. 
  27163.  
  27164.  winfo toplevel window  Returns the path name of the top-level window 
  27165.            containing window. 
  27166.  
  27167.  winfo viewable window  Returns 1 if window and all of its ancestors up through 
  27168.            the nearest toplevel window are mapped.  Returns 0 if any of these 
  27169.            windows are not mapped. 
  27170.  
  27171.  winfo visual window  Returns one of the following strings to indicate the 
  27172.            visual class for window: directcolor, grayscale, pseudocolor, 
  27173.            staticcolor, staticgray, or truecolor. 
  27174.  
  27175.  winfo visualid window  Returns the X identifier for the visual for window. 
  27176.  
  27177.  winfo visualsavailable window ?includeids?  Returns a list whose elements 
  27178.            describe the visuals available for window's screen. Each element 
  27179.            consists of a visual class followed by an integer depth. The class 
  27180.            has the same form as returned by winfo visual. The depth gives the 
  27181.            number of bits per pixel in the visual. In addition, if the 
  27182.            includeids argument is provided, then the depth is followed by the X 
  27183.            identifier for the visual. 
  27184.  
  27185.  winfo vrootheight window  Returns the height of the virtual root window 
  27186.            associated with window if there is one;  otherwise returns the 
  27187.            height of window's screen. 
  27188.  
  27189.  winfo vrootwidth window  Returns the width of the virtual root window 
  27190.            associated with window if there is one;  otherwise returns the width 
  27191.            of window's screen. 
  27192.  
  27193.  winfo vrootx window  Returns the x-offset of the virtual root window 
  27194.            associated with window, relative to the root window of its screen. 
  27195.            This is normally either zero or negative. Returns 0 if there is no 
  27196.            virtual root window for window. 
  27197.  
  27198.  winfo vrooty window  Returns the y-offset of the virtual root window 
  27199.            associated with window, relative to the root window of its screen. 
  27200.            This is normally either zero or negative. Returns 0 if there is no 
  27201.            virtual root window for window. 
  27202.  
  27203.  winfo width window  Returns a decimal string giving window's width in pixels. 
  27204.            When a window is first created its width will be 1 pixel;  the width 
  27205.            will eventually be changed by a geometry manager to fulfill the 
  27206.            window's needs. If you need the true width immediately after 
  27207.            creating a widget, invoke update to force the geometry manager to 
  27208.            arrange it, or use winfo reqwidth to get the window's requested 
  27209.            width instead of its actual width. 
  27210.  
  27211.  winfo x window  Returns a decimal string giving the x-coordinate, in window's 
  27212.            parent, of the upper-left corner of window's border (or window if it 
  27213.            has no border). 
  27214.  
  27215.  winfo y window  Returns a decimal string giving the y-coordinate, in window's 
  27216.            parent, of the upper-left corner of window's border (or window if it 
  27217.            has no border). 
  27218.  
  27219.  KEYWORDS 
  27220.  
  27221.  atom, children, class, geometry, height, identifier, information, 
  27222.  interpreters, mapped, parent, path name, screen, virtual root, width, window 
  27223.  
  27224.  
  27225. ΓòÉΓòÉΓòÉ 6.51. wm ΓòÉΓòÉΓòÉ
  27226.  
  27227.  NAME 
  27228.  
  27229. wm - Communicate with window manager 
  27230.  
  27231. SYNOPSIS 
  27232.  
  27233. wm option window ?args? 
  27234.  
  27235. DESCRIPTION 
  27236.  
  27237. The wm command is used to interact with window managers in order to control 
  27238. such things as the title for a window, its geometry, or the increments in terms 
  27239. of which it may be resized.  The wm command can take any of a number of 
  27240. different forms, depending on the option argument.  All of the forms expect at 
  27241. least one additional argument, window, which must be the path name of a 
  27242. top-level window. 
  27243.  
  27244. The legal forms for the wm command are: 
  27245.  
  27246.  wm aspect window ?minNumer minDenom maxNumer maxDenom?  If minNumer, minDenom, 
  27247.            maxNumer, and maxDenom are all specified, then they will be passed 
  27248.            to the window manager and the window manager should use them to 
  27249.            enforce a range of acceptable aspect ratios for window.  The aspect 
  27250.            ratio of window (width/length) will be constrained to lie between 
  27251.            minNumer/minDenom and maxNumer/maxDenom. If minNumer etc. are all 
  27252.            specified as empty strings, then any existing aspect ratio 
  27253.            restrictions are removed. If minNumer etc. are specified, then the 
  27254.            command returns an empty string.  Otherwise, it returns a Tcl list 
  27255.            containing four elements, which are the current values of minNumer, 
  27256.            minDenom, maxNumer, and maxDenom (if no aspect restrictions are in 
  27257.            effect, then an empty string is returned). 
  27258.  
  27259.  wm client window ?name?  If name is specified, this command stores name (which 
  27260.            should be the name of the host on which the application is 
  27261.            executing) in window's WM_CLIENT_MACHINE property for use by the 
  27262.            window manager or session manager. The command returns an empty 
  27263.            string in this case. If name isn't specified, the command returns 
  27264.            the last name set in a wm client command for window. If name is 
  27265.            specified as an empty string, the command deletes the 
  27266.            WM_CLIENT_MACHINE property from window. 
  27267.  
  27268.  wm colormapwindows window ?windowList?  This command is used to manipulate the 
  27269.            WM_COLORMAP_WINDOWS property, which provides information to the 
  27270.            window managers about windows that have private colormaps. If 
  27271.            windowList isn't specified, the command returns a list whose 
  27272.            elements are the names of the windows in the WM_COLORMAP_WINDOWS 
  27273.            property. If windowList is specified, it consists of a list of 
  27274.            window path names;  the command overwrites the WM_COLORMAP_WINDOWS 
  27275.            property with the given windows and returns an empty string. The 
  27276.            WM_COLORMAP_WINDOWS property should normally contain a list of the 
  27277.            internal windows within window whose colormaps differ from their 
  27278.            parents. The order of the windows in the property indicates a 
  27279.            priority order: the window manager will attempt to install as many 
  27280.            colormaps as possible from the head of this list when window gets 
  27281.            the colormap focus. If window is not included among the windows in 
  27282.            windowList, Tk implicitly adds it at the end of the 
  27283.            WM_COLORMAP_WINDOWS property, so that its colormap is lowest in 
  27284.            priority. If wm colormapwindows is not invoked, Tk will 
  27285.            automatically set the property for each top-level window to all the 
  27286.            internal windows whose colormaps differ from their parents, followed 
  27287.            by the top-level itself;  the order of the internal windows is 
  27288.            undefined. See the ICCCM documentation for more information on the 
  27289.            WM_COLORMAP_WINDOWS property. 
  27290.  
  27291.  wm command window ?value?  If value is specified, this command stores value in 
  27292.            window's WM_COMMAND property for use by the window manager or 
  27293.            session manager and returns an empty string. Value must have proper 
  27294.            list structure;  the elements should contain the words of the 
  27295.            command used to invoke the application. If value isn't specified 
  27296.            then the command returns the last value set in a wm command command 
  27297.            for window. If value is specified as an empty string, the command 
  27298.            deletes the WM_COMMAND property from window. 
  27299.  
  27300.  wm deiconify window  Arrange for window to be displayed in normal 
  27301.            (non-iconified) form. This is done by mapping the window.  If the 
  27302.            window has never been mapped then this command will not map the 
  27303.            window, but it will ensure that when the window is first mapped it 
  27304.            will be displayed in de-iconified form.  Returns an empty string. 
  27305.  
  27306.  wm focusmodel window ?active|passive?  If active or passive is supplied as an 
  27307.            optional argument to the command, then it specifies the focus model 
  27308.            for window. In this case the command returns an empty string.  If no 
  27309.            additional argument is supplied, then the command returns the 
  27310.            current focus model for window. An active focus model means that 
  27311.            window will claim the input focus for itself or its descendants, 
  27312.            even at times when the focus is currently in some other application. 
  27313.            Passive means that window will never claim the focus for itself: 
  27314.            the window manager should give the focus to window at appropriate 
  27315.            times.  However, once the focus has been given to window or one of 
  27316.            its descendants, the application may re-assign the focus among 
  27317.            window's descendants. The focus model defaults to passive, and Tk's 
  27318.            focus command assumes a passive model of focusing. 
  27319.  
  27320.  wm frame window  If window has been reparented by the window manager into a 
  27321.            decorative frame, the command returns the X window identifier for 
  27322.            the outermost frame that contains window (the window whose parent is 
  27323.            the root or virtual root).  If window hasn't been reparented by the 
  27324.            window manager then the command returns the X window identifier for 
  27325.            window. 
  27326.  
  27327.  wm geometry window ?newGeometry?  If newGeometry is specified, then the 
  27328.            geometry of window is changed and an empty string is returned. 
  27329.            Otherwise the current geometry for window is returned (this is the 
  27330.            most recent geometry specified either by manual resizing or in a wm 
  27331.            geometry command).  NewGeometry has the form =widthxheight╤æx╤æy, 
  27332.            where any of =, widthxheight, or ╤æx╤æy may be omitted.  Width and 
  27333.            height are positive integers specifying the desired dimensions of 
  27334.            window.  If window is gridded (see GRIDDED GEOMETRY MANAGEMENT 
  27335.            below) then the dimensions are specified in grid units;  otherwise 
  27336.            they are specified in pixel units.  X and y specify the desired 
  27337.            location of window on the screen, in pixels. If x is preceded by +, 
  27338.            it specifies the number of pixels between the left edge of the 
  27339.            screen and the left edge of window's border;  if preceded by - then 
  27340.            x specifies the number of pixels between the right edge of the 
  27341.            screen and the right edge of window's border.  If y is preceded by + 
  27342.            then it specifies the number of pixels between the top of the screen 
  27343.            and the top of window's border;  if y is preceded by - then it 
  27344.            specifies the number of pixels between the bottom of window's border 
  27345.            and the bottom of the screen. If newGeometry is specified as an 
  27346.            empty string then any existing user-specified geometry for window is 
  27347.            cancelled, and the window will revert to the size requested 
  27348.            internally by its widgets. 
  27349.  
  27350.  wm grid window ?baseWidth baseHeight widthInc heightInc?  This command 
  27351.            indicates that window is to be managed as a gridded window. It also 
  27352.            specifies the relationship between grid units and pixel units. 
  27353.            BaseWidth and baseHeight specify the number of grid units 
  27354.            corresponding to the pixel dimensions requested internally by window 
  27355.            using Tk_GeometryRequest.  WidthInc and heightInc specify the number 
  27356.            of pixels in each horizontal and vertical grid unit. These four 
  27357.            values determine a range of acceptable sizes for window, 
  27358.            corresponding to grid-based widths and heights that are non-negative 
  27359.            integers. Tk will pass this information to the window manager; 
  27360.            during manual resizing, the window manager will restrict the 
  27361.            window's size to one of these acceptable sizes. Furthermore, during 
  27362.            manual resizing the window manager will display the window's current 
  27363.            size in terms of grid units rather than pixels. If baseWidth etc. 
  27364.            are all specified as empty strings, then window will no longer be 
  27365.            managed as a gridded window.  If baseWidth etc. are specified then 
  27366.            the return value is an empty string. Otherwise the return value is a 
  27367.            Tcl list containing four elements corresponding to the current 
  27368.            baseWidth, baseHeight, widthInc, and heightInc;  if window is not 
  27369.            currently gridded, then an empty string is returned. Note: this 
  27370.            command should not be needed very often, since the Tk_SetGrid 
  27371.            library procedure and the setGrid option provide easier access to 
  27372.            the same functionality. 
  27373.  
  27374.  wm group window ?pathName?  If pathName is specified, it gives the path name 
  27375.            for the leader of a group of related windows.  The window manager 
  27376.            may use this information, for example, to unmap all of the windows 
  27377.            in a group when the group's leader is iconified.  PathName may be 
  27378.            specified as an empty string to remove window from any group 
  27379.            association.  If pathName is specified then the command returns an 
  27380.            empty string;  otherwise it returns the path name of window's 
  27381.            current group leader, or an empty string if window isn't part of any 
  27382.            group. 
  27383.  
  27384.  wm iconbitmap window ?bitmap?  If bitmap is specified, then it names a bitmap 
  27385.            in the standard forms accepted by Tk (see the Tk_GetBitmap manual 
  27386.            entry for details). This bitmap is passed to the window manager to 
  27387.            be displayed in window's icon, and the command returns an empty 
  27388.            string.  If an empty string is specified for bitmap, then any 
  27389.            current icon bitmap is cancelled for window. If bitmap is specified 
  27390.            then the command returns an empty string. Otherwise it returns the 
  27391.            name of the current icon bitmap associated with window, or an empty 
  27392.            string if window has no icon bitmap. 
  27393.  
  27394.  wm iconify window  Arrange for window to be iconified.  It window hasn't yet 
  27395.            been mapped for the first time, this command will arrange for it to 
  27396.            appear in the iconified state when it is eventually mapped. 
  27397.  
  27398.  wm iconmask window ?bitmap?  If bitmap is specified, then it names a bitmap in 
  27399.            the standard forms accepted by Tk (see the Tk_GetBitmap manual entry 
  27400.            for details). This bitmap is passed to the window manager to be used 
  27401.            as a mask in conjunction with the iconbitmap option:  where the mask 
  27402.            has zeroes no icon will be displayed;  where it has ones, the bits 
  27403.            from the icon bitmap will be displayed.  If an empty string is 
  27404.            specified for bitmap then any current icon mask is cancelled for 
  27405.            window (this is equivalent to specifying a bitmap of all ones).  If 
  27406.            bitmap is specified then the command returns an empty string. 
  27407.            Otherwise it returns the name of the current icon mask associated 
  27408.            with window, or an empty string if no mask is in effect. 
  27409.  
  27410.  wm iconname window ?newName?  If newName is specified, then it is passed to 
  27411.            the window manager;  the window manager should display newName 
  27412.            inside the icon associated with window.  In this case an empty 
  27413.            string is returned as result.  If newName isn't specified then the 
  27414.            command returns the current icon name for window, or an empty string 
  27415.            if no icon name has been specified (in this case the window manager 
  27416.            will normally display the window's title, as specified with the wm 
  27417.            title command). 
  27418.  
  27419.  wm iconposition window ?x y?  If x and y are specified, they are passed to the 
  27420.            window manager as a hint about where to position the icon for 
  27421.            window. In this case an empty string is returned.  If x and y are 
  27422.            specified as empty strings then any existing icon position hint is 
  27423.            cancelled. If neither x nor y is specified, then the command returns 
  27424.            a Tcl list containing two values, which are the current icon 
  27425.            position hints (if no hints are in effect then an empty string is 
  27426.            returned). 
  27427.  
  27428.  wm iconwindow window ?pathName?  If pathName is specified, it is the path name 
  27429.            for a window to use as icon for window: when window is iconified 
  27430.            then pathName will be mapped to serve as icon, and when window is 
  27431.            de-iconified then pathName will be unmapped again.  If pathName is 
  27432.            specified as an empty string then any existing icon window 
  27433.            association for window will be cancelled.  If the pathName argument 
  27434.            is specified then an empty string is returned.  Otherwise the 
  27435.            command returns the path name of the current icon window for window, 
  27436.            or an empty string if there is no icon window currently specified 
  27437.            for window. Button press events are disabled for window as long as 
  27438.            it is an icon window;  this is needed in order to allow window 
  27439.            managers to "own" those events. Note: not all window managers 
  27440.            support the notion of an icon window. 
  27441.  
  27442.  wm maxsize window ?width height?  If width and height are specified, they give 
  27443.            the maximum permissible dimensions for window. For gridded windows 
  27444.            the dimensions are specified in grid units;  otherwise they are 
  27445.            specified in pixel units. The window manager will restrict the 
  27446.            window's dimensions to be less than or equal to width and height. If 
  27447.            width and height are specified, then the command returns an empty 
  27448.            string.  Otherwise it returns a Tcl list with two elements, which 
  27449.            are the maximum width and height currently in effect. The maximum 
  27450.            size defaults to the size of the screen. If resizing has been 
  27451.            disabled with the wm resizable command, then this command has no 
  27452.            effect. See the sections on geometry management below for more 
  27453.            information. 
  27454.  
  27455.  wm minsize window ?width height?  If width and height are specified, they give 
  27456.            the minimum permissible dimensions for window. For gridded windows 
  27457.            the dimensions are specified in grid units;  otherwise they are 
  27458.            specified in pixel units. The window manager will restrict the 
  27459.            window's dimensions to be greater than or equal to width and height. 
  27460.            If width and height are specified, then the command returns an empty 
  27461.            string.  Otherwise it returns a Tcl list with two elements, which 
  27462.            are the minimum width and height currently in effect. The minimum 
  27463.            size defaults to one pixel in each dimension. If resizing has been 
  27464.            disabled with the wm resizable command, then this command has no 
  27465.            effect. See the sections on geometry management below for more 
  27466.            information. 
  27467.  
  27468.  wm overrideredirect window ?boolean?  If boolean is specified, it must have a 
  27469.            proper boolean form and the override-redirect flag for window is set 
  27470.            to that value. If boolean is not specified then 1 or 0 is returned 
  27471.            to indicate whether or not the override-redirect flag is currently 
  27472.            set for window. Setting the override-redirect flag for a window 
  27473.            causes it to be ignored by the window manager;  among other things, 
  27474.            this means that the window will not be reparented from the root 
  27475.            window into a decorative frame and the user will not be able to 
  27476.            manipulate the window using the normal window manager mechanisms. 
  27477.  
  27478.  wm positionfrom window ?who?  If who is specified, it must be either program 
  27479.            or user, or an abbreviation of one of these two.  It indicates 
  27480.            whether window's current position was requested by the program or by 
  27481.            the user.  Many window managers ignore program-requested initial 
  27482.            positions and ask the user to manually position the window;  if user 
  27483.            is specified then the window manager should position the window at 
  27484.            the given place without asking the user for assistance. If who is 
  27485.            specified as an empty string, then the current position source is 
  27486.            cancelled. If who is specified, then the command returns an empty 
  27487.            string. Otherwise it returns user or window to indicate the source 
  27488.            of the window's current position, or an empty string if no source 
  27489.            has been specified yet.  Most window managers interpret "no source" 
  27490.            as equivalent to program. Tk will automatically set the position 
  27491.            source to user when a wm geometry command is invoked, unless the 
  27492.            source has been set explicitly to program. 
  27493.  
  27494.  wm protocol window ?name? ?command?  This command is used to manage window 
  27495.            manager protocols such as WM_DELETE_WINDOW. Name is the name of an 
  27496.            atom corresponding to a window manager protocol, such as 
  27497.            WM_DELETE_WINDOW or WM_SAVE_YOURSELF or WM_TAKE_FOCUS. If both name 
  27498.            and command are specified, then command is associated with the 
  27499.            protocol specified by name. Name will be added to window's 
  27500.            WM_PROTOCOLS property to tell the window manager that the 
  27501.            application has a protocol handler for name, and command will be 
  27502.            invoked in the future whenever the window manager sends a message to 
  27503.            the client for that protocol. In this case the command returns an 
  27504.            empty string. If name is specified but command isn't, then the 
  27505.            current command for name is returned, or an empty string if there is 
  27506.            no handler defined for name. If command is specified as an empty 
  27507.            string then the current handler for name is deleted and it is 
  27508.            removed from the WM_PROTOCOLS property on window;  an empty string 
  27509.            is returned. Lastly, if neither name nor command is specified, the 
  27510.            command returns a list of all the protocols for which handlers are 
  27511.            currently defined for window. 
  27512.  
  27513.            Tk always defines a protocol handler for WM_DELETE_WINDOW, even if 
  27514.            you haven't asked for one with wm protocol. If a WM_DELETE_WINDOW 
  27515.            message arrives when you haven't defined a handler, then Tk handles 
  27516.            the message by destroying the window for which it was received. 
  27517.  
  27518.  wm resizable window ?width height?  This command controls whether or not the 
  27519.            user may interactively resize a top-level window.  If width and 
  27520.            height are specified, they are boolean values that determine whether 
  27521.            the width and height of window may be modified by the user. In this 
  27522.            case the command returns an empty string. If width and height are 
  27523.            omitted then the command returns a list with two 0/1 elements that 
  27524.            indicate whether the width and height of window are currently 
  27525.            resizable. By default, windows are resizable in both dimensions. If 
  27526.            resizing is disabled, then the window's size will be the size from 
  27527.            the most recent interactive resize or wm geometry command.  If there 
  27528.            has been no such operation then the window's natural size will be 
  27529.            used. 
  27530.  
  27531.  wm sizefrom window ?who?  If who is specified, it must be either program or 
  27532.            user, or an abbreviation of one of these two.  It indicates whether 
  27533.            window's current size was requested by the program or by the user. 
  27534.            Some window managers ignore program-requested sizes and ask the user 
  27535.            to manually size the window;  if user is specified then the window 
  27536.            manager should give the window its specified size without asking the 
  27537.            user for assistance. If who is specified as an empty string, then 
  27538.            the current size source is cancelled. If who is specified, then the 
  27539.            command returns an empty string. Otherwise it returns user or window 
  27540.            to indicate the source of the window's current size, or an empty 
  27541.            string if no source has been specified yet.  Most window managers 
  27542.            interpret "no source" as equivalent to program. 
  27543.  
  27544.  wm state window  Returns the current state of window:  either normal, iconic, 
  27545.            withdrawn, or icon.  The difference between iconic and icon is that 
  27546.            iconic refers to a window that has been iconified (e.g., with the wm 
  27547.            iconify command) while icon refers to a window whose only purpose is 
  27548.            to serve as the icon for some other window (via the wm iconwindow 
  27549.            command). 
  27550.  
  27551.  wm title window ?string?  If string is specified, then it will be passed to 
  27552.            the window manager for use as the title for window (the window 
  27553.            manager should display this string in window's title bar).  In this 
  27554.            case the command returns an empty string.  If string isn't specified 
  27555.            then the command returns the current title for the window.  The 
  27556.            title for a window defaults to its name. 
  27557.  
  27558.  wm transient window ?master?  If master is specified, then the window manager 
  27559.            is informed that window is a transient window (e.g. pull-down menu) 
  27560.            working on behalf of master (where master is the path name for a 
  27561.            top-level window).  Some window managers will use this information 
  27562.            to manage window specially.  If master is specified as an empty 
  27563.            string then window is marked as not being a transient window any 
  27564.            more.  If master is specified, then the command returns an empty 
  27565.            string.  Otherwise the command returns the path name of window's 
  27566.            current master, or an empty string if window isn't currently a 
  27567.            transient window. 
  27568.  
  27569.  wm withdraw window  Arranges for window to be withdrawn from the screen.  This 
  27570.            causes the window to be unmapped and forgotten about by the window 
  27571.            manager.  If the window has never been mapped, then this command 
  27572.            causes the window to be mapped in the withdrawn state.  Not all 
  27573.            window managers appear to know how to handle windows that are mapped 
  27574.            in the withdrawn state. Note: it sometimes seems to be necessary to 
  27575.            withdraw a window and then re-map it (e.g. with wm deiconify) to get 
  27576.            some window managers to pay attention to changes in window 
  27577.            attributes such as group. 
  27578.  
  27579.  GEOMETRY MANAGEMENT 
  27580.  
  27581.  By default a top-level window appears on the screen in its natural size, which 
  27582.  is the one determined internally by its widgets and geometry managers. If the 
  27583.  natural size of a top-level window changes, then the window's size changes to 
  27584.  match. A top-level window can be given a size other than its natural size in 
  27585.  two ways. First, the user can resize the window manually using the facilities 
  27586.  of the window manager, such as resize handles. Second, the application can 
  27587.  request a particular size for a top-level window using the wm geometry 
  27588.  command. These two cases are handled identically by Tk;  in either case, the 
  27589.  requested size overrides the natural size. You can return the window to its 
  27590.  natural by invoking wm geometry with an empty geometry string. 
  27591.  
  27592.  Normally a top-level window can have any size from one pixel in each dimension 
  27593.  up to the size of its screen. However, you can use the wm minsize and wm 
  27594.  maxsize commands to limit the range of allowable sizes. The range set by wm 
  27595.  minsize and wm maxsize applies to all forms of resizing, including the 
  27596.  window's natural size as well as manual resizes and the wm geometry command. 
  27597.  You can also use the command wm resizable to completely disable interactive 
  27598.  resizing in one or both dimensions. 
  27599.  
  27600.  GRIDDED GEOMETRY MANAGEMENT 
  27601.  
  27602.  Gridded geometry management occurs when one of the widgets of an application 
  27603.  supports a range of useful sizes. This occurs, for example, in a text editor 
  27604.  where the scrollbars, menus, and other adornments are fixed in size but the 
  27605.  edit widget can support any number of lines of text or characters per line. In 
  27606.  this case, it is usually desirable to let the user specify the number of lines 
  27607.  or characters-per-line, either with the wm geometry command or by 
  27608.  interactively resizing the window. In the case of text, and in other 
  27609.  interesting cases also, only discrete sizes of the window make sense, such as 
  27610.  integral numbers of lines and characters-per-line;  arbitrary pixel sizes are 
  27611.  not useful. 
  27612.  
  27613.  Gridded geometry management provides support for this kind of application. Tk 
  27614.  (and the window manager) assume that there is a grid of some sort within the 
  27615.  application and that the application should be resized in terms of grid units 
  27616.  rather than pixels. Gridded geometry management is typically invoked by 
  27617.  turning on the setGrid option for a widget;  it can also be invoked with the 
  27618.  wm grid command or by calling Tk_SetGrid. In each of these approaches the 
  27619.  particular widget (or sometimes code in the application as a whole) specifies 
  27620.  the relationship between integral grid sizes for the window and pixel sizes. 
  27621.  To return to non-gridded geometry management, invoke wm grid with empty 
  27622.  argument strings. 
  27623.  
  27624.  When gridded geometry management is enabled then all the dimensions specified 
  27625.  in wm minsize, wm maxsize, and wm geometry commands are treated as grid units 
  27626.  rather than pixel units. Interactive resizing is also carried out in even 
  27627.  numbers of grid units rather than pixels. 
  27628.  
  27629.  BUGS 
  27630.  
  27631.  Most existing window managers appear to have bugs that affect the operation of 
  27632.  the wm command.  For example, some changes won't take effect if the window is 
  27633.  already active:  the window will have to be withdrawn and de-iconified in 
  27634.  order to make the change happen. 
  27635.  
  27636.  KEYWORDS 
  27637.  
  27638.  aspect ratio, deiconify, focus model, geometry, grid, group, icon, iconify, 
  27639.  increments, position, size, title, top-level window, units, window manager