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.
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
;
46 // This is the protocol MMAppController implements.
48 // It handles connections between MacVim and Vim and communication from Vim to
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
;
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
;
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
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
;
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
[];
104 OpenWindowMsgID
= 1, // NOTE: FIRST IN ENUM MUST BE 1
118 SetTextDimensionsMsgID
,
120 SetTextDimensionsReplyMsgID
,
134 CreateScrollbarMsgID
,
135 DestroyScrollbarMsgID
,
137 SetScrollbarPositionMsgID
,
138 SetScrollbarThumbMsgID
,
143 SetDefaultColorsMsgID
,
152 AdjustLinespaceMsgID
,
155 EnterFullscreenMsgID
,
156 LeaveFullscreenMsgID
,
157 BuffersNotModifiedMsgID
,
158 BuffersModifiedMsgID
,
160 SetPreEditPositionMsgID
,
163 EnableAntialiasMsgID
,
164 DisableAntialiasMsgID
,
166 SetDocumentFilenameMsgID
,
167 OpenWithArgumentsMsgID
,
169 SetFullscreenColorMsgID
,
170 ShowFindReplaceDialogMsgID
,
172 ActivateKeyScriptMsgID
,
173 DeactivateKeyScriptMsgID
,
174 EnableImControlMsgID
,
175 DisableImControlMsgID
,
180 LastMsgID
// NOTE: MUST BE LAST MESSAGE IN ENUM!
184 #define DRAW_WIDE 0x40 /* draw wide text */
187 ClearAllDrawType
= 1,
193 SetCursorPosDrawType
,
194 DrawInvertedRectDrawType
,
198 MMInsertionPointBlock
,
199 MMInsertionPointHorizontal
,
200 MMInsertionPointVertical
,
201 MMInsertionPointHollow
,
202 MMInsertionPointVerticalRight
,
207 ToolbarLabelFlag
= 1,
209 ToolbarSizeRegularFlag
= 4
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
;
241 @interface
NSColor (MMExtras
)
242 + (NSColor
*)colorWithRgbInt
:(unsigned)rgb
;
243 + (NSColor
*)colorWithArgbInt
:(unsigned)argb
;
247 @interface
NSDictionary (MMExtras
)
248 + (id
)dictionaryWithData
:(NSData
*)data
;
249 - (NSData
*)dictionaryAsData
;
252 @interface
NSMutableDictionary (MMExtras
)
253 + (id
)dictionaryWithData
:(NSData
*)data
;
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
;
282 typedef int NSInteger
;
283 typedef unsigned int NSUInteger
;