Open and save dialogs track the Vim pwd
[MacVim.git] / src / MacVim / MacVim.h
blobeb94dd9cbd7f4aa3e0c5d63be8664c0a06fb6dc8
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>
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;
35 @end
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
45 saving:(int)saving;
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;
51 @end
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
62 pid:(int)pid;
63 - (NSArray *)serverList;
64 @end
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;
78 @end
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
86 // command line).
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;
93 @end
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[];
105 enum {
106 OpenVimWindowMsgID = 1,
107 InsertTextMsgID,
108 KeyDownMsgID,
109 CmdKeyMsgID,
110 BatchDrawMsgID,
111 SelectTabMsgID,
112 CloseTabMsgID,
113 AddNewTabMsgID,
114 DraggedTabMsgID,
115 UpdateTabBarMsgID,
116 ShowTabBarMsgID,
117 HideTabBarMsgID,
118 SetTextDimensionsMsgID,
119 SetWindowTitleMsgID,
120 ScrollWheelMsgID,
121 MouseDownMsgID,
122 MouseUpMsgID,
123 MouseDraggedMsgID,
124 FlushQueueMsgID,
125 AddMenuMsgID,
126 AddMenuItemMsgID,
127 RemoveMenuItemMsgID,
128 EnableMenuItemMsgID,
129 ExecuteMenuMsgID,
130 ShowToolbarMsgID,
131 ToggleToolbarMsgID,
132 CreateScrollbarMsgID,
133 DestroyScrollbarMsgID,
134 ShowScrollbarMsgID,
135 SetScrollbarPositionMsgID,
136 SetScrollbarThumbMsgID,
137 ScrollbarEventMsgID,
138 SetFontMsgID,
139 SetWideFontMsgID,
140 VimShouldCloseMsgID,
141 SetDefaultColorsMsgID,
142 ExecuteActionMsgID,
143 DropFilesMsgID,
144 DropStringMsgID,
145 ShowPopupMenuMsgID,
146 GotFocusMsgID,
147 LostFocusMsgID,
148 MouseMovedMsgID,
149 SetMouseShapeMsgID,
150 AdjustLinespaceMsgID,
151 ActivateMsgID,
152 SetServerNameMsgID,
153 EnterFullscreenMsgID,
154 LeaveFullscreenMsgID,
155 BuffersNotModifiedMsgID,
156 BuffersModifiedMsgID,
157 AddInputMsgID,
158 SetPreEditPositionMsgID,
159 TerminateNowMsgID,
160 ODBEditMsgID,
161 XcodeModMsgID,
162 LiveResizeMsgID,
163 EnableAntialiasMsgID,
164 DisableAntialiasMsgID,
165 SetVimStateMsgID,
169 #define DRAW_WIDE 0x40 /* draw wide text */
171 enum {
172 ClearAllDrawType = 1,
173 ClearBlockDrawType,
174 DeleteLinesDrawType,
175 DrawStringDrawType,
176 InsertLinesDrawType,
177 DrawCursorDrawType,
178 SetCursorPosDrawType,
181 enum {
182 MMInsertionPointBlock,
183 MMInsertionPointHorizontal,
184 MMInsertionPointVertical,
185 MMInsertionPointHollow,
189 // NOTE! These values must be close to zero, or the 'add menu' message might
190 // fail to distinguish type from tag.
191 enum {
192 MenuMenubarType = 0,
193 MenuPopupType,
194 MenuToolbarType
198 enum {
199 ToolbarLabelFlag = 1,
200 ToolbarIconFlag = 2,
201 ToolbarSizeRegularFlag = 4
205 // NSUserDefaults keys
206 extern NSString *MMNoWindowKey;
207 extern NSString *MMTabMinWidthKey;
208 extern NSString *MMTabMaxWidthKey;
209 extern NSString *MMTabOptimumWidthKey;
210 extern NSString *MMTextInsetLeftKey;
211 extern NSString *MMTextInsetRightKey;
212 extern NSString *MMTextInsetTopKey;
213 extern NSString *MMTextInsetBottomKey;
214 extern NSString *MMTerminateAfterLastWindowClosedKey;
215 extern NSString *MMTypesetterKey;
216 extern NSString *MMCellWidthMultiplierKey;
217 extern NSString *MMBaselineOffsetKey;
218 extern NSString *MMTranslateCtrlClickKey;
219 extern NSString *MMTopLeftPointKey;
220 extern NSString *MMOpenFilesInTabsKey;
221 extern NSString *MMNoFontSubstitutionKey;
222 extern NSString *MMLoginShellKey;
223 extern NSString *MMAtsuiRendererKey;
224 extern NSString *MMUntitledWindowKey;
225 extern NSString *MMTexturedWindowKey;
226 extern NSString *MMZoomBothKey;
227 extern NSString *MMCurrentPreferencePaneKey;
228 extern NSString *MMLoginShellCommandKey;
229 extern NSString *MMLoginShellArgumentKey;
230 extern NSString *MMDialogsTrackPwdKey;
232 // Enum for MMUntitledWindowKey
233 enum {
234 MMUntitledWindowNever = 0,
235 MMUntitledWindowOnOpen = 1,
236 MMUntitledWindowOnReopen = 2,
237 MMUntitledWindowAlways = 3
243 // Vim pasteboard type (holds motion type + string)
244 extern NSString *VimPBoardType;
248 // Loads all fonts in the Resouces folder of the app bundle and returns a font
249 // container reference (which should be used to deactivate the loaded fonts).
250 ATSFontContainerRef loadFonts();
252 // Functions to create command strings that can be sent to Vim as input.
253 NSString *buildTabDropCommand(NSArray *filenames);
254 NSString *buildSelectRangeCommand(NSRange range);
255 NSString *buildSearchTextCommand(NSString *searchText);
259 @interface NSString (MMExtras)
260 - (NSString *)stringByEscapingSpecialFilenameCharacters;
261 @end
266 @interface NSIndexSet (MMExtras)
267 + (id)indexSetWithVimList:(NSString *)list;
268 @end
273 @interface NSColor (MMExtras)
274 + (NSColor *)colorWithRgbInt:(unsigned)rgb;
275 + (NSColor *)colorWithArgbInt:(unsigned)argb;
276 @end
281 @interface NSDocumentController (MMExtras)
282 - (void)noteNewRecentFilePath:(NSString *)path;
283 @end
288 @interface NSDictionary (MMExtras)
289 + (id)dictionaryWithData:(NSData *)data;
290 - (NSData *)dictionaryAsData;
291 @end
296 // ODB Editor Suite Constants (taken from ODBEditorSuite.h)
297 #define keyFileSender 'FSnd'
298 #define keyFileSenderToken 'FTok'
299 #define keyFileCustomPath 'Burl'
300 #define kODBEditorSuite 'R*ch'
301 #define kAEModifiedFile 'FMod'
302 #define keyNewLocation 'New?'
303 #define kAEClosedFile 'FCls'
304 #define keySenderToken 'Tokn'
307 // MacVim Apple Event Constants
308 #define keyMMUntitledWindow 'MMuw'