Skip to content
Snippets Groups Projects
Commit b40106e0 authored by Brian K. White's avatar Brian K. White
Browse files

Merge pull request #10 from gnachman/master

Sync from upstream
parents cf36dab4 1f5856f3
No related branches found
No related tags found
No related merge requests found
Showing
with 354 additions and 412 deletions
Loading
Loading
@@ -230,6 +230,9 @@
/* NSTextField (Terminal) : <title:Terminal> (oid:251) */
"Terminal" = "Terminal";
 
/* NSTextField (Answerback String) : <title:Answerback String> */
"Answerback String" = "Answerback String";
/* NSTextField (Transparency) : <title:Transparency
> (oid:172) */
"Transparency\n" = "Transparency\n";
Loading
Loading
Loading
Loading
@@ -320,6 +320,9 @@
/* NSTextField (Terminal) : <title:Terminal> (oid:1209) */
"Terminal" = "Terminal";
 
/* NSTextField (Answerback String :) : <title:Answerback String> */
"Answerback String" = "Answerback String";
/* NSBox : <title:Title> (oid:945) */
"Title" = "Title";
 
Loading
Loading
This diff is collapsed.
Loading
Loading
@@ -14,6 +14,58 @@
 
static NSTimeInterval kHighlightAnimationDuration = 0.5;
 
// A timer that does not keep a strong reference to its target. The target
// should invoke -invalidate from its -dealloc method and release the timer to
// avoid getting called posthumously.
@interface PSMWeakTimer : NSObject
@property(nonatomic, assign) id target;
@property(nonatomic, assign) SEL selector;
- (instancetype)initWithTimeInterval:(NSTimeInterval)timeInterval
target:(id)target
selector:(SEL)selector
repeats:(BOOL)repeats;
- (void)invalidate;
@end
@implementation PSMWeakTimer {
NSTimer *_timer;
BOOL _repeats;
}
- (instancetype)initWithTimeInterval:(NSTimeInterval)timeInterval
target:(id)target
selector:(SEL)selector
repeats:(BOOL)repeats {
self = [super init];
if (self) {
_target = target;
_selector = selector;
_repeats = repeats;
_timer = [NSTimer scheduledTimerWithTimeInterval:timeInterval
target:self
selector:@selector(timerDidFire:)
userInfo:nil
repeats:repeats];
}
return self;
}
- (void)invalidate {
[_timer invalidate];
_timer = nil;
}
- (void)timerDidFire:(NSTimer *)timer {
[_target performSelector:_selector withObject:timer];
if (!_repeats) {
_timer = nil;
}
}
@end
@interface PSMTabBarCell()<PSMProgressIndicatorDelegate>
@end
 
Loading
Loading
@@ -21,7 +73,7 @@ static NSTimeInterval kHighlightAnimationDuration = 0.5;
NSSize _stringSize;
PSMProgressIndicator *_indicator;
NSTimeInterval _highlightChangeTime;
NSTimer *_delayedStringValueTimer; // For bug 3957
PSMWeakTimer *_delayedStringValueTimer; // For bug 3957
}
 
#pragma mark - Creation/Destruction
Loading
Loading
@@ -76,6 +128,9 @@ static NSTimeInterval kHighlightAnimationDuration = 0.5;
}
 
- (void)dealloc {
[_delayedStringValueTimer invalidate];
[_delayedStringValueTimer release];
[_modifierString release];
_indicator.delegate = nil;
[_indicator release];
Loading
Loading
@@ -109,15 +164,16 @@ static NSTimeInterval kHighlightAnimationDuration = 0.5;
if (!_delayedStringValueTimer) {
static const NSTimeInterval kStringValueSettingDelay = 0.1;
_delayedStringValueTimer = [NSTimer scheduledTimerWithTimeInterval:kStringValueSettingDelay
target:self
selector:@selector(updateStringValue:)
userInfo:nil
repeats:NO];
_delayedStringValueTimer =
[[PSMWeakTimer alloc] initWithTimeInterval:kStringValueSettingDelay
target:self
selector:@selector(updateStringValue:)
repeats:NO];
}
}
 
- (void)updateStringValue:(NSTimer *)timer {
[_delayedStringValueTimer release];
_delayedStringValueTimer = nil;
_stringSize = [[self attributedStringValue] size];
// need to redisplay now - binding observation was too quick.
Loading
Loading
Loading
Loading
@@ -184,7 +184,10 @@ const NSInteger kPSMStartResizeAnimation = 0;
// Remove bindings.
NSArray *temp = [[_cells copy] autorelease];
for (PSMTabBarCell *cell in temp) {
[cell retain];
[self removeTabForCell:cell];
cell.controlView = nil;
[cell release];
}
 
[_overflowPopUpButton release];
Loading
Loading
Loading
Loading
@@ -546,6 +546,10 @@
<cocoa key="profileName"/>
</property>
 
<property name="answerback string" code="Answ" description="ENQ Answerback string" type="text">
<cocoa key="answerBackString"/>
</property>
</class>
 
</suite>
Loading
Loading
Loading
Loading
@@ -715,6 +715,8 @@
1DEF5E6F185F889600300319 /* Alert@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1DEF5E6C185F889600300319 /* Alert@2x.png */; };
1DEF5E70185F889600300319 /* Alert@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1DEF5E6C185F889600300319 /* Alert@2x.png */; };
1DF0897113DBAF4C00A52AD8 /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF0897013DBAF4C00A52AD8 /* Quartz.framework */; };
1DF121091C344DF100E39F1F /* iTermDynamicProfileManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DF121071C344DF100E39F1F /* iTermDynamicProfileManager.h */; };
1DF1210A1C344DF100E39F1F /* iTermDynamicProfileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DF121081C344DF100E39F1F /* iTermDynamicProfileManager.m */; };
1DF8006F18F34CAB00722B35 /* NSPopUpButton+iTerm.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DF8006D18F34CAB00722B35 /* NSPopUpButton+iTerm.h */; };
1DF8AF5813FD781700C8A435 /* SplitPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DF8AF5613FD781700C8A435 /* SplitPanel.h */; };
1DF8FEF318F3217100722B35 /* KeysPreferencesViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DF8FEF118F3217100722B35 /* KeysPreferencesViewController.h */; };
Loading
Loading
@@ -2095,6 +2097,8 @@
1DEF5E6B185F889600300319 /* Alert.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Alert.png; path = images/Alert.png; sourceTree = "<group>"; };
1DEF5E6C185F889600300319 /* Alert@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Alert@2x.png"; path = "images/Alert@2x.png"; sourceTree = "<group>"; };
1DF0897013DBAF4C00A52AD8 /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = System/Library/Frameworks/Quartz.framework; sourceTree = SDKROOT; };
1DF121071C344DF100E39F1F /* iTermDynamicProfileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iTermDynamicProfileManager.h; sourceTree = "<group>"; };
1DF121081C344DF100E39F1F /* iTermDynamicProfileManager.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = iTermDynamicProfileManager.m; sourceTree = "<group>"; tabWidth = 4; };
1DF8006D18F34CAB00722B35 /* NSPopUpButton+iTerm.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = "NSPopUpButton+iTerm.h"; sourceTree = "<group>"; tabWidth = 4; };
1DF8006E18F34CAB00722B35 /* NSPopUpButton+iTerm.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = "NSPopUpButton+iTerm.m"; sourceTree = "<group>"; tabWidth = 4; };
1DF8AF5613FD781700C8A435 /* SplitPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = SplitPanel.h; sourceTree = "<group>"; tabWidth = 4; };
Loading
Loading
@@ -2951,8 +2955,10 @@
A6E7474B188C6394005355CF /* iTermCommandHistoryCommandUseMO+Addtions.h */,
A6E74746188C6344005355CF /* iTermCommandHistoryEntryMO+Additions.h */,
1D407A2714BABE8700BD5035 /* iTermController.h */,
A6F981CB1C13783C00EE0B80 /* iTermCPS.h */,
1D4F359F1813386600699FDF /* iTermCursor.h */,
A69B45BB197CB78B00F5444D /* iTermDragHandleView.h */,
1DF121071C344DF100E39F1F /* iTermDynamicProfileManager.h */,
1DFA9D6118F37160008ADC98 /* iTermEditKeyActionWindowController.h */,
1DDBC61C12E2BCDC00BC3868 /* iTermExpose.h */,
A6E7475A188C6731005355CF /* iTermExposeGridView.h */,
Loading
Loading
@@ -3000,6 +3006,7 @@
A6B5134818E779BB00D249A5 /* iTermPasteHelper.h */,
A6E77FB61A2BEC31009B1CB6 /* iTermPasteSpecialViewController.h */,
A6E77F981A2A6B9E009B1CB6 /* iTermPasteSpecialWindowController.h */,
1DD7363F1283C2FA009B7829 /* iTermPopupWindowController.h */,
A6E7137D18F1DB1E008D94DD /* iTermPreferences.h */,
A6E7138718F26445008D94DD /* iTermPreferencesBaseViewController.h */,
A6E713A618F7C9F4008D94DD /* iTermProfilePreferences.h */,
Loading
Loading
@@ -3081,7 +3088,6 @@
1D8255FE146881EC007CAE78 /* PointerController.h */,
1DFA9D6E18F3A30F008ADC98 /* PointerPreferencesViewController.h */,
1D8255FA14687EE8007CAE78 /* PointerPrefsController.h */,
1DD7363F1283C2FA009B7829 /* iTermPopupWindowController.h */,
A68A310D186E2EDA007F550F /* PopupEntry.h */,
A68A3117186E2F54007F550F /* PopupModel.h */,
A68A3112186E2F14007F550F /* PopupWindow.h */,
Loading
Loading
@@ -3194,7 +3200,6 @@
A6A13AB918C34F6400B241ED /* VT100XtermParser.h */,
1DCA5ECD13EE507800B7725E /* WindowArrangements.h */,
1DCBC810126DD98200D5B961 /* WindowControllerInterface.h */,
A6F981CB1C13783C00EE0B80 /* iTermCPS.h */,
);
name = Headers;
path = sources/;
Loading
Loading
@@ -3822,6 +3827,7 @@
20D5CC6404E7AA0500000106 /* iTermApplicationDelegate.m */,
E8A66F030272453F03A80106 /* iTermController.m */,
A635C4351AB38205008A2DEE /* iTermCursor.m */,
1DF121081C344DF100E39F1F /* iTermDynamicProfileManager.m */,
F69E788C0AB7AC6D001EC0FF /* iTermGrowlDelegate.m */,
DDDB7ABD05D7736600E197C2 /* iTermKeyBindingMgr.m */,
A647E3B618C5884600450FA1 /* iTermObjectPool.m */,
Loading
Loading
@@ -5001,6 +5007,7 @@
A62C3B3E1BD40DC900B5629D /* iTermCapturedOutputMark.h in Headers */,
A62C3B2D1BCC24AB00B5629D /* iTermCommandHistoryCommandUseMO.h in Headers */,
1D300BAA1BD9A8BB002043F7 /* NSDate+iTerm.h in Headers */,
1DF121091C344DF100E39F1F /* iTermDynamicProfileManager.h in Headers */,
A6F981CC1C13783C00EE0B80 /* iTermCPS.h in Headers */,
A62C3B421BD40E7C00B5629D /* iTermImageMark.h in Headers */,
A62C3B2B1BCC24AB00B5629D /* iTermCommandHistoryCommandUseMO+CoreDataProperties.h in Headers */,
Loading
Loading
@@ -6035,6 +6042,7 @@
A6C763351B45C52B00E3C992 /* iTermPasteSpecialViewController.m in Sources */,
A6C7635A1B45C52B00E3C992 /* iTermOpenQuicklyWindowController.m in Sources */,
A6C7632C1B45C52B00E3C992 /* TemporaryNumberAllocator.m in Sources */,
1DF1210A1C344DF100E39F1F /* iTermDynamicProfileManager.m in Sources */,
A6C763441B45C52B00E3C992 /* iTermKeyboardNavigatableTableView.m in Sources */,
A6C762EB1B45C52B00E3C992 /* AATreeNode.m in Sources */,
A6C762CC1B45C52B00E3C992 /* iTermCursor.m in Sources */,
Loading
Loading
Loading
Loading
@@ -77,7 +77,7 @@
}
 
- (void)tearDown {
iTermApplication *app = (iTermApplication *)[NSApplication sharedApplication];
iTermApplication *app = iTermApplication.sharedApplication;
app.fakeCurrentEvent = nil;
[_currentDir release];
[_insertedText release];
Loading
Loading
@@ -340,7 +340,7 @@
byExtendingSelection:NO];
 
tool.toolWrapper.delegate.delegate = self;
iTermApplication *app = (iTermApplication *)[NSApplication sharedApplication];
iTermApplication *app = iTermApplication.sharedApplication;
CGEventRef fakeEvent = CGEventCreateKeyboardEvent(NULL, 0, true);
CGEventSetFlags(fakeEvent, kCGEventFlagMaskAlternate);
app.fakeCurrentEvent = [NSEvent eventWithCGEvent:fakeEvent];
Loading
Loading
Loading
Loading
@@ -71,12 +71,12 @@ static const NSTimeInterval kMaximumTimeToKeepFinishedDownload = 24 * 60 * 60;
}
 
- (NSMenu *)downloadsMenu {
iTermApplicationDelegate *ad = (iTermApplicationDelegate *)[[NSApplication sharedApplication] delegate];
iTermApplicationDelegate *ad = iTermApplication.sharedApplication.delegate;
return [ad downloadsMenu];
}
 
- (NSMenu *)uploadsMenu {
iTermApplicationDelegate *ad = (iTermApplicationDelegate *)[[NSApplication sharedApplication] delegate];
iTermApplicationDelegate *ad = iTermApplication.sharedApplication.delegate;
return [ad uploadsMenu];
}
 
Loading
Loading
// -*- mode:objc -*-
/*
** FindViewController.h
**
Loading
Loading
@@ -28,6 +27,7 @@
 
#import <Cocoa/Cocoa.h>
#import "FutureMethods.h"
#import "iTermController.h"
 
@protocol FindViewControllerDelegate <NSObject>
 
Loading
Loading
Loading
Loading
@@ -98,12 +98,14 @@ const CGFloat kEdgeWidth = 3;
}
 
- (void)drawFocusRingMaskWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
if (IsYosemiteOrLater()) {
[super drawFocusRingMaskWithFrame:NSInsetRect(cellFrame, kFocusRingInset.width, kFocusRingInset.height)
inView:controlView];
} else {
[super drawFocusRingMaskWithFrame:cellFrame inView:controlView];
}
if (controlView.frame.origin.y >= 0) {
if (IsYosemiteOrLater()) {
[super drawFocusRingMaskWithFrame:NSInsetRect(cellFrame, kFocusRingInset.width, kFocusRingInset.height)
inView:controlView];
} else {
[super drawFocusRingMaskWithFrame:cellFrame inView:controlView];
}
}
}
 
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
Loading
Loading
Loading
Loading
@@ -166,6 +166,7 @@ static void RollInHotkeyTerm(PseudoTerminal* term)
withURL:nil
isHotkey:YES
makeKey:YES
canActivate:YES
command:nil
block:nil];
if (session) {
Loading
Loading
@@ -444,7 +445,7 @@ static BOOL UserIsActive() {
*/
static CGEventRef OnTappedEvent(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon)
{
iTermApplicationDelegate *ad = [[NSApplication sharedApplication] delegate];
iTermApplicationDelegate *ad = iTermApplication.sharedApplication.delegate;
if (!ad.workspaceSessionActive) {
return event;
}
Loading
Loading
@@ -704,7 +705,7 @@ static CGEventRef OnTappedEvent(CGEventTapProxy proxy, CGEventType type, CGEvent
}
 
- (void)carbonHotkeyPressed:(id)handler {
iTermApplicationDelegate *ad = [[NSApplication sharedApplication] delegate];
iTermApplicationDelegate *ad = iTermApplication.sharedApplication.delegate;
if (!ad.workspaceSessionActive) {
return;
}
Loading
Loading
@@ -712,19 +713,14 @@ static CGEventRef OnTappedEvent(CGEventTapProxy proxy, CGEventType type, CGEvent
}
 
- (void)requestAccessibilityPermissionMavericks {
static BOOL alreadyAsked;
if (alreadyAsked) {
return;
}
alreadyAsked = YES;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]
forKey:(NSString *)kAXTrustedCheckOptionPrompt];
// Show a dialog prompting the user to open system prefs.
if (!AXIsProcessTrustedWithOptions((CFDictionaryRef)options)) {
return;
}
#endif
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSDictionary *options = @{ (NSString *)kAXTrustedCheckOptionPrompt: @YES };
// Show a dialog prompting the user to open system prefs.
if (!AXIsProcessTrustedWithOptions((CFDictionaryRef)options)) {
return;
}
});
}
 
- (void)beginRemappingModifiers
Loading
Loading
Loading
Loading
@@ -169,6 +169,7 @@
#define KEY_SCROLLBACK_LINES @"Scrollback Lines"
#define KEY_UNLIMITED_SCROLLBACK @"Unlimited Scrollback"
#define KEY_TERMINAL_TYPE @"Terminal Type"
#define KEY_ANSWERBACK_STRING @"Answerback String"
#define KEY_USE_CANONICAL_PARSER @"Use Canonical Parser"
#define KEY_PLACE_PROMPT_AT_FIRST_COLUMN @"Place Prompt at First Column"
#define KEY_SHOW_MARK_INDICATORS @"Show Mark Indicators"
Loading
Loading
@@ -251,4 +252,11 @@ typedef NS_ENUM(NSInteger, iTermObjectType) {
+ (NSString*)bookmarkWorkingDirectory:(Profile*)bookmark
forObjectType:(iTermObjectType)objectType;
 
// Indicates if it is safe to remove the profile from the model.
+ (BOOL)canRemoveProfile:(Profile *)profile fromModel:(ProfileModel *)model;
// Removes the profile from the model, removes key mappings that reference this profile, and posts a
// kProfileWasDeletedNotification notification, then flushes the model to backing store.
+ (void)removeProfile:(Profile *)profile fromModel:(ProfileModel *)model;
@end
Loading
Loading
@@ -24,37 +24,29 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#import "ITAddressBookMgr.h"
#import "iTerm.h"
#import "iTermAdvancedSettingsModel.h"
#import "DebugLogging.h"
#import "iTermDynamicProfileManager.h"
#import "iTermKeyBindingMgr.h"
#import "iTermPreferences.h"
#import "iTermProfilePreferences.h"
#import "ProfileModel.h"
#import "PreferencePanel.h"
#import "iTermKeyBindingMgr.h"
#import "ProfileModel.h"
#import "NSColor+iTerm.h"
#import "NSDictionary+iTerm.h"
#import "NSDictionary+Profile.h"
#import "NSMutableDictionary+Profile.h"
#import "NSFileManager+iTerm.h"
#import "NSFont+iTerm.h"
#import "NSStringIterm.h"
#import "SCEvents.h"
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <pwd.h>
@interface ITAddressBookMgr () <SCEventListenerProtocol>
@end
 
@implementation ITAddressBookMgr {
SCEvents *_events;
NSNetServiceBrowser *sshBonjourBrowser;
NSNetServiceBrowser *ftpBonjourBrowser;
NSNetServiceBrowser *telnetBonjourBrowser;
NSMutableArray *bonjourServices;
iTermDynamicProfileManager *_dynamicProfileManager;
}
+ (id)sharedInstance {
static ITAddressBookMgr* shared = nil;
 
Loading
Loading
@@ -69,7 +61,7 @@
self = [super init];
if (self) {
NSUserDefaults* prefs = [NSUserDefaults standardUserDefaults];
_dynamicProfileManager = [iTermDynamicProfileManager sharedInstance];
if ([prefs objectForKey:KEY_DEPRECATED_BOOKMARKS] &&
[[prefs objectForKey:KEY_DEPRECATED_BOOKMARKS] isKindOfClass:[NSDictionary class]] &&
![prefs objectForKey:KEY_NEW_BOOKMARKS]) {
Loading
Loading
@@ -91,9 +83,9 @@
NSLog(@"Loading profiles from %@", newBookmarks);
NSMutableArray *profiles = [NSMutableArray array];
NSMutableSet *guids = [NSMutableSet set];
if ([self loadDynamicProfilesFromFile:(NSString *)newBookmarks
intoArray:profiles
guids:guids] &&
if ([_dynamicProfileManager loadDynamicProfilesFromFile:(NSString *)newBookmarks
intoArray:profiles
guids:guids] &&
[profiles count] > 0) {
NSString *defaultGuid = profiles[0][KEY_GUID];
for (Profile *profile in profiles) {
Loading
Loading
@@ -120,7 +112,7 @@
if ([iTermPreferences boolForKey:kPreferenceKeyAddBonjourHostsToProfiles]) {
[self locateBonjourServices];
}
[iTermPreferences addObserverForKey:kPreferenceKeyAddBonjourHostsToProfiles
block:^(id previousValue, id newValue) {
if ([newValue boolValue]) {
Loading
Loading
@@ -130,25 +122,21 @@
[self removeBonjourProfiles];
}
}];
_events = [[SCEvents alloc] init];
_events.delegate = self;
[_events startWatchingPaths:@[ [self dynamicProfilesPath] ]];
 
BOOL bookmarkWithDefaultGuidExisted =
([[ProfileModel sharedInstance] bookmarkWithGuid:originalDefaultGuid] != nil);
[self reloadDynamicProfiles];
[_dynamicProfileManager reloadDynamicProfiles];
if (!bookmarkWithDefaultGuidExisted &&
[[ProfileModel sharedInstance] bookmarkWithGuid:originalDefaultGuid] != nil) {
// One of the dynamic profiles has the default guid.
[[ProfileModel sharedInstance] setDefaultByGuid:originalDefaultGuid];
}
}
return self;
}
 
- (void)dealloc
{
- (void)dealloc {
[bonjourServices removeAllObjects];
[bonjourServices release];
 
Loading
Loading
@@ -158,7 +146,6 @@
[sshBonjourBrowser release];
[ftpBonjourBrowser release];
[telnetBonjourBrowser release];
[_events release];
[super dealloc];
}
 
Loading
Loading
@@ -658,211 +645,66 @@
}
}
 
#pragma mark - SCEventListenerProtocol
- (void)pathWatcher:(SCEvents *)pathWatcher eventOccurred:(SCEvent *)event {
[self reloadDynamicProfiles];
}
#pragma mark - Dynamic Profiles
- (NSString *)dynamicProfilesPath {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *appSupport = [fileManager applicationSupportDirectory];
NSString *thePath = [appSupport stringByAppendingPathComponent:@"DynamicProfiles"];
[[NSFileManager defaultManager] createDirectoryAtPath:thePath
withIntermediateDirectories:YES
attributes:nil
error:NULL];
return thePath;
}
- (void)reloadDynamicProfiles {
NSString *path = [self dynamicProfilesPath];
NSFileManager *fileManager = [NSFileManager defaultManager];
// Load the current dynamic profiles into |newProfiles|. The |guids| set
// is used to ensure that guids are unique across all files.
NSMutableArray *newProfiles = [NSMutableArray array];
NSMutableSet *guids = [NSMutableSet set];
NSMutableArray *fileNames = [NSMutableArray array];
for (NSString *file in [fileManager enumeratorAtPath:path]) {
[fileNames addObject:file];
}
[fileNames sortUsingSelector:@selector(compare:)];
for (NSString *file in fileNames) {
if ([file hasPrefix:@"."]) {
continue;
}
NSString *fullName = [path stringByAppendingPathComponent:file];
if (![self loadDynamicProfilesFromFile:fullName intoArray:newProfiles guids:guids]) {
NSLog(@"Igoring dynamic profiles in malformed file %@ and continuing.", fullName);
}
}
// Update changes to existing dynamic profiles and add ones whose guids are
// not known.
NSArray *oldProfiles = [self dynamicProfiles];
BOOL shouldReload = NO;
for (Profile *profile in newProfiles) {
Profile *existingProfile = [self profileWithGuid:profile[KEY_GUID] inArray:oldProfiles];
if (existingProfile) {
[self updateDynamicProfile:profile];
shouldReload = YES;
} else {
[self addDynamicProfile:profile];
}
+ (BOOL)canRemoveProfile:(NSDictionary *)profile fromModel:(ProfileModel *)model {
DLog(@"removeProfile called");
if (!profile) {
DLog(@"Nil profile");
return NO;
}
 
// Remove dynamic profiles whose guids no longer exist.
for (Profile *profile in oldProfiles) {
if (![self profileWithGuid:profile[KEY_GUID] inArray:newProfiles]) {
[self removeDynamicProfile:profile];
}
}
if (shouldReload) {
[[NSNotificationCenter defaultCenter] postNotificationName:kReloadAllProfiles
object:nil
userInfo:nil];
}
}
// Load the profiles from |filename| and add valid profiles into |profiles|.
// Add their guids to |guids|.
- (BOOL)loadDynamicProfilesFromFile:(NSString *)filename
intoArray:(NSMutableArray *)profiles
guids:(NSMutableSet *)guids {
// First, try xml and binary.
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:filename];
if (!dict) {
// Try JSON
NSData *data = [NSData dataWithContentsOfFile:filename];
if (!data) {
NSLog(@"Dynamic Profiles file %@ is unreadable", filename);
return NO;
}
NSError *error = nil;
dict = [NSJSONSerialization JSONObjectWithData:data
options:0
error:&error];
if (!dict) {
NSLog(@"Dynamic Profiles file %@ doesn't contain a valid property list", filename);
return NO;
}
}
NSArray *entries = dict[@"Profiles"];
if (!entries) {
NSLog(@"Property list in %@ has no entries", entries);
if (![model bookmarkWithGuid:profile[KEY_GUID]]) {
DLog(@"Can't remove profile not in shared profile model");
return NO;
}
for (Profile *profile in entries) {
if (![profile[KEY_GUID] isKindOfClass:[NSString class]]) {
NSLog(@"Dynamic profile is missing the Guid field in file %@", filename);
continue;
}
if (![profile[KEY_NAME] isKindOfClass:[NSString class]]) {
NSLog(@"Dynamic profile with guid %@ is missing the name field", profile[KEY_GUID]);
continue;
}
if ([self nonDynamicProfileHasGuid:profile[KEY_GUID]]) {
NSLog(@"Dynamic profile with guid %@ conflicts with non-dynamic profile with same guid", profile[KEY_GUID]);
continue;
}
if ([guids containsObject:profile[KEY_GUID]]) {
NSLog(@"Two dynamic profiles have the same guid: %@", profile[KEY_GUID]);
continue;
}
[profiles addObject:profile];
[guids addObject:profile[KEY_GUID]];
}
return YES;
}
 
// Does any "regular" profile have Guid |guid|?
- (BOOL)nonDynamicProfileHasGuid:(NSString *)guid {
Profile *profile = [[ProfileModel sharedInstance] bookmarkWithGuid:guid];
if (!profile) {
if ([model numberOfBookmarks] < 2) {
DLog(@"Can't remove last profile");
return NO;
}
return !profile.profileIsDynamic;
}
 
// Returns the current dynamic profiles.
- (NSArray *)dynamicProfiles {
NSMutableArray *array = [NSMutableArray array];
for (Profile *profile in [[ProfileModel sharedInstance] bookmarks]) {
if (profile.profileIsDynamic) {
[array addObject:profile];
}
}
return array;
DLog(@"Ok to remove.");
return YES;
}
 
// Returns the first profile in |profiles| whose guid is |guid|.
- (Profile *)profileWithGuid:(NSString *)guid inArray:(NSArray *)profiles {
for (Profile *aProfile in profiles) {
if ([guid isEqualToString:aProfile[KEY_GUID]]) {
return aProfile;
}
+ (void)removeProfile:(NSDictionary *)profile fromModel:(ProfileModel *)model {
NSString *guid = profile[KEY_GUID];
DLog(@"Remove profile with guid %@...", guid);
if ([model numberOfBookmarks] == 1) {
DLog(@"Refusing to remove only profile");
return;
}
return nil;
}
 
// Reload a dynamic profile, re-merging it with its parent.
- (void)updateDynamicProfile:(Profile *)newProfile {
Profile *prototype = [self prototypeForDynamicProfile:newProfile];
NSMutableDictionary *merged = [self profileByMergingProfile:newProfile
intoProfile:prototype];
[merged profileAddDynamicTagIfNeeded];
[[ProfileModel sharedInstance] setBookmark:merged
withGuid:merged[KEY_GUID]];
}
DLog(@"Removing key bindings that reference the guid being removed");
[self removeKeyMappingsReferringToGuid:guid];
DLog(@"Removing profile from model");
[model removeProfileWithGuid:guid];
 
// Copies fields from |profile| over those in |prototype| and returns a new
// mutable dictionary.
- (NSMutableDictionary *)profileByMergingProfile:(Profile *)profile
intoProfile:(Profile *)prototype {
NSMutableDictionary *merged = [[profile mutableCopy] autorelease];
for (NSString *key in prototype) {
if (profile[key]) {
merged[key] = profile[key];
} else {
merged[key] = prototype[key];
}
}
return merged;
// Ensure all profile list views reload their data to avoid issue 4033.
DLog(@"Posting profile was deleted notification");
[[NSNotificationCenter defaultCenter] postNotificationName:kProfileWasDeletedNotification
object:nil];
[model flush];
}
 
- (Profile *)prototypeForDynamicProfile:(Profile *)profile {
Profile *prototype = nil;
NSString *parentName = profile[KEY_DYNAMIC_PROFILE_PARENT_NAME];
if (parentName) {
prototype = [[ProfileModel sharedInstance] bookmarkWithName:parentName];
if (!prototype) {
NSLog(@"Dynamic profile %@ references unknown parent name %@. Using default profile as parent.",
profile[KEY_NAME], parentName);
+ (void)removeKeyMappingsReferringToGuid:(NSString *)badRef {
for (NSString* guid in [[ProfileModel sharedInstance] guids]) {
Profile *profile = [[ProfileModel sharedInstance] bookmarkWithGuid:guid];
profile = [iTermKeyBindingMgr removeMappingsReferencingGuid:badRef fromBookmark:profile];
if (profile) {
[[ProfileModel sharedInstance] setBookmark:profile withGuid:guid];
}
}
if (!prototype) {
prototype = [[ProfileModel sharedInstance] defaultBookmark];
for (NSString* guid in [[ProfileModel sessionsInstance] guids]) {
Profile* profile = [[ProfileModel sessionsInstance] bookmarkWithGuid:guid];
profile = [iTermKeyBindingMgr removeMappingsReferencingGuid:badRef fromBookmark:profile];
if (profile) {
[[ProfileModel sessionsInstance] setBookmark:profile withGuid:guid];
}
}
return prototype;
}
// Add a new dynamic profile to the model.
- (void)addDynamicProfile:(Profile *)profile {
Profile *prototype = [self prototypeForDynamicProfile:profile];
NSMutableDictionary *merged = [self profileByMergingProfile:profile
intoProfile:prototype];
[merged profileAddDynamicTagIfNeeded];
[[ProfileModel sharedInstance] addBookmark:merged];
}
// Remove a dynamic profile from the model. Updates displays of profiles,
// references to the profile, etc.
- (void)removeDynamicProfile:(Profile *)profile {
[[PreferencePanel sharedInstance] removeProfileWithGuid:profile[KEY_GUID]];
[iTermKeyBindingMgr removeMappingsReferencingGuid:badRef fromBookmark:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:kKeyBindingsChangedNotification
object:nil
userInfo:nil];
}
 
@end
Loading
Loading
@@ -1365,6 +1365,7 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
withURL:url
isHotkey:NO
makeKey:NO
canActivate:NO
command:nil
block:nil];
}
Loading
Loading
@@ -1391,7 +1392,7 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
 
- (void)_maybeWarnAboutShortLivedSessions
{
if ([(iTermApplicationDelegate *)[NSApp delegate] isApplescriptTestApp]) {
if (iTermApplication.sharedApplication.delegate.isApplescriptTestApp) {
// The applescript test driver doesn't care about short-lived sessions.
return;
}
Loading
Loading
@@ -2709,6 +2710,7 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
// extension.
[self setEncodingFromSInt32:[iTermProfilePreferences intForKey:KEY_CHARACTER_ENCODING inProfile:aDict]];
[self setTermVariable:[iTermProfilePreferences stringForKey:KEY_TERMINAL_TYPE inProfile:aDict]];
[_terminal setAnswerBackString:[iTermProfilePreferences stringForKey:KEY_ANSWERBACK_STRING inProfile:aDict]];
[self setAntiIdleCode:[iTermProfilePreferences intForKey:KEY_IDLE_CODE inProfile:aDict]];
[self setAntiIdle:[iTermProfilePreferences boolForKey:KEY_SEND_CODE_WHEN_IDLE inProfile:aDict]];
[self setAutoClose:[iTermProfilePreferences boolForKey:KEY_CLOSE_SESSIONS_ON_END inProfile:aDict]];
Loading
Loading
@@ -3375,7 +3377,6 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
}
 
static const NSTimeInterval kUpdateTitlePeriod = 0.7;
const NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
if ([[self tab] activeSession] == self) {
// Update window info for the active tab.
NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
Loading
Loading
@@ -6213,7 +6214,7 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
ofClass:markClass] retain];
self.currentMarkOrNotePosition = _lastMark.entry.interval;
if (self.alertOnNextMark) {
NSString *action = [(iTermApplicationDelegate *)[[iTermApplication sharedApplication] delegate] markAlertAction];
NSString *action = iTermApplication.sharedApplication.delegate.markAlertAction;
if ([action isEqualToString:kMarkAlertActionPostNotification]) {
[[iTermGrowlDelegate sharedInstance] growlNotify:@"Mark Set"
withDescription:[NSString stringWithFormat:@"Session %@ #%d had a mark set.",
Loading
Loading
Loading
Loading
@@ -210,12 +210,8 @@
 
- (void)addHiddenLiveView:(SessionView *)hiddenLiveView;
 
#pragma mark NSSplitView delegate methods
- (void)splitViewDidResizeSubviews:(NSNotification *)aNotification;
// This is the implementation of splitViewDidResizeSubviews. The delegate method isn't called when
// views are added or adjusted, so we often have to call this ourselves.
- (void)_splitViewDidResizeSubviews:(NSSplitView*)splitView;
- (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex;
- (void)_recursiveRemoveView:(NSView*)theView;
// Update the tab's title from the active session's name. Needed for initialzing the tab's title
// after setting up tmux tabs.
- (void)loadTitleFromSession;
 
@end
Loading
Loading
@@ -382,6 +382,10 @@ static const BOOL USE_THIN_SPLITTERS = YES;
}
}
 
- (void)loadTitleFromSession {
tabViewItem_.label = self.activeSession.name;
}
- (void)nameOfSession:(PTYSession*)session didChangeTo:(NSString*)newName {
if ([self activeSession] == session) {
[tabViewItem_ setLabel:newName];
Loading
Loading
@@ -4304,8 +4308,9 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize* dest, CGFloat value)
[self _splitViewDidResizeSubviews:splitView];
}
 
- (void)_splitViewDidResizeSubviews:(NSSplitView*)splitView
{
// This is the implementation of splitViewDidResizeSubviews. The delegate method isn't called when
// views are added or adjusted, so we often have to call this ourselves.
- (void)_splitViewDidResizeSubviews:(NSSplitView*)splitView {
PtyLog(@"_splitViewDidResizeSubviews running");
for (NSView* subview in [splitView subviews]) {
if ([subview isKindOfClass:[SessionView class]]) {
Loading
Loading
Loading
Loading
@@ -1331,12 +1331,11 @@ static const int kDragThreshold = 3;
// key then it starts searching from the bottom again.
[_findOnPageHelper resetFindCursor];
 
static BOOL isFirstInteraction = YES;
if (isFirstInteraction) {
iTermApplicationDelegate *appDelegate = (iTermApplicationDelegate *)[[NSApplication sharedApplication] delegate];
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
iTermApplicationDelegate *appDelegate = iTermApplication.sharedApplication.delegate;
[appDelegate userDidInteractWithASession];
isFirstInteraction = NO;
}
});
 
DLog(@"PTYTextView keyDown BEGIN %@", event);
id delegate = [self delegate];
Loading
Loading
@@ -1814,7 +1813,8 @@ static const int kDragThreshold = 3;
[self updateCursor:event];
[self updateUnderlinedURLs:event];
if ([iTermPreferences boolForKey:kPreferenceKeyFocusFollowsMouse] &&
[[self window] alphaValue] > 0) {
[[self window] alphaValue] > 0 &&
![NSApp modalWindow]) {
// Some windows automatically close when they lose key status and are
// incompatible with FFM. Check if the key window or its controller implements
// disableFocusFollowsMouse and if it returns YES do nothing.
Loading
Loading
@@ -4223,13 +4223,13 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
[theMenu addItemWithTitle:scpTitle
action:@selector(downloadWithSCP:)
keyEquivalent:@""];
[theMenu addItemWithTitle:NSLocalizedStringFromTableInBundle(@"Open Selection as URL",@"iTerm", [NSBundle bundleForClass: [self class]], @"Context menu")
[theMenu addItemWithTitle:@"Open Selection as URL"
action:@selector(browse:) keyEquivalent:@""];
[[theMenu itemAtIndex:[theMenu numberOfItems] - 1] setTarget:self];
[theMenu addItemWithTitle:NSLocalizedStringFromTableInBundle(@"Search Google for Selection",@"iTerm", [NSBundle bundleForClass: [self class]], @"Context menu")
[theMenu addItemWithTitle:@"Search the Web for Selection"
action:@selector(searchInBrowser:) keyEquivalent:@""];
[[theMenu itemAtIndex:[theMenu numberOfItems] - 1] setTarget:self];
[theMenu addItemWithTitle:NSLocalizedStringFromTableInBundle(@"Send Email to Selected Address",@"iTerm", [NSBundle bundleForClass: [self class]], @"Context menu")
[theMenu addItemWithTitle:@"Send Email to Selected Address"
action:@selector(mail:) keyEquivalent:@""];
[[theMenu itemAtIndex:[theMenu numberOfItems] - 1] setTarget:self];
 
Loading
Loading
@@ -5377,8 +5377,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
}
 
- (void)useBackgroundIndicatorChanged:(NSNotification *)notification {
_showStripesWhenBroadcastingInput =
[(iTermApplicationDelegate *)[[NSApplication sharedApplication] delegate] useBackgroundPatternIndicator];
_showStripesWhenBroadcastingInput = iTermApplication.sharedApplication.delegate.useBackgroundPatternIndicator;
[self setNeedsDisplay:YES];
}
 
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@
 
NSScriptObjectSpecifier *containerRef;
 
NSArray *windows = [[iTermApplication sharedApplication] orderedTerminalWindows];
NSArray *windows = [iTermApplication.sharedApplication orderedTerminalWindows];
anIndex = [windows indexOfObjectIdenticalTo:self];
if (anIndex != NSNotFound) {
containerRef = [NSApp objectSpecifier];
Loading
Loading
@@ -52,6 +52,7 @@
withURL:nil
isHotkey:NO
makeKey:YES
canActivate:NO
command:command
block:nil];
return session.tab;
Loading
Loading
@@ -74,6 +75,7 @@
withURL:nil
isHotkey:NO
makeKey:YES
canActivate:NO
command:command
block:nil];
return session.tab;
Loading
Loading
Loading
Loading
@@ -89,8 +89,7 @@
onString:(iTermStringLine *)stringLine
atAbsoluteLineNumber:(long long)lineNumber
stop:(BOOL *)stop {
iTermApplicationDelegate *delegate =
(iTermApplicationDelegate *)[[NSApplication sharedApplication] delegate];
iTermApplicationDelegate *delegate = iTermApplication.sharedApplication.delegate;
[delegate openPasswordManagerToAccountName:[self paramWithBackreferencesReplacedWithValues:capturedStrings
count:captureCount]
inSession:aSession];
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment