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

Use unique IDs to identify PTYWindow in scripting rather than indexes. The...

Use unique IDs to identify PTYWindow in scripting rather than indexes. The notion of windows being ordered is misbegotten. It causes issues like #4157.
parent 0af54e14
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -101,7 +101,10 @@
</class>
<class name="window" code="cwin" description="A window.">
<cocoa class="PTYWindow"/>
<property name="name" code="pnam" type="text" access="r"
<property name="id" code="ID " description="The unique identifier of the session." type="text" access="r">
<cocoa key="windowIdentifier"/>
</property>
<property name="name" code="pnam" type="text" access="r"
description="The full title of the window.">
<cocoa key="title"/>
</property>
Loading
Loading
Loading
Loading
@@ -7,7 +7,6 @@
 
@implementation PTYWindow (Scripting)
 
// Object specifier
- (NSScriptObjectSpecifier *)objectSpecifier {
NSUInteger anIndex = 0;
id classDescription = nil;
Loading
Loading
@@ -19,12 +18,10 @@
if (anIndex != NSNotFound) {
containerRef = [NSApp objectSpecifier];
classDescription = [NSClassDescription classDescriptionForClass:[NSApp class]];
// Create and return the specifier
return [[[NSIndexSpecifier alloc]
initWithContainerClassDescription:classDescription
containerSpecifier:containerRef
key:@"orderedTerminalWindows"
index:anIndex] autorelease];
return [[[NSUniqueIDSpecifier alloc] initWithContainerClassDescription:classDescription
containerSpecifier:containerRef
key:@"orderedTerminalWindows"
uniqueID:self.windowIdentifier] autorelease];
} else {
return nil;
}
Loading
Loading
Loading
Loading
@@ -38,6 +38,8 @@
 
@property(nonatomic, readonly) int screenNumber;
@property(nonatomic, readonly, getter=isTogglingLionFullScreen) BOOL togglingLionFullScreen;
// A unique identifier that does not get recycled during the program's lifetime.
@property(nonatomic, readonly) NSString *windowIdentifier;
 
- (void)smartLayout;
- (void)setLayoutDone;
Loading
Loading
Loading
Loading
@@ -52,6 +52,7 @@
BOOL isTogglingLionFullScreen_;
NSObject *restoreState_;
iTermDelayedTitleSetter *_titleSetter;
NSInteger _uniqueNumber;
}
 
- (void)dealloc {
Loading
Loading
@@ -75,6 +76,14 @@
self.delegate];
}
 
- (NSString *)windowIdentifier {
if (!_uniqueNumber) {
static NSInteger nextUniqueNumber = 1;
_uniqueNumber = nextUniqueNumber++;
}
return [NSString stringWithFormat:@"window-%ld", (long)_uniqueNumber];
}
- (void)encodeRestorableStateWithCoder:(NSCoder *)coder {
[super encodeRestorableStateWithCoder:coder];
[coder encodeObject:restoreState_ forKey:kPseudoTerminalStateRestorationWindowArrangementKey];
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