| 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 |