Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal image support #182442

Merged
merged 5 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
"worker_threads",
"xterm",
"xterm-addon-canvas",
"xterm-addon-image",
"xterm-addon-search",
"xterm-addon-serialize",
"xterm-addon-unicode11",
Expand Down
3 changes: 3 additions & 0 deletions build/.webignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ xterm/src/**
xterm-addon-canvas/src/**
xterm-addon-canvas/out/**

xterm-addon-image/src/**
xterm-addon-image/out/**

xterm-addon-search/src/**
xterm-addon-search/out/**
xterm-addon-search/fixtures/**
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@
"vscode-oniguruma": "1.7.0",
"vscode-regexpp": "^3.1.0",
"vscode-textmate": "9.0.0",
"xterm": "5.2.0-beta.40",
"xterm": "5.2.0-beta.41",
"xterm-addon-canvas": "0.4.0-beta.11",
"xterm-addon-image": "0.4.0",
"xterm-addon-search": "0.11.0",
"xterm-addon-serialize": "0.9.0",
"xterm-addon-unicode11": "0.5.0",
"xterm-addon-webgl": "0.15.0-beta.10",
"xterm-headless": "5.2.0-beta.40",
"xterm-headless": "5.2.0-beta.41",
"yauzl": "^2.9.2",
"yazl": "^2.4.3"
},
Expand Down
5 changes: 3 additions & 2 deletions remote/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
"vscode-oniguruma": "1.7.0",
"vscode-regexpp": "^3.1.0",
"vscode-textmate": "9.0.0",
"xterm": "5.2.0-beta.40",
"xterm": "5.2.0-beta.41",
"xterm-addon-canvas": "0.4.0-beta.11",
"xterm-addon-image": "0.4.0",
"xterm-addon-search": "0.11.0",
"xterm-addon-serialize": "0.9.0",
"xterm-addon-unicode11": "0.5.0",
"xterm-addon-webgl": "0.15.0-beta.10",
"xterm-headless": "5.2.0-beta.40",
"xterm-headless": "5.2.0-beta.41",
"yauzl": "^2.9.2",
"yazl": "^2.4.3"
},
Expand Down
3 changes: 2 additions & 1 deletion remote/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
"tas-client-umd": "0.1.8",
"vscode-oniguruma": "1.7.0",
"vscode-textmate": "9.0.0",
"xterm": "5.2.0-beta.40",
"xterm": "5.2.0-beta.41",
"xterm-addon-canvas": "0.4.0-beta.11",
"xterm-addon-image": "0.4.0",
"xterm-addon-search": "0.11.0",
"xterm-addon-unicode11": "0.5.0",
"xterm-addon-webgl": "0.15.0-beta.10"
Expand Down
13 changes: 9 additions & 4 deletions remote/web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/xterm-addon-canvas/-/xterm-addon-canvas-0.4.0-beta.11.tgz#d627050d7e2290ae804c0ec730d5bfc5861afd78"
integrity sha512-yfkx0R7wB3L+fWf1doDmEfwYIeNMVq4uXlq7sCvfPQAVA2H4eOH/s+SS1mhyy0A6DDEbM4eEQ7CroRZIsnVtMA==

[email protected]:
version "0.4.0"
resolved "https://registry.yarnpkg.com/xterm-addon-image/-/xterm-addon-image-0.4.0.tgz#36e98fa892db11755a5f6e9654f924e876e29bf8"
integrity sha512-3wumCJo4WTzxvecSMxJ7XtpVQeFe4gE2cdHCyUdo7zagVkS18YXJacGx6DjlAIccdJn6/LhGuD99xOSSvYx9Gw==

[email protected]:
version "0.11.0"
resolved "https://registry.yarnpkg.com/xterm-addon-search/-/xterm-addon-search-0.11.0.tgz#2a00ff7f9848f6140e7c4d1782486b0b18b06e0d"
Expand All @@ -88,7 +93,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.15.0-beta.10.tgz#39ebbfb1b89c6773a2d8cb8e1d2f3ef1f08b28f9"
integrity sha512-JVv4t5q6QGWyLiEAcAk9H2B83hFlIalzEwWu1VVYso0MJyZAlZ0NP5Za03iSKxYi7RQIA5bOe8r7W24esQDjLg==

[email protected].40:
version "5.2.0-beta.40"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-5.2.0-beta.40.tgz#c73d5576425dcd4fa6b48ce58b4224a7b5b9dbdf"
integrity sha512-7/Db3KPceM0VX4/YAKL+/ArvEHlGBwE3kt1oN9QP5TLaJ6r2ThMS7z7QwG8g2gy60GFnvjfvpcTv6Ewyste4zg==
[email protected].41:
version "5.2.0-beta.41"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-5.2.0-beta.41.tgz#ff9f5ed8890a751db2263ebdd362f5443699026d"
integrity sha512-yvDMaeELF8YuqTv220/+i5MKvy9GB4Vu7tH1T3OIqPvHwgnC8SY1vOSjskxHsHsRE5qLluiQJo6/wvt3kZH8+A==
21 changes: 13 additions & 8 deletions remote/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/xterm-addon-canvas/-/xterm-addon-canvas-0.4.0-beta.11.tgz#d627050d7e2290ae804c0ec730d5bfc5861afd78"
integrity sha512-yfkx0R7wB3L+fWf1doDmEfwYIeNMVq4uXlq7sCvfPQAVA2H4eOH/s+SS1mhyy0A6DDEbM4eEQ7CroRZIsnVtMA==

[email protected]:
version "0.4.0"
resolved "https://registry.yarnpkg.com/xterm-addon-image/-/xterm-addon-image-0.4.0.tgz#36e98fa892db11755a5f6e9654f924e876e29bf8"
integrity sha512-3wumCJo4WTzxvecSMxJ7XtpVQeFe4gE2cdHCyUdo7zagVkS18YXJacGx6DjlAIccdJn6/LhGuD99xOSSvYx9Gw==

[email protected]:
version "0.11.0"
resolved "https://registry.yarnpkg.com/xterm-addon-search/-/xterm-addon-search-0.11.0.tgz#2a00ff7f9848f6140e7c4d1782486b0b18b06e0d"
Expand All @@ -861,15 +866,15 @@ [email protected]:
resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.15.0-beta.10.tgz#39ebbfb1b89c6773a2d8cb8e1d2f3ef1f08b28f9"
integrity sha512-JVv4t5q6QGWyLiEAcAk9H2B83hFlIalzEwWu1VVYso0MJyZAlZ0NP5Za03iSKxYi7RQIA5bOe8r7W24esQDjLg==

[email protected].40:
version "5.2.0-beta.40"
resolved "https://registry.yarnpkg.com/xterm-headless/-/xterm-headless-5.2.0-beta.40.tgz#6edba318d23ed350c8ec6279e6f61f40bde9b163"
integrity sha512-6CHgR64POfa24CTILcq/HHg1im1u1HjJZSHWjlopP18KiS8Rq8dzCurZDsu38atxDK9dyjV8SRw2AB4ijcxZsQ==
[email protected].41:
version "5.2.0-beta.41"
resolved "https://registry.yarnpkg.com/xterm-headless/-/xterm-headless-5.2.0-beta.41.tgz#17085c0ef255214c244bdaa73e5914fd722be28e"
integrity sha512-cAKuiYPs2GQpCWFIWHakRF+57vPDmqLzMFX3kOcMj+deHPuDnxucQTZvjxKNbMZKG9u9r+shIyfGzgC0oA+bBw==

[email protected].40:
version "5.2.0-beta.40"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-5.2.0-beta.40.tgz#c73d5576425dcd4fa6b48ce58b4224a7b5b9dbdf"
integrity sha512-7/Db3KPceM0VX4/YAKL+/ArvEHlGBwE3kt1oN9QP5TLaJ6r2ThMS7z7QwG8g2gy60GFnvjfvpcTv6Ewyste4zg==
[email protected].41:
version "5.2.0-beta.41"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-5.2.0-beta.41.tgz#ff9f5ed8890a751db2263ebdd362f5443699026d"
integrity sha512-yvDMaeELF8YuqTv220/+i5MKvy9GB4Vu7tH1T3OIqPvHwgnC8SY1vOSjskxHsHsRE5qLluiQJo6/wvt3kZH8+A==

yallist@^4.0.0:
version "4.0.0"
Expand Down
1 change: 1 addition & 0 deletions scripts/update-xterm.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const path = require('path');
const moduleNames = [
'xterm',
'xterm-addon-canvas',
'xterm-addon-image',
'xterm-addon-search',
'xterm-addon-unicode11',
'xterm-addon-webgl'
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
'vscode-oniguruma': `${baseNodeModulesPath}/vscode-oniguruma/release/main.js`,
'xterm': `${baseNodeModulesPath}/xterm/lib/xterm.js`,
'xterm-addon-canvas': `${baseNodeModulesPath}/xterm-addon-canvas/lib/xterm-addon-canvas.js`,
'xterm-addon-image': `${baseNodeModulesPath}/xterm-addon-image/lib/xterm-addon-image.js`,
'xterm-addon-search': `${baseNodeModulesPath}/xterm-addon-search/lib/xterm-addon-search.js`,
'xterm-addon-unicode11': `${baseNodeModulesPath}/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`,
'xterm-addon-webgl': `${baseNodeModulesPath}/xterm-addon-webgl/lib/xterm-addon-webgl.js`,
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const enum TerminalSettingId {
ShellIntegrationDecorationsEnabled = 'terminal.integrated.shellIntegration.decorationsEnabled',
ShellIntegrationCommandHistory = 'terminal.integrated.shellIntegration.history',
ShellIntegrationSuggestEnabled = 'terminal.integrated.shellIntegration.suggestEnabled',
ExperimentalImageSupport = 'terminal.integrated.experimentalImageSupport',
SmoothScrolling = 'terminal.integrated.smoothScrolling'
}

Expand Down
29 changes: 29 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { ISearchOptions, SearchAddon as SearchAddonType } from 'xterm-addon
import type { Unicode11Addon as Unicode11AddonType } from 'xterm-addon-unicode11';
import type { WebglAddon as WebglAddonType } from 'xterm-addon-webgl';
import type { SerializeAddon as SerializeAddonType } from 'xterm-addon-serialize';
import type { ImageAddon as ImageAddonType } from 'xterm-addon-image';
import { IXtermCore } from 'vs/workbench/contrib/terminal/browser/xterm-private';
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminalConfigHelper';
Expand Down Expand Up @@ -47,6 +48,7 @@ const enum RenderConstants {
}

let CanvasAddon: typeof CanvasAddonType;
let ImageAddon: typeof ImageAddonType;
let SearchAddon: typeof SearchAddonType;
let SerializeAddon: typeof SerializeAddonType;
let Unicode11Addon: typeof Unicode11AddonType;
Expand Down Expand Up @@ -136,6 +138,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, II
private _unicode11Addon?: Unicode11AddonType;
private _webglAddon?: WebglAddonType;
private _serializeAddon?: SerializeAddonType;
private _imageAddon?: ImageAddonType;

private _lastFindResult: { resultIndex: number; resultCount: number } | undefined;
get findResult(): { resultIndex: number; resultCount: number } | undefined { return this._lastFindResult; }
Expand Down Expand Up @@ -243,6 +246,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, II

// Load addons
this._updateUnicodeVersion();
this._refreshImageAddon();
this._markNavigationAddon = this._instantiationService.createInstance(MarkNavigationAddon, _capabilities);
this.raw.loadAddon(this._markNavigationAddon);
this._decorationAddon = this._instantiationService.createInstance(DecorationAddon, this._capabilities);
Expand Down Expand Up @@ -332,6 +336,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, II
this._disposeOfCanvasRenderer();
}
}
this._refreshImageAddon();
}

private _shouldLoadWebgl(): boolean {
Expand Down Expand Up @@ -573,6 +578,30 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, II
return CanvasAddon;
}

private async _refreshImageAddon(): Promise<void> {
if (this._configHelper.config.experimentalImageSupport) {
if (!this._imageAddon) {
const AddonCtor = await this._getImageAddonConstructor();
this._imageAddon = new AddonCtor();
this.raw.loadAddon(this._imageAddon);
}
} else {
try {
this._imageAddon?.dispose();
} catch {
// ignore
}
this._imageAddon = undefined;
}
}

protected async _getImageAddonConstructor(): Promise<typeof ImageAddonType> {
if (!ImageAddon) {
ImageAddon = (await import('xterm-addon-image')).ImageAddon;
}
return ImageAddon;
}

protected async _getSearchAddonConstructor(): Promise<typeof SearchAddonType> {
if (!SearchAddon) {
SearchAddon = (await import('xterm-addon-search')).SearchAddon;
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ export interface ITerminalConfiguration {
enabled: boolean;
decorationsEnabled: boolean;
};
experimentalImageSupport: boolean;
smoothScrolling: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,14 @@ const terminalConfiguration: IConfigurationNode = {
markdownDescription: localize('terminal.integrated.smoothScrolling', "Controls whether the terminal will scroll using an animation."),
type: 'boolean',
default: false
}
},
[TerminalSettingId.ExperimentalImageSupport]: {
restricted: true,
markdownDescription: localize('terminal.integrated.experimentalImageSupport', "Enables experimental image support in the terminal. Both sixel and iTerm's inline image protocol are supported on Linux and macOS, Windows support will light up automatically when ConPTY passes through the sequences. Images will not be retained currently between window reloads/reconnects."),
type: 'boolean',
default: false,
tags: ['experimental']
},
}
};

Expand Down
21 changes: 13 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10513,6 +10513,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/xterm-addon-canvas/-/xterm-addon-canvas-0.4.0-beta.11.tgz#d627050d7e2290ae804c0ec730d5bfc5861afd78"
integrity sha512-yfkx0R7wB3L+fWf1doDmEfwYIeNMVq4uXlq7sCvfPQAVA2H4eOH/s+SS1mhyy0A6DDEbM4eEQ7CroRZIsnVtMA==

[email protected]:
version "0.4.0"
resolved "https://registry.yarnpkg.com/xterm-addon-image/-/xterm-addon-image-0.4.0.tgz#36e98fa892db11755a5f6e9654f924e876e29bf8"
integrity sha512-3wumCJo4WTzxvecSMxJ7XtpVQeFe4gE2cdHCyUdo7zagVkS18YXJacGx6DjlAIccdJn6/LhGuD99xOSSvYx9Gw==

[email protected]:
version "0.11.0"
resolved "https://registry.yarnpkg.com/xterm-addon-search/-/xterm-addon-search-0.11.0.tgz#2a00ff7f9848f6140e7c4d1782486b0b18b06e0d"
Expand All @@ -10533,15 +10538,15 @@ [email protected]:
resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.15.0-beta.10.tgz#39ebbfb1b89c6773a2d8cb8e1d2f3ef1f08b28f9"
integrity sha512-JVv4t5q6QGWyLiEAcAk9H2B83hFlIalzEwWu1VVYso0MJyZAlZ0NP5Za03iSKxYi7RQIA5bOe8r7W24esQDjLg==

[email protected].40:
version "5.2.0-beta.40"
resolved "https://registry.yarnpkg.com/xterm-headless/-/xterm-headless-5.2.0-beta.40.tgz#6edba318d23ed350c8ec6279e6f61f40bde9b163"
integrity sha512-6CHgR64POfa24CTILcq/HHg1im1u1HjJZSHWjlopP18KiS8Rq8dzCurZDsu38atxDK9dyjV8SRw2AB4ijcxZsQ==
[email protected].41:
version "5.2.0-beta.41"
resolved "https://registry.yarnpkg.com/xterm-headless/-/xterm-headless-5.2.0-beta.41.tgz#17085c0ef255214c244bdaa73e5914fd722be28e"
integrity sha512-cAKuiYPs2GQpCWFIWHakRF+57vPDmqLzMFX3kOcMj+deHPuDnxucQTZvjxKNbMZKG9u9r+shIyfGzgC0oA+bBw==

[email protected].40:
version "5.2.0-beta.40"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-5.2.0-beta.40.tgz#c73d5576425dcd4fa6b48ce58b4224a7b5b9dbdf"
integrity sha512-7/Db3KPceM0VX4/YAKL+/ArvEHlGBwE3kt1oN9QP5TLaJ6r2ThMS7z7QwG8g2gy60GFnvjfvpcTv6Ewyste4zg==
[email protected].41:
version "5.2.0-beta.41"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-5.2.0-beta.41.tgz#ff9f5ed8890a751db2263ebdd362f5443699026d"
integrity sha512-yvDMaeELF8YuqTv220/+i5MKvy9GB4Vu7tH1T3OIqPvHwgnC8SY1vOSjskxHsHsRE5qLluiQJo6/wvt3kZH8+A==

y18n@^3.2.1:
version "3.2.2"
Expand Down