File->Close sends performClose:
[MacVim.git] / src / MacVim / MacVim.h
blob98aee7036d7f7c3da08c131513bdbc038d9810da
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,
166 #define DRAW_WIDE 0x40 /* draw wide text */
168 enum {
169 ClearAllDrawType = 1,
170 ClearBlockDrawType,
171 DeleteLinesDrawType,
172 DrawStringDrawType,
173 InsertLinesDrawType,
174 DrawCursorDrawType
177 enum {
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.
187 enum {
188 MenuMenubarType = 0,
189 MenuPopupType,
190 MenuToolbarType
194 enum {
195 ToolbarLabelFlag = 1,
196 ToolbarIconFlag = 2,
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
224 enum {
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;
246 @end
251 @interface NSIndexSet (MMExtras)
252 + (id)indexSetWithVimList:(NSString *)list;
253 @end
258 @interface NSColor (MMExtras)
259 + (NSColor *)colorWithRgbInt:(unsigned)rgb;
260 + (NSColor *)colorWithArgbInt:(unsigned)argb;
261 @end
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'