diff --git a/src/InputHandler.ts b/src/InputHandler.ts index 574d29b8..259a2b1c 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -2094,7 +2094,7 @@ export class InputHandler extends Disposable implements IInputHandler { if (rs) { const w = rs.dimensions.actualCellWidth.toFixed(0); const h = rs.dimensions.actualCellHeight.toFixed(0); - this._coreService.triggerDataEvent(`${C0.ESC}[4;${h};${w}t`); + this._coreService.triggerDataEvent(`${C0.ESC}[6;${h};${w}t`); } break; case 18: // GetWinSizeChars, returns CSI 8 ; height ; width t diff --git a/test/api/InputHandler.api.ts b/test/api/InputHandler.api.ts index fe068610..991c5cb5 100644 --- a/test/api/InputHandler.api.ts +++ b/test/api/InputHandler.api.ts @@ -346,6 +346,51 @@ describe('InputHandler Integration Tests', function(): void { `); assert.deepEqual(await getLinesAsArray(3), ['#', ' #', 'abcd####']); }); + + describe.only('Window Options - CSI Ps ; Ps ; Ps t', () => { + it('should be disabled by default', async function() { + assert.equal(await page.evaluate(`(() => window.term.getOption('allowedWindowOps'))()`), ''); + await page.evaluate(`(() => { + window._stack = []; + const _h = window.term.onData(data => window._stack.push(data)); + window.term.write('\x1b[14t'); + window.term.write('\x1b[16t'); + window.term.write('\x1b[18t'); + window.term.write('\x1b[20t'); + window.term.write('\x1b[21t'); + return new Promise((r) => window.term.write('', () => { _h.dispose(); r(); })); + })()`); + assert.deepEqual(await page.evaluate(`(() => _stack)()`), []); + }); + it('14 - GetWinSizePixels', async function() { + assert.equal(await page.evaluate(`(() => { + window.term.setOption('allowedWindowOps', 'GetWinSizePixels'); + return window.term.getOption('allowedWindowOps'); + })()`), '14'); + await page.evaluate(`(() => { + window._stack = []; + const _h = window.term.onData(data => window._stack.push(data)); + window.term.write('\x1b[14t'); + return new Promise((r) => window.term.write('', () => { _h.dispose(); r(); })); + })()`); + const d = await getDimensions(); + assert.deepEqual(await page.evaluate(`(() => _stack)()`), [`\x1b[4;${d.height};${d.width}t`]); + }); + it('16 - GetCellSizePixels', async function() { + assert.equal(await page.evaluate(`(() => { + window.term.setOption('allowedWindowOps', 'GetCellSizePixels'); + return window.term.getOption('allowedWindowOps'); + })()`), '16'); + await page.evaluate(`(() => { + window._stack = []; + const _h = window.term.onData(data => window._stack.push(data)); + window.term.write('\x1b[16t'); + return new Promise((r) => window.term.write('', () => { _h.dispose(); r(); })); + })()`); + const d = await getDimensions(); + assert.deepEqual(await page.evaluate(`(() => _stack)()`), [`\x1b[6;${d.cellHeight};${d.cellWidth}t`]); + }); + }); }); describe('ESC', () => { @@ -404,3 +449,17 @@ async function getCursor(): Promise<{col: number, row: number}> { })(); `); } + +async function getDimensions(): Promise { + const dim = await page.evaluate(` + (function() { + return term._core._renderService.dimensions; + })(); + `); + return { + cellWidth: dim.actualCellWidth.toFixed(0), + cellHeight: dim.actualCellHeight.toFixed(0), + width: dim.canvasWidth.toFixed(0), + height: dim.canvasHeight.toFixed(0) + }; +}