Skip to content
Snippets Groups Projects
Commit fd3570ab authored by George Nachman's avatar George Nachman
Browse files

Add a cancel button to the prompt for substitutions, thus allowing session...

Add a cancel button to the prompt for substitutions, thus allowing session creation anywhere to fail. Make the parameter panel less ugly.

Preserve substitutions in saved arrangements. Fixes issue 1063.

Remove a bunch of dead code.

Fix Shell>Close terminal window by implementing -[PseudoTerminal performClose:]
parent 1703d5b2
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6206.8" systemVersion="13E28" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7531" systemVersion="14D131" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment version="1050" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6206.8"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7531"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="PseudoTerminal">
Loading
Loading
@@ -22,55 +22,38 @@
<window title="Session Parameter" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="351" userLabel="Session Parameter" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="491" y="651" width="347" height="122"/>
<rect key="contentRect" x="491" y="651" width="347" height="116"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="832"/>
<value key="minSize" type="size" width="213" height="107"/>
<view key="contentView" id="352">
<rect key="frame" x="0.0" y="0.0" width="347" height="122"/>
<rect key="frame" x="0.0" y="5" width="347" height="116"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField verticalHuggingPriority="750" id="354">
<rect key="frame" x="107" y="48" width="220" height="22"/>
<rect key="frame" x="107" y="49" width="220" height="22"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" drawsBackground="YES" id="372">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<outlet property="nextKeyView" destination="356" id="530"/>
</connections>
</textField>
<button verticalHuggingPriority="750" id="356">
<rect key="frame" x="110" y="12" width="117" height="32"/>
<autoresizingMask key="autoresizingMask"/>
<buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="374">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
DQ
</string>
</buttonCell>
<connections>
<action selector="parameterPanelEnd:" target="-2" id="359"/>
</connections>
</button>
<textField verticalHuggingPriority="750" id="355">
<rect key="frame" x="104" y="98" width="247" height="17"/>
<rect key="frame" x="104" y="79" width="119" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="left" title="This session requires you to enter:" id="373">
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="left" title="Enter the value for " id="373">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<imageView id="357">
<rect key="frame" x="20" y="38" width="79" height="77"/>
<rect key="frame" x="20" y="32" width="79" height="77"/>
<autoresizingMask key="autoresizingMask"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" animates="YES" imageScaling="axesIndependently" image="iTerm2" id="375"/>
</imageView>
<textField verticalHuggingPriority="750" id="353">
<rect key="frame" x="104" y="78" width="226" height="19"/>
<rect key="frame" x="220" y="79" width="109" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Name" id="371">
<font key="font" metaFont="system"/>
Loading
Loading
@@ -78,11 +61,40 @@ DQ
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" id="EmK-eB-jqr">
<rect key="frame" x="167" y="13" width="83" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Psw-4i-Kfp">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
Gw
</string>
</buttonCell>
<connections>
<action selector="parameterPanelEnd:" target="-2" id="MZU-S8-RjZ"/>
</connections>
</button>
<button verticalHuggingPriority="750" tag="1" id="gZv-eU-Fkp">
<rect key="frame" x="250" y="13" width="83" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="i9z-HT-tqx">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
DQ
</string>
</buttonCell>
<connections>
<action selector="parameterPanelEnd:" target="-2" id="fuU-px-Qy1"/>
</connections>
</button>
</subviews>
</view>
<connections>
<outlet property="initialFirstResponder" destination="354" id="531"/>
</connections>
<point key="canvasLocation" x="305.5" y="280"/>
</window>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" visibleAtLaunch="NO" appearanceType="aqua" animationBehavior="default" id="514">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
Loading
Loading
Loading
Loading
@@ -163,7 +163,9 @@ static void RollInHotkeyTerm(PseudoTerminal* term)
isHotkey:YES
makeKey:YES
command:nil];
term = [[iTermController sharedInstance] terminalWithSession:session];
if (session) {
term = [[iTermController sharedInstance] terminalWithSession:session];
}
}
if (term) {
[term setIsHotKeyWindow:YES];
Loading
Loading
Loading
Loading
@@ -162,6 +162,7 @@ int decode_utf8_char(const unsigned char * restrict datap,
- (NSArray *)keyValuePair;
 
- (NSString *)stringByReplacingVariableReferencesWithVariables:(NSDictionary *)vars;
- (NSString *)stringByPerformingSubstitutions:(NSDictionary *)substituions;
 
// Does self contain |substring|?
- (BOOL)containsString:(NSString *)substring;
Loading
Loading
@@ -184,6 +185,9 @@ int decode_utf8_char(const unsigned char * restrict datap,
// Characters in [0, 31] and 127 get replaced with ?
- (NSString *)stringByReplacingControlCharsWithQuestionMark;
 
// Returns the set of $$VARIABLES$$ in the string.
- (NSSet *)doubleDollarVariables;
@end
 
@interface NSMutableString (iTerm)
Loading
Loading
Loading
Loading
@@ -1070,6 +1070,18 @@ static TECObjectRef CreateTECConverterForUTF8Variants(TextEncodingVariant varian
}
}
 
- (NSString *)stringByPerformingSubstitutions:(NSDictionary *)substituions {
NSMutableString *temp = [[self mutableCopy] autorelease];
for (NSString *original in substituions) {
NSString *replacement = substituions[original];
[temp replaceOccurrencesOfString:original
withString:replacement
options:NSLiteralSearch
range:NSMakeRange(0, temp.length)];
}
return temp;
}
// Replace substrings like \(foo) or \1...\9 with the value of vars[@"foo"] or vars[@"1"].
- (NSString *)stringByReplacingVariableReferencesWithVariables:(NSDictionary *)vars {
unichar *chars = (unichar *)malloc(self.length * sizeof(unichar));
Loading
Loading
@@ -1203,6 +1215,19 @@ static TECObjectRef CreateTECConverterForUTF8Variants(TextEncodingVariant varian
return [self stringByReplacingOccurrencesOfRegex:@"[\x00-\x1f\x7f]" withString:@"?"];
}
 
- (NSSet *)doubleDollarVariables {
NSMutableSet *set = [NSMutableSet set];
[self enumerateStringsMatchedByRegex:@"\\$\\$(.*?)\\$\\$"
options:RKLNoOptions
inRange:NSMakeRange(0, self.length)
error:nil
enumerationOptions:RKLRegexEnumerationNoOptions
usingBlock:^(NSInteger captureCount, NSString *const *capturedStrings, const NSRange *capturedRanges, volatile BOOL *const stop) {
[set addObject:[[capturedStrings[0] copy] autorelease]];
}];
return set;
}
@end
 
@implementation NSMutableString (iTerm)
Loading
Loading
Loading
Loading
@@ -43,21 +43,11 @@
 
// Get the command's arguments:
NSDictionary *args = [aCommand evaluatedArguments];
NSString *command = [args objectForKey:@"command"];
BOOL isUTF8 = [[args objectForKey:@"isUTF8"] boolValue];
 
NSString *cmd;
NSArray *arg;
NSArray *components = [command componentsInShellCommand];
if (components.count > 0) {
cmd = components[0];
arg = [components subarrayWithRange:NSMakeRange(1, components.count - 1)];
} else {
cmd = command;
arg = @[];
}
[self startProgram:cmd arguments:arg environment:[NSDictionary dictionary] isUTF8:isUTF8];
[self startProgram:args[@"command"]
environment:@{}
isUTF8:[args[@"isUTF8"] boolValue]
substitutions:nil];
 
return;
}
Loading
Loading
Loading
Loading
@@ -334,12 +334,13 @@ typedef enum {
 
- (void)runCommandWithOldCwd:(NSString*)oldCWD
forObjectType:(iTermObjectType)objectType
forceUseOldCWD:(BOOL)forceUseOldCWD;
forceUseOldCWD:(BOOL)forceUseOldCWD
substitutions:(NSDictionary *)substituions;
 
- (void)startProgram:(NSString *)program
arguments:(NSArray *)prog_argv
environment:(NSDictionary *)prog_env
isUTF8:(BOOL)isUTF8;
isUTF8:(BOOL)isUTF8
substitutions:(NSDictionary *)substitutions;
 
- (void)softTerminate;
- (void)terminate;
Loading
Loading
Loading
Loading
@@ -103,6 +103,7 @@ static NSString *const SESSION_ARRANGEMENT_WINDOW_TITLE = @"Session Window Title
static NSString *const SESSION_ARRANGEMENT_NAME = @"Session Name"; // server-set "icon" (tab) name
static NSString *const SESSION_ARRANGEMENT_GUID = @"Session GUID"; // A truly unique ID.
static NSString *const SESSION_ARRANGEMENT_LIVE_SESSION = @"Live Session"; // If zoomed, this gives the "live" session's arrangement.
static NSString *const SESSION_ARRANGEMENT_SUBSTITUTIONS = @"Substitutions"; // Dictionary for $$VAR$$ substitutions
static NSString *const SESSION_UNIQUE_ID = @"Session Unique ID"; // -uniqueId, used for restoring soft-terminated sessions
 
static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
Loading
Loading
@@ -143,9 +144,9 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
// Info about what happens when the program is run so it can be restarted after
// a broken pipe if the user so chooses.
@property(nonatomic, copy) NSString *program;
@property(nonatomic, copy) NSArray *arguments;
@property(nonatomic, copy) NSDictionary *environment;
@property(nonatomic, assign) BOOL isUTF8;
@property(nonatomic, copy) NSDictionary *substitutions;
@property(nonatomic, copy) NSString *guid;
@property(nonatomic, retain) iTermPasteHelper *pasteHelper;
@property(nonatomic, copy) NSString *lastCommand;
Loading
Loading
@@ -446,7 +447,6 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
[_badgeFormat release];
[_variables release];
[_program release];
[_arguments release];
[_environment release];
[_commands release];
[_directories release];
Loading
Loading
@@ -454,6 +454,7 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
[_bellRate release];
[_guid release];
[_lastCommand release];
[_substitutions release];
[[NSNotificationCenter defaultCenter] removeObserver:self];
 
if (_dvrDecoder) {
Loading
Loading
@@ -673,7 +674,8 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
NSString *oldCWD = arrangement[SESSION_ARRANGEMENT_WORKING_DIRECTORY];
[aSession runCommandWithOldCwd:oldCWD
forObjectType:objectType
forceUseOldCWD:contents != nil && oldCWD.length];
forceUseOldCWD:contents != nil && oldCWD.length
substitutions:arrangement[SESSION_ARRANGEMENT_SUBSTITUTIONS]];
 
// GUID will be set for new saved arrangements since late 2014.
// Older versions won't be able to associate saved state with windows from a saved arrangement.
Loading
Loading
@@ -866,38 +868,27 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
 
- (void)runCommandWithOldCwd:(NSString*)oldCWD
forObjectType:(iTermObjectType)objectType
forceUseOldCWD:(BOOL)forceUseOldCWD {
NSMutableString *cmd;
NSArray *arg;
forceUseOldCWD:(BOOL)forceUseOldCWD
substitutions:(NSDictionary *)substitutions {
NSString *pwd;
BOOL isUTF8;
 
// Grab the addressbook command
Profile* addressbookEntry = [self profile];
Profile *profileForComputingCommand = addressbookEntry;
Profile* profile = [self profile];
Profile *profileForComputingCommand = profile;
if (forceUseOldCWD) {
NSMutableDictionary *hackedProfile = [[addressbookEntry mutableCopy] autorelease];
hackedProfile[KEY_CUSTOM_DIRECTORY] = kProfilePreferenceInitialDirectoryCustomValue;
profileForComputingCommand = hackedProfile;
}
cmd = [[[NSMutableString alloc] initWithString:[ITAddressBookMgr bookmarkCommand:profileForComputingCommand
forObjectType:objectType]] autorelease];
NSMutableString* theName = [[[NSMutableString alloc] initWithString:[addressbookEntry objectForKey:KEY_NAME]] autorelease];
// Get session parameters
[[[self tab] realParentWindow] getSessionParameters:cmd withName:theName];
NSArray *components = [cmd componentsInShellCommand];
if (components.count > 0) {
cmd = components[0];
arg = [components subarrayWithRange:NSMakeRange(1, components.count - 1)];
} else {
arg = @[];
NSMutableDictionary *temp = [[profile mutableCopy] autorelease];
temp[KEY_CUSTOM_DIRECTORY] = kProfilePreferenceInitialDirectoryCustomValue;
profileForComputingCommand = temp;
}
NSString *cmd = [ITAddressBookMgr bookmarkCommand:profileForComputingCommand
forObjectType:objectType];
NSString *theName = [profile[KEY_NAME] stringByPerformingSubstitutions:substitutions];
 
if (forceUseOldCWD) {
pwd = oldCWD;
} else {
pwd = [ITAddressBookMgr bookmarkWorkingDirectory:addressbookEntry
pwd = [ITAddressBookMgr bookmarkWorkingDirectory:profile
forObjectType:objectType];
}
if ([pwd length] == 0) {
Loading
Loading
@@ -907,13 +898,15 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
pwd = NSHomeDirectory();
}
}
NSDictionary *env = [NSDictionary dictionaryWithObject:pwd forKey:@"PWD"];
isUTF8 = ([[addressbookEntry objectForKey:KEY_CHARACTER_ENCODING] unsignedIntValue] == NSUTF8StringEncoding);
isUTF8 = ([profile[KEY_CHARACTER_ENCODING] unsignedIntValue] == NSUTF8StringEncoding);
 
[[[self tab] realParentWindow] setName:theName forSession:self];
 
// Start the command
[self startProgram:cmd arguments:arg environment:env isUTF8:isUTF8];
[self startProgram:cmd
environment:@{ @"PWD": pwd }
isUTF8:isUTF8
substitutions:substitutions];
}
 
- (void)setWidth:(int)width height:(int)height
Loading
Loading
@@ -1022,14 +1015,24 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
return ![iTermAdvancedSettingsModel doNotSetCtype];
}
 
- (void)startProgram:(NSString *)program
arguments:(NSArray *)arguments
- (void)startProgram:(NSString *)command
environment:(NSDictionary *)environment
isUTF8:(BOOL)isUTF8 {
self.program = program;
self.arguments = arguments;
isUTF8:(BOOL)isUTF8
substitutions:(NSDictionary *)substitutions {
self.program = command;
self.environment = environment;
self.isUTF8 = isUTF8;
self.substitutions = substitutions;
NSString *program = [command stringByPerformingSubstitutions:substitutions];
NSArray *components = [program componentsInShellCommand];
NSArray *arguments;
if (components.count > 0) {
program = components[0];
arguments = [components subarrayWithRange:NSMakeRange(1, components.count - 1)];
} else {
arguments = @[];
}
 
NSMutableDictionary *env = [NSMutableDictionary dictionaryWithDictionary:environment];
 
Loading
Loading
@@ -1072,13 +1075,13 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
[_tab indexOfSessionView:[self view]]];
env[@"ITERM_SESSION_ID"] = itermId;
if (_profile[KEY_NAME]) {
env[@"ITERM_PROFILE"] = _profile[KEY_NAME];
env[@"ITERM_PROFILE"] = [_profile[KEY_NAME] stringByPerformingSubstitutions:substitutions];
}
if ([_profile[KEY_AUTOLOG] boolValue]) {
[_shell loggingStartWithPath:[self _autoLogFilenameForTermId:itermId]];
}
[_shell launchWithPath:_program
arguments:_arguments
[_shell launchWithPath:program
arguments:arguments
environment:env
width:[_screen width]
height:[_screen height]
Loading
Loading
@@ -1676,9 +1679,9 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
[_shell setWidth:_screen.width
height:_screen.height];
[self startProgram:_program
arguments:_arguments
environment:_environment
isUTF8:_isUTF8];
isUTF8:_isUTF8
substitutions:_substitutions];
}
 
- (NSSize)idealScrollViewSizeWithStyle:(NSScrollerStyle)scrollerStyle
Loading
Loading
@@ -2882,6 +2885,9 @@ static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
result[SESSION_ARRANGEMENT_ROWS] = @(_screen.height);
result[SESSION_ARRANGEMENT_BOOKMARK] = _profile;
result[SESSION_ARRANGEMENT_BOOKMARK_NAME] = _bookmarkName;
if (_substitutions) {
result[SESSION_ARRANGEMENT_SUBSTITUTIONS] = _substitutions;
}
if (_name) {
result[SESSION_ARRANGEMENT_NAME] = _name;
}
Loading
Loading
Loading
Loading
@@ -218,8 +218,7 @@ static void HandleSigChld(int n)
environment:(NSDictionary*)env
width:(int)width
height:(int)height
isUTF8:(BOOL)isUTF8
{
isUTF8:(BOOL)isUTF8 {
struct termios term;
struct winsize win;
char theTtyname[PATH_MAX];
Loading
Loading
Loading
Loading
@@ -2025,22 +2025,6 @@ static const int kDragThreshold = 3;
[self updateTrackingAreas]; // Cause mouseMoved to be (not) called on movement if cmd is down (up).
}
 
- (BOOL)reportingMouseClicks {
if ([self xtermMouseReporting]) {
VT100Terminal *terminal = [_dataSource terminal];
switch ([terminal mouseMode]) {
case MOUSE_REPORTING_NORMAL:
case MOUSE_REPORTING_BUTTON_MOTION:
case MOUSE_REPORTING_ALL_MOTION:
return YES;
default:
break;
}
}
return NO;
}
- (BOOL)canOpenURL:(NSString *)aURLString onLine:(int)line {
// A URL is openable if Semantic History can handle it or if it looks enough like a web URL to
// pass muster.
Loading
Loading
@@ -4168,8 +4152,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
[[NSWorkspace sharedWorkspace] openURL:url];
}
 
- (void)browse:(id)sender
{
- (void)browse:(id)sender {
[self _findUrlInString:[self selectedText]
andOpenInBackground:NO];
}
Loading
Loading
@@ -5740,28 +5723,6 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
}
}
 
- (void)_openSemanticHistoryForUrl:(NSString *)aURLString
atLine:(long long)line
inBackground:(BOOL)background
prefix:(NSString *)prefix
suffix:(NSString *)suffix
{
NSString* trimmedURLString;
trimmedURLString = [aURLString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *workingDirectory = [_dataSource workingDirectoryOnLine:line];
if (![self openSemanticHistoryPath:trimmedURLString
workingDirectory:workingDirectory
prefix:prefix
suffix:suffix]) {
[self _findUrlInString:aURLString
andOpenInBackground:background];
}
return;
}
// Opens a URL in the default browser in background or foreground
// Don't call this unless you know that iTerm2 is NOT the handler for this scheme!
- (void)openURL:(NSURL *)url inBackground:(BOOL)background
Loading
Loading
Loading
Loading
@@ -36,55 +36,11 @@
return nil;
}
 
- (id)handleLaunchScriptCommand:(NSScriptCommand *)command {
// Get the command's arguments:
NSDictionary *args = [command evaluatedArguments];
NSString *session = [args objectForKey:@"session"];
NSDictionary *abEntry;
abEntry = [[ProfileModel sharedInstance] bookmarkWithName:session];
if (abEntry == nil) {
abEntry = [[ProfileModel sharedInstance] defaultBookmark];
}
if (abEntry == nil) {
NSMutableDictionary* aDict = [[[NSMutableDictionary alloc] init] autorelease];
[ITAddressBookMgr setDefaultsInBookmark:aDict];
[aDict setObject:[ProfileModel freshGuid] forKey:KEY_GUID];
abEntry = aDict;
}
return [[iTermController sharedInstance] launchBookmark:abEntry inTerminal:_delegate];
}
- (id)handleCloseScriptCommand:(NSScriptCommand *)command {
[self performClose:nil];
return nil;
}
 
- (void)handleSplitScriptCommand:(NSScriptCommand *)command {
// Get the command's arguments:
NSDictionary *args = [command evaluatedArguments];
NSString *direction = args[@"direction"];
BOOL isVertical = [direction isEqualToString:@"vertical"];
NSString *profileName = args[@"profile"];
NSDictionary *abEntry;
abEntry = [[ProfileModel sharedInstance] bookmarkWithName:profileName];
if (abEntry == nil) {
abEntry = [[ProfileModel sharedInstance] defaultBookmark];
}
if (abEntry == nil) {
NSMutableDictionary* aDict = [NSMutableDictionary dictionary];
[ITAddressBookMgr setDefaultsInBookmark:aDict];
[aDict setObject:[ProfileModel freshGuid] forKey:KEY_GUID];
abEntry = aDict;
}
[_delegate splitVertically:isVertical
withBookmark:abEntry
targetSession:[[_delegate currentTab] activeSession]];
}
- (void)handleCreateTabWithDefaultProfileCommand:(NSScriptCommand *)scriptCommand {
NSDictionary *args = [scriptCommand evaluatedArguments];
NSString *command = args[@"command"];
Loading
Loading
Loading
Loading
@@ -243,7 +243,6 @@ extern NSString *const kPseudoTerminalStateRestorationWindowArrangementKey;
// Return all sessions in all tabs.
- (NSArray*)allSessions;
 
- (PTYSession *)createSessionWithProfile:(NSDictionary *)addressbookEntry withURL:(NSString *)url;
- (PTYSession *)createSessionWithProfile:(NSDictionary *)addressbookEntry
withURL:(NSString *)url
forObjectType:(iTermObjectType)objectType;
Loading
Loading
This diff is collapsed.
Loading
Loading
@@ -213,12 +213,6 @@ typedef enum {
// or "Finish" if it's closed.
- (void)setName:(NSString *)theSessionName forSession:(PTYSession*)aSession;
 
// For each instance of a substring like $$foo$$ in command and name,
// prompt the user for a value and replace $$foo$$ with the user-entered
// value in both command and name.
- (void)getSessionParameters:(NSMutableString *)command
withName:(NSMutableString *)name;
// Return the name of the foreground session.
- (NSString *)currentSessionName;
 
Loading
Loading
Loading
Loading
@@ -1554,11 +1554,6 @@ static BOOL hasBecomeActive = NO;
[[iTermController sharedInstance] saveWindowArrangement:NO];
}
 
- (IBAction)loadWindowArrangement:(id)sender
{
[[iTermController sharedInstance] loadWindowArrangementWithName:[WindowArrangements defaultArrangementName]];
}
// TODO(georgen): Disable "Edit Current Session..." when there are no current sessions.
- (IBAction)editCurrentSession:(id)sender
{
Loading
Loading
@@ -1627,11 +1622,6 @@ static BOOL hasBecomeActive = NO;
 
@implementation iTermApplicationDelegate (MoreActions)
 
- (void)newSessionInTabAtIndex:(id)sender
{
[[iTermController sharedInstance] newSessionInTabAtIndex:sender];
}
- (void)newSessionInWindowAtIndex: (id) sender
{
[[iTermController sharedInstance] newSessionInWindowAtIndex:sender];
Loading
Loading
Loading
Loading
@@ -72,7 +72,7 @@
// actions are forwarded from application
- (IBAction)newWindow:(id)sender;
- (void)newWindow:(id)sender possiblyTmux:(BOOL)possiblyTmux;
- (IBAction)newSessionWithSameProfile:(id)sender;
- (void)newSessionWithSameProfile:(id)sender;
- (IBAction)newSession:(id)sender;
- (void)newSession:(id)sender possiblyTmux:(BOOL)possiblyTmux;
- (IBAction) previousTerminal:(id)sender;
Loading
Loading
@@ -102,7 +102,6 @@
 
- (PseudoTerminal *)currentTerminal;
- (void)terminalWillClose:(PseudoTerminal*)theTerminalWindow;
- (void)addBookmarksToMenu:(NSMenu *)aMenu startingAt:(int)startingAt;
- (void)addBookmarksToMenu:(NSMenu *)aMenu
withSelector:(SEL)selector
openAllSelector:(SEL)openAllSelector
Loading
Loading
Loading
Loading
@@ -287,7 +287,7 @@ static BOOL initDone = NO;
keyWindowIndexMemo_ = i;
}
 
- (void)newSessionInWindowAtIndex:(id) sender
- (void)newSessionInWindowAtIndex:(id)sender
{
Profile* bookmark = [[ProfileModel sharedInstance] bookmarkWithGuid:[sender representedObject]];
if (bookmark) {
Loading
Loading
@@ -300,8 +300,7 @@ static BOOL initDone = NO;
{
}
 
- (IBAction)newSessionWithSameProfile:(id)sender
{
- (void)newSessionWithSameProfile:(id)sender {
Profile *bookmark = nil;
if (FRONT) {
bookmark = [[FRONT currentSession] profile];
Loading
Loading
@@ -309,17 +308,11 @@ static BOOL initDone = NO;
[self launchBookmark:bookmark inTerminal:FRONT];
}
 
- (IBAction)newSession:(id)sender
{
DLog(@"iTermController newSession:");
[self newSession:sender possiblyTmux:NO];
}
// Launch a new session using the default profile. If the current session is
// tmux and possiblyTmux is true, open a new tmux session.
- (void)newSession:(id)sender possiblyTmux:(BOOL)possiblyTmux
{
DLog(@"newSession:%@ possiblyTmux:%d from %@", sender, (int)possiblyTmux, [NSThread callStackSymbols]);
- (void)newSession:(id)sender possiblyTmux:(BOOL)possiblyTmux {
DLog(@"newSession:%@ possiblyTmux:%d from %@",
sender, (int)possiblyTmux, [NSThread callStackSymbols]);
if (possiblyTmux &&
FRONT &&
[[FRONT currentSession] isTmuxClient]) {
Loading
Loading
@@ -835,26 +828,6 @@ static BOOL initDone = NO;
}
}
 
- (void)_newSessionsInManyWindowsInMenu:(NSMenu*)parent
{
for (NSMenuItem* item in [parent itemArray]) {
if (![item isSeparatorItem] && ![item submenu]) {
NSString* guid = [item representedObject];
Profile* bookmark = [[ProfileModel sharedInstance] bookmarkWithGuid:guid];
if (bookmark) {
[self launchBookmark:bookmark inTerminal:nil];
}
} else if (![item isSeparatorItem] && [item submenu]) {
[self _newSessionsInManyWindowsInMenu:[item submenu]];
}
}
}
- (void)newSessionsInManyWindows:(id)sender
{
[self _newSessionsInManyWindowsInMenu:[sender menu]];
}
- (PseudoTerminal *)terminalWithTab:(PTYTab *)tab
{
for (PseudoTerminal *term in [self terminals]) {
Loading
Loading
@@ -908,7 +881,9 @@ static BOOL initDone = NO;
for (Profile* bookmark in bookmarks) {
if (!term) {
PTYSession* session = [self launchBookmark:bookmark inTerminal:nil];
term = [self terminalWithSession:session];
if (session) {
term = [self terminalWithSession:session];
}
} else {
[self launchBookmark:bookmark inTerminal:term];
}
Loading
Loading
@@ -981,14 +956,6 @@ static BOOL initDone = NO;
}
}
 
- (void)addBookmarksToMenu:(NSMenu *)aMenu startingAt:(int)startingAt
{
[self addBookmarksToMenu:aMenu
withSelector:@selector(newSessionInTabAtIndex:)
openAllSelector:@selector(newSessionsInWindow:)
startingAt:startingAt];
}
- (void)irAdvance:(int)dir
{
[FRONT irAdvance:dir];
Loading
Loading
@@ -1208,6 +1175,11 @@ static BOOL initDone = NO;
} else {
session = [term createTabWithProfile:aDict withCommand:command];
}
if (!session && term.numberOfTabs == 0) {
[[term window] close];
return nil;
}
if (toggle) {
[term delayedEnterFullscreen];
}
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