Fix deprecated API compiler warning
[MacVim.git] / src / MacVim / MacVim.h
blob88e5e3c0a5e7b076e6558a3a7d5e0a2618801302
1 /* vi:set ts=8 sts=4 sw=4 ft=objc:
3 * VIM - Vi IMproved by Bram Moolenaar
4 * MacVim GUI port by Bjorn Winckler
6 * Do ":help uganda" in Vim to read copying and usage conditions.
7 * Do ":help credits" in Vim to see a list of people who contributed.
8 * See README.txt for an overview of the Vim source code.
9 */
11 #import <Cocoa/Cocoa.h>
15 // Enable support for MacVim plugins (not to be confused with Vim plugins!).
17 #define MM_ENABLE_PLUGINS
22 // This is the protocol MMBackend implements.
24 // Only processInput:data: is allowed to cause state changes in Vim; all other
25 // messages should only read the Vim state. (Note that setDialogReturn: is an
26 // exception to this rule; there really is no other way to deal with dialogs
27 // since they work with callbacks, so we cannot wait for them to return.)
29 // Be careful with messages with return type other than 'oneway void' -- there
30 // is a reply timeout set in MMAppController, if a message fails to get a
31 // response within the given timeout an exception will be thrown. Use
32 // @try/@catch/@finally to deal with timeouts.
34 @protocol MMBackendProtocol
35 - (oneway void)processInput:(int)msgid data:(in bycopy NSData *)data;
36 - (oneway void)processInputAndData:(in bycopy NSArray *)messages;
37 - (oneway void)setDialogReturn:(in bycopy id)obj;
38 - (NSString *)evaluateExpression:(in bycopy NSString *)expr;
39 - (id)evaluateExpressionCocoa:(in bycopy NSString *)expr
40 errorString:(out bycopy NSString **)errstr;
41 - (BOOL)starRegisterToPasteboard:(byref NSPasteboard *)pboard;
42 - (oneway void)acknowledgeConnection;
43 @end
46 // This is the protocol MMVimController implements.
48 // Be very careful if you want to add methods to this protocol. Since DO
49 // messages may arrive while Cocoa is in the middle of processing some other
50 // message be sure to consider reentrancy issues. Look at processCommandQueue:
51 // to see an example of how to deal with this.
53 @protocol MMFrontendProtocol
54 - (oneway void)processCommandQueue:(in bycopy NSArray *)queue;
55 - (oneway void)showSavePanelWithAttributes:(in bycopy NSDictionary *)attr;
56 - (oneway void)presentDialogWithAttributes:(in bycopy NSDictionary *)attr;
57 @end
61 // This is the protocol MMAppController implements.
63 // It handles connections between MacVim and Vim.
65 @protocol MMAppProtocol
66 - (byref id <MMFrontendProtocol>)
67 connectBackend:(byref in id <MMBackendProtocol>)backend
68 pid:(int)pid;
69 - (NSArray *)serverList;
70 @end
73 @protocol MMVimServerProtocol;
76 // The Vim client protocol (implemented by MMBackend).
78 // The client needs to keep track of server replies. Take a look at MMBackend
79 // if you want to implement this protocol in another program.
81 @protocol MMVimClientProtocol
82 - (oneway void)addReply:(in bycopy NSString *)reply
83 server:(in byref id <MMVimServerProtocol>)server;
84 @end
88 // The Vim server protocol (implemented by MMBackend).
90 // Note that addInput:client: is not asynchronous, because otherwise Vim might
91 // quit before the message has been passed (e.g. if --remote was used on the
92 // command line).
94 @protocol MMVimServerProtocol
95 - (void)addInput:(in bycopy NSString *)input
96 client:(in byref id <MMVimClientProtocol>)client;
97 - (NSString *)evaluateExpression:(in bycopy NSString *)expr
98 client:(in byref id <MMVimClientProtocol>)client;
99 @end
104 // The following enum lists all messages that are passed between MacVim and
105 // Vim. These can be sent in processInput:data: and in processCommandQueue:.
108 // NOTE! This array must be updated whenever the enum below changes!
109 extern char *MessageStrings[];
111 enum {
112 OpenWindowMsgID = 1,
113 InsertTextMsgID,
114 KeyDownMsgID,
115 CmdKeyMsgID,
116 BatchDrawMsgID,
117 SelectTabMsgID,
118 CloseTabMsgID,
119 AddNewTabMsgID,
120 DraggedTabMsgID,
121 UpdateTabBarMsgID,
122 ShowTabBarMsgID,
123 HideTabBarMsgID,
124 SetTextRowsMsgID,
125 SetTextColumnsMsgID,
126 SetTextDimensionsMsgID,
127 LiveResizeMsgID,
128 SetTextDimensionsReplyMsgID,
129 SetWindowTitleMsgID,
130 ScrollWheelMsgID,
131 MouseDownMsgID,
132 MouseUpMsgID,
133 MouseDraggedMsgID,
134 FlushQueueMsgID,
135 AddMenuMsgID,
136 AddMenuItemMsgID,
137 RemoveMenuItemMsgID,
138 EnableMenuItemMsgID,
139 ExecuteMenuMsgID,
140 ShowToolbarMsgID,
141 ToggleToolbarMsgID,
142 CreateScrollbarMsgID,
143 DestroyScrollbarMsgID,
144 ShowScrollbarMsgID,
145 SetScrollbarPositionMsgID,
146 SetScrollbarThumbMsgID,
147 ScrollbarEventMsgID,
148 SetFontMsgID,
149 SetWideFontMsgID,
150 VimShouldCloseMsgID,
151 SetDefaultColorsMsgID,
152 ExecuteActionMsgID,
153 DropFilesMsgID,
154 DropStringMsgID,
155 ShowPopupMenuMsgID,
156 GotFocusMsgID,
157 LostFocusMsgID,
158 MouseMovedMsgID,
159 SetMouseShapeMsgID,
160 AdjustLinespaceMsgID,
161 ActivateMsgID,
162 SetServerNameMsgID,
163 EnterFullscreenMsgID,
164 LeaveFullscreenMsgID,
165 BuffersNotModifiedMsgID,
166 BuffersModifiedMsgID,
167 AddInputMsgID,
168 SetPreEditPositionMsgID,
169 TerminateNowMsgID,
170 XcodeModMsgID,
171 EnableAntialiasMsgID,
172 DisableAntialiasMsgID,
173 SetVimStateMsgID,
174 SetDocumentFilenameMsgID,
175 OpenWithArgumentsMsgID,
176 CloseWindowMsgID,
177 InterruptMsgID,
178 SetFullscreenColorMsgID,
179 ShowFindReplaceDialogMsgID,
180 FindReplaceMsgID,
184 #define DRAW_WIDE 0x40 /* draw wide text */
186 enum {
187 ClearAllDrawType = 1,
188 ClearBlockDrawType,
189 DeleteLinesDrawType,
190 DrawStringDrawType,
191 InsertLinesDrawType,
192 DrawCursorDrawType,
193 SetCursorPosDrawType,
194 DrawInvertedRectDrawType,
197 enum {
198 MMInsertionPointBlock,
199 MMInsertionPointHorizontal,
200 MMInsertionPointVertical,
201 MMInsertionPointHollow,
202 MMInsertionPointVerticalRight,
206 enum {
207 ToolbarLabelFlag = 1,
208 ToolbarIconFlag = 2,
209 ToolbarSizeRegularFlag = 4
213 enum {
214 MMTabLabel = 0,
215 MMTabToolTip,
216 MMTabInfoCount
219 // Argument used to stop MacVim from opening an empty window on startup
220 // (techincally this is a user default but should not be used as such).
221 extern NSString *MMNoWindowKey;
223 // Vim pasteboard type (holds motion type + string)
224 extern NSString *VimPBoardType;
229 @interface NSString (MMExtras)
230 - (NSString *)stringByEscapingSpecialFilenameCharacters;
231 @end
234 @interface NSColor (MMExtras)
235 + (NSColor *)colorWithRgbInt:(unsigned)rgb;
236 + (NSColor *)colorWithArgbInt:(unsigned)argb;
237 @end
240 @interface NSDictionary (MMExtras)
241 + (id)dictionaryWithData:(NSData *)data;
242 - (NSData *)dictionaryAsData;
243 @end
245 @interface NSMutableDictionary (MMExtras)
246 + (id)dictionaryWithData:(NSData *)data;
247 @end
252 // ODB Editor Suite Constants (taken from ODBEditorSuite.h)
253 #define keyFileSender 'FSnd'
254 #define keyFileSenderToken 'FTok'
255 #define keyFileCustomPath 'Burl'
256 #define kODBEditorSuite 'R*ch'
257 #define kAEModifiedFile 'FMod'
258 #define keyNewLocation 'New?'
259 #define kAEClosedFile 'FCls'
260 #define keySenderToken 'Tokn'
263 // MacVim Apple Event Constants
264 #define keyMMUntitledWindow 'MMuw'
269 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
270 // NSInteger was introduced in 10.5
271 # if __LP64__ || NS_BUILD_32_LIKE_64
272 typedef long NSInteger;
273 typedef unsigned long NSUInteger;
274 # else
275 typedef int NSInteger;
276 typedef unsigned int NSUInteger;
277 # endif
278 #endif