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 @protocol MMAppProtocol
52 - (unsigned)connectBackend
:(byref in id
<MMBackendProtocol
>)backend
54 - (oneway
void)processInput
:(in bycopy NSArray
*)queue
55 forIdentifier
:(unsigned)identifier
;
56 - (NSArray
*)serverList
;
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
;
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
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
;
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
[];
113 SetTextDimensionsMsgID
,
115 SetTextDimensionsReplyMsgID
,
129 CreateScrollbarMsgID
,
130 DestroyScrollbarMsgID
,
132 SetScrollbarPositionMsgID
,
133 SetScrollbarThumbMsgID
,
138 SetDefaultColorsMsgID
,
147 AdjustLinespaceMsgID
,
150 EnterFullscreenMsgID
,
151 LeaveFullscreenMsgID
,
152 BuffersNotModifiedMsgID
,
153 BuffersModifiedMsgID
,
155 SetPreEditPositionMsgID
,
158 EnableAntialiasMsgID
,
159 DisableAntialiasMsgID
,
161 SetDocumentFilenameMsgID
,
162 OpenWithArgumentsMsgID
,
164 SetFullscreenColorMsgID
,
165 ShowFindReplaceDialogMsgID
,
168 DeactivateKeyScriptID
,
174 #define DRAW_WIDE 0x40 /* draw wide text */
177 ClearAllDrawType
= 1,
183 SetCursorPosDrawType
,
184 DrawInvertedRectDrawType
,
188 MMInsertionPointBlock
,
189 MMInsertionPointHorizontal
,
190 MMInsertionPointVertical
,
191 MMInsertionPointHollow
,
192 MMInsertionPointVerticalRight
,
197 ToolbarLabelFlag
= 1,
199 ToolbarSizeRegularFlag
= 4
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
;
224 @interface
NSColor (MMExtras
)
225 + (NSColor
*)colorWithRgbInt
:(unsigned)rgb
;
226 + (NSColor
*)colorWithArgbInt
:(unsigned)argb
;
230 @interface
NSDictionary (MMExtras
)
231 + (id
)dictionaryWithData
:(NSData
*)data
;
232 - (NSData
*)dictionaryAsData
;
235 @interface
NSMutableDictionary (MMExtras
)
236 + (id
)dictionaryWithData
:(NSData
*)data
;
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
;
265 typedef int NSInteger
;
266 typedef unsigned int NSUInteger
;