restty 0.1.33 → 0.1.34
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.
|
@@ -19634,11 +19634,18 @@ function normalizeSelectionCell(cell, rows, cols, wideFlags) {
|
|
|
19634
19634
|
}
|
|
19635
19635
|
return { row, col };
|
|
19636
19636
|
}
|
|
19637
|
-
function positionToCell(clientX, clientY, canvasRect, dpr, cellW, cellH, cols, rows) {
|
|
19638
|
-
const
|
|
19639
|
-
const
|
|
19640
|
-
const
|
|
19641
|
-
const
|
|
19637
|
+
function positionToCell(clientX, clientY, canvasRect, dpr, cellW, cellH, cols, rows, canvasWidth, canvasHeight) {
|
|
19638
|
+
const safeDpr = dpr || 1;
|
|
19639
|
+
const safeCols = cols || 1;
|
|
19640
|
+
const safeRows = rows || 1;
|
|
19641
|
+
const safeCellW = cellW || 1;
|
|
19642
|
+
const safeCellH = cellH || 1;
|
|
19643
|
+
const scaleX = canvasRect.width > 0 ? (canvasWidth && canvasWidth > 0 ? canvasWidth : safeDpr) / canvasRect.width : safeDpr;
|
|
19644
|
+
const scaleY = canvasRect.height > 0 ? (canvasHeight && canvasHeight > 0 ? canvasHeight : safeDpr) / canvasRect.height : safeDpr;
|
|
19645
|
+
const x = (clientX - canvasRect.left) * scaleX;
|
|
19646
|
+
const y = (clientY - canvasRect.top) * scaleY;
|
|
19647
|
+
const col = clamp(Math.floor(x / safeCellW), 0, safeCols - 1);
|
|
19648
|
+
const row = clamp(Math.floor(y / safeCellH), 0, safeRows - 1);
|
|
19642
19649
|
return { row, col };
|
|
19643
19650
|
}
|
|
19644
19651
|
|
|
@@ -59506,13 +59513,16 @@ function createRuntimeInteraction(options) {
|
|
|
59506
59513
|
const canvas = getCanvas();
|
|
59507
59514
|
const rect2 = canvas.getBoundingClientRect();
|
|
59508
59515
|
const { cellW, cellH, cols, rows } = getGridState();
|
|
59509
|
-
return positionToCell(event.clientX, event.clientY, rect2, getCurrentDpr(), cellW || 1, cellH || 1, cols || 1, rows || 1);
|
|
59516
|
+
return positionToCell(event.clientX, event.clientY, rect2, getCurrentDpr(), cellW || 1, cellH || 1, cols || 1, rows || 1, canvas.width, canvas.height);
|
|
59510
59517
|
};
|
|
59511
59518
|
const positionToPixel = (event) => {
|
|
59512
59519
|
const canvas = getCanvas();
|
|
59513
59520
|
const rect2 = canvas.getBoundingClientRect();
|
|
59514
|
-
const
|
|
59515
|
-
const
|
|
59521
|
+
const fallbackScale = getCurrentDpr() || 1;
|
|
59522
|
+
const scaleX = rect2.width > 0 ? canvas.width / rect2.width : fallbackScale;
|
|
59523
|
+
const scaleY = rect2.height > 0 ? canvas.height / rect2.height : fallbackScale;
|
|
59524
|
+
const x3 = (event.clientX - rect2.left) * scaleX;
|
|
59525
|
+
const y = (event.clientY - rect2.top) * scaleY;
|
|
59516
59526
|
return {
|
|
59517
59527
|
x: Math.max(1, Math.round(x3 + 1)),
|
|
59518
59528
|
y: Math.max(1, Math.round(y + 1))
|
package/dist/internal.js
CHANGED
package/dist/restty.js
CHANGED
package/dist/selection/core.d.ts
CHANGED
|
@@ -23,4 +23,4 @@ export declare function selectionForRow(state: SelectionState, row: number, cols
|
|
|
23
23
|
*/
|
|
24
24
|
export declare function normalizeSelectionCell(cell: CellPosition | null, rows: number, cols: number, wideFlags?: Uint8Array | null): CellPosition | null;
|
|
25
25
|
/** Convert client pixel coordinates to a grid cell position. */
|
|
26
|
-
export declare function positionToCell(clientX: number, clientY: number, canvasRect: DOMRect, dpr: number, cellW: number, cellH: number, cols: number, rows: number): CellPosition;
|
|
26
|
+
export declare function positionToCell(clientX: number, clientY: number, canvasRect: DOMRect, dpr: number, cellW: number, cellH: number, cols: number, rows: number, canvasWidth?: number, canvasHeight?: number): CellPosition;
|
package/dist/xterm.js
CHANGED