annotate src/console-msw.c @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents 74fd4e045ea6
children 501cfd01ee6d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1 /* Console functions for mswindows.
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
2 Copyright (C) 1996, 2000 Ben Wing.
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
3
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
4 This file is part of XEmacs.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
5
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
9 later version.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
10
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
14 for more details.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
15
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
20
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
21 /* Synched up with: Not in FSF. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
22
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
23 /* Authorship:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
24
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
25 Ben Wing: January 1996, for 19.14.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 249
diff changeset
26 Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
27 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
28
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
29 #include <config.h>
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
30 #include "lisp.h"
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
31 #include "events.h"
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
32 #include "opaque.h"
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
33
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
34 #include "console-msw.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
35
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
36 DEFINE_CONSOLE_TYPE (mswindows);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
37 DEFINE_CONSOLE_TYPE (msprinter);
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
38
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
39 /************************************************************************/
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
40 /* mswindows console methods */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
41 /************************************************************************/
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
42
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
43 static int
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
44 mswindows_initially_selected_for_input (struct console *con)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
45 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
46 return 1;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
47 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
48
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
49 static HWND msw_console_hwnd = 0;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
50
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
51 #define KLUDGE_BUFSIZE 1024 /* buffer size for console window titles */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
52
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
53 /* Direct from the horse's mouth: Microsoft KB article Q124103 */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
54 static HWND
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
55 GetConsoleHwnd (void)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
56 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
57 HWND hwndFound; /* this is what is returned to the caller */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
58 char pszNewWindowTitle[KLUDGE_BUFSIZE]; /* contains fabricated WindowTitle */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
59 char pszOldWindowTitle[KLUDGE_BUFSIZE]; /* contains original WindowTitle */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
60
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
61 /* fetch current window title */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
62
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
63 GetConsoleTitle(pszOldWindowTitle, KLUDGE_BUFSIZE);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
64
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
65 /* format a "unique" NewWindowTitle */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
66
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
67 wsprintf(pszNewWindowTitle,"%d/%d",
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
68 GetTickCount(),
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
69 GetCurrentProcessId());
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
70
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
71 /* change current window title */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
72
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
73 SetConsoleTitle(pszNewWindowTitle);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
74
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
75 /* ensure window title has been updated */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
76
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
77 Sleep(40);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
78
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
79 /* look for NewWindowTitle */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
80
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
81 hwndFound=FindWindow(NULL, pszNewWindowTitle);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
82
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
83 /* restore original window title */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
84
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
85 SetConsoleTitle(pszOldWindowTitle);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
86
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
87 return(hwndFound);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
88 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
89
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
90 HWND
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
91 msw_get_console_hwnd (void)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
92 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
93 if (!msw_console_hwnd)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
94 msw_console_hwnd = GetConsoleHwnd ();
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
95 return msw_console_hwnd;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
96 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
97
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
98 int
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
99 msw_ensure_console_allocated (void)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
100 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
101 HWND fgwin = GetForegroundWindow ();
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
102 /* stupid mswin api won't let you create the console window
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
103 hidden! creating it changes the focus! fuck me! */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
104 if (AllocConsole ())
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
105 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
106 SetForegroundWindow (fgwin);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
107 return 1;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
108 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
109 return 0;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
110 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
111
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
112 static Lisp_Object
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
113 mswindows_canonicalize_console_connection (Lisp_Object connection,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
114 Error_behavior errb)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
115 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
116 /* Do not allow more than one mswindows device, by explicitly
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
117 requiring that CONNECTION is nil, the only allowed connection in
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
118 Windows. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
119 if (!NILP (connection))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
120 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
121 if (ERRB_EQ (errb, ERROR_ME))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
122 signal_simple_error
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
123 ("Invalid (non-nil) connection for mswindows device/console",
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
124 connection);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
125 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
126 return Qunbound;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
127 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
128
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
129 return Qnil;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
130 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
131
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
132 static Lisp_Object
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
133 mswindows_canonicalize_device_connection (Lisp_Object connection,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
134 Error_behavior errb)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
135 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
136 return mswindows_canonicalize_console_connection (connection, errb);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
137 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
138
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
139 void
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
140 msw_hide_console (void)
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
141 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
142 ShowWindow (msw_get_console_hwnd (), SW_HIDE);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
143 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
144
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
145 void
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
146 msw_show_console (void)
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
147 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
148 HWND hwnd = msw_get_console_hwnd ();
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
149 ShowWindow (hwnd, SW_SHOWNA);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
150
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
151 /* I tried to raise the window to the top without activating
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
152 it, but this fails. Apparently Windows just doesn't like
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
153 having the active window not be on top. So instead, we
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
154 at least put it just below our own window, where part of it
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
155 will likely be seen. */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
156 SetWindowPos (hwnd, GetForegroundWindow (), 0, 0, 0, 0,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
157 SWP_NOSIZE | SWP_NOMOVE | SWP_NOSENDCHANGING |
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
158 SWP_NOACTIVATE);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
159 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
160
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
161 static int msw_console_buffered = 0;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
162 HANDLE msw_console_buffer;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
163
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
164 static void
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
165 msw_ensure_console_buffered (void)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
166 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
167 if (!msw_console_buffered)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
168 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
169 COORD new_size;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
170
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
171 new_size.X = 80;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
172 new_size.Y = 1000;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
173 msw_ensure_console_allocated ();
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
174 msw_console_buffer =
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
175 CreateConsoleScreenBuffer (GENERIC_WRITE, 0, NULL,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
176 CONSOLE_TEXTMODE_BUFFER, NULL);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
177 SetConsoleScreenBufferSize (msw_console_buffer, new_size);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
178 SetConsoleActiveScreenBuffer (msw_console_buffer);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
179 msw_console_buffered = 1;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
180 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
181 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
182
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
183 int
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
184 msw_output_console_string (CONST Extbyte *str, Extcount len)
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
185 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
186 DWORD num_written;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
187
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
188 msw_ensure_console_buffered ();
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
189 msw_show_console ();
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
190 return WriteConsole (msw_console_buffer, str, len, &num_written, NULL);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
191 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
192
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
193 /* Determine if running on Windows 9x and not NT */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
194 int
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
195 msw_windows9x_p (void)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
196 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
197 return GetVersion () & 0x80000000;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
198 }
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
199
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
200
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
201 #ifdef DEBUG_XEMACS
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
202
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
203 /*
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
204 * Random helper functions for debugging.
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
205 * Intended for use in the MSVC "Watch" window which doesn't like
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
206 * the aborts that the error_check_foo() functions can make.
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
207 */
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
208 struct lrecord_header *
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
209 DHEADER (Lisp_Object obj)
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
210 {
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
211 return LRECORDP (obj) ? XRECORD_LHEADER (obj) : NULL;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
212 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
213
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
214 void *
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
215 DOPAQUE_DATA (Lisp_Object obj)
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
216 {
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
217 return OPAQUEP (obj) ? OPAQUE_DATA (XOPAQUE (obj)) : NULL;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
218 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
219
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
220 Lisp_Event *
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
221 DEVENT (Lisp_Object obj)
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
222 {
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
223 return EVENTP (obj) ? XEVENT (obj) : NULL;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
224 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
225
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
226 Lisp_Cons *
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
227 DCONS (Lisp_Object obj)
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
228 {
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
229 return CONSP (obj) ? XCONS (obj) : NULL;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
230 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
231
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
232 Lisp_Cons *
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
233 DCONSCDR (Lisp_Object obj)
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
234 {
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
235 return (CONSP (obj) && CONSP (XCDR (obj))) ? XCONS (XCDR (obj)) : 0;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
236 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
237
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
238 Bufbyte *
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
239 DSTRING (Lisp_Object obj)
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
240 {
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
241 return STRINGP (obj) ? XSTRING_DATA (obj) : NULL;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
242 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
243
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
244 Lisp_Vector *
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
245 DVECTOR (Lisp_Object obj)
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
246 {
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
247 return VECTORP (obj) ? XVECTOR (obj) : NULL;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
248 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
249
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
250 Lisp_Symbol *
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
251 DSYMBOL (Lisp_Object obj)
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
252 {
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
253 return SYMBOLP (obj) ? XSYMBOL (obj) : NULL;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
254 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
255
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
256 Bufbyte *
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
257 DSYMNAME (Lisp_Object obj)
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
258 {
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 280
diff changeset
259 return SYMBOLP (obj) ? string_data (XSYMBOL (obj)->name) : NULL;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
260 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 213
diff changeset
261
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 382
diff changeset
262 #endif /* DEBUG_XEMACS */
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
263
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
264
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
265
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
266 /************************************************************************/
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
267 /* initialization */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
268 /************************************************************************/
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
269
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
270 void
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
271 syms_of_console_mswindows (void)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
272 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
273 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
274
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
275 void
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
276 console_type_create_mswindows (void)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
277 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
278 INITIALIZE_CONSOLE_TYPE (mswindows, "mswindows", "console-mswindows-p");
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
279
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
280 /* console methods */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
281 /* CONSOLE_HAS_METHOD (mswindows, init_console); */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
282 /* CONSOLE_HAS_METHOD (mswindows, mark_console); */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
283 CONSOLE_HAS_METHOD (mswindows, initially_selected_for_input);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
284 /* CONSOLE_HAS_METHOD (mswindows, delete_console); */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
285 CONSOLE_HAS_METHOD (mswindows, canonicalize_console_connection);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
286 CONSOLE_HAS_METHOD (mswindows, canonicalize_device_connection);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
287 /* CONSOLE_HAS_METHOD (mswindows, semi_canonicalize_console_connection); */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
288 /* CONSOLE_HAS_METHOD (mswindows, semi_canonicalize_device_connection); */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
289
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
290 INITIALIZE_CONSOLE_TYPE (msprinter, "msprinter", "console-msprinter-p");
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
291 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
292
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
293 void
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
294 reinit_console_type_create_mswindows (void)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
295 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
296 REINITIALIZE_CONSOLE_TYPE (mswindows);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
297 REINITIALIZE_CONSOLE_TYPE (msprinter);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
298 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
299
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
300 void
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
301 vars_of_console_mswindows (void)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
302 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
303 Fprovide (Qmswindows);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 398
diff changeset
304 }