Skip to content

Commit

Permalink
html: add xterm clipboard addon
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Nov 26, 2024
1 parent d0134c8 commit b1eaaee
Show file tree
Hide file tree
Showing 4 changed files with 14,134 additions and 13,944 deletions.
1 change: 1 addition & 0 deletions html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
},
"dependencies": {
"@xterm/addon-canvas": "^0.7.0",
"@xterm/addon-clipboard": "^0.1.0",
"@xterm/addon-fit": "^0.10.0",
"@xterm/addon-image": "^0.8.0",
"@xterm/addon-unicode11": "^0.8.0",
Expand Down
8 changes: 6 additions & 2 deletions html/src/components/terminal/xterm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { bind } from 'decko';
import type { IDisposable, ITerminalOptions } from '@xterm/xterm';
import { Terminal } from '@xterm/xterm';
import { CanvasAddon } from '@xterm/addon-canvas';
import { ClipboardAddon } from '@xterm/addon-clipboard';
import { WebglAddon } from '@xterm/addon-webgl';
import { FitAddon } from '@xterm/addon-fit';
import { WebLinksAddon } from '@xterm/addon-web-links';
Expand Down Expand Up @@ -84,6 +85,8 @@ export class Xterm {
private terminal: Terminal;
private fitAddon = new FitAddon();
private overlayAddon = new OverlayAddon();
private clipboardAddon = new ClipboardAddon();
private webLinksAddon = new WebLinksAddon();
private webglAddon?: WebglAddon;
private canvasAddon?: CanvasAddon;
private zmodemAddon?: ZmodemAddon;
Expand Down Expand Up @@ -149,15 +152,16 @@ export class Xterm {
@bind
public open(parent: HTMLElement) {
this.terminal = new Terminal(this.options.termOptions);
const { terminal, fitAddon, overlayAddon } = this;
const { terminal, fitAddon, overlayAddon, clipboardAddon, webLinksAddon } = this;
window.term = terminal as TtydTerminal;
window.term.fit = () => {
this.fitAddon.fit();
};

terminal.loadAddon(fitAddon);
terminal.loadAddon(overlayAddon);
terminal.loadAddon(new WebLinksAddon());
terminal.loadAddon(clipboardAddon);
terminal.loadAddon(webLinksAddon);

terminal.open(parent);
fitAddon.fit();
Expand Down
19 changes: 19 additions & 0 deletions html/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,17 @@ __metadata:
languageName: node
linkType: hard

"@xterm/addon-clipboard@npm:^0.1.0":
version: 0.1.0
resolution: "@xterm/addon-clipboard@npm:0.1.0"
dependencies:
js-base64: ^3.7.5
peerDependencies:
"@xterm/xterm": ^5.4.0
checksum: fe33d28223ae7f9965653c6c946a68e06f1d884fba1d11e8bcb52dcc608dbb2240caf48573d6297daefa56696e88f963148a1035ccf034cb6fb4f88f506a2ec7
languageName: node
linkType: hard

"@xterm/addon-fit@npm:^0.10.0":
version: 0.10.0
resolution: "@xterm/addon-fit@npm:0.10.0"
Expand Down Expand Up @@ -6431,6 +6442,13 @@ __metadata:
languageName: node
linkType: hard

"js-base64@npm:^3.7.5":
version: 3.7.7
resolution: "js-base64@npm:3.7.7"
checksum: d1b02971db9dc0fd35baecfaf6ba499731fb44fe3373e7e1d6681fbd3ba665f29e8d9d17910254ef8104e2cb8b44117fe4202d3dc54c7cafe9ba300fe5433358
languageName: node
linkType: hard

"js-tokens@npm:^4.0.0":
version: 4.0.0
resolution: "js-tokens@npm:4.0.0"
Expand Down Expand Up @@ -10475,6 +10493,7 @@ __metadata:
dependencies:
"@typescript-eslint/eslint-plugin": ^7.1.1
"@xterm/addon-canvas": ^0.7.0
"@xterm/addon-clipboard": ^0.1.0
"@xterm/addon-fit": ^0.10.0
"@xterm/addon-image": ^0.8.0
"@xterm/addon-unicode11": ^0.8.0
Expand Down
Loading

0 comments on commit b1eaaee

Please sign in to comment.