Cleanup
[MacVim.git] / src / MacVim / MacVim.h
bloba81e08ef3c014ccf5dc8f60b347efb23b5f591d8
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)setDialogReturn:(in bycopy id)obj;
37 - (NSString *)evaluateExpression:(in bycopy NSString *)expr;
38 - (id)evaluateExpressionCocoa:(in bycopy NSString *)expr
39 errorString:(out bycopy NSString **)errstr;
40 - (BOOL)starRegisterToPasteboard:(byref NSPasteboard *)pboard;
41 - (oneway void)acknowledgeConnection;
42 @end
46 // This is the protocol MMAppController implements.
48 // It handles connections between MacVim and Vim and communication from Vim to
49 // MacVim.
51 @protocol MMAppProtocol
52 - (unsigned)connectBackend:(byref in id <MMBackendProtocol>)backend
53 pid:(int)pid;
54 - (oneway void)processInput:(in bycopy NSArray *)queue
55 forIdentifier:(unsigned)identifier;
56 - (NSArray *)serverList;
57 @end
60 @protocol MMVimServerProtocol;
63 // The Vim client protocol (implemented by MMBackend).
65 // The client needs to keep track of server replies. Take a look at MMBackend
66 // if you want to implement this protocol in another program.
68 @protocol MMVimClientProtocol
69 - (oneway void)addReply:(in bycopy NSString *)reply
70 server:(in byref id <MMVimServerProtocol>)server;
71 @end
75 // The Vim server protocol (implemented by MMBackend).
77 // Note that addInput:client: is not asynchronous, because otherwise Vim might
78 // quit before the message has been passed (e.g. if --remote was used on the
79 // command line).
81 @protocol MMVimServerProtocol
82 - (void)addInput:(in bycopy NSString *)input
83 client:(in byref id <MMVimClientProtocol>)client;
84 - (NSString *)evaluateExpression:(in bycopy NSString *)expr
85 client:(in byref id <MMVimClientProtocol>)client;
86 @end
91 // The following enum lists all messages that are passed between MacVim and
92 // Vim. These can be sent in processInput:data: and in processCommandQueue:.
95 // NOTE! This array must be updated whenever the enum below changes!
96 extern char *MessageStrings[];
98 enum {
99 OpenWindowMsgID = 1,
100 InsertTextMsgID,
101 KeyDownMsgID,
102 CmdKeyMsgID,
103 BatchDrawMsgID,
104 SelectTabMsgID,
105 CloseTabMsgID,
106 AddNewTabMsgID,
107 DraggedTabMsgID,
108 UpdateTabBarMsgID,
109 ShowTabBarMsgID,
110 HideTabBarMsgID,
111 SetTextRowsMsgID,
112 SetTextColumnsMsgID,
113 SetTextDimensionsMsgID,
114 LiveResizeMsgID,
115 SetTextDimensionsReplyMsgID,
116 SetWindowTitleMsgID,
117 ScrollWheelMsgID,
118 MouseDownMsgID,
119 MouseUpMsgID,
120 MouseDraggedMsgID,
121 FlushQueueMsgID,
122 AddMenuMsgID,
123 AddMenuItemMsgID,
124 RemoveMenuItemMsgID,
125 EnableMenuItemMsgID,
126 ExecuteMenuMsgID,
127 ShowToolbarMsgID,
128 ToggleToolbarMsgID,
129 CreateScrollbarMsgID,
130 DestroyScrollbarMsgID,
131 ShowScrollbarMsgID,
132 SetScrollbarPositionMsgID,
133 SetScrollbarThumbMsgID,
134 ScrollbarEventMsgID,
135 SetFontMsgID,
136 SetWideFontMsgID,
137 VimShouldCloseMsgID,
138 SetDefaultColorsMsgID,
139 ExecuteActionMsgID,
140 DropFilesMsgID,
141 DropStringMsgID,
142 ShowPopupMenuMsgID,
143 GotFocusMsgID,
144 LostFocusMsgID,
145 MouseMovedMsgID,
146 SetMouseShapeMsgID,
147 AdjustLinespaceMsgID,
148 ActivateMsgID,
149 SetServerNameMsgID,
150 EnterFullscreenMsgID,
151 LeaveFullscreenMsgID,
152 BuffersNotModifiedMsgID,
153 BuffersModifiedMsgID,
154 AddInputMsgID,
155 SetPreEditPositionMsgID,
156 TerminateNowMsgID,
157 XcodeModMsgID,
158 EnableAntialiasMsgID,
159 DisableAntialiasMsgID,
160 SetVimStateMsgID,
161 SetDocumentFilenameMsgID,
162 OpenWithArgumentsMsgID,
163 CloseWindowMsgID,
164 SetFullscreenColorMsgID,
165 ShowFindReplaceDialogMsgID,
166 FindReplaceMsgID,
167 ActivateKeyScriptID,
168 DeactivateKeyScriptID,
169 BrowseForFileMsgID,
170 ShowDialogMsgID,
174 #define DRAW_WIDE 0x40 /* draw wide text */
176 enum {
177 ClearAllDrawType = 1,
178 ClearBlockDrawType,
179 DeleteLinesDrawType,
180 DrawStringDrawType,
181 InsertLinesDrawType,
182 DrawCursorDrawType,
183 SetCursorPosDrawType,
184 DrawInvertedRectDrawType,
187 enum {
188 MMInsertionPointBlock,
189 MMInsertionPointHorizontal,
190 MMInsertionPointVertical,
191 MMInsertionPointHollow,
192 MMInsertionPointVerticalRight,
196 enum {
197 ToolbarLabelFlag = 1,
198 ToolbarIconFlag = 2,
199 ToolbarSizeRegularFlag = 4
203 enum {
204 MMTabLabel = 0,
205 MMTabToolTip,
206 MMTabInfoCount
209 // Argument used to stop MacVim from opening an empty window on startup
210 // (techincally this is a user default but should not be used as such).
211 extern NSString *MMNoWindowKey;
213 // Vim pasteboard type (holds motion type + string)
214 extern NSString *VimPBoardType;
219 @interface NSString (MMExtras)
220 - (NSString *)stringByEscapingSpecialFilenameCharacters;
221 @end
224 @interface NSColor (MMExtras)
225 + (NSColor *)colorWithRgbInt:(unsigned)rgb;
226 + (NSColor *)colorWithArgbInt:(unsigned)argb;
227 @end
230 @interface NSDictionary (MMExtras)
231 + (id)dictionaryWithData:(NSData *)data;
232 - (NSData *)dictionaryAsData;
233 @end
235 @interface NSMutableDictionary (MMExtras)
236 + (id)dictionaryWithData:(NSData *)data;
237 @end
242 // ODB Editor Suite Constants (taken from ODBEditorSuite.h)
243 #define keyFileSender 'FSnd'
244 #define keyFileSenderToken 'FTok'
245 #define keyFileCustomPath 'Burl'
246 #define kODBEditorSuite 'R*ch'
247 #define kAEModifiedFile 'FMod'
248 #define keyNewLocation 'New?'
249 #define kAEClosedFile 'FCls'
250 #define keySenderToken 'Tokn'
253 // MacVim Apple Event Constants
254 #define keyMMUntitledWindow 'MMuw'
259 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
260 // NSInteger was introduced in 10.5
261 # if __LP64__ || NS_BUILD_32_LIKE_64
262 typedef long NSInteger;
263 typedef unsigned long NSUInteger;
264 # else
265 typedef int NSInteger;
266 typedef unsigned int NSUInteger;
267 # endif
268 #endif