comparison src/console-msw.c @ 563:183866b06e0b

[xemacs-hg @ 2001-05-24 07:50:48 by ben] Makefile.in.in, abbrev.c, alloc.c, buffer.c, bytecode.c, callint.c, callproc.c, casetab.c, chartab.c, cmdloop.c, cmds.c, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console.c, data.c, database.c, debug.c, device-gtk.c, device-msw.c, device-tty.c, device-x.c, device.c, dialog-gtk.c, dialog-msw.c, dialog-x.c, dialog.c, dired-msw.c, dired.c, doc.c, doprnt.c, dragdrop.c, editfns.c, eldap.c, eldap.h, elhash.c, emacs-widget-accessors.c, emacs.c, emodules.c, esd.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, filelock.c, floatfns.c, fns.c, font-lock.c, frame-gtk.c, frame-x.c, frame.c, general-slots.h, glade.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-gtk.c, gui-x.c, gui.c, gutter.c, hpplay.c, indent.c, input-method-xlib.c, insdel.c, intl.c, keymap.c, libsst.c, libsst.h, linuxplay.c, lisp.h, lread.c, lstream.c, lstream.h, macros.c, marker.c, md5.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, miscplay.c, miscplay.h, mule-ccl.c, mule-charset.c, mule-wnnfns.c, mule.c, nas.c, ntplay.c, ntproc.c, objects-gtk.c, objects-msw.c, objects-x.c, objects.c, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, ralloc.c, rangetab.c, redisplay.c, scrollbar.c, search.c, select-gtk.c, select-x.c, select.c, sgiplay.c, sheap.c, sound.c, specifier.c, sunplay.c, symbols.c, symeval.h, symsinit.h, syntax.c, sysdep.c, toolbar-msw.c, toolbar.c, tooltalk.c, ui-byhand.c, ui-gtk.c, undo.c, unexaix.c, unexapollo.c, unexconvex.c, unexec.c, widget.c, win32.c, window.c: -- defsymbol -> DEFSYMBOL. -- add an error type to all errors. -- eliminate the error functions in eval.c that let you just use Qerror as the type. -- redo the error API to be more consistent, sensibly named, and easier to use. -- redo the error hierarchy somewhat. create new errors: structure-formation-error, gui-error, invalid-constant, stack-overflow, out-of-memory, process-error, network-error, sound-error, printing-unreadable-object, base64-conversion- error; coding-system-error renamed to text-conversion error; some others. -- fix Mule problems in error strings in emodules.c, tooltalk.c. -- fix error handling in mswin open-network-stream. -- Mule-ize all sound files and clean up the headers. -- nativesound.h -> sound.h and used for all sound files. -- move some shared stuff into glyphs-shared.c: first attempt at eliminating some of the massive GTK code duplication. xemacs.mak: add glyphs-shared.c. xemacs-faq.texi: document how to debug X errors subr.el: fix doc string to reflect reality
author ben
date Thu, 24 May 2001 07:51:33 +0000
parents abe6d1db359e
children 190b164ddcac
comparison
equal deleted inserted replaced
562:c775bd016b32 563:183866b06e0b
1 /* Console functions for mswindows. 1 /* Console functions for mswindows.
2 Copyright (C) 1996, 2000 Ben Wing. 2 Copyright (C) 1996, 2000, 2001 Ben Wing.
3 3
4 This file is part of XEmacs. 4 This file is part of XEmacs.
5 5
6 XEmacs is free software; you can redistribute it and/or modify it 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 7 under the terms of the GNU General Public License as published by the
154 requiring that CONNECTION is nil, the only allowed connection in 154 requiring that CONNECTION is nil, the only allowed connection in
155 Windows. */ 155 Windows. */
156 if (!NILP (connection)) 156 if (!NILP (connection))
157 { 157 {
158 if (ERRB_EQ (errb, ERROR_ME)) 158 if (ERRB_EQ (errb, ERROR_ME))
159 signal_simple_error 159 invalid_argument
160 ("Invalid (non-nil) connection for mswindows device/console", 160 ("Invalid (non-nil) connection for mswindows device/console",
161 connection); 161 connection);
162 else 162 else
163 return Qunbound; 163 return Qunbound;
164 } 164 }
528 FROB (Qyesno, MB_YESNO); 528 FROB (Qyesno, MB_YESNO);
529 FROB (Qyesnocancel, MB_YESNOCANCEL); 529 FROB (Qyesnocancel, MB_YESNOCANCEL);
530 #undef FROB 530 #undef FROB
531 531
532 else 532 else
533 signal_simple_error ("Unrecognized flag", st); 533 invalid_constant ("Unrecognized flag", st);
534 } 534 }
535 535
536 { 536 {
537 int retval = MessageBox (NULL, msgout, titleout, sty); 537 int retval = MessageBox (NULL, msgout, titleout, sty);
538 538
539 if (retval == 0) 539 if (retval == 0)
540 error ("Out of memory when calling `mswindows-message-box'"); 540 out_of_memory ("When calling `mswindows-message-box'", Qunbound);
541 541
542 #define FROB(sym, val) if (retval == val) return sym 542 #define FROB(sym, val) if (retval == val) return sym
543 FROB (Qabort, IDABORT); 543 FROB (Qabort, IDABORT);
544 FROB (Qcancel, IDCANCEL); 544 FROB (Qcancel, IDCANCEL);
545 FROB (Qignore, IDIGNORE); 545 FROB (Qignore, IDIGNORE);
547 FROB (Qok, IDOK); 547 FROB (Qok, IDOK);
548 FROB (Qretry, IDRETRY); 548 FROB (Qretry, IDRETRY);
549 FROB (Qyes, IDYES); 549 FROB (Qyes, IDYES);
550 #undef FROB 550 #undef FROB
551 551
552 signal_simple_error ("Unknown return value from MessageBox()", 552 invalid_argument ("Unknown return value from MessageBox()",
553 make_int (retval)); 553 make_int (retval));
554 } 554 }
555 555
556 return Qnil; 556 return Qnil;
557 } 557 }
558 558
559 void 559 Lisp_Object
560 mswindows_output_last_error (char *frob) 560 mswindows_lisp_error (int errnum)
561 { 561 {
562 LPVOID lpMsgBuf; 562 LPTSTR lpMsgBuf;
563 int errval = GetLastError(); 563 Lisp_Object result;
564 Bufbyte *inres;
565 Bytecount len;
564 566
565 FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER 567 FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER
566 | FORMAT_MESSAGE_FROM_SYSTEM, 568 | FORMAT_MESSAGE_FROM_SYSTEM,
567 NULL, errval, 569 NULL, errnum,
570 /* !!#### not Mule-correct */
568 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), 571 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
572 /* yeah, i'm casting a char ** to a char *. ya gotta
573 problem widdat? */
569 (LPTSTR) &lpMsgBuf, 574 (LPTSTR) &lpMsgBuf,
570 0, 575 0,
571 NULL); 576 NULL);
577
578 TO_INTERNAL_FORMAT (C_STRING, lpMsgBuf, ALLOCA, (inres, len),
579 Qmswindows_tstr);
580 /* Messages tend to end with a period and newline */
581 if (len >= 3 && !strcmp (inres + len - 3, ".\r\n"))
582 len -= 3;
583 result = make_string (inres, len);
584
585 LocalFree (lpMsgBuf);
586 return result;
587 }
588
589 void
590 mswindows_output_last_error (char *frob)
591 {
592 int errval = GetLastError ();
593 Lisp_Object errmess = mswindows_lisp_error (errval);
594
572 stderr_out ("last error during %s is %d: %s\n", 595 stderr_out ("last error during %s is %d: %s\n",
573 frob, errval, (char*)lpMsgBuf); 596 frob, errval, XSTRING_DATA (errmess));
574 } 597 }
575 598
576 static Lisp_Object 599 static Lisp_Object
577 msprinter_canonicalize_console_connection (Lisp_Object connection, 600 msprinter_canonicalize_console_connection (Lisp_Object connection,
578 Error_behavior errb) 601 Error_behavior errb)
583 { 606 {
584 connection = msprinter_default_printer (); 607 connection = msprinter_default_printer ();
585 if (NILP (connection)) 608 if (NILP (connection))
586 { 609 {
587 if (ERRB_EQ (errb, ERROR_ME)) 610 if (ERRB_EQ (errb, ERROR_ME))
588 error ("There is no default printer in the system"); 611 invalid_state ("There is no default printer in the system",
612 Qunbound);
589 else 613 else
590 return Qunbound; 614 return Qunbound;
591 } 615 }
592 } 616 }
593 617
610 void 634 void
611 syms_of_console_mswindows (void) 635 syms_of_console_mswindows (void)
612 { 636 {
613 DEFSUBR (Fmswindows_debugging_output); 637 DEFSUBR (Fmswindows_debugging_output);
614 638
615 defsymbol (&Qabortretryignore, "abortretryignore"); 639 DEFSYMBOL (Qabortretryignore);
616 defsymbol (&Qapplmodal, "applmodal"); 640 DEFSYMBOL (Qapplmodal);
617 defsymbol (&Qdefault_desktop_only, "default-desktop-only"); 641 DEFSYMBOL (Qdefault_desktop_only);
618 defsymbol (&Qdefbutton1, "defbutton1"); 642 DEFSYMBOL (Qdefbutton1);
619 defsymbol (&Qdefbutton2, "defbutton2"); 643 DEFSYMBOL (Qdefbutton2);
620 defsymbol (&Qdefbutton3, "defbutton3"); 644 DEFSYMBOL (Qdefbutton3);
621 defsymbol (&Qdefbutton4, "defbutton4"); 645 DEFSYMBOL (Qdefbutton4);
622 /* defsymbol (&Qhelp, "help"); */ 646 /* DEFSYMBOL (Qhelp); */
623 defsymbol (&Qiconasterisk, "iconasterisk"); 647 DEFSYMBOL (Qiconasterisk);
624 defsymbol (&Qiconexclamation, "iconexclamation"); 648 DEFSYMBOL (Qiconexclamation);
625 defsymbol (&Qiconhand, "iconhand"); 649 DEFSYMBOL (Qiconhand);
626 defsymbol (&Qiconinformation, "iconinformation"); 650 DEFSYMBOL (Qiconinformation);
627 defsymbol (&Qiconquestion, "iconquestion"); 651 DEFSYMBOL (Qiconquestion);
628 defsymbol (&Qiconstop, "iconstop"); 652 DEFSYMBOL (Qiconstop);
629 /* defsymbol (&Qok, "ok"); */ 653 /* DEFSYMBOL (Qok); */
630 defsymbol (&Qokcancel, "okcancel"); 654 DEFSYMBOL (Qokcancel);
631 defsymbol (&Qretrycancel, "retrycancel"); 655 DEFSYMBOL (Qretrycancel);
632 /* defsymbol (&Qright, "right"); */ 656 /* DEFSYMBOL (Qright); */
633 defsymbol (&Qrtlreading, "rtlreading"); 657 DEFSYMBOL (Qrtlreading);
634 defsymbol (&Qservice_notification, "service-notification"); 658 DEFSYMBOL (Qservice_notification);
635 defsymbol (&Qsetforeground, "setforeground"); 659 DEFSYMBOL (Qsetforeground);
636 defsymbol (&Qsystemmodal, "systemmodal"); 660 DEFSYMBOL (Qsystemmodal);
637 defsymbol (&Qtaskmodal, "taskmodal"); 661 DEFSYMBOL (Qtaskmodal);
638 defsymbol (&Qtopmost, "topmost"); 662 DEFSYMBOL (Qtopmost);
639 defsymbol (&Qyesno, "yesno"); 663 DEFSYMBOL (Qyesno);
640 defsymbol (&Qyesnocancel, "yesnocancel"); 664 DEFSYMBOL (Qyesnocancel);
641 665
642 /* defsymbol (&Qabort, "abort"); */ 666 /* DEFSYMBOL (Qabort); */
643 /* defsymbol (&Qcancel, "cancel"); */ 667 /* DEFSYMBOL (Qcancel); */
644 /* defsymbol (&Qignore, "ignore"); */ 668 /* DEFSYMBOL (Qignore); */
645 /* defsymbol (&Qno, "no"); */ 669 /* DEFSYMBOL (Qno); */
646 /* defsymbol (&Qok, "ok"); */ 670 /* DEFSYMBOL (Qok); */
647 /* defsymbol (&Qretry, "retry"); */ 671 /* DEFSYMBOL (Qretry); */
648 /* defsymbol (&Qyes, "yes"); */ 672 /* DEFSYMBOL (Qyes); */
649 673
650 DEFSUBR (Fmswindows_message_box); 674 DEFSUBR (Fmswindows_message_box);
651 } 675 }
652 676
653 void 677 void