Skip to content

Commit

Permalink
Add xterm/image-addon to web terminal (#48780)
Browse files Browse the repository at this point in the history
This allows the terminal in the web UI to "pretty print" images based on
the supported protocols (SIXEL and IIP)
  • Loading branch information
avatus authored Nov 12, 2024
1 parent 11472ee commit 10d8666
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion web/packages/teleport/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
"@opentelemetry/sdk-trace-base": "1.26.0",
"@opentelemetry/sdk-trace-web": "1.26.0",
"@opentelemetry/semantic-conventions": "1.27.0",
"@xterm/xterm": "^5.5.0",
"@xterm/addon-canvas": "^0.7.0",
"@xterm/addon-fit": "^0.10.0",
"@xterm/addon-image": "^0.8.0",
"@xterm/addon-web-links": "^0.11.0",
"@xterm/addon-webgl": "^0.18.0",
"@xterm/xterm": "^5.5.0",
"create-react-class": "^15.6.3",
"events": "3.3.0"
},
Expand Down
4 changes: 4 additions & 0 deletions web/packages/teleport/src/lib/term/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import '@xterm/xterm/css/xterm.css';
import { ITheme, Terminal } from '@xterm/xterm';
import { FitAddon } from '@xterm/addon-fit';
import { ImageAddon } from '@xterm/addon-image';
import { WebglAddon } from '@xterm/addon-webgl';
import { WebLinksAddon } from '@xterm/addon-web-links';
import { CanvasAddon } from '@xterm/addon-canvas';
Expand Down Expand Up @@ -50,6 +51,7 @@ export default class TtyTerminal {
_convertEol: boolean;
_debouncedResize: DebouncedFunc<() => void>;
_fitAddon = new FitAddon();
_imageAddon = new ImageAddon();
_webLinksAddon = new WebLinksAddon();
_webglAddon: WebglAddon;
_canvasAddon = new CanvasAddon();
Expand Down Expand Up @@ -88,6 +90,7 @@ export default class TtyTerminal {

this.term.loadAddon(this._fitAddon);
this.term.loadAddon(this._webLinksAddon);
this.term.loadAddon(this._imageAddon);
// handle context loss and load webgl addon
try {
// try to create a new WebglAddon. If webgl is not supported, this
Expand Down Expand Up @@ -155,6 +158,7 @@ export default class TtyTerminal {
this._disconnect();
this._debouncedResize.cancel();
this._fitAddon.dispose();
this._imageAddon.dispose();
this._webglAddon?.dispose();
this._canvasAddon?.dispose();
this._el.innerHTML = null;
Expand Down

0 comments on commit 10d8666

Please sign in to comment.