Skip to content

Commit 9816568

Browse files
authored
feat: add scrolling support for altscreen (#30)
1 parent b1cc03e commit 9816568

3 files changed

Lines changed: 418 additions & 10 deletions

File tree

demo/index.html

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,24 @@
7575
background: #44ff44;
7676
}
7777

78+
.alt-screen-indicator {
79+
display: inline-block;
80+
padding: 4px 12px;
81+
margin-left: 15px;
82+
background: rgba(255, 255, 255, 0.15);
83+
border-radius: 4px;
84+
font-size: 0.85rem;
85+
font-weight: 500;
86+
opacity: 0;
87+
transition: opacity 0.3s ease;
88+
}
89+
90+
.alt-screen-indicator.active {
91+
opacity: 1;
92+
background: rgba(255, 200, 100, 0.25);
93+
color: #ffd700;
94+
}
95+
7896
@keyframes pulse {
7997
0%,
8098
100% {
@@ -269,6 +287,7 @@ <h1>🖥️ Ghostty Terminal</h1>
269287
<div class="status-indicator">
270288
<div class="status-dot" id="status-dot"></div>
271289
<span id="status-text">Connecting...</span>
290+
<span id="alt-screen-indicator" class="alt-screen-indicator">ALT SCREEN</span>
272291
</div>
273292
<div>
274293
<small id="ws-url" style="opacity: 0.7; margin-right: 15px"></small>
@@ -376,12 +395,14 @@ <h3>🔍 Buffer Access API (NEW!)</h3>
376395
// If it's a string (raw PTY output), write directly to terminal
377396
if (typeof data === 'string') {
378397
term.write(data);
398+
updateAltScreenIndicator();
379399
}
380400
// Otherwise try JSON parsing for file-browser-server compatibility
381401
else {
382402
try {
383403
const jsonData = JSON.parse(data);
384404
handleServerMessage(jsonData);
405+
updateAltScreenIndicator();
385406
} catch (error) {
386407
console.error('Failed to parse message:', error);
387408
}
@@ -475,6 +496,18 @@ <h3>🔍 Buffer Access API (NEW!)</h3>
475496
textEl.textContent = text;
476497
}
477498

499+
function updateAltScreenIndicator() {
500+
const indicator = document.getElementById('alt-screen-indicator');
501+
if (!term || !term.wasmTerm) return;
502+
503+
const isAltScreen = term.wasmTerm.isAlternateScreen();
504+
if (isAltScreen) {
505+
indicator.classList.add('active');
506+
} else {
507+
indicator.classList.remove('active');
508+
}
509+
}
510+
478511
function updateCwdDisplay(cwd) {
479512
const display = document.getElementById('cwd-display');
480513
// Shorten long paths

0 commit comments

Comments
 (0)