MCPcopy Create free account
hub / github.com/coder/ghostty-web / pixelToCell

Method pixelToCell

lib/selection-manager.ts:755–766  ·  view source on GitHub ↗

* Convert pixel coordinates to terminal cell coordinates

(x: number, y: number)

Source from the content-addressed store, hash-verified

753 * Convert pixel coordinates to terminal cell coordinates
754 */
755 private pixelToCell(x: number, y: number): { col: number; row: number } {
756 const metrics = this.renderer.getMetrics();
757
758 const col = Math.floor(x / metrics.width);
759 const row = Math.floor(y / metrics.height);
760
761 // Clamp to terminal bounds
762 return {
763 col: Math.max(0, Math.min(col, this.terminal.cols - 1)),
764 row: Math.max(0, Math.min(row, this.terminal.rows - 1)),
765 };
766 }
767
768 /**
769 * Normalize selection coordinates (handle backward selection)

Callers 1

attachEventListenersMethod · 0.95

Calls 1

getMetricsMethod · 0.80

Tested by

no test coverage detected