Merge branch 'master' into keydup
This commit is contained in:
@@ -126,8 +126,6 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
||||
public readonly onCursorMove = this._onCursorMove.event;
|
||||
private readonly _onKey = this._register(new Emitter<{ key: string, domEvent: KeyboardEvent }>());
|
||||
public readonly onKey = this._onKey.event;
|
||||
private readonly _onRender = this._register(new Emitter<{ start: number, end: number }>());
|
||||
public readonly onRender = this._onRender.event;
|
||||
private readonly _onSelectionChange = this._register(new Emitter<void>());
|
||||
public readonly onSelectionChange = this._onSelectionChange.event;
|
||||
private readonly _onTitleChange = this._register(new Emitter<string>());
|
||||
|
||||
@@ -75,7 +75,7 @@ export class OscLinkProvider implements ILinkProvider {
|
||||
if (!['http:', 'https:'].includes(parsed.protocol)) {
|
||||
ignoreLink = true;
|
||||
}
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// Ignore invalid URLs to prevent unexpected behaviors
|
||||
ignoreLink = true;
|
||||
}
|
||||
|
||||
@@ -1079,47 +1079,6 @@ describe('Terminal', () => {
|
||||
assert.equal(windowsModeTerminal.buffer.lines.get(2)!.isWrapped, false);
|
||||
});
|
||||
});
|
||||
describe('Windows Mode', () => {
|
||||
it('should mark lines as wrapped when the line ends in a non-null character after a LF', async () => {
|
||||
const data = [
|
||||
'aaaaaaaaaa\n\r', // cannot wrap as it's the first
|
||||
'aaaaaaaaa\n\r', // wrapped (windows mode only)
|
||||
'aaaaaaaaa' // not wrapped
|
||||
];
|
||||
|
||||
const normalTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: false });
|
||||
await normalTerminal.writeP(data.join(''));
|
||||
assert.equal(normalTerminal.buffer.lines.get(0)!.isWrapped, false);
|
||||
assert.equal(normalTerminal.buffer.lines.get(1)!.isWrapped, false);
|
||||
assert.equal(normalTerminal.buffer.lines.get(2)!.isWrapped, false);
|
||||
|
||||
const windowsModeTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: true });
|
||||
await windowsModeTerminal.writeP(data.join(''));
|
||||
assert.equal(windowsModeTerminal.buffer.lines.get(0)!.isWrapped, false);
|
||||
assert.equal(windowsModeTerminal.buffer.lines.get(1)!.isWrapped, true, 'This line should wrap in Windows mode as the previous line ends in a non-null character');
|
||||
assert.equal(windowsModeTerminal.buffer.lines.get(2)!.isWrapped, false);
|
||||
});
|
||||
|
||||
it('should mark lines as wrapped when the line ends in a non-null character after a CUP', async () => {
|
||||
const data = [
|
||||
'aaaaaaaaaa\x1b[2;1H', // cannot wrap as it's the first
|
||||
'aaaaaaaaa\x1b[3;1H', // wrapped (windows mode only)
|
||||
'aaaaaaaaa' // not wrapped
|
||||
];
|
||||
|
||||
const normalTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: false });
|
||||
await normalTerminal.writeP(data.join(''));
|
||||
assert.equal(normalTerminal.buffer.lines.get(0)!.isWrapped, false);
|
||||
assert.equal(normalTerminal.buffer.lines.get(1)!.isWrapped, false);
|
||||
assert.equal(normalTerminal.buffer.lines.get(2)!.isWrapped, false);
|
||||
|
||||
const windowsModeTerminal = new TestTerminal({ rows: 5, cols: 10, windowsMode: true });
|
||||
await windowsModeTerminal.writeP(data.join(''));
|
||||
assert.equal(windowsModeTerminal.buffer.lines.get(0)!.isWrapped, false);
|
||||
assert.equal(windowsModeTerminal.buffer.lines.get(1)!.isWrapped, true, 'This line should wrap in Windows mode as the previous line ends in a non-null character');
|
||||
assert.equal(windowsModeTerminal.buffer.lines.get(2)!.isWrapped, false);
|
||||
});
|
||||
});
|
||||
it('convertEol setting', async () => {
|
||||
// not converting
|
||||
const termNotConverting = new TestTerminal({ cols: 15, rows: 10 });
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import * as glob from 'glob';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import * as fs from 'fs';
|
||||
@@ -15,7 +14,10 @@ import { IDisposable } from '@xterm/xterm';
|
||||
const COLS = 80;
|
||||
const ROWS = 25;
|
||||
|
||||
const TESTFILES = glob.sync('**/escape_sequence_files/*.in', { cwd: path.join(__dirname, '../..')});
|
||||
const escapeSequenceFilesDir = path.join(__dirname, '../../fixtures/escape_sequence_files');
|
||||
const TESTFILES = fs.readdirSync(escapeSequenceFilesDir)
|
||||
.filter(f => f.endsWith('.in'))
|
||||
.map(f => path.join(escapeSequenceFilesDir, f));
|
||||
const SKIP_FILES = [
|
||||
't0055-EL.in', // EL/ED handle cursor at cols differently (see #3362)
|
||||
't0084-CBT.in',
|
||||
@@ -33,7 +35,7 @@ if (os.platform() === 'darwin') {
|
||||
);
|
||||
}
|
||||
// filter skipFilenames
|
||||
const FILES = TESTFILES.filter(value => !SKIP_FILES.includes(value.split('/').slice(-1)[0]));
|
||||
const FILES = TESTFILES.filter(value => !SKIP_FILES.includes(path.basename(value)));
|
||||
|
||||
describe('Escape Sequence Files', function(): void {
|
||||
this.timeout(1000);
|
||||
@@ -62,7 +64,7 @@ describe('Escape Sequence Files', function(): void {
|
||||
});
|
||||
|
||||
for (const filename of FILES) {
|
||||
(process.platform === 'win32' ? it.skip : it)(filename.split('/').slice(-1)[0], async () => {
|
||||
(process.platform === 'win32' ? it.skip : it)(path.basename(filename), async () => {
|
||||
// reset terminal and handler
|
||||
if (customHandler) {
|
||||
customHandler.dispose();
|
||||
@@ -88,7 +90,7 @@ describe('Escape Sequence Files', function(): void {
|
||||
});
|
||||
|
||||
// compare with expected output (right trimmed)
|
||||
const expected = fs.readFileSync(filename.split('.')[0] + '.text', 'utf8');
|
||||
const expected = fs.readFileSync(filename.replace(/\.in$/, '.text'), 'utf8');
|
||||
const expectedRightTrimmed = expected.split('\n').map(l => l.replace(/\s+$/, '')).join('\n');
|
||||
if (content !== expectedRightTrimmed) {
|
||||
throw new Error(formatError(fs.readFileSync(filename, 'utf8'), content, expected));
|
||||
|
||||
@@ -45,7 +45,7 @@ export class TimeBasedDebouncer implements IRenderDebouncer {
|
||||
|
||||
// Only refresh if the time since last refresh is above a threshold, otherwise wait for
|
||||
// enough time to pass before refreshing again.
|
||||
const refreshRequestTime: number = Date.now();
|
||||
const refreshRequestTime: number = performance.now();
|
||||
if (refreshRequestTime - this._lastRefreshMs >= this._debounceThresholdMS) {
|
||||
// Enough time has lapsed since the last refresh; refresh immediately
|
||||
this._lastRefreshMs = refreshRequestTime;
|
||||
@@ -57,7 +57,7 @@ export class TimeBasedDebouncer implements IRenderDebouncer {
|
||||
this._additionalRefreshRequested = true;
|
||||
|
||||
this._refreshTimeoutID = window.setTimeout(() => {
|
||||
this._lastRefreshMs = Date.now();
|
||||
this._lastRefreshMs = performance.now();
|
||||
this._innerRefresh();
|
||||
this._additionalRefreshRequested = false;
|
||||
this._refreshTimeoutID = undefined; // No longer need to clear the timeout
|
||||
|
||||
@@ -9,7 +9,7 @@ import { ColorZoneStore } from 'browser/decorations/ColorZoneStore';
|
||||
const optionsRedFull = {
|
||||
overviewRulerOptions: {
|
||||
color: 'red',
|
||||
position: 'full' as 'full'
|
||||
position: 'full' as const
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -123,6 +123,7 @@ export class Terminal extends Disposable implements ITerminalApi {
|
||||
originMode: m.origin,
|
||||
reverseWraparoundMode: m.reverseWraparound,
|
||||
sendFocusMode: m.sendFocus,
|
||||
synchronizedOutputMode: m.synchronizedOutput,
|
||||
wraparoundMode: m.wraparound
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import { IRenderDimensions, IRenderer } from 'browser/renderer/shared/Types';
|
||||
import { ICharSizeService, ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
|
||||
import { Disposable, MutableDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { DebouncedIdleTask } from 'common/TaskQueue';
|
||||
import { IBufferService, IDecorationService, IOptionsService } from 'common/services/Services';
|
||||
import { IBufferService, ICoreService, IDecorationService, IOptionsService } from 'common/services/Services';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
|
||||
interface ISelectionState {
|
||||
@@ -18,6 +18,10 @@ interface ISelectionState {
|
||||
columnSelectMode: boolean;
|
||||
}
|
||||
|
||||
const enum Constants {
|
||||
SYNCHRONIZED_OUTPUT_TIMEOUT_MS = 1000
|
||||
}
|
||||
|
||||
export class RenderService extends Disposable implements IRenderService {
|
||||
public serviceBrand: undefined;
|
||||
|
||||
@@ -32,6 +36,7 @@ export class RenderService extends Disposable implements IRenderService {
|
||||
private _needsSelectionRefresh: boolean = false;
|
||||
private _canvasWidth: number = 0;
|
||||
private _canvasHeight: number = 0;
|
||||
private _syncOutputHandler: SynchronizedOutputHandler;
|
||||
private _selectionState: ISelectionState = {
|
||||
start: undefined,
|
||||
end: undefined,
|
||||
@@ -52,23 +57,31 @@ export class RenderService extends Disposable implements IRenderService {
|
||||
constructor(
|
||||
private _rowCount: number,
|
||||
screenElement: HTMLElement,
|
||||
@IOptionsService optionsService: IOptionsService,
|
||||
@IOptionsService private readonly _optionsService: IOptionsService,
|
||||
@ICharSizeService private readonly _charSizeService: ICharSizeService,
|
||||
@ICoreService private readonly _coreService: ICoreService,
|
||||
@IDecorationService decorationService: IDecorationService,
|
||||
@IBufferService bufferService: IBufferService,
|
||||
@ICoreBrowserService coreBrowserService: ICoreBrowserService,
|
||||
@ICoreBrowserService private readonly _coreBrowserService: ICoreBrowserService,
|
||||
@IThemeService themeService: IThemeService
|
||||
) {
|
||||
super();
|
||||
|
||||
this._renderDebouncer = new RenderDebouncer((start, end) => this._renderRows(start, end), coreBrowserService);
|
||||
this._renderDebouncer = new RenderDebouncer((start, end) => this._renderRows(start, end), this._coreBrowserService);
|
||||
this._register(this._renderDebouncer);
|
||||
|
||||
this._register(coreBrowserService.onDprChange(() => this.handleDevicePixelRatioChange()));
|
||||
this._syncOutputHandler = new SynchronizedOutputHandler(
|
||||
this._coreBrowserService,
|
||||
this._coreService,
|
||||
() => this._fullRefresh()
|
||||
);
|
||||
this._register(toDisposable(() => this._syncOutputHandler.dispose()));
|
||||
|
||||
this._register(this._coreBrowserService.onDprChange(() => this.handleDevicePixelRatioChange()));
|
||||
|
||||
this._register(bufferService.onResize(() => this._fullRefresh()));
|
||||
this._register(bufferService.buffers.onBufferActivate(() => this._renderer.value?.clear()));
|
||||
this._register(optionsService.onOptionChange(() => this._handleOptionsChanged()));
|
||||
this._register(this._optionsService.onOptionChange(() => this._handleOptionsChanged()));
|
||||
this._register(this._charSizeService.onCharSizeChange(() => this.handleCharSizeChanged()));
|
||||
|
||||
// Do a full refresh whenever any decoration is added or removed. This may not actually result
|
||||
@@ -78,8 +91,7 @@ export class RenderService extends Disposable implements IRenderService {
|
||||
this._register(decorationService.onDecorationRemoved(() => this._fullRefresh()));
|
||||
|
||||
// Clear the renderer when the a change that could affect glyphs occurs
|
||||
this._register(optionsService.onMultipleOptionChange([
|
||||
'customGlyphs',
|
||||
this._register(this._optionsService.onMultipleOptionChange([
|
||||
'drawBoldTextInBrightColors',
|
||||
'letterSpacing',
|
||||
'lineHeight',
|
||||
@@ -96,15 +108,15 @@ export class RenderService extends Disposable implements IRenderService {
|
||||
}));
|
||||
|
||||
// Refresh the cursor line when the cursor changes
|
||||
this._register(optionsService.onMultipleOptionChange([
|
||||
this._register(this._optionsService.onMultipleOptionChange([
|
||||
'cursorBlink',
|
||||
'cursorStyle'
|
||||
], () => this.refreshRows(bufferService.buffer.y, bufferService.buffer.y, true)));
|
||||
|
||||
this._register(themeService.onChangeColors(() => this._fullRefresh()));
|
||||
|
||||
this._registerIntersectionObserver(coreBrowserService.window, screenElement);
|
||||
this._register(coreBrowserService.onWindowChange((w) => this._registerIntersectionObserver(w, screenElement)));
|
||||
this._registerIntersectionObserver(this._coreBrowserService.window, screenElement);
|
||||
this._register(this._coreBrowserService.onWindowChange((w) => this._registerIntersectionObserver(w, screenElement)));
|
||||
}
|
||||
|
||||
private _registerIntersectionObserver(w: Window & typeof globalThis, screenElement: HTMLElement): void {
|
||||
@@ -137,6 +149,18 @@ export class RenderService extends Disposable implements IRenderService {
|
||||
this._needsFullRefresh = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._coreService.decPrivateModes.synchronizedOutput) {
|
||||
this._syncOutputHandler.bufferRows(start, end);
|
||||
return;
|
||||
}
|
||||
|
||||
const buffered = this._syncOutputHandler.flush();
|
||||
if (buffered) {
|
||||
start = Math.min(start, buffered.start);
|
||||
end = Math.max(end, buffered.end);
|
||||
}
|
||||
|
||||
if (!isRedrawOnly) {
|
||||
this._isNextRenderRedrawOnly = false;
|
||||
}
|
||||
@@ -148,6 +172,13 @@ export class RenderService extends Disposable implements IRenderService {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip rendering if synchronized output mode is enabled. This check must happen here
|
||||
// (in addition to refreshRows) to handle renders that were queued before the mode was enabled.
|
||||
if (this._coreService.decPrivateModes.synchronizedOutput) {
|
||||
this._syncOutputHandler.bufferRows(start, end);
|
||||
return;
|
||||
}
|
||||
|
||||
// Since this is debounced, a resize event could have happened between the time a refresh was
|
||||
// requested and when this triggers. Clamp the values of start and end to ensure they're valid
|
||||
// given the current viewport state.
|
||||
@@ -283,3 +314,62 @@ export class RenderService extends Disposable implements IRenderService {
|
||||
this._renderer.value?.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Buffers row refresh requests during synchronized output mode (DEC mode 2026).
|
||||
* When the mode is disabled, the accumulated row range is flushed for rendering.
|
||||
* A safety timeout ensures rendering occurs even if the end sequence is not received.
|
||||
*/
|
||||
class SynchronizedOutputHandler {
|
||||
private _start: number = 0;
|
||||
private _end: number = 0;
|
||||
private _timeout: number | undefined;
|
||||
private _isBuffering: boolean = false;
|
||||
|
||||
constructor(
|
||||
private readonly _coreBrowserService: ICoreBrowserService,
|
||||
private readonly _coreService: ICoreService,
|
||||
private readonly _onTimeout: () => void
|
||||
) {}
|
||||
|
||||
public bufferRows(start: number, end: number): void {
|
||||
if (!this._isBuffering) {
|
||||
this._start = start;
|
||||
this._end = end;
|
||||
this._isBuffering = true;
|
||||
} else {
|
||||
this._start = Math.min(this._start, start);
|
||||
this._end = Math.max(this._end, end);
|
||||
}
|
||||
|
||||
if (this._timeout === undefined) {
|
||||
this._timeout = this._coreBrowserService.window.setTimeout(() => {
|
||||
this._timeout = undefined;
|
||||
this._coreService.decPrivateModes.synchronizedOutput = false;
|
||||
this._onTimeout();
|
||||
}, Constants.SYNCHRONIZED_OUTPUT_TIMEOUT_MS);
|
||||
}
|
||||
}
|
||||
|
||||
public flush(): { start: number, end: number } | undefined {
|
||||
if (this._timeout !== undefined) {
|
||||
this._coreBrowserService.window.clearTimeout(this._timeout);
|
||||
this._timeout = undefined;
|
||||
}
|
||||
|
||||
if (!this._isBuffering) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const result = { start: this._start, end: this._end };
|
||||
this._isBuffering = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
if (this._timeout !== undefined) {
|
||||
this._coreBrowserService.window.clearTimeout(this._timeout);
|
||||
this._timeout = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
|
||||
public readonly onData = this._onData.event;
|
||||
protected _onLineFeed = this._register(new Emitter<void>());
|
||||
public readonly onLineFeed = this._onLineFeed.event;
|
||||
protected readonly _onRender = this._register(new Emitter<{ start: number, end: number }>());
|
||||
public readonly onRender = this._onRender.event;
|
||||
private readonly _onResize = this._register(new Emitter<{ cols: number, rows: number }>());
|
||||
public readonly onResize = this._onResize.event;
|
||||
protected readonly _onWriteParsed = this._register(new Emitter<void>());
|
||||
@@ -124,7 +126,6 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
|
||||
// Register input handler and handle/forward events
|
||||
this._inputHandler = this._register(new InputHandler(this._bufferService, this._charsetService, this.coreService, this._logService, this.optionsService, this._oscLinkService, this.coreMouseService, this.unicodeService));
|
||||
this._register(Event.forward(this._inputHandler.onLineFeed, this._onLineFeed));
|
||||
this._register(this._inputHandler);
|
||||
|
||||
// Setup listeners
|
||||
this._register(Event.forward(this._bufferService.onResize, this._onResize));
|
||||
@@ -132,7 +133,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
|
||||
this._register(Event.forward(this.coreService.onBinary, this._onBinary));
|
||||
this._register(this.coreService.onRequestScrollToBottom(() => this.scrollToBottom(true)));
|
||||
this._register(this.coreService.onUserInput(() => this._writeBuffer.handleUserInput()));
|
||||
this._register(this.optionsService.onMultipleOptionChange(['windowsMode', 'windowsPty'], () => this._handleWindowsPtyOptionChange()));
|
||||
this._register(this.optionsService.onMultipleOptionChange(['windowsPty'], () => this._handleWindowsPtyOptionChange()));
|
||||
this._register(this._bufferService.onScroll(() => {
|
||||
this._onScroll.fire({ position: this._bufferService.buffer.ydisp });
|
||||
this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom);
|
||||
@@ -255,8 +256,6 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
|
||||
const windowsPty = this.optionsService.rawOptions.windowsPty;
|
||||
if (windowsPty && windowsPty.buildNumber !== undefined && windowsPty.buildNumber !== undefined) {
|
||||
value = !!(windowsPty.backend === 'conpty' && windowsPty.buildNumber < 21376);
|
||||
} else if (this.optionsService.rawOptions.windowsMode) {
|
||||
value = true;
|
||||
}
|
||||
if (value) {
|
||||
this._enableWindowsWrappingHeuristics();
|
||||
|
||||
@@ -1582,6 +1582,28 @@ describe('InputHandler', () => {
|
||||
assert.equal(bufferService.cols, 132);
|
||||
});
|
||||
});
|
||||
describe('XTVERSION (CSI > q, CSI > 0 q)', () => {
|
||||
it('should report xterm.js version', async () => {
|
||||
const stack: string[] = [];
|
||||
coreService.onData(data => stack.push(data));
|
||||
await inputHandler.parseP('\x1b[>q');
|
||||
assert.strictEqual(stack.length, 1);
|
||||
assert.ok(stack[0].match(/^\x1bP>\|xterm\.js\(\d+\.\d+\.\d+(-beta\.\d+)?\)\x1b\\/));
|
||||
});
|
||||
it('should report xterm.js version for CSI > 0 q', async () => {
|
||||
const stack: string[] = [];
|
||||
coreService.onData(data => stack.push(data));
|
||||
await inputHandler.parseP('\x1b[>0q');
|
||||
assert.strictEqual(stack.length, 1);
|
||||
assert.ok(stack[0].match(/^\x1bP>\|xterm\.js\(\d+\.\d+\.\d+(-beta\.\d+)?\)\x1b\\/));
|
||||
});
|
||||
it('should not report for CSI > 1 q', async () => {
|
||||
const stack: string[] = [];
|
||||
coreService.onData(data => stack.push(data));
|
||||
await inputHandler.parseP('\x1b[>1q');
|
||||
assert.strictEqual(stack.length, 0);
|
||||
});
|
||||
});
|
||||
describe('should correctly reset cells taken by wide chars', () => {
|
||||
beforeEach(async () => {
|
||||
bufferService.resize(10, 5);
|
||||
@@ -2314,7 +2336,7 @@ describe('InputHandler', () => {
|
||||
});
|
||||
it('DEC privates with set/reset semantic', async () => {
|
||||
// initially reset
|
||||
const reset = [1, 6, 9, 12, 45, 66, 1000, 1002, 1003, 1004, 1006, 1016, 47, 1047, 1049, 2004];
|
||||
const reset = [1, 6, 9, 12, 45, 66, 1000, 1002, 1003, 1004, 1006, 1016, 47, 1047, 1049, 2004, 2026];
|
||||
for (const mode of reset) {
|
||||
await inputHandler.parseP(`\x1b[?${mode}$p`);
|
||||
assert.deepEqual(reportStack.pop(), `\x1b[?${mode};2$y`); // initial reset
|
||||
|
||||
@@ -22,6 +22,7 @@ import { DcsHandler } from 'common/parser/DcsParser';
|
||||
import { IBuffer } from 'common/buffer/Types';
|
||||
import { parseColor } from 'common/input/XParseColor';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { XTERM_VERSION } from 'common/Version';
|
||||
|
||||
/**
|
||||
* Map collect to glevel. Used in `selectCharset`.
|
||||
@@ -256,6 +257,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
this._parser.registerCsiHandler({ final: 'n' }, params => this.deviceStatus(params));
|
||||
this._parser.registerCsiHandler({ prefix: '?', final: 'n' }, params => this.deviceStatusPrivate(params));
|
||||
this._parser.registerCsiHandler({ intermediates: '!', final: 'p' }, params => this.softReset(params));
|
||||
this._parser.registerCsiHandler({ prefix: '>', final: 'q' }, params => this.sendXtVersion(params));
|
||||
this._parser.registerCsiHandler({ intermediates: ' ', final: 'q' }, params => this.setCursorStyle(params));
|
||||
this._parser.registerCsiHandler({ final: 'r' }, params => this.setScrollRegion(params));
|
||||
this._parser.registerCsiHandler({ final: 's' }, params => this.saveCursor(params));
|
||||
@@ -1721,6 +1723,22 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* CSI > Ps q
|
||||
* Ps = 0 => Report xterm name and version (XTVERSION).
|
||||
*
|
||||
* The response is a DCS sequence identifying the version: DCS > | text ST
|
||||
*
|
||||
* @vt: #Y CSI XTVERSION "Report Xterm Version" "CSI > q" "Report the terminal name and version."
|
||||
*/
|
||||
public sendXtVersion(params: IParams): boolean {
|
||||
if (params.params[0] > 0) {
|
||||
return true;
|
||||
}
|
||||
this._coreService.triggerDataEvent(`${C0.ESC}P>|xterm.js(${XTERM_VERSION})${C0.ESC}\\`);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate if the current terminal is the given argument.
|
||||
* @param term The terminal name to evaluate
|
||||
@@ -1969,6 +1987,9 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
case 2004: // bracketed paste mode (https://cirw.in/blog/bracketed-paste)
|
||||
this._coreService.decPrivateModes.bracketedPasteMode = true;
|
||||
break;
|
||||
case 2026: // synchronized output (https://github.com/contour-terminal/vt-extensions/blob/master/synchronized-output.md)
|
||||
this._coreService.decPrivateModes.synchronizedOutput = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -2197,6 +2218,10 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
case 2004: // bracketed paste mode (https://cirw.in/blog/bracketed-paste)
|
||||
this._coreService.decPrivateModes.bracketedPasteMode = false;
|
||||
break;
|
||||
case 2026: // synchronized output (https://github.com/contour-terminal/vt-extensions/blob/master/synchronized-output.md)
|
||||
this._coreService.decPrivateModes.synchronizedOutput = false;
|
||||
this._onRequestRefreshRows.fire(undefined);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -2291,6 +2316,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
if (p === 1048) return f(p, V.SET); // xterm always returns SET here
|
||||
if (p === 47 || p === 1047 || p === 1049) return f(p, b2v(active === alt));
|
||||
if (p === 2004) return f(p, b2v(dm.bracketedPasteMode));
|
||||
if (p === 2026) return f(p, b2v(dm.synchronizedOutput));
|
||||
return f(p, V.NOT_RECOGNIZED);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,14 +74,14 @@ abstract class TaskQueue implements ITaskQueue {
|
||||
let lastDeadlineRemaining = deadline.timeRemaining();
|
||||
let deadlineRemaining = 0;
|
||||
while (this._i < this._tasks.length) {
|
||||
taskDuration = Date.now();
|
||||
taskDuration = performance.now();
|
||||
if (!this._tasks[this._i]()) {
|
||||
this._i++;
|
||||
}
|
||||
// other than performance.now, Date.now might not be stable (changes on wall clock changes),
|
||||
// this is not an issue here as a clock change during a short running task is very unlikely
|
||||
// in case it still happened and leads to negative duration, simply assume 1 msec
|
||||
taskDuration = Math.max(1, Date.now() - taskDuration);
|
||||
// other than performance.now, performance.now might not be stable (changes on wall clock
|
||||
// changes), this is not an issue here as a clock change during a short running task is very
|
||||
// unlikely in case it still happened and leads to negative duration, simply assume 1 msec
|
||||
taskDuration = Math.max(1, performance.now() - taskDuration);
|
||||
longestTask = Math.max(taskDuration, longestTask);
|
||||
// Guess the following task will take a similar time to the longest task in this batch, allow
|
||||
// additional room to try avoid exceeding the deadline
|
||||
@@ -116,9 +116,9 @@ export class PriorityTaskQueue extends TaskQueue {
|
||||
}
|
||||
|
||||
private _createDeadline(duration: number): ITaskDeadline {
|
||||
const end = Date.now() + duration;
|
||||
const end = performance.now() + duration;
|
||||
return {
|
||||
timeRemaining: () => Math.max(0, end - Date.now())
|
||||
timeRemaining: () => Math.max(0, end - performance.now())
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ export class MockCoreService implements ICoreService {
|
||||
origin: false,
|
||||
reverseWraparound: false,
|
||||
sendFocus: false,
|
||||
synchronizedOutput: false,
|
||||
wraparound: true
|
||||
};
|
||||
public onData: Event<string> = new Emitter<string>().event;
|
||||
|
||||
+2
-1
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { IDeleteEvent, IInsertEvent } from 'common/CircularList';
|
||||
import { Attributes, UnderlineStyle } from 'common/buffer/Constants'; // eslint-disable-line no-unused-vars
|
||||
import { UnderlineStyle } from 'common/buffer/Constants';
|
||||
import { IBufferSet } from 'common/buffer/Types';
|
||||
import { IParams } from 'common/parser/Types';
|
||||
import { ICoreMouseService, ICoreService, IOptionsService, IUnicodeService } from 'common/services/Services';
|
||||
@@ -273,6 +273,7 @@ export interface IDecPrivateModes {
|
||||
origin: boolean;
|
||||
reverseWraparound: boolean;
|
||||
sendFocus: boolean;
|
||||
synchronizedOutput: boolean;
|
||||
wraparound: boolean; // defaults: xterm - true, vt100 - false
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) 2025 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* The xterm.js version. This is updated by the publish script from package.json.
|
||||
*/
|
||||
export const XTERM_VERSION = '6.0.0';
|
||||
@@ -181,7 +181,7 @@ export class Buffer implements IBuffer {
|
||||
if (this._rows < newRows) {
|
||||
for (let y = this._rows; y < newRows; y++) {
|
||||
if (this.lines.length < newRows + this.ybase) {
|
||||
if (this._optionsService.rawOptions.windowsMode || this._optionsService.rawOptions.windowsPty.backend !== undefined || this._optionsService.rawOptions.windowsPty.buildNumber !== undefined) {
|
||||
if (this._optionsService.rawOptions.windowsPty.backend !== undefined || this._optionsService.rawOptions.windowsPty.buildNumber !== undefined) {
|
||||
// Just add the new missing rows on Windows as conpty reprints the screen with it's
|
||||
// view of the world. Once a line enters scrollback for conpty it remains there
|
||||
this.lines.push(new BufferLine(newCols, nullCell));
|
||||
@@ -298,7 +298,7 @@ export class Buffer implements IBuffer {
|
||||
if (windowsPty && windowsPty.buildNumber) {
|
||||
return this._hasScrollback && windowsPty.backend === 'conpty' && windowsPty.buildNumber >= 21376;
|
||||
}
|
||||
return this._hasScrollback && !this._optionsService.rawOptions.windowsMode;
|
||||
return this._hasScrollback;
|
||||
}
|
||||
|
||||
private _reflow(newCols: number, newRows: number): void {
|
||||
|
||||
@@ -246,7 +246,7 @@ CHARSETS['='] = {
|
||||
'\\': 'ç',
|
||||
']': 'ê',
|
||||
'^': 'î',
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
|
||||
'_': 'è',
|
||||
'`': 'ô',
|
||||
'{': 'ä',
|
||||
|
||||
@@ -315,6 +315,8 @@ export function evaluateKeyboardEvent(
|
||||
result.key = String.fromCharCode(ev.keyCode - 51 + 27);
|
||||
} else if (ev.keyCode === 56) {
|
||||
result.key = C0.DEL;
|
||||
} else if (ev.key === '/') {
|
||||
result.key = C0.US; // https://github.com/xtermjs/xterm.js/issues/5457
|
||||
} else if (ev.keyCode === 219) {
|
||||
result.key = C0.ESC;
|
||||
} else if (ev.keyCode === 220) {
|
||||
|
||||
@@ -137,7 +137,7 @@ export class WriteBuffer extends Disposable {
|
||||
* effectively lowering the redrawing needs, schematically:
|
||||
*
|
||||
* macroTask _innerWrite:
|
||||
* if (Date.now() - (lastTime | 0) < WRITE_TIMEOUT_MS):
|
||||
* if (performance.now() - (lastTime | 0) < WRITE_TIMEOUT_MS):
|
||||
* schedule microTask _innerWrite(lastTime)
|
||||
* else:
|
||||
* schedule macroTask _innerWrite(0)
|
||||
@@ -158,7 +158,7 @@ export class WriteBuffer extends Disposable {
|
||||
* Note, for pure sync code `lastTime` and `promiseResult` have no meaning.
|
||||
*/
|
||||
protected _innerWrite(lastTime: number = 0, promiseResult: boolean = true): void {
|
||||
const startTime = lastTime || Date.now();
|
||||
const startTime = lastTime || performance.now();
|
||||
while (this._writeBuffer.length > this._bufferOffset) {
|
||||
const data = this._writeBuffer[this._bufferOffset];
|
||||
const result = this._action(data, promiseResult);
|
||||
@@ -186,7 +186,7 @@ export class WriteBuffer extends Disposable {
|
||||
* responsibility to slice hard work), but we can at least schedule a screen update as we
|
||||
* gain control.
|
||||
*/
|
||||
const continuation: (r: boolean) => void = (r: boolean) => Date.now() - startTime >= WRITE_TIMEOUT_MS
|
||||
const continuation: (r: boolean) => void = (r: boolean) => performance.now() - startTime >= WRITE_TIMEOUT_MS
|
||||
? setTimeout(() => this._innerWrite(0, r))
|
||||
: this._innerWrite(startTime, r);
|
||||
|
||||
@@ -202,7 +202,8 @@ export class WriteBuffer extends Disposable {
|
||||
* throughput by eval'ing `startTime` upfront pulling at least one more chunk into the
|
||||
* current microtask queue (executed before setTimeout).
|
||||
*/
|
||||
// const continuation: (r: boolean) => void = Date.now() - startTime >= WRITE_TIMEOUT_MS
|
||||
// const continuation: (r: boolean) => void = performance.now() - startTime >=
|
||||
// WRITE_TIMEOUT_MS
|
||||
// ? r => setTimeout(() => this._innerWrite(0, r))
|
||||
// : r => this._innerWrite(startTime, r);
|
||||
|
||||
@@ -222,7 +223,7 @@ export class WriteBuffer extends Disposable {
|
||||
this._bufferOffset++;
|
||||
this._pendingData -= data.length;
|
||||
|
||||
if (Date.now() - startTime >= WRITE_TIMEOUT_MS) {
|
||||
if (performance.now() - startTime >= WRITE_TIMEOUT_MS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ const DEFAULT_DEC_PRIVATE_MODES: IDecPrivateModes = Object.freeze({
|
||||
origin: false,
|
||||
reverseWraparound: false,
|
||||
sendFocus: false,
|
||||
synchronizedOutput: false,
|
||||
wraparound: true // defaults: xterm - true, vt100 - false
|
||||
});
|
||||
|
||||
|
||||
@@ -16,10 +16,8 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
|
||||
cursorStyle: 'block',
|
||||
cursorWidth: 1,
|
||||
cursorInactiveStyle: 'outline',
|
||||
customGlyphs: true,
|
||||
drawBoldTextInBrightColors: true,
|
||||
documentOverride: null,
|
||||
fastScrollModifier: 'alt',
|
||||
fastScrollSensitivity: 5,
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 15,
|
||||
@@ -49,7 +47,6 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
|
||||
rescaleOverlappingGlyphs: false,
|
||||
rightClickSelectsWord: isMac,
|
||||
windowOptions: {},
|
||||
windowsMode: false,
|
||||
windowsPty: {},
|
||||
wordSeparator: ' ()[]{}\',"`',
|
||||
altClickMovesCursor: true,
|
||||
|
||||
@@ -230,12 +230,9 @@ export interface ITerminalOptions {
|
||||
cursorStyle?: CursorStyle;
|
||||
cursorWidth?: number;
|
||||
cursorInactiveStyle?: CursorInactiveStyle;
|
||||
customGlyphs?: boolean;
|
||||
disableStdin?: boolean;
|
||||
documentOverride?: any | null;
|
||||
drawBoldTextInBrightColors?: boolean;
|
||||
/** @deprecated No longer supported */
|
||||
fastScrollModifier?: 'none' | 'alt' | 'ctrl' | 'shift';
|
||||
fastScrollSensitivity?: number;
|
||||
fontSize?: number;
|
||||
fontFamily?: string;
|
||||
@@ -261,7 +258,6 @@ export interface ITerminalOptions {
|
||||
smoothScrollDuration?: number;
|
||||
tabStopWidth?: number;
|
||||
theme?: ITheme;
|
||||
windowsMode?: boolean;
|
||||
windowsPty?: IWindowsPty;
|
||||
windowOptions?: IWindowOptions;
|
||||
wordSeparator?: string;
|
||||
|
||||
@@ -53,6 +53,7 @@ export class Terminal extends CoreTerminal {
|
||||
this._register(Event.forward(this._inputHandler.onTitleChange, this._onTitleChange));
|
||||
this._register(Event.forward(this._inputHandler.onA11yChar, this._onA11yCharEmitter));
|
||||
this._register(Event.forward(this._inputHandler.onA11yTab, this._onA11yTabEmitter));
|
||||
this._register(Event.forward(Event.map(this._inputHandler.onRequestRefreshRows, e => ({ start: e?.start ?? 0, end: e?.end ?? this.rows - 1 })), this._onRender));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -202,6 +202,15 @@ describe('Headless API Tests', function (): void {
|
||||
strictEqual(callCount, 2);
|
||||
});
|
||||
|
||||
it('onRender', async () => {
|
||||
const calls: { start: number, end: number }[] = [];
|
||||
term.onRender(e => calls.push(e));
|
||||
await writeSync('foo');
|
||||
deepStrictEqual(calls, [{ start: 0, end: 0 }]);
|
||||
await writeSync('\n\nbar');
|
||||
deepStrictEqual(calls, [{ start: 0, end: 0 }, { start: 0, end: 2 }]);
|
||||
});
|
||||
|
||||
it('onScroll', async () => {
|
||||
term = new Terminal({ rows: 5 });
|
||||
const calls: number[] = [];
|
||||
@@ -400,6 +409,7 @@ describe('Headless API Tests', function (): void {
|
||||
originMode: false,
|
||||
reverseWraparoundMode: false,
|
||||
sendFocusMode: false,
|
||||
synchronizedOutputMode: false,
|
||||
wraparoundMode: true
|
||||
});
|
||||
});
|
||||
|
||||
@@ -77,6 +77,7 @@ export class Terminal extends Disposable implements ITerminalApi {
|
||||
public get onCursorMove(): Event<void> { return this._core.onCursorMove; }
|
||||
public get onData(): Event<string> { return this._core.onData; }
|
||||
public get onLineFeed(): Event<void> { return this._core.onLineFeed; }
|
||||
public get onRender(): Event<{ start: number, end: number }> { return this._core.onRender; }
|
||||
public get onResize(): Event<{ cols: number, rows: number }> { return this._core.onResize; }
|
||||
public get onScroll(): Event<number> { return this._core.onScroll; }
|
||||
public get onTitleChange(): Event<string> { return this._core.onTitleChange; }
|
||||
@@ -124,6 +125,7 @@ export class Terminal extends Disposable implements ITerminalApi {
|
||||
originMode: m.origin,
|
||||
reverseWraparoundMode: m.reverseWraparound,
|
||||
sendFocusMode: m.sendFocus,
|
||||
synchronizedOutputMode: m.synchronizedOutput,
|
||||
wraparoundMode: m.wraparound
|
||||
};
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ node ./bin/vs_base_find_unused.js
|
||||
|
||||
The last step is to do a once over of the resulting bundled xterm.js file to ensure it isn't too large:
|
||||
|
||||
1. Run `yarn esbuild`
|
||||
1. Run `npm run esbuild`
|
||||
2. Open up `xterm.mjs`
|
||||
3. Search for `src/vs/base/`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user