Add IM control support
[MacVim/jjgod.git] / src / MacVim / MacVim.h
blobb07b33339f974e486a0c51db31624d422389c702
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,
162 #define DRAW_WIDE 0x40 /* draw wide text */
164 enum {
165 ClearAllDrawType = 1,
166 ClearBlockDrawType,
167 DeleteLinesDrawType,
168 DrawStringDrawType,
169 InsertLinesDrawType,
170 DrawCursorDrawType
173 enum {
174 MMInsertionPointBlock,
175 MMInsertionPointHorizontal,
176 MMInsertionPointVertical,
177 MMInsertionPointHollow,
181 // NOTE! These values must be close to zero, or the 'add menu' message might
182 // fail to distinguish type from tag.
183 enum {
184 MenuMenubarType = 0,
185 MenuPopupType,
186 MenuToolbarType
190 enum {
191 ToolbarLabelFlag = 1,
192 ToolbarIconFlag = 2,
193 ToolbarSizeRegularFlag = 4
197 // NSUserDefaults keys
198 extern NSString *MMNoWindowKey;
199 extern NSString *MMTabMinWidthKey;
200 extern NSString *MMTabMaxWidthKey;
201 extern NSString *MMTabOptimumWidthKey;
202 extern NSString *MMTextInsetLeftKey;
203 extern NSString *MMTextInsetRightKey;
204 extern NSString *MMTextInsetTopKey;
205 extern NSString *MMTextInsetBottomKey;
206 extern NSString *MMTerminateAfterLastWindowClosedKey;
207 extern NSString *MMTypesetterKey;
208 extern NSString *MMCellWidthMultiplierKey;
209 extern NSString *MMBaselineOffsetKey;
210 extern NSString *MMTranslateCtrlClickKey;
211 extern NSString *MMTopLeftPointKey;
212 extern NSString *MMOpenFilesInTabsKey;
213 extern NSString *MMNoFontSubstitutionKey;
214 extern NSString *MMLoginShellKey;
219 // Loads all fonts in the Resouces folder of the app bundle and returns a font
220 // container reference (which should be used to deactivate the loaded fonts).
221 ATSFontContainerRef loadFonts();
226 @interface NSString (MMExtras)
227 - (NSString *)stringByEscapingSpecialFilenameCharacters;
228 @end
233 @interface NSIndexSet (MMExtras)
234 + (id)indexSetWithVimList:(NSString *)list;
235 @end