Skip to content

Commit

Permalink
Merge pull request #3960 from Tyriar/init_options
Browse files Browse the repository at this point in the history
Make cols/rows only usable in the ctor
  • Loading branch information
Tyriar authored Jul 29, 2022
2 parents 29aca47 + 006249c commit 7f5ed40
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion addons/xterm-addon-ligatures/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function enableLigatures(term: Terminal): void {

// Only refresh things if we actually found a font
if (f) {
term.refresh(0, term.options.rows! - 1);
term.refresh(0, term.rows - 1);
}
}
})
Expand Down
4 changes: 2 additions & 2 deletions test/api/TestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import * as playwright from 'playwright';
import deepEqual = require('deep-equal');
import { ITerminalOptions } from 'xterm';
import { ITerminalInitOnlyOptions, ITerminalOptions } from 'xterm';
import { deepStrictEqual, fail } from 'assert';

export async function pollFor<T>(page: playwright.Page, evalOrFn: string | (() => Promise<T>), val: T, preFn?: () => Promise<void>, maxDuration?: number): Promise<void> {
Expand Down Expand Up @@ -43,7 +43,7 @@ export async function timeout(ms: number): Promise<void> {
return new Promise<void>(r => setTimeout(r, ms));
}

export async function openTerminal(page: playwright.Page, options: ITerminalOptions = {}): Promise<void> {
export async function openTerminal(page: playwright.Page, options: ITerminalOptions & ITerminalInitOnlyOptions = {}): Promise<void> {
await page.evaluate(`window.term = new Terminal(${JSON.stringify({ allowProposedApi: true, ...options })})`);
await page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`);
await page.waitForSelector('.xterm-rows');
Expand Down
30 changes: 18 additions & 12 deletions typings/xterm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ declare module 'xterm' {
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 @@ -55,11 +55,6 @@ declare module 'xterm' {
*/
convertEol?: boolean;

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

/**
* Whether the cursor blinks.
*/
Expand Down Expand Up @@ -177,11 +172,6 @@ declare module 'xterm' {
*/
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 @@ -248,6 +238,22 @@ declare module 'xterm' {
overviewRulerWidth?: number;
}

/**
* 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 @@ -714,7 +720,7 @@ declare module 'xterm' {
*
* @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

0 comments on commit 7f5ed40

Please sign in to comment.