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

Make cols/rows only usable in the ctor #3960

Merged
merged 1 commit into from
Jul 29, 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
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