diff --git a/src/common/EventEmitter.ts b/src/common/EventEmitter.ts index efc101ce..34ac190f 100644 --- a/src/common/EventEmitter.ts +++ b/src/common/EventEmitter.ts @@ -13,7 +13,12 @@ export interface IEvent { (listener: (e: T) => any): IDisposable; } -export class EventEmitter { +export interface IEventEmitter { + event: IEvent; + fire(data: T): void; +} + +export class EventEmitter implements IEventEmitter { private _listeners: IListener[] = []; private _event?: IEvent; diff --git a/src/common/Types.ts b/src/common/Types.d.ts similarity index 87% rename from src/common/Types.ts rename to src/common/Types.d.ts index b29515d4..97bd6029 100644 --- a/src/common/Types.ts +++ b/src/common/Types.d.ts @@ -3,22 +3,13 @@ * @license MIT */ -import { IEvent, EventEmitter } from 'common/EventEmitter'; +import { IEvent, IEventEmitter } from 'common/EventEmitter'; import { IDeleteEvent, IInsertEvent } from 'common/CircularList'; -export const DEFAULT_COLOR = 256; - export interface IDisposable { dispose(): void; } -export interface IEventEmitter { - on(type: string, listener: (...args: any[]) => void): void; - off(type: string, listener: (...args: any[]) => void): void; - emit(type: string, data?: any): void; - addDisposableListener(type: string, handler: (...args: any[]) => void): IDisposable; -} - export type XtermListener = (...args: any[]) => void; /** @@ -40,11 +31,11 @@ export interface ICircularList { maxLength: number; isFull: boolean; - onDeleteEmitter: EventEmitter; + onDeleteEmitter: IEventEmitter; onDelete: IEvent; - onInsertEmitter: EventEmitter; + onInsertEmitter: IEventEmitter; onInsert: IEvent; - onTrimEmitter: EventEmitter; + onTrimEmitter: IEventEmitter; onTrim: IEvent; get(index: number): T | undefined; diff --git a/src/common/buffer/BufferLine.ts b/src/common/buffer/BufferLine.ts index eb0a5e99..ffa2c284 100644 --- a/src/common/buffer/BufferLine.ts +++ b/src/common/buffer/BufferLine.ts @@ -2,8 +2,9 @@ * Copyright (c) 2018 The xterm.js authors. All rights reserved. * @license MIT */ -import { DEFAULT_COLOR, CharData, IBufferLine, ICellData, IColorRGB, IAttributeData } from 'common/Types'; +import { CharData, IBufferLine, ICellData, IColorRGB, IAttributeData } from 'common/Types'; import { stringFromCodePoint } from 'common/input/TextDecoder'; +import { DEFAULT_COLOR } from 'common/buffer/Constants'; export const DEFAULT_ATTR = (0 << 18) | (DEFAULT_COLOR << 9) | (256 << 0); diff --git a/src/common/buffer/Constants.ts b/src/common/buffer/Constants.ts new file mode 100644 index 00000000..3ad7e551 --- /dev/null +++ b/src/common/buffer/Constants.ts @@ -0,0 +1,6 @@ +/** + * Copyright (c) 2019 The xterm.js authors. All rights reserved. + * @license MIT + */ + +export const DEFAULT_COLOR = 256; diff --git a/src/common/buffer/Types.ts b/src/common/buffer/Types.d.ts similarity index 100% rename from src/common/buffer/Types.ts rename to src/common/buffer/Types.d.ts diff --git a/src/common/parser/Constants.ts b/src/common/parser/Constants.ts new file mode 100644 index 00000000..55e4a005 --- /dev/null +++ b/src/common/parser/Constants.ts @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2017 The xterm.js authors. All rights reserved. + * @license MIT + */ + +/** + * Internal states of EscapeSequenceParser. + */ +export const enum ParserState { + GROUND = 0, + ESCAPE = 1, + ESCAPE_INTERMEDIATE = 2, + CSI_ENTRY = 3, + CSI_PARAM = 4, + CSI_INTERMEDIATE = 5, + CSI_IGNORE = 6, + SOS_PM_APC_STRING = 7, + OSC_STRING = 8, + DCS_ENTRY = 9, + DCS_PARAM = 10, + DCS_IGNORE = 11, + DCS_INTERMEDIATE = 12, + DCS_PASSTHROUGH = 13 +} + +/** +* Internal actions of EscapeSequenceParser. +*/ +export const enum ParserAction { + IGNORE = 0, + ERROR = 1, + PRINT = 2, + EXECUTE = 3, + OSC_START = 4, + OSC_PUT = 5, + OSC_END = 6, + CSI_DISPATCH = 7, + PARAM = 8, + COLLECT = 9, + ESC_DISPATCH = 10, + CLEAR = 11, + DCS_HOOK = 12, + DCS_PUT = 13, + DCS_UNHOOK = 14 +} diff --git a/src/common/parser/EscapeSequenceParser.test.ts b/src/common/parser/EscapeSequenceParser.test.ts index 18d5c6cf..f445efc4 100644 --- a/src/common/parser/EscapeSequenceParser.test.ts +++ b/src/common/parser/EscapeSequenceParser.test.ts @@ -3,10 +3,11 @@ * @license MIT */ -import { ParserState, IDcsHandler, IParsingState } from 'common/parser/Types'; +import { IDcsHandler, IParsingState } from 'common/parser/Types'; import { EscapeSequenceParser, TransitionTable, VT500_TRANSITION_TABLE } from 'common/parser/EscapeSequenceParser'; import * as chai from 'chai'; import { StringToUtf32, stringFromCodePoint } from 'common/input/TextDecoder'; +import { ParserState } from 'common/parser/Constants'; function r(a: number, b: number): string[] { let c = b - a; diff --git a/src/common/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts index c8b631d0..d8d4e02e 100644 --- a/src/common/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -3,7 +3,8 @@ * @license MIT */ -import { ParserState, ParserAction, IParsingState, IDcsHandler, IEscapeSequenceParser } from 'common/parser/Types'; +import { IParsingState, IDcsHandler, IEscapeSequenceParser } from 'common/parser/Types'; +import { ParserState, ParserAction } from 'common/parser/Constants'; import { Disposable } from 'common/Lifecycle'; import { utf32ToString } from 'common/input/TextDecoder'; import { IDisposable } from 'common/Types'; diff --git a/src/common/parser/Types.ts b/src/common/parser/Types.d.ts similarity index 84% rename from src/common/parser/Types.ts rename to src/common/parser/Types.d.ts index 87199702..47ec98e1 100644 --- a/src/common/parser/Types.ts +++ b/src/common/parser/Types.d.ts @@ -4,47 +4,7 @@ */ import { IDisposable } from 'common/Types'; - -/** - * Internal states of EscapeSequenceParser. - */ -export const enum ParserState { - GROUND = 0, - ESCAPE = 1, - ESCAPE_INTERMEDIATE = 2, - CSI_ENTRY = 3, - CSI_PARAM = 4, - CSI_INTERMEDIATE = 5, - CSI_IGNORE = 6, - SOS_PM_APC_STRING = 7, - OSC_STRING = 8, - DCS_ENTRY = 9, - DCS_PARAM = 10, - DCS_IGNORE = 11, - DCS_INTERMEDIATE = 12, - DCS_PASSTHROUGH = 13 -} - -/** -* Internal actions of EscapeSequenceParser. -*/ -export const enum ParserAction { - IGNORE = 0, - ERROR = 1, - PRINT = 2, - EXECUTE = 3, - OSC_START = 4, - OSC_PUT = 5, - OSC_END = 6, - CSI_DISPATCH = 7, - PARAM = 8, - COLLECT = 9, - ESC_DISPATCH = 10, - CLEAR = 11, - DCS_HOOK = 12, - DCS_PUT = 13, - DCS_UNHOOK = 14 -} +import { ParserState } from 'common/parser/Constants'; /** * Internal state of EscapeSequenceParser. diff --git a/src/renderer/BaseRenderLayer.ts b/src/renderer/BaseRenderLayer.ts index 8335f76d..f4ff6ccb 100644 --- a/src/renderer/BaseRenderLayer.ts +++ b/src/renderer/BaseRenderLayer.ts @@ -6,7 +6,8 @@ import { IRenderLayer } from './Types'; import { IRenderDimensions } from 'browser/renderer/Types'; import { ITerminal } from '../Types'; -import { ICellData, DEFAULT_COLOR } from 'common/Types'; +import { ICellData } from 'common/Types'; +import { DEFAULT_COLOR } from 'common/buffer/Constants'; import { DIM_OPACITY, INVERTED_DEFAULT_COLOR, IGlyphIdentifier } from './atlas/Types'; import { BaseCharAtlas } from './atlas/BaseCharAtlas'; import { acquireCharAtlas } from './atlas/CharAtlasCache'; diff --git a/src/renderer/atlas/CharAtlasUtils.ts b/src/renderer/atlas/CharAtlasUtils.ts index b68793f6..ee787a7b 100644 --- a/src/renderer/atlas/CharAtlasUtils.ts +++ b/src/renderer/atlas/CharAtlasUtils.ts @@ -5,7 +5,7 @@ import { ITerminal } from '../../Types'; import { ICharAtlasConfig } from './Types'; -import { DEFAULT_COLOR } from 'common/Types'; +import { DEFAULT_COLOR } from 'common/buffer/Constants'; import { IColorSet } from 'browser/Types'; export function generateConfig(scaledCharWidth: number, scaledCharHeight: number, terminal: ITerminal, colors: IColorSet): ICharAtlasConfig {