diff --git a/src/browser/Terminal.test.ts b/src/browser/Terminal.test.ts index 8d52b505..eaf420ed 100644 --- a/src/browser/Terminal.test.ts +++ b/src/browser/Terminal.test.ts @@ -469,7 +469,7 @@ describe('Terminal', () => { describe('when scrollback === 0', () => { beforeEach(() => { - term.optionsService.setOption('scrollback', 0); + term.optionsService.options.scrollback = 0; assert.equal(term.buffer.lines.maxLength, INIT_ROWS); }); @@ -1346,7 +1346,7 @@ describe('Terminal', () => { term = new TestTerminal({}); markers = []; disposeStack = []; - term.optionsService.setOption('scrollback', 1); + term.optionsService.options.scrollback = 1; term.resize(10, 5); markers.push(term.buffers.active.addMarker(term.buffers.active.y)); await term.writeP('\x1b[r0\r\n'); diff --git a/src/browser/TestUtils.test.ts b/src/browser/TestUtils.test.ts index 62dc611e..d59119e7 100644 --- a/src/browser/TestUtils.test.ts +++ b/src/browser/TestUtils.test.ts @@ -137,9 +137,6 @@ export class MockTerminal implements ITerminal { public write(data: string): void { throw new Error('Method not implemented.'); } - public writeUtf8(data: Uint8Array): void { - throw new Error('Method not implemented.'); - } public bracketedPasteMode!: boolean; public renderer!: IRenderer; public linkifier2!: ILinkifier2; diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 53904cf9..65f26db0 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -219,9 +219,6 @@ export class Terminal implements ITerminalApi { public write(data: string | Uint8Array, callback?: () => void): void { this._core.write(data, callback); } - public writeUtf8(data: Uint8Array, callback?: () => void): void { - this._core.write(data, callback); - } public writeln(data: string | Uint8Array, callback?: () => void): void { this._core.write(data); this._core.write('\r\n', callback); @@ -229,27 +226,6 @@ export class Terminal implements ITerminalApi { public paste(data: string): void { this._core.paste(data); } - public getOption(key: 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; - public getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord'): boolean; - public getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; - public getOption(key: 'fontWeight' | 'fontWeightBold'): FontWeight; - public getOption(key: string): any; - public getOption(key: any): any { - return this._core.optionsService.getOption(key); - } - public setOption(key: 'fontFamily' | 'termName' | 'wordSeparator', value: string): void; - public setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; - public setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void; - public setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void; - public setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord', value: boolean): void; - public setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; - public setOption(key: 'theme', value: ITheme): void; - public setOption(key: 'cols' | 'rows', value: number): void; - public setOption(key: string, value: any): void; - public setOption(key: any, value: any): void { - this._checkReadonlyOptions(key); - this._core.optionsService.setOption(key, value); - } public refresh(start: number, end: number): void { this._verifyIntegers(start, end); this._core.refresh(start, end); diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index 6b5c1425..aad2c466 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -694,7 +694,7 @@ export class SelectionService extends Disposable implements ISelectionService { this._removeMouseDownListeners(); - if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME && event.altKey && this._optionsService.getOption('altClickMovesCursor')) { + if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME && event.altKey && this._optionsService.rawOptions.altClickMovesCursor) { if (this._bufferService.buffer.ybase === this._bufferService.buffer.ydisp) { const coordinates = this._mouseService.getCoords( event, diff --git a/src/common/TestUtils.test.ts b/src/common/TestUtils.test.ts index 11d9a8c5..48f3a69e 100644 --- a/src/common/TestUtils.test.ts +++ b/src/common/TestUtils.test.ts @@ -136,12 +136,6 @@ export class MockOptionsService implements IOptionsService { this.options[key] = options[key]; } } - public setOption(key: string, value: T): void { - throw new Error('Method not implemented.'); - } - public getOption(key: string): T { - throw new Error('Method not implemented.'); - } } // defaults to V6 always to keep tests passing diff --git a/src/common/services/OptionsService.test.ts b/src/common/services/OptionsService.test.ts index ae9e77ec..a65cb986 100644 --- a/src/common/services/OptionsService.test.ts +++ b/src/common/services/OptionsService.test.ts @@ -17,16 +17,16 @@ describe('OptionsService', () => { }); it('uses default value if invalid constructor option values passed for cols/rows', () => { const optionsService = new OptionsService({ cols: undefined, rows: undefined }); - assert.equal(optionsService.getOption('rows'), DEFAULT_OPTIONS.rows); - assert.equal(optionsService.getOption('cols'), DEFAULT_OPTIONS.cols); + assert.equal(optionsService.options.rows, DEFAULT_OPTIONS.rows); + assert.equal(optionsService.options.cols, DEFAULT_OPTIONS.cols); }); it('uses values from constructor option values if correctly passed', () => { const optionsService = new OptionsService({ cols: 80, rows: 25 }); - assert.equal(optionsService.getOption('rows'), 25); - assert.equal(optionsService.getOption('cols'), 80); + assert.equal(optionsService.options.rows, 25); + assert.equal(optionsService.options.cols, 80); }); it('uses default value if invalid constructor option value passed', () => { - assert.equal(new OptionsService({ tabStopWidth: 0 }).getOption('tabStopWidth'), DEFAULT_OPTIONS.tabStopWidth); + assert.equal(new OptionsService({ tabStopWidth: 0 }).options.tabStopWidth, DEFAULT_OPTIONS.tabStopWidth); }); it('object.keys return the correct number of options', () => { const optionsService = new OptionsService({ cols: 80, rows: 25 }); @@ -39,36 +39,36 @@ describe('OptionsService', () => { service = new OptionsService({}); }); it('applies valid fontWeight option values', () => { - service.setOption('fontWeight', 'bold'); - assert.equal(service.getOption('fontWeight'), 'bold', '"bold" keyword value should be applied'); + service.options.fontWeight = 'bold'; + assert.equal(service.options.fontWeight, 'bold', '"bold" keyword value should be applied'); - service.setOption('fontWeight', 'normal'); - assert.equal(service.getOption('fontWeight'), 'normal', '"normal" keyword value should be applied'); + service.options.fontWeight = 'normal'; + assert.equal(service.options.fontWeight, 'normal', '"normal" keyword value should be applied'); - service.setOption('fontWeight', '600'); - assert.equal(service.getOption('fontWeight'), '600', 'String numeric values should be applied'); + service.options.fontWeight = '600'; + assert.equal(service.options.fontWeight, '600', 'String numeric values should be applied'); - service.setOption('fontWeight', 350); - assert.equal(service.getOption('fontWeight'), 350, 'Values between 1 and 1000 should be applied as is'); + service.options.fontWeight = 350; + assert.equal(service.options.fontWeight, 350, 'Values between 1 and 1000 should be applied as is'); - service.setOption('fontWeight', 1); - assert.equal(service.getOption('fontWeight'), 1, 'Range should include minimum value: 1'); + service.options.fontWeight = 1; + assert.equal(service.options.fontWeight, 1, 'Range should include minimum value: 1'); - service.setOption('fontWeight', 1000); - assert.equal(service.getOption('fontWeight'), 1000, 'Range should include maximum value: 1000'); + service.options.fontWeight = 1000; + assert.equal(service.options.fontWeight, 1000, 'Range should include maximum value: 1000'); }); it('normalizes invalid fontWeight option values', () => { - service.setOption('fontWeight', 350); - assert.doesNotThrow(() => service.setOption('fontWeight', 10000), 'fontWeight should be normalized instead of throwing'); - assert.equal(service.getOption('fontWeight'), DEFAULT_OPTIONS.fontWeight, 'Values greater than 1000 should be reset to default'); + service.options.fontWeight = 350; + assert.doesNotThrow(() => service.options.fontWeight = 10000), 'fontWeight should be normalized instead of throwing'; + assert.equal(service.options.fontWeight, DEFAULT_OPTIONS.fontWeight, 'Values greater than 1000 should be reset to default'); - service.setOption('fontWeight', 350); - service.setOption('fontWeight', -10); - assert.equal(service.getOption('fontWeight'), DEFAULT_OPTIONS.fontWeight, 'Values less than 1 should be reset to default'); + service.options.fontWeight = 350; + service.options.fontWeight = -10; + assert.equal(service.options.fontWeight, DEFAULT_OPTIONS.fontWeight, 'Values less than 1 should be reset to default'); - service.setOption('fontWeight', 350); - service.setOption('fontWeight', 'bold700'); - assert.equal(service.getOption('fontWeight'), DEFAULT_OPTIONS.fontWeight, 'Wrong string literals should be reset to default'); + service.options.fontWeight = 350; + service.options.fontWeight = 'bold700' as any; + assert.equal(service.options.fontWeight, DEFAULT_OPTIONS.fontWeight, 'Wrong string literals should be reset to default'); }); }); }); diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index 0a2c81a3..911cc9b2 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -109,10 +109,6 @@ export class OptionsService implements IOptionsService { } } - public setOption(key: string, value: any): void { - this.options[key] = value; - } - private _sanitizeAndValidateOption(key: string, value: any): any { switch (key) { case 'cursorStyle': @@ -170,10 +166,6 @@ export class OptionsService implements IOptionsService { } return value; } - - public getOption(key: string): any { - return this.options[key]; - } } function isCursorStyle(value: unknown): value is CursorStyle { diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index a7830b4d..22bff06d 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -198,9 +198,6 @@ export interface IOptionsService { readonly options: ITerminalOptions; readonly onOptionChange: IEvent; - - setOption(key: string, value: T): void; - getOption(key: string): T | undefined; } export type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number; diff --git a/src/headless/public/Terminal.test.ts b/src/headless/public/Terminal.test.ts index 403cf35a..7f341b91 100644 --- a/src/headless/public/Terminal.test.ts +++ b/src/headless/public/Terminal.test.ts @@ -114,12 +114,6 @@ describe('Headless API Tests', function (): void { } }); - it('getOption, setOption', async () => { - strictEqual(term.getOption('scrollback'), 1000); - term.setOption('scrollback', 50); - strictEqual(term.getOption('scrollback'), 50); - }); - describe('options', () => { const termOptions = { cols: 80, diff --git a/src/headless/public/Terminal.ts b/src/headless/public/Terminal.ts index 01c0eab0..451d2372 100644 --- a/src/headless/public/Terminal.ts +++ b/src/headless/public/Terminal.ts @@ -172,31 +172,10 @@ export class Terminal implements ITerminalApi { public write(data: string | Uint8Array, callback?: () => void): void { this._core.write(data, callback); } - public writeUtf8(data: Uint8Array, callback?: () => void): void { - this._core.write(data, callback); - } public writeln(data: string | Uint8Array, callback?: () => void): void { this._core.write(data); this._core.write('\r\n', callback); } - public getOption(key: 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; - public getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord'): boolean; - public getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; - public getOption(key: string): any; - public getOption(key: any): any { - return this._core.optionsService.getOption(key); - } - public setOption(key: 'fontFamily' | 'termName' | 'wordSeparator', value: string): void; - public setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; - public setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void; - public setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void; - public setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord', value: boolean): void; - public setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; - public setOption(key: 'cols' | 'rows', value: number): void; - public setOption(key: string, value: any): void; - public setOption(key: any, value: any): void { - this._core.optionsService.setOption(key, value); - } public reset(): void { this._core.reset(); } diff --git a/test/api/Terminal.api.ts b/test/api/Terminal.api.ts index bf5875d0..80e46be0 100644 --- a/test/api/Terminal.api.ts +++ b/test/api/Terminal.api.ts @@ -154,13 +154,6 @@ describe('API Integration Tests', function(): void { } }); - it('getOption, setOption', async () => { - await openTerminal(page); - assert.equal(await page.evaluate(`window.term.getOption('rendererType')`), 'canvas'); - await page.evaluate(`window.term.setOption('rendererType', 'dom')`); - assert.equal(await page.evaluate(`window.term.getOption('rendererType')`), 'dom'); - }); - describe('options', () => { it('getter', async () => { await openTerminal(page); diff --git a/typings/xterm-headless.d.ts b/typings/xterm-headless.d.ts index 44868cdf..c2b77acc 100644 --- a/typings/xterm-headless.d.ts +++ b/typings/xterm-headless.d.ts @@ -689,90 +689,6 @@ declare module 'xterm-headless' { */ writeln(data: string | Uint8Array, callback?: () => void): void; - /** - * Write UTF8 data to the terminal. - * @param data The data to write to the terminal. - * @param callback Optional callback when data was processed. - * @deprecated use `write` instead - */ - writeUtf8(data: Uint8Array, callback?: () => void): void; - - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - */ - getOption(key: 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - */ - getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'windowsMode'): boolean; - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - */ - getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - */ - getOption(key: string): any; - - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'fontFamily' | 'termName' | 'wordSeparator', value: string): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'fontWeight' | 'fontWeightBold', value: null | 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'logLevel', value: LogLevel): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'cursorStyle', value: null | 'block' | 'underline' | 'bar'): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'windowsMode', value: boolean): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'theme', value: ITheme): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: 'cols' | 'rows', value: number): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - */ - setOption(key: string, value: any): void; - /** * Perform a full reset (RIS, aka '\x1bc'). */ diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 058eb656..eb90202c 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -1021,115 +1021,12 @@ declare module 'xterm' { */ writeln(data: string | Uint8Array, callback?: () => void): void; - /** - * Write UTF8 data to the terminal. - * @param data The data to write to the terminal. - * @param callback Optional callback when data was processed. - * @deprecated use `write` instead - */ - writeUtf8(data: Uint8Array, callback?: () => void): void; - /** * Writes text to the terminal, performing the necessary transformations for pasted text. * @param data The text to write to the terminal. */ paste(data: string): void; - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - * @deprecated Use `options` instead. - */ - getOption(key: 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - * @deprecated Use `options` instead. - */ - getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'windowsMode'): boolean; - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - * @deprecated Use `options` instead. - */ - getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - * @deprecated Use `options` instead. - */ - getOption(key: 'fontWeight' | 'fontWeightBold'): FontWeight; - /** - * Retrieves an option's value from the terminal. - * @param key The option key. - * @deprecated Use `options` instead. - */ - getOption(key: string): any; - - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - * @deprecated Use `options` instead. - */ - setOption(key: 'fontFamily' | 'termName' | 'wordSeparator', value: string): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - * @deprecated Use `options` instead. - */ - setOption(key: 'fontWeight' | 'fontWeightBold', value: null | 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - * @deprecated Use `options` instead. - */ - setOption(key: 'logLevel', value: LogLevel): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - * @deprecated Use `options` instead. - */ - setOption(key: 'cursorStyle', value: null | 'block' | 'underline' | 'bar'): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - * @deprecated Use `options` instead. - */ - setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'windowsMode', value: boolean): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - * @deprecated Use `options` instead. - */ - setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - * @deprecated Use `options` instead. - */ - setOption(key: 'theme', value: ITheme): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - * @deprecated Use `options` instead. - */ - setOption(key: 'cols' | 'rows', value: number): void; - /** - * Sets an option on the terminal. - * @param key The option key. - * @param value The option value. - * @deprecated Use `options` instead. - */ - setOption(key: string, value: any): void; - /** * Tells the renderer to refresh terminal content between two rows * (inclusive) at the next opportunity.