Change a few toolbar icons
[MacVim.git] / src / MacVim / MacVim.h
blobaf06826d13297cee061be01351fbd1d1bb3aed33
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>
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;
42 @end
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;
56 @end
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
67 pid:(int)pid;
68 - (NSArray *)serverList;
69 @end
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;
83 @end
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
91 // command line).
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;
98 @end
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[];
110 enum {
111 OpenVimWindowMsgID = 1,
112 InsertTextMsgID,
113 KeyDownMsgID,
114 CmdKeyMsgID,
115 BatchDrawMsgID,
116 SelectTabMsgID,
117 CloseTabMsgID,
118 AddNewTabMsgID,
119 DraggedTabMsgID,
120 UpdateTabBarMsgID,
121 ShowTabBarMsgID,
122 HideTabBarMsgID,
123 SetTextDimensionsMsgID,
124 SetWindowTitleMsgID,
125 ScrollWheelMsgID,
126 MouseDownMsgID,
127 MouseUpMsgID,
128 MouseDraggedMsgID,
129 FlushQueueMsgID,
130 AddMenuMsgID,
131 AddMenuItemMsgID,
132 RemoveMenuItemMsgID,
133 EnableMenuItemMsgID,
134 ExecuteMenuMsgID,
135 ShowToolbarMsgID,
136 ToggleToolbarMsgID,
137 CreateScrollbarMsgID,
138 DestroyScrollbarMsgID,
139 ShowScrollbarMsgID,
140 SetScrollbarPositionMsgID,
141 SetScrollbarThumbMsgID,
142 ScrollbarEventMsgID,
143 SetFontMsgID,
144 SetWideFontMsgID,
145 VimShouldCloseMsgID,
146 SetDefaultColorsMsgID,
147 ExecuteActionMsgID,
148 DropFilesMsgID,
149 DropStringMsgID,
150 ShowPopupMenuMsgID,
151 GotFocusMsgID,
152 LostFocusMsgID,
153 MouseMovedMsgID,
154 SetMouseShapeMsgID,
155 AdjustLinespaceMsgID,
156 ActivateMsgID,
157 SetServerNameMsgID,
158 EnterFullscreenMsgID,
159 LeaveFullscreenMsgID,
160 BuffersNotModifiedMsgID,
161 BuffersModifiedMsgID,
162 AddInputMsgID,
163 SetPreEditPositionMsgID,
164 TerminateNowMsgID,
165 ODBEditMsgID,
166 XcodeModMsgID,
167 LiveResizeMsgID,
168 EnableAntialiasMsgID,
169 DisableAntialiasMsgID,
170 SetVimStateMsgID,
171 SetDocumentFilenameMsgID,
175 #define DRAW_WIDE 0x40 /* draw wide text */
177 enum {
178 ClearAllDrawType = 1,
179 ClearBlockDrawType,
180 DeleteLinesDrawType,
181 DrawStringDrawType,
182 InsertLinesDrawType,
183 DrawCursorDrawType,
184 SetCursorPosDrawType,
185 DrawInvertedRectDrawType,
188 enum {
189 MMInsertionPointBlock,
190 MMInsertionPointHorizontal,
191 MMInsertionPointVertical,
192 MMInsertionPointHollow,
193 MMInsertionPointVerticalRight,
197 enum {
198 ToolbarLabelFlag = 1,
199 ToolbarIconFlag = 2,
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;
220 @end
223 @interface NSColor (MMExtras)
224 + (NSColor *)colorWithRgbInt:(unsigned)rgb;
225 + (NSColor *)colorWithArgbInt:(unsigned)argb;
226 @end
229 @interface NSDictionary (MMExtras)
230 + (id)dictionaryWithData:(NSData *)data;
231 - (NSData *)dictionaryAsData;
232 @end
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'