Skip to content

Commit 60457a6

Browse files
chapterjasonclaude
andcommitted
Fit xterm to container and load core addons
Adds fit, clipboard, progress, web-links, and ligatures addons; xterm now resizes with its container (via ResizeObserver) so it never overlaps the virtual keyboard. Proposed API enabled for ligatures. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 6c3641c commit 60457a6

3 files changed

Lines changed: 172 additions & 0 deletions

File tree

package-lock.json

Lines changed: 146 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
"fetch-v86": "node scripts/fetch-v86-assets.mjs"
1212
},
1313
"devDependencies": {
14+
"@xterm/addon-clipboard": "^0.2.0",
15+
"@xterm/addon-fit": "^0.11.0",
16+
"@xterm/addon-ligatures": "^0.10.0",
17+
"@xterm/addon-progress": "^0.2.0",
18+
"@xterm/addon-web-links": "^0.12.0",
1419
"@xterm/xterm": "^6.0.0",
1520
"sass": "^1.99.0",
1621
"typescript": "^6.0.3",

src/linux.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { Terminal } from "@xterm/xterm";
2+
import { FitAddon } from "@xterm/addon-fit";
3+
import { ClipboardAddon } from "@xterm/addon-clipboard";
4+
import { LigaturesAddon } from "@xterm/addon-ligatures";
5+
import { ProgressAddon } from "@xterm/addon-progress";
6+
import { WebLinksAddon } from "@xterm/addon-web-links";
27
import "@xterm/xterm/css/xterm.css";
38
// @ts-expect-error — v86 ships no types
49
import V86 from "v86";
@@ -21,6 +26,7 @@ const HOST = import.meta.env.BASE_URL + "v86/";
2126

2227
const term = new Terminal({
2328
cursorBlink: true,
29+
allowProposedApi: true,
2430
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
2531
fontSize: 14,
2632
theme: {
@@ -30,8 +36,23 @@ const term = new Terminal({
3036
},
3137
});
3238

39+
const fit = new FitAddon();
40+
term.loadAddon(fit);
41+
term.loadAddon(new ClipboardAddon());
42+
term.loadAddon(new ProgressAddon());
43+
term.loadAddon(new WebLinksAddon());
44+
3345
const host = document.getElementById("term")!;
3446
term.open(host);
47+
fit.fit();
48+
term.loadAddon(new LigaturesAddon());
49+
50+
const ro = new ResizeObserver(() => {
51+
try {
52+
fit.fit();
53+
} catch {}
54+
});
55+
ro.observe(host);
3556

3657
const status = document.getElementById("status")!;
3758
const setStatus = (text: string): void => {

0 commit comments

Comments
 (0)