forked from gnachman/iTerm2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FakeWindow.m
246 lines (209 loc) · 4.88 KB
/
FakeWindow.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
// -*- mode:objc -*-
/*
** FakeWindow.m
**
** Copyright 20101
**
** Author: George Nachman
**
** Project: iTerm2
**
** Description: Shell window that takes over for a session during instant
** replay.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#import "FakeWindow.h"
#import "PTYSession.h"
#import "PTYTab.h"
@implementation FakeWindow
- (id)initFromRealWindow:(PseudoTerminal*)aTerm session:(PTYSession*)aSession
{
self = [super init];
if (!self) {
return nil;
}
isFullScreen = [aTerm fullScreen];
isLionFullScreen = [aTerm lionFullScreen];
isMiniaturized = [[aTerm window] isMiniaturized];
frame = [[aTerm window] frame];
screen = [[aTerm window] screen];
session = aSession;
[session retain];
realWindow = aTerm;
return self;
}
- (void)dealloc
{
if (pendingLabelColor) {
[pendingLabelColor release];
}
if (pendingTabColor) {
[pendingTabColor release];
}
[super dealloc];
}
- (void)rejoin:(PseudoTerminal*)aTerm
{
[session release];
if (hasPendingClose) {
// TODO(georgen): We don't honor pending closes. It's not safe to close right now because
// this may release aTerm, but aTerm may exist in the calling stack (in many places!).
// It might work to start a timer to close it, but that would have some serious unexpected
// side effects.
// [aTerm closeSession:session];
return;
}
if (hasPendingBlurChange) {
if (pendingBlur) {
[aTerm enableBlur:pendingBlurRadius];
} else {
[aTerm disableBlur];
}
}
if (hasPendingSizeChange) {
[aTerm sessionInitiatedResize:session width:pendingW height:pendingH];
}
if (hasPendingFitWindowToTab) {
[aTerm fitWindowToTab:[session tab]];
}
if (pendingLabelColor) {
[aTerm setLabelColor:pendingLabelColor forTabViewItem:[[session tab] tabViewItem]];
}
if (pendingTabColor) {
[aTerm setTabColor:pendingTabColor forTabViewItem:[[session tab]tabViewItem]];
}
if (hasPendingSetWindowTitle) {
[aTerm setWindowTitle];
}
if (hasPendingResetTempTitle) {
[aTerm resetTempTitle];
}
}
- (void)sessionInitiatedResize:(PTYSession*)session width:(int)width height:(int)height
{
hasPendingSizeChange = YES;
pendingW = width;
pendingH = height;
}
- (BOOL)fullScreen
{
return isFullScreen;
}
- (BOOL)anyFullScreen
{
return isLionFullScreen || isFullScreen;
}
- (PTYSession *)currentSession
{
return session;
}
- (void)closeSession:(PTYSession*)aSession
{
hasPendingClose = YES; // TODO: This isn't right with panes.
}
- (void)closeTab:(PTYTab*)theTab
{
hasPendingClose = YES;
}
- (IBAction)nextTab:(id)sender
{
}
- (IBAction)previousTab:(id)sender
{
}
- (void)setLabelColor:(NSColor *)color forTabViewItem:tabViewItem
{
[pendingLabelColor release];
pendingLabelColor = color;
[pendingLabelColor retain];
}
- (void)setTabColor:(NSColor *)color forTabViewItem:tabViewItem
{
[pendingTabColor release];
pendingTabColor = color;
[pendingTabColor retain];
}
- (NSColor*)tabColorForTabViewItem:(NSTabViewItem*)tabViewItem
{
if (pendingTabColor) {
return pendingTabColor;
} else {
return [realWindow tabColorForTabViewItem:tabViewItem];
}
}
- (void)enableBlur:(double)radius
{
hasPendingBlurChange = YES;
pendingBlurRadius = radius;
pendingBlur = YES;
}
- (void)disableBlur
{
hasPendingBlurChange = YES;
pendingBlur = NO;
}
- (BOOL)tempTitle
{
return NO;
}
- (void)fitWindowToTab:(PTYTab*)tab
{
hasPendingFitWindowToTab = YES;
}
- (PTYTabView *)tabView
{
return nil;
}
- (void)setWindowTitle
{
hasPendingSetWindowTitle = YES;
}
- (void)resetTempTitle
{
hasPendingResetTempTitle = YES;
}
- (PTYTab*)currentTab
{
return nil;
}
- (void)windowSetFrameTopLeftPoint:(NSPoint)point
{
}
- (void)windowPerformMiniaturize:(id)sender
{
}
- (void)windowDeminiaturize:(id)sender
{
}
- (void)windowOrderFront:(id)sender
{
}
- (void)windowOrderBack:(id)sender
{
}
- (BOOL)windowIsMiniaturized
{
return isMiniaturized;
}
- (NSRect)windowFrame
{
return frame;
}
- (NSScreen*)windowScreen
{
return screen;
}
@end