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

initial add of multiple saved arrangements

parent 5417d4b7
No related branches found
No related tags found
No related merge requests found
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Loading
Loading
@@ -245,6 +245,7 @@ static const float kBackgroundSessionIntervalSec = 1;
// Session specific methods
- (BOOL)setScreenSize:(NSRect)aRect parent:(id<WindowControllerInterface>)parent;
 
+ (void)drawArrangementPreview:(NSDictionary *)arrangement frame:(NSRect)frame;
+ (PTYSession*)sessionFromArrangement:(NSDictionary*)arrangement inView:(SessionView*)sessionView inTab:(PTYTab*)theTab;
 
- (void)runCommandWithOldCwd:(NSString*)oldCWD;
Loading
Loading
Loading
Loading
@@ -27,6 +27,7 @@
#import <Cocoa/Cocoa.h>
#import <iTerm/BookmarkModel.h>
#import "BookmarkListView.h"
#import "ArrangementsModel.h"
 
#define OPT_NORMAL 0
#define OPT_META 1
Loading
Loading
@@ -271,12 +272,15 @@ typedef enum { CURSOR_UNDERLINE, CURSOR_VERTICAL, CURSOR_BOX } ITermCursorType;
IBOutlet NSToolbarItem* appearanceToolbarItem;
IBOutlet NSTabViewItem* appearanceTabViewItem;
IBOutlet NSToolbarItem* keyboardToolbarItem;
IBOutlet NSToolbarItem* arrangementsToolbarItem;
IBOutlet NSTabViewItem* keyboardTabViewItem;
IBOutlet NSTabViewItem* arrangementsTabViewItem;
IBOutlet NSToolbarItem* bookmarksToolbarItem;
IBOutlet NSTabViewItem* bookmarksTabViewItem;
NSString* globalToolbarId;
NSString* appearanceToolbarId;
NSString* keyboardToolbarId;
NSString* arrangementsToolbarId;
NSString* bookmarksToolbarId;
 
// url handler stuff
Loading
Loading
@@ -455,6 +459,8 @@ typedef enum { CURSOR_UNDERLINE, CURSOR_VERTICAL, CURSOR_BOX } ITermCursorType;
IBOutlet NSTableColumn* globalActionColumn;
IBOutlet NSButton* globalRemoveMappingButton;
IBOutlet NSButton* globalAddNewMapping;
IBOutlet ArrangementsModel *arrangements_;
}
 
typedef enum { BulkCopyColors, BulkCopyDisplay, BulkCopyWindow, BulkCopyTerminal, BulkCopyKeyboard } BulkCopySettings;
Loading
Loading
@@ -470,6 +476,7 @@ typedef enum { BulkCopyColors, BulkCopyDisplay, BulkCopyWindow, BulkCopyTerminal
- (void)editKeyMapping:(id)sender;
- (IBAction)saveKeyMapping:(id)sender;
- (BOOL)keySheetIsOpen;
- (ArrangementsModel *)arrangements;
- (IBAction)closeKeyMapping:(id)sender;
- (BOOL)validateToolbarItem:(NSToolbarItem *)theItem;
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag;
Loading
Loading
@@ -566,6 +573,7 @@ typedef enum { BulkCopyColors, BulkCopyDisplay, BulkCopyWindow, BulkCopyTerminal
- (IBAction)showAppearanceTabView:(id)sender;
- (IBAction)showBookmarksTabView:(id)sender;
- (IBAction)showKeyboardTabView:(id)sender;
- (IBAction)showArrangementsTabView:(id)sender;
- (void)connectBookmarkWithGuid:(NSString*)guid toScheme:(NSString*)scheme;
- (void)disconnectHandlerForScheme:(NSString*)scheme;
- (IBAction)closeWindow:(id)sender;
Loading
Loading
Loading
Loading
@@ -208,6 +208,9 @@ typedef enum {
NSMutableSet *broadcastViewIds_;
}
 
+ (void)drawArrangementPreview:(NSDictionary*)terminalArrangement
screenFrames:(NSArray *)frames;
// Initialize a new PseudoTerminal.
// smartLayout: If true then position windows using the "smart layout"
// algorithm.
Loading
Loading
Loading
Loading
@@ -97,7 +97,6 @@ BOOL IsLionOrLater(void);
- (PseudoTerminal*)terminalWithNumber:(int)n;
- (int)allocateWindowNumber;
 
- (BOOL)hasWindowArrangement;
- (void)saveWindowArrangement;
- (void)loadWindowArrangement;
 
Loading
Loading
Loading
Loading
@@ -240,6 +240,18 @@ static NSString* SESSION_ARRANGEMENT_WORKING_DIRECTORY = @"Working Directory";
}
}
 
+ (void)drawArrangementPreview:(NSDictionary *)arrangement frame:(NSRect)frame
{
Bookmark* theBookmark = [[BookmarkModel sharedInstance] bookmarkWithGuid:[[arrangement objectForKey:SESSION_ARRANGEMENT_BOOKMARK] objectForKey:KEY_GUID]];
if (!theBookmark) {
theBookmark = [arrangement objectForKey:SESSION_ARRANGEMENT_BOOKMARK];
}
// [self setForegroundColor:[ITAddressBookMgr decodeColor:[aDict objectForKey:KEY_FOREGROUND_COLOR]]];
[[ITAddressBookMgr decodeColor:[theBookmark objectForKey:KEY_BACKGROUND_COLOR]] set];
NSRectFill(frame);
}
+ (PTYSession*)sessionFromArrangement:(NSDictionary*)arrangement inView:(SessionView*)sessionView inTab:(PTYTab*)theTab
{
PTYSession* aSession = [[[PTYSession alloc] init] autorelease];
Loading
Loading
Loading
Loading
@@ -179,6 +179,7 @@ static const int MIN_SESSION_COLUMNS = 2;
- (NSSize)_recursiveMinSize:(NSSplitView*)node;
- (PTYSession*)_recursiveSessionAtPoint:(NSPoint)point relativeTo:(NSView*)node;
 
+ (void)drawArrangementPreview:(NSDictionary*)arrangement frame:(NSRect)frame;
+ (void)openTabWithArrangement:(NSDictionary*)arrangement inTerminal:(PseudoTerminal*)term;
- (NSDictionary*)arrangement;
 
Loading
Loading
Loading
Loading
@@ -1693,6 +1693,54 @@ static NSString* FormatRect(NSRect r) {
return result;
}
 
+ (void)_recursiveDrawArrangementPreview:(NSDictionary*)arrangement frame:(NSRect)frame
{
NSLog(@"Frame=%@", [NSValue valueWithRect:frame]);
if ([[arrangement objectForKey:TAB_ARRANGEMENT_VIEW_TYPE] isEqualToString:VIEW_TYPE_SPLITTER]) {
BOOL isVerticalSplitter = [[arrangement objectForKey:SPLITTER_IS_VERTICAL] boolValue];
float xExtent = 0;
float yExtent = 0;
float dx = 0;
float dy = 0;
float pw, ph;
NSArray* subviews = [arrangement objectForKey:SUBVIEWS];
if (isVerticalSplitter) {
yExtent = frame.size.height;
dx = frame.size.width / [subviews count];
pw = dx;
ph = yExtent;
} else {
xExtent = frame.size.width;
dy = frame.size.height / [subviews count];
pw = xExtent;
ph = dy;
}
double x = frame.origin.x;
double y = frame.origin.y;
for (int i = 0; i < [subviews count]; i++) {
NSDictionary* subArrangement = [subviews objectAtIndex:i];
NSRect subFrame = NSMakeRect(x, y, pw, ph);
[PTYTab _recursiveDrawArrangementPreview:subArrangement frame:subFrame];
x += dx;
y += dy;
}
[[NSColor grayColor] set];
x = frame.origin.x;
y = frame.origin.y;
for (int i = 0; i < [subviews count]; i++) {
NSBezierPath *line = [[[NSBezierPath alloc] init] autorelease];
[line moveToPoint:NSMakePoint(x, y)];
[line lineToPoint:NSMakePoint(x + xExtent, y + yExtent)];
[line stroke];
x += dx;
y += dy;
// NSRectFill(NSMakeRect(x, y, x+10, y+10));
}
} else {
[PTYSession drawArrangementPreview:[arrangement objectForKey:TAB_ARRANGEMENT_SESSION] frame:frame];
}
}
+ (NSView*)_recusiveRestoreSplitters:(NSDictionary*)arrangement fromMap:(NSDictionary*)theMap
{
if ([[arrangement objectForKey:TAB_ARRANGEMENT_VIEW_TYPE] isEqualToString:VIEW_TYPE_SPLITTER]) {
Loading
Loading
@@ -1757,6 +1805,12 @@ static NSString* FormatRect(NSRect r) {
}
}
 
+ (void)drawArrangementPreview:(NSDictionary*)arrangement frame:(NSRect)frame
{
[PTYTab _recursiveDrawArrangementPreview:[arrangement objectForKey:TAB_ARRANGEMENT_ROOT]
frame:frame];
}
+ (void)openTabWithArrangement:(NSDictionary*)arrangement inTerminal:(PseudoTerminal*)term
{
PTYTab* theTab;
Loading
Loading
Loading
Loading
@@ -35,6 +35,7 @@
#import <iTerm/BookmarkModel.h>
#import "PasteboardHistory.h"
#import "SessionView.h"
#import "ArrangementsModel.h"
 
#define CUSTOM_COLOR_PRESETS @"Custom Color Presets"
#define HOTKEY_WINDOW_GENERATED_PROFILE_NAME @"Hotkey Window"
Loading
Loading
@@ -155,8 +156,8 @@ static float versionNumber;
- (void)_savedArrangementChanged:(id)sender
{
[openArrangementAtStartup setState:defaultOpenArrangementAtStartup ? NSOnState : NSOffState];
[openArrangementAtStartup setEnabled:[[iTermController sharedInstance] hasWindowArrangement]];
if (![[iTermController sharedInstance] hasWindowArrangement]) {
[openArrangementAtStartup setEnabled:[arrangements_ count] > 0];
if ([arrangements_ count] == 0) {
[openArrangementAtStartup setState:NO];
}
}
Loading
Loading
@@ -484,6 +485,7 @@ static float versionNumber;
globalToolbarId = [globalToolbarItem itemIdentifier];
appearanceToolbarId = [appearanceToolbarItem itemIdentifier];
keyboardToolbarId = [keyboardToolbarItem itemIdentifier];
arrangementsToolbarId = [arrangementsToolbarItem itemIdentifier];
[toolbar setSelectedItemIdentifier:globalToolbarId];
 
// add list of encodings
Loading
Loading
@@ -777,6 +779,11 @@ static float versionNumber;
return [editKeyMappingWindow isVisible];
}
 
- (ArrangementsModel *)arrangements
{
return arrangements_;
}
- (IBAction)closeKeyMapping:(id)sender
{
[NSApp endSheet:editKeyMappingWindow];
Loading
Loading
@@ -800,6 +807,8 @@ static float versionNumber;
return bookmarksToolbarItem;
} else if ([itemIdentifier isEqual:keyboardToolbarId]) {
return keyboardToolbarItem;
} else if ([itemIdentifier isEqual:arrangementsToolbarId]) {
return arrangementsToolbarItem;
} else {
return nil;
}
Loading
Loading
@@ -811,12 +820,14 @@ static float versionNumber;
appearanceToolbarId,
bookmarksToolbarId,
keyboardToolbarId,
arrangementsToolbarId,
nil];
}
 
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar
{
return [NSArray arrayWithObjects:globalToolbarId, appearanceToolbarId, bookmarksToolbarId, keyboardToolbarId, nil];
return [NSArray arrayWithObjects:globalToolbarId, appearanceToolbarId, bookmarksToolbarId,
keyboardToolbarId, arrangementsToolbarId, nil];
}
 
- (NSArray *)toolbarSelectableItemIdentifiers: (NSToolbar *)toolbar
Loading
Loading
@@ -827,6 +838,7 @@ static float versionNumber;
appearanceToolbarId,
bookmarksToolbarId,
keyboardToolbarId,
arrangementsToolbarId,
nil];
}
 
Loading
Loading
@@ -916,7 +928,7 @@ static float versionNumber;
defaultHotkeyChar = [prefs objectForKey:@"HotkeyChar"]?[[prefs objectForKey:@"HotkeyChar"] intValue]: 0;
defaultHotkeyModifiers = [prefs objectForKey:@"HotkeyModifiers"]?[[prefs objectForKey:@"HotkeyModifiers"] intValue]: 0;
defaultSavePasteHistory = [prefs objectForKey:@"SavePasteHistory"]?[[prefs objectForKey:@"SavePasteHistory"] boolValue]: NO;
if ([[iTermController sharedInstance] hasWindowArrangement]) {
if ([arrangements_ count] > 0) {
defaultOpenArrangementAtStartup = [prefs objectForKey:@"OpenArrangementAtStartup"]?[[prefs objectForKey:@"OpenArrangementAtStartup"] boolValue]: NO;
} else {
defaultOpenArrangementAtStartup = NO;
Loading
Loading
@@ -1139,8 +1151,8 @@ static float versionNumber;
[showBookmarkName setState: defaultShowBookmarkName?NSOnState:NSOffState];
[savePasteHistory setState: defaultSavePasteHistory?NSOnState:NSOffState];
[openArrangementAtStartup setState:defaultOpenArrangementAtStartup ? NSOnState : NSOffState];
[openArrangementAtStartup setEnabled:[[iTermController sharedInstance] hasWindowArrangement]];
if (![[iTermController sharedInstance] hasWindowArrangement]) {
[openArrangementAtStartup setEnabled:[arrangements_ count] > 0];
if ([arrangements_ count] == 0) {
[openArrangementAtStartup setState:NO];
}
[hotkey setState: defaultHotkey?NSOnState:NSOffState];
Loading
Loading
@@ -2719,6 +2731,11 @@ static float versionNumber;
[tabView selectTabViewItem:keyboardTabViewItem];
}
 
- (IBAction)showArrangementsTabView:(id)sender
{
[tabView selectTabViewItem:arrangementsTabViewItem];
}
- (void)connectBookmarkWithGuid:(NSString*)guid toScheme:(NSString*)scheme
{
NSURL *appURL = nil;
Loading
Loading
Loading
Loading
@@ -865,9 +865,8 @@ NSString *sessionsKey = @"sessions";
}
}
 
+ (PseudoTerminal*)terminalWithArrangement:(NSDictionary*)arrangement
+ (int)_windowTypeForArrangement:(NSDictionary*)arrangement
{
PseudoTerminal* term;
int windowType;
if ([arrangement objectForKey:TERMINAL_ARRANGEMENT_WINDOW_TYPE]) {
windowType = [[arrangement objectForKey:TERMINAL_ARRANGEMENT_WINDOW_TYPE] intValue];
Loading
Loading
@@ -885,6 +884,11 @@ NSString *sessionsKey = @"sessions";
windowType = WINDOW_TYPE_NORMAL;
}
}
return windowType;
}
+ (int)_screenIndexForArrangement:(NSDictionary*)arrangement
{
int screenIndex;
if ([arrangement objectForKey:TERMINAL_ARRANGEMENT_SCREEN_INDEX]) {
screenIndex = [[arrangement objectForKey:TERMINAL_ARRANGEMENT_SCREEN_INDEX] intValue];
Loading
Loading
@@ -894,6 +898,70 @@ NSString *sessionsKey = @"sessions";
if (screenIndex < 0 || screenIndex >= [[NSScreen screens] count]) {
screenIndex = 0;
}
return screenIndex;
}
+ (void)drawArrangementPreview:(NSDictionary*)terminalArrangement
screenFrames:(NSArray *)frames
{
int windowType = [PseudoTerminal _windowTypeForArrangement:terminalArrangement];
int screenIndex = [PseudoTerminal _screenIndexForArrangement:terminalArrangement];
NSRect virtualScreenFrame = [[frames objectAtIndex:screenIndex] rectValue];
NSRect screenFrame = [[[NSScreen screens] objectAtIndex:screenIndex] frame];
double xScale = virtualScreenFrame.size.width / screenFrame.size.width;
double yScale = virtualScreenFrame.size.height / screenFrame.size.height;
double xOrigin = virtualScreenFrame.origin.x;
double yOrigin = virtualScreenFrame.origin.y;
NSRect rect;
if (windowType == WINDOW_TYPE_FULL_SCREEN || windowType == WINDOW_TYPE_LION_FULL_SCREEN) {
rect = virtualScreenFrame;
} else if (windowType == WINDOW_TYPE_NORMAL) {
rect.origin.x = xOrigin + xScale * [[terminalArrangement objectForKey:TERMINAL_ARRANGEMENT_X_ORIGIN] doubleValue];
rect.origin.y = yOrigin + yScale * [[terminalArrangement objectForKey:TERMINAL_ARRANGEMENT_Y_ORIGIN] doubleValue];
rect.size.width = xScale * [[terminalArrangement objectForKey:TERMINAL_ARRANGEMENT_WIDTH] doubleValue];
rect.size.height = yScale * [[terminalArrangement objectForKey:TERMINAL_ARRANGEMENT_HEIGHT] doubleValue];
} else if (windowType == WINDOW_TYPE_TOP) {
rect.origin.x = xOrigin;
rect.origin.y = yOrigin;
rect.size.width = virtualScreenFrame.size.width;
rect.size.height = yScale * [[terminalArrangement objectForKey:TERMINAL_ARRANGEMENT_HEIGHT] doubleValue];
}
[[NSColor blackColor] set];
NSRectFill(rect);
[[NSColor windowFrameColor] set];
NSFrameRect(rect);
int N = [(NSDictionary *)[terminalArrangement objectForKey:TERMINAL_ARRANGEMENT_TABS] count];
[[NSColor windowBackgroundColor] set];
double y;
if ([[PreferencePanel sharedInstance] tabViewType] == PSMTab_BottomTab) {
y = rect.origin.y + rect.size.height - 10;
} else {
y = rect.origin.y;
}
NSRectFill(NSMakeRect(rect.origin.x + 1, y, rect.size.width - 2, 10));
double x = 1;
[[NSColor darkGrayColor] set];
for (int i = 0; i < N; i++) {
NSFrameRect(NSMakeRect(rect.origin.x + x, y, rect.size.width / N, 9));
x += floor((rect.size.width - 2) / N);
}
NSDictionary* tabArrangement = [[terminalArrangement objectForKey:TERMINAL_ARRANGEMENT_TABS] objectAtIndex:0];
[PTYTab drawArrangementPreview:tabArrangement frame:NSMakeRect(rect.origin.x + 1,
([[PreferencePanel sharedInstance] tabViewType] == PSMTab_BottomTab) ? rect.origin.y : rect.origin.y + 10,
rect.size.width - 2,
rect.size.height - 10)];
}
+ (PseudoTerminal*)terminalWithArrangement:(NSDictionary*)arrangement
{
PseudoTerminal* term;
int windowType = [PseudoTerminal _windowTypeForArrangement:arrangement];
int screenIndex = [PseudoTerminal _screenIndexForArrangement:arrangement];
 
if (windowType == WINDOW_TYPE_FULL_SCREEN) {
term = [[[PseudoTerminal alloc] initWithSmartLayout:NO
Loading
Loading
Loading
Loading
@@ -1332,8 +1332,10 @@ static char* FormatCont(int c)
[[SESSION tab] sessionInitiatedResize:SESSION
width:([TERMINAL columnMode] ? 132 : 80)
height:HEIGHT];
token.u.csi.p[0]=2; [self eraseInDisplay:token]; //erase the screen
token.u.csi.p[0]=token.u.csi.p[1]=0; [self setTopBottom:token]; // reset scroll;
token.u.csi.p[0] = 2;
[self eraseInDisplay:token]; // erase the screen
token.u.csi.p[0] = token.u.csi.p[1] = 0;
[self setTopBottom:token]; // reset scroll
}
 
break;
Loading
Loading
Loading
Loading
@@ -17,6 +17,8 @@
1D237D90131D8BEE004DD60C /* FindView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1D237D8E131D8BEE004DD60C /* FindView.xib */; };
1D237D94131D8D66004DD60C /* FindViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D237D92131D8D66004DD60C /* FindViewController.h */; };
1D237D95131D8D66004DD60C /* FindViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D237D93131D8D66004DD60C /* FindViewController.m */; };
1D2560AA13EE60E4006B35CD /* ArrangementPreviewView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D2560A813EE60E4006B35CD /* ArrangementPreviewView.h */; };
1D2560AB13EE60E4006B35CD /* ArrangementPreviewView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D2560A913EE60E4006B35CD /* ArrangementPreviewView.m */; };
1D2E802E129DA45A00F3D71E /* PTYTab.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D2E802C129DA45A00F3D71E /* PTYTab.h */; };
1D2E802F129DA45A00F3D71E /* PTYTab.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D2E802D129DA45A00F3D71E /* PTYTab.m */; };
1D2E813112A18F7500F3D71E /* SessionView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D2E812F12A18F7500F3D71E /* SessionView.h */; };
Loading
Loading
@@ -203,6 +205,9 @@
1DAED99312EDF923005E49ED /* iTermSearchField.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DAED99112EDF923005E49ED /* iTermSearchField.m */; };
1DB72CF61396059200EB1005 /* xterm-terminfo.txt in Resources */ = {isa = PBXBuildFile; fileRef = 1DB72CF51396059200EB1005 /* xterm-terminfo.txt */; };
1DC742A0127C96F90069594C /* IBarCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 1DC7429F127C96F90069594C /* IBarCursor.png */; };
1DCA5ECC13EE4DA800B7725E /* arrangement.png in Resources */ = {isa = PBXBuildFile; fileRef = 1DCA5ECB13EE4DA800B7725E /* arrangement.png */; };
1DCA5ECF13EE507800B7725E /* ArrangementsModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DCA5ECD13EE507800B7725E /* ArrangementsModel.h */; };
1DCA5ED013EE507800B7725E /* ArrangementsModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DCA5ECE13EE507800B7725E /* ArrangementsModel.m */; };
1DCA8BA9121A1B8000ABDEB5 /* PrefsAdvanced.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 1DCA8BA3121A1B8000ABDEB5 /* PrefsAdvanced.tiff */; };
1DCA8BAA121A1B8000ABDEB5 /* PrefsBookmarks.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 1DCA8BA4121A1B8000ABDEB5 /* PrefsBookmarks.tiff */; };
1DCA8BAB121A1B8000ABDEB5 /* PrefsDisplay.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 1DCA8BA5121A1B8000ABDEB5 /* PrefsDisplay.tiff */; };
Loading
Loading
@@ -308,6 +313,8 @@
1D237D8F131D8BEE004DD60C /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/FindView.xib; sourceTree = "<group>"; };
1D237D92131D8D66004DD60C /* FindViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FindViewController.h; sourceTree = "<group>"; };
1D237D93131D8D66004DD60C /* FindViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FindViewController.m; sourceTree = "<group>"; };
1D2560A813EE60E4006B35CD /* ArrangementPreviewView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrangementPreviewView.h; sourceTree = "<group>"; };
1D2560A913EE60E4006B35CD /* ArrangementPreviewView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ArrangementPreviewView.m; sourceTree = "<group>"; };
1D2E802C129DA45A00F3D71E /* PTYTab.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PTYTab.h; sourceTree = "<group>"; };
1D2E802D129DA45A00F3D71E /* PTYTab.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PTYTab.m; sourceTree = "<group>"; };
1D2E812F12A18F7500F3D71E /* SessionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SessionView.h; sourceTree = "<group>"; };
Loading
Loading
@@ -376,6 +383,9 @@
1DAED99112EDF923005E49ED /* iTermSearchField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iTermSearchField.m; sourceTree = "<group>"; };
1DB72CF51396059200EB1005 /* xterm-terminfo.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "xterm-terminfo.txt"; sourceTree = "<group>"; };
1DC7429F127C96F90069594C /* IBarCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = IBarCursor.png; path = images/IBarCursor.png; sourceTree = "<group>"; };
1DCA5ECB13EE4DA800B7725E /* arrangement.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = arrangement.png; path = images/arrangement.png; sourceTree = "<group>"; };
1DCA5ECD13EE507800B7725E /* ArrangementsModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrangementsModel.h; sourceTree = "<group>"; };
1DCA5ECE13EE507800B7725E /* ArrangementsModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ArrangementsModel.m; sourceTree = "<group>"; };
1DCA8BA3121A1B8000ABDEB5 /* PrefsAdvanced.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = PrefsAdvanced.tiff; path = images/PrefsAdvanced.tiff; sourceTree = "<group>"; };
1DCA8BA4121A1B8000ABDEB5 /* PrefsBookmarks.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = PrefsBookmarks.tiff; path = images/PrefsBookmarks.tiff; sourceTree = "<group>"; };
1DCA8BA5121A1B8000ABDEB5 /* PrefsDisplay.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = PrefsDisplay.tiff; path = images/PrefsDisplay.tiff; sourceTree = "<group>"; };
Loading
Loading
@@ -679,6 +689,10 @@
1D44218B1290B34500891504 /* TextViewWrapper.m */,
E8CF7562026DDA6303A80106 /* VT100Screen.m */,
E8CF7563026DDA6303A80106 /* VT100Terminal.m */,
1DCA5ECD13EE507800B7725E /* ArrangementsModel.h */,
1DCA5ECE13EE507800B7725E /* ArrangementsModel.m */,
1D2560A813EE60E4006B35CD /* ArrangementPreviewView.h */,
1D2560A913EE60E4006B35CD /* ArrangementPreviewView.m */,
);
name = Classes;
sourceTree = "<group>";
Loading
Loading
@@ -813,6 +827,7 @@
1D093C131217412B0029F9AD /* Resources */ = {
isa = PBXGroup;
children = (
1DCA5ECB13EE4DA800B7725E /* arrangement.png */,
1D8F396A13EB7A2C0025B80B /* BroadcastInput.png */,
1D395912134E75B5005A8021 /* SmartSelectionRules.plist */,
1DA02CFA1327612600D7E7DB /* bell.png */,
Loading
Loading
@@ -1125,6 +1140,8 @@
1DA8117E13CEA30A00CCA89A /* FontSizeEstimator.h in Headers */,
1DF0895B13DBAE1F00A52AD8 /* NSBitmapImageRep+CoreImage.h in Headers */,
1DF0895D13DBAE1F00A52AD8 /* NSImage+CoreImage.h in Headers */,
1DCA5ECF13EE507800B7725E /* ArrangementsModel.h in Headers */,
1D2560AA13EE60E4006B35CD /* ArrangementPreviewView.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Loading
Loading
@@ -1299,6 +1316,7 @@
1D395913134E75B5005A8021 /* SmartSelectionRules.plist in Resources */,
1DB72CF61396059200EB1005 /* xterm-terminfo.txt in Resources */,
1D8F396B13EB7A2C0025B80B /* BroadcastInput.png in Resources */,
1DCA5ECC13EE4DA800B7725E /* arrangement.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Loading
Loading
@@ -1409,6 +1427,8 @@
1DA8117F13CEA30A00CCA89A /* FontSizeEstimator.m in Sources */,
1DF0895C13DBAE1F00A52AD8 /* NSBitmapImageRep+CoreImage.m in Sources */,
1DF0895E13DBAE1F00A52AD8 /* NSImage+CoreImage.m in Sources */,
1DCA5ED013EE507800B7725E /* ArrangementsModel.m in Sources */,
1D2560AB13EE60E4006B35CD /* ArrangementPreviewView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Loading
Loading
Loading
Loading
@@ -50,6 +50,7 @@
#import "iTermExpose.h"
#import "GTMCarbonEvent.h"
#import "iTerm.h"
#import "ArrangementsModel.h"
 
#define HOTKEY_WINDOW_VERBOSE_LOGGING
#ifdef HOTKEY_WINDOW_VERBOSE_LOGGING
Loading
Loading
@@ -68,11 +69,9 @@ DebugLog([NSString stringWithFormat:args]); \
@end
 
// Constants for saved window arrangement key names.
static NSString* DEFAULT_ARRANGEMENT_NAME = @"Default";
static NSString* APPLICATION_SUPPORT_DIRECTORY = @"~/Library/Application Support";
static NSString *SUPPORT_DIRECTORY = @"~/Library/Application Support/iTerm";
static NSString *SCRIPT_DIRECTORY = @"~/Library/Application Support/iTerm/Scripts";
static NSString* WINDOW_ARRANGEMENTS = @"Window Arrangements";
 
// Comparator for sorting encodings
static NSInteger _compareEncodingByLocalizedName(id a, id b, void *unused)
Loading
Loading
@@ -269,16 +268,38 @@ static BOOL IsSnowLeopardOrLater() {
[NSApp _cycleWindowsReversed:NO];
}
 
- (BOOL)hasWindowArrangement
{
return [[[NSUserDefaults standardUserDefaults] objectForKey:WINDOW_ARRANGEMENTS] objectForKey:DEFAULT_ARRANGEMENT_NAME] != nil;
- (NSString *)_showAlertWithText:(NSString *)prompt defaultInput:(NSString *)defaultValue {
NSAlert *alert = [NSAlert alertWithMessageText:prompt
defaultButton:@"OK"
alternateButton:@"Cancel"
otherButton:nil
informativeTextWithFormat:@""];
NSTextField *input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 24)];
[input setStringValue:defaultValue];
[alert setAccessoryView:input];
NSInteger button = [alert runModal];
if (button == NSAlertDefaultReturn) {
[input validateEditing];
return [input stringValue];
} else if (button == NSAlertAlternateReturn) {
return nil;
} else {
NSAssert1(NO, @"Invalid input dialog button %d", button);
return nil;
}
}
 
- (void)saveWindowArrangement
{
if ([self hasWindowArrangement]) {
NSString *name = [self _showAlertWithText:@"Name for saved window arrangement:"
defaultInput:[NSString stringWithFormat:@"Arrangement %d", 1+[[ArrangementsModel sharedInstance] count]]];
if (!name) {
return;
}
if ([[ArrangementsModel sharedInstance] hasWindowArrangement:name]) {
if (NSRunAlertPanel(@"Replace Existing Saved Window Arrangement?",
@"There is an existing saved window arrangement. Would you like to replace it with the current arrangement?",
@"There is an existing saved window arrangement with this name. Would you like to replace it with the current arrangement?",
@"Yes",
@"No",
nil) != NSAlertDefaultReturn) {
Loading
Loading
@@ -291,23 +312,18 @@ static BOOL IsSnowLeopardOrLater() {
[terminalArrangements addObject:[terminal arrangement]];
}
}
NSMutableDictionary* arrangements = [NSMutableDictionary dictionaryWithObject:terminalArrangements
forKey:DEFAULT_ARRANGEMENT_NAME];
[[NSUserDefaults standardUserDefaults] setObject:arrangements forKey:WINDOW_ARRANGEMENTS];
// Post a notification
[[NSNotificationCenter defaultCenter] postNotificationName:@"iTermSavedArrangementChanged"
object:nil
userInfo:nil];
[[ArrangementsModel sharedInstance] setArrangement:terminalArrangements withName:name];
}
 
- (void)loadWindowArrangement
{
NSDictionary* arrangements = [[NSUserDefaults standardUserDefaults] objectForKey:WINDOW_ARRANGEMENTS];
NSArray* terminalArrangements = [arrangements objectForKey:DEFAULT_ARRANGEMENT_NAME];
for (NSDictionary* terminalArrangement in terminalArrangements) {
PseudoTerminal* term = [PseudoTerminal terminalWithArrangement:terminalArrangement];
[self addInTerminals:term];
NSArray* terminalArrangements = [[ArrangementsModel sharedInstance] arrangementWithName:nil];
if (terminalArrangements) {
for (NSDictionary* terminalArrangement in terminalArrangements) {
PseudoTerminal* term = [PseudoTerminal terminalWithArrangement:terminalArrangement];
[self addInTerminals:term];
}
}
}
 
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