@lethevimlet/sshift 1.4.4 → 1.4.5
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/package.json +1 -1
- package/src/webapp/js/app.js +50 -11
package/package.json
CHANGED
package/src/webapp/js/app.js
CHANGED
|
@@ -995,13 +995,40 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
995
995
|
session.terminal.refresh(0, session.terminal.rows - 1);
|
|
996
996
|
}
|
|
997
997
|
|
|
998
|
-
//
|
|
999
|
-
//
|
|
1000
|
-
//
|
|
1001
|
-
//
|
|
1002
|
-
//
|
|
998
|
+
// Snap cell width to an integer number of device pixels by adjusting
|
|
999
|
+
// letterSpacing. When cellWidth × DPR is fractional, adjacent cells
|
|
1000
|
+
// land on sub-pixel boundaries, causing 1px vertical seams in block
|
|
1001
|
+
// characters. Adding a tiny letterSpacing rounds the device-pixel cell
|
|
1002
|
+
// width up to a whole number, eliminating seams.
|
|
1003
|
+
//
|
|
1004
|
+
// Only applies when the needed padding is <= 0.15 CSS px — larger
|
|
1005
|
+
// padding is visually noticeable as extra character spacing, so we
|
|
1006
|
+
// skip it and accept the occasional 1px seam instead.
|
|
1003
1007
|
_snapCellWidth(session) {
|
|
1004
|
-
|
|
1008
|
+
if (!session || !session.terminal || !session.fitAddon) return;
|
|
1009
|
+
const term = session.terminal;
|
|
1010
|
+
const core = term._core;
|
|
1011
|
+
if (!core?._renderService?.dimensions?.css?.cell) return;
|
|
1012
|
+
|
|
1013
|
+
const cellCssW = core._renderService.dimensions.css.cell.width;
|
|
1014
|
+
if (!cellCssW || cellCssW <= 0) return;
|
|
1015
|
+
|
|
1016
|
+
const dpr = window.devicePixelRatio || 1;
|
|
1017
|
+
const deviceW = cellCssW * dpr;
|
|
1018
|
+
const fraction = deviceW - Math.floor(deviceW);
|
|
1019
|
+
|
|
1020
|
+
if (fraction > 0.01 && fraction < 0.99) {
|
|
1021
|
+
const padCss = (1 - fraction) / dpr;
|
|
1022
|
+
// Only snap if the padding needed is tiny (imperceptible).
|
|
1023
|
+
// Larger padding creates visible gaps between characters.
|
|
1024
|
+
if (padCss <= 0.15) {
|
|
1025
|
+
term.options.letterSpacing = padCss;
|
|
1026
|
+
} else {
|
|
1027
|
+
term.options.letterSpacing = 0;
|
|
1028
|
+
}
|
|
1029
|
+
} else {
|
|
1030
|
+
term.options.letterSpacing = 0;
|
|
1031
|
+
}
|
|
1005
1032
|
}
|
|
1006
1033
|
|
|
1007
1034
|
// Initialize (or re-initialize) the WebGL renderer addon for a session.
|
|
@@ -1092,6 +1119,7 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1092
1119
|
if (session.webglAddon) {
|
|
1093
1120
|
try { session.webglAddon.clearTextureAtlas(); } catch (_) {}
|
|
1094
1121
|
}
|
|
1122
|
+
this._snapCellWidth(session);
|
|
1095
1123
|
if (session.terminal) {
|
|
1096
1124
|
session.terminal.refresh(0, session.terminal.rows - 1);
|
|
1097
1125
|
}
|
|
@@ -1155,6 +1183,7 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1155
1183
|
currentDPR = newDPR;
|
|
1156
1184
|
this.sessions.forEach(session => {
|
|
1157
1185
|
this._resetWebGLAtlas(session);
|
|
1186
|
+
this._snapCellWidth(session);
|
|
1158
1187
|
if (session.fitAddon && session.terminal && session.isController) {
|
|
1159
1188
|
const wrapper = document.getElementById(`terminal-wrapper-${session.id}`);
|
|
1160
1189
|
if (wrapper && wrapper.classList.contains('active')) {
|
|
@@ -1239,11 +1268,21 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1239
1268
|
}
|
|
1240
1269
|
}
|
|
1241
1270
|
|
|
1242
|
-
//
|
|
1243
|
-
//
|
|
1244
|
-
//
|
|
1245
|
-
//
|
|
1246
|
-
|
|
1271
|
+
// Snap cell width to an integer number of device pixels so block/box
|
|
1272
|
+
// drawing characters tile without 1px seams on fractional-DPR displays.
|
|
1273
|
+
// This MUST be followed by a refit because letterSpacing changes the
|
|
1274
|
+
// cell width, which changes how many columns fit in the container.
|
|
1275
|
+
const letterSpacingBefore = terminal.options.letterSpacing || 0;
|
|
1276
|
+
this._snapCellWidth(session);
|
|
1277
|
+
const letterSpacingAfter = terminal.options.letterSpacing || 0;
|
|
1278
|
+
|
|
1279
|
+
// If letterSpacing changed, refit so xterm recalculates column count
|
|
1280
|
+
// with the new (snapped) cell width.
|
|
1281
|
+
if (letterSpacingAfter !== letterSpacingBefore) {
|
|
1282
|
+
try {
|
|
1283
|
+
session.fitAddon.fit();
|
|
1284
|
+
} catch (_) {}
|
|
1285
|
+
}
|
|
1247
1286
|
|
|
1248
1287
|
console.log('[SSHIFT] Terminal fitted, cols:', terminal.cols, 'rows:', terminal.rows);
|
|
1249
1288
|
|