Vim talks only to app controller
[MacVim.git] / src / MacVim / MacVim.h
blobc2d10c59a939dad1b91d7ba69695e6a7b6b98ee1
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
45 #if 0
47 // This is the protocol MMVimController implements.
49 // Be very careful if you want to add methods to this protocol. Since DO
50 // messages may arrive while Cocoa is in the middle of processing some other
51 // message be sure to consider reentrancy issues. Look at processCommandQueue:
52 // to see an example of how to deal with this.
54 @protocol MMFrontendProtocol
55 - (oneway void)processCommandQueue:(in bycopy NSArray *)queue;
56 - (oneway void)showSavePanelWithAttributes:(in bycopy NSDictionary *)attr;
57 - (oneway void)presentDialogWithAttributes:(in bycopy NSDictionary *)attr;
58 @end
59 #endif
63 // This is the protocol MMAppController implements.
65 // It handles connections between MacVim and Vim.
67 @protocol MMAppProtocol
68 - (unsigned)connectBackend:(byref in id <MMBackendProtocol>)backend
69 pid:(int)pid;
70 - (NSArray *)serverList;
71 - (oneway void)processInput:(in bycopy NSArray *)queue
72 forIdentifier:(unsigned)identifier;
73 @end
76 @protocol MMVimServerProtocol;
79 // The Vim client protocol (implemented by MMBackend).
81 // The client needs to keep track of server replies. Take a look at MMBackend
82 // if you want to implement this protocol in another program.
84 @protocol MMVimClientProtocol
85 - (oneway void)addReply:(in bycopy NSString *)reply
86 server:(in byref id <MMVimServerProtocol>)server;
87 @end
91 // The Vim server protocol (implemented by MMBackend).
93 // Note that addInput:client: is not asynchronous, because otherwise Vim might
94 // quit before the message has been passed (e.g. if --remote was used on the
95 // command line).
97 @protocol MMVimServerProtocol
98 - (void)addInput:(in bycopy NSString *)input
99 client:(in byref id <MMVimClientProtocol>)client;
100 - (NSString *)evaluateExpression:(in bycopy NSString *)expr
101 client:(in byref id <MMVimClientProtocol>)client;
102 @end
107 // The following enum lists all messages that are passed between MacVim and
108 // Vim. These can be sent in processInput:data: and in processCommandQueue:.
111 // NOTE! This array must be updated whenever the enum below changes!
112 extern char *MessageStrings[];
114 enum {
115 OpenWindowMsgID = 1,
116 InsertTextMsgID,
117 KeyDownMsgID,
118 CmdKeyMsgID,
119 BatchDrawMsgID,
120 SelectTabMsgID,
121 CloseTabMsgID,
122 AddNewTabMsgID,
123 DraggedTabMsgID,
124 UpdateTabBarMsgID,
125 ShowTabBarMsgID,
126 HideTabBarMsgID,
127 SetTextRowsMsgID,
128 SetTextColumnsMsgID,
129 SetTextDimensionsMsgID,
130 LiveResizeMsgID,
131 SetTextDimensionsReplyMsgID,
132 SetWindowTitleMsgID,
133 ScrollWheelMsgID,
134 MouseDownMsgID,
135 MouseUpMsgID,
136 MouseDraggedMsgID,
137 FlushQueueMsgID,
138 AddMenuMsgID,
139 AddMenuItemMsgID,
140 RemoveMenuItemMsgID,
141 EnableMenuItemMsgID,
142 ExecuteMenuMsgID,
143 ShowToolbarMsgID,
144 ToggleToolbarMsgID,
145 CreateScrollbarMsgID,
146 DestroyScrollbarMsgID,
147 ShowScrollbarMsgID,
148 SetScrollbarPositionMsgID,
149 SetScrollbarThumbMsgID,
150 ScrollbarEventMsgID,
151 SetFontMsgID,
152 SetWideFontMsgID,
153 VimShouldCloseMsgID,
154 SetDefaultColorsMsgID,
155 ExecuteActionMsgID,
156 DropFilesMsgID,
157 DropStringMsgID,
158 ShowPopupMenuMsgID,
159 GotFocusMsgID,
160 LostFocusMsgID,
161 MouseMovedMsgID,
162 SetMouseShapeMsgID,
163 AdjustLinespaceMsgID,
164 ActivateMsgID,
165 SetServerNameMsgID,
166 EnterFullscreenMsgID,
167 LeaveFullscreenMsgID,
168 BuffersNotModifiedMsgID,
169 BuffersModifiedMsgID,
170 AddInputMsgID,
171 SetPreEditPositionMsgID,
172 TerminateNowMsgID,
173 XcodeModMsgID,
174 EnableAntialiasMsgID,
175 DisableAntialiasMsgID,
176 SetVimStateMsgID,
177 SetDocumentFilenameMsgID,
178 OpenWithArgumentsMsgID,
179 CloseWindowMsgID,
180 SetFullscreenColorMsgID,
181 ShowFindReplaceDialogMsgID,
182 FindReplaceMsgID,
183 ActivateKeyScriptID,
184 DeactivateKeyScriptID,
188 #define DRAW_WIDE 0x40 /* draw wide text */
190 enum {
191 ClearAllDrawType = 1,
192 ClearBlockDrawType,
193 DeleteLinesDrawType,
194 DrawStringDrawType,
195 InsertLinesDrawType,
196 DrawCursorDrawType,
197 SetCursorPosDrawType,
198 DrawInvertedRectDrawType,
201 enum {
202 MMInsertionPointBlock,
203 MMInsertionPointHorizontal,
204 MMInsertionPointVertical,
205 MMInsertionPointHollow,
206 MMInsertionPointVerticalRight,
210 enum {
211 ToolbarLabelFlag = 1,
212 ToolbarIconFlag = 2,
213 ToolbarSizeRegularFlag = 4
217 enum {
218 MMTabLabel = 0,
219 MMTabToolTip,
220 MMTabInfoCount
223 // Argument used to stop MacVim from opening an empty window on startup
224 // (techincally this is a user default but should not be used as such).
225 extern NSString *MMNoWindowKey;
227 // Vim pasteboard type (holds motion type + string)
228 extern NSString *VimPBoardType;
233 @interface NSString (MMExtras)
234 - (NSString *)stringByEscapingSpecialFilenameCharacters;
235 @end
238 @interface NSColor (MMExtras)
239 + (NSColor *)colorWithRgbInt:(unsigned)rgb;
240 + (NSColor *)colorWithArgbInt:(unsigned)argb;
241 @end
244 @interface NSDictionary (MMExtras)
245 + (id)dictionaryWithData:(NSData *)data;
246 - (NSData *)dictionaryAsData;
247 @end
249 @interface NSMutableDictionary (MMExtras)
250 + (id)dictionaryWithData:(NSData *)data;
251 @end
256 // ODB Editor Suite Constants (taken from ODBEditorSuite.h)
257 #define keyFileSender 'FSnd'
258 #define keyFileSenderToken 'FTok'
259 #define keyFileCustomPath 'Burl'
260 #define kODBEditorSuite 'R*ch'
261 #define kAEModifiedFile 'FMod'
262 #define keyNewLocation 'New?'
263 #define kAEClosedFile 'FCls'
264 #define keySenderToken 'Tokn'
267 // MacVim Apple Event Constants
268 #define keyMMUntitledWindow 'MMuw'
273 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
274 // NSInteger was introduced in 10.5
275 # if __LP64__ || NS_BUILD_32_LIKE_64
276 typedef long NSInteger;
277 typedef unsigned long NSUInteger;
278 # else
279 typedef int NSInteger;
280 typedef unsigned int NSUInteger;
281 # endif
282 #endif