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

Split Types.ts into Types.d.ts and Constants.ts #2229

Merged
merged 3 commits into from
Jun 15, 2019
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
6 changes: 3 additions & 3 deletions src/Types.ts → src/Types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { ITerminalOptions as IPublicTerminalOptions, IDisposable, IMarker, ISelectionPosition } from 'xterm';
import { ICharset, IAttributeData, CharData } from 'common/Types';
import { IEvent, EventEmitter } from 'common/EventEmitter';
import { IEvent, IEventEmitter } from 'common/EventEmitter';
import { IColorSet, IMouseHelper } from 'browser/Types';
import { IOptionsService } from 'common/services/Services';
import { IBuffer, IBufferSet } from 'common/buffer/Types';
Expand Down Expand Up @@ -54,8 +54,8 @@ export interface IInputHandlingTerminal {
viewport: IViewport;
selectionManager: ISelectionManager;

onA11yCharEmitter: EventEmitter<string>;
onA11yTabEmitter: EventEmitter<number>;
onA11yCharEmitter: IEventEmitter<string>;
onA11yTabEmitter: IEventEmitter<number>;

bell(): void;
focus(): void;
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 6 additions & 1 deletion src/common/EventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ export interface IEvent<T> {
(listener: (e: T) => any): IDisposable;
}

export class EventEmitter<T> {
export interface IEventEmitter<T> {
event: IEvent<T>;
fire(data: T): void;
}

export class EventEmitter<T> implements IEventEmitter<T> {
private _listeners: IListener<T>[] = [];
private _event?: IEvent<T>;

Expand Down
17 changes: 4 additions & 13 deletions src/common/Types.ts → src/common/Types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -40,11 +31,11 @@ export interface ICircularList<T> {
maxLength: number;
isFull: boolean;

onDeleteEmitter: EventEmitter<IDeleteEvent>;
onDeleteEmitter: IEventEmitter<IDeleteEvent>;
onDelete: IEvent<IDeleteEvent>;
onInsertEmitter: EventEmitter<IInsertEvent>;
onInsertEmitter: IEventEmitter<IInsertEvent>;
onInsert: IEvent<IInsertEvent>;
onTrimEmitter: EventEmitter<number>;
onTrimEmitter: IEventEmitter<number>;
onTrim: IEvent<number>;

get(index: number): T | undefined;
Expand Down
3 changes: 2 additions & 1 deletion src/common/buffer/BufferLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 6 additions & 0 deletions src/common/buffer/Constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
* @license MIT
*/

export const DEFAULT_COLOR = 256;
File renamed without changes.
45 changes: 45 additions & 0 deletions src/common/parser/Constants.ts
Original file line number Diff line number Diff line change
@@ -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
}
3 changes: 2 additions & 1 deletion src/common/parser/EscapeSequenceParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/common/parser/EscapeSequenceParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
42 changes: 1 addition & 41 deletions src/common/parser/Types.ts → src/common/parser/Types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions src/renderer/BaseRenderLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import { IRenderLayer } from './Types';
import { IRenderDimensions } from 'browser/renderer/Types';
import { ITerminal } from '../Types';
import { ICellData, DEFAULT_COLOR } from 'common/Types';
import { DIM_OPACITY, INVERTED_DEFAULT_COLOR, IGlyphIdentifier } from './atlas/Types';
import { ICellData } from 'common/Types';
import { DEFAULT_COLOR } from 'common/buffer/Constants';
import { IGlyphIdentifier } from './atlas/Types';
import { DIM_OPACITY, INVERTED_DEFAULT_COLOR } from './atlas/Constants';
import { BaseCharAtlas } from './atlas/BaseCharAtlas';
import { acquireCharAtlas } from './atlas/CharAtlasCache';
import { CellData, AttributeData, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE } from 'common/buffer/BufferLine';
Expand Down
17 changes: 17 additions & 0 deletions src/renderer/Constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
* @license MIT
*/

/**
* Flags used to render terminal text properly for the old CharData format
*/
export const enum FLAGS {
BOLD = 1,
UNDERLINE = 2,
BLINK = 4,
INVERSE = 8,
INVISIBLE = 16,
DIM = 32,
ITALIC = 64
}
2 changes: 1 addition & 1 deletion src/renderer/LinkRenderLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { ILinkifierEvent, ITerminal, ILinkifierAccessor } from '../Types';
import { IRenderDimensions } from 'browser/renderer/Types';
import { BaseRenderLayer } from './BaseRenderLayer';
import { INVERTED_DEFAULT_COLOR } from './atlas/Types';
import { INVERTED_DEFAULT_COLOR } from './atlas/Constants';
import { is256Color } from './atlas/CharAtlasUtils';
import { IColorSet } from 'browser/Types';

Expand Down
13 changes: 0 additions & 13 deletions src/renderer/Types.ts → src/renderer/Types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@ import { IDisposable } from 'xterm';
import { IColorSet } from 'browser/Types';
import { IRenderDimensions, CharacterJoinerHandler } from 'browser/renderer/Types';

/**
* Flags used to render terminal text properly.
*/
export const enum FLAGS {
BOLD = 1,
UNDERLINE = 2,
BLINK = 4,
INVERSE = 8,
INVISIBLE = 16,
DIM = 32,
ITALIC = 64
}

export interface IRenderLayer extends IDisposable {
/**
* Called when the terminal loses focus.
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/atlas/CharAtlasUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions src/renderer/atlas/Constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
* @license MIT
*/

export const INVERTED_DEFAULT_COLOR = 257;
export const DIM_OPACITY = 0.5;

export const CHAR_ATLAS_CELL_SPACING = 1;
3 changes: 2 additions & 1 deletion src/renderer/atlas/DynamicCharAtlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* @license MIT
*/

import { DIM_OPACITY, IGlyphIdentifier, INVERTED_DEFAULT_COLOR, ICharAtlasConfig } from './Types';
import { IGlyphIdentifier, ICharAtlasConfig } from './Types';
import { DIM_OPACITY, INVERTED_DEFAULT_COLOR } from './Constants';
import { BaseCharAtlas } from './BaseCharAtlas';
import { DEFAULT_ANSI_COLORS } from 'browser/ColorManager';
import { LRUMap } from './LRUMap';
Expand Down
5 changes: 0 additions & 5 deletions src/renderer/atlas/Types.ts → src/renderer/atlas/Types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
import { FontWeight } from 'xterm';
import { IColorSet } from 'browser/Types';

export const INVERTED_DEFAULT_COLOR = 257;
export const DIM_OPACITY = 0.5;

export const CHAR_ATLAS_CELL_SPACING = 1;

export interface IGlyphIdentifier {
chars: string;
code: number;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/dom/DomRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { IRenderer, IRenderDimensions, CharacterJoinerHandler } from 'browser/renderer/Types';
import { ILinkifierEvent, ITerminal } from '../../Types';
import { BOLD_CLASS, ITALIC_CLASS, CURSOR_CLASS, CURSOR_STYLE_BLOCK_CLASS, CURSOR_BLINK_CLASS, CURSOR_STYLE_BAR_CLASS, CURSOR_STYLE_UNDERLINE_CLASS, DomRendererRowFactory } from './DomRendererRowFactory';
import { INVERTED_DEFAULT_COLOR } from '../atlas/Types';
import { INVERTED_DEFAULT_COLOR } from '../atlas/Constants';
import { Disposable } from 'common/Lifecycle';
import { IColorSet } from 'browser/Types';
import { ICharSizeService } from 'browser/services/Services';
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/dom/DomRendererRowFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { ITerminalOptions } from '../../Types';
import { IBufferLine } from 'common/Types';
import { INVERTED_DEFAULT_COLOR } from '../atlas/Types';
import { INVERTED_DEFAULT_COLOR } from '../atlas/Constants';
import { CellData, AttributeData, NULL_CELL_CODE, WHITESPACE_CELL_CHAR } from 'common/buffer/BufferLine';

export const BOLD_CLASS = 'xterm-bold';
Expand Down