claude-opencode-viewer 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.html +27 -22
- package/package.json +1 -1
package/index.html
CHANGED
|
@@ -949,8 +949,6 @@
|
|
|
949
949
|
<div class="virtual-key" data-key="tab">Tab</div>
|
|
950
950
|
<div class="virtual-key" data-key="esc">Esc</div>
|
|
951
951
|
<div class="virtual-key" data-key="ctrlc">Ctrl+C</div>
|
|
952
|
-
<div class="virtual-key scroll-key" data-scroll="-5">⇡ 滚动</div>
|
|
953
|
-
<div class="virtual-key scroll-key" data-scroll="5">⇣ 滚动</div>
|
|
954
952
|
<div class="virtual-key" id="btn-copy">复制</div>
|
|
955
953
|
</div>
|
|
956
954
|
</div>
|
|
@@ -1153,14 +1151,32 @@
|
|
|
1153
1151
|
pixelAccum = 0;
|
|
1154
1152
|
}
|
|
1155
1153
|
|
|
1156
|
-
//
|
|
1154
|
+
// 触摸滚动实现 - 混合模式:alternate buffer 发鼠标滚轮,normal buffer 用 scrollLines
|
|
1157
1155
|
var touchScreen = null;
|
|
1158
1156
|
var touchEventsBound = false;
|
|
1159
1157
|
|
|
1158
|
+
function isAlternateBuffer() {
|
|
1159
|
+
return term.buffer.active.type === 'alternate';
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
function sendPageKey(direction) {
|
|
1163
|
+
if (!ws || ws.readyState !== 1) return;
|
|
1164
|
+
var seq = direction === 'up' ? '\x1b[5~' : '\x1b[6~';
|
|
1165
|
+
ws.send(JSON.stringify({ type: 'input', data: seq }));
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
function doScroll(lines) {
|
|
1169
|
+
if (lines === 0) return;
|
|
1170
|
+
if (isAlternateBuffer()) {
|
|
1171
|
+
sendPageKey(lines < 0 ? 'up' : 'down');
|
|
1172
|
+
} else {
|
|
1173
|
+
term.scrollLines(lines);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1160
1177
|
function getLineHeight() {
|
|
1161
1178
|
var cellDims = getCellDims();
|
|
1162
1179
|
var height = (cellDims && cellDims.height) || 15;
|
|
1163
|
-
console.log('[scroll] lineHeight:', height);
|
|
1164
1180
|
return height;
|
|
1165
1181
|
}
|
|
1166
1182
|
|
|
@@ -1188,8 +1204,7 @@
|
|
|
1188
1204
|
var lines = Math.trunc(pixelAccum / lh);
|
|
1189
1205
|
|
|
1190
1206
|
if (lines !== 0) {
|
|
1191
|
-
|
|
1192
|
-
term.scrollLines(lines);
|
|
1207
|
+
doScroll(lines);
|
|
1193
1208
|
pixelAccum -= lines * lh;
|
|
1194
1209
|
}
|
|
1195
1210
|
}
|
|
@@ -1273,8 +1288,7 @@
|
|
|
1273
1288
|
var lh = getLineHeight();
|
|
1274
1289
|
var lines = Math.trunc(pixelAccum / lh);
|
|
1275
1290
|
if (lines !== 0) {
|
|
1276
|
-
|
|
1277
|
-
term.scrollLines(lines);
|
|
1291
|
+
doScroll(lines);
|
|
1278
1292
|
}
|
|
1279
1293
|
pixelAccum = 0;
|
|
1280
1294
|
}
|
|
@@ -1304,8 +1318,7 @@
|
|
|
1304
1318
|
var lh = getLineHeight();
|
|
1305
1319
|
var rest = Math.round(mAccum / lh);
|
|
1306
1320
|
if (rest !== 0) {
|
|
1307
|
-
|
|
1308
|
-
term.scrollLines(rest);
|
|
1321
|
+
doScroll(rest);
|
|
1309
1322
|
}
|
|
1310
1323
|
momentumRaf = null;
|
|
1311
1324
|
return;
|
|
@@ -1314,7 +1327,7 @@
|
|
|
1314
1327
|
var lh = getLineHeight();
|
|
1315
1328
|
var lines = Math.trunc(mAccum / lh);
|
|
1316
1329
|
if (lines !== 0) {
|
|
1317
|
-
|
|
1330
|
+
doScroll(lines);
|
|
1318
1331
|
mAccum -= lines * lh;
|
|
1319
1332
|
}
|
|
1320
1333
|
velocity *= friction;
|
|
@@ -1338,12 +1351,6 @@
|
|
|
1338
1351
|
// 先解绑旧的
|
|
1339
1352
|
unbindTouchScroll();
|
|
1340
1353
|
|
|
1341
|
-
// 只在 opencode 模式下绑定
|
|
1342
|
-
if (currentMode !== 'opencode') {
|
|
1343
|
-
console.log('[scroll] Not opencode mode, skip binding');
|
|
1344
|
-
return;
|
|
1345
|
-
}
|
|
1346
|
-
|
|
1347
1354
|
var screen = terminalEl.querySelector('.xterm-screen');
|
|
1348
1355
|
if (!screen) {
|
|
1349
1356
|
console.log('[scroll] .xterm-screen not found, retrying...');
|
|
@@ -1356,7 +1363,7 @@
|
|
|
1356
1363
|
screen.addEventListener('touchmove', handleTouchMove, { passive: true });
|
|
1357
1364
|
screen.addEventListener('touchend', handleTouchEnd, { passive: true });
|
|
1358
1365
|
touchEventsBound = true;
|
|
1359
|
-
console.log('[scroll] Touch events bound to .xterm-screen
|
|
1366
|
+
console.log('[scroll] Touch events bound to .xterm-screen');
|
|
1360
1367
|
}
|
|
1361
1368
|
|
|
1362
1369
|
function rebindTouchScroll() {
|
|
@@ -1547,10 +1554,8 @@
|
|
|
1547
1554
|
}
|
|
1548
1555
|
|
|
1549
1556
|
function scrollTerminal(lines) {
|
|
1550
|
-
if (term)
|
|
1551
|
-
|
|
1552
|
-
console.log('[scroll] scrolled by:', lines);
|
|
1553
|
-
}
|
|
1557
|
+
if (!term) return;
|
|
1558
|
+
doScroll(lines);
|
|
1554
1559
|
}
|
|
1555
1560
|
|
|
1556
1561
|
// 参考 cc-viewer 的 TerminalPanel.jsx 行 519-546: 虚拟按键触摸处理
|