console(4,n)(n) Tk Built-In Commands console(4,n)(n) NAME console(4,n) - Control the console(4,n) on systems without a real console(4,n) SYNOPSIS console(4,n) title ?string(3,n)? console(4,n) hide console(4,n) show console(4,n) eval script DESCRIPTION The console(4,n) window is a replacement for a real console(4,n) to allow input and output on the standard I/O channels on platforms that do not have a real console. It is implemented as a separate interpreter with the Tk toolkit loaded, and control over this interpreter is given through the console(4,n) command. The behaviour of the console(4,n) window is defined mainly through the contents of the console.tcl file(1,n) in(1,8) the Tk library (or the Console resource on Macintosh systems.) console(4,n) eval script Evaluate the script argument as a Tcl script in(1,8) the console(4,n) interpreter. The normal interpreter is accessed through the consoleinterp command in(1,8) the console(4,n) interpreter. console(4,n) hide Hide the console(4,n) window from view. Precisely equivalent to withdrawing the . window in(1,8) the console(4,n) interpreter. console(4,n) show Display the console(4,n) window. Precisely equivalent to deiconify- ing the . window in(1,8) the console(4,n) interpreter. console(4,n) title ?string(3,n)? Query or modify the title of the console(4,n) window. If string(3,n) is not specified, queries the title of the console(4,n) window, and sets the title of the console(4,n) window to string(3,n) otherwise. Precisely equivalent to using the wm title command in(1,8) the console(4,n) inter- preter. ACCESS TO THE MAIN INTERPRETER The consoleinterp command in(1,8) the console(4,n) interpreter allows scripts to be evaluated in(1,8) the main interpreter. It supports two subcommands: eval and record. consoleinterp eval script Evaluates script as a Tcl script at the global level in(1,8) the main interpreter. consoleinterp record script Records and evaluates script as a Tcl script at the global level in(1,8) the main interpreter as if(3,n) script had been typed in(1,8) at the console. ADDITIONAL TRAP CALLS There are several additional commands in(1,8) the console(4,n) interpreter that are called in(1,8) response to activity in(1,8) the main interpreter. These are documented here for completeness only; they form part of the internal implementation of the console(4,n) and are likely to change or be modified without warning. Output to the console(4,n) from the main interpreter via the stdout and stderr channels is handled by invoking the tk::ConsoleOutput command in(1,8) the console(4,n) interpreter with two arguments. The first argument is the name of the channel being written to, and the second argument is the string(3,n) being written to the channel (after encoding(3,n) and end-of-line translation processing has been performed.) When the . window of the main interpreter is destroyed, the tk::Con- soleExit command in(1,8) the console(4,n) interpreter is called (assuming the console(4,n) interpreter has not already been deleted itself, that is.) DEFAULT BINDINGS The default script creates a console(4,n) 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(3,n) complete by the rules of info(1,5,n) complete) to be passed to the main interpreter for evaluation. [3] Pressing the delete key deletes the selected text (if(3,n) any text is selected) or the character to the right of the cursor (if(3,n) not at the end of the line.) [4] Pressing the backspace key deletes the selected text (if(3,n) 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(3,n) 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. [7] Pressing either Control+P or the up key causes the previous entry in(1,8) the command history(1,3,n,1 builtins) to be selected. [8] Pressing either Control+N or the down key causes the next entry in(1,8) the command history(1,3,n,1 builtins) to be selected. [9] Pressing either Control+B or the left key causes the cursor to move(3x,7,3x curs_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(3x,7,3x curs_move) one character forward. [11] Pressing F9 rebuilds the console(4,n) window by destroying all its children and reloading the Tcl script that defined the console(4,n)'s behaviour. Most other behaviour is the same as a conventional text widget except for the way that the <<Cut>> event is handled identically to the <<Copy>> event. KEYWORDS console(4,n), interpreter, window, interactive, output channels SEE ALSO destroy(n), fconfigure(n), history(1,3,n,1 builtins)(n), interp(n), puts(3,n)(n), text(n), wm(n) Tk 8.4 console(4,n)(n)