54@interface OOJavaScriptConsoleController (Private)
60- (NSColor *)foregroundColorForKey:(NSString *)key;
61- (NSColor *)backgroundColorForKey:(NSString *)key;
72@interface NSLayoutManager (Leopard)
73- (void)setAllowsNonContiguousLayout:(BOOL)flag;
81 [consoleWindow release];
82 [inputHistoryManager release];
99 NSView *contentView = [consoleWindow contentView];
102 [contentView addSubview:splitView];
103 [splitView setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
111 CGFloat height = [consoleInputHolderView frame].size.height;
114 [inputSplitSubview setMinDimension:30 andMaxDimension:0];
116 NSString *thumbPath = [[NSBundle bundleForClass:[
self class]] pathForResource:@"SplitViewThumb" ofType:@"png"];
117 [splitView
setDivider:[[[NSImage alloc] initWithContentsOfFile:thumbPath] autorelease]];
118 [inputSplitSubview setDimension:height];
121 if ([[consoleTextView layoutManager] respondsToSelector:
@selector(setAllowsNonContiguousLayout:)])
123 [[consoleTextView layoutManager] setAllowsNonContiguousLayout:YES];
127 [verticalScroller setFloatValue:1.0];
129 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
130 [inputHistoryManager setHistory:[defaults arrayForKey:@"debug-js-console-scrollback"]];
132 [
self reloadAllSettings];
134 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
138- (void)applicationWillTerminate:(NSNotification *)notification
146- (IBAction) clearConsole:sender
152- (IBAction)showConsole:sender
158- (IBAction)toggleShowOnWarning:sender
160 [_debugger performConsoleCommand:@"console.settings[\"show-console-on-warning\"] = !console.settings[\"show-console-on-warning\"]"];
164- (IBAction)toggleShowOnError:sender
166 [_debugger performConsoleCommand:@"console.settings[\"show-console-on-error\"] = !console.settings[\"show-console-on-error\"]"];
170- (IBAction)toggleShowOnLog:sender
172 [_debugger performConsoleCommand:@"console.settings[\"show-console-on-log\"] = !console.settings[\"show-console-on-log\"]"];
176- (IBAction)consolePerformCommand:sender
178 NSString *command =
nil;
181 command = [consoleInputField stringValue];
182 [consoleInputField setStringValue:@""];
183 [consoleWindow makeFirstResponder:consoleInputField];
185 [inputHistoryManager addToHistory:command];
188 [_debugger performConsoleCommand:command];
192- (void)appendMessage:(NSString *)string
193 colorKey:(NSString *)colorKey
194 emphasisRange:(NSRange)emphasisRange
198 NSMutableAttributedString *mutableStr =
nil;
199 NSColor *fgColor =
nil,
201 volatile NSRange fullRange;
202 NSTextStorage *textStorage =
nil;
206 mutableStr = [NSMutableAttributedString stringWithString:[string stringByAppendingString:@"\n"]
209 fullRange = (NSRange){ 0, [mutableStr length] };
210 fgColor = [
self foregroundColorForKey:colorKey];
213 if ([fgColor alphaComponent] == 0.0)
return;
214 [mutableStr addAttribute:NSForegroundColorAttributeName
219 bgColor = [
self backgroundColorForKey:colorKey];
222 [mutableStr addAttribute:NSBackgroundColorAttributeName
227 if (emphasisRange.length != 0)
229 [mutableStr addAttribute:NSFontAttributeName
231 range:emphasisRange];
234 doScroll = [verticalScroller floatValue] > 0.980f;
236 textStorage = [consoleTextView textStorage];
237 [textStorage appendAttributedString:mutableStr];
238 length = [textStorage length];
241 [textStorage deleteCharactersInRange:(NSRange){ length - kConsoleTrimToSize, kConsoleTrimToSize }];
246 if (doScroll) [consoleTextView scrollRangeToVisible:(NSRange){ length, 0 }];