Mercurial > vim
annotate src/os_macosx.m @ 19817:a6a2d6bfc30f
Correct list of patch numbers
Commit: https://github.com/vim/vim/commit/495282b6e7e418d072a8ab53c9056b269dc308b7
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Mar 27 20:59:54 2020 +0100
Correct list of patch numbers
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 27 Mar 2020 21:15:04 +0100 |
parents | d0438b4b0acf |
children | e86237409bd2 |
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 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
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 | 12 */ |
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 | 22 /* Avoid a conflict for the definition of Boolean between Mac header files and |
23 * X11 header files. */ | |
24 #define NO_X11_INCLUDES | |
25 | |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
26 #include "vim.h" |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
27 #import <AppKit/AppKit.h> |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
28 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
29 |
2565
4b7929dad28a
Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents:
2315
diff
changeset
|
30 /* |
4b7929dad28a
Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents:
2315
diff
changeset
|
31 * Clipboard support for the console. |
4b7929dad28a
Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents:
2315
diff
changeset
|
32 * Don't include this when building the GUI version, the functions in |
2567
6931da037310
Do include Mac clipboard code for MacVim.
Bram Moolenaar <bram@vim.org>
parents:
2565
diff
changeset
|
33 * gui_mac.c are used then. TODO: remove those instead? |
2891 | 34 * But for MacVim we do need these ones. |
2565
4b7929dad28a
Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents:
2315
diff
changeset
|
35 */ |
2891 | 36 #if defined(FEAT_CLIPBOARD) && (!defined(FEAT_GUI_ENABLED) || defined(FEAT_GUI_MACVIM)) |
7 | 37 |
2315 | 38 /* Used to identify clipboard data copied from Vim. */ |
7 | 39 |
2315 | 40 NSString *VimPboardType = @"VimPboardType"; |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
41 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
42 void |
17067
d0438b4b0acf
patch 8.1.1533: GUI build fails on Mac
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
43 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
|
44 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
45 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
46 |
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 int |
17067
d0438b4b0acf
patch 8.1.1533: GUI build fails on Mac
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
49 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
|
50 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
51 /* 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
|
52 * 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
|
53 * 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
|
54 * 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
|
55 */ |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
56 return TRUE; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
57 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
58 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
59 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
60 void |
17067
d0438b4b0acf
patch 8.1.1533: GUI build fails on Mac
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
61 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
|
62 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
63 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
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 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
|
66 #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
|
67 NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType, |
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
68 NSPasteboardTypeString, nil]; |
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
69 #else |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
70 NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType, |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
71 NSStringPboardType, nil]; |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
72 #endif |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
73 NSString *bestType = [pb availableTypeFromArray:supportedTypes]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
74 if (!bestType) goto releasepool; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
75 |
2909 | 76 int motion_type = MAUTO; |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
77 NSString *string = nil; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
78 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
79 if ([bestType isEqual:VimPboardType]) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
80 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
81 /* 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
|
82 * 1. motion type (NSNumber) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
83 * 2. text (NSString) |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
84 * 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
|
85 */ |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
86 id plist = [pb propertyListForType:VimPboardType]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
87 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
|
88 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
89 id obj = [plist objectAtIndex:1]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
90 if ([obj isKindOfClass:[NSString class]]) |
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 motion_type = [[plist objectAtIndex:0] intValue]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
93 string = obj; |
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 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
96 } |
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 if (!string) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
99 { |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
100 /* 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
|
101 */ |
14911
73162bc0b21f
patch 8.1.0467: cannot build with Mac OS X 10.5
Bram Moolenaar <Bram@vim.org>
parents:
14091
diff
changeset
|
102 #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
|
103 NSMutableString *mstring = |
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
104 [[pb stringForType:NSPasteboardTypeString] mutableCopy]; |
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
105 #else |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
106 NSMutableString *mstring = |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
107 [[pb stringForType:NSStringPboardType] mutableCopy]; |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
108 #endif |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
109 if (!mstring) goto releasepool; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
110 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
111 /* 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
|
112 NSRange range = { 0, [mstring length] }; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
113 unsigned n = [mstring replaceOccurrencesOfString:@"\x0d\x0a" |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
114 withString:@"\x0a" options:0 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
115 range:range]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
116 if (0 == n) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
117 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
118 n = [mstring replaceOccurrencesOfString:@"\x0d" withString:@"\x0a" |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
119 options:0 range:range]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
120 } |
2310
3e4574a4b627
Fix a few compiler warnings.
Bram Moolenaar <bram@vim.org>
parents:
2309
diff
changeset
|
121 |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
122 string = mstring; |
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 |
2909 | 125 /* 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
|
126 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
|
127 || MAUTO == motion_type)) |
2909 | 128 motion_type = MAUTO; |
2309
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 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
|
131 int len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
132 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
133 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
|
134 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
|
135 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
136 if (str) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
137 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
|
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 vim_free(str); |
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 releasepool: |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
143 [pool release]; |
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 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
146 |
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 * 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
|
149 */ |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
150 void |
17067
d0438b4b0acf
patch 8.1.1533: GUI build fails on Mac
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
151 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
|
152 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
153 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
154 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
155 /* 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
|
156 cbd->owned = TRUE; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
157 clip_get_selection(cbd); |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
158 cbd->owned = FALSE; |
2310
3e4574a4b627
Fix a few compiler warnings.
Bram Moolenaar <bram@vim.org>
parents:
2309
diff
changeset
|
159 |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
160 /* 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
|
161 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
|
162 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
|
163 if (motion_type < 0) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
164 goto releasepool; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
165 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
166 /* TODO: Avoid overflow. */ |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
167 int len = (int)llen; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
168 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
|
169 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
170 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
|
171 if (conv_str) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
172 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
173 vim_free(str); |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
174 str = conv_str; |
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 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
177 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
178 if (len > 0) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
179 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
180 NSString *string = [[NSString alloc] |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
181 initWithBytes:str length:len encoding:NSUTF8StringEncoding]; |
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 /* 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
|
184 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
|
185 #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
|
186 NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType, |
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
187 NSPasteboardTypeString, nil]; |
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
188 #else |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
189 NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType, |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
190 NSStringPboardType, nil]; |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
191 #endif |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
192 [pb declareTypes:supportedTypes owner:nil]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
193 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
194 NSNumber *motion = [NSNumber numberWithInt:motion_type]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
195 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
|
196 [pb setPropertyList:plist forType:VimPboardType]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
197 |
14911
73162bc0b21f
patch 8.1.0467: cannot build with Mac OS X 10.5
Bram Moolenaar <Bram@vim.org>
parents:
14091
diff
changeset
|
198 #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
|
199 [pb setString:string forType:NSPasteboardTypeString]; |
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
200 #else |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
201 [pb setString:string forType:NSStringPboardType]; |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
202 #endif |
2310
3e4574a4b627
Fix a few compiler warnings.
Bram Moolenaar <bram@vim.org>
parents:
2309
diff
changeset
|
203 |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
204 [string release]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
205 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
206 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
207 vim_free(str); |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
208 releasepool: |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
209 [pool release]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
210 } |
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 #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
|
213 |
f80abb797a32
patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents:
12877
diff
changeset
|
214 /* 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
|
215 #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
|
216 # 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
|
217 # 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
|
218 #endif |