From cea3dd60b6de75d248d9df28d24243e58fe36590 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sun, 20 Aug 2017 11:43:40 -0700 Subject: [PATCH 1/2] Add cols and rows to d.ts --- typings/xterm.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 7ccd19435..ce9fd8f6c 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -87,9 +87,26 @@ declare module 'xterm' { * The class that represents an xterm.js terminal. */ export class Terminal { + /** + * The element containing the terminal. + */ element: HTMLElement; + + /** + * The textarea that accepts input for the terminal. + */ textarea: HTMLTextAreaElement; + /** + * The number of rows in the terminal's viewport. + */ + rows: number; + + /** + * The number of columns in the terminal's viewport. + */ + cols: number; + /** * Creates a new `Terminal` object. * From 8bc2242d9fe1823d8b2e3be9a98d889bfd71a048 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sun, 20 Aug 2017 11:45:42 -0700 Subject: [PATCH 2/2] Add generic overloads to overloaded functions in d.ts If we don't have this then tsc will throw errors when passing strings to the functions, seems wrong to force casting strings to use the functions, eg. <'bar'>style --- typings/xterm.d.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index ce9fd8f6c..ccc83ed90 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -172,13 +172,19 @@ declare module 'xterm' { * @param listener The listener. */ on(type: 'title', listener: (title?: string) => void): void; + /** + * Registers an event listener. + * @param type The type of the event. + * @param listener The listener. + */ + on(type: string, listener: (...args: any[]) => void): void; /** * Deregisters an event listener. * @param type The type of the event. * @param listener The listener. */ - off(type: 'blur' | 'focus' | 'lineFeed' | 'data' | 'key' | 'keypress' | 'keydown' | 'refresh' | 'resize' | 'scroll' | 'title', listener: (...args: any[]) => void): void; + off(type: 'blur' | 'focus' | 'lineFeed' | 'data' | 'key' | 'keypress' | 'keydown' | 'refresh' | 'resize' | 'scroll' | 'title' | string, listener: (...args: any[]) => void): void; /** * Resizes the terminal. @@ -333,6 +339,11 @@ declare module 'xterm' { * @param key The option key. */ getOption(key: 'handler'): (data: string) => void; + /** + * Retrieves an option's value from the terminal. + * @param key The option key. + */ + getOption(key: string): any; /** * Sets an option on the terminal. @@ -382,6 +393,12 @@ declare module 'xterm' { * @param value The option value. */ setOption(key: 'handler', value: (data: string) => void): void; + /** + * Sets an option on the terminal. + * @param key The option key. + * @param value The option value. + */ + setOption(key: string, value: any): void; /** * Tells the renderer to refresh terminal content between two rows