428
|
1 /* Console functions for mswindows.
|
563
|
2 Copyright (C) 1996, 2000, 2001 Ben Wing.
|
428
|
3
|
|
4 This file is part of XEmacs.
|
|
5
|
|
6 XEmacs is free software; you can redistribute it and/or modify it
|
|
7 under the terms of the GNU General Public License as published by the
|
|
8 Free Software Foundation; either version 2, or (at your option) any
|
|
9 later version.
|
|
10
|
|
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with XEmacs; see the file COPYING. If not, write to
|
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
19 Boston, MA 02111-1307, USA. */
|
|
20
|
|
21 /* Synched up with: Not in FSF. */
|
|
22
|
771
|
23 /* This file essentially Mule-ized (except perhaps some Unicode splitting).
|
|
24 5-2000. */
|
|
25
|
428
|
26 /* Authorship:
|
|
27
|
|
28 Ben Wing: January 1996, for 19.14.
|
|
29 Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0
|
|
30 */
|
|
31
|
|
32 #include <config.h>
|
|
33 #include "lisp.h"
|
|
34
|
|
35 #include "console-msw.h"
|
442
|
36 #include "events.h"
|
|
37 #include "opaque.h"
|
428
|
38
|
440
|
39 DEFINE_CONSOLE_TYPE (mswindows);
|
|
40 DEFINE_CONSOLE_TYPE (msprinter);
|
428
|
41
|
442
|
42 Lisp_Object Qabortretryignore;
|
|
43 Lisp_Object Qapplmodal;
|
|
44 Lisp_Object Qdefault_desktop_only;
|
|
45 Lisp_Object Qdefbutton1;
|
|
46 Lisp_Object Qdefbutton2;
|
|
47 Lisp_Object Qdefbutton3;
|
|
48 Lisp_Object Qdefbutton4;
|
|
49 /* Lisp_Object Qhelp; */
|
|
50 Lisp_Object Qiconasterisk;
|
|
51 Lisp_Object Qiconexclamation;
|
|
52 Lisp_Object Qiconhand;
|
|
53 Lisp_Object Qiconinformation;
|
|
54 Lisp_Object Qiconquestion;
|
|
55 Lisp_Object Qiconstop;
|
|
56 /* Lisp_Object Qok; */
|
|
57 Lisp_Object Qokcancel;
|
|
58 Lisp_Object Qretrycancel;
|
|
59 /* Lisp_Object Qright; */
|
|
60 Lisp_Object Qrtlreading;
|
|
61 Lisp_Object Qservice_notification;
|
|
62 Lisp_Object Qsetforeground;
|
|
63 Lisp_Object Qsystemmodal;
|
|
64 Lisp_Object Qtaskmodal;
|
|
65 Lisp_Object Qtopmost;
|
|
66 Lisp_Object Qyesno;
|
|
67 Lisp_Object Qyesnocancel;
|
|
68
|
|
69 /* Lisp_Object Qabort; */
|
|
70 /* Lisp_Object Qcancel; */
|
|
71 /* Lisp_Object Qignore; */
|
|
72 /* Lisp_Object Qno; */
|
|
73 /* Lisp_Object Qok; */
|
|
74 /* Lisp_Object Qretry; */
|
|
75 /* Lisp_Object Qyes; */
|
|
76
|
|
77
|
440
|
78 /************************************************************************/
|
|
79 /* mswindows console methods */
|
|
80 /************************************************************************/
|
428
|
81
|
|
82 static int
|
|
83 mswindows_initially_selected_for_input (struct console *con)
|
|
84 {
|
|
85 return 1;
|
|
86 }
|
|
87
|
442
|
88 static HWND mswindows_console_hwnd = 0;
|
|
89
|
|
90 #define KLUDGE_BUFSIZE 1024 /* buffer size for console window titles */
|
|
91
|
|
92 /* Direct from the horse's mouth: Microsoft KB article Q124103 */
|
|
93 static HWND
|
|
94 GetConsoleHwnd (void)
|
|
95 {
|
|
96 HWND hwndFound; /* this is what is returned to the caller */
|
|
97 char pszNewWindowTitle[KLUDGE_BUFSIZE]; /* contains fabricated WindowTitle */
|
|
98 char pszOldWindowTitle[KLUDGE_BUFSIZE]; /* contains original WindowTitle */
|
|
99
|
|
100 /* fetch current window title */
|
|
101
|
771
|
102 GetConsoleTitle (pszOldWindowTitle, KLUDGE_BUFSIZE);
|
442
|
103
|
|
104 /* format a "unique" NewWindowTitle */
|
|
105
|
771
|
106 sprintf (pszNewWindowTitle, "%ld/%ld",
|
|
107 GetTickCount (),
|
|
108 GetCurrentProcessId ());
|
442
|
109
|
|
110 /* change current window title */
|
|
111
|
771
|
112 SetConsoleTitle (pszNewWindowTitle);
|
442
|
113
|
|
114 /* ensure window title has been updated */
|
|
115
|
771
|
116 Sleep (40);
|
442
|
117
|
|
118 /* look for NewWindowTitle */
|
|
119
|
771
|
120 hwndFound=FindWindow (NULL, pszNewWindowTitle);
|
442
|
121
|
|
122 /* restore original window title */
|
|
123
|
771
|
124 SetConsoleTitle (pszOldWindowTitle);
|
442
|
125
|
771
|
126 return (hwndFound);
|
442
|
127 }
|
|
128
|
771
|
129 static HWND
|
442
|
130 mswindows_get_console_hwnd (void)
|
|
131 {
|
|
132 if (!mswindows_console_hwnd)
|
|
133 mswindows_console_hwnd = GetConsoleHwnd ();
|
|
134 return mswindows_console_hwnd;
|
|
135 }
|
|
136
|
|
137 static int
|
|
138 mswindows_ensure_console_allocated (void)
|
|
139 {
|
|
140 HWND fgwin = GetForegroundWindow ();
|
|
141 /* stupid mswin api won't let you create the console window
|
|
142 hidden! creating it changes the focus! fuck me! */
|
|
143 if (AllocConsole ())
|
|
144 {
|
|
145 SetForegroundWindow (fgwin);
|
|
146 return 1;
|
|
147 }
|
|
148 return 0;
|
|
149 }
|
|
150
|
440
|
151 static Lisp_Object
|
|
152 mswindows_canonicalize_console_connection (Lisp_Object connection,
|
578
|
153 Error_Behavior errb)
|
440
|
154 {
|
|
155 /* Do not allow more than one mswindows device, by explicitly
|
|
156 requiring that CONNECTION is nil, the only allowed connection in
|
|
157 Windows. */
|
|
158 if (!NILP (connection))
|
|
159 {
|
|
160 if (ERRB_EQ (errb, ERROR_ME))
|
563
|
161 invalid_argument
|
440
|
162 ("Invalid (non-nil) connection for mswindows device/console",
|
|
163 connection);
|
|
164 else
|
|
165 return Qunbound;
|
|
166 }
|
428
|
167
|
440
|
168 return Qnil;
|
|
169 }
|
|
170
|
|
171 static Lisp_Object
|
|
172 mswindows_canonicalize_device_connection (Lisp_Object connection,
|
578
|
173 Error_Behavior errb)
|
440
|
174 {
|
|
175 return mswindows_canonicalize_console_connection (connection, errb);
|
|
176 }
|
428
|
177
|
442
|
178 void
|
|
179 mswindows_hide_console (void)
|
|
180 {
|
|
181 ShowWindow (mswindows_get_console_hwnd (), SW_HIDE);
|
|
182 }
|
|
183
|
771
|
184 static void
|
442
|
185 mswindows_show_console (void)
|
|
186 {
|
|
187 /* What I really want is for the console window to appear on top of other
|
|
188 windows, but NOT get the focus. This seems hard-to-impossible under
|
|
189 Windows. The following sequence seems to do the best possible, along
|
|
190 with keeping the console window on top when xemacs --help is used. */
|
|
191 HWND hwnd = mswindows_get_console_hwnd ();
|
|
192 HWND hwndf = GetFocus ();
|
771
|
193 if (!IsWindowVisible (hwnd))
|
|
194 ShowWindow (hwnd, SW_SHOWNA);
|
|
195 if (noninteractive)
|
|
196 BringWindowToTop (hwnd);
|
|
197 else
|
|
198 SetWindowPos (hwnd, hwndf, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE
|
|
199 | SWP_NOACTIVATE);
|
442
|
200 }
|
|
201
|
|
202 static int mswindows_console_buffered = 0;
|
|
203 HANDLE mswindows_console_buffer;
|
|
204
|
|
205 static void
|
|
206 mswindows_ensure_console_buffered (void)
|
|
207 {
|
|
208 if (!mswindows_console_buffered)
|
|
209 {
|
|
210 COORD new_size;
|
|
211
|
|
212 new_size.X = 80;
|
|
213 new_size.Y = 1000;
|
|
214 mswindows_ensure_console_allocated ();
|
|
215 mswindows_console_buffer =
|
|
216 CreateConsoleScreenBuffer (GENERIC_WRITE, 0, NULL,
|
|
217 CONSOLE_TEXTMODE_BUFFER, NULL);
|
|
218 SetConsoleScreenBufferSize (mswindows_console_buffer, new_size);
|
|
219 SetConsoleActiveScreenBuffer (mswindows_console_buffer);
|
|
220 mswindows_console_buffered = 1;
|
|
221 }
|
|
222 }
|
|
223
|
|
224 int mswindows_message_outputted;
|
|
225
|
|
226 int
|
771
|
227 mswindows_output_console_string (const Intbyte *ptr, Bytecount len)
|
442
|
228 {
|
|
229 DWORD num_written;
|
|
230
|
|
231 mswindows_message_outputted = 1;
|
|
232 mswindows_ensure_console_buffered ();
|
|
233 mswindows_show_console ();
|
|
234
|
771
|
235 if (initialized && !inhibit_non_essential_printing_operations)
|
|
236 {
|
|
237 const Extbyte *extptr;
|
|
238 Bytecount extlen;
|
|
239 TO_EXTERNAL_FORMAT (DATA, (ptr, len),
|
|
240 ALLOCA, (extptr, extlen),
|
|
241 Qmswindows_tstr);
|
|
242 return qxeWriteConsole (mswindows_console_buffer, extptr,
|
|
243 extlen / XETCHAR_SIZE, &num_written, NULL);
|
|
244 }
|
|
245 else
|
|
246 return WriteConsoleA (mswindows_console_buffer, (char *) ptr, len,
|
|
247 &num_written, NULL);
|
442
|
248 }
|
|
249
|
|
250 DEFUN ("mswindows-debugging-output", Fmswindows_debugging_output, 1, 1, 0, /*
|
|
251 Write CHAR-OR-STRING to the Windows debugger, using OutputDebugString().
|
|
252 This function can be used as the STREAM argument of Fprint() or the like.
|
|
253 */
|
|
254 (char_or_string))
|
|
255 {
|
|
256 if (STRINGP (char_or_string))
|
771
|
257 /* It's safe to pass in string data because TO_EXTERNAL_FORMAT
|
|
258 inhibits GC. */
|
|
259 write_string_to_mswindows_debugging_output
|
|
260 (XSTRING_DATA (char_or_string), XSTRING_LENGTH (char_or_string));
|
442
|
261 else
|
|
262 {
|
771
|
263 Intbyte str[MAX_EMCHAR_LEN];
|
442
|
264 Bytecount len;
|
|
265
|
|
266 CHECK_CHAR_COERCE_INT (char_or_string);
|
|
267 len = set_charptr_emchar (str, XCHAR (char_or_string));
|
771
|
268 write_string_to_mswindows_debugging_output (str, len);
|
442
|
269 }
|
|
270
|
|
271 return char_or_string;
|
|
272 }
|
|
273
|
771
|
274 void
|
|
275 write_string_to_mswindows_debugging_output (Intbyte *str, Bytecount len)
|
|
276 {
|
|
277 const Extbyte *extptr;
|
|
278 if (initialized && !inhibit_non_essential_printing_operations)
|
|
279 {
|
|
280 TO_EXTERNAL_FORMAT (DATA, (str, len),
|
|
281 C_STRING_ALLOCA, extptr,
|
|
282 Qmswindows_tstr);
|
|
283 qxeOutputDebugString (extptr);
|
|
284 }
|
|
285 else
|
|
286 OutputDebugStringA ((char *) str);
|
|
287 }
|
|
288
|
442
|
289 #ifdef DEBUG_XEMACS
|
|
290
|
|
291 /*
|
|
292 * Random helper functions for debugging.
|
|
293 * Intended for use in the MSVC "Watch" window which doesn't like
|
|
294 * the aborts that the error_check_foo() functions can make.
|
|
295 */
|
|
296 struct lrecord_header *DHEADER (Lisp_Object obj);
|
|
297 struct lrecord_header *
|
|
298 DHEADER (Lisp_Object obj)
|
|
299 {
|
|
300 return LRECORDP (obj) ? XRECORD_LHEADER (obj) : NULL;
|
|
301 }
|
|
302
|
|
303 void *DOPAQUE_DATA (Lisp_Object obj);
|
|
304 void *
|
|
305 DOPAQUE_DATA (Lisp_Object obj)
|
|
306 {
|
|
307 return OPAQUEP (obj) ? OPAQUE_DATA (XOPAQUE (obj)) : NULL;
|
|
308 }
|
|
309
|
|
310 Lisp_Event *DEVENT (Lisp_Object obj);
|
|
311 Lisp_Event *
|
|
312 DEVENT (Lisp_Object obj)
|
|
313 {
|
|
314 return EVENTP (obj) ? XEVENT (obj) : NULL;
|
|
315 }
|
|
316
|
|
317 Lisp_Cons *DCONS (Lisp_Object obj);
|
|
318 Lisp_Cons *
|
|
319 DCONS (Lisp_Object obj)
|
|
320 {
|
|
321 return CONSP (obj) ? XCONS (obj) : NULL;
|
|
322 }
|
|
323
|
|
324 Lisp_Cons *DCONSCDR (Lisp_Object obj);
|
|
325 Lisp_Cons *
|
|
326 DCONSCDR (Lisp_Object obj)
|
|
327 {
|
|
328 return (CONSP (obj) && CONSP (XCDR (obj))) ? XCONS (XCDR (obj)) : 0;
|
|
329 }
|
|
330
|
665
|
331 Intbyte *DSTRING (Lisp_Object obj);
|
|
332 Intbyte *
|
442
|
333 DSTRING (Lisp_Object obj)
|
|
334 {
|
|
335 return STRINGP (obj) ? XSTRING_DATA (obj) : NULL;
|
|
336 }
|
|
337
|
|
338 Lisp_Vector *DVECTOR (Lisp_Object obj);
|
|
339 Lisp_Vector *
|
|
340 DVECTOR (Lisp_Object obj)
|
|
341 {
|
|
342 return VECTORP (obj) ? XVECTOR (obj) : NULL;
|
|
343 }
|
|
344
|
|
345 Lisp_Symbol *DSYMBOL (Lisp_Object obj);
|
|
346 Lisp_Symbol *
|
|
347 DSYMBOL (Lisp_Object obj)
|
|
348 {
|
|
349 return SYMBOLP (obj) ? XSYMBOL (obj) : NULL;
|
|
350 }
|
|
351
|
665
|
352 Intbyte *DSYMNAME (Lisp_Object obj);
|
|
353 Intbyte *
|
442
|
354 DSYMNAME (Lisp_Object obj)
|
|
355 {
|
|
356 return SYMBOLP (obj) ? string_data (XSYMBOL (obj)->name) : NULL;
|
|
357 }
|
|
358
|
|
359 #endif /* DEBUG_XEMACS */
|
|
360
|
|
361 DEFUN ("mswindows-message-box", Fmswindows_message_box, 1, 3, 0, /*
|
|
362 Pop up an MS Windows message box.
|
|
363 MESSAGE is the string to display. Optional argument FLAG controls
|
|
364 what appears in the box and how it behaves; it is a symbol or list of
|
|
365 symbols, described below. Second optional argument TITLE controls the
|
|
366 title bar; if omitted, a standard title bar will be used, probably
|
|
367 displaying "XEmacs".
|
|
368
|
|
369 Possible flags are
|
|
370
|
|
371
|
|
372 -- To specify the buttons in the message box:
|
|
373
|
|
374 abortretryignore
|
|
375 The message box contains three push buttons: Abort, Retry, and Ignore.
|
|
376 ok
|
|
377 The message box contains one push button: OK. This is the default.
|
|
378 okcancel
|
|
379 The message box contains two push buttons: OK and Cancel.
|
|
380 retrycancel
|
|
381 The message box contains two push buttons: Retry and Cancel.
|
|
382 yesno
|
|
383 The message box contains two push buttons: Yes and No.
|
|
384 yesnocancel
|
|
385 The message box contains three push buttons: Yes, No, and Cancel.
|
|
386
|
|
387
|
|
388 -- To display an icon in the message box:
|
|
389
|
|
390 iconexclamation, iconwarning
|
|
391 An exclamation-point icon appears in the message box.
|
|
392 iconinformation, iconasterisk
|
|
393 An icon consisting of a lowercase letter i in a circle appears in
|
|
394 the message box.
|
|
395 iconquestion
|
|
396 A question-mark icon appears in the message box.
|
|
397 iconstop, iconerror, iconhand
|
|
398 A stop-sign icon appears in the message box.
|
|
399
|
|
400
|
|
401 -- To indicate the default button:
|
|
402
|
|
403 defbutton1
|
|
404 The first button is the default button. This is the default.
|
|
405 defbutton2
|
|
406 The second button is the default button.
|
|
407 defbutton3
|
|
408 The third button is the default button.
|
|
409 defbutton4
|
|
410 The fourth button is the default button.
|
|
411
|
|
412
|
|
413 -- To indicate the modality of the dialog box:
|
|
414
|
|
415 applmodal
|
|
416 The user must respond to the message box before continuing work in
|
|
417 the window identified by the hWnd parameter. However, the user can
|
|
418 move to the windows of other applications and work in those windows.
|
|
419 Depending on the hierarchy of windows in the application, the user
|
|
420 may be able to move to other windows within the application. All
|
|
421 child windows of the parent of the message box are automatically
|
|
422 disabled, but popup windows are not. This is the default.
|
|
423 systemmodal
|
|
424 Same as applmodal except that the message box has the WS_EX_TOPMOST
|
|
425 style. Use system-modal message boxes to notify the user of serious,
|
|
426 potentially damaging errors that require immediate attention (for
|
|
427 example, running out of memory). This flag has no effect on the
|
|
428 user's ability to interact with windows other than those associated
|
|
429 with hWnd.
|
|
430 taskmodal
|
|
431 Same as applmodal except that all the top-level windows belonging to
|
|
432 the current task are disabled if the hWnd parameter is NULL. Use
|
|
433 this flag when the calling application or library does not have a
|
|
434 window handle available but still needs to prevent input to other
|
|
435 windows in the current application without suspending other
|
|
436 applications.
|
|
437
|
|
438
|
|
439 In addition, you can specify the following flags:
|
|
440
|
|
441 default-desktop-only
|
|
442 The desktop currently receiving input must be a default desktop;
|
|
443 otherwise, the function fails. A default desktop is one an
|
|
444 application runs on after the user has logged on.
|
|
445 help
|
|
446 Adds a Help button to the message box. Choosing the Help button or
|
|
447 pressing F1 generates a Help event.
|
|
448 right
|
|
449 The text is right-justified.
|
|
450 rtlreading
|
|
451 Displays message and caption text using right-to-left reading order
|
|
452 on Hebrew and Arabic systems.
|
|
453 setforeground
|
|
454 The message box becomes the foreground window. Internally, Windows
|
|
455 calls the SetForegroundWindow function for the message box.
|
|
456 topmost
|
|
457 The message box is created with the WS_EX_TOPMOST window style.
|
|
458 service-notification
|
|
459 Windows NT only: The caller is a service notifying the user of an
|
|
460 event. The function displays a message box on the current active
|
|
461 desktop, even if there is no user logged on to the computer. If
|
|
462 this flag is set, the hWnd parameter must be NULL. This is so the
|
|
463 message box can appear on a desktop other than the desktop
|
|
464 corresponding to the hWnd.
|
|
465
|
|
466
|
|
467
|
|
468 The return value is one of the following menu-item values returned by
|
|
469 the dialog box:
|
|
470
|
|
471 abort
|
|
472 Abort button was selected.
|
|
473 cancel
|
|
474 Cancel button was selected.
|
|
475 ignore
|
|
476 Ignore button was selected.
|
|
477 no
|
|
478 No button was selected.
|
|
479 ok
|
|
480 OK button was selected.
|
|
481 retry
|
|
482 Retry button was selected.
|
|
483 yes
|
|
484 Yes button was selected.
|
|
485
|
|
486 If a message box has a Cancel button, the function returns the
|
|
487 `cancel' value if either the ESC key is pressed or the Cancel button
|
|
488 is selected. If the message box has no Cancel button, pressing ESC has
|
|
489 no effect. */
|
|
490 (message_, flags, title))
|
|
491 {
|
|
492 Lisp_Object tail;
|
|
493 Extbyte *msgout;
|
|
494 Extbyte *titleout = 0;
|
|
495 UINT sty = 0;
|
|
496
|
|
497 if (!LISTP (flags))
|
|
498 {
|
|
499 CHECK_SYMBOL (flags);
|
|
500 flags = list1 (flags);
|
|
501 }
|
|
502
|
|
503 CHECK_STRING (message_);
|
771
|
504 LISP_STRING_TO_TSTR (message_, msgout);
|
442
|
505
|
|
506 if (!NILP (title))
|
|
507 {
|
|
508 CHECK_STRING (title);
|
771
|
509 LISP_STRING_TO_TSTR (title, titleout);
|
442
|
510 }
|
|
511
|
|
512 EXTERNAL_LIST_LOOP (tail, flags)
|
|
513 {
|
|
514 Lisp_Object st = XCAR (tail);
|
|
515 CHECK_SYMBOL (st);
|
|
516 if (0)
|
|
517 ;
|
|
518 #define FROB(sym, val) else if (EQ (st, sym)) sty |= val
|
|
519 FROB (Qabortretryignore, MB_ABORTRETRYIGNORE);
|
|
520 FROB (Qapplmodal, MB_APPLMODAL);
|
|
521 FROB (Qdefault_desktop_only, MB_DEFAULT_DESKTOP_ONLY);
|
|
522 FROB (Qdefbutton1, MB_DEFBUTTON1);
|
|
523 FROB (Qdefbutton2, MB_DEFBUTTON2);
|
|
524 FROB (Qdefbutton3, MB_DEFBUTTON3);
|
|
525 FROB (Qdefbutton4, MB_DEFBUTTON4);
|
|
526 FROB (Qhelp, MB_HELP);
|
|
527 FROB (Qiconasterisk, MB_ICONASTERISK);
|
|
528 FROB (Qiconexclamation, MB_ICONEXCLAMATION);
|
|
529 FROB (Qiconhand, MB_ICONHAND);
|
|
530 FROB (Qiconinformation, MB_ICONINFORMATION);
|
|
531 FROB (Qiconquestion, MB_ICONQUESTION);
|
|
532 FROB (Qiconstop, MB_ICONSTOP);
|
|
533 FROB (Qok, MB_OK);
|
|
534 FROB (Qokcancel, MB_OKCANCEL);
|
|
535 FROB (Qretrycancel, MB_RETRYCANCEL);
|
|
536 FROB (Qright, MB_RIGHT);
|
|
537 FROB (Qrtlreading, MB_RTLREADING);
|
|
538 FROB (Qservice_notification, MB_SERVICE_NOTIFICATION);
|
|
539 FROB (Qsetforeground, MB_SETFOREGROUND);
|
|
540 FROB (Qsystemmodal, MB_SYSTEMMODAL);
|
|
541 FROB (Qtaskmodal, MB_TASKMODAL);
|
|
542 FROB (Qtopmost, MB_TOPMOST);
|
|
543 FROB (Qyesno, MB_YESNO);
|
|
544 FROB (Qyesnocancel, MB_YESNOCANCEL);
|
|
545 #undef FROB
|
|
546
|
|
547 else
|
563
|
548 invalid_constant ("Unrecognized flag", st);
|
442
|
549 }
|
|
550
|
|
551 {
|
771
|
552 int retval = qxeMessageBox (NULL, msgout, titleout, sty);
|
442
|
553
|
|
554 if (retval == 0)
|
563
|
555 out_of_memory ("When calling `mswindows-message-box'", Qunbound);
|
442
|
556
|
|
557 #define FROB(sym, val) if (retval == val) return sym
|
|
558 FROB (Qabort, IDABORT);
|
|
559 FROB (Qcancel, IDCANCEL);
|
|
560 FROB (Qignore, IDIGNORE);
|
|
561 FROB (Qno, IDNO);
|
|
562 FROB (Qok, IDOK);
|
|
563 FROB (Qretry, IDRETRY);
|
|
564 FROB (Qyes, IDYES);
|
|
565 #undef FROB
|
|
566
|
563
|
567 invalid_argument ("Unknown return value from MessageBox()",
|
|
568 make_int (retval));
|
442
|
569 }
|
|
570
|
|
571 return Qnil;
|
|
572 }
|
|
573
|
|
574 static Lisp_Object
|
|
575 msprinter_canonicalize_console_connection (Lisp_Object connection,
|
578
|
576 Error_Behavior errb)
|
442
|
577 {
|
|
578 /* If nil connection is specified, transform it into the name
|
|
579 of the default printer */
|
|
580 if (NILP (connection))
|
|
581 {
|
|
582 connection = msprinter_default_printer ();
|
|
583 if (NILP (connection))
|
|
584 {
|
|
585 if (ERRB_EQ (errb, ERROR_ME))
|
563
|
586 invalid_state ("There is no default printer in the system",
|
|
587 Qunbound);
|
442
|
588 else
|
|
589 return Qunbound;
|
|
590 }
|
|
591 }
|
|
592
|
|
593 CHECK_STRING (connection);
|
|
594 return connection;
|
|
595 }
|
|
596
|
|
597 static Lisp_Object
|
|
598 msprinter_canonicalize_device_connection (Lisp_Object connection,
|
578
|
599 Error_Behavior errb)
|
442
|
600 {
|
|
601 return msprinter_canonicalize_console_connection (connection, errb);
|
|
602 }
|
|
603
|
428
|
604
|
|
605 /************************************************************************/
|
|
606 /* initialization */
|
|
607 /************************************************************************/
|
|
608
|
|
609 void
|
|
610 syms_of_console_mswindows (void)
|
|
611 {
|
442
|
612 DEFSUBR (Fmswindows_debugging_output);
|
|
613
|
563
|
614 DEFSYMBOL (Qabortretryignore);
|
|
615 DEFSYMBOL (Qapplmodal);
|
|
616 DEFSYMBOL (Qdefault_desktop_only);
|
|
617 DEFSYMBOL (Qdefbutton1);
|
|
618 DEFSYMBOL (Qdefbutton2);
|
|
619 DEFSYMBOL (Qdefbutton3);
|
|
620 DEFSYMBOL (Qdefbutton4);
|
|
621 /* DEFSYMBOL (Qhelp); */
|
|
622 DEFSYMBOL (Qiconasterisk);
|
|
623 DEFSYMBOL (Qiconexclamation);
|
|
624 DEFSYMBOL (Qiconhand);
|
|
625 DEFSYMBOL (Qiconinformation);
|
|
626 DEFSYMBOL (Qiconquestion);
|
|
627 DEFSYMBOL (Qiconstop);
|
|
628 /* DEFSYMBOL (Qok); */
|
|
629 DEFSYMBOL (Qokcancel);
|
|
630 DEFSYMBOL (Qretrycancel);
|
|
631 /* DEFSYMBOL (Qright); */
|
|
632 DEFSYMBOL (Qrtlreading);
|
|
633 DEFSYMBOL (Qservice_notification);
|
|
634 DEFSYMBOL (Qsetforeground);
|
|
635 DEFSYMBOL (Qsystemmodal);
|
|
636 DEFSYMBOL (Qtaskmodal);
|
|
637 DEFSYMBOL (Qtopmost);
|
|
638 DEFSYMBOL (Qyesno);
|
|
639 DEFSYMBOL (Qyesnocancel);
|
442
|
640
|
563
|
641 /* DEFSYMBOL (Qabort); */
|
|
642 /* DEFSYMBOL (Qcancel); */
|
|
643 /* DEFSYMBOL (Qignore); */
|
|
644 /* DEFSYMBOL (Qno); */
|
|
645 /* DEFSYMBOL (Qok); */
|
|
646 /* DEFSYMBOL (Qretry); */
|
|
647 /* DEFSYMBOL (Qyes); */
|
442
|
648
|
|
649 DEFSUBR (Fmswindows_message_box);
|
428
|
650 }
|
|
651
|
|
652 void
|
|
653 console_type_create_mswindows (void)
|
|
654 {
|
|
655 INITIALIZE_CONSOLE_TYPE (mswindows, "mswindows", "console-mswindows-p");
|
|
656
|
|
657 /* console methods */
|
|
658 /* CONSOLE_HAS_METHOD (mswindows, init_console); */
|
|
659 /* CONSOLE_HAS_METHOD (mswindows, mark_console); */
|
|
660 CONSOLE_HAS_METHOD (mswindows, initially_selected_for_input);
|
|
661 /* CONSOLE_HAS_METHOD (mswindows, delete_console); */
|
440
|
662 CONSOLE_HAS_METHOD (mswindows, canonicalize_console_connection);
|
|
663 CONSOLE_HAS_METHOD (mswindows, canonicalize_device_connection);
|
428
|
664 /* CONSOLE_HAS_METHOD (mswindows, semi_canonicalize_console_connection); */
|
|
665 /* CONSOLE_HAS_METHOD (mswindows, semi_canonicalize_device_connection); */
|
440
|
666
|
|
667 INITIALIZE_CONSOLE_TYPE (msprinter, "msprinter", "console-msprinter-p");
|
442
|
668 CONSOLE_HAS_METHOD (msprinter, canonicalize_console_connection);
|
|
669 CONSOLE_HAS_METHOD (msprinter, canonicalize_device_connection);
|
428
|
670 }
|
|
671
|
|
672 void
|
|
673 reinit_console_type_create_mswindows (void)
|
|
674 {
|
|
675 REINITIALIZE_CONSOLE_TYPE (mswindows);
|
440
|
676 REINITIALIZE_CONSOLE_TYPE (msprinter);
|
428
|
677 }
|
|
678
|
|
679 void
|
|
680 vars_of_console_mswindows (void)
|
|
681 {
|
|
682 Fprovide (Qmswindows);
|
|
683 }
|