| 1 |
/** |
| 2 |
* Copyright (c) 2019 The xterm.js authors. All rights reserved. |
| 3 |
* @license MIT |
| 4 |
*/ |
| 5 |
|
| 6 |
import { CHAR_DATA_CODE_INDEX, NULL_CELL_CODE, WHITESPACE_CELL_CODE } from 'common/buffer/Constants'; |
| 7 |
import { IBufferService } from 'common/services/Services'; |
| 8 |
|
| 9 |
export function updateWindowsModeWrappedState(bufferService: IBufferService): void { |
| 10 |
// Winpty does not support wraparound mode which means that lines will never |
| 11 |
// be marked as wrapped. This causes issues for things like copying a line |
| 12 |
// retaining the wrapped new line characters or if consumers are listening |
| 13 |
// in on the data stream. |
| 14 |
// |
| 15 |
// The workaround for this is to listen to every incoming line feed and mark |
| 16 |
// the line as wrapped if the last character in the previous line is not a |
| 17 |
// space. This is certainly not without its problems, but generally on |
| 18 |
// Windows when text reaches the end of the terminal it's likely going to be |
| 19 |
// wrapped. |
| 20 |
const line = bufferService.buffer.lines.get(bufferService.buffer.ybase + bufferService.buffer.y - 1); |
| 21 |
const lastChar = line?.get(bufferService.cols - 1); |
| 22 |
|
| 23 |
const nextLine = bufferService.buffer.lines.get(bufferService.buffer.ybase + bufferService.buffer.y); |
| 24 |
if (nextLine && lastChar) { |
| 25 |
nextLine.isWrapped = (lastChar[CHAR_DATA_CODE_INDEX] !== NULL_CELL_CODE && lastChar[CHAR_DATA_CODE_INDEX] !== WHITESPACE_CELL_CODE); |
| 26 |
} |
| 27 |
} |