Skip to content

Commit

Permalink
Remove option overloads from src
Browse files Browse the repository at this point in the history
src/ handles more than that specified (and should incase you're not
using TS), this also reduces duplication as the definitions are only
in typings/
  • Loading branch information
Tyriar committed Aug 19, 2017
1 parent 380f950 commit 34f5b2c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 38 deletions.
18 changes: 3 additions & 15 deletions src/Terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import * as Browser from './utils/Browser';
import * as Mouse from './utils/Mouse';
import { CHARSETS } from './Charsets';
import { getRawByteCoords } from './utils/Mouse';
import { CustomKeyEventHandler, Charset, LinkMatcherHandler, LinkMatcherValidationCallback, CharData, LineData, Option, StringOption, BooleanOption, StringArrayOption, NumberOption, GeometryOption, HandlerOption } from './Types';
import { CustomKeyEventHandler, Charset, LinkMatcherHandler, LinkMatcherValidationCallback, CharData, LineData } from './Types';
import { ITerminal, IBrowser, ITerminalOptions, IInputHandlingTerminal, ILinkMatcherOptions, IViewport, ICompositionHelper } from './Interfaces';

// Declare for RequireJS in loadAddon
Expand Down Expand Up @@ -412,13 +412,7 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
* Retrieves an option's value from the terminal.
* @param {string} key The option key.
*/
public getOption(key: StringOption): string;
public getOption(key: BooleanOption): boolean;
public getOption(key: StringArrayOption): string[];
public getOption(key: NumberOption): number;
public getOption(key: GeometryOption): [number, number];
public getOption(key: HandlerOption): (data: string) => void;
public getOption(key: Option): any {
public getOption(key: string): any {
if (!(key in DEFAULT_OPTIONS)) {
throw new Error('No option with key "' + key + '"');
}
Expand All @@ -435,13 +429,7 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
* @param {string} key The option key.
* @param {any} value The option value.
*/
public setOption(key: StringOption, value: string): void;
public setOption(key: BooleanOption, value: boolean): void;
public setOption(key: StringArrayOption, value: number[]): void;
public setOption(key: NumberOption, value: number): void;
public setOption(key: GeometryOption, value: [number, number]): void;
public setOption(key: HandlerOption, value: (data: string) => void): void;
public setOption(key: Option, value: any): void {
public setOption(key: string, value: any): void {
if (!(key in DEFAULT_OPTIONS)) {
throw new Error('No option with key "' + key + '"');
}
Expand Down
23 changes: 0 additions & 23 deletions src/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,3 @@ export type Charset = {[key: string]: string};

export type CharData = [number, string, number];
export type LineData = CharData[];

export type Option = BooleanOption | StringOption | StringArrayOption | NumberOption | GeometryOption | HandlerOption;
export type BooleanOption =
'cancelEvents' |
'convertEol' |
'cursorBlink' |
'debug' |
'disableStdin' |
'popOnBell' |
'screenKeys' |
'useFlowControl' |
'visualBell';
export type StringOption =
'cursorStyle' |
'termName';
export type StringArrayOption = 'colors';
export type NumberOption =
'cols' |
'rows' |
'tabStopWidth' |
'scrollback';
export type GeometryOption = 'geometry';
export type HandlerOption = 'handler';

0 comments on commit 34f5b2c

Please sign in to comment.