@opensumi/ide-terminal-next 3.5.1-next-1730882731.0 → 3.5.1-next-1730963433.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/component/resize.view.d.ts +1 -3
- package/lib/browser/component/resize.view.d.ts.map +1 -1
- package/lib/browser/component/resize.view.js +24 -20
- package/lib/browser/component/resize.view.js.map +1 -1
- package/lib/browser/component/tab.item.d.ts +2 -6
- package/lib/browser/component/tab.item.d.ts.map +1 -1
- package/lib/browser/component/tab.item.js +32 -24
- package/lib/browser/component/tab.item.js.map +1 -1
- package/lib/browser/component/tab.view.d.ts +1 -3
- package/lib/browser/component/tab.view.d.ts.map +1 -1
- package/lib/browser/component/tab.view.js +5 -9
- package/lib/browser/component/tab.view.js.map +1 -1
- package/lib/browser/component/terminal.view.d.ts +1 -3
- package/lib/browser/component/terminal.view.d.ts.map +1 -1
- package/lib/browser/component/terminal.view.js +8 -7
- package/lib/browser/component/terminal.view.js.map +1 -1
- package/lib/browser/contribution/terminal.command.d.ts.map +1 -1
- package/lib/browser/contribution/terminal.command.js +24 -19
- package/lib/browser/contribution/terminal.command.js.map +1 -1
- package/lib/browser/terminal.api.d.ts.map +1 -1
- package/lib/browser/terminal.api.js +5 -2
- package/lib/browser/terminal.api.js.map +1 -1
- package/lib/browser/terminal.client.d.ts.map +1 -1
- package/lib/browser/terminal.client.js +8 -4
- package/lib/browser/terminal.client.js.map +1 -1
- package/lib/browser/terminal.controller.d.ts.map +1 -1
- package/lib/browser/terminal.controller.js +12 -15
- package/lib/browser/terminal.controller.js.map +1 -1
- package/lib/browser/terminal.render.d.ts +2 -6
- package/lib/browser/terminal.render.d.ts.map +1 -1
- package/lib/browser/terminal.search.js +1 -1
- package/lib/browser/terminal.search.js.map +1 -1
- package/lib/browser/terminal.view.d.ts +19 -22
- package/lib/browser/terminal.view.d.ts.map +1 -1
- package/lib/browser/terminal.view.js +121 -214
- package/lib/browser/terminal.view.js.map +1 -1
- package/lib/common/controller.d.ts +7 -6
- package/lib/common/controller.d.ts.map +1 -1
- package/lib/common/controller.js.map +1 -1
- package/lib/common/render.d.ts +2 -5
- package/lib/common/render.d.ts.map +1 -1
- package/lib/common/render.js.map +1 -1
- package/lib/common/resize.d.ts +10 -9
- package/lib/common/resize.d.ts.map +1 -1
- package/package.json +18 -17
- package/src/browser/component/resize.view.tsx +69 -54
- package/src/browser/component/tab.item.tsx +43 -32
- package/src/browser/component/tab.view.tsx +11 -16
- package/src/browser/component/terminal.view.tsx +11 -8
- package/src/browser/contribution/terminal.command.ts +26 -20
- package/src/browser/terminal.api.ts +6 -2
- package/src/browser/terminal.client.ts +8 -4
- package/src/browser/terminal.controller.ts +12 -18
- package/src/browser/terminal.search.ts +1 -1
- package/src/browser/terminal.view.ts +132 -127
- package/src/common/controller.ts +7 -8
- package/src/common/render.ts +2 -5
- package/src/common/resize.ts +13 -9
- package/lib/browser/component/terminal.select.d.ts +0 -6
- package/lib/browser/component/terminal.select.d.ts.map +0 -1
- package/lib/browser/component/terminal.select.js +0 -19
- package/lib/browser/component/terminal.select.js.map +0 -1
- package/src/browser/component/terminal.select.tsx +0 -29
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { action, computed, makeObservable, observable } from 'mobx';
|
|
2
|
-
|
|
3
1
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
4
2
|
import { Disposable, Emitter, Event } from '@opensumi/ide-core-browser';
|
|
3
|
+
import { derived, observableValue, transaction } from '@opensumi/ide-monaco/lib/common/observable';
|
|
5
4
|
|
|
6
5
|
import {
|
|
7
6
|
IShellLaunchConfig,
|
|
@@ -13,32 +12,18 @@ import {
|
|
|
13
12
|
} from '../common';
|
|
14
13
|
|
|
15
14
|
export class Widget extends Disposable implements IWidget {
|
|
16
|
-
protected _id: string;
|
|
17
15
|
protected _group: WidgetGroup;
|
|
18
16
|
protected _element: HTMLDivElement;
|
|
19
17
|
protected _show: boolean;
|
|
20
18
|
protected _error: boolean;
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
shadowDynamic = 0;
|
|
20
|
+
readonly dynamic = observableValue<number>(this, 0);
|
|
21
|
+
readonly shadowDynamic = observableValue<number>(this, 0);
|
|
22
|
+
readonly name = observableValue<string>(this, '');
|
|
23
|
+
readonly processName = observableValue<string>(this, '');
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
name = '';
|
|
30
|
-
|
|
31
|
-
@observable
|
|
32
|
-
processName: string | undefined;
|
|
33
|
-
|
|
34
|
-
constructor(id: string, public reuse: boolean = false, public recovery: boolean = false) {
|
|
25
|
+
constructor(public readonly id: string, public reuse: boolean = false, public recovery: boolean = false) {
|
|
35
26
|
super();
|
|
36
|
-
makeObservable(this);
|
|
37
|
-
this._id = id;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
get id() {
|
|
41
|
-
return this._id;
|
|
42
27
|
}
|
|
43
28
|
|
|
44
29
|
get group() {
|
|
@@ -88,22 +73,28 @@ export class Widget extends Disposable implements IWidget {
|
|
|
88
73
|
onShow: Event<boolean> = this._onShow.event;
|
|
89
74
|
onError: Event<boolean> = this._onError.event;
|
|
90
75
|
|
|
91
|
-
@action
|
|
92
76
|
resize(dynamic?: number) {
|
|
93
|
-
|
|
94
|
-
|
|
77
|
+
transaction((tx) => {
|
|
78
|
+
const dynamicValue = dynamic || this.shadowDynamic.get();
|
|
79
|
+
|
|
80
|
+
this.dynamic.set(dynamicValue, tx);
|
|
81
|
+
this.shadowDynamic.set(dynamicValue, tx);
|
|
82
|
+
});
|
|
95
83
|
this._onResize.fire();
|
|
96
84
|
}
|
|
97
85
|
|
|
98
|
-
@action
|
|
99
86
|
increase(increment: number) {
|
|
100
|
-
|
|
87
|
+
transaction((tx) => {
|
|
88
|
+
const preValue = this.shadowDynamic.get();
|
|
89
|
+
this.shadowDynamic.set(preValue + increment, tx);
|
|
90
|
+
});
|
|
101
91
|
this._onResize.fire();
|
|
102
92
|
}
|
|
103
93
|
|
|
104
|
-
@action
|
|
105
94
|
rename(name: string) {
|
|
106
|
-
|
|
95
|
+
transaction((tx) => {
|
|
96
|
+
this.name.set(name, tx);
|
|
97
|
+
});
|
|
107
98
|
}
|
|
108
99
|
}
|
|
109
100
|
|
|
@@ -116,20 +107,11 @@ export class WidgetGroup extends Disposable implements IWidgetGroup {
|
|
|
116
107
|
protected _name: string;
|
|
117
108
|
protected _activated: boolean;
|
|
118
109
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
@observable
|
|
126
|
-
activated = false;
|
|
127
|
-
|
|
128
|
-
@observable
|
|
129
|
-
name = '';
|
|
130
|
-
|
|
131
|
-
@observable
|
|
132
|
-
currentId: string;
|
|
110
|
+
readonly widgets = observableValue<Widget[]>(this, []);
|
|
111
|
+
readonly editable = observableValue<boolean>(this, false);
|
|
112
|
+
readonly activated = observableValue<boolean>(this, false);
|
|
113
|
+
readonly name = observableValue<string>(this, '');
|
|
114
|
+
readonly currentId = observableValue<string>(this, '');
|
|
133
115
|
|
|
134
116
|
widgetsMap: Map<string, Widget> = new Map();
|
|
135
117
|
|
|
@@ -149,54 +131,62 @@ export class WidgetGroup extends Disposable implements IWidgetGroup {
|
|
|
149
131
|
}
|
|
150
132
|
|
|
151
133
|
get length() {
|
|
152
|
-
return this.widgets.length;
|
|
134
|
+
return this.widgets.get().length;
|
|
153
135
|
}
|
|
154
136
|
|
|
155
137
|
get first() {
|
|
156
|
-
return this.widgets[0];
|
|
138
|
+
return this.widgets.get()[0];
|
|
157
139
|
}
|
|
158
140
|
|
|
159
141
|
get last() {
|
|
160
|
-
return this.widgets[this.length - 1];
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
get current() {
|
|
164
|
-
return this.widgetsMap.get(this.currentId);
|
|
142
|
+
return this.widgets.get()[this.length - 1];
|
|
165
143
|
}
|
|
166
144
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return this.
|
|
170
|
-
}
|
|
145
|
+
readonly current = derived(this, (reader) => {
|
|
146
|
+
const currentId = this.currentId.read(reader);
|
|
147
|
+
return this.widgetsMap.get(currentId);
|
|
148
|
+
});
|
|
171
149
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return this.current?.processName;
|
|
175
|
-
}
|
|
150
|
+
readonly snapshot = derived(this, (reader) => {
|
|
151
|
+
const current = this.current.read(reader);
|
|
152
|
+
return this.name.read(reader) || current?.name.read(reader) || current?.processName.read(reader) || '';
|
|
153
|
+
});
|
|
176
154
|
|
|
177
|
-
@action
|
|
178
155
|
addWidget(widget: Widget) {
|
|
179
|
-
|
|
156
|
+
transaction((tx) => {
|
|
157
|
+
const preWidgets = this.widgets.get();
|
|
158
|
+
this.widgets.set([...preWidgets, widget], tx);
|
|
159
|
+
});
|
|
180
160
|
this.widgetsMap.set(widget.id, widget);
|
|
181
161
|
|
|
182
|
-
if (!this.currentId) {
|
|
183
|
-
|
|
162
|
+
if (!this.currentId.get()) {
|
|
163
|
+
transaction((tx) => {
|
|
164
|
+
this.currentId.set(widget.id, tx);
|
|
165
|
+
});
|
|
184
166
|
}
|
|
185
167
|
this._averageLayout();
|
|
186
168
|
}
|
|
187
169
|
|
|
188
170
|
findWidget(widget: Widget) {
|
|
189
|
-
return this.widgets.findIndex((item) => item.id === widget.id);
|
|
171
|
+
return this.widgets.get().findIndex((item) => item.id === widget.id);
|
|
190
172
|
}
|
|
191
173
|
|
|
192
|
-
@action
|
|
193
174
|
selectWidget(widget: Widget) {
|
|
194
|
-
|
|
175
|
+
transaction((tx) => {
|
|
176
|
+
this.currentId.set(widget.id, tx);
|
|
177
|
+
});
|
|
195
178
|
}
|
|
196
179
|
|
|
197
180
|
removeWidgetByIndex(index: number) {
|
|
198
|
-
const
|
|
181
|
+
const widgets = this.widgets.get();
|
|
182
|
+
const widget = widgets.splice(index, 1);
|
|
199
183
|
this.widgetsMap.delete(widget[0].id);
|
|
184
|
+
transaction((tx) => {
|
|
185
|
+
this.widgets.set(
|
|
186
|
+
widgets.filter((w) => w !== widget[0]),
|
|
187
|
+
tx,
|
|
188
|
+
);
|
|
189
|
+
});
|
|
200
190
|
this._averageLayout();
|
|
201
191
|
|
|
202
192
|
if (this.last) {
|
|
@@ -206,31 +196,34 @@ export class WidgetGroup extends Disposable implements IWidgetGroup {
|
|
|
206
196
|
return widget[0];
|
|
207
197
|
}
|
|
208
198
|
|
|
209
|
-
@action
|
|
210
199
|
edit() {
|
|
211
|
-
|
|
200
|
+
transaction((tx) => {
|
|
201
|
+
this.editable.set(true, tx);
|
|
202
|
+
});
|
|
212
203
|
}
|
|
213
204
|
|
|
214
|
-
@action
|
|
215
205
|
unedit() {
|
|
216
|
-
|
|
206
|
+
transaction((tx) => {
|
|
207
|
+
this.editable.set(false, tx);
|
|
208
|
+
});
|
|
217
209
|
}
|
|
218
210
|
|
|
219
|
-
@action
|
|
220
211
|
rename(name: string) {
|
|
221
|
-
|
|
222
|
-
|
|
212
|
+
transaction((tx) => {
|
|
213
|
+
this.name.set(name, tx);
|
|
214
|
+
this.editable.set(false, tx);
|
|
215
|
+
});
|
|
223
216
|
}
|
|
224
217
|
|
|
225
218
|
private _isLast(widget: Widget) {
|
|
226
|
-
return widget.id === this.widgets[this.widgets.length - 1].id;
|
|
219
|
+
return widget.id === this.widgets.get()[this.widgets.get().length - 1].id;
|
|
227
220
|
}
|
|
228
221
|
|
|
229
222
|
private _averageLayout() {
|
|
230
|
-
const average = Math.round((WidgetGroup.whole / this.widgets.length) * WidgetGroup.float) / WidgetGroup.float;
|
|
231
|
-
this.widgets.forEach((widget) => {
|
|
223
|
+
const average = Math.round((WidgetGroup.whole / this.widgets.get().length) * WidgetGroup.float) / WidgetGroup.float;
|
|
224
|
+
this.widgets.get().forEach((widget) => {
|
|
232
225
|
if (this._isLast(widget)) {
|
|
233
|
-
widget.resize(WidgetGroup.whole - average * (this.widgets.length - 1));
|
|
226
|
+
widget.resize(WidgetGroup.whole - average * (this.widgets.get().length - 1));
|
|
234
227
|
} else {
|
|
235
228
|
widget.resize(average);
|
|
236
229
|
}
|
|
@@ -240,41 +233,35 @@ export class WidgetGroup extends Disposable implements IWidgetGroup {
|
|
|
240
233
|
|
|
241
234
|
@Injectable()
|
|
242
235
|
export class TerminalGroupViewService implements ITerminalGroupViewService {
|
|
243
|
-
protected _widgets: Map<string, Widget>;
|
|
244
|
-
|
|
245
|
-
@observable
|
|
246
|
-
groups: WidgetGroup[] = observable.array([]);
|
|
247
|
-
|
|
248
|
-
@observable
|
|
249
|
-
currentGroupId = '';
|
|
250
|
-
|
|
251
|
-
@observable
|
|
252
|
-
currentGroupIndex = -1;
|
|
253
|
-
|
|
254
236
|
@Autowired(ITerminalInternalService)
|
|
255
237
|
private readonly service: ITerminalInternalService;
|
|
256
238
|
|
|
239
|
+
protected _widgets: Map<string, Widget> = new Map();
|
|
240
|
+
|
|
241
|
+
readonly groups = observableValue<WidgetGroup[]>(this, []);
|
|
242
|
+
readonly currentGroupIndex = observableValue<number>(this, -1);
|
|
243
|
+
readonly currentGroupId = observableValue<string>(this, '');
|
|
244
|
+
|
|
257
245
|
protected _onWidgetCreated = new Emitter<Widget>();
|
|
258
246
|
protected _onWidgetSelected = new Emitter<Widget>();
|
|
259
247
|
protected _onWidgetDisposed = new Emitter<Widget>();
|
|
260
248
|
protected _onWidgetEmpty = new Emitter<void>();
|
|
261
249
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
get currentGroup() {
|
|
268
|
-
return this.groups[this.currentGroupIndex];
|
|
269
|
-
}
|
|
250
|
+
readonly currentGroup = derived(this, (reader) => {
|
|
251
|
+
const groups = this.groups.read(reader);
|
|
252
|
+
const index = this.currentGroupIndex.read(reader);
|
|
253
|
+
return groups[index];
|
|
254
|
+
});
|
|
270
255
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
256
|
+
readonly currentWidget = derived(this, (reader) => {
|
|
257
|
+
const group = this.currentGroup.read(reader);
|
|
258
|
+
return group && this.getWidget(group.currentId.read(reader));
|
|
259
|
+
});
|
|
274
260
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
261
|
+
readonly currentWidgetId = derived(this, (reader) => {
|
|
262
|
+
const group = this.currentGroup.read(reader);
|
|
263
|
+
return group && group.currentId.read(reader);
|
|
264
|
+
});
|
|
278
265
|
|
|
279
266
|
onWidgetCreated = this._onWidgetCreated.event;
|
|
280
267
|
onWidgetSelected = this._onWidgetSelected.event;
|
|
@@ -282,24 +269,26 @@ export class TerminalGroupViewService implements ITerminalGroupViewService {
|
|
|
282
269
|
onWidgetEmpty = this._onWidgetEmpty.event;
|
|
283
270
|
|
|
284
271
|
getGroup(index: number): WidgetGroup {
|
|
285
|
-
if (index > this.groups.length - 1) {
|
|
272
|
+
if (index > this.groups.get().length - 1) {
|
|
286
273
|
throw new Error('out of groups length');
|
|
287
274
|
}
|
|
288
|
-
return this.groups[index];
|
|
275
|
+
return this.groups.get()[index];
|
|
289
276
|
}
|
|
290
277
|
|
|
291
|
-
@action
|
|
292
278
|
private _doSelectGroup(index: number) {
|
|
293
279
|
const group = this.getGroup(index);
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
280
|
+
transaction((tx) => {
|
|
281
|
+
this.currentGroupIndex.set(index, tx);
|
|
282
|
+
this.currentGroupId.set(group.id, tx);
|
|
283
|
+
group.activated.set(true, tx);
|
|
284
|
+
});
|
|
297
285
|
// 恢复的 group.current 为空,手动选择第一个 widget
|
|
298
286
|
if (!group.current && group.first) {
|
|
299
287
|
group.selectWidget(group.first);
|
|
300
288
|
}
|
|
301
|
-
|
|
302
|
-
|
|
289
|
+
const current = group.current.get();
|
|
290
|
+
if (current) {
|
|
291
|
+
this._onWidgetSelected.fire(current);
|
|
303
292
|
this.resize();
|
|
304
293
|
}
|
|
305
294
|
}
|
|
@@ -308,11 +297,13 @@ export class TerminalGroupViewService implements ITerminalGroupViewService {
|
|
|
308
297
|
this._doSelectGroup(index);
|
|
309
298
|
}
|
|
310
299
|
|
|
311
|
-
@action
|
|
312
300
|
private _doCreateGroup(id?: string, options?: IShellLaunchConfig) {
|
|
313
301
|
const group = new WidgetGroup(id, options);
|
|
314
|
-
|
|
315
|
-
|
|
302
|
+
transaction((tx) => {
|
|
303
|
+
const preGroups = this.groups.get();
|
|
304
|
+
this.groups.set([...preGroups, group], tx);
|
|
305
|
+
});
|
|
306
|
+
return this.groups.get().length - 1;
|
|
316
307
|
}
|
|
317
308
|
|
|
318
309
|
createGroup(options?: IShellLaunchConfig) {
|
|
@@ -325,26 +316,35 @@ export class TerminalGroupViewService implements ITerminalGroupViewService {
|
|
|
325
316
|
if (this.empty()) {
|
|
326
317
|
this._onWidgetEmpty.fire();
|
|
327
318
|
} else {
|
|
328
|
-
|
|
329
|
-
|
|
319
|
+
const currentGroupIndex = this.currentGroupIndex.get();
|
|
320
|
+
if (index === currentGroupIndex) {
|
|
321
|
+
this._doSelectGroup(this.groups.get().length - 1);
|
|
330
322
|
}
|
|
331
|
-
if (index <
|
|
332
|
-
this._doSelectGroup(
|
|
323
|
+
if (index < currentGroupIndex) {
|
|
324
|
+
this._doSelectGroup(currentGroupIndex - 1);
|
|
333
325
|
}
|
|
334
326
|
}
|
|
335
327
|
}
|
|
336
328
|
|
|
337
|
-
@action
|
|
338
329
|
private _doRemoveGroup(index: number) {
|
|
339
|
-
const
|
|
330
|
+
const preGroups = this.groups.get();
|
|
331
|
+
|
|
332
|
+
const [group] = preGroups.splice(index, 1);
|
|
340
333
|
|
|
341
334
|
if (group) {
|
|
342
|
-
group.widgets.forEach((widget) => {
|
|
335
|
+
group.widgets.get().forEach((widget) => {
|
|
343
336
|
this._widgets.delete(widget.id);
|
|
344
337
|
widget.dispose();
|
|
345
338
|
this._onWidgetDisposed.fire(widget);
|
|
346
339
|
});
|
|
347
340
|
group.dispose();
|
|
341
|
+
|
|
342
|
+
transaction((tx) => {
|
|
343
|
+
this.groups.set(
|
|
344
|
+
preGroups.filter((g) => g.id !== group.id),
|
|
345
|
+
tx,
|
|
346
|
+
);
|
|
347
|
+
});
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
this._checkIfEmpty(index);
|
|
@@ -367,7 +367,7 @@ export class TerminalGroupViewService implements ITerminalGroupViewService {
|
|
|
367
367
|
selectWidget(id: string) {
|
|
368
368
|
const widget = this.getWidget(id);
|
|
369
369
|
const group = widget.group;
|
|
370
|
-
const index = this.groups.findIndex((g) => g.id === group.id);
|
|
370
|
+
const index = this.groups.get().findIndex((g) => g.id === group.id);
|
|
371
371
|
group.selectWidget(widget);
|
|
372
372
|
this.selectGroup(index);
|
|
373
373
|
}
|
|
@@ -392,22 +392,26 @@ export class TerminalGroupViewService implements ITerminalGroupViewService {
|
|
|
392
392
|
removeWidget(id: string) {
|
|
393
393
|
const widget = this.getWidget(id);
|
|
394
394
|
const group = widget.group;
|
|
395
|
-
|
|
395
|
+
|
|
396
|
+
const groupIndex = this.groups.get().findIndex((g) => group.id === g.id);
|
|
396
397
|
const index = group.findWidget(widget);
|
|
397
398
|
group.removeWidgetByIndex(index);
|
|
399
|
+
|
|
398
400
|
this._widgets.delete(id);
|
|
399
401
|
widget.dispose();
|
|
400
402
|
this._onWidgetDisposed.fire(widget);
|
|
401
403
|
this._checkIfGroupEmpty(groupIndex);
|
|
402
404
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
+
const current = group.current.get();
|
|
406
|
+
if (current) {
|
|
407
|
+
this._onWidgetSelected.fire(current);
|
|
405
408
|
}
|
|
406
409
|
}
|
|
407
410
|
|
|
408
411
|
resize() {
|
|
409
|
-
|
|
410
|
-
|
|
412
|
+
const group = this.currentGroup.get();
|
|
413
|
+
if (group) {
|
|
414
|
+
group.widgets.get().forEach((widget) => {
|
|
411
415
|
widget.resize();
|
|
412
416
|
});
|
|
413
417
|
}
|
|
@@ -417,9 +421,10 @@ export class TerminalGroupViewService implements ITerminalGroupViewService {
|
|
|
417
421
|
return this._widgets.size === 0;
|
|
418
422
|
}
|
|
419
423
|
|
|
420
|
-
@action
|
|
421
424
|
clear() {
|
|
422
|
-
|
|
425
|
+
transaction((tx) => {
|
|
426
|
+
this.groups.set([], tx);
|
|
427
|
+
});
|
|
423
428
|
this._widgets.clear();
|
|
424
429
|
this._onWidgetEmpty.fire();
|
|
425
430
|
}
|
package/src/common/controller.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IContextKeyService } from '@opensumi/ide-core-browser';
|
|
2
2
|
import { Deferred, Disposable, Event, IDisposable, Uri } from '@opensumi/ide-core-common';
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line import/no-restricted-paths
|
|
3
|
+
import { IObservable } from '@opensumi/ide-monaco/lib/common/observable';
|
|
5
4
|
|
|
6
5
|
import {
|
|
7
6
|
ITerminalClient,
|
|
@@ -129,12 +128,12 @@ export interface ITerminalSearchService {
|
|
|
129
128
|
|
|
130
129
|
export const ITerminalGroupViewService = Symbol('ITerminalGroupViewService');
|
|
131
130
|
export interface ITerminalGroupViewService {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
readonly groups: IObservable<IWidgetGroup[]>;
|
|
132
|
+
readonly currentGroupIndex: IObservable<number>;
|
|
133
|
+
readonly currentGroup: IObservable<IWidgetGroup>;
|
|
134
|
+
readonly currentGroupId: IObservable<string>;
|
|
135
|
+
readonly currentWidgetId: IObservable<string>;
|
|
136
|
+
readonly currentWidget: IObservable<IWidget>;
|
|
138
137
|
|
|
139
138
|
createGroup(): number;
|
|
140
139
|
getGroup(index: number): IWidgetGroup;
|
package/src/common/render.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ThemeType } from '@opensumi/ide-theme/lib/common';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { IWidgetGroup } from '../index';
|
|
4
4
|
|
|
5
5
|
export enum ItemType {
|
|
6
6
|
info = 0,
|
|
@@ -8,12 +8,9 @@ export enum ItemType {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface ItemProps {
|
|
11
|
-
|
|
12
|
-
name?: string;
|
|
11
|
+
group?: IWidgetGroup;
|
|
13
12
|
selected?: boolean;
|
|
14
13
|
type?: ItemType;
|
|
15
|
-
editable?: boolean;
|
|
16
|
-
options?: IShellLaunchConfig;
|
|
17
14
|
onClick?: () => void;
|
|
18
15
|
onClose?: () => void;
|
|
19
16
|
onInputBlur?: (id: string) => void;
|
package/src/common/resize.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { Disposable, Event } from '@opensumi/ide-core-common';
|
|
2
|
+
import { IObservable, ISettableObservable } from '@opensumi/ide-monaco/lib/common/observable';
|
|
2
3
|
|
|
3
4
|
import { IShellLaunchConfig } from './pty';
|
|
4
5
|
|
|
5
6
|
export interface IWidget extends Disposable {
|
|
7
|
+
dynamic: IObservable<number>;
|
|
8
|
+
shadowDynamic: IObservable<number>;
|
|
9
|
+
name: ISettableObservable<string>;
|
|
10
|
+
processName: ISettableObservable<string>;
|
|
11
|
+
|
|
6
12
|
id: string;
|
|
7
|
-
name: string;
|
|
8
|
-
processName?: string;
|
|
9
|
-
dynamic: number;
|
|
10
|
-
shadowDynamic: number;
|
|
11
13
|
element: HTMLDivElement;
|
|
12
14
|
group: IWidgetGroup;
|
|
13
15
|
reuse: boolean;
|
|
14
16
|
recovery: boolean;
|
|
15
17
|
show: boolean;
|
|
16
18
|
error: boolean;
|
|
19
|
+
|
|
17
20
|
resize: (dynamic?: number) => void;
|
|
18
21
|
increase: (increment: number) => void;
|
|
19
22
|
rename(name: string): void;
|
|
@@ -25,16 +28,17 @@ export interface IWidget extends Disposable {
|
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
export interface IWidgetGroup extends Disposable {
|
|
31
|
+
name: IObservable<string>;
|
|
32
|
+
snapshot: IObservable<string>;
|
|
33
|
+
activated: IObservable<boolean>;
|
|
34
|
+
editable: IObservable<boolean>;
|
|
35
|
+
widgets: IObservable<IWidget[]>;
|
|
36
|
+
|
|
28
37
|
id: string;
|
|
29
|
-
name: string;
|
|
30
38
|
options?: IShellLaunchConfig;
|
|
31
|
-
editable: boolean;
|
|
32
|
-
activated: boolean;
|
|
33
39
|
length: number;
|
|
34
|
-
widgets: IWidget[];
|
|
35
40
|
widgetsMap: Map<string, IWidget>;
|
|
36
41
|
last: IWidget;
|
|
37
|
-
snapshot: string;
|
|
38
42
|
addWidget(widget: IWidget): void;
|
|
39
43
|
removeWidgetByIndex: (index: number) => IWidget;
|
|
40
44
|
edit(): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.select.d.ts","sourceRoot":"","sources":["../../../src/browser/component/terminal.select.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;;;;AAQ1B,wBAmBG"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const mobx_react_lite_1 = require("mobx-react-lite");
|
|
5
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
|
|
7
|
-
const common_1 = require("../../common");
|
|
8
|
-
const terminal_module_less_1 = tslib_1.__importDefault(require("./terminal.module.less"));
|
|
9
|
-
exports.default = (0, mobx_react_lite_1.observer)(() => {
|
|
10
|
-
const view = (0, ide_core_browser_1.useInjectable)(common_1.ITerminalGroupViewService);
|
|
11
|
-
const onChange = (event) => {
|
|
12
|
-
const index = event.target.value;
|
|
13
|
-
view.selectGroup(parseInt(index, 10));
|
|
14
|
-
};
|
|
15
|
-
const index = view.currentGroupIndex;
|
|
16
|
-
return (react_1.default.createElement("div", { className: terminal_module_less_1.default.toolbarSelect },
|
|
17
|
-
react_1.default.createElement("select", { value: index || 0, onChange: onChange }, (view.groups || []).map((group, index) => (react_1.default.createElement("option", { key: `${group}-${index}`, value: index }, `${index + 1}: ${group.snapshot}`))))));
|
|
18
|
-
});
|
|
19
|
-
//# sourceMappingURL=terminal.select.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.select.js","sourceRoot":"","sources":["../../../src/browser/component/terminal.select.tsx"],"names":[],"mappings":";;;AAAA,qDAA2C;AAC3C,0DAA0B;AAE1B,iEAA2D;AAE3D,yCAAyD;AAEzD,0FAA4C;AAE5C,kBAAe,IAAA,0BAAQ,EAAC,GAAG,EAAE;IAC3B,MAAM,IAAI,GAAG,IAAA,gCAAa,EAA4B,kCAAyB,CAAC,CAAC;IAEjF,MAAM,QAAQ,GAAG,CAAC,KAA2C,EAAE,EAAE;QAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QACjC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;IACxC,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC;IAErC,OAAO,CACL,uCAAK,SAAS,EAAE,8BAAM,CAAC,aAAa;QAClC,0CAAQ,KAAK,EAAE,KAAK,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAQ,IAC1C,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CACzC,0CAAQ,GAAG,EAAE,GAAG,KAAK,IAAI,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,IAAG,GAAG,KAAK,GAAG,CAAC,KAAK,KAAK,CAAC,QAAQ,EAAE,CAAU,CAC7F,CAAC,CACK,CACL,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { observer } from 'mobx-react-lite';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import { useInjectable } from '@opensumi/ide-core-browser';
|
|
5
|
-
|
|
6
|
-
import { ITerminalGroupViewService } from '../../common';
|
|
7
|
-
|
|
8
|
-
import styles from './terminal.module.less';
|
|
9
|
-
|
|
10
|
-
export default observer(() => {
|
|
11
|
-
const view = useInjectable<ITerminalGroupViewService>(ITerminalGroupViewService);
|
|
12
|
-
|
|
13
|
-
const onChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
|
|
14
|
-
const index = event.target.value;
|
|
15
|
-
view.selectGroup(parseInt(index, 10));
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const index = view.currentGroupIndex;
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<div className={styles.toolbarSelect}>
|
|
22
|
-
<select value={index || 0} onChange={onChange}>
|
|
23
|
-
{(view.groups || []).map((group, index) => (
|
|
24
|
-
<option key={`${group}-${index}`} value={index}>{`${index + 1}: ${group.snapshot}`}</option>
|
|
25
|
-
))}
|
|
26
|
-
</select>
|
|
27
|
-
</div>
|
|
28
|
-
);
|
|
29
|
-
});
|