@@ -14,7 +14,7 @@ + (id)getFactorySettingsForFileType: (NSString *)filetype
14
14
{
15
15
static FileSettings *fsdefault_py, *fsdefault_pyw, *fsdefault_pyc;
16
16
FileSettings **curdefault;
17
-
17
+
18
18
if ([filetype isEqualToString: @" Python Script" ]) {
19
19
curdefault = &fsdefault_py;
20
20
} else if ([filetype isEqualToString: @" Python GUI Script" ]) {
@@ -36,7 +36,7 @@ + (id)getDefaultsForFileType: (NSString *)filetype
36
36
{
37
37
static FileSettings *default_py, *default_pyw, *default_pyc;
38
38
FileSettings **curdefault;
39
-
39
+
40
40
if ([filetype isEqualToString: @" Python Script" ]) {
41
41
curdefault = &default_py;
42
42
} else if ([filetype isEqualToString: @" Python GUI Script" ]) {
@@ -57,7 +57,7 @@ + (id)getDefaultsForFileType: (NSString *)filetype
57
57
+ (id )newSettingsForFileType : (NSString *)filetype
58
58
{
59
59
FileSettings *cur;
60
-
60
+
61
61
cur = [FileSettings new ];
62
62
[cur initForFileType: filetype];
63
63
return [cur retain ];
@@ -67,7 +67,7 @@ - (id)initWithFileSettings: (FileSettings *)source
67
67
{
68
68
self = [super init ];
69
69
if (!self) return self;
70
-
70
+
71
71
interpreter = [source->interpreter retain ];
72
72
honourhashbang = source->honourhashbang ;
73
73
debug = source->debug ;
@@ -81,36 +81,30 @@ - (id)initWithFileSettings: (FileSettings *)source
81
81
with_terminal = source->with_terminal ;
82
82
prefskey = source->prefskey ;
83
83
if (prefskey) [prefskey retain ];
84
-
84
+
85
85
return self;
86
86
}
87
87
88
88
- (id )initForFileType : (NSString *)filetype
89
89
{
90
90
FileSettings *defaults;
91
-
91
+
92
92
defaults = [FileSettings getDefaultsForFileType: filetype];
93
93
self = [self initWithFileSettings: defaults];
94
94
origsource = [defaults retain ];
95
95
return self;
96
96
}
97
97
98
- // - (id)init
99
- // {
100
- // self = [self initForFileType: @"Python Script"];
101
- // return self;
102
- // }
103
-
104
98
- (id )initForFSDefaultFileType : (NSString *)filetype
105
99
{
106
100
int i;
107
101
NSString *filename;
108
102
NSDictionary *dict;
109
103
static NSDictionary *factorySettings;
110
-
104
+
111
105
self = [super init ];
112
106
if (!self) return self;
113
-
107
+
114
108
if (factorySettings == NULL ) {
115
109
NSBundle *bdl = [NSBundle mainBundle ];
116
110
NSString *path = [ bdl pathForResource: @" factorySettings"
@@ -149,18 +143,18 @@ - (void)applyUserDefaults: (NSString *)filetype
149
143
{
150
144
NSUserDefaults *defaults;
151
145
NSDictionary *dict;
152
-
146
+
153
147
defaults = [NSUserDefaults standardUserDefaults ];
154
148
dict = [defaults dictionaryForKey: filetype];
155
149
if (!dict)
156
150
return ;
157
151
[self applyValuesFromDict: dict];
158
152
}
159
-
153
+
160
154
- (id )initForDefaultFileType : (NSString *)filetype
161
155
{
162
156
FileSettings *fsdefaults;
163
-
157
+
164
158
fsdefaults = [FileSettings getFactorySettingsForFileType: filetype];
165
159
self = [self initWithFileSettings: fsdefaults];
166
160
if (!self) return self;
@@ -220,7 +214,7 @@ - (void)updateFromSource: (id <FileSettingsSource>)source
220
214
- (void )applyValuesFromDict : (NSDictionary *)dict
221
215
{
222
216
id value;
223
-
217
+
224
218
value = [dict objectForKey: @" interpreter" ];
225
219
if (value) interpreter = [value retain ];
226
220
value = [dict objectForKey: @" honourhashbang" ];
@@ -247,12 +241,12 @@ - (void)applyValuesFromDict: (NSDictionary *)dict
247
241
248
242
- (NSString *)_replaceSingleQuotes : (NSString *)string
249
243
{
250
- /* Replace all single-quotes by '"'"', that way shellquoting will
251
- * be correct when the result value is delimited using single quotes.
252
- */
253
- NSArray * components = [string componentsSeparatedByString: @" '" ];
244
+ /* Replace all single-quotes by '"'"', that way shellquoting will
245
+ * be correct when the result value is delimited using single quotes.
246
+ */
247
+ NSArray * components = [string componentsSeparatedByString: @" '" ];
254
248
255
- return [components componentsJoinedByString: @" '\" '\" '" ];
249
+ return [components componentsJoinedByString: @" '\" '\" '" ];
256
250
}
257
251
258
252
- (NSString *)commandLineForScript : (NSString *)script
@@ -265,7 +259,7 @@ - (NSString *)commandLineForScript: (NSString *)script
265
259
266
260
script_dir = [script substringToIndex:
267
261
[script length ]-[[script lastPathComponent ] length ]];
268
-
262
+
269
263
if (honourhashbang &&
270
264
(fp=fopen ([script fileSystemRepresentation ], " r" )) &&
271
265
fgets (hashbangbuf, sizeof (hashbangbuf), fp) &&
@@ -278,7 +272,7 @@ - (NSString *)commandLineForScript: (NSString *)script
278
272
}
279
273
if (!cur_interp)
280
274
cur_interp = interpreter;
281
-
275
+
282
276
return [NSString stringWithFormat:
283
277
@" cd '%@ ' && '%@ '%s%s%s%s%s%s %@ '%@ ' %@ %s " ,
284
278
[self _replaceSingleQuotes: script_dir],
@@ -297,7 +291,7 @@ - (NSString *)commandLineForScript: (NSString *)script
297
291
298
292
- (NSArray *) interpreters { return interpreters;};
299
293
300
- // FileSettingsSource protocol
294
+ // FileSettingsSource protocol
301
295
- (NSString *) interpreter { return interpreter;};
302
296
- (BOOL ) honourhashbang { return honourhashbang; };
303
297
- (BOOL ) debug { return debug;};
0 commit comments