Tk Built-In Commands console(1T)
_________________________________________________________________
NAME
console - Control the console on systems without a real con-
soleSYNOPSIS
console subcommand ?arg ...?
_________________________________________________________________
DESCRIPTION
The console window is a replacement for a real console to
allow input and output on the standard I/O channels on plat-
forms that do not have a real console. It is implemented as
a separate interpreter with the Tk toolkit loaded, and con-
trol over this interpreter is given through the console com-
mand. The behaviour of the console window is defined mainly
through the contents of the console.tcl file in the Tk
library (or the Console resource on Macintosh systems.)console eval script
Evaluate the script argument as a Tcl script in theconsole interpreter. The normal interpreter is
accessed through the consoleinterp command in the con-
sole interpreter.console hide
Hide the console window from view. Precisely
equivalent to withdrawing the . window in the console
interpreter.console show
Display the console window. Precisely equivalent to
deiconifying theconsole title ?string?
Query or modify the title of the console window. If
string is not specified, queries the title of the con-
sole window, and sets the title of the console window
to string otherwise. Precisely equivalent to using thewm title command in the console interpreter.
ACCESS TO THE MAIN INTERPRETERThe consoleinterp command in the console interpreter allows
scripts to be evaluated in the main interpreter. It sup-
ports two subcommands: eval and record.consoleinterp eval script
Evaluates script as a Tcl script at the global level in the main interpreter. Tk Last change: 8.4 1Tk Built-In Commands console(1T)
consoleinterp record script
Records and evaluates script as a Tcl script at the global level in the main interpreter as if script hadbeen typed in at the console.
ADDITIONAL TRAP CALLSThere are several additional commands in the console inter-
preter that are called in response to activity in the main interpreter. These are documented here for completeness only; they form part of the internal implementation of theconsole and are likely to change or be modified without
warning.Output to the console from the main interpreter via the
stdout and stderr channels is handled by invoking thetk::ConsoleOutput command in the console interpreter with
two arguments. The first argument is the name of the chan-
nel being written to, and the second argument is the stringbeing written to the channel (after encoding and end-of-line
translation processing has been performed.) When the . window of the main interpreter is destroyed, thetk::ConsoleExit command in the console interpreter is called
(assuming the console interpreter has not already been
deleted itself, that is.) DEFAULT BINDINGSThe default script creates a console window (implemented
using a text widget) that has the following behaviour: [1] Pressing the tab key inserts a TAB character (as defined by the Tcl \t escape.) [2] Pressing the return key causes the current line (if complete by the rules of info complete) to be passed to the main interpreter for evaluation. [3] Pressing the delete key deletes the selected text (if any text is selected) or the character to the right of the cursor (if not at the end of the line.) [4] Pressing the backspace key deletes the selected text (if any text is selected) or the character to the left of the cursor (of not at the start of the line.) [5] Pressing either Control+A or the home key causes the cursor to go to the start of the line (but after the prompt, if a prompt is present on the line.) [6] Pressing either Control+E or the end key causes the cursor to go to the end of the line. Tk Last change: 8.4 2Tk Built-In Commands console(1T)
[7] Pressing either Control+P or the up key causes the pre-
vious entry in the command history to be selected. [8] Pressing either Control+N or the down key causes the next entry in the command history to be selected. [9] Pressing either Control+B or the left key causes the cursor to move one character backward as long as the cursor is not at the prompt. [10] Pressing either Control+F or the right key causes the cursor to move one character forward.[11] Pressing F9 rebuilds the console window by destroying
all its children and reloading the Tcl script thatdefined the console's behaviour.
Most other behaviour is the same as a conventional text widget except for the way that the <> event is handled identically to the < > event. EXAMPLE
Not all platforms have the console command, so debugging
code often has the following code fragment in it so output produced by puts can be seen while during development:catch {console show}
KEYWORDSconsole, interpreter, window, interactive, output channels
SEE ALSO
destroy(1T), fconfigure(1T), history(1T), interp(1T), puts(1T), text(1T), wm(1T)ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:_______________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE|
|____________________|__________________|_
| Availability | runtime/tk-8 |
|____________________|__________________|_
| Interface Stability| Uncommitted ||____________________|_________________|
NOTES Source for Tk is available on http://opensolaris.org. Tk Last change: 8.4 3