1 <chapter id=
"consoles">
2 <title>Consoles in Wine
</title>
4 <sect1 id=
"wine-consoles">
5 <title>Consoles
</title>
8 Written by &name-john-richardson;
<email>&email-john-richardson;
</email>
9 Maintained by &name-joseph-pranevich;
<email>&email-joseph-pranevich;
</email>
12 (Extracted from
<filename>wine/documentation/console
</filename>)
16 <title>Console - First Pass
</title>
19 Consoles are just xterms created with the
20 <parameter>-Sxxn
</parameter> switch. A
21 <systemitem>pty
</systemitem> is opened and the master goes
22 to the
<filename>xterm
</filename> side and the slave is held
23 by the wine side. The console itself is turned into a few
24 <type>HANDLE32
</type>s and is set to the
25 <varname>STD_*_HANDLES
</varname>.
28 It is possible to use the
<function>WriteFile
</function> and
29 <function>ReadFile
</function> commands to write to a win32
30 console. To accomplish this, all
<type>K32OBJ
</type>s that
31 support I/O have a read and write function pointer. So,
32 <function>WriteFile
</function> calls
33 <function>K32OBJ_WriteFile
</function> which calls the
34 <type>K32OBJ
</type>'s write function pointer, which then
35 finally calls
<function>write
</function>.
38 <emphasis>[this paragraph is now out of date]
</emphasis> If
39 the command line console is to be inherited or a process
40 inherits its parent's console (-- can that happen???), the
41 console is created at process init time via
42 <function>PROCESS_InheritConsole
</function>. The
43 <literal>0</literal>,
<literal>1</literal>, and
44 <literal>2</literal> file descriptors are duped to be the
45 <varname>STD_*_HANDLES
</varname> in this case. Also in this
46 case a flag is set to indicate that the console comes from
47 the parent process or command line.
50 If a process doesn't have a console at all, its
51 <varname>pdb-
>console
</varname> is set to
52 <constant>NULL
</constant>. This helps indicate when it is
53 possible to create a new console (via
54 <function>AllocConsole
</function>).
57 When
<function>FreeConsole
</function> is called, all handles that the process has
58 open to the console are closed. Like most
<type>K32OBJ
</type>s, if the
59 console's refcount reaches zero, its
<type>K32OBJ
</type> destroy function
60 is called. The destroy kills the xterm if one was open.
63 Also like most k32 objects, we assume that
64 (
<type>K32OBJ
</type>) header is the first field so the
65 casting (from
<type>K32OBJ*
</type>to
<type>CONSOLE*
</type>)
69 <function>FreeConsole
</function> is called on process exit
70 (in
<function>ExitProcess
</function>) if
71 <varname>pdb-
>console
</varname> is not
72 <constant>NULL
</constant>.
80 Console processes do not inherit their parent's handles. I
81 think there needs to be two cases, one where they have to
82 inherit the
<filename>stdin
</filename> /
83 <filename>stdout
</filename> /
<filename>stderr
</filename>
84 from unix, and one where they have to inherit from another
88 <function>SetConsoleMode
</function> -- UNIX only has
89 <constant>ICANON
</constant> and various
90 <constant>ECHO
</constant>s to play around with for
91 processing input. Win32 has line-at-a-time processing,
92 character processing, and echo. I'm putting together an
93 intermediate driver that will handle this (and hopefully
94 won't be any more buggy than the NT4 console
100 <title>Experimentation
</title>
103 experimentation with NT4 yields that:
108 <term><function>WriteFile
</function></term>
112 <para>does not truncate file on
0 length write
</para>
116 0 length write or error on write changes
117 <varname>numcharswritten
</varname> to
122 <para>0 length write returns
<constant>TRUE
</constant></para>
125 <para>works with console handles
</para>
131 <term><function>_lwrite
</function></term>
135 <para>does truncate/expand file at current position on
0 length write
</para>
138 <para>returns
0 on a zero length write
</para>
141 <para>works with console handles (typecasted)
</para>
147 <term><function>WriteConsole
</function></term>
151 <para>expects only console handles
</para>
157 <term><function>SetFilePointer
</function></term>
161 <para>returns -
1 (err
6) when used with a console handle
</para>
167 <term><function>FreeConsole
</function></term>
172 even when all the handles to it are freed, the
173 win32 console stays visible, the only way I could
174 find to free it was via the
<function>FreeConsole
</function>
183 Is it possible to interrupt win32's
184 <function>FileWrite
</function>? I'm not sure. It may not be
185 possible to interrupt any system calls.
190 <title>DOS (Generic) Console Support
</title>
193 <title>I. Command Line Configuration
</title>
196 DOS consoles must be configured either on the command line
197 or in a dot resource file (
<filename>.console
</filename>).
198 A typical configuration consists of a string of driver
199 keywords separated by plus ('+') signs. To change the
200 configuration on the command-line, use the
201 <parameter>-console
</parameter> switch.
207 wine -console ncurses+xterm
<application
>
217 <para>Generic text-only support. Supports redirection.
</para>
221 <term>ncurses:
</term>
223 <para>Full-screen graphical support with color.
</para>
230 Load a new window to display the console in. Also
231 supports resizing windows.
239 <title>II.
<filename>wine.conf
</filename> Configuration
</title>
242 In the
<filename>wine.conf
</filename> file, you can create
243 a section called [console] that contains configuration
244 options that are respected by the assorted console
253 <term>XtermProg=
<program
></term>
256 Use this program instead of
257 <command>xterm
</command>. This eliminates the need
258 for a recompile. See the table below for a
259 comparison of various terminals.
264 <term>InitialRows=
<number
></term>
267 Attempt to start all drivers with this number of
268 rows. This causes xterms to be resized, for
273 This information is passed on the command-line
274 with the
<parameter>-g
</parameter> switch.
280 <term>InitialColumns=
<number
></term>
283 Attempt to start all drivers with this number of
284 columns. This causes xterms to be resized, for
289 This information is passed on the command-line
290 with the
<parameter>-g
</parameter> switch.
296 <term>TerminalType=
<name
></term>
299 Tell any driver that is interested (ncurses) which
300 termcap and/or terminfo type to use. The default is
301 xterm which is appropriate for most uses.
302 <command>nxterm
</command> may give you better
303 support if you use that terminal. This can also be
304 changed to
"linux" (or
"console" on older systems)
305 if you manage to hack the ability to write to the
306 console into this driver.
314 <title>III. Terminal Types
</title>
317 There are a large number of potential terminals that can
318 be used with Wine, depending on what you are trying to do.
319 Unfortunately, I am still looking for the
"best" driver
324 'slave' is required for use in Wine, currently.
332 <entry>Program
</entry>
333 <entry>Color?
</entry>
334 <entry>Resizing?
</entry>
335 <entry>Slave?
</entry>
340 <entry>(linux console)
</entry>
354 <entry>nxterm
</entry>
370 As X terminals typically use a
24x80 screen resolution
371 rather than the typical
25x80 one, it is necessary to
372 resize the screen to allow a DOS program to work
373 full-screen. There is a
<filename>wine.conf
</filename>
374 option to work around this in some cases but run-time
375 resizing will be disabled.
382 <!-- Keep this comment at the end of the file
385 sgml-parent-document:("wine-doc.sgml" "set" "book" "part" "chapter" "")