/* Copyright (C) 2002-2003, Jeffrey D. Argast. The authors make NO WARRANTY or representation, either express or implied, with respect to this software, its quality, accuracy, merchantability, or fitness for a particular purpose. This software is provided "AS IS", and you, its user, assume the entire risk as to its quality and accuracy. Permission is hereby granted to use, copy, modify, and distribute this software or portions thereof for any purpose, without fee, subject to these conditions: (1) If any part of the source code is distributed, then this statement must be included, with this copyright and no-warranty notice unaltered. (2) Permission for use of this software is granted only if the user accepts full responsibility for any undesirable consequences; the authors accept NO LIABILITY for damages of any kind. */ #import "ConsoleController.h" #import "MessageDefs.h" @implementation ConsoleController - (id) init { if ( self = [super init] ) { NSNotificationCenter* nCenter = [NSNotificationCenter defaultCenter]; [nCenter addObserver:self selector:@selector(handleOutputMessage:) name:kOutputMessage object:nil]; [nCenter addObserver:self selector:@selector(handleExecutingMessage:) name:kExecutingMessage object:nil]; [nCenter addObserver:self selector:@selector(handleInfoMessage:) name:kInfoMessage object:nil]; [nCenter addObserver:self selector:@selector(handleWarnMessage:) name:kWarnMessage object:nil]; [nCenter addObserver:self selector:@selector(handleErrorMessage:) name:kErrorMessage object:nil]; } return self; } - (void) awakeFromNib { // We don't want a context menu [fTextView setMenu:nil]; } - (void) dealloc { NSNotificationCenter* nCenter = [NSNotificationCenter defaultCenter]; [nCenter removeObserver:self]; [super dealloc]; } - (void) handleExecutingMessage: (NSNotification*) notification { [self sendToConsole:[notification object] withRed:0.0 withGreen:0.0 withBlue:0.0]; } - (void) handleOutputMessage: (NSNotification*) notification { [self sendToConsole:[notification object] withRed:0.0 withGreen:0.5 withBlue:0.0]; } - (void) handleInfoMessage: (NSNotification*) notification { [self sendToConsole:[notification object] withRed:0.0 withGreen:0.0 withBlue:1.0]; } - (void) handleWarnMessage: (NSNotification*) notification { [self sendToConsole:[notification object] withRed:0.8 withGreen:0.4 withBlue:0.0]; } - (void) handleErrorMessage: (NSNotification*) notification { [self sendToConsole:[notification object] withRed:1.0 withGreen:0.0 withBlue:0.0]; } - (void) sendToConsole: (NSString*) msg withRed: (float) red withGreen: (float) green withBlue: (float) blue { NSRange attrStrRange; NSRange endOfTextRange; NSColor* textColor = [NSColor colorWithDeviceRed:red green:green blue:blue alpha:1.0]; // We can't use the insertText method on NSTextView because // the view is not editable. The insertText method honors the // editable flag. Instead we have to use NSText methods to insert // the text // Since the text view is selectable, the current insertion point can be altered // by the user. But we always want to insert the text at the end of the window. // Hence we set the selection to be the end of the text. NSString* backingStoreString = [fTextView string]; endOfTextRange.location = [backingStoreString length]; endOfTextRange.length = 0; attrStrRange.location = endOfTextRange.location; attrStrRange.length = [msg length]; [fTextView replaceCharactersInRange:endOfTextRange withString:msg]; [fTextView setTextColor:textColor range:attrStrRange]; // force it to scroll to the end of the inserted text [fTextView scrollRangeToVisible:NSMakeRange(attrStrRange.location + attrStrRange.length, 0)]; [fTextView display]; } @end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 3132 | Jeff Argast |
Finally fixed the stupid wrapping problem. Turns out there are tabs in the text returned from Perforce. No problem. But in NSTextView if a tab occurs beyond the last tab stop then NSTextView breaks the line. So no what I want. The fix is to create a bunch of tab stops out to the etherlands. |
||
#2 | 2803 | Jeff Argast |
Added submit default changelist to the changelist menu Made the out window selectable Changed the tabs in a few places |
||
#1 | 2732 | Jeff Argast | Initial submission of P4Cocoa |