diff options
Diffstat (limited to 'src/mac.c')
| -rw-r--r-- | src/mac.c | 48 |
1 files changed, 30 insertions, 18 deletions
| @@ -24,6 +24,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 24 | 24 | ||
| 25 | #include <stdio.h> | 25 | #include <stdio.h> |
| 26 | #include <errno.h> | 26 | #include <errno.h> |
| 27 | #include <time.h> | ||
| 27 | #include <utime.h> | 28 | #include <utime.h> |
| 28 | #include <dirent.h> | 29 | #include <dirent.h> |
| 29 | #include <sys/types.h> | 30 | #include <sys/types.h> |
| @@ -46,6 +47,8 @@ Boston, MA 02111-1307, USA. */ | |||
| 46 | #undef realloc | 47 | #undef realloc |
| 47 | #undef init_process | 48 | #undef init_process |
| 48 | #include <Carbon/Carbon.h> | 49 | #include <Carbon/Carbon.h> |
| 50 | #undef mktime | ||
| 51 | #define mktime emacs_mktime | ||
| 49 | #undef free | 52 | #undef free |
| 50 | #define free unexec_free | 53 | #define free unexec_free |
| 51 | #undef malloc | 54 | #undef malloc |
| @@ -72,6 +75,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 72 | #include "process.h" | 75 | #include "process.h" |
| 73 | #include "sysselect.h" | 76 | #include "sysselect.h" |
| 74 | #include "systime.h" | 77 | #include "systime.h" |
| 78 | #include "blockinput.h" | ||
| 75 | 79 | ||
| 76 | Lisp_Object QCLIPBOARD; | 80 | Lisp_Object QCLIPBOARD; |
| 77 | 81 | ||
| @@ -2547,7 +2551,9 @@ component. */) | |||
| 2547 | 2551 | ||
| 2548 | CHECK_STRING (script); | 2552 | CHECK_STRING (script); |
| 2549 | 2553 | ||
| 2554 | BLOCK_INPUT; | ||
| 2550 | status = do_applescript (SDATA (script), &result); | 2555 | status = do_applescript (SDATA (script), &result); |
| 2556 | UNBLOCK_INPUT; | ||
| 2551 | if (status) | 2557 | if (status) |
| 2552 | { | 2558 | { |
| 2553 | if (!result) | 2559 | if (!result) |
| @@ -2617,26 +2623,23 @@ DEFUN ("mac-paste-function", Fmac_paste_function, Smac_paste_function, 0, 0, 0, | |||
| 2617 | () | 2623 | () |
| 2618 | { | 2624 | { |
| 2619 | #if TARGET_API_MAC_CARBON | 2625 | #if TARGET_API_MAC_CARBON |
| 2626 | OSStatus err; | ||
| 2620 | ScrapRef scrap; | 2627 | ScrapRef scrap; |
| 2621 | ScrapFlavorFlags sff; | 2628 | ScrapFlavorFlags sff; |
| 2622 | Size s; | 2629 | Size s; |
| 2623 | int i; | 2630 | int i; |
| 2624 | char *data; | 2631 | char *data; |
| 2625 | 2632 | ||
| 2626 | if (GetCurrentScrap (&scrap) != noErr) | 2633 | BLOCK_INPUT; |
| 2627 | return Qnil; | 2634 | err = GetCurrentScrap (&scrap); |
| 2628 | 2635 | if (err == noErr) | |
| 2629 | if (GetScrapFlavorFlags (scrap, kScrapFlavorTypeText, &sff) != noErr) | 2636 | err = GetScrapFlavorFlags (scrap, kScrapFlavorTypeText, &sff); |
| 2630 | return Qnil; | 2637 | if (err == noErr) |
| 2631 | 2638 | err = GetScrapFlavorSize (scrap, kScrapFlavorTypeText, &s); | |
| 2632 | if (GetScrapFlavorSize (scrap, kScrapFlavorTypeText, &s) != noErr) | 2639 | if (err == noErr && (data = (char*) alloca (s))) |
| 2633 | return Qnil; | 2640 | err = GetScrapFlavorData (scrap, kScrapFlavorTypeText, &s, data); |
| 2634 | 2641 | UNBLOCK_INPUT; | |
| 2635 | if ((data = (char*) alloca (s)) == NULL) | 2642 | if (err != noErr || s == 0) |
| 2636 | return Qnil; | ||
| 2637 | |||
| 2638 | if (GetScrapFlavorData (scrap, kScrapFlavorTypeText, &s, data) != noErr | ||
| 2639 | || s == 0) | ||
| 2640 | return Qnil; | 2643 | return Qnil; |
| 2641 | 2644 | ||
| 2642 | /* Emacs expects clipboard contents have Unix-style eol's */ | 2645 | /* Emacs expects clipboard contents have Unix-style eol's */ |
| @@ -2701,13 +2704,22 @@ DEFUN ("mac-cut-function", Fmac_cut_function, Smac_cut_function, 1, 2, 0, | |||
| 2701 | #if TARGET_API_MAC_CARBON | 2704 | #if TARGET_API_MAC_CARBON |
| 2702 | { | 2705 | { |
| 2703 | ScrapRef scrap; | 2706 | ScrapRef scrap; |
| 2707 | |||
| 2708 | BLOCK_INPUT; | ||
| 2704 | ClearCurrentScrap (); | 2709 | ClearCurrentScrap (); |
| 2705 | if (GetCurrentScrap (&scrap) != noErr) | 2710 | if (GetCurrentScrap (&scrap) != noErr) |
| 2706 | error ("cannot get current scrap"); | 2711 | { |
| 2712 | UNBLOCK_INPUT; | ||
| 2713 | error ("cannot get current scrap"); | ||
| 2714 | } | ||
| 2707 | 2715 | ||
| 2708 | if (PutScrapFlavor (scrap, kScrapFlavorTypeText, kScrapFlavorMaskNone, len, | 2716 | if (PutScrapFlavor (scrap, kScrapFlavorTypeText, kScrapFlavorMaskNone, len, |
| 2709 | buf) != noErr) | 2717 | buf) != noErr) |
| 2710 | error ("cannot put to scrap"); | 2718 | { |
| 2719 | UNBLOCK_INPUT; | ||
| 2720 | error ("cannot put to scrap"); | ||
| 2721 | } | ||
| 2722 | UNBLOCK_INPUT; | ||
| 2711 | } | 2723 | } |
| 2712 | #else /* not TARGET_API_MAC_CARBON */ | 2724 | #else /* not TARGET_API_MAC_CARBON */ |
| 2713 | ZeroScrap (); | 2725 | ZeroScrap (); |
| @@ -2742,9 +2754,11 @@ and t is the same as `SECONDARY'. */) | |||
| 2742 | ScrapRef scrap; | 2754 | ScrapRef scrap; |
| 2743 | ScrapFlavorFlags sff; | 2755 | ScrapFlavorFlags sff; |
| 2744 | 2756 | ||
| 2757 | BLOCK_INPUT; | ||
| 2745 | if (GetCurrentScrap (&scrap) == noErr) | 2758 | if (GetCurrentScrap (&scrap) == noErr) |
| 2746 | if (GetScrapFlavorFlags (scrap, kScrapFlavorTypeText, &sff) == noErr) | 2759 | if (GetScrapFlavorFlags (scrap, kScrapFlavorTypeText, &sff) == noErr) |
| 2747 | val = Qt; | 2760 | val = Qt; |
| 2761 | UNBLOCK_INPUT; | ||
| 2748 | #else /* not TARGET_API_MAC_CARBON */ | 2762 | #else /* not TARGET_API_MAC_CARBON */ |
| 2749 | Handle my_handle; | 2763 | Handle my_handle; |
| 2750 | long rc, scrap_offset; | 2764 | long rc, scrap_offset; |
| @@ -2769,8 +2783,6 @@ and t is the same as `SECONDARY'. */) | |||
| 2769 | extern int inhibit_window_system; | 2783 | extern int inhibit_window_system; |
| 2770 | extern int noninteractive; | 2784 | extern int noninteractive; |
| 2771 | 2785 | ||
| 2772 | #include "blockinput.h" | ||
| 2773 | |||
| 2774 | /* When Emacs is started from the Finder, SELECT always immediately | 2786 | /* When Emacs is started from the Finder, SELECT always immediately |
| 2775 | returns as if input is present when file descriptor 0 is polled for | 2787 | returns as if input is present when file descriptor 0 is polled for |
| 2776 | input. Strangely, when Emacs is run as a GUI application from the | 2788 | input. Strangely, when Emacs is run as a GUI application from the |