Mercurial > hg > xemacs-beta
annotate src/console-msw.c @ 5925:08cfc8f77fb6 cygwin
make space for long ptr, and store as such, for frame in WINDOW data,
add a bit more debugging to debug-mswindow,
Vin Shelton patch to fix M-x shell
| author | Henry Thompson <ht@markup.co.uk> |
|---|---|
| date | Fri, 27 Feb 2015 17:41:20 +0000 |
| parents | 68639fb08af8 |
| children |
| rev | line source |
|---|---|
| 428 | 1 /* Console functions for mswindows. |
| 793 | 2 Copyright (C) 1996, 2000, 2001, 2002 Ben Wing. |
| 428 | 3 |
| 4 This file is part of XEmacs. | |
| 5 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5191
diff
changeset
|
6 XEmacs is free software: you can redistribute it and/or modify it |
| 428 | 7 under the terms of the GNU General Public License as published by the |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5191
diff
changeset
|
8 Free Software Foundation, either version 3 of the License, or (at your |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5191
diff
changeset
|
9 option) any later version. |
| 428 | 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 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5191
diff
changeset
|
17 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 428 | 18 |
| 19 /* Synched up with: Not in FSF. */ | |
| 20 | |
| 771 | 21 /* This file essentially Mule-ized (except perhaps some Unicode splitting). |
| 22 5-2000. */ | |
| 23 | |
| 428 | 24 /* Authorship: |
| 25 | |
| 26 Ben Wing: January 1996, for 19.14. | |
| 27 Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0 | |
| 28 */ | |
| 29 | |
| 2367 | 30 /* See win32.c for info about the different Windows files in XEmacs. */ |
| 31 | |
| 428 | 32 #include <config.h> |
| 33 #include "lisp.h" | |
| 34 | |
| 872 | 35 #include "console-msw-impl.h" |
| 442 | 36 #include "events.h" |
| 37 #include "opaque.h" | |
| 2828 | 38 #include "elhash.h" |
| 428 | 39 |
| 440 | 40 DEFINE_CONSOLE_TYPE (mswindows); |
| 41 DEFINE_CONSOLE_TYPE (msprinter); | |
| 428 | 42 |
| 442 | 43 Lisp_Object Qabortretryignore; |
| 44 Lisp_Object Qapplmodal; | |
| 45 Lisp_Object Qdefault_desktop_only; | |
| 46 Lisp_Object Qdefbutton1; | |
| 47 Lisp_Object Qdefbutton2; | |
| 48 Lisp_Object Qdefbutton3; | |
| 49 Lisp_Object Qdefbutton4; | |
| 50 /* Lisp_Object Qhelp; */ | |
| 51 Lisp_Object Qiconasterisk; | |
| 52 Lisp_Object Qiconexclamation; | |
| 53 Lisp_Object Qiconhand; | |
| 54 Lisp_Object Qiconinformation; | |
| 55 Lisp_Object Qiconquestion; | |
| 56 Lisp_Object Qiconstop; | |
| 57 /* Lisp_Object Qok; */ | |
| 58 Lisp_Object Qokcancel; | |
| 59 Lisp_Object Qretrycancel; | |
| 60 /* Lisp_Object Qright; */ | |
| 61 Lisp_Object Qrtlreading; | |
| 62 Lisp_Object Qservice_notification; | |
| 63 Lisp_Object Qsetforeground; | |
| 64 Lisp_Object Qsystemmodal; | |
| 65 Lisp_Object Qtaskmodal; | |
| 66 Lisp_Object Qtopmost; | |
| 67 Lisp_Object Qyesno; | |
| 68 Lisp_Object Qyesnocancel; | |
| 2850 | 69 Lisp_Object Vmswindows_seen_characters; |
| 442 | 70 |
| 71 /* Lisp_Object Qabort; */ | |
| 72 /* Lisp_Object Qcancel; */ | |
| 73 /* Lisp_Object Qignore; */ | |
| 74 /* Lisp_Object Qno; */ | |
| 75 /* Lisp_Object Qok; */ | |
| 76 /* Lisp_Object Qretry; */ | |
| 77 /* Lisp_Object Qyes; */ | |
| 78 | |
| 79 | |
| 440 | 80 /************************************************************************/ |
| 81 /* mswindows console methods */ | |
| 82 /************************************************************************/ | |
| 428 | 83 |
| 84 static int | |
| 2286 | 85 mswindows_initially_selected_for_input (struct console *UNUSED (con)) |
| 428 | 86 { |
| 87 return 1; | |
| 88 } | |
| 89 | |
| 442 | 90 static HWND mswindows_console_hwnd = 0; |
| 91 | |
| 800 | 92 /* Based on Microsoft KB article Q124103 */ |
| 442 | 93 static HWND |
| 94 GetConsoleHwnd (void) | |
| 95 { | |
| 800 | 96 HWND hwndFound; |
| 2367 | 97 Ascbyte newtitle[100]; |
| 800 | 98 Extbyte *oldtitle; |
| 99 int numchars; | |
| 442 | 100 |
| 101 /* fetch current window title */ | |
| 102 | |
| 800 | 103 { |
| 104 int size = 64; | |
| 105 do | |
| 106 { | |
| 107 size *= 2; | |
| 108 oldtitle = alloca_extbytes (size * XETCHAR_SIZE); | |
| 109 numchars = qxeGetConsoleTitle (oldtitle, size); | |
| 110 } | |
| 111 while (numchars >= size - 1); | |
| 112 } | |
| 442 | 113 |
| 800 | 114 /* format a "unique" new title */ |
| 115 | |
|
5921
68639fb08af8
no obvious 64 vs. 32 pblms in compilation, but still crashing in event-msw
Henry Thompson <ht@markup.co.uk>
parents:
5581
diff
changeset
|
116 sprintf (newtitle, "%ld/%ld", (long)GetTickCount (), (long)GetCurrentProcessId ()); |
| 800 | 117 |
| 2367 | 118 /* change current window title; we may be called during armageddon |
| 119 so don't do any conversion */ | |
| 442 | 120 |
| 2367 | 121 SetConsoleTitleA (newtitle); |
| 442 | 122 |
| 123 /* ensure window title has been updated */ | |
| 124 | |
| 771 | 125 Sleep (40); |
| 442 | 126 |
| 127 /* look for NewWindowTitle */ | |
| 128 | |
| 2367 | 129 hwndFound = FindWindowA (NULL, newtitle); |
| 442 | 130 |
| 131 /* restore original window title */ | |
| 132 | |
| 800 | 133 qxeSetConsoleTitle (oldtitle); |
| 442 | 134 |
| 800 | 135 return hwndFound; |
| 442 | 136 } |
| 137 | |
| 771 | 138 static HWND |
| 442 | 139 mswindows_get_console_hwnd (void) |
| 140 { | |
| 141 if (!mswindows_console_hwnd) | |
| 142 mswindows_console_hwnd = GetConsoleHwnd (); | |
| 143 return mswindows_console_hwnd; | |
| 144 } | |
| 145 | |
| 146 static int | |
| 147 mswindows_ensure_console_allocated (void) | |
| 148 { | |
| 149 HWND fgwin = GetForegroundWindow (); | |
| 150 /* stupid mswin api won't let you create the console window | |
| 151 hidden! creating it changes the focus! fuck me! */ | |
| 152 if (AllocConsole ()) | |
| 153 { | |
| 154 SetForegroundWindow (fgwin); | |
| 155 return 1; | |
| 156 } | |
| 157 return 0; | |
| 158 } | |
| 159 | |
| 440 | 160 static Lisp_Object |
| 161 mswindows_canonicalize_console_connection (Lisp_Object connection, | |
| 578 | 162 Error_Behavior errb) |
| 440 | 163 { |
| 164 /* Do not allow more than one mswindows device, by explicitly | |
| 165 requiring that CONNECTION is nil, the only allowed connection in | |
| 166 Windows. */ | |
| 167 if (!NILP (connection)) | |
| 168 { | |
| 169 if (ERRB_EQ (errb, ERROR_ME)) | |
| 563 | 170 invalid_argument |
| 440 | 171 ("Invalid (non-nil) connection for mswindows device/console", |
| 172 connection); | |
| 173 else | |
| 174 return Qunbound; | |
| 175 } | |
| 428 | 176 |
| 440 | 177 return Qnil; |
| 178 } | |
| 179 | |
| 180 static Lisp_Object | |
| 181 mswindows_canonicalize_device_connection (Lisp_Object connection, | |
| 578 | 182 Error_Behavior errb) |
| 440 | 183 { |
| 184 return mswindows_canonicalize_console_connection (connection, errb); | |
| 185 } | |
| 428 | 186 |
| 2828 | 187 /* The actual console doesn't matter, because the global map is global. See |
| 188 console-x.c for a corner case, though. */ | |
| 189 | |
| 190 static Lisp_Object | |
| 191 mswindows_perhaps_init_unseen_key_defaults (struct console *UNUSED(con), | |
| 192 Lisp_Object key) | |
| 193 { | |
| 194 Ichar val; | |
| 195 extern Lisp_Object Vcurrent_global_map; | |
| 196 | |
| 197 if (SYMBOLP(key)) | |
| 198 { | |
| 199 /* We've no idea what to default a symbol to on MS Windows, and most | |
| 200 of the keys I'm aware of that have | |
| 201 symbols--cf. event-msw.c--_shouldn't_ have associated chars. */ | |
| 202 return Qnil; | |
| 203 } | |
| 204 | |
| 205 CHECK_CHAR(key); | |
| 206 | |
| 2850 | 207 if (!(HASH_TABLEP(Vmswindows_seen_characters))) |
| 2828 | 208 { |
| 209 /* All the keysym we deal with are character objects; therefore, we | |
| 210 can use eq as the test without worrying. */ | |
| 2850 | 211 Vmswindows_seen_characters = make_lisp_hash_table (128, |
| 212 HASH_TABLE_NON_WEAK, | |
|
5191
71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents:
4981
diff
changeset
|
213 Qeq); |
| 2828 | 214 } |
| 215 /* Might give the user an opaque error if make_lisp_hash_table fails, | |
| 216 but it shouldn't crash. */ | |
| 2850 | 217 CHECK_HASH_TABLE(Vmswindows_seen_characters); |
| 2828 | 218 |
| 219 val = XCHAR(key); | |
| 220 | |
| 221 /* Same logic as in x_has_keysym; I'm not convinced it's sane. */ | |
| 222 if (val < 0x80) | |
| 223 { | |
| 224 return Qnil; | |
| 225 } | |
| 226 | |
| 2850 | 227 if (!NILP(Fgethash(key, Vmswindows_seen_characters, Qnil))) |
| 2828 | 228 { |
| 229 return Qnil; | |
| 230 } | |
| 231 | |
| 232 if (NILP (Flookup_key (Vcurrent_global_map, key, Qnil))) | |
| 233 { | |
| 2850 | 234 Fputhash(key, Qt, Vmswindows_seen_characters); |
| 2828 | 235 Fdefine_key (Vcurrent_global_map, key, Qself_insert_command); |
| 236 return Qt; | |
| 237 } | |
| 238 | |
| 239 return Qnil; | |
| 240 } | |
| 241 | |
| 442 | 242 void |
| 243 mswindows_hide_console (void) | |
| 244 { | |
| 245 ShowWindow (mswindows_get_console_hwnd (), SW_HIDE); | |
| 246 } | |
| 247 | |
| 771 | 248 static void |
| 442 | 249 mswindows_show_console (void) |
| 250 { | |
| 251 /* What I really want is for the console window to appear on top of other | |
| 252 windows, but NOT get the focus. This seems hard-to-impossible under | |
| 253 Windows. The following sequence seems to do the best possible, along | |
| 254 with keeping the console window on top when xemacs --help is used. */ | |
| 255 HWND hwnd = mswindows_get_console_hwnd (); | |
| 256 HWND hwndf = GetFocus (); | |
| 771 | 257 if (!IsWindowVisible (hwnd)) |
| 258 ShowWindow (hwnd, SW_SHOWNA); | |
| 259 if (noninteractive) | |
| 260 BringWindowToTop (hwnd); | |
| 261 else | |
| 262 SetWindowPos (hwnd, hwndf, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | |
| 263 | SWP_NOACTIVATE); | |
| 442 | 264 } |
| 265 | |
| 266 static int mswindows_console_buffered = 0; | |
| 267 HANDLE mswindows_console_buffer; | |
| 268 | |
| 269 static void | |
| 270 mswindows_ensure_console_buffered (void) | |
| 271 { | |
| 272 if (!mswindows_console_buffered) | |
| 273 { | |
| 274 COORD new_size; | |
| 275 | |
| 276 new_size.X = 80; | |
| 277 new_size.Y = 1000; | |
| 278 mswindows_ensure_console_allocated (); | |
| 279 mswindows_console_buffer = | |
| 280 CreateConsoleScreenBuffer (GENERIC_WRITE, 0, NULL, | |
| 281 CONSOLE_TEXTMODE_BUFFER, NULL); | |
| 282 SetConsoleScreenBufferSize (mswindows_console_buffer, new_size); | |
| 283 SetConsoleActiveScreenBuffer (mswindows_console_buffer); | |
| 284 mswindows_console_buffered = 1; | |
| 285 } | |
| 286 } | |
| 287 | |
| 288 int mswindows_message_outputted; | |
| 289 | |
| 290 int | |
| 867 | 291 mswindows_output_console_string (const Ibyte *ptr, Bytecount len) |
| 442 | 292 { |
| 293 DWORD num_written; | |
| 294 | |
| 295 mswindows_message_outputted = 1; | |
| 296 mswindows_ensure_console_buffered (); | |
| 297 mswindows_show_console (); | |
| 298 | |
| 2367 | 299 if (initialized && !inhibit_non_essential_conversion_operations) |
| 771 | 300 { |
| 301 const Extbyte *extptr; | |
| 302 Bytecount extlen; | |
| 303 TO_EXTERNAL_FORMAT (DATA, (ptr, len), | |
| 304 ALLOCA, (extptr, extlen), | |
| 305 Qmswindows_tstr); | |
| 306 return qxeWriteConsole (mswindows_console_buffer, extptr, | |
| 307 extlen / XETCHAR_SIZE, &num_written, NULL); | |
| 308 } | |
| 309 else | |
| 2367 | 310 #ifdef NON_ASCII_INTERNAL_FORMAT |
| 311 #error Do something here | |
| 312 #endif | |
| 313 return WriteConsoleA (mswindows_console_buffer, (Chbyte *) ptr, len, | |
| 771 | 314 &num_written, NULL); |
| 442 | 315 } |
| 316 | |
| 317 DEFUN ("mswindows-debugging-output", Fmswindows_debugging_output, 1, 1, 0, /* | |
| 318 Write CHAR-OR-STRING to the Windows debugger, using OutputDebugString(). | |
| 319 This function can be used as the STREAM argument of Fprint() or the like. | |
| 320 */ | |
| 321 (char_or_string)) | |
| 322 { | |
| 323 if (STRINGP (char_or_string)) | |
| 771 | 324 /* It's safe to pass in string data because TO_EXTERNAL_FORMAT |
| 325 inhibits GC. */ | |
| 326 write_string_to_mswindows_debugging_output | |
| 327 (XSTRING_DATA (char_or_string), XSTRING_LENGTH (char_or_string)); | |
| 442 | 328 else |
| 329 { | |
| 867 | 330 Ibyte str[MAX_ICHAR_LEN]; |
| 442 | 331 Bytecount len; |
| 332 | |
| 333 CHECK_CHAR_COERCE_INT (char_or_string); | |
| 867 | 334 len = set_itext_ichar (str, XCHAR (char_or_string)); |
| 771 | 335 write_string_to_mswindows_debugging_output (str, len); |
| 442 | 336 } |
| 337 | |
| 338 return char_or_string; | |
| 339 } | |
| 340 | |
| 771 | 341 void |
| 1346 | 342 write_string_to_mswindows_debugging_output (const Ibyte *str, Bytecount len) |
| 771 | 343 { |
| 344 const Extbyte *extptr; | |
| 2367 | 345 if (initialized && !inhibit_non_essential_conversion_operations) |
| 771 | 346 { |
| 347 TO_EXTERNAL_FORMAT (DATA, (str, len), | |
|
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
2850
diff
changeset
|
348 C_STRING_ALLOCA, extptr, Qmswindows_tstr); |
| 771 | 349 qxeOutputDebugString (extptr); |
| 350 } | |
| 351 else | |
| 1204 | 352 { |
| 2367 | 353 #ifdef NON_ASCII_INTERNAL_FORMAT |
| 354 #error Do something here | |
| 355 #endif | |
| 1204 | 356 /* STR may not be null-terminated so make it that way. */ |
| 357 Extbyte *ext = alloca_extbytes (len + 1); | |
| 358 memcpy (ext, str, len); | |
| 359 ext[len] = '\0'; | |
| 360 OutputDebugStringA (ext); | |
| 361 } | |
| 771 | 362 } |
| 363 | |
| 442 | 364 #ifdef DEBUG_XEMACS |
| 365 | |
| 366 /* | |
| 367 * Random helper functions for debugging. | |
| 368 * Intended for use in the MSVC "Watch" window which doesn't like | |
| 369 * the aborts that the error_check_foo() functions can make. | |
| 370 */ | |
| 371 struct lrecord_header *DHEADER (Lisp_Object obj); | |
| 372 struct lrecord_header * | |
| 373 DHEADER (Lisp_Object obj) | |
| 374 { | |
| 375 return LRECORDP (obj) ? XRECORD_LHEADER (obj) : NULL; | |
| 376 } | |
| 377 | |
| 378 void *DOPAQUE_DATA (Lisp_Object obj); | |
| 379 void * | |
| 380 DOPAQUE_DATA (Lisp_Object obj) | |
| 381 { | |
| 382 return OPAQUEP (obj) ? OPAQUE_DATA (XOPAQUE (obj)) : NULL; | |
| 383 } | |
| 384 | |
| 385 Lisp_Event *DEVENT (Lisp_Object obj); | |
| 386 Lisp_Event * | |
| 387 DEVENT (Lisp_Object obj) | |
| 388 { | |
| 389 return EVENTP (obj) ? XEVENT (obj) : NULL; | |
| 390 } | |
| 391 | |
| 392 Lisp_Cons *DCONS (Lisp_Object obj); | |
| 393 Lisp_Cons * | |
| 394 DCONS (Lisp_Object obj) | |
| 395 { | |
| 396 return CONSP (obj) ? XCONS (obj) : NULL; | |
| 397 } | |
| 398 | |
| 399 Lisp_Cons *DCONSCDR (Lisp_Object obj); | |
| 400 Lisp_Cons * | |
| 401 DCONSCDR (Lisp_Object obj) | |
| 402 { | |
| 403 return (CONSP (obj) && CONSP (XCDR (obj))) ? XCONS (XCDR (obj)) : 0; | |
| 404 } | |
| 405 | |
| 867 | 406 Ibyte *DSTRING (Lisp_Object obj); |
| 407 Ibyte * | |
| 442 | 408 DSTRING (Lisp_Object obj) |
| 409 { | |
| 410 return STRINGP (obj) ? XSTRING_DATA (obj) : NULL; | |
| 411 } | |
| 412 | |
| 413 Lisp_Vector *DVECTOR (Lisp_Object obj); | |
| 414 Lisp_Vector * | |
| 415 DVECTOR (Lisp_Object obj) | |
| 416 { | |
| 417 return VECTORP (obj) ? XVECTOR (obj) : NULL; | |
| 418 } | |
| 419 | |
| 420 Lisp_Symbol *DSYMBOL (Lisp_Object obj); | |
| 421 Lisp_Symbol * | |
| 422 DSYMBOL (Lisp_Object obj) | |
| 423 { | |
| 424 return SYMBOLP (obj) ? XSYMBOL (obj) : NULL; | |
| 425 } | |
| 426 | |
| 867 | 427 Ibyte *DSYMNAME (Lisp_Object obj); |
| 428 Ibyte * | |
| 442 | 429 DSYMNAME (Lisp_Object obj) |
| 430 { | |
| 793 | 431 return SYMBOLP (obj) ? XSTRING_DATA (XSYMBOL (obj)->name) : NULL; |
| 442 | 432 } |
| 433 | |
| 434 #endif /* DEBUG_XEMACS */ | |
| 435 | |
| 436 DEFUN ("mswindows-message-box", Fmswindows_message_box, 1, 3, 0, /* | |
| 437 Pop up an MS Windows message box. | |
| 438 MESSAGE is the string to display. Optional argument FLAG controls | |
| 439 what appears in the box and how it behaves; it is a symbol or list of | |
| 440 symbols, described below. Second optional argument TITLE controls the | |
| 441 title bar; if omitted, a standard title bar will be used, probably | |
| 442 displaying "XEmacs". | |
| 443 | |
| 444 Possible flags are | |
| 445 | |
| 446 | |
| 447 -- To specify the buttons in the message box: | |
| 448 | |
| 449 abortretryignore | |
| 450 The message box contains three push buttons: Abort, Retry, and Ignore. | |
| 451 ok | |
| 452 The message box contains one push button: OK. This is the default. | |
| 453 okcancel | |
| 454 The message box contains two push buttons: OK and Cancel. | |
| 455 retrycancel | |
| 456 The message box contains two push buttons: Retry and Cancel. | |
| 457 yesno | |
| 458 The message box contains two push buttons: Yes and No. | |
| 459 yesnocancel | |
| 460 The message box contains three push buttons: Yes, No, and Cancel. | |
| 461 | |
| 462 | |
| 463 -- To display an icon in the message box: | |
| 464 | |
| 465 iconexclamation, iconwarning | |
| 466 An exclamation-point icon appears in the message box. | |
| 467 iconinformation, iconasterisk | |
| 468 An icon consisting of a lowercase letter i in a circle appears in | |
| 469 the message box. | |
| 470 iconquestion | |
| 471 A question-mark icon appears in the message box. | |
| 472 iconstop, iconerror, iconhand | |
| 473 A stop-sign icon appears in the message box. | |
| 474 | |
| 475 | |
| 476 -- To indicate the default button: | |
| 477 | |
| 478 defbutton1 | |
| 479 The first button is the default button. This is the default. | |
| 480 defbutton2 | |
| 481 The second button is the default button. | |
| 482 defbutton3 | |
| 483 The third button is the default button. | |
| 484 defbutton4 | |
| 485 The fourth button is the default button. | |
| 486 | |
| 487 | |
| 488 -- To indicate the modality of the dialog box: | |
| 489 | |
| 490 applmodal | |
| 491 The user must respond to the message box before continuing work in | |
| 492 the window identified by the hWnd parameter. However, the user can | |
| 493 move to the windows of other applications and work in those windows. | |
| 494 Depending on the hierarchy of windows in the application, the user | |
| 495 may be able to move to other windows within the application. All | |
| 496 child windows of the parent of the message box are automatically | |
| 497 disabled, but popup windows are not. This is the default. | |
| 498 systemmodal | |
| 499 Same as applmodal except that the message box has the WS_EX_TOPMOST | |
| 500 style. Use system-modal message boxes to notify the user of serious, | |
| 501 potentially damaging errors that require immediate attention (for | |
| 502 example, running out of memory). This flag has no effect on the | |
| 503 user's ability to interact with windows other than those associated | |
| 504 with hWnd. | |
| 505 taskmodal | |
| 506 Same as applmodal except that all the top-level windows belonging to | |
| 507 the current task are disabled if the hWnd parameter is NULL. Use | |
| 508 this flag when the calling application or library does not have a | |
| 509 window handle available but still needs to prevent input to other | |
| 510 windows in the current application without suspending other | |
| 511 applications. | |
| 512 | |
| 513 | |
| 514 In addition, you can specify the following flags: | |
| 515 | |
| 516 default-desktop-only | |
| 517 The desktop currently receiving input must be a default desktop; | |
| 518 otherwise, the function fails. A default desktop is one an | |
| 519 application runs on after the user has logged on. | |
| 520 help | |
| 521 Adds a Help button to the message box. Choosing the Help button or | |
| 522 pressing F1 generates a Help event. | |
| 523 right | |
| 524 The text is right-justified. | |
| 525 rtlreading | |
| 526 Displays message and caption text using right-to-left reading order | |
| 527 on Hebrew and Arabic systems. | |
| 528 setforeground | |
| 529 The message box becomes the foreground window. Internally, Windows | |
| 530 calls the SetForegroundWindow function for the message box. | |
| 531 topmost | |
| 532 The message box is created with the WS_EX_TOPMOST window style. | |
| 533 service-notification | |
| 534 Windows NT only: The caller is a service notifying the user of an | |
| 535 event. The function displays a message box on the current active | |
| 536 desktop, even if there is no user logged on to the computer. If | |
| 537 this flag is set, the hWnd parameter must be NULL. This is so the | |
| 538 message box can appear on a desktop other than the desktop | |
| 539 corresponding to the hWnd. | |
| 540 | |
| 541 | |
| 542 | |
| 543 The return value is one of the following menu-item values returned by | |
| 544 the dialog box: | |
| 545 | |
| 546 abort | |
| 547 Abort button was selected. | |
| 548 cancel | |
| 549 Cancel button was selected. | |
| 550 ignore | |
| 551 Ignore button was selected. | |
| 552 no | |
| 553 No button was selected. | |
| 554 ok | |
| 555 OK button was selected. | |
| 556 retry | |
| 557 Retry button was selected. | |
| 558 yes | |
| 559 Yes button was selected. | |
| 560 | |
| 561 If a message box has a Cancel button, the function returns the | |
| 562 `cancel' value if either the ESC key is pressed or the Cancel button | |
| 563 is selected. If the message box has no Cancel button, pressing ESC has | |
| 564 no effect. */ | |
| 565 (message_, flags, title)) | |
| 566 { | |
| 567 Extbyte *msgout; | |
| 568 Extbyte *titleout = 0; | |
| 569 UINT sty = 0; | |
| 570 | |
| 571 if (!LISTP (flags)) | |
| 572 { | |
| 573 CHECK_SYMBOL (flags); | |
| 574 flags = list1 (flags); | |
| 575 } | |
| 576 | |
| 577 CHECK_STRING (message_); | |
|
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
2850
diff
changeset
|
578 msgout = LISP_STRING_TO_TSTR (message_); |
| 442 | 579 |
| 580 if (!NILP (title)) | |
| 581 { | |
| 582 CHECK_STRING (title); | |
|
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
2850
diff
changeset
|
583 titleout = LISP_STRING_TO_TSTR (title); |
| 442 | 584 } |
| 585 | |
| 2367 | 586 { |
| 587 EXTERNAL_LIST_LOOP_2 (st, flags) | |
| 588 { | |
| 589 CHECK_SYMBOL (st); | |
| 590 if (0) | |
| 591 ; | |
| 442 | 592 #define FROB(sym, val) else if (EQ (st, sym)) sty |= val |
| 2367 | 593 FROB (Qabortretryignore, MB_ABORTRETRYIGNORE); |
| 594 FROB (Qapplmodal, MB_APPLMODAL); | |
| 595 FROB (Qdefault_desktop_only, MB_DEFAULT_DESKTOP_ONLY); | |
| 596 FROB (Qdefbutton1, MB_DEFBUTTON1); | |
| 597 FROB (Qdefbutton2, MB_DEFBUTTON2); | |
| 598 FROB (Qdefbutton3, MB_DEFBUTTON3); | |
| 599 FROB (Qdefbutton4, MB_DEFBUTTON4); | |
| 600 FROB (Qhelp, MB_HELP); | |
| 601 FROB (Qiconasterisk, MB_ICONASTERISK); | |
| 602 FROB (Qiconexclamation, MB_ICONEXCLAMATION); | |
| 603 FROB (Qiconhand, MB_ICONHAND); | |
| 604 FROB (Qiconinformation, MB_ICONINFORMATION); | |
| 605 FROB (Qiconquestion, MB_ICONQUESTION); | |
| 606 FROB (Qiconstop, MB_ICONSTOP); | |
| 607 FROB (Qok, MB_OK); | |
| 608 FROB (Qokcancel, MB_OKCANCEL); | |
| 609 FROB (Qretrycancel, MB_RETRYCANCEL); | |
| 610 FROB (Qright, MB_RIGHT); | |
| 611 FROB (Qrtlreading, MB_RTLREADING); | |
| 612 FROB (Qservice_notification, MB_SERVICE_NOTIFICATION); | |
| 613 FROB (Qsetforeground, MB_SETFOREGROUND); | |
| 614 FROB (Qsystemmodal, MB_SYSTEMMODAL); | |
| 615 FROB (Qtaskmodal, MB_TASKMODAL); | |
| 616 FROB (Qtopmost, MB_TOPMOST); | |
| 617 FROB (Qyesno, MB_YESNO); | |
| 618 FROB (Qyesnocancel, MB_YESNOCANCEL); | |
| 442 | 619 #undef FROB |
| 620 | |
| 2367 | 621 else |
| 622 invalid_constant ("Unrecognized flag", st); | |
| 623 } | |
| 624 } | |
| 442 | 625 |
| 626 { | |
| 771 | 627 int retval = qxeMessageBox (NULL, msgout, titleout, sty); |
| 442 | 628 |
| 629 if (retval == 0) | |
| 563 | 630 out_of_memory ("When calling `mswindows-message-box'", Qunbound); |
| 442 | 631 |
| 632 #define FROB(sym, val) if (retval == val) return sym | |
| 633 FROB (Qabort, IDABORT); | |
| 634 FROB (Qcancel, IDCANCEL); | |
| 635 FROB (Qignore, IDIGNORE); | |
| 636 FROB (Qno, IDNO); | |
| 637 FROB (Qok, IDOK); | |
| 638 FROB (Qretry, IDRETRY); | |
| 639 FROB (Qyes, IDYES); | |
| 640 #undef FROB | |
| 641 | |
| 563 | 642 invalid_argument ("Unknown return value from MessageBox()", |
|
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
643 make_fixnum (retval)); |
| 442 | 644 } |
| 645 | |
| 646 return Qnil; | |
| 647 } | |
| 648 | |
| 649 static Lisp_Object | |
| 650 msprinter_canonicalize_console_connection (Lisp_Object connection, | |
| 578 | 651 Error_Behavior errb) |
| 442 | 652 { |
| 653 /* If nil connection is specified, transform it into the name | |
| 654 of the default printer */ | |
| 655 if (NILP (connection)) | |
| 656 { | |
| 657 connection = msprinter_default_printer (); | |
| 658 if (NILP (connection)) | |
| 659 { | |
| 660 if (ERRB_EQ (errb, ERROR_ME)) | |
| 563 | 661 invalid_state ("There is no default printer in the system", |
| 662 Qunbound); | |
| 442 | 663 else |
| 664 return Qunbound; | |
| 665 } | |
| 666 } | |
| 667 | |
| 668 CHECK_STRING (connection); | |
| 669 return connection; | |
| 670 } | |
| 671 | |
| 672 static Lisp_Object | |
| 673 msprinter_canonicalize_device_connection (Lisp_Object connection, | |
| 578 | 674 Error_Behavior errb) |
| 442 | 675 { |
| 676 return msprinter_canonicalize_console_connection (connection, errb); | |
| 677 } | |
| 678 | |
| 428 | 679 |
| 680 /************************************************************************/ | |
| 681 /* initialization */ | |
| 682 /************************************************************************/ | |
| 683 | |
| 684 void | |
| 685 syms_of_console_mswindows (void) | |
| 686 { | |
| 442 | 687 DEFSUBR (Fmswindows_debugging_output); |
| 688 | |
| 563 | 689 DEFSYMBOL (Qabortretryignore); |
| 690 DEFSYMBOL (Qapplmodal); | |
| 691 DEFSYMBOL (Qdefault_desktop_only); | |
| 692 DEFSYMBOL (Qdefbutton1); | |
| 693 DEFSYMBOL (Qdefbutton2); | |
| 694 DEFSYMBOL (Qdefbutton3); | |
| 695 DEFSYMBOL (Qdefbutton4); | |
| 696 /* DEFSYMBOL (Qhelp); */ | |
| 697 DEFSYMBOL (Qiconasterisk); | |
| 698 DEFSYMBOL (Qiconexclamation); | |
| 699 DEFSYMBOL (Qiconhand); | |
| 700 DEFSYMBOL (Qiconinformation); | |
| 701 DEFSYMBOL (Qiconquestion); | |
| 702 DEFSYMBOL (Qiconstop); | |
| 703 /* DEFSYMBOL (Qok); */ | |
| 704 DEFSYMBOL (Qokcancel); | |
| 705 DEFSYMBOL (Qretrycancel); | |
| 706 /* DEFSYMBOL (Qright); */ | |
| 707 DEFSYMBOL (Qrtlreading); | |
| 708 DEFSYMBOL (Qservice_notification); | |
| 709 DEFSYMBOL (Qsetforeground); | |
| 710 DEFSYMBOL (Qsystemmodal); | |
| 711 DEFSYMBOL (Qtaskmodal); | |
| 712 DEFSYMBOL (Qtopmost); | |
| 713 DEFSYMBOL (Qyesno); | |
| 714 DEFSYMBOL (Qyesnocancel); | |
| 442 | 715 |
| 563 | 716 /* DEFSYMBOL (Qabort); */ |
| 717 /* DEFSYMBOL (Qcancel); */ | |
| 718 /* DEFSYMBOL (Qignore); */ | |
| 719 /* DEFSYMBOL (Qno); */ | |
| 720 /* DEFSYMBOL (Qok); */ | |
| 721 /* DEFSYMBOL (Qretry); */ | |
| 722 /* DEFSYMBOL (Qyes); */ | |
| 442 | 723 |
| 724 DEFSUBR (Fmswindows_message_box); | |
| 428 | 725 } |
| 726 | |
| 727 void | |
| 728 console_type_create_mswindows (void) | |
| 729 { | |
| 730 INITIALIZE_CONSOLE_TYPE (mswindows, "mswindows", "console-mswindows-p"); | |
| 731 | |
| 732 /* console methods */ | |
| 733 /* CONSOLE_HAS_METHOD (mswindows, init_console); */ | |
| 734 /* CONSOLE_HAS_METHOD (mswindows, mark_console); */ | |
| 735 CONSOLE_HAS_METHOD (mswindows, initially_selected_for_input); | |
| 736 /* CONSOLE_HAS_METHOD (mswindows, delete_console); */ | |
| 440 | 737 CONSOLE_HAS_METHOD (mswindows, canonicalize_console_connection); |
| 738 CONSOLE_HAS_METHOD (mswindows, canonicalize_device_connection); | |
| 428 | 739 /* CONSOLE_HAS_METHOD (mswindows, semi_canonicalize_console_connection); */ |
| 740 /* CONSOLE_HAS_METHOD (mswindows, semi_canonicalize_device_connection); */ | |
| 2828 | 741 CONSOLE_HAS_METHOD (mswindows, perhaps_init_unseen_key_defaults); |
| 440 | 742 |
| 743 INITIALIZE_CONSOLE_TYPE (msprinter, "msprinter", "console-msprinter-p"); | |
| 442 | 744 CONSOLE_HAS_METHOD (msprinter, canonicalize_console_connection); |
| 745 CONSOLE_HAS_METHOD (msprinter, canonicalize_device_connection); | |
| 428 | 746 } |
| 747 | |
| 748 void | |
| 749 reinit_console_type_create_mswindows (void) | |
| 750 { | |
| 751 REINITIALIZE_CONSOLE_TYPE (mswindows); | |
| 440 | 752 REINITIALIZE_CONSOLE_TYPE (msprinter); |
| 428 | 753 } |
| 754 | |
| 755 void | |
| 756 vars_of_console_mswindows (void) | |
| 757 { | |
| 2850 | 758 DEFVAR_LISP ("mswindows-seen-characters", &Vmswindows_seen_characters /* |
| 759 Hash table of non-ASCII characters the MS Windows subsystem has seen. | |
| 760 */ ); | |
| 761 Vmswindows_seen_characters = Qnil; | |
| 428 | 762 Fprovide (Qmswindows); |
| 763 } |
