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>
17 // This is the protocol MMBackend implements.
19 // Only processInput:data: is allowed to cause state changes in Vim; all other
20 // messages should only read the Vim state. (Note that setDialogReturn: is an
21 // exception to this rule; there really is no other way to deal with dialogs
22 // since they work with callbacks, so we cannot wait for them to return.)
24 // Be careful with messages with return type other than 'oneway void' -- there
25 // is a reply timeout set in MMAppController, if a message fails to get a
26 // response within the given timeout an exception will be thrown. Use
27 // @try/@catch/@finally to deal with timeouts.
29 @protocol MMBackendProtocol
30 - (oneway
void)processInput
:(int)msgid data
:(in bycopy NSData
*)data
;
31 - (oneway
void)processInputAndData
:(in bycopy NSArray
*)messages
;
32 - (oneway
void)setDialogReturn
:(in bycopy id
)obj
;
33 - (NSString
*)evaluateExpression
:(in bycopy NSString
*)expr
;
34 - (BOOL
)starRegisterToPasteboard
:(byref NSPasteboard
*)pboard
;
39 // This is the protocol MMVimController implements.
41 @protocol MMFrontendProtocol
42 - (oneway
void)processCommandQueue
:(in bycopy NSArray
*)queue
;
43 - (oneway
void)showSavePanelForDirectory
:(in bycopy NSString
*)dir
44 title
:(in bycopy NSString
*)title
46 - (oneway
void)presentDialogWithStyle
:(int)style
47 message
:(in bycopy NSString
*)message
48 informativeText
:(in bycopy NSString
*)text
49 buttonTitles
:(in bycopy NSArray
*)buttonTitles
50 textFieldString
:(in bycopy NSString
*)textFieldString
;
55 // This is the protocol MMAppController implements.
57 // It handles connections between MacVim and Vim.
59 @protocol MMAppProtocol
60 - (byref id
<MMFrontendProtocol
>)
61 connectBackend
:(byref in id
<MMBackendProtocol
>)backend
63 - (NSArray
*)serverList
;
67 @protocol MMVimServerProtocol
;
70 // The Vim client protocol (implemented by MMBackend).
72 // The client needs to keep track of server replies. Take a look at MMBackend
73 // if you want to implement this protocol in another program.
75 @protocol MMVimClientProtocol
76 - (oneway
void)addReply
:(in bycopy NSString
*)reply
77 server
:(in byref id
<MMVimServerProtocol
>)server
;
82 // The Vim server protocol (implemented by MMBackend).
84 // Note that addInput:client: is not asynchronous, because otherwise Vim might
85 // quit before the message has been passed (e.g. if --remote was used on the
88 @protocol MMVimServerProtocol
89 - (void)addInput
:(in bycopy NSString
*)input
90 client
:(in byref id
<MMVimClientProtocol
>)client
;
91 - (NSString
*)evaluateExpression
:(in bycopy NSString
*)expr
92 client
:(in byref id
<MMVimClientProtocol
>)client
;
98 // The following enum lists all messages that are passed between MacVim and
99 // Vim. These can be sent in processInput:data: and in processCommandQueue:.
102 // NOTE! This array must be updated whenever the enum below changes!
103 extern char *MessageStrings
[];
106 OpenVimWindowMsgID
= 1,
118 SetTextDimensionsMsgID
,
132 CreateScrollbarMsgID
,
133 DestroyScrollbarMsgID
,
135 SetScrollbarPositionMsgID
,
136 SetScrollbarThumbMsgID
,
141 SetDefaultColorsMsgID
,
150 AdjustLinespaceMsgID
,
153 EnterFullscreenMsgID
,
154 LeaveFullscreenMsgID
,
155 BuffersNotModifiedMsgID
,
156 BuffersModifiedMsgID
,
158 SetPreEditPositionMsgID
,
166 #define DRAW_WIDE 0x40 /* draw wide text */
169 ClearAllDrawType
= 1,
178 MMInsertionPointBlock
,
179 MMInsertionPointHorizontal
,
180 MMInsertionPointVertical
,
181 MMInsertionPointHollow
,
185 // NOTE! These values must be close to zero, or the 'add menu' message might
186 // fail to distinguish type from tag.
195 ToolbarLabelFlag
= 1,
197 ToolbarSizeRegularFlag
= 4
201 // NSUserDefaults keys
202 extern NSString
*MMNoWindowKey
;
203 extern NSString
*MMTabMinWidthKey
;
204 extern NSString
*MMTabMaxWidthKey
;
205 extern NSString
*MMTabOptimumWidthKey
;
206 extern NSString
*MMTextInsetLeftKey
;
207 extern NSString
*MMTextInsetRightKey
;
208 extern NSString
*MMTextInsetTopKey
;
209 extern NSString
*MMTextInsetBottomKey
;
210 extern NSString
*MMTerminateAfterLastWindowClosedKey
;
211 extern NSString
*MMTypesetterKey
;
212 extern NSString
*MMCellWidthMultiplierKey
;
213 extern NSString
*MMBaselineOffsetKey
;
214 extern NSString
*MMTranslateCtrlClickKey
;
215 extern NSString
*MMTopLeftPointKey
;
216 extern NSString
*MMOpenFilesInTabsKey
;
217 extern NSString
*MMNoFontSubstitutionKey
;
218 extern NSString
*MMLoginShellKey
;
219 extern NSString
*MMAtsuiRendererKey
;
220 extern NSString
*MMUntitledWindowKey
;
221 extern NSString
*MMTexturedWindowKey
;
223 // Enum for MMUntitledWindowKey
225 MMUntitledWindowNever
= 0,
226 MMUntitledWindowOnOpen
= 1,
227 MMUntitledWindowOnReopen
= 2,
228 MMUntitledWindowAlways
= 3
233 // Loads all fonts in the Resouces folder of the app bundle and returns a font
234 // container reference (which should be used to deactivate the loaded fonts).
235 ATSFontContainerRef
loadFonts();
237 // Functions to create command strings that can be sent to Vim as input.
238 NSString
*buildTabDropCommand(NSArray
*filenames
);
239 NSString
*buildSelectRangeCommand(NSRange range
);
240 NSString
*buildSearchTextCommand(NSString
*searchText
);
244 @interface
NSString (MMExtras
)
245 - (NSString
*)stringByEscapingSpecialFilenameCharacters
;
251 @interface
NSIndexSet (MMExtras
)
252 + (id
)indexSetWithVimList
:(NSString
*)list
;
258 @interface
NSColor (MMExtras
)
259 + (NSColor
*)colorWithRgbInt
:(unsigned)rgb
;
260 + (NSColor
*)colorWithArgbInt
:(unsigned)argb
;
266 // ODB Editor Suite Constants (taken from ODBEditorSuite.h)
267 #define keyFileSender 'FSnd'
268 #define keyFileSenderToken 'FTok'
269 #define keyFileCustomPath 'Burl'
270 #define kODBEditorSuite 'R*ch'
271 #define kAEModifiedFile 'FMod'
272 #define keyNewLocation 'New?'
273 #define kAEClosedFile 'FCls'
274 #define keySenderToken 'Tokn'
277 // MacVim Apple Event Constants
278 #define keyMMUntitledWindow 'MMuw'