22
22
*/
23
23
24
24
// This is the JavaScript code for bridging to native functionality
25
- // See brackets_extentions.mm for implementation of native methods.
25
+ // See appshell_extentions_[platform] for implementation of native methods.
26
26
//
27
27
// Note: All file native file i/o functions are synchronous, but are exposed
28
28
// here as asynchronous calls.
29
29
30
30
/*jslint vars: true, plusplus: true, devel: true, browser: true, nomen: true, indent: 4, forin: true, maxerr: 50, regexp: true */
31
31
/*global define, native */
32
32
33
- var brackets ;
34
- if ( ! brackets ) {
35
- brackets = { } ;
33
+ var appshell ;
34
+ if ( ! appshell ) {
35
+ appshell = { } ;
36
36
}
37
- if ( ! brackets . fs ) {
38
- brackets . fs = { } ;
37
+ if ( ! appshell . fs ) {
38
+ appshell . fs = { } ;
39
39
}
40
- if ( ! brackets . app ) {
41
- brackets . app = { } ;
40
+ if ( ! appshell . app ) {
41
+ appshell . app = { } ;
42
42
}
43
43
( function ( ) {
44
44
// Error values. These MUST be in sync with the error values
45
- // at the top of brackets_extensions .h.
45
+ // at the top of appshell_extensions_platform .h.
46
46
47
47
/**
48
48
* @constant No error.
49
49
*/
50
- brackets . fs . NO_ERROR = 0 ;
50
+ appshell . fs . NO_ERROR = 0 ;
51
51
52
52
/**
53
53
* @constant Unknown error occurred.
54
54
*/
55
- brackets . fs . ERR_UNKNOWN = 1 ;
55
+ appshell . fs . ERR_UNKNOWN = 1 ;
56
56
57
57
/**
58
58
* @constant Invalid parameters passed to function.
59
59
*/
60
- brackets . fs . ERR_INVALID_PARAMS = 2 ;
60
+ appshell . fs . ERR_INVALID_PARAMS = 2 ;
61
61
62
62
/**
63
63
* @constant File or directory was not found.
64
64
*/
65
- brackets . fs . ERR_NOT_FOUND = 3 ;
65
+ appshell . fs . ERR_NOT_FOUND = 3 ;
66
66
67
67
/**
68
68
* @constant File or directory could not be read.
69
69
*/
70
- brackets . fs . ERR_CANT_READ = 4 ;
70
+ appshell . fs . ERR_CANT_READ = 4 ;
71
71
72
72
/**
73
73
* @constant An unsupported encoding value was specified.
74
74
*/
75
- brackets . fs . ERR_UNSUPPORTED_ENCODING = 5 ;
75
+ appshell . fs . ERR_UNSUPPORTED_ENCODING = 5 ;
76
76
77
77
/**
78
78
* @constant File could not be written.
79
79
*/
80
- brackets . fs . ERR_CANT_WRITE = 6 ;
80
+ appshell . fs . ERR_CANT_WRITE = 6 ;
81
81
82
82
/**
83
83
* @constant Target directory is out of space. File could not be written.
84
84
*/
85
- brackets . fs . ERR_OUT_OF_SPACE = 7 ;
85
+ appshell . fs . ERR_OUT_OF_SPACE = 7 ;
86
86
87
87
/**
88
88
* @constant Specified path does not point to a file.
89
89
*/
90
- brackets . fs . ERR_NOT_FILE = 8 ;
90
+ appshell . fs . ERR_NOT_FILE = 8 ;
91
91
92
92
/**
93
93
* @constant Specified path does not point to a directory.
94
94
*/
95
- brackets . fs . ERR_NOT_DIRECTORY = 9 ;
95
+ appshell . fs . ERR_NOT_DIRECTORY = 9 ;
96
96
97
97
/**
98
98
* Display the OS File Open dialog, allowing the user to select
@@ -116,7 +116,7 @@ if (!brackets.app) {
116
116
* @return None. This is an asynchronous call that sends all return information to the callback.
117
117
*/
118
118
native function ShowOpenDialog ( ) ;
119
- brackets . fs . showOpenDialog = function ( allowMultipleSelection , chooseDirectory , title , initialPath , fileTypes , callback ) {
119
+ appshell . fs . showOpenDialog = function ( allowMultipleSelection , chooseDirectory , title , initialPath , fileTypes , callback ) {
120
120
setTimeout ( function ( ) {
121
121
ShowOpenDialog ( callback , allowMultipleSelection , chooseDirectory ,
122
122
title || 'Open' , initialPath || '' ,
@@ -141,7 +141,7 @@ if (!brackets.app) {
141
141
* @return None. This is an asynchronous call that sends all return information to the callback.
142
142
*/
143
143
native function ReadDir ( ) ;
144
- brackets . fs . readdir = function ( path , callback ) {
144
+ appshell . fs . readdir = function ( path , callback ) {
145
145
var resultString = ReadDir ( callback , path ) ;
146
146
} ;
147
147
@@ -160,7 +160,7 @@ if (!brackets.app) {
160
160
* @return None. This is an asynchronous call that sends all return information to the callback.
161
161
*/
162
162
native function GetFileModificationTime ( ) ;
163
- brackets . fs . stat = function ( path , callback ) {
163
+ appshell . fs . stat = function ( path , callback ) {
164
164
GetFileModificationTime ( function ( err , modtime , isDir ) {
165
165
callback ( err , {
166
166
isFile : function ( ) {
@@ -174,19 +174,32 @@ if (!brackets.app) {
174
174
} , path ) ;
175
175
} ;
176
176
177
+ native function CloseWindow ( ) ;
178
+ close = function ( ) {
179
+ CloseWindow ( ) ;
180
+ } ;
181
+
177
182
/**
178
183
* Quits native shell application
179
184
*/
180
185
native function QuitApplication ( ) ;
181
- brackets . app . quit = function ( ) {
186
+ appshell . app . quit = function ( ) {
182
187
QuitApplication ( ) ;
183
188
} ;
189
+
190
+ /**
191
+ * Abort a quit operation
192
+ */
193
+ native function AbortQuit ( ) ;
194
+ appshell . app . abortQuit = function ( ) {
195
+ AbortQuit ( ) ;
196
+ } ;
184
197
185
198
/**
186
199
* Invokes developer tools application
187
200
*/
188
201
native function ShowDeveloperTools ( ) ;
189
- brackets . app . showDeveloperTools = function ( ) {
202
+ appshell . app . showDeveloperTools = function ( ) {
190
203
ShowDeveloperTools ( ) ;
191
204
} ;
192
205
@@ -208,7 +221,7 @@ if (!brackets.app) {
208
221
* @return None. This is an asynchronous call that sends all return information to the callback.
209
222
*/
210
223
native function ReadFile ( ) ;
211
- brackets . fs . readFile = function ( path , encoding , callback ) {
224
+ appshell . fs . readFile = function ( path , encoding , callback ) {
212
225
ReadFile ( callback , path , encoding ) ;
213
226
} ;
214
227
@@ -230,7 +243,7 @@ if (!brackets.app) {
230
243
* @return None. This is an asynchronous call that sends all return information to the callback.
231
244
*/
232
245
native function WriteFile ( ) ;
233
- brackets . fs . writeFile = function ( path , data , encoding , callback ) {
246
+ appshell . fs . writeFile = function ( path , data , encoding , callback ) {
234
247
WriteFile ( callback , path , data , encoding ) ;
235
248
} ;
236
249
@@ -249,7 +262,7 @@ if (!brackets.app) {
249
262
* @return None. This is an asynchronous call that sends all return information to the callback.
250
263
*/
251
264
native function SetPosixPermissions ( ) ;
252
- brackets . fs . chmod = function ( path , mode , callback ) {
265
+ appshell . fs . chmod = function ( path , mode , callback ) {
253
266
SetPosixPermissions ( callback , path , mode ) ;
254
267
} ;
255
268
@@ -268,7 +281,7 @@ if (!brackets.app) {
268
281
* @return None. This is an asynchronous call that sends all return information to the callback.
269
282
*/
270
283
native function DeleteFileOrDirectory ( ) ;
271
- brackets . fs . unlink = function ( path , callback ) {
284
+ appshell . fs . unlink = function ( path , callback ) {
272
285
DeleteFileOrDirectory ( callback , path ) ;
273
286
} ;
274
287
@@ -277,7 +290,7 @@ if (!brackets.app) {
277
290
* was launched.
278
291
*/
279
292
native function GetElapsedMilliseconds ( ) ;
280
- brackets . app . getElapsedMilliseconds = function ( ) {
293
+ appshell . app . getElapsedMilliseconds = function ( ) {
281
294
return GetElapsedMilliseconds ( ) ;
282
295
}
283
296
@@ -296,7 +309,7 @@ if (!brackets.app) {
296
309
* @return None. This is an asynchronous call that sends all return information to the callback.
297
310
*/
298
311
native function OpenLiveBrowser ( ) ;
299
- brackets . app . openLiveBrowser = function ( url , enableRemoteDebugging , callback ) {
312
+ appshell . app . openLiveBrowser = function ( url , enableRemoteDebugging , callback ) {
300
313
/*
301
314
// enableRemoteDebugging flag is ignored on mac
302
315
setTimeout(function() {
@@ -320,9 +333,12 @@ if (!brackets.app) {
320
333
* @return None. This is an asynchronous call that sends all return information to the callback.
321
334
*/
322
335
native function CloseLiveBrowser ( ) ;
323
- brackets . app . closeLiveBrowser = function ( callback ) {
336
+ appshell . app . closeLiveBrowser = function ( callback ) {
324
337
/*
325
338
CloseLiveBrowser(callback);
326
339
*/
327
340
} ;
341
+
342
+ // Alias the appshell object to brackets. This is temporary and should be removed.
343
+ brackets = appshell ;
328
344
} ) ( ) ;
0 commit comments