@gkoreli/ghostty-vt-js 0.3.2
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/LICENSE +21 -0
- package/README.md +89 -0
- package/THIRD_PARTY_NOTICES.md +45 -0
- package/dist/browser-terminal/buffer.d.ts +93 -0
- package/dist/browser-terminal/buffer.d.ts.map +1 -0
- package/dist/browser-terminal/buffer.js +337 -0
- package/dist/browser-terminal/buffer.js.map +1 -0
- package/dist/browser-terminal/encoding.d.ts +17 -0
- package/dist/browser-terminal/encoding.d.ts.map +1 -0
- package/dist/browser-terminal/encoding.js +22 -0
- package/dist/browser-terminal/encoding.js.map +1 -0
- package/dist/browser-terminal/event-emitter.d.ts +8 -0
- package/dist/browser-terminal/event-emitter.d.ts.map +1 -0
- package/dist/browser-terminal/event-emitter.js +27 -0
- package/dist/browser-terminal/event-emitter.js.map +1 -0
- package/dist/browser-terminal/frame-hold.d.ts +13 -0
- package/dist/browser-terminal/frame-hold.d.ts.map +1 -0
- package/dist/browser-terminal/frame-hold.js +17 -0
- package/dist/browser-terminal/frame-hold.js.map +1 -0
- package/dist/browser-terminal/geometry.d.ts +229 -0
- package/dist/browser-terminal/geometry.d.ts.map +1 -0
- package/dist/browser-terminal/geometry.js +299 -0
- package/dist/browser-terminal/geometry.js.map +1 -0
- package/dist/browser-terminal/ghostty.d.ts +478 -0
- package/dist/browser-terminal/ghostty.d.ts.map +1 -0
- package/dist/browser-terminal/ghostty.js +1212 -0
- package/dist/browser-terminal/ghostty.js.map +1 -0
- package/dist/browser-terminal/gpu/adapter.d.ts +70 -0
- package/dist/browser-terminal/gpu/adapter.d.ts.map +1 -0
- package/dist/browser-terminal/gpu/adapter.js +260 -0
- package/dist/browser-terminal/gpu/adapter.js.map +1 -0
- package/dist/browser-terminal/gpu/core/canvas-glyph-rasterizer.d.ts +33 -0
- package/dist/browser-terminal/gpu/core/canvas-glyph-rasterizer.d.ts.map +1 -0
- package/dist/browser-terminal/gpu/core/canvas-glyph-rasterizer.js +159 -0
- package/dist/browser-terminal/gpu/core/canvas-glyph-rasterizer.js.map +1 -0
- package/dist/browser-terminal/gpu/core/context-loss-watchdog.d.ts +35 -0
- package/dist/browser-terminal/gpu/core/context-loss-watchdog.d.ts.map +1 -0
- package/dist/browser-terminal/gpu/core/context-loss-watchdog.js +73 -0
- package/dist/browser-terminal/gpu/core/context-loss-watchdog.js.map +1 -0
- package/dist/browser-terminal/gpu/core/frame.d.ts +68 -0
- package/dist/browser-terminal/gpu/core/frame.d.ts.map +1 -0
- package/dist/browser-terminal/gpu/core/frame.js +167 -0
- package/dist/browser-terminal/gpu/core/frame.js.map +1 -0
- package/dist/browser-terminal/gpu/core/glyph-atlas.d.ts +136 -0
- package/dist/browser-terminal/gpu/core/glyph-atlas.d.ts.map +1 -0
- package/dist/browser-terminal/gpu/core/glyph-atlas.js +281 -0
- package/dist/browser-terminal/gpu/core/glyph-atlas.js.map +1 -0
- package/dist/browser-terminal/gpu/core/procedural-shapes.d.ts +24 -0
- package/dist/browser-terminal/gpu/core/procedural-shapes.d.ts.map +1 -0
- package/dist/browser-terminal/gpu/core/procedural-shapes.js +316 -0
- package/dist/browser-terminal/gpu/core/procedural-shapes.js.map +1 -0
- package/dist/browser-terminal/gpu/core/webgl2-renderer.d.ts +107 -0
- package/dist/browser-terminal/gpu/core/webgl2-renderer.d.ts.map +1 -0
- package/dist/browser-terminal/gpu/core/webgl2-renderer.js +698 -0
- package/dist/browser-terminal/gpu/core/webgl2-renderer.js.map +1 -0
- package/dist/browser-terminal/gpu/create-renderer.d.ts +15 -0
- package/dist/browser-terminal/gpu/create-renderer.d.ts.map +1 -0
- package/dist/browser-terminal/gpu/create-renderer.js +33 -0
- package/dist/browser-terminal/gpu/create-renderer.js.map +1 -0
- package/dist/browser-terminal/index.d.ts +47 -0
- package/dist/browser-terminal/index.d.ts.map +1 -0
- package/dist/browser-terminal/index.js +75 -0
- package/dist/browser-terminal/index.js.map +1 -0
- package/dist/browser-terminal/input-handler.d.ts +262 -0
- package/dist/browser-terminal/input-handler.d.ts.map +1 -0
- package/dist/browser-terminal/input-handler.js +978 -0
- package/dist/browser-terminal/input-handler.js.map +1 -0
- package/dist/browser-terminal/interfaces.d.ts +230 -0
- package/dist/browser-terminal/interfaces.d.ts.map +1 -0
- package/dist/browser-terminal/interfaces.js +5 -0
- package/dist/browser-terminal/interfaces.js.map +1 -0
- package/dist/browser-terminal/link-detector.d.ts +76 -0
- package/dist/browser-terminal/link-detector.d.ts.map +1 -0
- package/dist/browser-terminal/link-detector.js +165 -0
- package/dist/browser-terminal/link-detector.js.map +1 -0
- package/dist/browser-terminal/providers/osc8-link-provider.d.ts +56 -0
- package/dist/browser-terminal/providers/osc8-link-provider.d.ts.map +1 -0
- package/dist/browser-terminal/providers/osc8-link-provider.js +204 -0
- package/dist/browser-terminal/providers/osc8-link-provider.js.map +1 -0
- package/dist/browser-terminal/providers/url-regex-provider.d.ts +68 -0
- package/dist/browser-terminal/providers/url-regex-provider.d.ts.map +1 -0
- package/dist/browser-terminal/providers/url-regex-provider.js +107 -0
- package/dist/browser-terminal/providers/url-regex-provider.js.map +1 -0
- package/dist/browser-terminal/renderer-interface.d.ts +59 -0
- package/dist/browser-terminal/renderer-interface.d.ts.map +1 -0
- package/dist/browser-terminal/renderer-interface.js +2 -0
- package/dist/browser-terminal/renderer-interface.js.map +1 -0
- package/dist/browser-terminal/renderer.d.ts +254 -0
- package/dist/browser-terminal/renderer.d.ts.map +1 -0
- package/dist/browser-terminal/renderer.js +905 -0
- package/dist/browser-terminal/renderer.js.map +1 -0
- package/dist/browser-terminal/scrollbar-overlay.d.ts +45 -0
- package/dist/browser-terminal/scrollbar-overlay.d.ts.map +1 -0
- package/dist/browser-terminal/scrollbar-overlay.js +89 -0
- package/dist/browser-terminal/scrollbar-overlay.js.map +1 -0
- package/dist/browser-terminal/selection-manager.d.ts +180 -0
- package/dist/browser-terminal/selection-manager.d.ts.map +1 -0
- package/dist/browser-terminal/selection-manager.js +913 -0
- package/dist/browser-terminal/selection-manager.js.map +1 -0
- package/dist/browser-terminal/terminal.d.ts +423 -0
- package/dist/browser-terminal/terminal.d.ts.map +1 -0
- package/dist/browser-terminal/terminal.js +1754 -0
- package/dist/browser-terminal/terminal.js.map +1 -0
- package/dist/browser-terminal/types.d.ts +595 -0
- package/dist/browser-terminal/types.d.ts.map +1 -0
- package/dist/browser-terminal/types.js +467 -0
- package/dist/browser-terminal/types.js.map +1 -0
- package/dist/browser-terminal/viewport-scroller.d.ts +94 -0
- package/dist/browser-terminal/viewport-scroller.d.ts.map +1 -0
- package/dist/browser-terminal/viewport-scroller.js +159 -0
- package/dist/browser-terminal/viewport-scroller.js.map +1 -0
- package/dist/browser-terminal/vt/effects.d.ts +114 -0
- package/dist/browser-terminal/vt/effects.d.ts.map +1 -0
- package/dist/browser-terminal/vt/effects.js +143 -0
- package/dist/browser-terminal/vt/effects.js.map +1 -0
- package/dist/browser-terminal/vt/enums.d.ts +155 -0
- package/dist/browser-terminal/vt/enums.d.ts.map +1 -0
- package/dist/browser-terminal/vt/enums.js +161 -0
- package/dist/browser-terminal/vt/enums.js.map +1 -0
- package/dist/browser-terminal/vt/mouse.d.ts +166 -0
- package/dist/browser-terminal/vt/mouse.d.ts.map +1 -0
- package/dist/browser-terminal/vt/mouse.js +259 -0
- package/dist/browser-terminal/vt/mouse.js.map +1 -0
- package/dist/browser-terminal/vt/paste.d.ts +53 -0
- package/dist/browser-terminal/vt/paste.d.ts.map +1 -0
- package/dist/browser-terminal/vt/paste.js +89 -0
- package/dist/browser-terminal/vt/paste.js.map +1 -0
- package/dist/browser-terminal/vt/render-state.d.ts +208 -0
- package/dist/browser-terminal/vt/render-state.d.ts.map +1 -0
- package/dist/browser-terminal/vt/render-state.js +776 -0
- package/dist/browser-terminal/vt/render-state.js.map +1 -0
- package/dist/browser-terminal/vt/style.d.ts +54 -0
- package/dist/browser-terminal/vt/style.d.ts.map +1 -0
- package/dist/browser-terminal/vt/style.js +92 -0
- package/dist/browser-terminal/vt/style.js.map +1 -0
- package/dist/browser-terminal/wasm-loader.d.ts +39 -0
- package/dist/browser-terminal/wasm-loader.d.ts.map +1 -0
- package/dist/browser-terminal/wasm-loader.js +73 -0
- package/dist/browser-terminal/wasm-loader.js.map +1 -0
- package/dist/browser-terminal/write-buffer.d.ts +40 -0
- package/dist/browser-terminal/write-buffer.d.ts.map +1 -0
- package/dist/browser-terminal/write-buffer.js +144 -0
- package/dist/browser-terminal/write-buffer.js.map +1 -0
- package/dist/protocol/index.d.ts +135 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +76 -0
- package/dist/protocol/index.js.map +1 -0
- package/dist/react/index.d.ts +59 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +146 -0
- package/dist/react/index.js.map +1 -0
- package/dist/server/index.d.ts +130 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +191 -0
- package/dist/server/index.js.map +1 -0
- package/dist/terminal-screen-emulator/emulator.d.ts +66 -0
- package/dist/terminal-screen-emulator/emulator.d.ts.map +1 -0
- package/dist/terminal-screen-emulator/emulator.js +286 -0
- package/dist/terminal-screen-emulator/emulator.js.map +1 -0
- package/dist/terminal-screen-emulator/index.d.ts +82 -0
- package/dist/terminal-screen-emulator/index.d.ts.map +1 -0
- package/dist/terminal-screen-emulator/index.js +92 -0
- package/dist/terminal-screen-emulator/index.js.map +1 -0
- package/dist/terminal-screen-emulator/types.d.ts +382 -0
- package/dist/terminal-screen-emulator/types.d.ts.map +1 -0
- package/dist/terminal-screen-emulator/types.js +91 -0
- package/dist/terminal-screen-emulator/types.js.map +1 -0
- package/dist/terminal-screen-emulator/wasm-loader.d.ts +71 -0
- package/dist/terminal-screen-emulator/wasm-loader.d.ts.map +1 -0
- package/dist/terminal-screen-emulator/wasm-loader.js +162 -0
- package/dist/terminal-screen-emulator/wasm-loader.js.map +1 -0
- package/dist/themes/index.d.ts +6 -0
- package/dist/themes/index.d.ts.map +1 -0
- package/dist/themes/index.js +51 -0
- package/dist/themes/index.js.map +1 -0
- package/dist/wasm/alloc.d.ts +170 -0
- package/dist/wasm/alloc.d.ts.map +1 -0
- package/dist/wasm/alloc.js +307 -0
- package/dist/wasm/alloc.js.map +1 -0
- package/dist/wasm/compile.d.ts +73 -0
- package/dist/wasm/compile.d.ts.map +1 -0
- package/dist/wasm/compile.js +82 -0
- package/dist/wasm/compile.js.map +1 -0
- package/dist/wasm/exports.d.ts +234 -0
- package/dist/wasm/exports.d.ts.map +1 -0
- package/dist/wasm/exports.js +15 -0
- package/dist/wasm/exports.js.map +1 -0
- package/dist/wasm/fn-table.d.ts +119 -0
- package/dist/wasm/fn-table.d.ts.map +1 -0
- package/dist/wasm/fn-table.js +168 -0
- package/dist/wasm/fn-table.js.map +1 -0
- package/dist/wasm/memory.d.ts +59 -0
- package/dist/wasm/memory.d.ts.map +1 -0
- package/dist/wasm/memory.js +89 -0
- package/dist/wasm/memory.js.map +1 -0
- package/dist/wasm/type-layouts.d.ts +61 -0
- package/dist/wasm/type-layouts.d.ts.map +1 -0
- package/dist/wasm/type-layouts.js +32 -0
- package/dist/wasm/type-layouts.js.map +1 -0
- package/package.json +94 -0
- package/wasm/ghostty-vt.wasm +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Portions originally derived from coder/ghostty-web (MIT — see ./LICENSE):
|
|
2
|
+
// https://github.com/coder/ghostty-web/blob/6a1a50df5b4f6b34d1b1de10fad3a0fc811bfbc0/lib/event-emitter.ts
|
|
3
|
+
// Substantially rewritten since; this file is ours and does not track that project.
|
|
4
|
+
// Modified: typed listener parameter (TS7006 fix); kept to track upstream.
|
|
5
|
+
export class EventEmitter {
|
|
6
|
+
listeners = [];
|
|
7
|
+
fire(arg) {
|
|
8
|
+
for (const listener of this.listeners) {
|
|
9
|
+
listener(arg);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
event = (listener) => {
|
|
13
|
+
this.listeners.push(listener);
|
|
14
|
+
return {
|
|
15
|
+
dispose: () => {
|
|
16
|
+
const index = this.listeners.indexOf(listener);
|
|
17
|
+
if (index >= 0) {
|
|
18
|
+
this.listeners.splice(index, 1);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
dispose() {
|
|
24
|
+
this.listeners = [];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=event-emitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-emitter.js","sourceRoot":"","sources":["../../src/browser-terminal/event-emitter.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4GAA4G;AAC5G,oFAAoF;AACpF,2EAA2E;AAI3E,MAAM,OAAO,YAAY;IACf,SAAS,GAA4B,EAAE,CAAC;IAEhD,IAAI,CAAC,GAAM;QACT,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IAED,KAAK,GAAc,CAAC,QAA0B,EAAE,EAAE;QAChD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9B,OAAO;YACL,OAAO,EAAE,GAAG,EAAE;gBACZ,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC/C,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;oBACf,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;gBAClC,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO;QACL,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const SYNCHRONIZED_OUTPUT_MAX_HOLD_MS = 150;
|
|
2
|
+
export type FrameHoldAction = 'paint' | 'skip';
|
|
3
|
+
export interface FrameHoldDecision {
|
|
4
|
+
action: FrameHoldAction;
|
|
5
|
+
holdStartMs: number | undefined;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Decide whether the frame scheduler should paint while synchronized output is
|
|
9
|
+
* active. The original hold timestamp is retained after the safety valve
|
|
10
|
+
* expires so a mode that is never cleared paints every subsequent frame.
|
|
11
|
+
*/
|
|
12
|
+
export declare function decideSynchronizedOutputFrameHold(active: boolean, holdStartMs: number | undefined, nowMs: number): FrameHoldDecision;
|
|
13
|
+
//# sourceMappingURL=frame-hold.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-hold.d.ts","sourceRoot":"","sources":["../../src/browser-terminal/frame-hold.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,+BAA+B,MAAM,CAAC;AAEnD,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,eAAe,CAAC;IACxB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,KAAK,EAAE,MAAM,GACZ,iBAAiB,CAUnB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const SYNCHRONIZED_OUTPUT_MAX_HOLD_MS = 150;
|
|
2
|
+
/**
|
|
3
|
+
* Decide whether the frame scheduler should paint while synchronized output is
|
|
4
|
+
* active. The original hold timestamp is retained after the safety valve
|
|
5
|
+
* expires so a mode that is never cleared paints every subsequent frame.
|
|
6
|
+
*/
|
|
7
|
+
export function decideSynchronizedOutputFrameHold(active, holdStartMs, nowMs) {
|
|
8
|
+
if (!active) {
|
|
9
|
+
return { action: 'paint', holdStartMs: undefined };
|
|
10
|
+
}
|
|
11
|
+
const effectiveHoldStartMs = holdStartMs ?? nowMs;
|
|
12
|
+
const action = nowMs - effectiveHoldStartMs >= SYNCHRONIZED_OUTPUT_MAX_HOLD_MS
|
|
13
|
+
? 'paint'
|
|
14
|
+
: 'skip';
|
|
15
|
+
return { action, holdStartMs: effectiveHoldStartMs };
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=frame-hold.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-hold.js","sourceRoot":"","sources":["../../src/browser-terminal/frame-hold.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAAG,CAAC;AASnD;;;;GAIG;AACH,MAAM,UAAU,iCAAiC,CAC/C,MAAe,EACf,WAA+B,EAC/B,KAAa;IAEb,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;IACrD,CAAC;IAED,MAAM,oBAAoB,GAAG,WAAW,IAAI,KAAK,CAAC;IAClD,MAAM,MAAM,GAAG,KAAK,GAAG,oBAAoB,IAAI,+BAA+B;QAC5E,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TerminalGeometry — the single owner of a terminal's size, in every unit.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this exists (the geometry-authority design)
|
|
5
|
+
*
|
|
6
|
+
* Terminal size lives in four different unit systems at once: font metrics
|
|
7
|
+
* (fractional CSS px), the cell grid (cols × rows), the canvas box (CSS px and
|
|
8
|
+
* device px), and the PTY's `winsize`. Before this class, four places converted
|
|
9
|
+
* between them independently — `renderer.measureFont`, `addons/fit.ts`,
|
|
10
|
+
* `Terminal.resize`, and the consumer's socket code — each rounding on its own.
|
|
11
|
+
* That is how a session ended up with the engine at one width and the PTY at
|
|
12
|
+
* another, which is what puts a cursor in the middle of a prompt.
|
|
13
|
+
*
|
|
14
|
+
* This class owns every conversion. Nothing else measures a font, divides
|
|
15
|
+
* available space by a cell size, or assigns `canvas.width`.
|
|
16
|
+
*
|
|
17
|
+
* ## Proposal vs. decision (the authority split)
|
|
18
|
+
*
|
|
19
|
+
* The **server** decides terminal size; a client may only *propose* what fits
|
|
20
|
+
* in its viewport (the geometry-authority design, following tmux, where clients report
|
|
21
|
+
* their size and the server arbitrates across all attached clients). So this
|
|
22
|
+
* class exposes two distinct values, and the distinction is load-bearing:
|
|
23
|
+
*
|
|
24
|
+
* - {@link proposal} — what the measured host box can hold. An *input* to the
|
|
25
|
+
* authority. Never applied to the engine directly.
|
|
26
|
+
* - {@link decided} — the authoritative grid. Only {@link applyDecision} sets
|
|
27
|
+
* it, and only from a server decision. This is what the engine and canvas
|
|
28
|
+
* follow.
|
|
29
|
+
*
|
|
30
|
+
* Until the first decision arrives, `decided` is `null` — a state, not a
|
|
31
|
+
* number to invent (the old `?? 120` default was a second source of truth).
|
|
32
|
+
* Standalone/local use (no server) calls `applyDecision(proposal)` explicitly,
|
|
33
|
+
* making "I am my own authority" a visible choice rather than an accident.
|
|
34
|
+
*
|
|
35
|
+
* ## Testability
|
|
36
|
+
*
|
|
37
|
+
* Measurement and host-size reading are injected, so all of the arithmetic
|
|
38
|
+
* (rounding, remainder, DPR, clamping) is unit-testable in Node with no DOM.
|
|
39
|
+
*/
|
|
40
|
+
/** Cell metrics in fractional CSS pixels. Fractional on purpose — see {@link measureCellWithCanvas}. */
|
|
41
|
+
export interface CellMetrics {
|
|
42
|
+
/** Horizontal advance of one cell. */
|
|
43
|
+
width: number;
|
|
44
|
+
/** Full line height of one cell. */
|
|
45
|
+
height: number;
|
|
46
|
+
/** Baseline offset from the cell top, for `fillText`. */
|
|
47
|
+
baseline: number;
|
|
48
|
+
}
|
|
49
|
+
/** A cell grid. */
|
|
50
|
+
export interface GridSize {
|
|
51
|
+
cols: number;
|
|
52
|
+
rows: number;
|
|
53
|
+
}
|
|
54
|
+
/** The canvas element's box, in both unit systems. Device pixels are integers. */
|
|
55
|
+
export interface CanvasBox {
|
|
56
|
+
/**
|
|
57
|
+
* CSS pixel size of the paint surface — the FULL host box, not the grid.
|
|
58
|
+
* The canvas covers the pane; the grid is painted inset within it. This is
|
|
59
|
+
* what makes insets invisible outside this class: consumers size the canvas
|
|
60
|
+
* to the pane (effectively 100%/100%) and never see a margin.
|
|
61
|
+
*/
|
|
62
|
+
cssWidth: number;
|
|
63
|
+
cssHeight: number;
|
|
64
|
+
/** Backing store (`canvas.width/height`) — integer device pixels. */
|
|
65
|
+
deviceWidth: number;
|
|
66
|
+
deviceHeight: number;
|
|
67
|
+
/** The ratio the box was computed with. */
|
|
68
|
+
devicePixelRatio: number;
|
|
69
|
+
/**
|
|
70
|
+
* Where cell (0,0) starts, in CSS px from the surface's top-left: the
|
|
71
|
+
* configured padding plus half the sub-cell leftover, so the grid sits
|
|
72
|
+
* centred. The renderer applies this ONCE as a context transform; nothing
|
|
73
|
+
* else needs it — pixel→cell goes through {@link TerminalGeometry.cellAt}.
|
|
74
|
+
*/
|
|
75
|
+
gridOriginX: number;
|
|
76
|
+
gridOriginY: number;
|
|
77
|
+
/** The painted grid's size in CSS px (`decided × cell`). */
|
|
78
|
+
gridCssWidth: number;
|
|
79
|
+
gridCssHeight: number;
|
|
80
|
+
}
|
|
81
|
+
export interface TerminalGeometryOptions {
|
|
82
|
+
/** Measure one cell. Injected for testability; see {@link measureCellWithCanvas}. */
|
|
83
|
+
measureCell: () => CellMetrics;
|
|
84
|
+
/**
|
|
85
|
+
* Content-box size of the host element in CSS pixels (i.e. padding already
|
|
86
|
+
* subtracted). Injected for testability; see {@link readHostContentBox}.
|
|
87
|
+
*/
|
|
88
|
+
readHostBox: () => {
|
|
89
|
+
width: number;
|
|
90
|
+
height: number;
|
|
91
|
+
};
|
|
92
|
+
/** Defaults to `window.devicePixelRatio ?? 1`. */
|
|
93
|
+
devicePixelRatio?: number;
|
|
94
|
+
/** Minimum grid, clamped against degenerate host boxes. Defaults to 2×1. */
|
|
95
|
+
minCols?: number;
|
|
96
|
+
minRows?: number;
|
|
97
|
+
/**
|
|
98
|
+
* Breathing room between the host's edges and the first/last cell, in CSS px
|
|
99
|
+
* per side. Default {@link DEFAULT_PADDING}.
|
|
100
|
+
*
|
|
101
|
+
* This MUST live here rather than as CSS padding on the host, because it has
|
|
102
|
+
* to be subtracted *before* the cell division. CSS padding on the host looks
|
|
103
|
+
* equivalent and is not: it shrinks the measured box after the fact, which can
|
|
104
|
+
* push the result past a row boundary and silently cost a row (observed: 6px
|
|
105
|
+
* of demo padding turned 44 rows into 43).
|
|
106
|
+
*/
|
|
107
|
+
padding?: number;
|
|
108
|
+
}
|
|
109
|
+
export declare class TerminalGeometry {
|
|
110
|
+
private readonly opts;
|
|
111
|
+
private _metrics;
|
|
112
|
+
private _proposal;
|
|
113
|
+
private _decided;
|
|
114
|
+
private readonly listeners;
|
|
115
|
+
constructor(opts: TerminalGeometryOptions);
|
|
116
|
+
/** Measured cell metrics (fractional CSS px). */
|
|
117
|
+
get metrics(): CellMetrics;
|
|
118
|
+
/** What the host box can hold. An input to the authority — not the truth. */
|
|
119
|
+
get proposal(): GridSize;
|
|
120
|
+
/**
|
|
121
|
+
* The authoritative grid, or `null` before the first decision. Engine and
|
|
122
|
+
* canvas follow this — never {@link proposal}.
|
|
123
|
+
*/
|
|
124
|
+
get decided(): GridSize | null;
|
|
125
|
+
/** Effective device pixel ratio. */
|
|
126
|
+
get devicePixelRatio(): number;
|
|
127
|
+
/**
|
|
128
|
+
* Re-measure the font (font-size/family change, webfont load) and recompute
|
|
129
|
+
* the proposal. Returns true if the proposal changed.
|
|
130
|
+
*/
|
|
131
|
+
remeasure(): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Recompute the proposal from the current host box (resize observed).
|
|
134
|
+
* Returns true if it changed — the caller then sends it upstream.
|
|
135
|
+
*/
|
|
136
|
+
reproposal(): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Adopt the authority's decision. This is the ONLY way `decided` changes.
|
|
139
|
+
* Returns true if it changed (caller then resizes engine + canvas).
|
|
140
|
+
*/
|
|
141
|
+
applyDecision(size: GridSize): boolean;
|
|
142
|
+
/** Subscribe to decided-geometry changes. Returns an unsubscribe. */
|
|
143
|
+
onDecision(listener: (decided: GridSize) => void): () => void;
|
|
144
|
+
/**
|
|
145
|
+
* The canvas box for the decided grid — the single computation of
|
|
146
|
+
* `canvas.width`/`style.width`. Device pixels are rounded to integers
|
|
147
|
+
* (a fractional backing store is silently truncated by the browser, which
|
|
148
|
+
* shifts every cell after it).
|
|
149
|
+
*
|
|
150
|
+
* Throws if called before a decision: sizing a canvas from a proposal is the
|
|
151
|
+
* bug this class exists to prevent.
|
|
152
|
+
*/
|
|
153
|
+
canvasBox(): CanvasBox;
|
|
154
|
+
/**
|
|
155
|
+
* Map surface-local CSS pixels (e.g. a mouse event relative to the canvas)
|
|
156
|
+
* to a cell, clamped to the decided grid. THE pixel→cell authority: input
|
|
157
|
+
* handling must pipe through here rather than dividing by cell size itself,
|
|
158
|
+
* because only this class knows where the grid sits on the surface.
|
|
159
|
+
* Coordinates in the inset gutter clamp to the nearest edge cell, matching
|
|
160
|
+
* native terminals (a click in the padding selects the adjacent cell).
|
|
161
|
+
*/
|
|
162
|
+
cellAt(cssX: number, cssY: number): {
|
|
163
|
+
col: number;
|
|
164
|
+
row: number;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Unused host space below/right of the decided grid, in CSS px. Always
|
|
168
|
+
* sub-cell: a cell grid cannot fill an arbitrary box exactly. Exposed so
|
|
169
|
+
* consumers can center or letterbox instead of guessing.
|
|
170
|
+
*/
|
|
171
|
+
remainder(): {
|
|
172
|
+
width: number;
|
|
173
|
+
height: number;
|
|
174
|
+
};
|
|
175
|
+
private get minCols();
|
|
176
|
+
private get minRows();
|
|
177
|
+
private get padding();
|
|
178
|
+
/**
|
|
179
|
+
* Host box ÷ cell size, floored.
|
|
180
|
+
*
|
|
181
|
+
* VT_NOTE: no scrollbar reservation. The scrollbar is an on-canvas overlay
|
|
182
|
+
* (`renderer.renderScrollbar`, drawn over the last columns with its own
|
|
183
|
+
* `clearRect`), not a DOM scrollbar — the old `DEFAULT_SCROLLBAR_WIDTH = 15`
|
|
184
|
+
* in `addons/fit.ts` reserved space for a DOM scrollbar that was never
|
|
185
|
+
* built, permanently costing ~2 columns.
|
|
186
|
+
*/
|
|
187
|
+
private computeProposal;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Read an element's content box (borders and padding excluded) in CSS pixels.
|
|
191
|
+
*
|
|
192
|
+
* Uses `getBoundingClientRect()` (fractional) rather than `clientWidth`
|
|
193
|
+
* (integer-rounded): rounding here compounds into the cell division below.
|
|
194
|
+
*
|
|
195
|
+
* `getBoundingClientRect()` returns the BORDER box, so borders must be
|
|
196
|
+
* subtracted alongside padding. Skipping them is not a cosmetic off-by-two:
|
|
197
|
+
* the canvas surface fills this box (`canvasBox()`), the canvas lives inside
|
|
198
|
+
* the border, and a `ResizeObserver` watches the host — so a border-inclusive
|
|
199
|
+
* read makes the canvas 2px taller than the space inside the border, which
|
|
200
|
+
* grows the host, which re-fires the observer with a larger box, indefinitely
|
|
201
|
+
* ("ResizeObserver loop completed with undelivered notifications").
|
|
202
|
+
*/
|
|
203
|
+
export declare function readHostContentBox(element: HTMLElement): () => {
|
|
204
|
+
width: number;
|
|
205
|
+
height: number;
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Measure one cell with a canvas 2D context.
|
|
209
|
+
*
|
|
210
|
+
* Two deliberate differences from the old `renderer.measureFont()`:
|
|
211
|
+
*
|
|
212
|
+
* 1. **Fractional advance, averaged over a run.** The old code did
|
|
213
|
+
* `Math.ceil(measureText('M').width)`, which at 12px monospace turns a
|
|
214
|
+
* ~7.2px advance into 8px — cells ~11% too wide, so ~11% fewer columns fit
|
|
215
|
+
* and text is loosely spaced. We measure a 32-char run and divide, keeping
|
|
216
|
+
* the fraction; integer snapping happens once, in device pixels, in
|
|
217
|
+
* {@link TerminalGeometry.canvasBox}.
|
|
218
|
+
* 2. **Line height is explicit, not magic.** The old code added a bare `+2` px
|
|
219
|
+
* per row for glyph overflow — ~70px of lost height over 35 rows. Here the
|
|
220
|
+
* ratio is a named parameter (default 1.2, the conventional terminal line
|
|
221
|
+
* height) applied to the font's own ascent+descent.
|
|
222
|
+
*/
|
|
223
|
+
export declare function measureCellWithCanvas(opts: {
|
|
224
|
+
fontSize: number;
|
|
225
|
+
fontFamily: string;
|
|
226
|
+
/** Multiplier on ascent+descent. Default 1.2. */
|
|
227
|
+
lineHeight?: number;
|
|
228
|
+
}): () => CellMetrics;
|
|
229
|
+
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/browser-terminal/geometry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,wGAAwG;AACxG,MAAM,WAAW,WAAW;IAC1B,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,mBAAmB;AACnB,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,kFAAkF;AAClF,MAAM,WAAW,SAAS;IACxB;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;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K7D;;;;;;;;OAQG;IACH,SAAS,IAAI,SAAS;IA6CtB;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IAahE;;;;OAIG;IACH,SAAS,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAY9C,OAAO,KAAK,OAAO,GAElB;IAED,OAAO,KAAK,OAAO,GAElB;IAED,OAAO,KAAK,OAAO,GAElB;IAED;;;;;;;;OAQG;IACH,OAAO,CAAC,eAAe;CAexB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAoBhG;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,MAAM,WAAW,CAmBpB"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TerminalGeometry — the single owner of a terminal's size, in every unit.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this exists (the geometry-authority design)
|
|
5
|
+
*
|
|
6
|
+
* Terminal size lives in four different unit systems at once: font metrics
|
|
7
|
+
* (fractional CSS px), the cell grid (cols × rows), the canvas box (CSS px and
|
|
8
|
+
* device px), and the PTY's `winsize`. Before this class, four places converted
|
|
9
|
+
* between them independently — `renderer.measureFont`, `addons/fit.ts`,
|
|
10
|
+
* `Terminal.resize`, and the consumer's socket code — each rounding on its own.
|
|
11
|
+
* That is how a session ended up with the engine at one width and the PTY at
|
|
12
|
+
* another, which is what puts a cursor in the middle of a prompt.
|
|
13
|
+
*
|
|
14
|
+
* This class owns every conversion. Nothing else measures a font, divides
|
|
15
|
+
* available space by a cell size, or assigns `canvas.width`.
|
|
16
|
+
*
|
|
17
|
+
* ## Proposal vs. decision (the authority split)
|
|
18
|
+
*
|
|
19
|
+
* The **server** decides terminal size; a client may only *propose* what fits
|
|
20
|
+
* in its viewport (the geometry-authority design, following tmux, where clients report
|
|
21
|
+
* their size and the server arbitrates across all attached clients). So this
|
|
22
|
+
* class exposes two distinct values, and the distinction is load-bearing:
|
|
23
|
+
*
|
|
24
|
+
* - {@link proposal} — what the measured host box can hold. An *input* to the
|
|
25
|
+
* authority. Never applied to the engine directly.
|
|
26
|
+
* - {@link decided} — the authoritative grid. Only {@link applyDecision} sets
|
|
27
|
+
* it, and only from a server decision. This is what the engine and canvas
|
|
28
|
+
* follow.
|
|
29
|
+
*
|
|
30
|
+
* Until the first decision arrives, `decided` is `null` — a state, not a
|
|
31
|
+
* number to invent (the old `?? 120` default was a second source of truth).
|
|
32
|
+
* Standalone/local use (no server) calls `applyDecision(proposal)` explicitly,
|
|
33
|
+
* making "I am my own authority" a visible choice rather than an accident.
|
|
34
|
+
*
|
|
35
|
+
* ## Testability
|
|
36
|
+
*
|
|
37
|
+
* Measurement and host-size reading are injected, so all of the arithmetic
|
|
38
|
+
* (rounding, remainder, DPR, clamping) is unit-testable in Node with no DOM.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Default inset per side. 4px is enough that glyphs don't touch the frame,
|
|
42
|
+
* small enough never to cost a row at normal font sizes (Ghostty native
|
|
43
|
+
* defaults to a comparable 2px window padding).
|
|
44
|
+
*/
|
|
45
|
+
const DEFAULT_PADDING = 4;
|
|
46
|
+
const DEFAULT_MIN_COLS = 2;
|
|
47
|
+
const DEFAULT_MIN_ROWS = 1;
|
|
48
|
+
export class TerminalGeometry {
|
|
49
|
+
opts;
|
|
50
|
+
_metrics;
|
|
51
|
+
_proposal;
|
|
52
|
+
_decided = null;
|
|
53
|
+
listeners = new Set();
|
|
54
|
+
constructor(opts) {
|
|
55
|
+
this.opts = opts;
|
|
56
|
+
this._metrics = opts.measureCell();
|
|
57
|
+
this._proposal = this.computeProposal();
|
|
58
|
+
}
|
|
59
|
+
/** Measured cell metrics (fractional CSS px). */
|
|
60
|
+
get metrics() {
|
|
61
|
+
return { ...this._metrics };
|
|
62
|
+
}
|
|
63
|
+
/** What the host box can hold. An input to the authority — not the truth. */
|
|
64
|
+
get proposal() {
|
|
65
|
+
return { ...this._proposal };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The authoritative grid, or `null` before the first decision. Engine and
|
|
69
|
+
* canvas follow this — never {@link proposal}.
|
|
70
|
+
*/
|
|
71
|
+
get decided() {
|
|
72
|
+
return this._decided ? { ...this._decided } : null;
|
|
73
|
+
}
|
|
74
|
+
/** Effective device pixel ratio. */
|
|
75
|
+
get devicePixelRatio() {
|
|
76
|
+
return this.opts.devicePixelRatio ?? (typeof window !== 'undefined' ? window.devicePixelRatio : 1) ?? 1;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Re-measure the font (font-size/family change, webfont load) and recompute
|
|
80
|
+
* the proposal. Returns true if the proposal changed.
|
|
81
|
+
*/
|
|
82
|
+
remeasure() {
|
|
83
|
+
this._metrics = this.opts.measureCell();
|
|
84
|
+
return this.reproposal();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Recompute the proposal from the current host box (resize observed).
|
|
88
|
+
* Returns true if it changed — the caller then sends it upstream.
|
|
89
|
+
*/
|
|
90
|
+
reproposal() {
|
|
91
|
+
const next = this.computeProposal();
|
|
92
|
+
if (next.cols === this._proposal.cols && next.rows === this._proposal.rows)
|
|
93
|
+
return false;
|
|
94
|
+
this._proposal = next;
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Adopt the authority's decision. This is the ONLY way `decided` changes.
|
|
99
|
+
* Returns true if it changed (caller then resizes engine + canvas).
|
|
100
|
+
*/
|
|
101
|
+
applyDecision(size) {
|
|
102
|
+
const cols = Math.max(this.minCols, Math.floor(size.cols));
|
|
103
|
+
const rows = Math.max(this.minRows, Math.floor(size.rows));
|
|
104
|
+
if (this._decided && this._decided.cols === cols && this._decided.rows === rows)
|
|
105
|
+
return false;
|
|
106
|
+
this._decided = { cols, rows };
|
|
107
|
+
for (const l of this.listeners)
|
|
108
|
+
l({ cols, rows });
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
/** Subscribe to decided-geometry changes. Returns an unsubscribe. */
|
|
112
|
+
onDecision(listener) {
|
|
113
|
+
this.listeners.add(listener);
|
|
114
|
+
return () => this.listeners.delete(listener);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The canvas box for the decided grid — the single computation of
|
|
118
|
+
* `canvas.width`/`style.width`. Device pixels are rounded to integers
|
|
119
|
+
* (a fractional backing store is silently truncated by the browser, which
|
|
120
|
+
* shifts every cell after it).
|
|
121
|
+
*
|
|
122
|
+
* Throws if called before a decision: sizing a canvas from a proposal is the
|
|
123
|
+
* bug this class exists to prevent.
|
|
124
|
+
*/
|
|
125
|
+
canvasBox() {
|
|
126
|
+
const decided = this._decided;
|
|
127
|
+
if (!decided) {
|
|
128
|
+
throw new Error('TerminalGeometry.canvasBox() before applyDecision() — canvas size must follow the decided grid, never the proposal');
|
|
129
|
+
}
|
|
130
|
+
const dpr = this.devicePixelRatio;
|
|
131
|
+
const gridCssWidth = decided.cols * this._metrics.width;
|
|
132
|
+
const gridCssHeight = decided.rows * this._metrics.height;
|
|
133
|
+
// Invariant: the grid can never be larger than the box it was measured
|
|
134
|
+
// from. If it is, one of the INPUTS is wrong (stale cell metrics, a host
|
|
135
|
+
// box read while the element was detached/unlaid-out, or a decision from an
|
|
136
|
+
// authority that measured a different viewport) — not the arithmetic here.
|
|
137
|
+
// Report the inputs loudly instead of silently painting a canvas many times
|
|
138
|
+
// the pane, which reads as "the terminal is enormous and off-centre".
|
|
139
|
+
const host = this.opts.readHostBox();
|
|
140
|
+
if (host.width > 0 && (gridCssWidth > host.width + 1 || gridCssHeight > host.height + 1)) {
|
|
141
|
+
console.warn('[ghostty-vt] geometry invariant violated: grid exceeds its host.', {
|
|
142
|
+
decided,
|
|
143
|
+
cell: this._metrics,
|
|
144
|
+
host,
|
|
145
|
+
padding: this.padding,
|
|
146
|
+
gridCss: { width: gridCssWidth, height: gridCssHeight },
|
|
147
|
+
devicePixelRatio: dpr,
|
|
148
|
+
proposal: this._proposal,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
const cssWidth = Math.max(gridCssWidth, host.width);
|
|
152
|
+
const cssHeight = Math.max(gridCssHeight, host.height);
|
|
153
|
+
return {
|
|
154
|
+
cssWidth,
|
|
155
|
+
cssHeight,
|
|
156
|
+
deviceWidth: Math.round(cssWidth * dpr),
|
|
157
|
+
deviceHeight: Math.round(cssHeight * dpr),
|
|
158
|
+
devicePixelRatio: dpr,
|
|
159
|
+
gridOriginX: Math.max(0, (cssWidth - gridCssWidth) / 2),
|
|
160
|
+
gridOriginY: Math.max(0, (cssHeight - gridCssHeight) / 2),
|
|
161
|
+
gridCssWidth,
|
|
162
|
+
gridCssHeight,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Map surface-local CSS pixels (e.g. a mouse event relative to the canvas)
|
|
167
|
+
* to a cell, clamped to the decided grid. THE pixel→cell authority: input
|
|
168
|
+
* handling must pipe through here rather than dividing by cell size itself,
|
|
169
|
+
* because only this class knows where the grid sits on the surface.
|
|
170
|
+
* Coordinates in the inset gutter clamp to the nearest edge cell, matching
|
|
171
|
+
* native terminals (a click in the padding selects the adjacent cell).
|
|
172
|
+
*/
|
|
173
|
+
cellAt(cssX, cssY) {
|
|
174
|
+
const decided = this._decided;
|
|
175
|
+
if (!decided) {
|
|
176
|
+
throw new Error('TerminalGeometry.cellAt() before applyDecision() — there is no grid to map into yet');
|
|
177
|
+
}
|
|
178
|
+
const box = this.canvasBox();
|
|
179
|
+
const clamp = (v, max) => Math.min(Math.max(v, 0), max);
|
|
180
|
+
return {
|
|
181
|
+
col: clamp(Math.floor((cssX - box.gridOriginX) / this._metrics.width), decided.cols - 1),
|
|
182
|
+
row: clamp(Math.floor((cssY - box.gridOriginY) / this._metrics.height), decided.rows - 1),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Unused host space below/right of the decided grid, in CSS px. Always
|
|
187
|
+
* sub-cell: a cell grid cannot fill an arbitrary box exactly. Exposed so
|
|
188
|
+
* consumers can center or letterbox instead of guessing.
|
|
189
|
+
*/
|
|
190
|
+
remainder() {
|
|
191
|
+
const host = this.opts.readHostBox();
|
|
192
|
+
if (!this._decided)
|
|
193
|
+
return { width: host.width, height: host.height };
|
|
194
|
+
const box = this.canvasBox();
|
|
195
|
+
// Slack is host minus the GRID (the surface intentionally covers the whole
|
|
196
|
+
// host, so surface-based slack would always read 0 and hide bad metrics).
|
|
197
|
+
return {
|
|
198
|
+
width: Math.max(0, host.width - box.gridCssWidth),
|
|
199
|
+
height: Math.max(0, host.height - box.gridCssHeight),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
get minCols() {
|
|
203
|
+
return this.opts.minCols ?? DEFAULT_MIN_COLS;
|
|
204
|
+
}
|
|
205
|
+
get minRows() {
|
|
206
|
+
return this.opts.minRows ?? DEFAULT_MIN_ROWS;
|
|
207
|
+
}
|
|
208
|
+
get padding() {
|
|
209
|
+
return this.opts.padding ?? DEFAULT_PADDING;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Host box ÷ cell size, floored.
|
|
213
|
+
*
|
|
214
|
+
* VT_NOTE: no scrollbar reservation. The scrollbar is an on-canvas overlay
|
|
215
|
+
* (`renderer.renderScrollbar`, drawn over the last columns with its own
|
|
216
|
+
* `clearRect`), not a DOM scrollbar — the old `DEFAULT_SCROLLBAR_WIDTH = 15`
|
|
217
|
+
* in `addons/fit.ts` reserved space for a DOM scrollbar that was never
|
|
218
|
+
* built, permanently costing ~2 columns.
|
|
219
|
+
*/
|
|
220
|
+
computeProposal() {
|
|
221
|
+
const host = this.opts.readHostBox();
|
|
222
|
+
// Padding comes off BEFORE the division — see TerminalGeometryOptions.padding.
|
|
223
|
+
const available = {
|
|
224
|
+
width: host.width - this.padding * 2,
|
|
225
|
+
height: host.height - this.padding * 2,
|
|
226
|
+
};
|
|
227
|
+
if (available.width <= 0 || available.height <= 0 || this._metrics.width <= 0 || this._metrics.height <= 0) {
|
|
228
|
+
return { cols: this.minCols, rows: this.minRows };
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
cols: Math.max(this.minCols, Math.floor(available.width / this._metrics.width)),
|
|
232
|
+
rows: Math.max(this.minRows, Math.floor(available.height / this._metrics.height)),
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Read an element's content box (borders and padding excluded) in CSS pixels.
|
|
238
|
+
*
|
|
239
|
+
* Uses `getBoundingClientRect()` (fractional) rather than `clientWidth`
|
|
240
|
+
* (integer-rounded): rounding here compounds into the cell division below.
|
|
241
|
+
*
|
|
242
|
+
* `getBoundingClientRect()` returns the BORDER box, so borders must be
|
|
243
|
+
* subtracted alongside padding. Skipping them is not a cosmetic off-by-two:
|
|
244
|
+
* the canvas surface fills this box (`canvasBox()`), the canvas lives inside
|
|
245
|
+
* the border, and a `ResizeObserver` watches the host — so a border-inclusive
|
|
246
|
+
* read makes the canvas 2px taller than the space inside the border, which
|
|
247
|
+
* grows the host, which re-fires the observer with a larger box, indefinitely
|
|
248
|
+
* ("ResizeObserver loop completed with undelivered notifications").
|
|
249
|
+
*/
|
|
250
|
+
export function readHostContentBox(element) {
|
|
251
|
+
return () => {
|
|
252
|
+
const rect = element.getBoundingClientRect();
|
|
253
|
+
const style = window.getComputedStyle(element);
|
|
254
|
+
const px = (v) => Number.parseFloat(v) || 0;
|
|
255
|
+
return {
|
|
256
|
+
width: Math.max(0, rect.width
|
|
257
|
+
- px(style.borderLeftWidth) - px(style.borderRightWidth)
|
|
258
|
+
- px(style.paddingLeft) - px(style.paddingRight)),
|
|
259
|
+
height: Math.max(0, rect.height
|
|
260
|
+
- px(style.borderTopWidth) - px(style.borderBottomWidth)
|
|
261
|
+
- px(style.paddingTop) - px(style.paddingBottom)),
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Measure one cell with a canvas 2D context.
|
|
267
|
+
*
|
|
268
|
+
* Two deliberate differences from the old `renderer.measureFont()`:
|
|
269
|
+
*
|
|
270
|
+
* 1. **Fractional advance, averaged over a run.** The old code did
|
|
271
|
+
* `Math.ceil(measureText('M').width)`, which at 12px monospace turns a
|
|
272
|
+
* ~7.2px advance into 8px — cells ~11% too wide, so ~11% fewer columns fit
|
|
273
|
+
* and text is loosely spaced. We measure a 32-char run and divide, keeping
|
|
274
|
+
* the fraction; integer snapping happens once, in device pixels, in
|
|
275
|
+
* {@link TerminalGeometry.canvasBox}.
|
|
276
|
+
* 2. **Line height is explicit, not magic.** The old code added a bare `+2` px
|
|
277
|
+
* per row for glyph overflow — ~70px of lost height over 35 rows. Here the
|
|
278
|
+
* ratio is a named parameter (default 1.2, the conventional terminal line
|
|
279
|
+
* height) applied to the font's own ascent+descent.
|
|
280
|
+
*/
|
|
281
|
+
export function measureCellWithCanvas(opts) {
|
|
282
|
+
return () => {
|
|
283
|
+
const canvas = document.createElement('canvas');
|
|
284
|
+
const ctx = canvas.getContext('2d');
|
|
285
|
+
if (!ctx)
|
|
286
|
+
throw new Error('measureCellWithCanvas: 2D context unavailable');
|
|
287
|
+
ctx.font = `${opts.fontSize}px ${opts.fontFamily}`;
|
|
288
|
+
// Average over a run: per-glyph advances are fractional and rounding a
|
|
289
|
+
// single glyph biases every column position downstream.
|
|
290
|
+
const sample = 'MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'; // 32 × 'M'
|
|
291
|
+
const width = ctx.measureText(sample).width / sample.length;
|
|
292
|
+
const probe = ctx.measureText('Mg');
|
|
293
|
+
const ascent = probe.actualBoundingBoxAscent || opts.fontSize * 0.8;
|
|
294
|
+
const descent = probe.actualBoundingBoxDescent || opts.fontSize * 0.2;
|
|
295
|
+
const height = (ascent + descent) * (opts.lineHeight ?? 1.2);
|
|
296
|
+
return { width, height, baseline: ascent + (height - (ascent + descent)) / 2 };
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/browser-terminal/geometry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAwEH;;;;GAIG;AACH,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,MAAM,OAAO,gBAAgB;IACV,IAAI,CAA0B;IACvC,QAAQ,CAAc;IACtB,SAAS,CAAW;IACpB,QAAQ,GAAoB,IAAI,CAAC;IACxB,SAAS,GAAG,IAAI,GAAG,EAA+B,CAAC;IAEpE,YAAY,IAA6B;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;IAC1C,CAAC;IAED,iDAAiD;IACjD,IAAI,OAAO;QACT,OAAO,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;IAED,6EAA6E;IAC7E,IAAI,QAAQ;QACV,OAAO,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IAC/B,CAAC;IAED;;;OAG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