@theia/terminal 1.45.0 → 1.46.0-next.72
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/README.md +30 -30
- package/lib/browser/base/terminal-service.d.ts +34 -34
- package/lib/browser/base/terminal-service.js +7 -7
- package/lib/browser/base/terminal-widget.d.ts +192 -192
- package/lib/browser/base/terminal-widget.js +34 -34
- package/lib/browser/index.d.ts +1 -1
- package/lib/browser/index.js +28 -28
- package/lib/browser/search/terminal-search-container.d.ts +3 -3
- package/lib/browser/search/terminal-search-container.js +28 -28
- package/lib/browser/search/terminal-search-widget.d.ts +30 -30
- package/lib/browser/search/terminal-search-widget.js +147 -147
- package/lib/browser/shell-terminal-profile.d.ts +20 -20
- package/lib/browser/shell-terminal-profile.js +42 -42
- package/lib/browser/terminal-contribution.d.ts +3 -3
- package/lib/browser/terminal-contribution.js +20 -20
- package/lib/browser/terminal-copy-on-selection-handler.d.ts +10 -10
- package/lib/browser/terminal-copy-on-selection-handler.js +103 -103
- package/lib/browser/terminal-file-link-provider.d.ts +24 -24
- package/lib/browser/terminal-file-link-provider.js +200 -200
- package/lib/browser/terminal-frontend-contribution.d.ts +115 -115
- package/lib/browser/terminal-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/terminal-frontend-contribution.js +1078 -1056
- package/lib/browser/terminal-frontend-contribution.js.map +1 -1
- package/lib/browser/terminal-frontend-module.d.ts +5 -5
- package/lib/browser/terminal-frontend-module.js +117 -117
- package/lib/browser/terminal-link-helpers.d.ts +27 -27
- package/lib/browser/terminal-link-helpers.js +155 -155
- package/lib/browser/terminal-link-provider.d.ts +51 -51
- package/lib/browser/terminal-link-provider.js +197 -197
- package/lib/browser/terminal-preferences.d.ts +61 -61
- package/lib/browser/terminal-preferences.d.ts.map +1 -1
- package/lib/browser/terminal-preferences.js +357 -356
- package/lib/browser/terminal-preferences.js.map +1 -1
- package/lib/browser/terminal-profile-service.d.ts +58 -58
- package/lib/browser/terminal-profile-service.js +158 -158
- package/lib/browser/terminal-quick-open-service.d.ts +36 -36
- package/lib/browser/terminal-quick-open-service.js +137 -137
- package/lib/browser/terminal-theme-service.d.ts +21 -21
- package/lib/browser/terminal-theme-service.d.ts.map +1 -1
- package/lib/browser/terminal-theme-service.js +222 -218
- package/lib/browser/terminal-theme-service.js.map +1 -1
- package/lib/browser/terminal-url-link-provider.d.ts +11 -11
- package/lib/browser/terminal-url-link-provider.js +76 -76
- package/lib/browser/terminal-widget-impl.d.ts +180 -187
- package/lib/browser/terminal-widget-impl.d.ts.map +1 -1
- package/lib/browser/terminal-widget-impl.js +857 -867
- package/lib/browser/terminal-widget-impl.js.map +1 -1
- package/lib/common/base-terminal-protocol.d.ts +55 -55
- package/lib/common/base-terminal-protocol.js +84 -84
- package/lib/common/shell-terminal-protocol.d.ts +66 -66
- package/lib/common/shell-terminal-protocol.js +35 -35
- package/lib/common/terminal-common-module.d.ts +7 -7
- package/lib/common/terminal-common-module.js +31 -31
- package/lib/common/terminal-protocol.d.ts +12 -12
- package/lib/common/terminal-protocol.js +21 -21
- package/lib/common/terminal-watcher.d.ts +13 -13
- package/lib/common/terminal-watcher.js +70 -70
- package/lib/node/base-terminal-server.d.ts +24 -24
- package/lib/node/base-terminal-server.js +168 -168
- package/lib/node/buffering-stream.d.ts +39 -39
- package/lib/node/buffering-stream.js +75 -75
- package/lib/node/buffering-stream.spec.d.ts +1 -1
- package/lib/node/buffering-stream.spec.js +43 -43
- package/lib/node/index.d.ts +1 -1
- package/lib/node/index.js +28 -28
- package/lib/node/shell-process.d.ts +27 -27
- package/lib/node/shell-process.js +107 -107
- package/lib/node/shell-process.js.map +1 -1
- package/lib/node/shell-terminal-server.d.ts +30 -30
- package/lib/node/shell-terminal-server.js +212 -212
- package/lib/node/shell-terminal-server.spec.d.ts +1 -1
- package/lib/node/shell-terminal-server.spec.js +35 -35
- package/lib/node/terminal-backend-contribution.d.ts +9 -9
- package/lib/node/terminal-backend-contribution.js +75 -75
- package/lib/node/terminal-backend-contribution.slow-spec.d.ts +1 -1
- package/lib/node/terminal-backend-contribution.slow-spec.js +54 -54
- package/lib/node/terminal-backend-module.d.ts +11 -11
- package/lib/node/terminal-backend-module.js +69 -69
- package/lib/node/terminal-server.d.ts +9 -9
- package/lib/node/terminal-server.js +64 -64
- package/lib/node/terminal-server.spec.d.ts +1 -1
- package/lib/node/terminal-server.spec.js +41 -41
- package/lib/node/test/terminal-test-container.d.ts +2 -2
- package/lib/node/test/terminal-test-container.js +40 -40
- package/lib/package.spec.js +25 -25
- package/package.json +12 -12
- package/src/browser/base/terminal-service.ts +60 -60
- package/src/browser/base/terminal-widget.ts +254 -254
- package/src/browser/index.ts +17 -17
- package/src/browser/search/terminal-search-container.ts +28 -28
- package/src/browser/search/terminal-search-widget.tsx +161 -161
- package/src/browser/shell-terminal-profile.ts +45 -45
- package/src/browser/style/terminal-search.css +99 -99
- package/src/browser/style/terminal.css +32 -32
- package/src/browser/terminal-contribution.ts +19 -19
- package/src/browser/terminal-copy-on-selection-handler.ts +92 -92
- package/src/browser/terminal-file-link-provider.ts +200 -200
- package/src/browser/terminal-frontend-contribution.ts +1120 -1098
- package/src/browser/terminal-frontend-module.ts +136 -136
- package/src/browser/terminal-link-helpers.ts +187 -187
- package/src/browser/terminal-link-provider.ts +203 -203
- package/src/browser/terminal-preferences.ts +428 -427
- package/src/browser/terminal-profile-service.ts +180 -180
- package/src/browser/terminal-quick-open-service.ts +132 -132
- package/src/browser/terminal-theme-service.ts +213 -209
- package/src/browser/terminal-url-link-provider.ts +66 -66
- package/src/browser/terminal-widget-impl.ts +939 -936
- package/src/common/base-terminal-protocol.ts +125 -125
- package/src/common/shell-terminal-protocol.ts +103 -103
- package/src/common/terminal-common-module.ts +30 -30
- package/src/common/terminal-protocol.ts +32 -32
- package/src/common/terminal-watcher.ts +69 -69
- package/src/node/base-terminal-server.ts +173 -173
- package/src/node/buffering-stream.spec.ts +46 -46
- package/src/node/buffering-stream.ts +95 -95
- package/src/node/index.ts +17 -17
- package/src/node/shell-process.ts +101 -101
- package/src/node/shell-terminal-server.spec.ts +40 -40
- package/src/node/shell-terminal-server.ts +221 -221
- package/src/node/terminal-backend-contribution.slow-spec.ts +63 -63
- package/src/node/terminal-backend-contribution.ts +60 -60
- package/src/node/terminal-backend-module.ts +82 -82
- package/src/node/terminal-server.spec.ts +47 -47
- package/src/node/terminal-server.ts +52 -52
- package/src/node/test/terminal-test-container.ts +39 -39
- package/src/package.spec.ts +28 -28
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2017 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import '../../src/browser/style/terminal.css';
|
|
18
|
-
import 'xterm/css/xterm.css';
|
|
19
|
-
|
|
20
|
-
import { ContainerModule, Container } from '@theia/core/shared/inversify';
|
|
21
|
-
import { CommandContribution, MenuContribution, nls } from '@theia/core/lib/common';
|
|
22
|
-
import { bindContributionProvider } from '@theia/core';
|
|
23
|
-
import { KeybindingContribution, WebSocketConnectionProvider, WidgetFactory, FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
24
|
-
import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
25
|
-
import { TerminalFrontendContribution } from './terminal-frontend-contribution';
|
|
26
|
-
import { TerminalWidgetImpl, TERMINAL_WIDGET_FACTORY_ID } from './terminal-widget-impl';
|
|
27
|
-
import { TerminalWidget, TerminalWidgetOptions } from './base/terminal-widget';
|
|
28
|
-
import { ITerminalServer, terminalPath } from '../common/terminal-protocol';
|
|
29
|
-
import { TerminalWatcher } from '../common/terminal-watcher';
|
|
30
|
-
import { IShellTerminalServer, shellTerminalPath, ShellTerminalServerProxy } from '../common/shell-terminal-protocol';
|
|
31
|
-
import { createCommonBindings } from '../common/terminal-common-module';
|
|
32
|
-
import { TerminalService } from './base/terminal-service';
|
|
33
|
-
import { bindTerminalPreferences } from './terminal-preferences';
|
|
34
|
-
import { TerminalContribution } from './terminal-contribution';
|
|
35
|
-
import { TerminalSearchWidgetFactory } from './search/terminal-search-widget';
|
|
36
|
-
import { TerminalQuickOpenService, TerminalQuickOpenContribution } from './terminal-quick-open-service';
|
|
37
|
-
import { createTerminalSearchFactory } from './search/terminal-search-container';
|
|
38
|
-
import { TerminalCopyOnSelectionHandler } from './terminal-copy-on-selection-handler';
|
|
39
|
-
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
|
|
40
|
-
import { TerminalThemeService } from './terminal-theme-service';
|
|
41
|
-
import { QuickAccessContribution } from '@theia/core/lib/browser/quick-input/quick-access';
|
|
42
|
-
import { createXtermLinkFactory, TerminalLinkProvider, TerminalLinkProviderContribution, XtermLinkFactory } from './terminal-link-provider';
|
|
43
|
-
import { UrlLinkProvider } from './terminal-url-link-provider';
|
|
44
|
-
import { FileDiffPostLinkProvider, FileDiffPreLinkProvider, FileLinkProvider } from './terminal-file-link-provider';
|
|
45
|
-
import {
|
|
46
|
-
ContributedTerminalProfileStore, DefaultProfileStore, DefaultTerminalProfileService,
|
|
47
|
-
TerminalProfileService, TerminalProfileStore, UserTerminalProfileStore
|
|
48
|
-
} from './terminal-profile-service';
|
|
49
|
-
|
|
50
|
-
export default new ContainerModule(bind => {
|
|
51
|
-
bindTerminalPreferences(bind);
|
|
52
|
-
|
|
53
|
-
bind(TerminalWidget).to(TerminalWidgetImpl).inTransientScope();
|
|
54
|
-
bind(TerminalWatcher).toSelf().inSingletonScope();
|
|
55
|
-
|
|
56
|
-
let terminalNum = 0;
|
|
57
|
-
bind(WidgetFactory).toDynamicValue(ctx => ({
|
|
58
|
-
id: TERMINAL_WIDGET_FACTORY_ID,
|
|
59
|
-
createWidget: (options: TerminalWidgetOptions) => {
|
|
60
|
-
const child = new Container({ defaultScope: 'Singleton' });
|
|
61
|
-
child.parent = ctx.container;
|
|
62
|
-
const counter = terminalNum++;
|
|
63
|
-
const domId = options.id || 'terminal-' + counter;
|
|
64
|
-
const widgetOptions: TerminalWidgetOptions = {
|
|
65
|
-
title: `${nls.localizeByDefault('Terminal')} ${counter}`,
|
|
66
|
-
useServerTitle: true,
|
|
67
|
-
destroyTermOnClose: true,
|
|
68
|
-
...options
|
|
69
|
-
};
|
|
70
|
-
child.bind(TerminalWidgetOptions).toConstantValue(widgetOptions);
|
|
71
|
-
child.bind('terminal-dom-id').toConstantValue(domId);
|
|
72
|
-
|
|
73
|
-
child.bind(TerminalSearchWidgetFactory).toDynamicValue(context => createTerminalSearchFactory(context.container));
|
|
74
|
-
|
|
75
|
-
return child.get(TerminalWidget);
|
|
76
|
-
}
|
|
77
|
-
}));
|
|
78
|
-
|
|
79
|
-
bind(TerminalQuickOpenService).toSelf().inSingletonScope();
|
|
80
|
-
bind(TerminalCopyOnSelectionHandler).toSelf().inSingletonScope();
|
|
81
|
-
|
|
82
|
-
bind(TerminalQuickOpenContribution).toSelf().inSingletonScope();
|
|
83
|
-
for (const identifier of [CommandContribution, QuickAccessContribution]) {
|
|
84
|
-
bind(identifier).toService(TerminalQuickOpenContribution);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
bind(TerminalThemeService).toSelf().inSingletonScope();
|
|
88
|
-
bind(TerminalFrontendContribution).toSelf().inSingletonScope();
|
|
89
|
-
bind(TerminalService).toService(TerminalFrontendContribution);
|
|
90
|
-
for (const identifier of [CommandContribution, MenuContribution, KeybindingContribution, TabBarToolbarContribution, ColorContribution]) {
|
|
91
|
-
bind(identifier).toService(TerminalFrontendContribution);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
bind(ITerminalServer).toDynamicValue(ctx => {
|
|
95
|
-
const connection = ctx.container.get(WebSocketConnectionProvider);
|
|
96
|
-
const terminalWatcher = ctx.container.get(TerminalWatcher);
|
|
97
|
-
return connection.createProxy<ITerminalServer>(terminalPath, terminalWatcher.getTerminalClient());
|
|
98
|
-
}).inSingletonScope();
|
|
99
|
-
|
|
100
|
-
bind(ShellTerminalServerProxy).toDynamicValue(ctx => {
|
|
101
|
-
const connection = ctx.container.get(WebSocketConnectionProvider);
|
|
102
|
-
const terminalWatcher = ctx.container.get(TerminalWatcher);
|
|
103
|
-
return connection.createProxy<IShellTerminalServer>(shellTerminalPath, terminalWatcher.getTerminalClient());
|
|
104
|
-
}).inSingletonScope();
|
|
105
|
-
bind(IShellTerminalServer).toService(ShellTerminalServerProxy);
|
|
106
|
-
|
|
107
|
-
createCommonBindings(bind);
|
|
108
|
-
|
|
109
|
-
bindContributionProvider(bind, TerminalContribution);
|
|
110
|
-
|
|
111
|
-
// terminal link provider contribution point
|
|
112
|
-
bindContributionProvider(bind, TerminalLinkProvider);
|
|
113
|
-
bind(TerminalLinkProviderContribution).toSelf().inSingletonScope();
|
|
114
|
-
bind(TerminalContribution).toService(TerminalLinkProviderContribution);
|
|
115
|
-
bind(XtermLinkFactory).toFactory(createXtermLinkFactory);
|
|
116
|
-
|
|
117
|
-
// default terminal link provider
|
|
118
|
-
bind(UrlLinkProvider).toSelf().inSingletonScope();
|
|
119
|
-
bind(TerminalLinkProvider).toService(UrlLinkProvider);
|
|
120
|
-
bind(FileLinkProvider).toSelf().inSingletonScope();
|
|
121
|
-
bind(TerminalLinkProvider).toService(FileLinkProvider);
|
|
122
|
-
bind(FileDiffPreLinkProvider).toSelf().inSingletonScope();
|
|
123
|
-
bind(TerminalLinkProvider).toService(FileDiffPreLinkProvider);
|
|
124
|
-
bind(FileDiffPostLinkProvider).toSelf().inSingletonScope();
|
|
125
|
-
bind(TerminalLinkProvider).toService(FileDiffPostLinkProvider);
|
|
126
|
-
|
|
127
|
-
bind(ContributedTerminalProfileStore).to(DefaultProfileStore).inSingletonScope();
|
|
128
|
-
bind(UserTerminalProfileStore).to(DefaultProfileStore).inSingletonScope();
|
|
129
|
-
bind(TerminalProfileService).toDynamicValue(ctx => {
|
|
130
|
-
const userStore = ctx.container.get<TerminalProfileStore>(UserTerminalProfileStore);
|
|
131
|
-
const contributedStore = ctx.container.get<TerminalProfileStore>(ContributedTerminalProfileStore);
|
|
132
|
-
return new DefaultTerminalProfileService(userStore, contributedStore);
|
|
133
|
-
}).inSingletonScope();
|
|
134
|
-
|
|
135
|
-
bind(FrontendApplicationContribution).to(TerminalFrontendContribution);
|
|
136
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2017 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import '../../src/browser/style/terminal.css';
|
|
18
|
+
import 'xterm/css/xterm.css';
|
|
19
|
+
|
|
20
|
+
import { ContainerModule, Container } from '@theia/core/shared/inversify';
|
|
21
|
+
import { CommandContribution, MenuContribution, nls } from '@theia/core/lib/common';
|
|
22
|
+
import { bindContributionProvider } from '@theia/core';
|
|
23
|
+
import { KeybindingContribution, WebSocketConnectionProvider, WidgetFactory, FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
24
|
+
import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
25
|
+
import { TerminalFrontendContribution } from './terminal-frontend-contribution';
|
|
26
|
+
import { TerminalWidgetImpl, TERMINAL_WIDGET_FACTORY_ID } from './terminal-widget-impl';
|
|
27
|
+
import { TerminalWidget, TerminalWidgetOptions } from './base/terminal-widget';
|
|
28
|
+
import { ITerminalServer, terminalPath } from '../common/terminal-protocol';
|
|
29
|
+
import { TerminalWatcher } from '../common/terminal-watcher';
|
|
30
|
+
import { IShellTerminalServer, shellTerminalPath, ShellTerminalServerProxy } from '../common/shell-terminal-protocol';
|
|
31
|
+
import { createCommonBindings } from '../common/terminal-common-module';
|
|
32
|
+
import { TerminalService } from './base/terminal-service';
|
|
33
|
+
import { bindTerminalPreferences } from './terminal-preferences';
|
|
34
|
+
import { TerminalContribution } from './terminal-contribution';
|
|
35
|
+
import { TerminalSearchWidgetFactory } from './search/terminal-search-widget';
|
|
36
|
+
import { TerminalQuickOpenService, TerminalQuickOpenContribution } from './terminal-quick-open-service';
|
|
37
|
+
import { createTerminalSearchFactory } from './search/terminal-search-container';
|
|
38
|
+
import { TerminalCopyOnSelectionHandler } from './terminal-copy-on-selection-handler';
|
|
39
|
+
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
|
|
40
|
+
import { TerminalThemeService } from './terminal-theme-service';
|
|
41
|
+
import { QuickAccessContribution } from '@theia/core/lib/browser/quick-input/quick-access';
|
|
42
|
+
import { createXtermLinkFactory, TerminalLinkProvider, TerminalLinkProviderContribution, XtermLinkFactory } from './terminal-link-provider';
|
|
43
|
+
import { UrlLinkProvider } from './terminal-url-link-provider';
|
|
44
|
+
import { FileDiffPostLinkProvider, FileDiffPreLinkProvider, FileLinkProvider } from './terminal-file-link-provider';
|
|
45
|
+
import {
|
|
46
|
+
ContributedTerminalProfileStore, DefaultProfileStore, DefaultTerminalProfileService,
|
|
47
|
+
TerminalProfileService, TerminalProfileStore, UserTerminalProfileStore
|
|
48
|
+
} from './terminal-profile-service';
|
|
49
|
+
|
|
50
|
+
export default new ContainerModule(bind => {
|
|
51
|
+
bindTerminalPreferences(bind);
|
|
52
|
+
|
|
53
|
+
bind(TerminalWidget).to(TerminalWidgetImpl).inTransientScope();
|
|
54
|
+
bind(TerminalWatcher).toSelf().inSingletonScope();
|
|
55
|
+
|
|
56
|
+
let terminalNum = 0;
|
|
57
|
+
bind(WidgetFactory).toDynamicValue(ctx => ({
|
|
58
|
+
id: TERMINAL_WIDGET_FACTORY_ID,
|
|
59
|
+
createWidget: (options: TerminalWidgetOptions) => {
|
|
60
|
+
const child = new Container({ defaultScope: 'Singleton' });
|
|
61
|
+
child.parent = ctx.container;
|
|
62
|
+
const counter = terminalNum++;
|
|
63
|
+
const domId = options.id || 'terminal-' + counter;
|
|
64
|
+
const widgetOptions: TerminalWidgetOptions = {
|
|
65
|
+
title: `${nls.localizeByDefault('Terminal')} ${counter}`,
|
|
66
|
+
useServerTitle: true,
|
|
67
|
+
destroyTermOnClose: true,
|
|
68
|
+
...options
|
|
69
|
+
};
|
|
70
|
+
child.bind(TerminalWidgetOptions).toConstantValue(widgetOptions);
|
|
71
|
+
child.bind('terminal-dom-id').toConstantValue(domId);
|
|
72
|
+
|
|
73
|
+
child.bind(TerminalSearchWidgetFactory).toDynamicValue(context => createTerminalSearchFactory(context.container));
|
|
74
|
+
|
|
75
|
+
return child.get(TerminalWidget);
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
|
|
79
|
+
bind(TerminalQuickOpenService).toSelf().inSingletonScope();
|
|
80
|
+
bind(TerminalCopyOnSelectionHandler).toSelf().inSingletonScope();
|
|
81
|
+
|
|
82
|
+
bind(TerminalQuickOpenContribution).toSelf().inSingletonScope();
|
|
83
|
+
for (const identifier of [CommandContribution, QuickAccessContribution]) {
|
|
84
|
+
bind(identifier).toService(TerminalQuickOpenContribution);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
bind(TerminalThemeService).toSelf().inSingletonScope();
|
|
88
|
+
bind(TerminalFrontendContribution).toSelf().inSingletonScope();
|
|
89
|
+
bind(TerminalService).toService(TerminalFrontendContribution);
|
|
90
|
+
for (const identifier of [CommandContribution, MenuContribution, KeybindingContribution, TabBarToolbarContribution, ColorContribution]) {
|
|
91
|
+
bind(identifier).toService(TerminalFrontendContribution);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
bind(ITerminalServer).toDynamicValue(ctx => {
|
|
95
|
+
const connection = ctx.container.get(WebSocketConnectionProvider);
|
|
96
|
+
const terminalWatcher = ctx.container.get(TerminalWatcher);
|
|
97
|
+
return connection.createProxy<ITerminalServer>(terminalPath, terminalWatcher.getTerminalClient());
|
|
98
|
+
}).inSingletonScope();
|
|
99
|
+
|
|
100
|
+
bind(ShellTerminalServerProxy).toDynamicValue(ctx => {
|
|
101
|
+
const connection = ctx.container.get(WebSocketConnectionProvider);
|
|
102
|
+
const terminalWatcher = ctx.container.get(TerminalWatcher);
|
|
103
|
+
return connection.createProxy<IShellTerminalServer>(shellTerminalPath, terminalWatcher.getTerminalClient());
|
|
104
|
+
}).inSingletonScope();
|
|
105
|
+
bind(IShellTerminalServer).toService(ShellTerminalServerProxy);
|
|
106
|
+
|
|
107
|
+
createCommonBindings(bind);
|
|
108
|
+
|
|
109
|
+
bindContributionProvider(bind, TerminalContribution);
|
|
110
|
+
|
|
111
|
+
// terminal link provider contribution point
|
|
112
|
+
bindContributionProvider(bind, TerminalLinkProvider);
|
|
113
|
+
bind(TerminalLinkProviderContribution).toSelf().inSingletonScope();
|
|
114
|
+
bind(TerminalContribution).toService(TerminalLinkProviderContribution);
|
|
115
|
+
bind(XtermLinkFactory).toFactory(createXtermLinkFactory);
|
|
116
|
+
|
|
117
|
+
// default terminal link provider
|
|
118
|
+
bind(UrlLinkProvider).toSelf().inSingletonScope();
|
|
119
|
+
bind(TerminalLinkProvider).toService(UrlLinkProvider);
|
|
120
|
+
bind(FileLinkProvider).toSelf().inSingletonScope();
|
|
121
|
+
bind(TerminalLinkProvider).toService(FileLinkProvider);
|
|
122
|
+
bind(FileDiffPreLinkProvider).toSelf().inSingletonScope();
|
|
123
|
+
bind(TerminalLinkProvider).toService(FileDiffPreLinkProvider);
|
|
124
|
+
bind(FileDiffPostLinkProvider).toSelf().inSingletonScope();
|
|
125
|
+
bind(TerminalLinkProvider).toService(FileDiffPostLinkProvider);
|
|
126
|
+
|
|
127
|
+
bind(ContributedTerminalProfileStore).to(DefaultProfileStore).inSingletonScope();
|
|
128
|
+
bind(UserTerminalProfileStore).to(DefaultProfileStore).inSingletonScope();
|
|
129
|
+
bind(TerminalProfileService).toDynamicValue(ctx => {
|
|
130
|
+
const userStore = ctx.container.get<TerminalProfileStore>(UserTerminalProfileStore);
|
|
131
|
+
const contributedStore = ctx.container.get<TerminalProfileStore>(ContributedTerminalProfileStore);
|
|
132
|
+
return new DefaultTerminalProfileService(userStore, contributedStore);
|
|
133
|
+
}).inSingletonScope();
|
|
134
|
+
|
|
135
|
+
bind(FrontendApplicationContribution).to(TerminalFrontendContribution);
|
|
136
|
+
});
|
|
@@ -1,187 +1,187 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2022 STMicroelectronics and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import type { IBufferRange, IBufferLine, IBuffer, Terminal } from 'xterm';
|
|
18
|
-
|
|
19
|
-
export const LinkContext = Symbol('LinkContext');
|
|
20
|
-
export interface LinkContext {
|
|
21
|
-
text: string;
|
|
22
|
-
startLine: number;
|
|
23
|
-
lines: IBufferLine[];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Mimics VS Code IRange
|
|
28
|
-
*/
|
|
29
|
-
interface TerminalRange {
|
|
30
|
-
readonly startLineNumber: number;
|
|
31
|
-
readonly startColumn: number;
|
|
32
|
-
readonly endLineNumber: number;
|
|
33
|
-
readonly endColumn: number;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/*---------------------------------------------------------------------------------------------
|
|
37
|
-
* Copyright (c) Microsoft Corporation and others. All rights reserved.
|
|
38
|
-
* Licensed under the MIT License.
|
|
39
|
-
*--------------------------------------------------------------------------------------------*/
|
|
40
|
-
export function getLinkContext(terminal: Terminal, line: number, maxLinkLength = 2000): LinkContext {
|
|
41
|
-
// The following method is based on VS Code's TerminalLinkDetectorAdapter._provideLinks()
|
|
42
|
-
// https://github.com/microsoft/vscode/blob/7888ff3a6b104e9e2e3d0f7890ca92dd0828215f/src/vs/workbench/contrib/terminal/browser/links/terminalLinkDetectorAdapter.ts#L51
|
|
43
|
-
let startLine = line - 1;
|
|
44
|
-
let endLine = startLine;
|
|
45
|
-
|
|
46
|
-
const lines: IBufferLine[] = [terminal.buffer.active.getLine(startLine)!];
|
|
47
|
-
|
|
48
|
-
// Cap the maximum context on either side of the line being provided, by taking the context
|
|
49
|
-
// around the line being provided for this ensures the line the pointer is on will have
|
|
50
|
-
// links provided.
|
|
51
|
-
const maxLineContext = Math.max(maxLinkLength / terminal.cols);
|
|
52
|
-
const minStartLine = Math.max(startLine - maxLineContext, 0);
|
|
53
|
-
const maxEndLine = Math.min(endLine + maxLineContext, terminal.buffer.active.length);
|
|
54
|
-
|
|
55
|
-
while (startLine >= minStartLine && terminal.buffer.active.getLine(startLine)?.isWrapped) {
|
|
56
|
-
lines.unshift(terminal.buffer.active.getLine(startLine - 1)!);
|
|
57
|
-
startLine--;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
while (endLine < maxEndLine && terminal.buffer.active.getLine(endLine + 1)?.isWrapped) {
|
|
61
|
-
lines.push(terminal.buffer.active.getLine(endLine + 1)!);
|
|
62
|
-
endLine++;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const text = getXtermLineContent(terminal.buffer.active, startLine, endLine, terminal.cols);
|
|
66
|
-
|
|
67
|
-
return { text, startLine, lines };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// The following code is taken as is from
|
|
71
|
-
// https://github.com/microsoft/vscode/blob/7888ff3a6b104e9e2e3d0f7890ca92dd0828215f/src/vs/workbench/contrib/terminal/browser/links/terminalLinkHelpers.ts#L1
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Converts a possibly wrapped link's range (comprised of string indices) into a buffer range that plays nicely with xterm.js
|
|
75
|
-
*
|
|
76
|
-
* @param lines A single line (not the entire buffer)
|
|
77
|
-
* @param bufferWidth The number of columns in the terminal
|
|
78
|
-
* @param range The link range - string indices
|
|
79
|
-
* @param startLine The absolute y position (on the buffer) of the line
|
|
80
|
-
*/
|
|
81
|
-
export function convertLinkRangeToBuffer(
|
|
82
|
-
lines: IBufferLine[],
|
|
83
|
-
bufferWidth: number,
|
|
84
|
-
range: TerminalRange,
|
|
85
|
-
startLine: number
|
|
86
|
-
): IBufferRange {
|
|
87
|
-
const bufferRange: IBufferRange = {
|
|
88
|
-
start: {
|
|
89
|
-
x: range.startColumn,
|
|
90
|
-
y: range.startLineNumber + startLine
|
|
91
|
-
},
|
|
92
|
-
end: {
|
|
93
|
-
x: range.endColumn - 1,
|
|
94
|
-
y: range.endLineNumber + startLine
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
// Shift start range right for each wide character before the link
|
|
99
|
-
let startOffset = 0;
|
|
100
|
-
const startWrappedLineCount = Math.ceil(range.startColumn / bufferWidth);
|
|
101
|
-
for (let y = 0; y < Math.min(startWrappedLineCount); y++) {
|
|
102
|
-
const lineLength = Math.min(bufferWidth, range.startColumn - y * bufferWidth);
|
|
103
|
-
let lineOffset = 0;
|
|
104
|
-
const line = lines[y];
|
|
105
|
-
// Sanity check for line, apparently this can happen but it's not clear under what
|
|
106
|
-
// circumstances this happens. Continue on, skipping the remainder of start offset if this
|
|
107
|
-
// happens to minimize impact.
|
|
108
|
-
if (!line) {
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
for (let x = 0; x < Math.min(bufferWidth, lineLength + lineOffset); x++) {
|
|
112
|
-
const cell = line.getCell(x)!;
|
|
113
|
-
const width = cell.getWidth();
|
|
114
|
-
if (width === 2) {
|
|
115
|
-
lineOffset++;
|
|
116
|
-
}
|
|
117
|
-
const char = cell.getChars();
|
|
118
|
-
if (char.length > 1) {
|
|
119
|
-
lineOffset -= char.length - 1;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
startOffset += lineOffset;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Shift end range right for each wide character inside the link
|
|
126
|
-
let endOffset = 0;
|
|
127
|
-
const endWrappedLineCount = Math.ceil(range.endColumn / bufferWidth);
|
|
128
|
-
for (let y = Math.max(0, startWrappedLineCount - 1); y < endWrappedLineCount; y++) {
|
|
129
|
-
const start = (y === startWrappedLineCount - 1 ? (range.startColumn + startOffset) % bufferWidth : 0);
|
|
130
|
-
const lineLength = Math.min(bufferWidth, range.endColumn + startOffset - y * bufferWidth);
|
|
131
|
-
const startLineOffset = (y === startWrappedLineCount - 1 ? startOffset : 0);
|
|
132
|
-
let lineOffset = 0;
|
|
133
|
-
const line = lines[y];
|
|
134
|
-
// Sanity check for line, apparently this can happen but it's not clear under what
|
|
135
|
-
// circumstances this happens. Continue on, skipping the remainder of start offset if this
|
|
136
|
-
// happens to minimize impact.
|
|
137
|
-
if (!line) {
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
for (let x = start; x < Math.min(bufferWidth, lineLength + lineOffset + startLineOffset); x++) {
|
|
141
|
-
const cell = line.getCell(x)!;
|
|
142
|
-
const width = cell.getWidth();
|
|
143
|
-
// Offset for 0 cells following wide characters
|
|
144
|
-
if (width === 2) {
|
|
145
|
-
lineOffset++;
|
|
146
|
-
}
|
|
147
|
-
// Offset for early wrapping when the last cell in row is a wide character
|
|
148
|
-
if (x === bufferWidth - 1 && cell.getChars() === '') {
|
|
149
|
-
lineOffset++;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
endOffset += lineOffset;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Apply the width character offsets to the result
|
|
156
|
-
bufferRange.start.x += startOffset;
|
|
157
|
-
bufferRange.end.x += startOffset + endOffset;
|
|
158
|
-
|
|
159
|
-
// Convert back to wrapped lines
|
|
160
|
-
while (bufferRange.start.x > bufferWidth) {
|
|
161
|
-
bufferRange.start.x -= bufferWidth;
|
|
162
|
-
bufferRange.start.y++;
|
|
163
|
-
}
|
|
164
|
-
while (bufferRange.end.x > bufferWidth) {
|
|
165
|
-
bufferRange.end.x -= bufferWidth;
|
|
166
|
-
bufferRange.end.y++;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return bufferRange;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function getXtermLineContent(buffer: IBuffer, lineStart: number, lineEnd: number, cols: number): string {
|
|
173
|
-
// Cap the maximum number of lines generated to prevent potential performance problems. This is
|
|
174
|
-
// more of a sanity check as the wrapped line should already be trimmed down at this point.
|
|
175
|
-
const maxLineLength = Math.max(2048 / cols * 2);
|
|
176
|
-
lineEnd = Math.min(lineEnd, lineStart + maxLineLength);
|
|
177
|
-
let content = '';
|
|
178
|
-
for (let i = lineStart; i <= lineEnd; i++) {
|
|
179
|
-
// Make sure only 0 to cols are considered as resizing when windows mode is enabled will
|
|
180
|
-
// retain buffer data outside of the terminal width as reflow is disabled.
|
|
181
|
-
const line = buffer.getLine(i);
|
|
182
|
-
if (line) {
|
|
183
|
-
content += line.translateToString(true, 0, cols);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return content;
|
|
187
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2022 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import type { IBufferRange, IBufferLine, IBuffer, Terminal } from 'xterm';
|
|
18
|
+
|
|
19
|
+
export const LinkContext = Symbol('LinkContext');
|
|
20
|
+
export interface LinkContext {
|
|
21
|
+
text: string;
|
|
22
|
+
startLine: number;
|
|
23
|
+
lines: IBufferLine[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Mimics VS Code IRange
|
|
28
|
+
*/
|
|
29
|
+
interface TerminalRange {
|
|
30
|
+
readonly startLineNumber: number;
|
|
31
|
+
readonly startColumn: number;
|
|
32
|
+
readonly endLineNumber: number;
|
|
33
|
+
readonly endColumn: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/*---------------------------------------------------------------------------------------------
|
|
37
|
+
* Copyright (c) Microsoft Corporation and others. All rights reserved.
|
|
38
|
+
* Licensed under the MIT License.
|
|
39
|
+
*--------------------------------------------------------------------------------------------*/
|
|
40
|
+
export function getLinkContext(terminal: Terminal, line: number, maxLinkLength = 2000): LinkContext {
|
|
41
|
+
// The following method is based on VS Code's TerminalLinkDetectorAdapter._provideLinks()
|
|
42
|
+
// https://github.com/microsoft/vscode/blob/7888ff3a6b104e9e2e3d0f7890ca92dd0828215f/src/vs/workbench/contrib/terminal/browser/links/terminalLinkDetectorAdapter.ts#L51
|
|
43
|
+
let startLine = line - 1;
|
|
44
|
+
let endLine = startLine;
|
|
45
|
+
|
|
46
|
+
const lines: IBufferLine[] = [terminal.buffer.active.getLine(startLine)!];
|
|
47
|
+
|
|
48
|
+
// Cap the maximum context on either side of the line being provided, by taking the context
|
|
49
|
+
// around the line being provided for this ensures the line the pointer is on will have
|
|
50
|
+
// links provided.
|
|
51
|
+
const maxLineContext = Math.max(maxLinkLength / terminal.cols);
|
|
52
|
+
const minStartLine = Math.max(startLine - maxLineContext, 0);
|
|
53
|
+
const maxEndLine = Math.min(endLine + maxLineContext, terminal.buffer.active.length);
|
|
54
|
+
|
|
55
|
+
while (startLine >= minStartLine && terminal.buffer.active.getLine(startLine)?.isWrapped) {
|
|
56
|
+
lines.unshift(terminal.buffer.active.getLine(startLine - 1)!);
|
|
57
|
+
startLine--;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
while (endLine < maxEndLine && terminal.buffer.active.getLine(endLine + 1)?.isWrapped) {
|
|
61
|
+
lines.push(terminal.buffer.active.getLine(endLine + 1)!);
|
|
62
|
+
endLine++;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const text = getXtermLineContent(terminal.buffer.active, startLine, endLine, terminal.cols);
|
|
66
|
+
|
|
67
|
+
return { text, startLine, lines };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// The following code is taken as is from
|
|
71
|
+
// https://github.com/microsoft/vscode/blob/7888ff3a6b104e9e2e3d0f7890ca92dd0828215f/src/vs/workbench/contrib/terminal/browser/links/terminalLinkHelpers.ts#L1
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Converts a possibly wrapped link's range (comprised of string indices) into a buffer range that plays nicely with xterm.js
|
|
75
|
+
*
|
|
76
|
+
* @param lines A single line (not the entire buffer)
|
|
77
|
+
* @param bufferWidth The number of columns in the terminal
|
|
78
|
+
* @param range The link range - string indices
|
|
79
|
+
* @param startLine The absolute y position (on the buffer) of the line
|
|
80
|
+
*/
|
|
81
|
+
export function convertLinkRangeToBuffer(
|
|
82
|
+
lines: IBufferLine[],
|
|
83
|
+
bufferWidth: number,
|
|
84
|
+
range: TerminalRange,
|
|
85
|
+
startLine: number
|
|
86
|
+
): IBufferRange {
|
|
87
|
+
const bufferRange: IBufferRange = {
|
|
88
|
+
start: {
|
|
89
|
+
x: range.startColumn,
|
|
90
|
+
y: range.startLineNumber + startLine
|
|
91
|
+
},
|
|
92
|
+
end: {
|
|
93
|
+
x: range.endColumn - 1,
|
|
94
|
+
y: range.endLineNumber + startLine
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// Shift start range right for each wide character before the link
|
|
99
|
+
let startOffset = 0;
|
|
100
|
+
const startWrappedLineCount = Math.ceil(range.startColumn / bufferWidth);
|
|
101
|
+
for (let y = 0; y < Math.min(startWrappedLineCount); y++) {
|
|
102
|
+
const lineLength = Math.min(bufferWidth, range.startColumn - y * bufferWidth);
|
|
103
|
+
let lineOffset = 0;
|
|
104
|
+
const line = lines[y];
|
|
105
|
+
// Sanity check for line, apparently this can happen but it's not clear under what
|
|
106
|
+
// circumstances this happens. Continue on, skipping the remainder of start offset if this
|
|
107
|
+
// happens to minimize impact.
|
|
108
|
+
if (!line) {
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
for (let x = 0; x < Math.min(bufferWidth, lineLength + lineOffset); x++) {
|
|
112
|
+
const cell = line.getCell(x)!;
|
|
113
|
+
const width = cell.getWidth();
|
|
114
|
+
if (width === 2) {
|
|
115
|
+
lineOffset++;
|
|
116
|
+
}
|
|
117
|
+
const char = cell.getChars();
|
|
118
|
+
if (char.length > 1) {
|
|
119
|
+
lineOffset -= char.length - 1;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
startOffset += lineOffset;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Shift end range right for each wide character inside the link
|
|
126
|
+
let endOffset = 0;
|
|
127
|
+
const endWrappedLineCount = Math.ceil(range.endColumn / bufferWidth);
|
|
128
|
+
for (let y = Math.max(0, startWrappedLineCount - 1); y < endWrappedLineCount; y++) {
|
|
129
|
+
const start = (y === startWrappedLineCount - 1 ? (range.startColumn + startOffset) % bufferWidth : 0);
|
|
130
|
+
const lineLength = Math.min(bufferWidth, range.endColumn + startOffset - y * bufferWidth);
|
|
131
|
+
const startLineOffset = (y === startWrappedLineCount - 1 ? startOffset : 0);
|
|
132
|
+
let lineOffset = 0;
|
|
133
|
+
const line = lines[y];
|
|
134
|
+
// Sanity check for line, apparently this can happen but it's not clear under what
|
|
135
|
+
// circumstances this happens. Continue on, skipping the remainder of start offset if this
|
|
136
|
+
// happens to minimize impact.
|
|
137
|
+
if (!line) {
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
for (let x = start; x < Math.min(bufferWidth, lineLength + lineOffset + startLineOffset); x++) {
|
|
141
|
+
const cell = line.getCell(x)!;
|
|
142
|
+
const width = cell.getWidth();
|
|
143
|
+
// Offset for 0 cells following wide characters
|
|
144
|
+
if (width === 2) {
|
|
145
|
+
lineOffset++;
|
|
146
|
+
}
|
|
147
|
+
// Offset for early wrapping when the last cell in row is a wide character
|
|
148
|
+
if (x === bufferWidth - 1 && cell.getChars() === '') {
|
|
149
|
+
lineOffset++;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
endOffset += lineOffset;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Apply the width character offsets to the result
|
|
156
|
+
bufferRange.start.x += startOffset;
|
|
157
|
+
bufferRange.end.x += startOffset + endOffset;
|
|
158
|
+
|
|
159
|
+
// Convert back to wrapped lines
|
|
160
|
+
while (bufferRange.start.x > bufferWidth) {
|
|
161
|
+
bufferRange.start.x -= bufferWidth;
|
|
162
|
+
bufferRange.start.y++;
|
|
163
|
+
}
|
|
164
|
+
while (bufferRange.end.x > bufferWidth) {
|
|
165
|
+
bufferRange.end.x -= bufferWidth;
|
|
166
|
+
bufferRange.end.y++;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return bufferRange;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function getXtermLineContent(buffer: IBuffer, lineStart: number, lineEnd: number, cols: number): string {
|
|
173
|
+
// Cap the maximum number of lines generated to prevent potential performance problems. This is
|
|
174
|
+
// more of a sanity check as the wrapped line should already be trimmed down at this point.
|
|
175
|
+
const maxLineLength = Math.max(2048 / cols * 2);
|
|
176
|
+
lineEnd = Math.min(lineEnd, lineStart + maxLineLength);
|
|
177
|
+
let content = '';
|
|
178
|
+
for (let i = lineStart; i <= lineEnd; i++) {
|
|
179
|
+
// Make sure only 0 to cols are considered as resizing when windows mode is enabled will
|
|
180
|
+
// retain buffer data outside of the terminal width as reflow is disabled.
|
|
181
|
+
const line = buffer.getLine(i);
|
|
182
|
+
if (line) {
|
|
183
|
+
content += line.translateToString(true, 0, cols);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return content;
|
|
187
|
+
}
|