forked from secca/Coda-Sass-Plug-in
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CodaPlugInsController.h
257 lines (140 loc) · 6.85 KB
/
CodaPlugInsController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#import <Cocoa/Cocoa.h>
////////////////////////////////////////////////////////////////////////////////
// This object is passed during initialization. You must register your //
// available functionality with one of the methods implemented by the //
// plug-in controller //
////////////////////////////////////////////////////////////////////////////////
@class CodaTextView;
@interface CodaPlugInsController : NSObject
{
NSMutableArray* plugins;
NSMutableDictionary* loadedMenuItemsDict;
}
////////////////////////////////////////////////////////////////////////////////
// The following methods are available in plug-in API version 2 and higher //
////////////////////////////////////////////////////////////////////////////////
// Returns the version of Coda that is hosting the plugin, such as "1.6.3"
- (NSString*)codaVersion:(id)sender;
// Returns to the plugin an abstract object representing the text view in Coda
// that currently has focus
- (CodaTextView*)focusedTextView:(id)sender;
// Exposes to the user a plug-in action (a menu item) with the given title, that
// will perform the given selector on the target
- (void)registerActionWithTitle:(NSString*)title target:(id)target selector:(SEL)selector;
// Returns 5 as of Coda 1.6.8.
- (int)apiVersion;
// Displays the provided HTML in a new tab.
- (void)displayHTMLString:(NSString*)html;
// Creates a new unsaved document in the frontmost Coda window and returns the Text View associated with it.
// The text view provided is auto-released, so the caller does not need to explicitly release it.
- (CodaTextView*)makeUntitledDocument;
// Similar to registerActionWithTitle:target:selector: but allows further customization of the registered
// menu items, including submenu title, represented object, keyEquivalent and custom plug-in name.
- (void)registerActionWithTitle:(NSString*)title
underSubmenuWithTitle:(NSString*)submenuTitle
target:(id)target
selector:(SEL)selector
representedObject:(id)repOb
keyEquivalent:(NSString*)keyEquivalent
pluginName:(NSString*)aName;
// Causes the frontmost Coda window to save all documents that have unsaved changes.
- (void)saveAll;
@end
//
// This is your hook to a text view in Coda. You can use this to provide
// manipulation of files.
//
@class StudioPlainTextEditor;
@interface CodaTextView : NSObject
{
StudioPlainTextEditor* editor;
}
////////////////////////////////////////////////////////////////////////////////
// The following methods are available in plug-in API version 2 and higher //
////////////////////////////////////////////////////////////////////////////////
// Inserts the given string at the insertion point
- (void)insertText:(NSString*)inText;
// Replaces characters in the given range with the given string
- (void)replaceCharactersInRange:(NSRange)aRange withString:(NSString *)aString;
// Returns the range of currently selected characters
- (NSRange)selectedRange;
// Returns the currently selected text, or nil if none
- (NSString*)selectedText;
// Selects the given character range
- (void)setSelectedRange:(NSRange)range;
// Returns a string containing the entire content of the line that the insertion
// point is on
- (NSString*)currentLine;
// Returns the line number corresponding to the location of the insertion point
- (unsigned int)currentLineNumber;
// Deletes the selected text range
- (void)deleteSelection;
// Returns the current line ending of the file
- (NSString*)lineEnding;
// Returns the character range of the entire line the insertion point
// is on
- (NSRange)rangeOfCurrentLine;
// StartOfLine returns the character index (relative to the beginning of the
// document) of the start of the line the insertion point is on
- (unsigned int)startOfLine;
// String returns the entire document as a plain string
- (NSString*)string;
// Returns the specified ranged substring of the entire document
- (NSString*)stringWithRange:(NSRange)range;
// Returns the width of tabs as spaces
- (int)tabWidth;
// Returns the range of the word previous to the insertion point
- (NSRange)previousWordRange;
// UsesTabs returns if the editor is currently uses tabs instead of spaces for
// indentation
- (BOOL)usesTabs;
// saves the document you are working on
- (void)save;
// Saves the document you are working on to a local path, returns YES if
// successful
- (BOOL)saveToPath:(NSString*)aPath;
// Allows for multiple text manipulations to be considered one "undo/redo"
// operation
- (void)beginUndoGrouping;
- (void)endUndoGrouping;
// Returns the window the editor is located in (useful for showing sheets)
- (NSWindow*)window;
// Returns the path to the text view's file (may be nil for unsaved documents)
- (NSString*)path;
// Returns the root local path of the site if specified (nil if unspecified in
// the site or site is not loaded)
- (NSString*)siteLocalPath;
////////////////////////////////////////////////////////////////////////////////
// The following methods are available in plug-in API version 3 and higher //
////////////////////////////////////////////////////////////////////////////////
// Returns the range of the word containing the insertion point
- (NSRange)currentWordRange;
////////////////////////////////////////////////////////////////////////////////
// The following methods are available in plug-in API version 4 and higher //
////////////////////////////////////////////////////////////////////////////////
// Returns the URL of the site if specified (nil if unspecified in
// the site or site is not loaded)
- (NSString*)siteURL;
// Returns the local URL of the site if specified (nil if unspecified in
// the site or site is not loaded)
- (NSString*)siteLocalURL;
// Returns the root remote path of the site if specified (nil if unspecified in
// the site or site is not loaded)
- (NSString*)siteRemotePath;
// Returns the nickname of the site if specified (nil if site is not loaded)
- (NSString*)siteNickname;
////////////////////////////////////////////////////////////////////////////////
// The following methods are available in plug-in API version 5 and higher //
////////////////////////////////////////////////////////////////////////////////
- (NSStringEncoding)encoding;
@end
////////////////////////////////////////////////////////////////////////////////
// Your plug-in's principal class must conform to this protocol //
////////////////////////////////////////////////////////////////////////////////
@protocol CodaPlugIn
// Default init'r for your plug-in's principal class. Passes a reference to your
// bundle and the singelton instance of the CodaPlugInsController
- (id)initWithPlugInController:(CodaPlugInsController*)aController bundle:(NSBundle*)yourBundle;
// Return a name to display in the plug-ins menu
- (NSString*)name;
@end