Skip to content

Commit

Permalink
Fix missing text field on Xcode 7.3 and remove verbose logs. Fix #48, #…
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhua-chen committed Mar 29, 2016
1 parent ffe03f6 commit 5e8eecd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
5 changes: 4 additions & 1 deletion MCLog/MCLog-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.2</string>
<string>1.4.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand All @@ -37,6 +37,7 @@
<string>0420B86A-AA43-4792-9ED0-6FE0F2B16A13</string>
<string>7265231C-39B4-402C-89E1-16167C4CC990</string>
<string>F41BD31E-2683-44B8-AE7F-5F09E919790E</string>
<string>ACA8656B-FEA8-4B6D-8E4A-93F4C95C362C</string>
</array>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2014年 Yuhua Chen. All rights reserved.</string>
Expand All @@ -46,6 +47,8 @@
<true/>
<key>XC5Compatible</key>
<true/>
<key>XC7Compatible</key>
<true/>
<key>XCGCReady</key>
<true/>
<key>XCPluginHasUI</key>
Expand Down
45 changes: 25 additions & 20 deletions MCLog/MCLog.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
@implementation MCLog

+ (void)load {
NSLog(@"%s, env: %s", __PRETTY_FUNCTION__, getenv(MCLOG_FLAG));

if (getenv(MCLOG_FLAG) && !strcmp(getenv(MCLOG_FLAG), "YES")) {
// alreay installed plugin
return;
Expand All @@ -40,7 +38,6 @@ + (void)load {
}

+ (void)pluginDidLoad:(NSBundle *)bundle {
MCLogger(@"%s, %@", __PRETTY_FUNCTION__, bundle);
static id sharedPlugin = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Expand Down Expand Up @@ -85,26 +82,34 @@ - (id)init {
#pragma mark - init UI

- (BOOL)addCustomViews {
NSView *contentView = [[NSApp mainWindow] contentView];
NSTextView *consoleTextView = [contentView descendantViewByClassName:@"IDEConsoleTextView"];
if (!consoleTextView) {
return NO;
}
DVTTextStorage *textStorage = [consoleTextView valueForKey:@"textStorage"];
if ([textStorage respondsToSelector:@selector(setConsoleStorage:)]) {
[textStorage setConsoleStorage:YES];
}
for (NSWindow *window in [NSApp windows]) {
NSView *contentView = [window contentView];
NSTextView *consoleTextView = [contentView descendantViewByClassName:@"IDEConsoleTextView"];

contentView = [consoleTextView ancestralViewByClassName:@"DVTControllerContentView"];
NSView *scopeBarView = [contentView descendantViewByClassName:@"DVTScopeBarView"];
if (!scopeBarView) {
return NO;
}

if (!consoleTextView) {
continue;
}

[self addLogLevelButtonItemsAt:scopeBarView defaultLogLevel:[[consoleTextView valueForKey:@"logMode"] intValue]];
[self addLogFilterPatternTextFieldAt:scopeBarView associateWith:consoleTextView];
DVTTextStorage *textStorage = [consoleTextView valueForKey:@"textStorage"];
if ([textStorage respondsToSelector:@selector(setConsoleStorage:)]) {
[textStorage setConsoleStorage:YES];
}

NSView *scopeBarView = nil;
NSView *parent = consoleTextView.superview;
while (!scopeBarView) {
if (!parent) break;
scopeBarView = [parent descendantViewByClassName:@"DVTScopeBarView"];
parent = parent.superview;
}

if (!scopeBarView) {
continue;
}

[self addLogLevelButtonItemsAt:scopeBarView defaultLogLevel:[[consoleTextView valueForKey:@"logMode"] intValue]];
[self addLogFilterPatternTextFieldAt:scopeBarView associateWith:consoleTextView];
}

return YES;
}
Expand Down

0 comments on commit 5e8eecd

Please sign in to comment.