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

Prepare to store the tmux integration profile in the tmux controller. This...

Prepare to store the tmux integration profile in the tmux controller. This allows each tmux session to use a different profile. This is a step toward making every pane able to use a different profile (but the same font, of course).

The change is hidden behind an advanced pref which is off by default.

It also fixes a bug where a new tmux tab in a fullscreen window when legacy scrollbars are enabled might have the wrong size.
parent 342edb03
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -191,6 +191,9 @@ typedef enum {
// Remove a session from the tab, even if it's the only one.
- (void)sessionRemoveSession:(PTYSession *)session;
 
// Returns the size of the tab in rows x cols. Initial tmux client size.
- (VT100GridSize)sessionTmuxSizeWithProfile:(Profile *)profile;
@end
 
@class SessionView;
Loading
Loading
Loading
Loading
@@ -492,6 +492,10 @@ static const NSUInteger kMaxHosts = 100;
[gRegisteredSessionContents removeAllObjects];
}
 
- (instancetype)initWithCoder:(NSCoder *)coder {
return [self initSynthetic:NO];
}
- (instancetype)initSynthetic:(BOOL)synthetic {
self = [super init];
if (self) {
Loading
Loading
@@ -4913,14 +4917,19 @@ ITERM_WEAKLY_REFERENCEABLE
}
self.tmuxMode = TMUX_GATEWAY;
_tmuxGateway = [[TmuxGateway alloc] initWithDelegate:self];
ProfileModel *model;
if (_isDivorced) {
model = [ProfileModel sessionsInstance];
} else {
model = [ProfileModel sharedInstance];
}
_tmuxController = [[TmuxController alloc] initWithGateway:_tmuxGateway
clientName:[self preferredTmuxClientName]];
clientName:[self preferredTmuxClientName]
profile:[iTermAdvancedSettingsModel tmuxUsesDedicatedProfile] ? [[ProfileModel sharedInstance] tmuxProfile] : self.profile
profileModel:model];
_tmuxController.ambiguousIsDoubleWidth = _treatAmbiguousWidthAsDoubleWidth;
_tmuxController.unicodeVersion = _unicodeVersion;
NSSize theSize;
Profile *tmuxBookmark = [[ProfileModel sharedInstance] tmuxProfile];
theSize.width = MAX(1, [[tmuxBookmark objectForKey:KEY_COLUMNS] intValue]);
theSize.height = MAX(1, [[tmuxBookmark objectForKey:KEY_ROWS] intValue]);
// We intentionally don't send anything to tmux yet. We wait to get a
// begin-end pair from it to make sure everything is cool (we have a legit
// session) and then we start going.
Loading
Loading
@@ -5345,20 +5354,20 @@ ITERM_WEAKLY_REFERENCEABLE
[_tmuxController session:sessionId renamedTo:newName];
}
 
- (NSSize)tmuxBookmarkSize
{
NSDictionary *dict = [[ProfileModel sharedInstance] tmuxProfile];
return NSMakeSize([[dict objectForKey:KEY_COLUMNS] intValue],
[[dict objectForKey:KEY_ROWS] intValue]);
- (VT100GridSize)tmuxClientSize {
return [_delegate sessionTmuxSizeWithProfile:_tmuxController.profile];
}
 
- (NSInteger)tmuxNumHistoryLinesInBookmark {
NSDictionary *dict = [[ProfileModel sharedInstance] tmuxProfile];
if ([[dict objectForKey:KEY_UNLIMITED_SCROLLBACK] boolValue]) {
- (NSInteger)tmuxNumberOfLinesOfScrollbackHistory {
Profile *profile = _tmuxController.profile;
if ([iTermAdvancedSettingsModel tmuxUsesDedicatedProfile]) {
profile = [[ProfileModel sharedInstance] tmuxProfile];
}
if ([profile[KEY_UNLIMITED_SCROLLBACK] boolValue]) {
// 10M is close enough to infinity to be indistinguishable.
return 10 * 1000 * 1000;
} else {
return [[dict objectForKey:KEY_SCROLLBACK_LINES] integerValue];
return [profile[KEY_SCROLLBACK_LINES] integerValue];
}
}
 
Loading
Loading
Loading
Loading
@@ -65,8 +65,6 @@
// activities, their contents can be rescued.
+ (void)registerSessionsInArrangement:(NSDictionary *)arrangement;
 
+ (NSDictionary *)tmuxBookmark;
+ (void)drawArrangementPreview:(NSDictionary*)arrangement frame:(NSRect)frame;
 
+ (PTYTab *)openTabWithArrangement:(NSDictionary*)arrangement
Loading
Loading
@@ -79,7 +77,8 @@
inTerminal:(NSWindowController<iTermWindowController> *)term
hasFlexibleView:(BOOL)hasFlexible
viewMap:(NSDictionary<NSNumber *, SessionView *> *)viewMap
sessionMap:(NSDictionary<NSString *, PTYSession *> *)sessionMap;
sessionMap:(NSDictionary<NSString *, PTYSession *> *)sessionMap
tmuxController:(TmuxController *)tmuxController;
 
+ (NSDictionary<NSString *, PTYSession *> *)sessionMapWithArrangement:(NSDictionary *)arrangement
sessions:(NSArray *)sessions;
Loading
Loading
@@ -89,11 +88,6 @@
tmuxWindow:(int)tmuxWindow
tmuxController:(TmuxController *)tmuxController;
 
+ (void)setTmuxFont:(NSFont *)font
nonAsciiFont:(NSFont *)nonAsciiFont
hSpacing:(double)hs
vSpacing:(double)vs;
+ (NSDictionary *)repairedArrangement:(NSDictionary *)arrangement
replacingProfileWithGUID:(NSString *)badGuid
withProfile:(Profile *)goodProfile;
Loading
Loading
@@ -187,6 +181,11 @@
- (BOOL)layoutIsTooLarge;
- (TmuxController *)tmuxController;
 
- (void)setTmuxFont:(NSFont *)font
nonAsciiFont:(NSFont *)nonAsciiFont
hSpacing:(double)hs
vSpacing:(double)vs;
- (void)moveCurrentSessionDividerBy:(int)direction horizontally:(BOOL)horizontally;
- (BOOL)canMoveCurrentSessionDividerBy:(int)direction horizontally:(BOOL)horizontally;
 
Loading
Loading
Loading
Loading
@@ -391,7 +391,8 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
inTerminal:[self realParentWindow]
hasFlexibleView:flexibleView_ != nil
viewMap:nil
sessionMap:nil];
sessionMap:nil
tmuxController:tmuxController_];
return [theCopy retain];
}
 
Loading
Loading
@@ -742,7 +743,7 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
if (!flexibleView_) {
return;
}
NSSize cellSize = [PTYTab cellSizeForBookmark:[PTYTab tmuxBookmark]];
NSSize cellSize = [PTYTab cellSizeForBookmark:self.tmuxController.profile];
if (![realParentWindow_ anyFullScreen] &&
flexibleView_.frame.size.width > root_.frame.size.width &&
flexibleView_.frame.size.width - root_.frame.size.width < cellSize.width &&
Loading
Loading
@@ -751,8 +752,7 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
// Root is just slightly smaller than flexibleView, by less than the size of a character.
// Set flexible view's color to the default background color for tmux tabs.
NSColor *bgColor;
Profile *bm = [PTYTab tmuxBookmark];
bgColor = [ITAddressBookMgr decodeColor:[bm objectForKey:KEY_BACKGROUND_COLOR]];
bgColor = [ITAddressBookMgr decodeColor:self.tmuxController.profile[KEY_BACKGROUND_COLOR]];
[flexibleView_ setColor:bgColor];
} else {
// Fullscreen, overly large flexible view, or exact size flex view.
Loading
Loading
@@ -2438,7 +2438,8 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
inTerminal:(NSWindowController<iTermWindowController> *)term
hasFlexibleView:(BOOL)hasFlexible
viewMap:(NSDictionary<NSNumber *, SessionView *> *)viewMap
sessionMap:(NSDictionary<NSString *, PTYSession *> *)sessionMap {
sessionMap:(NSDictionary<NSString *, PTYSession *> *)sessionMap
tmuxController:(TmuxController *)tmuxController {
PTYTab *theTab;
NSMutableArray<PTYSession *> *revivedSessions = [NSMutableArray array];
// Build a tree with splitters and SessionViews but no PTYSessions.
Loading
Loading
@@ -2449,6 +2450,7 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
 
// Create a tab.
theTab = [[[PTYTab alloc] initWithRoot:newRoot sessions:nil] autorelease];
theTab->tmuxController_ = [tmuxController retain];
if (hasFlexible) {
[theTab enableFlexibleView];
}
Loading
Loading
@@ -2522,7 +2524,8 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
inTerminal:term
hasFlexibleView:hasFlexible
viewMap:viewMap
sessionMap:sessionMap];
sessionMap:sessionMap
tmuxController:nil];
if ([[theTab sessionViews] count] == 0) {
return nil;
}
Loading
Loading
@@ -2813,41 +2816,17 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
[self nameOfSession:self.activeSession didChangeTo:self.activeSession.name];
}
 
+ (Profile *)tmuxBookmark {
return [[ProfileModel sharedInstance] tmuxProfile];
}
+ (void)setTmuxFont:(NSFont *)font
nonAsciiFont:(NSFont *)nonAsciiFont
hSpacing:(double)hs
vSpacing:(double)vs {
[[ProfileModel sharedInstance] setObject:[font stringValue]
forKey:KEY_NORMAL_FONT
inBookmark:[PTYTab tmuxBookmark]];
[[ProfileModel sharedInstance] setObject:[nonAsciiFont stringValue]
forKey:KEY_NON_ASCII_FONT
inBookmark:[PTYTab tmuxBookmark]];
[[ProfileModel sharedInstance] setObject:[NSNumber numberWithDouble:hs]
forKey:KEY_HORIZONTAL_SPACING
inBookmark:[PTYTab tmuxBookmark]];
[[ProfileModel sharedInstance] setObject:[NSNumber numberWithDouble:vs]
forKey:KEY_VERTICAL_SPACING
inBookmark:[PTYTab tmuxBookmark]];
[[ProfileModel sharedInstance] postChangeNotification];
}
- (void)setTmuxFont:(NSFont *)font
nonAsciiFont:(NSFont *)nonAsciiFont
hSpacing:(double)hs
vSpacing:(double)vs {
[PTYTab setTmuxFont:font nonAsciiFont:nonAsciiFont hSpacing:hs vSpacing:vs];
[self.tmuxController setTmuxFont:font nonAsciiFont:nonAsciiFont hSpacing:hs vSpacing:vs];
}
 
+ (void)setSizesInTmuxParseTree:(NSMutableDictionary *)parseTree
inTerminal:(NSWindowController<iTermWindowController> *)term
zoomed:(BOOL)zoomed {
Profile *bookmark = [PTYTab tmuxBookmark];
zoomed:(BOOL)zoomed
profile:(Profile *)profile {
NSArray *theChildren = [parseTree objectForKey:kLayoutDictChildrenKey];
BOOL haveMultipleSessions = ([theChildren count] > 1);
BOOL showTitles =
Loading
Loading
@@ -2855,7 +2834,7 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
// Begin by decorating the tree with pixel sizes.
[PTYTab _recursiveSetSizesInTmuxParseTree:parseTree
showTitles:showTitles
bookmark:bookmark
bookmark:profile
inTerminal:term];
}
 
Loading
Loading
@@ -2879,7 +2858,10 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
}
 
- (void)reloadTmuxLayout {
[PTYTab setSizesInTmuxParseTree:parseTree_ inTerminal:realParentWindow_ zoomed:isMaximized_];
[PTYTab setSizesInTmuxParseTree:parseTree_
inTerminal:realParentWindow_
zoomed:isMaximized_
profile:self.tmuxController.profile];
[self resizeViewsInViewHierarchy:root_ forNewLayout:parseTree_];
[[root_ window] makeFirstResponder:[[self activeSession] textview]];
}
Loading
Loading
@@ -2888,7 +2870,7 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
inTerminal:(NSWindowController<iTermWindowController> *)term
tmuxWindow:(int)tmuxWindow
tmuxController:(TmuxController *)tmuxController {
[PTYTab setSizesInTmuxParseTree:parseTree inTerminal:term zoomed:NO];
[PTYTab setSizesInTmuxParseTree:parseTree inTerminal:term zoomed:NO profile:tmuxController.profile];
parseTree = [PTYTab parseTreeWithInjectedRootSplit:parseTree];
 
// Grow the window to fit the tab before adding it
Loading
Loading
@@ -2898,13 +2880,14 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
 
// Now we can make an arrangement and restore it.
NSDictionary *arrangement = [PTYTab arrangementForDecoratedTmuxParseTree:parseTree
bookmark:[PTYTab tmuxBookmark]
bookmark:tmuxController.profile
activeWindowPane:0];
PTYTab *theTab = [self tabWithArrangement:arrangement
inTerminal:term
hasFlexibleView:YES
viewMap:nil
sessionMap:nil];
sessionMap:nil
tmuxController:tmuxController];
 
NSArray *theChildren = [parseTree objectForKey:kLayoutDictChildrenKey];
BOOL haveMultipleSessions = ([theChildren count] > 1);
Loading
Loading
@@ -2917,7 +2900,6 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
 
theTab->tmuxWindow_ = tmuxWindow;
theTab->tmuxController_ = [tmuxController retain];
theTab->parseTree_ = [parseTree retain];
 
if ([parseTree[kLayoutDictTabOpenedManually] boolValue]) {
Loading
Loading
@@ -2972,7 +2954,7 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
origin:(NSPoint)origin {
BOOL first = YES;
int minPos, size;
NSSize cellSize = [PTYTab cellSizeForBookmark:[PTYTab tmuxBookmark]];
NSSize cellSize = [PTYTab cellSizeForBookmark:self.tmuxController.profile];
for (NSView *view in [splitter subviews]) {
if (forHeight == [splitter isVertical]) {
if ([splitter isVertical]) {
Loading
Loading
@@ -3094,7 +3076,7 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
targetSizePixels.height - rootSizePixels.height);
 
// The size of a character
NSSize charSize = [PTYTab cellSizeForBookmark:[PTYTab tmuxBookmark]];
NSSize charSize = [PTYTab cellSizeForBookmark:self.tmuxController.profile];
 
// The characters growth (+ growth, - shrinkage) needed to attain the target
NSSize charsDiff = NSMakeSize(floor(sizeDiff.width / charSize.width),
Loading
Loading
@@ -3235,7 +3217,7 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
NSMutableDictionary *arrangement = [NSMutableDictionary dictionary];
parseTree = [PTYTab parseTreeWithInjectedRootSplit:parseTree];
[arrangement setObject:[PTYTab _recursiveArrangementForDecoratedTmuxParseTree:parseTree
bookmark:[PTYTab tmuxBookmark]
bookmark:self.tmuxController.profile
origin:NSZeroPoint
activeWindowPane:[activeSession_ tmuxPane]]
forKey:TAB_ARRANGEMENT_ROOT];
Loading
Loading
@@ -3323,7 +3305,8 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
DLog(@"setTmuxLayout:tmuxController:");
[PTYTab setSizesInTmuxParseTree:parseTree
inTerminal:realParentWindow_
zoomed:shouldZoom];
zoomed:shouldZoom
profile:tmuxController.profile];
DLog(@"Parse tree including sizes:\n%@", parseTree);
if ([self parseTree:parseTree matchesViewHierarchy:root_]) {
DLog(@"Parse tree matches the root's view hierarchy.");
Loading
Loading
@@ -3367,7 +3350,10 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
kLayoutDictXOffsetKey: @0,
kLayoutDictYOffsetKey: @0,
} mutableCopy] autorelease];
[PTYTab setSizesInTmuxParseTree:maximizedParseTree inTerminal:realParentWindow_ zoomed:YES];
[PTYTab setSizesInTmuxParseTree:maximizedParseTree
inTerminal:realParentWindow_
zoomed:YES
profile:tmuxController.profile];
[self resizeViewsInViewHierarchy:root_ forNewLayout:maximizedParseTree];
[self fitSubviewsToRoot];
}
Loading
Loading
@@ -3475,7 +3461,7 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
- (void)resizeTmuxSessionView:(SessionView *)sessionView toGridSize:(VT100GridSize)gridSize {
DLog(@"resize view %@ to grid size %@", sessionView, VT100GridSizeDescription(gridSize));
const BOOL showTitles = [iTermPreferences boolForKey:kPreferenceKeyShowPaneTitles];
NSSize size = [PTYTab _sessionSizeWithCellSize:[PTYTab cellSizeForBookmark:[PTYTab tmuxBookmark]]
NSSize size = [PTYTab _sessionSizeWithCellSize:[PTYTab cellSizeForBookmark:self.tmuxController.profile]
dimensions:NSMakeSize(gridSize.width, gridSize.height)
showTitles:showTitles
inTerminal:self.realParentWindow];
Loading
Loading
@@ -3788,7 +3774,7 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
PTYSession *session = [self sessionForSessionView:sessionView];
 
// Determine the number of characters moved
NSSize cellSize = [PTYTab cellSizeForBookmark:[PTYTab tmuxBookmark]];
NSSize cellSize = [PTYTab cellSizeForBookmark:self.tmuxController.profile];
int amount;
if (pxMoved.width) {
amount = pxMoved.width / cellSize.width;
Loading
Loading
@@ -4731,4 +4717,25 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
[_delegate tabRemoveTab:self];
}
}
- (VT100GridSize)sessionTmuxSizeWithProfile:(Profile *)profile {
if ([iTermAdvancedSettingsModel tmuxUsesDedicatedProfile]) {
return VT100GridSizeMake([[profile objectForKey:KEY_COLUMNS] intValue],
[[profile objectForKey:KEY_ROWS] intValue]);
} else {
NSSize frameSize = tabView_.frame.size;
PTYSession *anySession = self.sessions.firstObject;
NSSize contentSize = [NSScrollView contentSizeForFrameSize:frameSize
horizontalScrollerClass:nil
verticalScrollerClass:[realParentWindow_ scrollbarShouldBeVisible] ? [[anySession.view.scrollview verticalScroller] class] : nil
borderType:anySession.view.scrollview.borderType
controlSize:NSRegularControlSize
scrollerStyle:anySession.view.scrollview.scrollerStyle];
NSSize cellSize = [PTYTab cellSizeForBookmark:profile];
return VT100GridSizeMake((contentSize.width - [iTermAdvancedSettingsModel terminalMargin] * 2) / cellSize.width,
(contentSize.height - [iTermAdvancedSettingsModel terminalVMargin] * 2) / cellSize.height);
}
}
@end
Loading
Loading
@@ -99,6 +99,7 @@ int gMigrated;
[super dealloc];
}
 
// Use only when tmuxUsesDedicatedProfile is off
- (Profile *)tmuxProfile {
Profile *profile = [self bookmarkWithName:@"tmux"];
if (!profile) {
Loading
Loading
Loading
Loading
@@ -2733,6 +2733,14 @@ ITERM_WEAKLY_REFERENCEABLE
if (changedScrollBars && NSEqualSizes(self.window.frame.size, originalFrame.size)) {
DLog(@"Fitting tabs to window when canonicalizing fullscreen window because of scrollbar change");
[self fitTabsToWindow];
if (!tmuxOriginatedResizeInProgress_) {
// When opening a new tmux tab in a fullscreen window, it'll be initialized
// with legacy scrollers (if the system is configured to use them) and then
// it needs to update its size when the scrollers are forced to be inline.
for (TmuxController *controller in self.uniqueTmuxControllers) {
[controller setClientSize:self.tmuxCompatibleSize];
}
}
}
}
}
Loading
Loading
@@ -5298,7 +5306,8 @@ ITERM_WEAKLY_REFERENCEABLE
inTerminal:nil
hasFlexibleView:NO
viewMap:nil
sessionMap:theMap];
sessionMap:theMap
tmuxController:nil];
[tab replaceWithContentsOfTab:temporaryTab];
[tab updatePaneTitles];
[tab setActiveSession:nil];
Loading
Loading
@@ -5325,7 +5334,8 @@ ITERM_WEAKLY_REFERENCEABLE
inTerminal:self
hasFlexibleView:NO
viewMap:nil
sessionMap:sessionMap];
sessionMap:sessionMap
tmuxController:nil];
tab.uniqueId = tabUniqueId;
for (NSString *theKey in sessionMap) {
PTYSession *session = sessionMap[theKey];
Loading
Loading
Loading
Loading
@@ -6,6 +6,7 @@
//
 
#import <Cocoa/Cocoa.h>
#import "ProfileModel.h"
#import "iTermInitialDirectory.h"
#import "TmuxGateway.h"
#import "WindowControllerInterface.h"
Loading
Loading
@@ -45,8 +46,14 @@ extern NSString *const kTmuxControllerSessionWasRenamed;
@property(nonatomic, readonly) BOOL hasOutstandingWindowResize;
@property(nonatomic, readonly, getter=isAttached) BOOL attached;
@property(nonatomic, readonly) BOOL detaching;
@property(nonatomic, copy) Profile *profile;
- (instancetype)initWithGateway:(TmuxGateway *)gateway
clientName:(NSString *)clientName
profile:(Profile *)profile
profileModel:(ProfileModel *)profileModel NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
 
- (instancetype)initWithGateway:(TmuxGateway *)gateway clientName:(NSString *)clientName;
- (void)openWindowsInitial;
- (void)openWindowWithId:(int)windowId
intentional:(BOOL)intentional;
Loading
Loading
@@ -148,4 +155,9 @@ extern NSString *const kTmuxControllerSessionWasRenamed;
 
- (void)clearHistoryForWindowPane:(int)windowPane;
 
- (void)setTmuxFont:(NSFont *)font
nonAsciiFont:(NSFont *)nonAsciiFont
hSpacing:(double)hs
vSpacing:(double)vs;
@end
Loading
Loading
@@ -11,7 +11,9 @@
#import "iTermApplicationDelegate.h"
#import "iTermController.h"
#import "iTermPreferences.h"
#import "iTermProfilePreferences.h"
#import "iTermShortcut.h"
#import "NSFont+iTerm.h"
#import "NSStringITerm.h"
#import "PreferencePanel.h"
#import "PseudoTerminal.h"
Loading
Loading
@@ -136,6 +138,9 @@ static NSString *kListWindowsFormat = @"\"#{session_name}\t#{window_id}\t"
NSMutableDictionary *_windowOpenerOptions;
BOOL _manualOpenRequested;
BOOL _haveOpenendInitialWindows;
Profile *_profile;
ProfileModel *_profileModel;
NSDictionary *_fontOverrides;
}
 
@synthesize gateway = gateway_;
Loading
Loading
@@ -145,9 +150,19 @@ static NSString *kListWindowsFormat = @"\"#{session_name}\t#{window_id}\t"
@synthesize ambiguousIsDoubleWidth = ambiguousIsDoubleWidth_;
@synthesize sessionId = sessionId_;
 
- (instancetype)initWithGateway:(TmuxGateway *)gateway clientName:(NSString *)clientName {
- (instancetype)initWithGateway:(TmuxGateway *)gateway
clientName:(NSString *)clientName
profile:(NSDictionary *)profile
profileModel:(ProfileModel *)profileModel {
self = [super init];
if (self) {
_profile = [profile copy];
_profileModel = [profileModel retain];
_fontOverrides = [@{ KEY_NORMAL_FONT: [iTermProfilePreferences stringForKey:KEY_NORMAL_FONT inProfile:profile],
KEY_NON_ASCII_FONT: [iTermProfilePreferences stringForKey:KEY_NON_ASCII_FONT inProfile:profile],
KEY_HORIZONTAL_SPACING: [iTermProfilePreferences objectForKey:KEY_HORIZONTAL_SPACING inProfile:profile],
KEY_VERTICAL_SPACING: [iTermProfilePreferences objectForKey:KEY_VERTICAL_SPACING inProfile:profile] } retain];
gateway_ = [gateway retain];
_paneIDs = [[NSMutableSet alloc] init];
windowPanes_ = [[NSMutableDictionary alloc] init];
Loading
Loading
@@ -182,9 +197,21 @@ static NSString *kListWindowsFormat = @"\"#{session_name}\t#{window_id}\t"
[_windowOpenerOptions release];
[_hotkeys release];
[_tabColors release];
[_profile release];
[_profileModel release];
[_fontOverrides release];
[super dealloc];
}
 
- (NSDictionary *)profile {
Profile *profile = [_profileModel bookmarkWithGuid:_profile[KEY_GUID]] ?: _profile;
NSMutableDictionary *temp = [profile mutableCopy];
[_fontOverrides enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
temp[key] = obj;
}];
return temp;
}
- (void)openWindowWithIndex:(int)windowIndex
name:(NSString *)name
size:(NSSize)size
Loading
Loading
@@ -210,8 +237,8 @@ static NSString *kListWindowsFormat = @"\"#{session_name}\t#{window_id}\t"
windowOpener.size = size;
windowOpener.layout = layout;
windowOpener.maxHistory =
MAX([[gateway_ delegate] tmuxBookmarkSize].height,
[[gateway_ delegate] tmuxNumHistoryLinesInBookmark]);
MAX([[gateway_ delegate] tmuxClientSize].height,
[[gateway_ delegate] tmuxNumberOfLinesOfScrollbackHistory]);
windowOpener.controller = self;
windowOpener.gateway = gateway_;
windowOpener.target = self;
Loading
Loading
@@ -220,6 +247,7 @@ static NSString *kListWindowsFormat = @"\"#{session_name}\t#{window_id}\t"
windowOpener.zoomed = windowFlags ? @([windowFlags containsString:@"Z"]) : nil;
windowOpener.manuallyOpened = _manualOpenRequested;
windowOpener.tabColors = _tabColors;
windowOpener.profile = self.profile;
_manualOpenRequested = NO;
if (![windowOpener openWindows:YES]) {
[pendingWindowOpens_ removeObject:n];
Loading
Loading
@@ -235,8 +263,8 @@ static NSString *kListWindowsFormat = @"\"#{session_name}\t#{window_id}\t"
windowOpener.unicodeVersion = self.unicodeVersion;
windowOpener.layout = layout;
windowOpener.maxHistory =
MAX([[gateway_ delegate] tmuxBookmarkSize].height,
[[gateway_ delegate] tmuxNumHistoryLinesInBookmark]);
MAX([[gateway_ delegate] tmuxClientSize].height,
[[gateway_ delegate] tmuxNumberOfLinesOfScrollbackHistory]);
windowOpener.controller = self;
windowOpener.gateway = gateway_;
windowOpener.windowIndex = [tab tmuxWindow];
Loading
Loading
@@ -245,6 +273,7 @@ static NSString *kListWindowsFormat = @"\"#{session_name}\t#{window_id}\t"
windowOpener.windowOptions = _windowOpenerOptions;
windowOpener.zoomed = zoomed;
windowOpener.tabColors = _tabColors;
windowOpener.profile = self.profile;
[windowOpener updateLayoutInTab:tab];
}
 
Loading
Loading
@@ -397,13 +426,13 @@ static NSString *kListWindowsFormat = @"\"#{session_name}\t#{window_id}\t"
[scanner scanString:@"," intoString:nil] &&
[scanner scanInt:&height]);
if (ok) {
[self openWindowsOfSize:NSMakeSize(width, height)];
[self openWindowsOfSize:VT100GridSizeMake(width, height)];
} else {
[self openWindowsOfSize:[[gateway_ delegate] tmuxBookmarkSize]];
[self openWindowsOfSize:[[gateway_ delegate] tmuxClientSize]];
}
}
 
- (void)openWindowsOfSize:(NSSize)size {
- (void)openWindowsOfSize:(VT100GridSize)size {
// There's a (hopefully) minor race condition here. When we initially connect to
// a session we get its @iterm2_id. If one doesn't exist, it is assigned. This
// lets us know if a single instance of iTerm2 is trying to attach to the same
Loading
Loading
@@ -415,7 +444,7 @@ static NSString *kListWindowsFormat = @"\"#{session_name}\t#{window_id}\t"
NSString *getSessionGuidCommand = [NSString stringWithFormat:@"show -v -q -t $%d @iterm2_id",
sessionId_];
NSString *setSizeCommand = [NSString stringWithFormat:@"refresh-client -C %d,%d",
(int)size.width, (int)size.height];
size.width, size.height];
NSString *listWindowsCommand = [NSString stringWithFormat:@"list-windows -F %@", kListWindowsFormat];
NSString *listSessionsCommand = @"list-sessions -F \"#{session_name}\"";
NSString *getAffinitiesCommand = [NSString stringWithFormat:@"show -v -q -t $%d @affinities", sessionId_];
Loading
Loading
@@ -1368,6 +1397,31 @@ static NSString *kListWindowsFormat = @"\"#{session_name}\t#{window_id}\t"
[gateway_ sendCommandList:commands];
}
 
- (void)setTmuxFont:(NSFont *)font
nonAsciiFont:(NSFont *)nonAsciiFont
hSpacing:(double)hs
vSpacing:(double)vs {
[_fontOverrides release];
_fontOverrides = [@{ KEY_NORMAL_FONT: [font stringValue],
KEY_NON_ASCII_FONT: [nonAsciiFont stringValue],
KEY_HORIZONTAL_SPACING: @(hs),
KEY_VERTICAL_SPACING: @(vs) } retain];
[_profileModel setObject:[font stringValue]
forKey:KEY_NORMAL_FONT
inBookmark:self.profile];
[_profileModel setObject:[nonAsciiFont stringValue]
forKey:KEY_NON_ASCII_FONT
inBookmark:self.profile];
[_profileModel setObject:[NSNumber numberWithDouble:hs]
forKey:KEY_HORIZONTAL_SPACING
inBookmark:self.profile];
[_profileModel setObject:[NSNumber numberWithDouble:vs]
forKey:KEY_VERTICAL_SPACING
inBookmark:self.profile];
[_profileModel postChangeNotification];
}
#pragma mark - Private
 
- (void)getOriginsResponse:(NSString *)result
Loading
Loading
Loading
Loading
@@ -203,9 +203,10 @@
- (void)addWindow {
NSString *lastName = [[windowsTable_ names] lastObject];
if (lastName) {
[[self tmuxController] newWindowInSession:[sessionsTable_ selectedSessionName]
initialDirectory:[iTermInitialDirectory initialDirectoryFromProfile:[[ProfileModel sharedInstance] tmuxProfile]
objectType:iTermWindowObject]];
TmuxController *tmuxController = self.tmuxController;
[tmuxController newWindowInSession:[sessionsTable_ selectedSessionName]
initialDirectory:[iTermInitialDirectory initialDirectoryFromProfile:tmuxController.profile
objectType:iTermWindowObject]];
}
}
 
Loading
Loading
Loading
Loading
@@ -6,6 +6,7 @@
//
 
#import <Cocoa/Cocoa.h>
#import "VT100GridTypes.h"
#import "WindowControllerInterface.h"
 
// Constant values for flags:
Loading
Loading
@@ -38,8 +39,8 @@ extern NSString * const kTmuxGatewayErrorDomain;
- (void)tmuxSessionsChanged;
- (void)tmuxWindowsDidChange;
- (void)tmuxSession:(int)sessionId renamed:(NSString *)newName;
- (NSSize)tmuxBookmarkSize; // rows, cols
- (NSInteger)tmuxNumHistoryLinesInBookmark;
- (VT100GridSize)tmuxClientSize;
- (NSInteger)tmuxNumberOfLinesOfScrollbackHistory;
- (void)tmuxSetSecureLogging:(BOOL)secureLogging;
- (void)tmuxPrintLine:(NSString *)line;
- (NSWindowController<iTermWindowController> *)tmuxGatewayWindow;
Loading
Loading
Loading
Loading
@@ -8,6 +8,7 @@
#import <Foundation/Foundation.h>
#import "TmuxGateway.h"
#import "FutureMethods.h"
#import "ProfileModel.h"
 
extern NSString * const kTmuxWindowOpenerStatePendingOutput;
 
Loading
Loading
@@ -40,6 +41,7 @@ extern NSString *const kTmuxWindowOpenerWindowOptionStyleValueFullScreen;
@property (nonatomic, retain) NSDictionary *windowOptions;
@property (nonatomic, assign) BOOL manuallyOpened;
@property (nonatomic, copy) NSDictionary<NSNumber *, NSString *> *tabColors;
@property (nonatomic, copy) Profile *profile;
 
+ (TmuxWindowOpener *)windowOpener;
- (BOOL)openWindows:(BOOL)initial;
Loading
Loading
Loading
Loading
@@ -80,7 +80,8 @@ NSString *const kTmuxWindowOpenerWindowOptionStyleValueFullScreen = @"FullScreen
[_windowOptions release];
[_zoomed release];
[_tabColors release];
[_profile release];
[super dealloc];
}
 
Loading
Loading
@@ -316,7 +317,7 @@ static int OctalValue(const char *bytes) {
BOOL isNewWindow = NO;
if (!tabToUpdate_) {
DLog(@"Have no tab to update.");
if (![[[PTYTab tmuxBookmark] objectForKey:KEY_PREVENT_TAB] boolValue]) {
if (![self.profile[KEY_PREVENT_TAB] boolValue]) {
term = [self.controller windowWithAffinityForWindowId:self.windowIndex];
DLog(@"Term with affinity is %@", term);
}
Loading
Loading
@@ -332,7 +333,7 @@ static int OctalValue(const char *bytes) {
DLog(@"Use original window %@", term);
}
if (!term) {
term = [[iTermController sharedInstance] openTmuxIntegrationWindowUsingProfile:[PTYTab tmuxBookmark]];
term = [[iTermController sharedInstance] openTmuxIntegrationWindowUsingProfile:self.profile];
isNewWindow = YES;
DLog(@"Opened a new window %@", term);
}
Loading
Loading
Loading
Loading
@@ -184,5 +184,6 @@
+ (BOOL)logRestorableStateSize;
+ (NSString *)autoLogFormat;
+ (BOOL)killSessionsOnLogout;
+ (BOOL)tmuxUsesDedicatedProfile;
 
@end
Loading
Loading
@@ -191,6 +191,7 @@ DEFINE_BOOL(fontChangeAffectsBroadcastingSessions, NO, @"Windows: Should growing
 
#pragma mark tmux
DEFINE_BOOL(noSyncNewWindowOrTabFromTmuxOpensTmux, NO, @"Tmux Integration: Suppress alert asking what kind of tab/window to open in tmux integration.");
DEFINE_BOOL(tmuxUsesDedicatedProfile, YES, @"Tmux Integration: Tmux always uses the “tmux” profile.\nIf disabled, tmux sessions use the profile of the session you ran tmux -CC in.");
 
#pragma mark Warnings
DEFINE_BOOL(neverWarnAboutMeta, NO, @"Warnings: Suppress a warning when Option Key Acts as Meta is enabled in Prefs>Profiles>Keys.");
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