Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply row/col changes from xterm to xterm-headless #3972

Merged
merged 3 commits into from
Jul 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/headless/public/Terminal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,10 @@ describe('Headless API Tests', function (): void {
});
it('get options', () => {
const options: ITerminalOptions = term.options;
strictEqual(options.cols, 80);
strictEqual(options.rows, 24);
strictEqual(options.lineHeight, 1);
strictEqual(options.cursorWidth, 1);
});
it('set options', async () => {
const options: ITerminalOptions = term.options;
throws(() => options.cols = 40);
throws(() => options.rows = 20);
term.options.scrollback = 1;
strictEqual(term.options.scrollback, 1);
term.options= {
Expand Down
5 changes: 2 additions & 3 deletions src/headless/public/Terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import { IEvent } from 'common/EventEmitter';
import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi';
import { ParserApi } from 'common/public/ParserApi';
import { UnicodeApi } from 'common/public/UnicodeApi';
import { IBufferNamespace as IBufferNamespaceApi, IMarker, IModes, IParser, ITerminalAddon, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-headless';
import { IBufferNamespace as IBufferNamespaceApi, IMarker, IModes, IParser, ITerminalAddon, ITerminalInitOnlyOptions, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-headless';
import { Terminal as TerminalCore } from 'headless/Terminal';
import { AddonManager } from 'common/public/AddonManager';
import { ITerminalOptions } from 'common/Types';

/**
* The set of options that only have an effect when set in the Terminal constructor.
*/
Expand All @@ -24,7 +23,7 @@ export class Terminal implements ITerminalApi {
private _buffer: BufferNamespaceApi | undefined;
private _publicOptions: ITerminalOptions;

constructor(options?: ITerminalOptions) {
constructor(options?: ITerminalOptions & ITerminalInitOnlyOptions) {
this._core = new TerminalCore(options);
this._addonManager = new AddonManager();

Expand Down
30 changes: 18 additions & 12 deletions typings/xterm-headless.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ declare module 'xterm-headless' {
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off';

/**
* An object containing start up options for the terminal.
* An object containing options for the terminal.
*/
export interface ITerminalOptions {
/**
Expand Down Expand Up @@ -48,11 +48,6 @@ declare module 'xterm-headless' {
*/
convertEol?: boolean;

/**
* The number of columns in the terminal.
*/
cols?: number;

/**
* Whether the cursor blinks.
*/
Expand Down Expand Up @@ -145,11 +140,6 @@ declare module 'xterm-headless' {
*/
rightClickSelectsWord?: boolean;

/**
* The number of rows in the terminal.
*/
rows?: number;

/**
* Whether screen reader support is enabled. When on this will expose
* supporting elements in the DOM to support NVDA on Windows and VoiceOver
Expand Down Expand Up @@ -210,6 +200,22 @@ declare module 'xterm-headless' {
windowOptions?: IWindowOptions;
}

/**
* An object containing additional options for the terminal that can only be
* set on start up.
*/
export interface ITerminalInitOnlyOptions {
/**
* The number of columns in the terminal.
*/
cols?: number;

/**
* The number of rows in the terminal.
*/
rows?: number;
}

/**
* Contains colors to theme the terminal with.
*/
Expand Down Expand Up @@ -558,7 +564,7 @@ declare module 'xterm-headless' {
*
* @param options An object containing a set of options.
*/
constructor(options?: ITerminalOptions);
constructor(options?: ITerminalOptions & ITerminalInitOnlyOptions);

/**
* Adds an event listener for when the bell is triggered.
Expand Down