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)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
;
45 // This is the protocol MMVimController implements.
47 // Be very careful if you want to add methods to this protocol. Since DO
48 // messages may arrive while Cocoa is in the middle of processing some other
49 // message be sure to consider reentrancy issues. Look at processCommandQueue:
50 // to see an example of how to deal with this.
52 @protocol MMFrontendProtocol
53 - (oneway
void)processCommandQueue
:(in bycopy NSArray
*)queue
;
54 - (oneway
void)showSavePanelWithAttributes
:(in bycopy NSDictionary
*)attr
;
55 - (oneway
void)presentDialogWithAttributes
:(in bycopy NSDictionary
*)attr
;
60 // This is the protocol MMAppController implements.
62 // It handles connections between MacVim and Vim.
64 @protocol MMAppProtocol
65 - (byref id
<MMFrontendProtocol
>)
66 connectBackend
:(byref in id
<MMBackendProtocol
>)backend
68 - (NSArray
*)serverList
;
72 @protocol MMVimServerProtocol
;
75 // The Vim client protocol (implemented by MMBackend).
77 // The client needs to keep track of server replies. Take a look at MMBackend
78 // if you want to implement this protocol in another program.
80 @protocol MMVimClientProtocol
81 - (oneway
void)addReply
:(in bycopy NSString
*)reply
82 server
:(in byref id
<MMVimServerProtocol
>)server
;
87 // The Vim server protocol (implemented by MMBackend).
89 // Note that addInput:client: is not asynchronous, because otherwise Vim might
90 // quit before the message has been passed (e.g. if --remote was used on the
93 @protocol MMVimServerProtocol
94 - (void)addInput
:(in bycopy NSString
*)input
95 client
:(in byref id
<MMVimClientProtocol
>)client
;
96 - (NSString
*)evaluateExpression
:(in bycopy NSString
*)expr
97 client
:(in byref id
<MMVimClientProtocol
>)client
;
103 // The following enum lists all messages that are passed between MacVim and
104 // Vim. These can be sent in processInput:data: and in processCommandQueue:.
107 // NOTE! This array must be updated whenever the enum below changes!
108 extern char *MessageStrings
[];
111 OpenVimWindowMsgID
= 1,
123 SetTextDimensionsMsgID
,
137 CreateScrollbarMsgID
,
138 DestroyScrollbarMsgID
,
140 SetScrollbarPositionMsgID
,
141 SetScrollbarThumbMsgID
,
146 SetDefaultColorsMsgID
,
155 AdjustLinespaceMsgID
,
158 EnterFullscreenMsgID
,
159 LeaveFullscreenMsgID
,
160 BuffersNotModifiedMsgID
,
161 BuffersModifiedMsgID
,
163 SetPreEditPositionMsgID
,
168 EnableAntialiasMsgID
,
169 DisableAntialiasMsgID
,
171 SetDocumentFilenameMsgID
,
175 #define DRAW_WIDE 0x40 /* draw wide text */
178 ClearAllDrawType
= 1,
184 SetCursorPosDrawType
,
185 DrawInvertedRectDrawType
,
189 MMInsertionPointBlock
,
190 MMInsertionPointHorizontal
,
191 MMInsertionPointVertical
,
192 MMInsertionPointHollow
,
193 MMInsertionPointVerticalRight
,
198 ToolbarLabelFlag
= 1,
200 ToolbarSizeRegularFlag
= 4
203 // Argument used to stop MacVim from opening an empty window on startup
204 // (techincally this is a user default but should not be used as such).
205 extern NSString
*MMNoWindowKey
;
207 // Vim pasteboard type (holds motion type + string)
208 extern NSString
*VimPBoardType
;
212 // Loads all fonts in the Resouces folder of the app bundle and returns a font
213 // container reference (which should be used to deactivate the loaded fonts).
214 ATSFontContainerRef
loadFonts();
218 @interface
NSString (MMExtras
)
219 - (NSString
*)stringByEscapingSpecialFilenameCharacters
;
223 @interface
NSColor (MMExtras
)
224 + (NSColor
*)colorWithRgbInt
:(unsigned)rgb
;
225 + (NSColor
*)colorWithArgbInt
:(unsigned)argb
;
229 @interface
NSDictionary (MMExtras
)
230 + (id
)dictionaryWithData
:(NSData
*)data
;
231 - (NSData
*)dictionaryAsData
;
237 // ODB Editor Suite Constants (taken from ODBEditorSuite.h)
238 #define keyFileSender 'FSnd'
239 #define keyFileSenderToken 'FTok'
240 #define keyFileCustomPath 'Burl'
241 #define kODBEditorSuite 'R*ch'
242 #define kAEModifiedFile 'FMod'
243 #define keyNewLocation 'New?'
244 #define kAEClosedFile 'FCls'
245 #define keySenderToken 'Tokn'
248 // MacVim Apple Event Constants
249 #define keyMMUntitledWindow 'MMuw'