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

Method select

lib/selection-manager.ts:257–282  ·  view source on GitHub ↗

* Select text at specific column and row with length * xterm.js compatible API

(column: number, row: number, length: number)

Source from the content-addressed store, hash-verified

255 * xterm.js compatible API
256 */
257 select(column: number, row: number, length: number): void {
258 // Clamp to valid ranges
259 const dims = this.wasmTerm.getDimensions();
260 row = Math.max(0, Math.min(row, dims.rows - 1));
261 column = Math.max(0, Math.min(column, dims.cols - 1));
262
263 // Calculate end position
264 let endRow = row;
265 let endCol = column + length - 1;
266
267 // Handle wrapping if selection extends past end of line
268 while (endCol >= dims.cols) {
269 endCol -= dims.cols;
270 endRow++;
271 }
272
273 // Clamp end row
274 endRow = Math.min(endRow, dims.rows - 1);
275
276 // Convert viewport rows to absolute rows
277 const viewportY = this.getViewportY();
278 this.selectionStart = { col: column, absoluteRow: viewportY + row };
279 this.selectionEnd = { col: endCol, absoluteRow: viewportY + endRow };
280 this.requestRender();
281 this.selectionChangedEmitter.fire();
282 }
283
284 /**
285 * Select entire lines from start to end

Callers 2

attachEventListenersMethod · 0.45
copyToClipboardMethod · 0.45

Calls 4

getViewportYMethod · 0.95
requestRenderMethod · 0.95
getDimensionsMethod · 0.65
fireMethod · 0.45

Tested by

no test coverage detected