Permalink
Browse files

impr-v9

  • Loading branch information...
1 parent 932820b commit d6a393fc381273dad7bd398d1c426a9d8634afd9 UncleMiF committed Oct 11, 2011
Showing with 20 additions and 56 deletions.
  1. +14 −50 XcodeColors.m
  2. +5 −5 XcodeColors.xcodeproj/project.pbxproj
  3. +1 −1 xcb-install.pl
View
@@ -14,35 +14,6 @@
#define LC_SEQ_MAC @"\033["
#define LC_SEQ_IOS @"\xC2\xA0["
-BOOL isLogTextView(NSTextView* textView)
-{
- if (!textView)
- return NO;
- NSString * textViewClass = NSStringFromClass([textView class]);
- // Xcode Debuger View
- if ([textViewClass isEqualToString:@"IDEConsoleTextView"]/* Xcode 4 */ ||
- [textViewClass isEqualToString:@"PBXTtyText"]/* Xcode 3 */)
- return YES;
- return NO;
-}
-
-BOOL isLogTextStorage(NSAttributedString * textStorage)
-{
- id textView = nil;
- if ([textStorage respondsToSelector:@selector(layoutManagers)])
- {
- id layoutManagers = [(NSTextStorage*)textStorage layoutManagers];
- if ([layoutManagers count])
- {
- id layoutManager = [layoutManagers objectAtIndex:0];
- if ([layoutManager respondsToSelector:@selector(firstTextView)])
- textView = [layoutManager firstTextView];
- }
- }
-
- return isLogTextView(textView);
-}
-
static IMP imp_ts_fixAttributesInRange = nil;
@interface XcodeColors_NSTextStorage : NSTextStorage
@@ -53,16 +24,6 @@ -(void)fixAttributesInRange:(NSRange)aRange;
@implementation XcodeColors_NSTextStorage
-NSString* SeqReplacementWithLenght(NSUInteger length)
-{
- if (!length)
- return @"";
- NSMutableString * res = [NSMutableString string];
- while(length--)
- [res appendString:@"\x1D"];// Logical Group Separator
- return res;
-}
-
void ApplyANSIColors(NSTextStorage * textStorage, NSRange range, NSString * seq)
{
NSString * affectedString = [[textStorage string] substringWithRange:range];
@@ -85,7 +46,7 @@ void ApplyANSIColors(NSTextStorage * textStorage, NSRange range, NSString * seq)
// Background LBCL_*
@"0;40m"/*black*/,@"0;41m"/*red*/,@"0;42m"/*green*/,@"0;43m"/*yellow*/,@"0;44m"/*blue*/,@"0;45m"/*magenta*/,@"0;46m"/*cyan*/,@"0;47m"/*white*/,
-
+
@"0m"/*nothing*/,@"00m"/*nothing*/};
int i;
for (i = 0; i < sizeof(ctrlSEQ)/sizeof(ctrlSEQ[0]); i++)
@@ -155,24 +116,27 @@ void ApplyANSIColors(NSTextStorage * textStorage, NSRange range, NSString * seq)
}
}
componentRange.length = [component length];
- [textStorage addAttributes:attrs range:componentRange];
+ [textStorage addAttributes:attrs range:componentRange];
componentRange.location += componentRange.length + [seq length];
firstPass = NO;
}
for (NSValue * clearValue in clearSEQ)
{
NSRange range = [clearValue rangeValue];
- [textStorage replaceCharactersInRange:range withString:SeqReplacementWithLenght(range.length)];
+ [textStorage addAttributes:
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSFont systemFontOfSize:0.001],NSFontAttributeName,
+ [NSColor clearColor],NSForegroundColorAttributeName,
+ nil] range:range];
}
}
}
-(void)fixAttributesInRange:(NSRange)aRange// NSTextStorage
{
imp_ts_fixAttributesInRange(self,_cmd,aRange);
-
- if (getenv(XCODE_COLORS) && !strcmp(getenv(XCODE_COLORS),"YES") && isLogTextStorage(self))
+ if (getenv(XCODE_COLORS) && !strcmp(getenv(XCODE_COLORS),"YES"))
{
ApplyANSIColors(self,aRange,LC_SEQ_MAC);
ApplyANSIColors(self,aRange,LC_SEQ_IOS);
@@ -197,10 +161,10 @@ -(void)registerLaunchSystemDescriptions
+(void)load
{
- NSLog(@"%s,v,8",__PRETTY_FUNCTION__);
+ NSLog(@"%s,v,9",__PRETTY_FUNCTION__);
if (getenv(XCODE_COLORS) && !strcmp(getenv(XCODE_COLORS), "YES"))
return;
-
+
imp_ts_fixAttributesInRange = ReplaceInstanceMethod(NSTextStorage,fixAttributesInRange:,XcodeColors_NSTextStorage);
setenv(XCODE_COLORS, "YES", 0);
@@ -232,10 +196,10 @@ +(NSColor*)defaultColorWithName:(NSString*)colorName defaultColor:(NSColor*)colo
if ([components count] == 4)
{
return [NSColor
- colorWithDeviceRed:[[components objectAtIndex:0] floatValue]
- green:[[components objectAtIndex:1] floatValue]
- blue:[[components objectAtIndex:2] floatValue]
- alpha:[[components objectAtIndex:3] floatValue]];
+ colorWithDeviceRed:[[components objectAtIndex:0] floatValue]
+ green:[[components objectAtIndex:1] floatValue]
+ blue:[[components objectAtIndex:2] floatValue]
+ alpha:[[components objectAtIndex:3] floatValue]];
}
if ([components count] == 1)
{
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 45;
+ objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
@@ -159,8 +159,11 @@
/* Begin PBXProject section */
089C1669FE841209C02AAC07 /* Project object */ = {
isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0420;
+ };
buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "XcodeColors" */;
- compatibilityVersion = "Xcode 3.1";
+ compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
@@ -235,7 +238,6 @@
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -274,7 +276,6 @@
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.5;
ONLY_ACTIVE_ARCH = YES;
- PREBINDING = NO;
SDKROOT = macosx10.6;
};
name = Debug;
@@ -289,7 +290,6 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.5;
- PREBINDING = NO;
SDKROOT = macosx10.6;
};
name = Release;
View
@@ -1,3 +1,3 @@
#!/usr/bin/env perl
-system("./install") if ($ENV{BUILD_STYLE} =~ /Release/);
+system("./install") if ($ENV{BUILD_STYLE} =~ /Release/ || $ENV{CONFIGURATION} =~ 'Release');

0 comments on commit d6a393f

Please sign in to comment.