Update Appcast
[MacVim.git] / src / MacVim / MacVim.h
blob09891963ed81357cc129ec397807befda3879984
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 SetTextDimensionsMsgID,
125 SetWindowTitleMsgID,
126 ScrollWheelMsgID,
127 MouseDownMsgID,
128 MouseUpMsgID,
129 MouseDraggedMsgID,
130 FlushQueueMsgID,
131 AddMenuMsgID,
132 AddMenuItemMsgID,
133 RemoveMenuItemMsgID,
134 EnableMenuItemMsgID,
135 ExecuteMenuMsgID,
136 ShowToolbarMsgID,
137 ToggleToolbarMsgID,
138 CreateScrollbarMsgID,
139 DestroyScrollbarMsgID,
140 ShowScrollbarMsgID,
141 SetScrollbarPositionMsgID,
142 SetScrollbarThumbMsgID,
143 ScrollbarEventMsgID,
144 SetFontMsgID,
145 SetWideFontMsgID,
146 VimShouldCloseMsgID,
147 SetDefaultColorsMsgID,
148 ExecuteActionMsgID,
149 DropFilesMsgID,
150 DropStringMsgID,
151 ShowPopupMenuMsgID,
152 GotFocusMsgID,
153 LostFocusMsgID,
154 MouseMovedMsgID,
155 SetMouseShapeMsgID,
156 AdjustLinespaceMsgID,
157 ActivateMsgID,
158 SetServerNameMsgID,
159 EnterFullscreenMsgID,
160 LeaveFullscreenMsgID,
161 BuffersNotModifiedMsgID,
162 BuffersModifiedMsgID,
163 AddInputMsgID,
164 SetPreEditPositionMsgID,
165 TerminateNowMsgID,
166 XcodeModMsgID,
167 LiveResizeMsgID,
168 EnableAntialiasMsgID,
169 DisableAntialiasMsgID,
170 SetVimStateMsgID,
171 SetDocumentFilenameMsgID,
172 OpenWithArgumentsMsgID,
173 CloseWindowMsgID,
177 #define DRAW_WIDE 0x40 /* draw wide text */
179 enum {
180 ClearAllDrawType = 1,
181 ClearBlockDrawType,
182 DeleteLinesDrawType,
183 DrawStringDrawType,
184 InsertLinesDrawType,
185 DrawCursorDrawType,
186 SetCursorPosDrawType,
187 DrawInvertedRectDrawType,
190 enum {
191 MMInsertionPointBlock,
192 MMInsertionPointHorizontal,
193 MMInsertionPointVertical,
194 MMInsertionPointHollow,
195 MMInsertionPointVerticalRight,
199 enum {
200 ToolbarLabelFlag = 1,
201 ToolbarIconFlag = 2,
202 ToolbarSizeRegularFlag = 4
205 // Argument used to stop MacVim from opening an empty window on startup
206 // (techincally this is a user default but should not be used as such).
207 extern NSString *MMNoWindowKey;
209 // Vim pasteboard type (holds motion type + string)
210 extern NSString *VimPBoardType;
214 // Loads all fonts in the Resouces folder of the app bundle and returns a font
215 // container reference (which should be used to deactivate the loaded fonts).
216 ATSFontContainerRef loadFonts();
220 @interface NSString (MMExtras)
221 - (NSString *)stringByEscapingSpecialFilenameCharacters;
222 @end
225 @interface NSColor (MMExtras)
226 + (NSColor *)colorWithRgbInt:(unsigned)rgb;
227 + (NSColor *)colorWithArgbInt:(unsigned)argb;
228 @end
231 @interface NSDictionary (MMExtras)
232 + (id)dictionaryWithData:(NSData *)data;
233 - (NSData *)dictionaryAsData;
234 @end
236 @interface NSMutableDictionary (MMExtras)
237 + (id)dictionaryWithData:(NSData *)data;
238 @end
243 // ODB Editor Suite Constants (taken from ODBEditorSuite.h)
244 #define keyFileSender 'FSnd'
245 #define keyFileSenderToken 'FTok'
246 #define keyFileCustomPath 'Burl'
247 #define kODBEditorSuite 'R*ch'
248 #define kAEModifiedFile 'FMod'
249 #define keyNewLocation 'New?'
250 #define kAEClosedFile 'FCls'
251 #define keySenderToken 'Tokn'
254 // MacVim Apple Event Constants
255 #define keyMMUntitledWindow 'MMuw'