-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyTermColors.m
96 lines (81 loc) · 3.04 KB
/
MyTermColors.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* MyTermColors, a SIMBL plugin to change Terminal.app's colors
* Copyright (C) 2009 Hugo Camboulive <hugo.camboulive AT gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import "MyTermColors.h"
#import "MyTTProfile.h"
#import "JRSwizzle.h"
#import "MyColors.h"
/**
* Helper function to localize a string
*/
NSString *_L(NSString *in)
{
NSBundle *b = [NSBundle bundleForClass: [MyTermColors class]];
return NSLocalizedStringFromTableInBundle (in, @"Localizable", b, @"");
}
@implementation MyTermColors
/**
* A special method called by SIMBL once the application has started and all classes are initialized.
*/
+ (void) load
{
MyTermColors* plugin = [MyTermColors sharedInstance];
NSError *err = nil;
/* new for OSX 10.6 */
[NSClassFromString(@"TTProfile") jr_swizzleMethod:@selector(valueForUndefinedKey:)
withMethod:@selector(valueForUndefinedKey2:) error:&err];
[NSClassFromString(@"TTProfile") jr_swizzleMethod:@selector(valueForKey:)
withMethod:@selector(valueForKey2:) error:&err];
[NSClassFromString(@"TTProfile") jr_swizzleMethod:@selector(setValue:forKey:)
withMethod:@selector(setValue2:forKey:) error:&err];
[NSClassFromString(@"TTProfile") jr_swizzleMethod:@selector(initWithProfile:)
withMethod:@selector(initWithProfile2:) error:&err];
[NSClassFromString(@"TTView") jr_swizzleMethod:@selector(colorForANSIColor:adjustedRelativeToColor:)
withMethod:@selector(colorForANSIColor2:adjustedRelativeToColor:)
error:&err];
/* Add the new tab */
plugin->ctl = [NSClassFromString(@"TTAppPrefsController") performSelector:NSSelectorFromString(@"sharedPreferencesController")];
[plugin->ctl window]; /* Force instanciation of the Controller */
[plugin->ctl addColorsTab]; /* Add the colors tab */
}
+ (void) redrawWindows
{
int count = [[NSApp windows] count];
int i;
for (i = 0 ; i < count ; i++) {
[[[[NSApp windows] objectAtIndex: i] contentView] setNeedsDisplay: YES];
}
}
/**
* @return the single static instance of the plugin object
*/
+ (MyTermColors*) sharedInstance
{
static MyTermColors* plugin = nil;
if (plugin == nil)
plugin = [[MyTermColors alloc] init];
return plugin;
}
/**
* Returns the profiles controller instance
*/
- (id) profilesController
{
return [[NSClassFromString(@"TTAppPrefsController") performSelector:NSSelectorFromString(@"sharedPreferencesController")]
performSelector:NSSelectorFromString(@"profilesController")];
}
@end