-
Notifications
You must be signed in to change notification settings - Fork 0
/
Safari.h
262 lines (177 loc) · 9.64 KB
/
Safari.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
256
257
258
259
260
261
/*
* Safari.h
*/
#import <AppKit/AppKit.h>
#import <ScriptingBridge/ScriptingBridge.h>
@class SafariItem, SafariApplication, SafariColor, SafariDocument, SafariWindow, SafariAttributeRun, SafariCharacter, SafariParagraph, SafariText, SafariAttachment, SafariWord, SafariTab, SafariPrintSettings;
enum SafariSavo {
SafariSavoAsk = 'ask ' /* Ask the user whether or not to save the file. */,
SafariSavoNo = 'no ' /* Do not save the file. */,
SafariSavoYes = 'yes ' /* Save the file. */
};
typedef enum SafariSavo SafariSavo;
enum SafariEnum {
SafariEnumStandard = 'lwst' /* Standard PostScript error handling */,
SafariEnumDetailed = 'lwdt' /* print a detailed report of PostScript errors */
};
typedef enum SafariEnum SafariEnum;
@protocol SafariGenericMethods
- (void) closeSaving:(SafariSavo)saving savingIn:(NSURL *)savingIn; // Close an object.
- (void) delete; // Delete an object.
- (void) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties; // Copy object(s) and put the copies at a new location.
- (BOOL) exists; // Verify if an object exists.
- (void) moveTo:(SBObject *)to; // Move object(s) to a new location.
- (void) saveAs:(NSString *)as in:(NSURL *)in_; // Save an object.
- (void) emailContentsOf:(SafariTab *)of; // Emails the contents of a tab.
- (void) searchTheWebFor:(NSString *)for_ in:(SafariTab *)in_; // Searches the web using Safari's current search provider.
@end
/*
* Standard Suite
*/
// A scriptable object.
@interface SafariItem : SBObject <SafariGenericMethods>
@property (copy) NSDictionary *properties; // All of the object's properties.
@end
// An application's top level scripting object.
@interface SafariApplication : SBApplication
- (SBElementArray<SafariDocument *> *) documents;
- (SBElementArray<SafariWindow *> *) windows;
@property (readonly) BOOL frontmost; // Is this the frontmost (active) application?
@property (copy, readonly) NSString *name; // The name of the application.
@property (copy, readonly) NSString *version; // The version of the application.
- (SafariDocument *) open:(NSURL *)x; // Open an object.
- (void) print:(NSURL *)x printDialog:(BOOL)printDialog withProperties:(SafariPrintSettings *)withProperties; // Print an object.
- (void) quitSaving:(SafariSavo)saving; // Quit an application.
- (void) addReadingListItem:(NSString *)x andPreviewText:(NSString *)andPreviewText withTitle:(NSString *)withTitle; // Add a new Reading List item with the given URL. Allows a custom title and preview text to be specified.
- (id) doJavaScript:(NSString *)x in:(SafariTab *)in_; // Applies a string of JavaScript code to a document.
- (void) showBookmarks; // Shows Safari's bookmarks.
@end
// A color.
@interface SafariColor : SafariItem
@end
// A document.
@interface SafariDocument : SafariItem
@property (readonly) BOOL modified; // Has the document been modified since the last save?
@property (copy) NSString *name; // The document's name.
@property (copy) NSString *path; // The document's path.
@end
// A window.
@interface SafariWindow : SafariItem
@property NSRect bounds; // The bounding rectangle of the window.
@property (readonly) BOOL closeable; // Whether the window has a close box.
@property (copy, readonly) SafariDocument *document; // The document whose contents are being displayed in the window.
@property (readonly) BOOL floating; // Whether the window floats.
- (NSInteger) id; // The unique identifier of the window.
@property NSInteger index; // The index of the window, ordered front to back.
@property (readonly) BOOL miniaturizable; // Whether the window can be miniaturized.
@property BOOL miniaturized; // Whether the window is currently miniaturized.
@property (readonly) BOOL modal; // Whether the window is the application's current modal window.
@property (copy) NSString *name; // The full title of the window.
@property (readonly) BOOL resizable; // Whether the window can be resized.
@property (readonly) BOOL titled; // Whether the window has a title bar.
@property BOOL visible; // Whether the window is currently visible.
@property (readonly) BOOL zoomable; // Whether the window can be zoomed.
@property BOOL zoomed; // Whether the window is currently zoomed.
@end
/*
* Text Suite
*/
// This subdivides the text into chunks that all have the same attributes.
@interface SafariAttributeRun : SafariItem
- (SBElementArray<SafariAttachment *> *) attachments;
- (SBElementArray<SafariAttributeRun *> *) attributeRuns;
- (SBElementArray<SafariCharacter *> *) characters;
- (SBElementArray<SafariParagraph *> *) paragraphs;
- (SBElementArray<SafariWord *> *) words;
@property (copy) NSColor *color; // The color of the first character.
@property (copy) NSString *font; // The name of the font of the first character.
@property NSInteger size; // The size in points of the first character.
@end
// This subdivides the text into characters.
@interface SafariCharacter : SafariItem
- (SBElementArray<SafariAttachment *> *) attachments;
- (SBElementArray<SafariAttributeRun *> *) attributeRuns;
- (SBElementArray<SafariCharacter *> *) characters;
- (SBElementArray<SafariParagraph *> *) paragraphs;
- (SBElementArray<SafariWord *> *) words;
@property (copy) NSColor *color; // The color of the first character.
@property (copy) NSString *font; // The name of the font of the first character.
@property NSInteger size; // The size in points of the first character.
@end
// This subdivides the text into paragraphs.
@interface SafariParagraph : SafariItem
- (SBElementArray<SafariAttachment *> *) attachments;
- (SBElementArray<SafariAttributeRun *> *) attributeRuns;
- (SBElementArray<SafariCharacter *> *) characters;
- (SBElementArray<SafariParagraph *> *) paragraphs;
- (SBElementArray<SafariWord *> *) words;
@property (copy) NSColor *color; // The color of the first character.
@property (copy) NSString *font; // The name of the font of the first character.
@property NSInteger size; // The size in points of the first character.
@end
// Rich (styled) text
@interface SafariText : SafariItem
- (SBElementArray<SafariAttachment *> *) attachments;
- (SBElementArray<SafariAttributeRun *> *) attributeRuns;
- (SBElementArray<SafariCharacter *> *) characters;
- (SBElementArray<SafariParagraph *> *) paragraphs;
- (SBElementArray<SafariWord *> *) words;
@property (copy) NSColor *color; // The color of the first character.
@property (copy) NSString *font; // The name of the font of the first character.
@property NSInteger size; // The size in points of the first character.
- (void) addReadingListItemAndPreviewText:(NSString *)andPreviewText withTitle:(NSString *)withTitle; // Add a new Reading List item with the given URL. Allows a custom title and preview text to be specified.
- (id) doJavaScriptIn:(SafariTab *)in_; // Applies a string of JavaScript code to a document.
@end
// Represents an inline text attachment. This class is used mainly for make commands.
@interface SafariAttachment : SafariText
@property (copy) NSString *fileName; // The path to the file for the attachment
@end
// This subdivides the text into words.
@interface SafariWord : SafariItem
- (SBElementArray<SafariAttachment *> *) attachments;
- (SBElementArray<SafariAttributeRun *> *) attributeRuns;
- (SBElementArray<SafariCharacter *> *) characters;
- (SBElementArray<SafariParagraph *> *) paragraphs;
- (SBElementArray<SafariWord *> *) words;
@property (copy) NSColor *color; // The color of the first character.
@property (copy) NSString *font; // The name of the font of the first character.
@property NSInteger size; // The size in points of the first character.
@end
/*
* Safari suite
*/
// A Safari document representing the active tab in a window.
@interface SafariDocument (SafariSuite)
@property (copy, readonly) NSString *source; // The HTML source of the web page currently loaded in the document.
@property (copy, readonly) SafariText *text; // The text of the web page currently loaded in the document. Modifications to text aren't reflected on the web page.
@property (copy) NSString *URL; // The current URL of the document.
@end
// A Safari window tab.
@interface SafariTab : SafariItem
@property (readonly) NSInteger index; // The index of the tab, ordered left to right.
@property (copy, readonly) NSString *name; // The name of the tab.
@property (copy, readonly) NSString *source; // The HTML source of the web page currently loaded in the tab.
@property (copy, readonly) SafariText *text; // The text of the web page currently loaded in the tab. Modifications to text aren't reflected on the web page.
@property (copy) NSString *URL; // The current URL of the tab.
@property (readonly) BOOL visible; // Whether the tab is currently visible.
@end
// A Safari window.
@interface SafariWindow (SafariSuite)
- (SBElementArray<SafariTab *> *) tabs;
@property (copy) SafariTab *currentTab; // The current tab.
@end
/*
* Type Definitions
*/
@interface SafariPrintSettings : SBObject <SafariGenericMethods>
@property NSInteger copies; // the number of copies of a document to be printed
@property BOOL collating; // Should printed copies be collated?
@property NSInteger startingPage; // the first page of the document to be printed
@property NSInteger endingPage; // the last page of the document to be printed
@property NSInteger pagesAcross; // number of logical pages laid across a physical page
@property NSInteger pagesDown; // number of logical pages laid out down a physical page
@property (copy) NSDate *requestedPrintTime; // the time at which the desktop printer should print the document
@property SafariEnum errorHandling; // how errors are handled
@property (copy) NSString *faxNumber; // for fax number
@property (copy) NSString *targetPrinter; // for target printer
@end