1 <chapter id=
"consoles">
2 <title>Consoles in Wine
</title>
4 <sect1 id=
"wine-consoles">
5 <title>Consoles
</title>
11 (Extracted from
<filename>wine/documentation/console
</filename>)
15 <title>Console - First Pass
</title>
18 Consoles are just xterms created with the
19 <parameter>-Sxxn
</parameter> switch. A
20 <systemitem>pty
</systemitem> is opened and the master goes
21 to the
<filename>xterm
</filename> side and the slave is held
22 by the wine side. The console itself it turned into a few
23 <type>HANDLE32
</type>s and is set to the
24 <varname>STD_*_HANDLES
</varname>.
27 It is possible to use the
<function>WriteFile
</function> and
28 <function>ReadFile
</function> commands to write to a win32
29 console. To accomplish this, all
<type>K32OBJ
</type>s that
30 support I/O have a read and write function pointer. So,
31 <function>WriteFile
</function> calls
32 <function>K32OBJ_WriteFile
</function> which calls the
33 <type>K32OBJ
</type>'s write function pointer, which then
34 finally calls
<function>write
</function>.
37 <emphasis>[this paragraph is now out of date]
</emphasis> If
38 the command line console is to be inheirited or a process
39 inherits its parent's console (-- can that happen???), the
40 console is created at process init time via
41 <function>PROCESS_InheritConsole
</function>. The
42 <literal>0</literal>,
<literal>1</literal>, and
43 <literal>2</literal> file descriptors are duped to be the
44 <varname>STD_*_HANDLES
</varname> in this case. Also in this
45 case a flag is set to indicate that the console comes from
46 the parent process or command line.
49 If a process doesn't have a console at all, its
50 <varname>pdb-
>console
</varname> is set to
51 <constant>NULL
</constant>. This helps indicate when it is
52 possible to create a new console (via
53 <function>AllocConsole
</function>).
56 When
<function>FreeConsole
</function> is called, all handles that the process has
57 open to the console are closed. Like most
<type>K32OBJ
</type>s, if the
58 console's refcount reaches zero, its
<type>K32OBJ
</type> destroy function
59 is called. The destroy kills the xterm if one was open.
62 Also like most k32 objects, we assume that
63 (
<type>K32OBJ
</type>) header is the first field so the
64 casting (from
<type>K32OBJ*
</type>to
<type>CONSOLE*
</type>)
68 <function>FreeConsole
</function> is called on process exit
69 (in
<function>ExitProcess
</function>) if
70 <varname>pdb-
>console
</varname> is not
71 <constant>NULL
</constant>.
79 Console processes do not inherit their parent's handles. I
80 think there needs to be two cases, one where they have to
81 inherit the
<filename>stdin
</filename> /
82 <filename>stdout
</filename> /
<filename>stderr
</filename>
83 from unix, and one where they have to inherit from another
87 <function>SetConsoleMode
</function> -- UNIX only has
88 <constant>ICANON
</constant> and various
89 <constant>ECHO
</constant>s to play around with for
90 processing input. Win32 has line-at-a-time processing,
91 character processing, and echo. I'm putting together an
92 intermediate driver that will handle this (and hopefully
93 won't be any more buggy then the NT4 console
99 <title>Experimentation
</title>
102 experimentation with NT4 yields that:
107 <term><function>WriteFile
</function></term>
111 <para>does not truncate file on
0 length write
</para>
115 0 length write or error on write changes
116 <varname>numcharswritten
</varname> to
121 <para>0 length write returns
<constant>TRUE
</constant></para>
124 <para>works with console handles
</para>
130 <term><function>_lwrite
</function></term>
134 <para>does truncate/expand file at current position on
0 length write
</para>
137 <para>returns
0 on a zero length write
</para>
140 <para>works with console handles (typecasted)
</para>
146 <term><function>WriteConsole
</function></term>
150 <para>expects only console handles
</para>
156 <term><function>SetFilePointer
</function></term>
160 <para>returns -
1 (err
6) when used with a console handle
</para>
166 <term><function>FreeConsole
</function></term>
171 even when all the handles to it are freed, the
172 win32 console stays visible, the only way I could
173 find to free it was via the
<function>FreeConsole
</function>
182 Is it possible to interrupt win32's
183 <function>FileWrite
</function>? I'm not sure. It may not be
184 possible to interrupt any system calls.
189 <title>DOS (Generic) Console Support
</title>
192 <title>I. Command Line Configuration
</title>
195 DOS consoles must be configured either on the command line
196 or in a dot resource file (
<filename>.console
</filename>).
197 A typical configuration consists of a string of driver
198 keywords separated by plus ('+') signs. To change the
199 configuration on the command-line, use the
200 <parameter>-console
</parameter> switch.
206 wine -console ncurses+xterm
<application
>
216 <para>Generic text-only support. Supports redirection.
</para>
220 <term>ncurses:
</term>
222 <para>Full-screen graphical support with color.
</para>
229 Load a new window to display the console in. Also
230 supports resizing windows.
238 <title>II.
<filename>wine.conf
</filename> Configuration
</title>
241 In the
<filename>wine.conf
</filename> file, you can create
242 a section called [console] that contains configuration
243 options that are respected by the assorted console
252 <term>XtermProg=
<program
></term>
255 Use this program instead of
256 <command>xterm
</command>. This eliminates the need
257 for a recompile. See the table below for a
258 comparison of various terminals.
263 <term>InitialRows=
<number
></term>
266 Attempt to start all drivers with this number of
267 rows. This causes xterms to be resized, for
272 This information is passed on the command-line
273 with the
<parameter>-g
</parameter> switch.
279 <term>InitialColumns=
<number
></term>
282 Attempt to start all drivers with this number of
283 columns. This causes xterms to be resized, for
288 This information is passed on the command-line
289 with the
<parameter>-g
</parameter> switch.
295 <term>TerminalType=
<name
></term>
298 Tell any driver that is interested (ncurses) which
299 termcap and/or terminfo type to use. The default is
300 xterm which is appropiate for most uses.
301 <command>nxterm
</command> may give you better
302 support if you use that terminal. This can also be
303 changed to
"linux" (or
"console" on older systems)
304 if you manage to hack the ability to write to the
305 console into this driver.
313 <title>III. Terminal Types
</title>
316 There are a large number of potential terminals that can
317 be used with Wine, depending on what you are trying to do.
318 Unfortunately, I am still looking for the
"best" driver
323 'slave' is required for use in Wine, currently.
331 <entry>Program
</entry>
332 <entry>Color?
</entry>
333 <entry>Resizing?
</entry>
334 <entry>Slave?
</entry>
339 <entry>(linux console)
</entry>
353 <entry>nxterm
</entry>
369 As X terminals typically use a
24x80 screen resolution
370 rather than the typical
25x80 one, it is necessary to
371 resize the screen to allow a DOS program to work
372 full-screen. There is a
<filename>wine.conf
</filename>
373 option to work around this in some cases but run-time
374 resizing will be disabled.
381 <!-- Keep this comment at the end of the file
384 sgml-parent-document:("wine-doc.sgml" "book" "part" "chapter" "")