Merge pull request #2569 from Tyriar/layers6
Move WindowsMode to common/
This commit is contained in:
+9
-5
@@ -43,7 +43,7 @@ import { IKeyboardEvent, KeyboardResultType, ICharset, IBufferLine, IAttributeDa
|
|||||||
import { evaluateKeyboardEvent } from 'common/input/Keyboard';
|
import { evaluateKeyboardEvent } from 'common/input/Keyboard';
|
||||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||||
import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
|
import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
|
||||||
import { applyWindowsMode } from './WindowsMode';
|
import { handleWindowsModeLineFeed } from 'common/WindowsMode';
|
||||||
import { ColorManager } from 'browser/ColorManager';
|
import { ColorManager } from 'browser/ColorManager';
|
||||||
import { RenderService } from 'browser/services/RenderService';
|
import { RenderService } from 'browser/services/RenderService';
|
||||||
import { IOptionsService, IBufferService, ICoreMouseService, ICoreService, ILogService, IDirtyRowService, IInstantiationService } from 'common/services/Services';
|
import { IOptionsService, IBufferService, ICoreMouseService, ICoreService, ILogService, IDirtyRowService, IInstantiationService } from 'common/services/Services';
|
||||||
@@ -284,7 +284,13 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
|||||||
this.linkifier = this.linkifier || new Linkifier(this._bufferService, this._logService);
|
this.linkifier = this.linkifier || new Linkifier(this._bufferService, this._logService);
|
||||||
|
|
||||||
if (this.options.windowsMode) {
|
if (this.options.windowsMode) {
|
||||||
this._windowsMode = applyWindowsMode(this);
|
this._enableWindowsMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _enableWindowsMode(): void {
|
||||||
|
if (!this._windowsMode) {
|
||||||
|
this._windowsMode = this.onLineFeed(handleWindowsModeLineFeed.bind(null, this._bufferService));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,9 +372,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
|||||||
break;
|
break;
|
||||||
case 'windowsMode':
|
case 'windowsMode':
|
||||||
if (this.optionsService.options.windowsMode) {
|
if (this.optionsService.options.windowsMode) {
|
||||||
if (!this._windowsMode) {
|
this._enableWindowsMode();
|
||||||
this._windowsMode = applyWindowsMode(this);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this._windowsMode?.dispose();
|
this._windowsMode?.dispose();
|
||||||
this._windowsMode = undefined;
|
this._windowsMode = undefined;
|
||||||
|
|||||||
@@ -3,11 +3,10 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IDisposable } from 'xterm';
|
|
||||||
import { ITerminal } from './Types';
|
|
||||||
import { CHAR_DATA_CODE_INDEX, NULL_CELL_CODE, WHITESPACE_CELL_CODE } from 'common/buffer/Constants';
|
import { CHAR_DATA_CODE_INDEX, NULL_CELL_CODE, WHITESPACE_CELL_CODE } from 'common/buffer/Constants';
|
||||||
|
import { IBufferService } from 'common/services/Services';
|
||||||
|
|
||||||
export function applyWindowsMode(terminal: ITerminal): IDisposable {
|
export function handleWindowsModeLineFeed(bufferService: IBufferService): void {
|
||||||
// Winpty does not support wraparound mode which means that lines will never
|
// Winpty does not support wraparound mode which means that lines will never
|
||||||
// be marked as wrapped. This causes issues for things like copying a line
|
// be marked as wrapped. This causes issues for things like copying a line
|
||||||
// retaining the wrapped new line characters or if consumers are listening
|
// retaining the wrapped new line characters or if consumers are listening
|
||||||
@@ -18,11 +17,11 @@ export function applyWindowsMode(terminal: ITerminal): IDisposable {
|
|||||||
// space. This is certainly not without its problems, but generally on
|
// space. This is certainly not without its problems, but generally on
|
||||||
// Windows when text reaches the end of the terminal it's likely going to be
|
// Windows when text reaches the end of the terminal it's likely going to be
|
||||||
// wrapped.
|
// wrapped.
|
||||||
return terminal.onLineFeed(() => {
|
const line = bufferService.buffer.lines.get(bufferService.buffer.ybase + bufferService.buffer.y - 1);
|
||||||
const line = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y - 1);
|
const lastChar = line?.get(bufferService.cols - 1);
|
||||||
const lastChar = line.get(terminal.cols - 1);
|
|
||||||
|
|
||||||
const nextLine = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y);
|
const nextLine = bufferService.buffer.lines.get(bufferService.buffer.ybase + bufferService.buffer.y);
|
||||||
|
if (nextLine && lastChar) {
|
||||||
nextLine.isWrapped = (lastChar[CHAR_DATA_CODE_INDEX] !== NULL_CELL_CODE && lastChar[CHAR_DATA_CODE_INDEX] !== WHITESPACE_CELL_CODE);
|
nextLine.isWrapped = (lastChar[CHAR_DATA_CODE_INDEX] !== NULL_CELL_CODE && lastChar[CHAR_DATA_CODE_INDEX] !== WHITESPACE_CELL_CODE);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user