Change name of window menu items
[MacVim.git] / src / MacVim / MacVim.h
blob359803d0d5ec7ef57de6769cd5a0483dc37a67f1
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 // Do not add methods to this interface without a _very_ good reason (if
52 // possible, instead add a new message to the *MsgID enum below and pass it via
53 // processInput:forIdentifier). Methods should not modify the state directly
54 // but should instead delay any potential modifications (see
55 // connectBackend:pid: and processInput:forIdentifier:).
57 @protocol MMAppProtocol
58 - (unsigned)connectBackend:(byref in id <MMBackendProtocol>)proxy pid:(int)pid;
59 - (oneway void)processInput:(in bycopy NSArray *)queue
60 forIdentifier:(unsigned)identifier;
61 - (NSArray *)serverList;
62 @end
65 @protocol MMVimServerProtocol;
68 // The Vim client protocol (implemented by MMBackend).
70 // The client needs to keep track of server replies. Take a look at MMBackend
71 // if you want to implement this protocol in another program.
73 @protocol MMVimClientProtocol
74 - (oneway void)addReply:(in bycopy NSString *)reply
75 server:(in byref id <MMVimServerProtocol>)server;
76 @end
80 // The Vim server protocol (implemented by MMBackend).
82 // Note that addInput:client: is not asynchronous, because otherwise Vim might
83 // quit before the message has been passed (e.g. if --remote was used on the
84 // command line).
86 @protocol MMVimServerProtocol
87 - (void)addInput:(in bycopy NSString *)input
88 client:(in byref id <MMVimClientProtocol>)client;
89 - (NSString *)evaluateExpression:(in bycopy NSString *)expr
90 client:(in byref id <MMVimClientProtocol>)client;
91 @end
96 // The following enum lists all messages that are passed between MacVim and
97 // Vim. These can be sent in processInput:data: and in processCommandQueue:.
100 // NOTE! This array must be updated whenever the enum below changes!
101 extern char *MessageStrings[];
103 enum {
104 OpenWindowMsgID = 1, // NOTE: FIRST IN ENUM MUST BE 1
105 InsertTextMsgID,
106 KeyDownMsgID,
107 CmdKeyMsgID,
108 BatchDrawMsgID,
109 SelectTabMsgID,
110 CloseTabMsgID,
111 AddNewTabMsgID,
112 DraggedTabMsgID,
113 UpdateTabBarMsgID,
114 ShowTabBarMsgID,
115 HideTabBarMsgID,
116 SetTextRowsMsgID,
117 SetTextColumnsMsgID,
118 SetTextDimensionsMsgID,
119 LiveResizeMsgID,
120 SetTextDimensionsReplyMsgID,
121 SetWindowTitleMsgID,
122 ScrollWheelMsgID,
123 MouseDownMsgID,
124 MouseUpMsgID,
125 MouseDraggedMsgID,
126 FlushQueueMsgID,
127 AddMenuMsgID,
128 AddMenuItemMsgID,
129 RemoveMenuItemMsgID,
130 EnableMenuItemMsgID,
131 ExecuteMenuMsgID,
132 ShowToolbarMsgID,
133 ToggleToolbarMsgID,
134 CreateScrollbarMsgID,
135 DestroyScrollbarMsgID,
136 ShowScrollbarMsgID,
137 SetScrollbarPositionMsgID,
138 SetScrollbarThumbMsgID,
139 ScrollbarEventMsgID,
140 SetFontMsgID,
141 SetWideFontMsgID,
142 VimShouldCloseMsgID,
143 SetDefaultColorsMsgID,
144 ExecuteActionMsgID,
145 DropFilesMsgID,
146 DropStringMsgID,
147 ShowPopupMenuMsgID,
148 GotFocusMsgID,
149 LostFocusMsgID,
150 MouseMovedMsgID,
151 SetMouseShapeMsgID,
152 AdjustLinespaceMsgID,
153 ActivateMsgID,
154 SetServerNameMsgID,
155 EnterFullscreenMsgID,
156 LeaveFullscreenMsgID,
157 BuffersNotModifiedMsgID,
158 BuffersModifiedMsgID,
159 AddInputMsgID,
160 SetPreEditPositionMsgID,
161 TerminateNowMsgID,
162 XcodeModMsgID,
163 EnableAntialiasMsgID,
164 DisableAntialiasMsgID,
165 SetVimStateMsgID,
166 SetDocumentFilenameMsgID,
167 OpenWithArgumentsMsgID,
168 CloseWindowMsgID,
169 SetFullscreenColorMsgID,
170 ShowFindReplaceDialogMsgID,
171 FindReplaceMsgID,
172 ActivateKeyScriptMsgID,
173 DeactivateKeyScriptMsgID,
174 EnableImControlMsgID,
175 DisableImControlMsgID,
176 ActivatedImMsgID,
177 DeactivatedImMsgID,
178 BrowseForFileMsgID,
179 ShowDialogMsgID,
180 LastMsgID // NOTE: MUST BE LAST MESSAGE IN ENUM!
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
220 // Create a string holding the labels of all messages in message queue for
221 // debugging purposes (condense some messages since there may typically be LOTS
222 // of them on a queue).
223 NSString *debugStringForMessageQueue(NSArray *queue);
226 // Argument used to stop MacVim from opening an empty window on startup
227 // (techincally this is a user default but should not be used as such).
228 extern NSString *MMNoWindowKey;
230 // Vim pasteboard type (holds motion type + string)
231 extern NSString *VimPBoardType;
236 @interface NSString (MMExtras)
237 - (NSString *)stringByEscapingSpecialFilenameCharacters;
238 @end
241 @interface NSColor (MMExtras)
242 + (NSColor *)colorWithRgbInt:(unsigned)rgb;
243 + (NSColor *)colorWithArgbInt:(unsigned)argb;
244 @end
247 @interface NSDictionary (MMExtras)
248 + (id)dictionaryWithData:(NSData *)data;
249 - (NSData *)dictionaryAsData;
250 @end
252 @interface NSMutableDictionary (MMExtras)
253 + (id)dictionaryWithData:(NSData *)data;
254 @end
259 // ODB Editor Suite Constants (taken from ODBEditorSuite.h)
260 #define keyFileSender 'FSnd'
261 #define keyFileSenderToken 'FTok'
262 #define keyFileCustomPath 'Burl'
263 #define kODBEditorSuite 'R*ch'
264 #define kAEModifiedFile 'FMod'
265 #define keyNewLocation 'New?'
266 #define kAEClosedFile 'FCls'
267 #define keySenderToken 'Tokn'
270 // MacVim Apple Event Constants
271 #define keyMMUntitledWindow 'MMuw'
276 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
277 // NSInteger was introduced in 10.5
278 # if __LP64__ || NS_BUILD_32_LIKE_64
279 typedef long NSInteger;
280 typedef unsigned long NSUInteger;
281 # else
282 typedef int NSInteger;
283 typedef unsigned int NSUInteger;
284 # endif
285 #endif