MCPcopy
hub / github.com/xtermjs/xterm.js / _syncTextArea

Method _syncTextArea

src/browser/CoreBrowserTerminal.ts:301–325  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

299 }
300
301 private _syncTextArea(): void {
302 if (!this.textarea || !this.buffer.isCursorInViewport || this._compositionHelper!.isComposing || !this._renderService) {
303 return;
304 }
305 const cursorY = this.buffer.ybase + this.buffer.y;
306 const bufferLine = this.buffer.lines.get(cursorY);
307 if (!bufferLine) {
308 return;
309 }
310 const cursorX = Math.min(this.buffer.x, this.cols - 1);
311 const cellHeight = this._renderService.dimensions.css.cell.height;
312 const width = bufferLine.getWidth(cursorX);
313 const cellWidth = this._renderService.dimensions.css.cell.width * width;
314 const cursorTop = this.buffer.y * this._renderService.dimensions.css.cell.height;
315 const cursorLeft = cursorX * this._renderService.dimensions.css.cell.width;
316
317 // Sync the textarea to the exact position of the composition view so the IME knows where the
318 // text is.
319 this.textarea.style.left = cursorLeft + 'px';
320 this.textarea.style.top = cursorTop + 'px';
321 this.textarea.style.width = cellWidth + 'px';
322 this.textarea.style.height = cellHeight + 'px';
323 this.textarea.style.lineHeight = cellHeight + 'px';
324 this.textarea.style.zIndex = '-5';
325 }
326
327 /**
328 * Initialize default behavior

Callers 1

openMethod · 0.95

Calls 2

getMethod · 0.65
getWidthMethod · 0.65

Tested by

no test coverage detected