Skip to content

Commit 0d31c05

Browse files
committed
dynamic screen size
1 parent 89ee90e commit 0d31c05

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

index.html

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,28 @@
33
<head>
44
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/xterm@5.3.0/css/xterm.css" />
55
<script src="https://cdn.jsdelivr.net/npm/xterm@5.3.0/lib/xterm.js"></script>
6+
<script src="https://cdn.jsdelivr.net/npm/xterm-addon-fit@0.8.0/lib/xterm-addon-fit.js"></script>
67
</head>
7-
<body style="margin: 0; padding: 20px; background: #1e1e1e;">
8-
<div id="terminal"></div>
8+
<body style="margin: 0; padding: 20px; background: #1e1e1e; height: 100vh; box-sizing: border-box;">
9+
<div id="terminal" style="height: 100%;"></div>
910

1011
<script>
1112
// Create terminal with responsive font size
1213
const term = new Terminal({
1314
fontSize: window.innerWidth < 768 ? 14 : 16
1415
});
16+
17+
// Fit addon
18+
const fitAddon = new FitAddon.FitAddon();
19+
term.loadAddon(fitAddon);
20+
1521
term.open(document.getElementById('terminal'));
22+
fitAddon.fit();
23+
24+
// Handle window resize
25+
window.addEventListener('resize', () => {
26+
fitAddon.fit();
27+
});
1628

1729
// Create worker code inline
1830
const workerCode = `

0 commit comments

Comments
 (0)