Make cols/rows only usable in the ctor

Fixes #3825
This commit is contained in:
Daniel Imms
2022-07-28 11:16:12 -07:00
parent 04b513cf9b
commit 006249ce65
3 changed files with 21 additions and 15 deletions
+1 -1
View File
@@ -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);
}
}
})
+2 -2
View File
@@ -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> {
@@ -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');
+18 -12
View File
@@ -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 {
/**
@@ -55,11 +55,6 @@ declare module 'xterm' {
*/
convertEol?: boolean;
/**
* The number of columns in the terminal.
*/
cols?: number;
/**
* Whether the cursor blinks.
*/
@@ -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
@@ -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.
*/
@@ -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.