1console(n)                   Tk Built-In Commands                   console(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       console - Control the console on systems without a real console
9

SYNOPSIS

11       console subcommand ?arg ...?
12_________________________________________________________________
13

DESCRIPTION

15       The  console  window is a replacement for a real console to allow input
16       and output on the standard I/O channels on platforms that do not have a
17       real  console.  It is implemented as a separate interpreter with the Tk
18       toolkit loaded, and control over this interpreter is given through  the
19       console command.  The behaviour of the console window is defined mainly
20       through the contents of the console.tcl file in the Tk library.  Except
21       for  TkAqua,  this  command  is  not available when Tk is loaded into a
22       tclsh interpreter with “package require Tk”, as a conventional terminal
23       is expected to be present in that case.  In TkAqua, this command is ony
24       available when stdin is /dev/null (as is the case e.g. when the  appli‐
25       cation embedding Tk is started from the Mac OS X Finder).
26
27       console eval script
28              Evaluate  the  script  argument  as  a Tcl script in the console
29              interpreter.  The normal interpreter  is  accessed  through  the
30              consoleinterp command in the console interpreter.
31
32       console hide
33              Hide  the  console  window  from  view.  Precisely equivalent to
34              withdrawing the . window in the console interpreter.
35
36       console show
37              Display the console window.  Precisely equivalent to  deiconify‐
38              ing the . window in the console interpreter.
39
40       console title ?string?
41              Query  or  modify the title of the console window.  If string is
42              not specified, queries the title of the console window, and sets
43              the  title of the console window to string otherwise.  Precisely
44              equivalent to using the wm title command in the  console  inter‐
45              preter.
46

ACCESS TO THE MAIN INTERPRETER

48       The  consoleinterp command in the console interpreter allows scripts to
49       be evaluated in the main interpreter.   It  supports  two  subcommands:
50       eval and record.
51
52       consoleinterp eval script
53              Evaluates script as a Tcl script at the global level in the main
54              interpreter.
55
56       consoleinterp record script
57              Records and evaluates script as a Tcl script at the global level
58              in  the  main  interpreter as if script had been typed in at the
59              console.
60

ADDITIONAL TRAP CALLS

62       There are several additional commands in the console  interpreter  that
63       are  called in response to activity in the main interpreter.  These are
64       documented here for completeness only; they form part of  the  internal
65       implementation  of  the console and are likely to change or be modified
66       without warning.
67
68       Output to the console from the main  interpreter  via  the  stdout  and
69       stderr channels is handled by invoking the tk::ConsoleOutput command in
70       the console interpreter with two arguments.  The first argument is  the
71       name  of  the  channel being written to, and the second argument is the
72       string being written to the channel  (after  encoding  and  end-of-line
73       translation processing has been performed.)
74
75       When  the  .  window of the main interpreter is destroyed, the tk::Con‐
76       soleExit command in the console interpreter  is  called  (assuming  the
77       console interpreter has not already been deleted itself, that is.)
78

DEFAULT BINDINGS

80       The  default  script creates a console window (implemented using a text
81       widget) that has the following behaviour:
82
83       [1]    Pressing the tab key inserts a TAB character (as defined by  the
84              Tcl \t escape.)
85
86       [2]    Pressing  the return key causes the current line (if complete by
87              the rules of info complete) to be passed to the main interpreter
88              for evaluation.
89
90       [3]    Pressing  the  delete key deletes the selected text (if any text
91              is selected) or the character to the right of the cursor (if not
92              at the end of the line.)
93
94       [4]    Pressing  the  backspace  key  deletes the selected text (if any
95              text is selected) or the character to the left of the cursor (of
96              not at the start of the line.)
97
98       [5]    Pressing  either  Control+A or the home key causes the cursor to
99              go to the start of the line (but after the prompt, if  a  prompt
100              is present on the line.)
101
102       [6]    Pressing either Control+E or the end key causes the cursor to go
103              to the end of the line.
104
105       [7]    Pressing either Control+P or the  up  key  causes  the  previous
106              entry in the command history to be selected.
107
108       [8]    Pressing  either Control+N or the down key causes the next entry
109              in the command history to be selected.
110
111       [9]    Pressing either Control+B or the left key causes the  cursor  to
112              move  one character backward as long as the cursor is not at the
113              prompt.
114
115       [10]   Pressing either Control+F or the right key causes the cursor  to
116              move one character forward.
117
118       [11]   Pressing  F9  rebuilds  the console window by destroying all its
119              children and reloading the Tcl script that defined the console's
120              behaviour.
121
122       Most  other  behaviour is the same as a conventional text widget except
123       for the way that the  <<Cut>>  event  is  handled  identically  to  the
124       <<Copy>> event.
125

EXAMPLE

127       Not all platforms have the console command, so debugging code often has
128       the following code fragment in it so output produced  by  puts  can  be
129       seen while during development:
130              catch {console show}
131

SEE ALSO

133       destroy(n),  fconfigure(n),  history(n),  interp(n),  puts(n), text(n),
134       wm(n)
135

KEYWORDS

137       console, interpreter, window, interactive, output channels
138
139
140
141Tk                                    8.4                           console(n)
Impressum