| Line 211... |
Line 211... |
| 211 |
c=[Preferences unarchivedObjectForKey:identifierSyntaxColorKey withDefault:nil];
|
211 |
c=[Preferences unarchivedObjectForKey:identifierSyntaxColorKey withDefault:nil];
|
| 212 |
if (c) shColorIdentifier = c;
|
212 |
if (c) shColorIdentifier = c;
|
| 213 |
else shColorIdentifier=[NSColor colorWithDeviceRed:0.0 green:0.0 blue:0.0 alpha:1.0];
|
213 |
else shColorIdentifier=[NSColor colorWithDeviceRed:0.0 green:0.0 blue:0.0 alpha:1.0];
|
| 214 |
[shColorIdentifier retain];
|
214 |
[shColorIdentifier retain];
|
| 215 |
|
215 |
|
| 216 |
|
216 |
// Rd stuff
|
| 217 |
c=[Preferences unarchivedObjectForKey:commentRdSyntaxColorKey withDefault:nil];
|
217 |
// c=[Preferences unarchivedObjectForKey:sectionRdSyntaxColorKey withDefault:nil];
|
| 218 |
if (c) rdColorComment = c;
|
218 |
// if (c) rdColorSection = c;
|
| 219 |
else rdColorComment=[NSColor colorWithDeviceRed:0.1 green:0.55 blue:0.05 alpha:1.0];
|
219 |
// else rdColorSection=[NSColor colorWithDeviceRed:0.8 green:0.0353 blue:0.02 alpha:1.0];
|
| 220 |
[rdColorComment retain];
|
220 |
// [rdColorSection retain];
|
| 221 |
|
221 |
//
|
| 222 |
c=[Preferences unarchivedObjectForKey:sectionRdSyntaxColorKey withDefault:nil];
|
222 |
// c=[Preferences unarchivedObjectForKey:macroArgRdSyntaxColorKey withDefault:nil];
|
| 223 |
if (c) rdColorSection = c;
|
223 |
// if (c) rdColorMacroArg = c;
|
| 224 |
else rdColorSection=[NSColor colorWithDeviceRed:0.8 green:0.0353 blue:0.02 alpha:1.0];
|
224 |
// else rdColorMacroArg=[NSColor colorWithDeviceRed:0.0 green:0.0 blue:0.98 alpha:1.0];
|
| 225 |
[rdColorSection retain];
|
225 |
// [rdColorMacroArg retain];
|
| 226 |
|
226 |
//
|
| 227 |
c=[Preferences unarchivedObjectForKey:macroArgRdSyntaxColorKey withDefault:nil];
|
227 |
// c=[Preferences unarchivedObjectForKey:macroGenRdSyntaxColorKey withDefault:nil];
|
| 228 |
if (c) rdColorMacroArg = c;
|
228 |
// if (c) rdColorMacroGen = c;
|
| 229 |
else rdColorMacroArg=[NSColor colorWithDeviceRed:0.0 green:0.0 blue:0.98 alpha:1.0];
|
229 |
// else rdColorMacroGen=[NSColor colorWithDeviceRed:0.4 green:0.78 blue:0.98 alpha:1.0];
|
| 230 |
[rdColorMacroArg retain];
|
230 |
// [rdColorMacroGen retain];
|
| 231 |
|
231 |
//
|
| 232 |
c=[Preferences unarchivedObjectForKey:macroGenRdSyntaxColorKey withDefault:nil];
|
232 |
// c=[Preferences unarchivedObjectForKey:directiveRdSyntaxColorKey withDefault:nil];
|
| 233 |
if (c) rdColorMacroGen = c;
|
233 |
// if (c) rdColorDirective = c;
|
| 234 |
else rdColorMacroGen=[NSColor colorWithDeviceRed:0.4 green:0.78 blue:0.98 alpha:1.0];
|
234 |
// else rdColorDirective=[NSColor colorWithDeviceRed:0.0 green:0.785 blue:0.0 alpha:1.0];
|
| 235 |
[rdColorMacroGen retain];
|
235 |
// [rdColorDirective retain];
|
| 236 |
|
236 |
|
| 237 |
c=[Preferences unarchivedObjectForKey:directiveRdSyntaxColorKey withDefault:nil];
|
237 |
// c=[Preferences unarchivedObjectForKey:commentRdSyntaxColorKey withDefault:nil];
|
| 238 |
if (c) rdColorDirective = c;
|
238 |
// if (c) rdColorComment = c;
|
| 239 |
else rdColorDirective=[NSColor colorWithDeviceRed:0.0 green:0.785 blue:0.0 alpha:1.0];
|
239 |
// else rdColorComment=[NSColor colorWithDeviceRed:0.1 green:0.55 blue:0.05 alpha:1.0];
|
| 240 |
[rdColorDirective retain];
|
240 |
// [rdColorComment retain];
|
| 241 |
|
241 |
|
| 242 |
c=[Preferences unarchivedObjectForKey:normalRdSyntaxColorKey withDefault:nil];
|
242 |
// c=[Preferences unarchivedObjectForKey:normalRdSyntaxColorKey withDefault:nil];
|
| 243 |
if (c) rdColorNormal = c;
|
243 |
// if (c) rdColorNormal = c;
|
| 244 |
else rdColorNormal=[NSColor colorWithDeviceRed:0.0 green:0.0 blue:0.0 alpha:1.0];
|
244 |
// else rdColorNormal=[NSColor colorWithDeviceRed:0.0 green:0.0 blue:0.0 alpha:1.0];
|
| 245 |
[rdColorNormal retain];
|
245 |
// [rdColorNormal retain];
|
| 246 |
|
- |
|
| 247 |
|
246 |
|
| 248 |
|
247 |
|
| 249 |
c=[Preferences unarchivedObjectForKey:editorBackgroundColorKey withDefault:nil];
|
248 |
c=[Preferences unarchivedObjectForKey:editorBackgroundColorKey withDefault:nil];
|
| 250 |
if (c) shColorBackground = c;
|
249 |
if (c) shColorBackground = c;
|
| 251 |
else shColorBackground=[NSColor colorWithDeviceRed:1.0 green:1.0 blue:1.0 alpha:1.0];
|
250 |
else shColorBackground=[NSColor colorWithDeviceRed:1.0 green:1.0 blue:1.0 alpha:1.0];
|
| Line 266... |
Line 265... |
| 266 |
[prefs addObserver:self forKeyPath:normalSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
265 |
[prefs addObserver:self forKeyPath:normalSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 267 |
[prefs addObserver:self forKeyPath:stringSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
266 |
[prefs addObserver:self forKeyPath:stringSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 268 |
[prefs addObserver:self forKeyPath:numberSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
267 |
[prefs addObserver:self forKeyPath:numberSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 269 |
[prefs addObserver:self forKeyPath:keywordSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
268 |
[prefs addObserver:self forKeyPath:keywordSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 270 |
[prefs addObserver:self forKeyPath:commentSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
269 |
[prefs addObserver:self forKeyPath:commentSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 271 |
[prefs addObserver:self forKeyPath:normalRdSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
270 |
// [prefs addObserver:self forKeyPath:normalRdSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 272 |
[prefs addObserver:self forKeyPath:sectionRdSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
271 |
// [prefs addObserver:self forKeyPath:commentRdSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 273 |
[prefs addObserver:self forKeyPath:macroArgRdSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
272 |
// [prefs addObserver:self forKeyPath:sectionRdSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 274 |
[prefs addObserver:self forKeyPath:macroGenRdSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
273 |
// [prefs addObserver:self forKeyPath:macroArgRdSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 275 |
[prefs addObserver:self forKeyPath:commentRdSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
274 |
// [prefs addObserver:self forKeyPath:macroGenRdSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 276 |
[prefs addObserver:self forKeyPath:directiveRdSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
275 |
// [prefs addObserver:self forKeyPath:directiveRdSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 277 |
[prefs addObserver:self forKeyPath:editorBackgroundColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
276 |
[prefs addObserver:self forKeyPath:editorBackgroundColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 278 |
[prefs addObserver:self forKeyPath:editorCurrentLineBackgroundColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
277 |
[prefs addObserver:self forKeyPath:editorCurrentLineBackgroundColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 279 |
[prefs addObserver:self forKeyPath:identifierSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
278 |
[prefs addObserver:self forKeyPath:identifierSyntaxColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 280 |
[prefs addObserver:self forKeyPath:editorCursorColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
279 |
[prefs addObserver:self forKeyPath:editorCursorColorKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 281 |
[prefs addObserver:self forKeyPath:showSyntaxColoringKey options:NSKeyValueObservingOptionNew context:NULL];
|
280 |
[prefs addObserver:self forKeyPath:showSyntaxColoringKey options:NSKeyValueObservingOptionNew context:NULL];
|
| Line 284... |
Line 283... |
| 284 |
[prefs addObserver:self forKeyPath:RScriptEditorDefaultFont options:NSKeyValueObservingOptionNew context:NULL];
|
283 |
[prefs addObserver:self forKeyPath:RScriptEditorDefaultFont options:NSKeyValueObservingOptionNew context:NULL];
|
| 285 |
[prefs addObserver:self forKeyPath:HighlightIntervalKey options:NSKeyValueObservingOptionNew context:NULL];
|
284 |
[prefs addObserver:self forKeyPath:HighlightIntervalKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 286 |
[prefs addObserver:self forKeyPath:highlightCurrentLine options:NSKeyValueObservingOptionNew context:NULL];
|
285 |
[prefs addObserver:self forKeyPath:highlightCurrentLine options:NSKeyValueObservingOptionNew context:NULL];
|
| 287 |
[prefs addObserver:self forKeyPath:showLineNumbersKey options:NSKeyValueObservingOptionNew context:NULL];
|
286 |
[prefs addObserver:self forKeyPath:showLineNumbersKey options:NSKeyValueObservingOptionNew context:NULL];
|
| 288 |
|
287 |
|
| - |
|
288 |
[self setTextColor:shColorNormal];
|
| - |
|
289 |
[self setInsertionPointColor:shColorCursor];
|
| - |
|
290 |
|
| 289 |
theTextStorage = [self textStorage];
|
291 |
theTextStorage = [self textStorage];
|
| 290 |
}
|
292 |
}
|
| 291 |
|
293 |
|
| 292 |
- (void)dealloc {
|
294 |
- (void)dealloc {
|
| 293 |
SLog(@"RScriptEditorTextView: dealloc <%@>", self);
|
295 |
SLog(@"RScriptEditorTextView: dealloc <%@>", self);
|
| Line 304... |
Line 306... |
| 304 |
if(shColorIdentifier) [shColorIdentifier release];
|
306 |
if(shColorIdentifier) [shColorIdentifier release];
|
| 305 |
if(shColorBackground) [shColorBackground release];
|
307 |
if(shColorBackground) [shColorBackground release];
|
| 306 |
if(shColorCurrentLine) [shColorCurrentLine release];
|
308 |
if(shColorCurrentLine) [shColorCurrentLine release];
|
| 307 |
if(shColorCursor) [shColorCursor release];
|
309 |
if(shColorCursor) [shColorCursor release];
|
| 308 |
|
310 |
|
| 309 |
if(rdColorNormal) [rdColorNormal release];
|
311 |
// if(rdColorNormal) [rdColorNormal release];
|
| 310 |
if(rdColorSection) [rdColorSection release];
|
312 |
// if(rdColorComment) [rdColorComment release];
|
| 311 |
if(rdColorMacroArg) [rdColorMacroArg release];
|
313 |
// if(rdColorSection) [rdColorSection release];
|
| 312 |
if(rdColorMacroGen) [rdColorMacroGen release];
|
314 |
// if(rdColorMacroArg) [rdColorMacroArg release];
|
| 313 |
if(rdColorComment) [rdColorComment release];
|
315 |
// if(rdColorMacroGen) [rdColorMacroGen release];
|
| 314 |
if(rdColorDirective) [rdColorDirective release];
|
316 |
// if(rdColorDirective) [rdColorDirective release];
|
| 315 |
|
317 |
|
| 316 |
if(theRulerView) [theRulerView release];
|
318 |
if(theRulerView) [theRulerView release];
|
| 317 |
|
319 |
|
| 318 |
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
320 |
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
| 319 |
[[Preferences sharedPreferences] removeDependent:self];
|
321 |
[[Preferences sharedPreferences] removeDependent:self];
|
| Line 357... |
Line 359... |
| 357 |
} else if ([keyPath isEqualToString:identifierSyntaxColorKey]) {
|
359 |
} else if ([keyPath isEqualToString:identifierSyntaxColorKey]) {
|
| 358 |
if(shColorIdentifier) [shColorIdentifier release];
|
360 |
if(shColorIdentifier) [shColorIdentifier release];
|
| 359 |
shColorIdentifier = [[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]] retain];
|
361 |
shColorIdentifier = [[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]] retain];
|
| 360 |
if([self isEditable])
|
362 |
if([self isEditable])
|
| 361 |
[self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1];
|
363 |
[self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1];
|
| - |
|
364 |
// } else if ([keyPath isEqualToString:sectionRdSyntaxColorKey]) {
|
| - |
|
365 |
// if(rdColorSection) [rdColorSection release];
|
| - |
|
366 |
// rdColorSection = [[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]] retain];
|
| - |
|
367 |
// if([self isEditable])
|
| - |
|
368 |
// [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1];
|
| - |
|
369 |
// } else if ([keyPath isEqualToString:macroArgRdSyntaxColorKey]) {
|
| - |
|
370 |
// if(rdColorMacroArg) [rdColorMacroArg release];
|
| - |
|
371 |
// rdColorMacroArg = [[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]] retain];
|
| - |
|
372 |
// if([self isEditable])
|
| - |
|
373 |
// [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1];
|
| - |
|
374 |
// } else if ([keyPath isEqualToString:macroGenRdSyntaxColorKey]) {
|
| - |
|
375 |
// if(rdColorMacroGen) [rdColorMacroGen release];
|
| - |
|
376 |
// rdColorMacroGen = [[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]] retain];
|
| - |
|
377 |
// if([self isEditable])
|
| - |
|
378 |
// [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1];
|
| - |
|
379 |
// } else if ([keyPath isEqualToString:directiveRdSyntaxColorKey]) {
|
| - |
|
380 |
// if(rdColorDirective) [rdColorDirective release];
|
| - |
|
381 |
// rdColorDirective = [[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]] retain];
|
| - |
|
382 |
// if([self isEditable])
|
| - |
|
383 |
// [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1];
|
| 362 |
} else if ([keyPath isEqualToString:editorCursorColorKey]) {
|
384 |
} else if ([keyPath isEqualToString:editorCursorColorKey]) {
|
| 363 |
if(shColorCursor) [shColorCursor release];
|
385 |
if(shColorCursor) [shColorCursor release];
|
| 364 |
shColorCursor = [[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]] retain];
|
386 |
shColorCursor = [[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]] retain];
|
| 365 |
[self setInsertionPointColor:shColorCursor];
|
387 |
[self setInsertionPointColor:shColorCursor];
|
| 366 |
[self setNeedsDisplayInRect:[self bounds]];
|
388 |
[self setNeedsDisplayInRect:[self bounds]];
|
| Line 690... |
Line 712... |
| 690 |
// now loop through all the tokens
|
712 |
// now loop through all the tokens
|
| 691 |
while ((token = rdlex())) {
|
713 |
while ((token = rdlex())) {
|
| 692 |
// NSLog(@"t %d", token);
|
714 |
// NSLog(@"t %d", token);
|
| 693 |
switch (token) {
|
715 |
switch (token) {
|
| 694 |
case RDPT_COMMENT:
|
716 |
case RDPT_COMMENT:
|
| 695 |
tokenColor = rdColorComment;
|
717 |
tokenColor = shColorComment;
|
| 696 |
break;
|
718 |
break;
|
| 697 |
case RDPT_SECTION:
|
719 |
case RDPT_SECTION:
|
| 698 |
tokenColor = rdColorSection;
|
720 |
tokenColor = shColorKeyword;
|
| 699 |
break;
|
721 |
break;
|
| 700 |
case RDPT_MACRO_ARG:
|
722 |
case RDPT_MACRO_ARG:
|
| 701 |
tokenColor = rdColorMacroArg;
|
723 |
tokenColor = shColorNumber;
|
| 702 |
break;
|
724 |
break;
|
| 703 |
case RDPT_MACRO_GEN:
|
725 |
case RDPT_MACRO_GEN:
|
| 704 |
tokenColor = rdColorMacroGen;
|
726 |
tokenColor = shColorNumber;
|
| 705 |
break;
|
727 |
break;
|
| 706 |
case RDPT_DIRECTIVE:
|
728 |
case RDPT_DIRECTIVE:
|
| 707 |
tokenColor = rdColorDirective;
|
729 |
tokenColor = shColorString;
|
| 708 |
break;
|
730 |
break;
|
| 709 |
case RDPT_OTHER:
|
731 |
case RDPT_OTHER:
|
| 710 |
tokenColor = rdColorNormal;
|
732 |
tokenColor = shColorNormal;
|
| 711 |
break;
|
733 |
break;
|
| 712 |
default:
|
734 |
default:
|
| 713 |
tokenColor = rdColorNormal;
|
735 |
tokenColor = shColorNormal;
|
| 714 |
}
|
736 |
}
|
| 715 |
|
737 |
|
| 716 |
tokenRange = NSMakeRange(yyuoffset, yyuleng);
|
738 |
tokenRange = NSMakeRange(yyuoffset, yyuleng);
|
| 717 |
|
739 |
|
| 718 |
// make sure that tokenRange is valid (and therefore within textRange)
|
740 |
// make sure that tokenRange is valid (and therefore within textRange)
|