diff --git a/PTYSession.h b/PTYSession.h index 8ea7975c84..4070e57c46 100644 --- a/PTYSession.h +++ b/PTYSession.h @@ -251,6 +251,7 @@ typedef enum { + (void)selectMenuItem:(NSString*)theName; - (BOOL)isTmuxClient; +- (BOOL)isTmuxGateway; // init/dealloc - (id)init; @@ -321,6 +322,7 @@ typedef enum { // PTYTask - (void)writeTask:(NSData*)data; +- (void)writeTaskNoBroadcast:(NSData *)data; - (void)readTask:(NSData*)data; - (void)brokenPipe; diff --git a/PTYSession.m b/PTYSession.m index 32f7f22a95..07f6d8982d 100644 --- a/PTYSession.m +++ b/PTYSession.m @@ -865,6 +865,16 @@ - (void)writeTaskImpl:(NSData *)data } } +- (void)writeTaskNoBroadcast:(NSData *)data +{ + if (tmuxMode_ == TMUX_CLIENT) { + [[tmuxController_ gateway] sendKeys:data + toWindowPane:tmuxPane_]; + return; + } + [self writeTaskImpl:data]; +} + - (void)handleKeypressInTmuxGateway:(unichar)unicode { if (unicode == 27) { @@ -898,8 +908,12 @@ - (void)writeTask:(NSData*)data { if (tmuxMode_ == TMUX_CLIENT) { [self setBell:NO]; - [[tmuxController_ gateway] sendKeys:data - toWindowPane:tmuxPane_]; + if ([[tab_ realParentWindow] broadcastInputToSession:self]) { + [[tab_ realParentWindow] sendInputToAllSessions:data]; + } else { + [[tmuxController_ gateway] sendKeys:data + toWindowPane:tmuxPane_]; + } PTYScroller* ptys = (PTYScroller*)[SCROLLVIEW verticalScroller]; [ptys setUserScroll:NO]; return; @@ -3622,6 +3636,11 @@ - (BOOL)isTmuxClient return tmuxMode_ == TMUX_CLIENT; } +- (BOOL)isTmuxGateway +{ + return tmuxMode_ == TMUX_GATEWAY; +} + - (void)tmuxDetach { if (tmuxMode_ != TMUX_GATEWAY) { diff --git a/PseudoTerminal.h b/PseudoTerminal.h index 57966260ac..e16754d91a 100644 --- a/PseudoTerminal.h +++ b/PseudoTerminal.h @@ -403,6 +403,9 @@ NSWindowDelegate, // Set the window title to non-transient. - (void)resetTempTitle; +// Sessions in the broadcast group. +- (NSArray *)broadcastSessions; + // Call writeTask: for each session's shell with the given data. - (void)sendInputToAllSessions:(NSData *)data; diff --git a/PseudoTerminal.m b/PseudoTerminal.m index 4ebe915465..6ea2a10bef 100644 --- a/PseudoTerminal.m +++ b/PseudoTerminal.m @@ -450,7 +450,7 @@ - (id)initWithSmartLayout:(BOOL)smartLayout } if (isHotkey && IsSnowLeopardOrLater()) { [[self window] setCollectionBehavior:[[self window] collectionBehavior] | NSWindowCollectionBehaviorIgnoresCycle]; - [[self window] setCollectionBehavior:[[self window] collectionBehavior] & ~NSWindowCollectionBehaviorParticipatesInCycle]; + [[self window] setCollectionBehavior:[[self window] collectionBehavior] & ~NSWindowCollectionBehaviorParticipatesInCycle]; } toolbelt_ = [[[ToolbeltView alloc] initWithFrame:NSMakeRect(0, 0, 200, self.window.frame.size.height - kToolbeltMargin) @@ -1051,19 +1051,19 @@ - (void)resetTempTitle tempTitle = NO; } -- (void)sendInputToAllSessions:(NSData *)data +- (NSArray *)broadcastSessions { + NSMutableArray *sessions = [NSMutableArray array]; int i; - int n = [TABVIEW numberOfTabViewItems]; switch (broadcastMode_) { case BROADCAST_OFF: - return; + break; case BROADCAST_TO_ALL_PANES: for (PTYSession* aSession in [[self currentTab] sessions]) { if (![aSession exited]) { - [[aSession SHELL] writeTask:data]; + [sessions addObject:aSession]; } } break; @@ -1072,7 +1072,7 @@ - (void)sendInputToAllSessions:(NSData *)data for (i = 0; i < n; ++i) { for (PTYSession* aSession in [[[TABVIEW tabViewItemAtIndex:i] identifier] sessions]) { if (![aSession exited]) { - [[aSession SHELL] writeTask:data]; + [sessions addObject:aSession]; } } } @@ -1083,7 +1083,7 @@ - (void)sendInputToAllSessions:(NSData *)data for (PTYSession *aSession in [aTab sessions]) { if ([broadcastViewIds_ containsObject:[NSNumber numberWithInt:[[aSession view] viewId]]]) { if (![aSession exited]) { - [[aSession SHELL] writeTask:data]; + [sessions addObject:aSession]; } } } @@ -1091,6 +1091,18 @@ - (void)sendInputToAllSessions:(NSData *)data break; } } + return sessions; +} + +- (void)sendInputToAllSessions:(NSData *)data +{ + for (PTYSession *aSession in [self broadcastSessions]) { + if ([aSession isTmuxClient]) { + [aSession writeTaskNoBroadcast:data]; + } else if (![aSession isTmuxGateway]) { + [[aSession SHELL] writeTask:data]; + } + } } - (BOOL)broadcastInputToSession:(PTYSession *)session @@ -1239,7 +1251,7 @@ + (PseudoTerminal*)bareTerminalWithArrangement:(NSDictionary*)arrangement term = [[[PseudoTerminal alloc] initWithSmartLayout:NO windowType:WINDOW_TYPE_FORCE_FULL_SCREEN screen:screenIndex] autorelease]; - + NSRect rect; rect.origin.x = [[arrangement objectForKey:TERMINAL_ARRANGEMENT_OLD_X_ORIGIN] doubleValue]; rect.origin.y = [[arrangement objectForKey:TERMINAL_ARRANGEMENT_OLD_Y_ORIGIN] doubleValue]; @@ -1260,7 +1272,7 @@ + (PseudoTerminal*)bareTerminalWithArrangement:(NSDictionary*)arrangement } // TODO: this looks like a bug - are top-of-screen windows not restored to the right screen? term = [[[PseudoTerminal alloc] initWithSmartLayout:NO windowType:windowType screen:-1] autorelease]; - + NSRect rect; rect.origin.x = [[arrangement objectForKey:TERMINAL_ARRANGEMENT_X_ORIGIN] doubleValue]; rect.origin.y = [[arrangement objectForKey:TERMINAL_ARRANGEMENT_Y_ORIGIN] doubleValue]; @@ -5444,6 +5456,7 @@ - (void)window:(NSWindow *)window willEncodeRestorableState:(NSCoder *)state { if ([self isHotKeyWindow] || [self allTabsAreTmuxTabs]) { // Don't save and restore hotkey windows or tmux windows. + [[self ptyWindow] setRestoreState:nil]; return; } if (wellFormed_) {