annotate src/os_macosx.m @ 31468:005dbf7d37de

Added tag v9.0.1066 for changeset 4abd8f9edf470f38fdf98f2e53a46dee94e61f87
author Bram Moolenaar <Bram@vim.org>
date Sat, 17 Dec 2022 11:45:06 +0100
parents 360f286b5869
children ca4e81de477a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 7860
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
11 * os_macosx.m -- Mac specific things for Mac OS X.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
13420
f80abb797a32 patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents: 12877
diff changeset
14 /* Suppress compiler warnings to non-C89 code. */
f80abb797a32 patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents: 12877
diff changeset
15 #if defined(__clang__) && defined(__STRICT_ANSI__)
f80abb797a32 patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents: 12877
diff changeset
16 # pragma clang diagnostic push
f80abb797a32 patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents: 12877
diff changeset
17 # pragma clang diagnostic ignored "-Wc99-extensions"
f80abb797a32 patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents: 12877
diff changeset
18 # pragma clang diagnostic push
f80abb797a32 patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents: 12877
diff changeset
19 # pragma clang diagnostic ignored "-Wdeclaration-after-statement"
f80abb797a32 patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents: 12877
diff changeset
20 #endif
f80abb797a32 patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents: 12877
diff changeset
21
2598
10ce04af8c5b updated for version 7.3.021
Bram Moolenaar <bram@vim.org>
parents: 2567
diff changeset
22 /* Avoid a conflict for the definition of Boolean between Mac header files and
10ce04af8c5b updated for version 7.3.021
Bram Moolenaar <bram@vim.org>
parents: 2567
diff changeset
23 * X11 header files. */
10ce04af8c5b updated for version 7.3.021
Bram Moolenaar <bram@vim.org>
parents: 2567
diff changeset
24 #define NO_X11_INCLUDES
10ce04af8c5b updated for version 7.3.021
Bram Moolenaar <bram@vim.org>
parents: 2567
diff changeset
25
29071
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
26 #include <stdbool.h>
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
27 #include <mach/boolean.h>
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
28 #include <sys/errno.h>
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
29 #include <stdlib.h>
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
30
29796
3f88a6d02354 patch 9.0.0237: Mac: cannot build if dispatch.h is not available
Bram Moolenaar <Bram@vim.org>
parents: 29228
diff changeset
31 #ifdef FEAT_RELTIME
29071
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
32 #include <dispatch/dispatch.h>
29796
3f88a6d02354 patch 9.0.0237: Mac: cannot build if dispatch.h is not available
Bram Moolenaar <Bram@vim.org>
parents: 29228
diff changeset
33 #endif
29071
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
34
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
35 #include "vim.h"
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
36 #import <AppKit/AppKit.h>
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
37
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
38
2565
4b7929dad28a Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents: 2315
diff changeset
39 /*
4b7929dad28a Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents: 2315
diff changeset
40 * Clipboard support for the console.
4b7929dad28a Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents: 2315
diff changeset
41 */
21785
c346db463a59 patch 8.2.1442: outdated references to the Mac Carbon GUI
Bram Moolenaar <Bram@vim.org>
parents: 21749
diff changeset
42 #if defined(FEAT_CLIPBOARD)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43
2315
2e6dbc2fccd4 Remove obsolete Mac code.
Bram Moolenaar <bram@vim.org>
parents: 2314
diff changeset
44 /* Used to identify clipboard data copied from Vim. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
2315
2e6dbc2fccd4 Remove obsolete Mac code.
Bram Moolenaar <bram@vim.org>
parents: 2314
diff changeset
46 NSString *VimPboardType = @"VimPboardType";
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
47
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
48 void
17067
d0438b4b0acf patch 8.1.1533: GUI build fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
49 clip_mch_lose_selection(Clipboard_T *cbd UNUSED)
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
50 {
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
51 }
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
52
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
53
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
54 int
17067
d0438b4b0acf patch 8.1.1533: GUI build fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
55 clip_mch_own_selection(Clipboard_T *cbd UNUSED)
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
56 {
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
57 /* This is called whenever there is a new selection and 'guioptions'
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
58 * contains the "a" flag (automatically copy selection). Return TRUE, else
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
59 * the "a" flag does nothing. Note that there is no concept of "ownership"
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
60 * of the clipboard in Mac OS X.
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
61 */
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
62 return TRUE;
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
63 }
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
64
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
65
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
66 void
17067
d0438b4b0acf patch 8.1.1533: GUI build fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
67 clip_mch_request_selection(Clipboard_T *cbd)
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
68 {
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
69 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
70
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
71 NSPasteboard *pb = [NSPasteboard generalPasteboard];
14911
73162bc0b21f patch 8.1.0467: cannot build with Mac OS X 10.5
Bram Moolenaar <Bram@vim.org>
parents: 14091
diff changeset
72 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
14091
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
73 NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
74 NSPasteboardTypeString, nil];
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
75 #else
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
76 NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
77 NSStringPboardType, nil];
14091
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
78 #endif
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
79 NSString *bestType = [pb availableTypeFromArray:supportedTypes];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
80 if (!bestType) goto releasepool;
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
81
2909
b65a26a2aa09 updated for version 7.3.227
Bram Moolenaar <bram@vim.org>
parents: 2891
diff changeset
82 int motion_type = MAUTO;
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
83 NSString *string = nil;
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
84
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
85 if ([bestType isEqual:VimPboardType])
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
86 {
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
87 /* This type should consist of an array with two objects:
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
88 * 1. motion type (NSNumber)
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
89 * 2. text (NSString)
14091
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
90 * If this is not the case we fall back on using NSPasteboardTypeString.
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
91 */
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
92 id plist = [pb propertyListForType:VimPboardType];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
93 if ([plist isKindOfClass:[NSArray class]] && [plist count] == 2)
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
94 {
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
95 id obj = [plist objectAtIndex:1];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
96 if ([obj isKindOfClass:[NSString class]])
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
97 {
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
98 motion_type = [[plist objectAtIndex:0] intValue];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
99 string = obj;
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
100 }
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
101 }
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
102 }
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
103
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
104 if (!string)
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
105 {
14091
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
106 /* Use NSPasteboardTypeString. The motion type is detected automatically.
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
107 */
14911
73162bc0b21f patch 8.1.0467: cannot build with Mac OS X 10.5
Bram Moolenaar <Bram@vim.org>
parents: 14091
diff changeset
108 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
14091
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
109 NSMutableString *mstring =
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
110 [[pb stringForType:NSPasteboardTypeString] mutableCopy];
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
111 #else
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
112 NSMutableString *mstring =
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
113 [[pb stringForType:NSStringPboardType] mutableCopy];
14091
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
114 #endif
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
115 if (!mstring) goto releasepool;
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
116
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
117 /* Replace unrecognized end-of-line sequences with \x0a (line feed). */
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
118 NSRange range = { 0, [mstring length] };
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
119 unsigned n = [mstring replaceOccurrencesOfString:@"\x0d\x0a"
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
120 withString:@"\x0a" options:0
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
121 range:range];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
122 if (0 == n)
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
123 {
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
124 n = [mstring replaceOccurrencesOfString:@"\x0d" withString:@"\x0a"
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
125 options:0 range:range];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
126 }
2310
3e4574a4b627 Fix a few compiler warnings.
Bram Moolenaar <bram@vim.org>
parents: 2309
diff changeset
127
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
128 string = mstring;
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
129 }
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
130
2909
b65a26a2aa09 updated for version 7.3.227
Bram Moolenaar <bram@vim.org>
parents: 2891
diff changeset
131 /* Default to MAUTO, uses MCHAR or MLINE depending on trailing NL. */
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
132 if (!(MCHAR == motion_type || MLINE == motion_type || MBLOCK == motion_type
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
133 || MAUTO == motion_type))
2909
b65a26a2aa09 updated for version 7.3.227
Bram Moolenaar <bram@vim.org>
parents: 2891
diff changeset
134 motion_type = MAUTO;
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
135
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
136 char_u *str = (char_u*)[string UTF8String];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
137 int len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
138
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
139 if (input_conv.vc_type != CONV_NONE)
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
140 str = string_convert(&input_conv, str, &len);
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
141
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
142 if (str)
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
143 clip_yank_selection(motion_type, str, len, cbd);
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
144
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
145 if (input_conv.vc_type != CONV_NONE)
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
146 vim_free(str);
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
147
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
148 releasepool:
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
149 [pool release];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
150 }
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
151
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
152
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
153 /*
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
154 * Send the current selection to the clipboard.
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
155 */
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
156 void
17067
d0438b4b0acf patch 8.1.1533: GUI build fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
157 clip_mch_set_selection(Clipboard_T *cbd)
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
158 {
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
159 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
160
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
161 /* If the '*' register isn't already filled in, fill it in now. */
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
162 cbd->owned = TRUE;
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
163 clip_get_selection(cbd);
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
164 cbd->owned = FALSE;
2310
3e4574a4b627 Fix a few compiler warnings.
Bram Moolenaar <bram@vim.org>
parents: 2309
diff changeset
165
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
166 /* Get the text to put on the pasteboard. */
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
167 long_u llen = 0; char_u *str = 0;
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
168 int motion_type = clip_convert_selection(&str, &llen, cbd);
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
169 if (motion_type < 0)
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
170 goto releasepool;
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
171
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
172 /* TODO: Avoid overflow. */
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
173 int len = (int)llen;
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
174 if (output_conv.vc_type != CONV_NONE)
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
175 {
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
176 char_u *conv_str = string_convert(&output_conv, str, &len);
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
177 if (conv_str)
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
178 {
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
179 vim_free(str);
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
180 str = conv_str;
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
181 }
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
182 }
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
183
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
184 if (len > 0)
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
185 {
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
186 NSString *string = [[NSString alloc]
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
187 initWithBytes:str length:len encoding:NSUTF8StringEncoding];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
188
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
189 /* See clip_mch_request_selection() for info on pasteboard types. */
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
190 NSPasteboard *pb = [NSPasteboard generalPasteboard];
14911
73162bc0b21f patch 8.1.0467: cannot build with Mac OS X 10.5
Bram Moolenaar <Bram@vim.org>
parents: 14091
diff changeset
191 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
14091
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
192 NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
193 NSPasteboardTypeString, nil];
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
194 #else
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
195 NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType,
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
196 NSStringPboardType, nil];
14091
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
197 #endif
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
198 [pb declareTypes:supportedTypes owner:nil];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
199
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
200 NSNumber *motion = [NSNumber numberWithInt:motion_type];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
201 NSArray *plist = [NSArray arrayWithObjects:motion, string, nil];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
202 [pb setPropertyList:plist forType:VimPboardType];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
203
14911
73162bc0b21f patch 8.1.0467: cannot build with Mac OS X 10.5
Bram Moolenaar <Bram@vim.org>
parents: 14091
diff changeset
204 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
14091
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
205 [pb setString:string forType:NSPasteboardTypeString];
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
206 #else
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
207 [pb setString:string forType:NSStringPboardType];
14091
616dc84228b7 patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents: 13420
diff changeset
208 #endif
2310
3e4574a4b627 Fix a few compiler warnings.
Bram Moolenaar <bram@vim.org>
parents: 2309
diff changeset
209
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
210 [string release];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
211 }
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
212
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
213 vim_free(str);
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
214 releasepool:
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
215 [pool release];
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
216 }
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
217
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
218 #endif /* FEAT_CLIPBOARD */
13420
f80abb797a32 patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents: 12877
diff changeset
219
29071
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
220 #ifdef FEAT_RELTIME
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
221 /*
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
222 * The following timer code is based on a Gist by Jorgen Lundman:
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
223 *
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
224 * https://gist.github.com/lundman
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
225 */
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
226
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
227 typedef struct macos_timer macos_timer_T;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
228
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
229 static void
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
230 _timer_cancel(void *arg UNUSED)
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
231 {
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
232 // This is not currently used, but it might be useful in the future and
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
233 // it is non-trivial enough to provide as usable implementation.
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
234 # if 0
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
235 macos_timer_T *timerid = (macos_timer_T *)arg;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
236
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
237 dispatch_release(timerid->tim_timer);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
238 dispatch_release(timerid->tim_queue);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
239 timerid->tim_timer = NULL;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
240 timerid->tim_queue = NULL;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
241 free(timerid);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
242 # endif
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
243 }
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
244
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
245 static void
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
246 _timer_handler(void *arg)
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
247 {
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
248 macos_timer_T *timerid = (macos_timer_T *)arg;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
249 union sigval sv;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
250
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
251 sv.sival_ptr = timerid->tim_arg;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
252
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
253 if (timerid->tim_func != NULL)
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
254 timerid->tim_func(sv);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
255 }
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
256
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
257 static uint64_t
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
258 itime_to_ns(const struct timespec *it)
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
259 {
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
260 time_t sec = it->tv_sec;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
261 long nsec = it->tv_nsec;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
262 uint64_t ns = NSEC_PER_SEC * sec + nsec;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
263
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
264 return ns == 0 ? DISPATCH_TIME_FOREVER : ns;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
265 }
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
266
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
267 /*
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
268 * A partial emulation of the POSIX timer_create function.
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
269 *
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
270 * The limitations and differences include:
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
271 *
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
272 * - Only CLOCK_REALTIME and CLOCK_MONOTONIC are supported as clockid
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
273 * values.
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
274 * - Even if CLOCK_REALTIME is specified, internally the mach_absolute_time
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
275 * source is used internally.
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
276 * - The only notification method supported is SIGEV_THREAD.
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
277 */
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
278 inline int
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
279 timer_create(clockid_t clockid, struct sigevent *sevp, timer_t *timerid)
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
280 {
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
281 macos_timer_T *timer = NULL;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
282
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
283 // We only support real time and monotonic clocks; and SIGEV_THREAD
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
284 // notification. In practice, there is no difference between the two
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
285 // types of clocks on MacOS - we always use the mach_machine_time
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
286 // source.
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
287 if ( (clockid != CLOCK_REALTIME && clockid != CLOCK_MONOTONIC)
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
288 || sevp->sigev_notify != SIGEV_THREAD)
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
289 {
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
290 semsg("clockid: %d %d", clockid, CLOCK_REALTIME);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
291 semsg("notify: %d %d", sevp->sigev_notify, SIGEV_THREAD);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
292 errno = ENOTSUP;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
293 return -1;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
294 }
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
295
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
296 timer = (macos_timer_T *)malloc(sizeof(macos_timer_T));
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
297 if (timer == NULL)
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
298 {
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
299 errno = ENOMEM;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
300 return -1;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
301 }
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
302 *timerid = timer;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
303
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
304 timer->tim_queue = dispatch_queue_create(
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
305 "org.vim.timerqueue", NULL);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
306 if (timer->tim_queue == NULL)
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
307 {
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
308 errno = ENOMEM;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
309 return -1;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
310 }
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
311
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
312 timer->tim_timer = dispatch_source_create(
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
313 DISPATCH_SOURCE_TYPE_TIMER, 0, 0, timer->tim_queue);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
314 if (timer->tim_timer == NULL)
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
315 {
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
316 errno = ENOMEM;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
317 return -1;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
318 }
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
319
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
320 timer->tim_func = sevp->sigev_notify_function;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
321 timer->tim_arg = sevp->sigev_value.sival_ptr;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
322
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
323 dispatch_set_context(timer->tim_timer, timer);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
324 dispatch_source_set_event_handler_f(timer->tim_timer, _timer_handler);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
325 dispatch_source_set_cancel_handler_f(timer->tim_timer, _timer_cancel);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
326
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
327 dispatch_resume(timer->tim_timer);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
328
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
329 return 0;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
330 }
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
331
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
332 /*
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
333 * A partial emulation of the POSIX timer_settime function.
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
334 *
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
335 * The limitations and differences include:
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
336 *
30986
360f286b5869 patch 9.0.0828: various typos
Bram Moolenaar <Bram@vim.org>
parents: 30719
diff changeset
337 * - The flags argument is ignored. The supplied new_value is therefore
29071
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
338 * always treated as a relative time.
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
339 * - The old_value argument is ignored.
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
340 */
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
341 int
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
342 timer_settime(
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
343 timer_t timerid,
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
344 int unused_flags UNUSED,
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
345 const struct itimerspec *new_value,
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
346 struct itimerspec *old_value UNUSED)
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
347 {
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
348 uint64_t first_shot = itime_to_ns(&new_value->it_value);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
349
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
350 if (timerid == NULL)
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
351 return 0;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
352
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
353 if (first_shot == DISPATCH_TIME_FOREVER)
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
354 {
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
355 dispatch_source_set_timer(
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
356 timerid->tim_timer, first_shot, first_shot, 0);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
357 }
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
358 else
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
359 {
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
360 uint64_t interval = itime_to_ns(&new_value->it_interval);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
361
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
362 dispatch_time_t start = dispatch_time(DISPATCH_TIME_NOW, first_shot);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
363 dispatch_source_set_timer(timerid->tim_timer, start, interval, 0);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
364 }
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
365
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
366 return 0;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
367 }
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
368
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
369 /*
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
370 * An emulation of the POSIX timer_delete function.
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
371 *
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
372 * Disabled because it is not currently used, but an implemented provided
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
373 * for completeness and possible future use.
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
374 */
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
375 int
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
376 timer_delete(timer_t timerid)
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
377 {
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
378 /* Calls _timer_cancel() */
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
379 if (timerid != NULL)
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
380 dispatch_source_cancel(timerid->tim_timer);
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
381
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
382 return 0;
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
383 }
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
384
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
385 #endif /* FEAT_RELTIME */
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 21785
diff changeset
386
30719
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
387 #ifdef FEAT_SOUND
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
388
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
389 static NSMutableDictionary<NSNumber*, NSSound*> *sounds_list = nil;
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
390
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
391 /// A delegate for handling when a sound has stopped playing, in
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
392 /// order to clean up the sound and to send a callback.
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
393 @interface SoundDelegate : NSObject<NSSoundDelegate>;
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
394
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
395 - (id) init:(long) sound_id callback:(soundcb_T*) callback;
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
396 - (void) sound:(NSSound *)sound didFinishPlaying:(BOOL)flag;
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
397
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
398 @property (readonly) long sound_id;
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
399 @property (readonly) soundcb_T *callback;
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
400
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
401 @end
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
402
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
403 @implementation SoundDelegate
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
404 - (id) init:(long) sound_id callback:(soundcb_T*) callback
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
405 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
406 if ([super init])
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
407 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
408 _sound_id = sound_id;
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
409 _callback = callback;
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
410 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
411 return self;
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
412 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
413
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
414 - (void) sound:(NSSound *)sound didFinishPlaying:(BOOL)flag
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
415 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
416 if (sounds_list != nil)
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
417 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
418 if (_callback)
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
419 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
420 call_sound_callback(_callback, _sound_id, flag ? 0 : 1);
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
421 delete_sound_callback(_callback);
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
422 _callback = NULL;
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
423 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
424 [sounds_list removeObjectForKey:[NSNumber numberWithLong:_sound_id]];
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
425 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
426 // Release itself. Do that here instead of earlier because NSSound only
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
427 // holds weak reference to this object.
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
428 [self release];
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
429 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
430 @end
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
431
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
432 void
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
433 process_cfrunloop()
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
434 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
435 if (sounds_list != nil && [sounds_list count] > 0)
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
436 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
437 // Continually drain the run loop of events. Currently, this
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
438 // is only used for processing sound callbacks, because
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
439 // NSSound relies of this runloop to call back to the
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
440 // delegate.
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
441 @autoreleasepool
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
442 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
443 while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true)
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
444 == kCFRunLoopRunHandledSource)
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
445 ; // do nothing
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
446 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
447 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
448 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
449
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
450 bool
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
451 sound_mch_play(const char_u* sound_name, long sound_id, soundcb_T *callback, bool playfile)
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
452 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
453 @autoreleasepool
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
454 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
455 NSString *sound_name_ns = [[[NSString alloc] initWithUTF8String:(const char*)sound_name] autorelease];
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
456 NSSound* sound = playfile ?
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
457 [[[NSSound alloc] initWithContentsOfFile:sound_name_ns byReference:YES] autorelease] :
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
458 [NSSound soundNamed:sound_name_ns];
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
459 if (!sound)
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
460 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
461 return false;
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
462 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
463
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
464 if (sounds_list == nil)
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
465 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
466 sounds_list = [[NSMutableDictionary<NSNumber*, NSSound*> alloc] init];
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
467 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
468 sounds_list[[NSNumber numberWithLong:sound_id]] = sound;
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
469
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
470 // Make a delegate to handle when the sound stops. No need to call
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
471 // autorelease because NSSound only holds a weak reference to it.
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
472 SoundDelegate *delegate = [[SoundDelegate alloc] init:sound_id callback:callback];
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
473
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
474 [sound setDelegate:delegate];
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
475 [sound play];
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
476 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
477 return true;
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
478 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
479
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
480 void
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
481 sound_mch_stop(long sound_id)
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
482 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
483 @autoreleasepool
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
484 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
485 NSSound *sound = sounds_list[[NSNumber numberWithLong:sound_id]];
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
486 if (sound != nil)
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
487 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
488 // Stop the sound. No need to release it because the delegate will do
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
489 // it for us.
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
490 [sound stop];
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
491 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
492 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
493 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
494
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
495 void
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
496 sound_mch_clear()
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
497 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
498 if (sounds_list != nil)
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
499 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
500 @autoreleasepool
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
501 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
502 for (NSSound *sound in [sounds_list allValues])
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
503 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
504 [sound stop];
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
505 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
506 [sounds_list release];
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
507 sounds_list = nil;
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
508 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
509 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
510 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
511
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
512 void
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
513 sound_mch_free()
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
514 {
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
515 sound_mch_clear();
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
516 }
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
517
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
518 #endif // FEAT_SOUND
71137f73c94d patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents: 29796
diff changeset
519
13420
f80abb797a32 patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents: 12877
diff changeset
520 /* Lift the compiler warning suppression. */
f80abb797a32 patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents: 12877
diff changeset
521 #if defined(__clang__) && defined(__STRICT_ANSI__)
f80abb797a32 patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents: 12877
diff changeset
522 # pragma clang diagnostic pop
f80abb797a32 patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents: 12877
diff changeset
523 # pragma clang diagnostic pop
f80abb797a32 patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents: 12877
diff changeset
524 #endif