From f8e7ff24d9af0daea8df15dcad89da8a07670561 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 8 Jun 2019 16:09:27 -0700 Subject: [PATCH] Merge core into common Part of #1507 --- src/Buffer.test.ts | 2 +- src/Buffer.ts | 8 +- src/BufferSet.ts | 2 +- src/InputHandler.test.ts | 4 +- src/InputHandler.ts | 10 +- src/Linkifier.test.ts | 4 +- src/MouseHelper.test.ts | 3 + src/SelectionManager.test.ts | 4 +- src/SelectionManager.ts | 4 +- src/Terminal.test.ts | 2 +- src/Terminal.ts | 6 +- src/Terminal2.test.ts | 2 +- src/TestUtils.test.ts | 4 +- src/Types.ts | 2 +- src/WindowsMode.ts | 2 +- src/common/Types.ts | 102 +++++++++++++++++ .../buffer/BufferLine.test.ts | 0 src/{core => common}/buffer/BufferLine.ts | 5 +- .../buffer/BufferReflow.test.ts | 4 +- src/{core => common}/buffer/BufferReflow.ts | 4 +- src/{core => common}/buffer/Marker.ts | 2 +- src/{core => common}/data/Charsets.ts | 2 +- src/{core => common}/input/Keyboard.test.ts | 5 +- src/{core => common}/input/Keyboard.ts | 3 +- .../input/TextDecoder.test.ts | 2 +- src/{core => common}/input/TextDecoder.ts | 0 .../parser/EscapeSequenceParser.test.ts | 6 +- .../parser/EscapeSequenceParser.ts | 4 +- src/{core => common}/parser/Types.ts | 0 src/core/Types.ts | 108 ------------------ src/core/tsconfig.json | 17 --- src/handlers/AltClickHandler.ts | 3 +- src/public/Terminal.ts | 2 +- src/renderer/BaseRenderLayer.ts | 4 +- src/renderer/CharacterJoinerRegistry.test.ts | 4 +- src/renderer/CharacterJoinerRegistry.ts | 4 +- src/renderer/CursorRenderLayer.ts | 4 +- src/renderer/TextRenderLayer.ts | 4 +- .../dom/DomRendererRowFactory.test.ts | 4 +- src/renderer/dom/DomRendererRowFactory.ts | 4 +- src/tsconfig.json | 2 - 41 files changed, 166 insertions(+), 192 deletions(-) rename src/{core => common}/buffer/BufferLine.test.ts (100%) rename src/{core => common}/buffer/BufferLine.ts (99%) rename src/{core => common}/buffer/BufferReflow.test.ts (97%) rename src/{core => common}/buffer/BufferReflow.ts (98%) rename src/{core => common}/buffer/Marker.ts (95%) rename src/{core => common}/data/Charsets.ts (99%) rename src/{core => common}/input/Keyboard.test.ts (99%) rename src/{core => common}/input/Keyboard.ts (98%) rename src/{core => common}/input/TextDecoder.test.ts (99%) rename src/{core => common}/input/TextDecoder.ts (100%) rename src/{core => common}/parser/EscapeSequenceParser.test.ts (99%) rename src/{core => common}/parser/EscapeSequenceParser.ts (99%) rename src/{core => common}/parser/Types.ts (100%) delete mode 100644 src/core/Types.ts delete mode 100644 src/core/tsconfig.json diff --git a/src/Buffer.test.ts b/src/Buffer.test.ts index e1572889..101912bb 100644 --- a/src/Buffer.test.ts +++ b/src/Buffer.test.ts @@ -8,7 +8,7 @@ import { ITerminal } from './Types'; import { Buffer } from './Buffer'; import { CircularList } from 'common/CircularList'; import { MockTerminal, TestTerminal } from './TestUtils.test'; -import { BufferLine, CellData, DEFAULT_ATTR_DATA } from 'core/buffer/BufferLine'; +import { BufferLine, CellData, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; const INIT_COLS = 80; const INIT_ROWS = 24; diff --git a/src/Buffer.ts b/src/Buffer.ts index a0d590a5..6b89884e 100644 --- a/src/Buffer.ts +++ b/src/Buffer.ts @@ -5,10 +5,10 @@ import { CircularList, IInsertEvent } from 'common/CircularList'; import { ITerminal, IBuffer, BufferIndex, IBufferStringIterator, IBufferStringIteratorResult } from './Types'; -import { IBufferLine, ICellData, IAttributeData } from 'core/Types'; -import { BufferLine, CellData, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_WIDTH, WHITESPACE_CELL_CODE, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX, DEFAULT_ATTR_DATA } from 'core/buffer/BufferLine'; -import { reflowLargerApplyNewLayout, reflowLargerCreateNewLayout, reflowLargerGetLinesToRemove, reflowSmallerGetNewLineLengths, getWrappedLineTrimmedLength } from 'core/buffer/BufferReflow'; -import { Marker } from 'core/buffer/Marker'; +import { IBufferLine, ICellData, IAttributeData } from 'common/Types'; +import { BufferLine, CellData, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_WIDTH, WHITESPACE_CELL_CODE, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; +import { reflowLargerApplyNewLayout, reflowLargerCreateNewLayout, reflowLargerGetLinesToRemove, reflowSmallerGetNewLineLengths, getWrappedLineTrimmedLength } from 'common/buffer/BufferReflow'; +import { Marker } from 'common/buffer/Marker'; export const MAX_BUFFER_SIZE = 4294967295; // 2^32 - 1 diff --git a/src/BufferSet.ts b/src/BufferSet.ts index c2aee6a7..1d4ae2c6 100644 --- a/src/BufferSet.ts +++ b/src/BufferSet.ts @@ -4,7 +4,7 @@ */ import { ITerminal, IBufferSet, IBuffer } from './Types'; -import { IAttributeData } from 'core/Types'; +import { IAttributeData } from 'common/Types'; import { Buffer } from './Buffer'; import { EventEmitter2, IEvent } from 'common/EventEmitter2'; diff --git a/src/InputHandler.test.ts b/src/InputHandler.test.ts index f3a217a1..3e5cef57 100644 --- a/src/InputHandler.test.ts +++ b/src/InputHandler.test.ts @@ -7,8 +7,8 @@ import { assert, expect } from 'chai'; import { InputHandler } from './InputHandler'; import { MockInputHandlingTerminal, TestTerminal } from './TestUtils.test'; import { Terminal } from './Terminal'; -import { IBufferLine } from 'core/Types'; -import { CellData, Attributes, AttributeData, DEFAULT_ATTR_DATA } from 'core/buffer/BufferLine'; +import { IBufferLine } from 'common/Types'; +import { CellData, Attributes, AttributeData, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; describe('InputHandler', () => { describe('save and restore cursor', () => { diff --git a/src/InputHandler.ts b/src/InputHandler.ts index 354f3962..78bebfa5 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -6,16 +6,16 @@ import { IInputHandler, IInputHandlingTerminal } from './Types'; import { C0, C1 } from 'common/data/EscapeSequences'; -import { CHARSETS, DEFAULT_CHARSET } from 'core/data/Charsets'; +import { CHARSETS, DEFAULT_CHARSET } from 'common/data/Charsets'; import { wcwidth } from './common/CharWidth'; -import { EscapeSequenceParser } from 'core/parser/EscapeSequenceParser'; +import { EscapeSequenceParser } from 'common/parser/EscapeSequenceParser'; import { IDisposable } from 'xterm'; import { Disposable } from 'common/Lifecycle'; import { concat } from 'common/TypedArrayUtils'; -import { StringToUtf32, stringFromCodePoint, utf32ToString, Utf8ToUtf32 } from 'core/input/TextDecoder'; -import { CellData, Attributes, FgFlags, BgFlags, AttributeData, NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR_DATA } from 'core/buffer/BufferLine'; +import { StringToUtf32, stringFromCodePoint, utf32ToString, Utf8ToUtf32 } from 'common/input/TextDecoder'; +import { CellData, Attributes, FgFlags, BgFlags, AttributeData, NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; import { EventEmitter2, IEvent } from 'common/EventEmitter2'; -import { IParsingState, IDcsHandler, IEscapeSequenceParser } from 'core/parser/Types'; +import { IParsingState, IDcsHandler, IEscapeSequenceParser } from 'common/parser/Types'; /** * Map collect to glevel. Used in `selectCharset`. diff --git a/src/Linkifier.test.ts b/src/Linkifier.test.ts index e02105d8..8b7e71a0 100644 --- a/src/Linkifier.test.ts +++ b/src/Linkifier.test.ts @@ -5,11 +5,11 @@ import { assert } from 'chai'; import { IMouseZoneManager, IMouseZone, ILinkMatcher, ITerminal } from './Types'; -import { IBufferLine } from 'core/Types'; +import { IBufferLine } from 'common/Types'; import { Linkifier } from './Linkifier'; import { MockBuffer, MockTerminal, TestTerminal } from './TestUtils.test'; import { CircularList } from 'common/CircularList'; -import { BufferLine, CellData } from 'core/buffer/BufferLine'; +import { BufferLine, CellData } from 'common/buffer/BufferLine'; class TestLinkifier extends Linkifier { constructor(terminal: ITerminal) { diff --git a/src/MouseHelper.test.ts b/src/MouseHelper.test.ts index 946b3cb8..a0669ec0 100644 --- a/src/MouseHelper.test.ts +++ b/src/MouseHelper.test.ts @@ -3,6 +3,7 @@ * @license MIT */ +import jsdom = require('jsdom'); import { assert } from 'chai'; import { MouseHelper } from './MouseHelper'; import { MockRenderer, MockCharSizeService } from './TestUtils.test'; @@ -11,9 +12,11 @@ const CHAR_WIDTH = 10; const CHAR_HEIGHT = 20; describe('MouseHelper.getCoords', () => { + let document: Document; let mouseHelper: MouseHelper; beforeEach(() => { + document = new jsdom.JSDOM('').window.document; const renderer = new MockRenderer(); renderer.dimensions = { actualCellWidth: CHAR_WIDTH, diff --git a/src/SelectionManager.test.ts b/src/SelectionManager.test.ts index 538abc91..90d70d79 100644 --- a/src/SelectionManager.test.ts +++ b/src/SelectionManager.test.ts @@ -8,9 +8,9 @@ import { SelectionManager, SelectionMode } from './SelectionManager'; import { SelectionModel } from './SelectionModel'; import { BufferSet } from './BufferSet'; import { ITerminal, IBuffer } from './Types'; -import { IBufferLine } from 'core/Types'; +import { IBufferLine } from 'common/Types'; import { MockTerminal, MockCharSizeService } from './TestUtils.test'; -import { BufferLine, CellData } from 'core/buffer/BufferLine'; +import { BufferLine, CellData } from 'common/buffer/BufferLine'; class TestMockTerminal extends MockTerminal { emit(event: string, data: any): void {} diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index 0b939562..33a087e2 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -4,12 +4,12 @@ */ import { ITerminal, ISelectionManager, IBuffer, ISelectionRedrawRequestEvent } from './Types'; -import { IBufferLine } from 'core/Types'; +import { IBufferLine } from 'common/Types'; import { MouseHelper } from './MouseHelper'; import * as Browser from 'common/Platform'; import { SelectionModel } from './SelectionModel'; import { AltClickHandler } from './handlers/AltClickHandler'; -import { CellData } from 'core/buffer/BufferLine'; +import { CellData } from 'common/buffer/BufferLine'; import { IDisposable } from 'xterm'; import { EventEmitter2, IEvent } from 'common/EventEmitter2'; import { ICharSizeService } from 'ui/services/Services'; diff --git a/src/Terminal.test.ts b/src/Terminal.test.ts index beb9e921..db474269 100644 --- a/src/Terminal.test.ts +++ b/src/Terminal.test.ts @@ -6,7 +6,7 @@ import { assert, expect } from 'chai'; import { Terminal } from './Terminal'; import { MockViewport, MockCompositionHelper, MockRenderer } from './TestUtils.test'; -import { CellData, DEFAULT_ATTR_DATA } from 'core/buffer/BufferLine'; +import { CellData, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; const INIT_COLS = 80; const INIT_ROWS = 24; diff --git a/src/Terminal.ts b/src/Terminal.ts index 0ea8a335..5bc6c6a6 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -45,10 +45,10 @@ import { ITheme, IMarker, IDisposable, ISelectionPosition } from 'xterm'; import { removeTerminalFromCache } from './renderer/atlas/CharAtlasCache'; import { DomRenderer } from './renderer/dom/DomRenderer'; import { IKeyboardEvent } from 'common/Types'; -import { evaluateKeyboardEvent } from 'core/input/Keyboard'; -import { KeyboardResultType, ICharset, IBufferLine, IAttributeData } from 'core/Types'; +import { evaluateKeyboardEvent } from 'common/input/Keyboard'; +import { KeyboardResultType, ICharset, IBufferLine, IAttributeData } from 'common/Types'; import { EventEmitter2, IEvent } from 'common/EventEmitter2'; -import { Attributes, DEFAULT_ATTR_DATA } from 'core/buffer/BufferLine'; +import { Attributes, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; import { applyWindowsMode } from './WindowsMode'; import { ColorManager } from 'ui/ColorManager'; import { RenderCoordinator } from './renderer/RenderCoordinator'; diff --git a/src/Terminal2.test.ts b/src/Terminal2.test.ts index 3e85347b..0fc2f461 100644 --- a/src/Terminal2.test.ts +++ b/src/Terminal2.test.ts @@ -12,7 +12,7 @@ import * as path from 'path'; import * as pty from 'node-pty'; import { Terminal } from './Terminal'; import { IViewport } from './Types'; -import { CellData, WHITESPACE_CELL_CHAR } from 'core/buffer/BufferLine'; +import { CellData, WHITESPACE_CELL_CHAR } from 'common/buffer/BufferLine'; class TestTerminal extends Terminal { innerWrite(): void { this._innerWrite(); } diff --git a/src/TestUtils.test.ts b/src/TestUtils.test.ts index 05e7fa61..eb2f43fc 100644 --- a/src/TestUtils.test.ts +++ b/src/TestUtils.test.ts @@ -5,13 +5,13 @@ import { IRenderer, IRenderDimensions } from './renderer/Types'; import { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminal, IBuffer, IBufferSet, IBrowser, ISelectionManager, ITerminalOptions, ILinkifier, IMouseHelper, ILinkMatcherOptions, CharacterJoinerHandler, IBufferStringIterator } from './Types'; -import { IBufferLine, ICellData, IAttributeData } from 'core/Types'; +import { IBufferLine, ICellData, IAttributeData } from 'common/Types'; import { ICircularList, XtermListener } from 'common/Types'; import { Buffer } from './Buffer'; import * as Browser from 'common/Platform'; import { IDisposable, IMarker, IEvent, ISelectionPosition } from 'xterm'; import { Terminal } from './Terminal'; -import { AttributeData } from 'core/buffer/BufferLine'; +import { AttributeData } from 'common/buffer/BufferLine'; import { IColorManager, IColorSet } from 'ui/Types'; import { IOptionsService } from 'common/services/Services'; import { ICharSizeService } from 'ui/services/Services'; diff --git a/src/Types.ts b/src/Types.ts index 3eca3ac4..c0ce984a 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -4,7 +4,7 @@ */ import { ITerminalOptions as IPublicTerminalOptions, IEventEmitter, IDisposable, IMarker, ISelectionPosition } from 'xterm'; -import { ICharset, IAttributeData, ICellData, IBufferLine, CharData } from 'core/Types'; +import { ICharset, IAttributeData, ICellData, IBufferLine, CharData } from 'common/Types'; import { ICircularList } from 'common/Types'; import { IEvent } from 'common/EventEmitter2'; import { IColorSet } from 'ui/Types'; diff --git a/src/WindowsMode.ts b/src/WindowsMode.ts index 3bfa2a16..cee31de1 100644 --- a/src/WindowsMode.ts +++ b/src/WindowsMode.ts @@ -5,7 +5,7 @@ import { IDisposable } from 'xterm'; import { ITerminal } from './Types'; -import { CHAR_DATA_CODE_INDEX, NULL_CELL_CODE, WHITESPACE_CELL_CODE } from 'core/buffer/BufferLine'; +import { CHAR_DATA_CODE_INDEX, NULL_CELL_CODE, WHITESPACE_CELL_CODE } from 'common/buffer/BufferLine'; export function applyWindowsMode(terminal: ITerminal): IDisposable { // Winpty does not support wraparound mode which means that lines will never diff --git a/src/common/Types.ts b/src/common/Types.ts index e0a1e612..67d449e5 100644 --- a/src/common/Types.ts +++ b/src/common/Types.ts @@ -56,3 +56,105 @@ export interface ICircularList { trimStart(count: number): void; shiftElements(start: number, count: number, offset: number): void; } + +export const enum KeyboardResultType { + SEND_KEY, + SELECT_ALL, + PAGE_UP, + PAGE_DOWN +} + +export interface IKeyboardResult { + type: KeyboardResultType; + cancel: boolean; + key: string | undefined; +} + +export interface ICharset { + [key: string]: string; +} + +export type CharData = [number, string, number, number]; +export type IColorRGB = [number, number, number]; + +/** Attribute data */ +export interface IAttributeData { + fg: number; + bg: number; + + clone(): IAttributeData; + + // flags + isInverse(): number; + isBold(): number; + isUnderline(): number; + isBlink(): number; + isInvisible(): number; + isItalic(): number; + isDim(): number; + + // color modes + getFgColorMode(): number; + getBgColorMode(): number; + isFgRGB(): boolean; + isBgRGB(): boolean; + isFgPalette(): boolean; + isBgPalette(): boolean; + isFgDefault(): boolean; + isBgDefault(): boolean; + + // colors + getFgColor(): number; + getBgColor(): number; +} + +/** Cell data */ +export interface ICellData extends IAttributeData { + content: number; + combinedData: string; + isCombined(): number; + getWidth(): number; + getChars(): string; + getCode(): number; + setFromCharData(value: CharData): void; + getAsCharData(): CharData; +} + +/** + * Interface for a line in the terminal buffer. + */ +export interface IBufferLine { + length: number; + isWrapped: boolean; + get(index: number): CharData; + set(index: number, value: CharData): void; + loadCell(index: number, cell: ICellData): ICellData; + setCell(index: number, cell: ICellData): void; + setCellFromCodePoint(index: number, codePoint: number, width: number, fg: number, bg: number): void; + addCodepointToCell(index: number, codePoint: number): void; + insertCells(pos: number, n: number, ch: ICellData): void; + deleteCells(pos: number, n: number, fill: ICellData): void; + replaceCells(start: number, end: number, fill: ICellData): void; + resize(cols: number, fill: ICellData): void; + fill(fillCellData: ICellData): void; + copyFrom(line: IBufferLine): void; + clone(): IBufferLine; + getTrimmedLength(): number; + translateToString(trimRight?: boolean, startCol?: number, endCol?: number): string; + + /* direct access to cell attrs */ + getWidth(index: number): number; + hasWidth(index: number): number; + getFg(index: number): number; + getBg(index: number): number; + hasContent(index: number): number; + getCodePoint(index: number): number; + isCombined(index: number): number; + getString(index: number): string; +} + +export interface IMarker extends IDisposable { + readonly id: number; + readonly isDisposed: boolean; + readonly line: number; +} diff --git a/src/core/buffer/BufferLine.test.ts b/src/common/buffer/BufferLine.test.ts similarity index 100% rename from src/core/buffer/BufferLine.test.ts rename to src/common/buffer/BufferLine.test.ts diff --git a/src/core/buffer/BufferLine.ts b/src/common/buffer/BufferLine.ts similarity index 99% rename from src/core/buffer/BufferLine.ts rename to src/common/buffer/BufferLine.ts index 91c3a8d1..eb0a5e99 100644 --- a/src/core/buffer/BufferLine.ts +++ b/src/common/buffer/BufferLine.ts @@ -2,9 +2,8 @@ * Copyright (c) 2018 The xterm.js authors. All rights reserved. * @license MIT */ -import { CharData, IBufferLine, ICellData, IColorRGB, IAttributeData } from 'core/Types'; -import { stringFromCodePoint } from 'core/input/TextDecoder'; -import { DEFAULT_COLOR } from 'common/Types'; +import { DEFAULT_COLOR, CharData, IBufferLine, ICellData, IColorRGB, IAttributeData } from 'common/Types'; +import { stringFromCodePoint } from 'common/input/TextDecoder'; export const DEFAULT_ATTR = (0 << 18) | (DEFAULT_COLOR << 9) | (256 << 0); diff --git a/src/core/buffer/BufferReflow.test.ts b/src/common/buffer/BufferReflow.test.ts similarity index 97% rename from src/core/buffer/BufferReflow.test.ts rename to src/common/buffer/BufferReflow.test.ts index f7d2de73..af908572 100644 --- a/src/core/buffer/BufferReflow.test.ts +++ b/src/common/buffer/BufferReflow.test.ts @@ -3,8 +3,8 @@ * @license MIT */ import { assert } from 'chai'; -import { BufferLine, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE } from 'core/buffer/BufferLine'; -import { reflowSmallerGetNewLineLengths } from 'core/buffer/BufferReflow'; +import { BufferLine, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE } from 'common/buffer/BufferLine'; +import { reflowSmallerGetNewLineLengths } from 'common/buffer/BufferReflow'; describe('BufferReflow', () => { describe('reflowSmallerGetNewLineLengths', () => { diff --git a/src/core/buffer/BufferReflow.ts b/src/common/buffer/BufferReflow.ts similarity index 98% rename from src/core/buffer/BufferReflow.ts rename to src/common/buffer/BufferReflow.ts index d75941e3..ece9a96e 100644 --- a/src/core/buffer/BufferReflow.ts +++ b/src/common/buffer/BufferReflow.ts @@ -3,9 +3,9 @@ * @license MIT */ -import { BufferLine } from 'core/buffer/BufferLine'; +import { BufferLine } from 'common/buffer/BufferLine'; import { CircularList } from 'common/CircularList'; -import { IBufferLine, ICellData } from 'core/Types'; +import { IBufferLine, ICellData } from 'common/Types'; export interface INewLayoutResult { layout: number[]; diff --git a/src/core/buffer/Marker.ts b/src/common/buffer/Marker.ts similarity index 95% rename from src/core/buffer/Marker.ts rename to src/common/buffer/Marker.ts index 8d207166..51c5d7f8 100644 --- a/src/core/buffer/Marker.ts +++ b/src/common/buffer/Marker.ts @@ -5,7 +5,7 @@ import { EventEmitter2, IEvent } from 'common/EventEmitter2'; import { Disposable } from 'common/Lifecycle'; -import { IMarker } from 'core/Types'; +import { IMarker } from 'common/Types'; export class Marker extends Disposable implements IMarker { private static _nextId = 1; diff --git a/src/core/data/Charsets.ts b/src/common/data/Charsets.ts similarity index 99% rename from src/core/data/Charsets.ts rename to src/common/data/Charsets.ts index f6ee7297..56ca6799 100644 --- a/src/core/data/Charsets.ts +++ b/src/common/data/Charsets.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { ICharset } from 'core/Types'; +import { ICharset } from 'common/Types'; /** * The character sets supported by the terminal. These enable several languages diff --git a/src/core/input/Keyboard.test.ts b/src/common/input/Keyboard.test.ts similarity index 99% rename from src/core/input/Keyboard.test.ts rename to src/common/input/Keyboard.test.ts index 8a5f105b..409a3192 100644 --- a/src/core/input/Keyboard.test.ts +++ b/src/common/input/Keyboard.test.ts @@ -1,8 +1,7 @@ import { assert } from 'chai'; -import { evaluateKeyboardEvent } from 'core/input/Keyboard'; -import { IKeyboardResult } from 'core/Types'; -import { IKeyboardEvent } from 'common/Types'; +import { evaluateKeyboardEvent } from 'common/input/Keyboard'; +import { IKeyboardResult, IKeyboardEvent } from 'common/Types'; /** * A helper function for testing which allows passing in a partial event and defaults will be filled diff --git a/src/core/input/Keyboard.ts b/src/common/input/Keyboard.ts similarity index 98% rename from src/core/input/Keyboard.ts rename to src/common/input/Keyboard.ts index c78328da..3cc0eb76 100644 --- a/src/core/input/Keyboard.ts +++ b/src/common/input/Keyboard.ts @@ -4,8 +4,7 @@ * @license MIT */ -import { IKeyboardEvent } from 'common/Types'; -import { IKeyboardResult, KeyboardResultType } from 'core/Types'; +import { IKeyboardEvent, IKeyboardResult, KeyboardResultType } from 'common/Types'; import { C0 } from 'common/data/EscapeSequences'; // reg + shift key mappings for digits and special chars diff --git a/src/core/input/TextDecoder.test.ts b/src/common/input/TextDecoder.test.ts similarity index 99% rename from src/core/input/TextDecoder.test.ts rename to src/common/input/TextDecoder.test.ts index ba1c04fa..cda74a18 100644 --- a/src/core/input/TextDecoder.test.ts +++ b/src/common/input/TextDecoder.test.ts @@ -4,7 +4,7 @@ */ import { assert } from 'chai'; -import { StringToUtf32, stringFromCodePoint, Utf8ToUtf32, utf32ToString } from 'core/input/TextDecoder'; +import { StringToUtf32, stringFromCodePoint, Utf8ToUtf32, utf32ToString } from 'common/input/TextDecoder'; import { encode } from 'utf8'; // convert UTF32 codepoints to string diff --git a/src/core/input/TextDecoder.ts b/src/common/input/TextDecoder.ts similarity index 100% rename from src/core/input/TextDecoder.ts rename to src/common/input/TextDecoder.ts diff --git a/src/core/parser/EscapeSequenceParser.test.ts b/src/common/parser/EscapeSequenceParser.test.ts similarity index 99% rename from src/core/parser/EscapeSequenceParser.test.ts rename to src/common/parser/EscapeSequenceParser.test.ts index 01436e5e..18d5c6cf 100644 --- a/src/core/parser/EscapeSequenceParser.test.ts +++ b/src/common/parser/EscapeSequenceParser.test.ts @@ -3,10 +3,10 @@ * @license MIT */ -import { ParserState, IDcsHandler, IParsingState } from 'core/parser/Types'; -import { EscapeSequenceParser, TransitionTable, VT500_TRANSITION_TABLE } from 'core/parser/EscapeSequenceParser'; +import { ParserState, 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 'core/input/TextDecoder'; +import { StringToUtf32, stringFromCodePoint } from 'common/input/TextDecoder'; function r(a: number, b: number): string[] { let c = b - a; diff --git a/src/core/parser/EscapeSequenceParser.ts b/src/common/parser/EscapeSequenceParser.ts similarity index 99% rename from src/core/parser/EscapeSequenceParser.ts rename to src/common/parser/EscapeSequenceParser.ts index 5ecf4909..c8b631d0 100644 --- a/src/core/parser/EscapeSequenceParser.ts +++ b/src/common/parser/EscapeSequenceParser.ts @@ -3,9 +3,9 @@ * @license MIT */ -import { ParserState, ParserAction, IParsingState, IDcsHandler, IEscapeSequenceParser } from 'core/parser/Types'; +import { ParserState, ParserAction, IParsingState, IDcsHandler, IEscapeSequenceParser } from 'common/parser/Types'; import { Disposable } from 'common/Lifecycle'; -import { utf32ToString } from 'core/input/TextDecoder'; +import { utf32ToString } from 'common/input/TextDecoder'; import { IDisposable } from 'common/Types'; import { fill } from 'common/TypedArrayUtils'; diff --git a/src/core/parser/Types.ts b/src/common/parser/Types.ts similarity index 100% rename from src/core/parser/Types.ts rename to src/common/parser/Types.ts diff --git a/src/core/Types.ts b/src/core/Types.ts deleted file mode 100644 index 39cb172e..00000000 --- a/src/core/Types.ts +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Copyright (c) 2018 The xterm.js authors. All rights reserved. - * @license MIT - */ - -import { IDisposable } from 'common/Types'; - -export const enum KeyboardResultType { - SEND_KEY, - SELECT_ALL, - PAGE_UP, - PAGE_DOWN -} - -export interface IKeyboardResult { - type: KeyboardResultType; - cancel: boolean; - key: string | undefined; -} - -export interface ICharset { - [key: string]: string; -} - -export type CharData = [number, string, number, number]; -export type IColorRGB = [number, number, number]; - -/** Attribute data */ -export interface IAttributeData { - fg: number; - bg: number; - - clone(): IAttributeData; - - // flags - isInverse(): number; - isBold(): number; - isUnderline(): number; - isBlink(): number; - isInvisible(): number; - isItalic(): number; - isDim(): number; - - // color modes - getFgColorMode(): number; - getBgColorMode(): number; - isFgRGB(): boolean; - isBgRGB(): boolean; - isFgPalette(): boolean; - isBgPalette(): boolean; - isFgDefault(): boolean; - isBgDefault(): boolean; - - // colors - getFgColor(): number; - getBgColor(): number; -} - -/** Cell data */ -export interface ICellData extends IAttributeData { - content: number; - combinedData: string; - isCombined(): number; - getWidth(): number; - getChars(): string; - getCode(): number; - setFromCharData(value: CharData): void; - getAsCharData(): CharData; -} - -/** - * Interface for a line in the terminal buffer. - */ -export interface IBufferLine { - length: number; - isWrapped: boolean; - get(index: number): CharData; - set(index: number, value: CharData): void; - loadCell(index: number, cell: ICellData): ICellData; - setCell(index: number, cell: ICellData): void; - setCellFromCodePoint(index: number, codePoint: number, width: number, fg: number, bg: number): void; - addCodepointToCell(index: number, codePoint: number): void; - insertCells(pos: number, n: number, ch: ICellData): void; - deleteCells(pos: number, n: number, fill: ICellData): void; - replaceCells(start: number, end: number, fill: ICellData): void; - resize(cols: number, fill: ICellData): void; - fill(fillCellData: ICellData): void; - copyFrom(line: IBufferLine): void; - clone(): IBufferLine; - getTrimmedLength(): number; - translateToString(trimRight?: boolean, startCol?: number, endCol?: number): string; - - /* direct access to cell attrs */ - getWidth(index: number): number; - hasWidth(index: number): number; - getFg(index: number): number; - getBg(index: number): number; - hasContent(index: number): number; - getCodePoint(index: number): number; - isCombined(index: number): number; - getString(index: number): string; -} - -export interface IMarker extends IDisposable { - readonly id: number; - readonly isDisposed: boolean; - readonly line: number; -} diff --git a/src/core/tsconfig.json b/src/core/tsconfig.json deleted file mode 100644 index 5eeac7bc..00000000 --- a/src/core/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../tsconfig-library-base", - "compilerOptions": { - "outDir": "../../out", - "types": [ - "../../node_modules/@types/mocha" - ], - "baseUrl": "..", - "paths": { - "common/*": [ "./common/*" ] - } - }, - "include": [ "./**/*" ], - "references": [ - { "path": "../common" } - ] -} diff --git a/src/handlers/AltClickHandler.ts b/src/handlers/AltClickHandler.ts index eebabd7d..506e6ee1 100644 --- a/src/handlers/AltClickHandler.ts +++ b/src/handlers/AltClickHandler.ts @@ -4,8 +4,7 @@ */ import { ITerminal } from '../Types'; -import { IBufferLine } from 'core/Types'; -import { ICircularList } from 'common/Types'; +import { IBufferLine, ICircularList } from 'common/Types'; import { C0 } from 'common/data/EscapeSequences'; const enum Direction { diff --git a/src/public/Terminal.ts b/src/public/Terminal.ts index e6bd5923..f2524381 100644 --- a/src/public/Terminal.ts +++ b/src/public/Terminal.ts @@ -5,7 +5,7 @@ import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi } from 'xterm'; import { ITerminal, IBuffer } from '../Types'; -import { IBufferLine } from 'core/Types'; +import { IBufferLine } from 'common/Types'; import { Terminal as TerminalCore } from '../Terminal'; import * as Strings from '../Strings'; import { IEvent } from 'common/EventEmitter2'; diff --git a/src/renderer/BaseRenderLayer.ts b/src/renderer/BaseRenderLayer.ts index f61df580..4b31e270 100644 --- a/src/renderer/BaseRenderLayer.ts +++ b/src/renderer/BaseRenderLayer.ts @@ -5,12 +5,12 @@ import { IRenderLayer, IRenderDimensions } from './Types'; import { ITerminal } from '../Types'; -import { ICellData } from 'core/Types'; +import { ICellData } from 'common/Types'; import { DEFAULT_COLOR } from 'common/Types'; import { DIM_OPACITY, INVERTED_DEFAULT_COLOR, IGlyphIdentifier } from './atlas/Types'; import { BaseCharAtlas } from './atlas/BaseCharAtlas'; import { acquireCharAtlas } from './atlas/CharAtlasCache'; -import { CellData, AttributeData, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE } from 'core/buffer/BufferLine'; +import { CellData, AttributeData, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE } from 'common/buffer/BufferLine'; import { IColorSet } from 'ui/Types'; export abstract class BaseRenderLayer implements IRenderLayer { diff --git a/src/renderer/CharacterJoinerRegistry.test.ts b/src/renderer/CharacterJoinerRegistry.test.ts index 1ce02b76..e5ab08ea 100644 --- a/src/renderer/CharacterJoinerRegistry.test.ts +++ b/src/renderer/CharacterJoinerRegistry.test.ts @@ -10,8 +10,8 @@ import { CircularList } from 'common/CircularList'; import { ICharacterJoinerRegistry } from './Types'; import { CharacterJoinerRegistry } from './CharacterJoinerRegistry'; -import { BufferLine, CellData } from 'core/buffer/BufferLine'; -import { IBufferLine } from 'core/Types'; +import { BufferLine, CellData } from 'common/buffer/BufferLine'; +import { IBufferLine } from 'common/Types'; describe('CharacterJoinerRegistry', () => { let registry: ICharacterJoinerRegistry; diff --git a/src/renderer/CharacterJoinerRegistry.ts b/src/renderer/CharacterJoinerRegistry.ts index 1432e805..b707d863 100644 --- a/src/renderer/CharacterJoinerRegistry.ts +++ b/src/renderer/CharacterJoinerRegistry.ts @@ -4,9 +4,9 @@ */ import { ITerminal } from '../Types'; -import { IBufferLine, ICellData, CharData } from 'core/Types'; +import { IBufferLine, ICellData, CharData } from 'common/Types'; import { ICharacterJoinerRegistry, ICharacterJoiner } from './Types'; -import { CellData, Content, AttributeData, WHITESPACE_CELL_CHAR } from 'core/buffer/BufferLine'; +import { CellData, Content, AttributeData, WHITESPACE_CELL_CHAR } from 'common/buffer/BufferLine'; export class JoinedCellData extends AttributeData implements ICellData { private _width: number; diff --git a/src/renderer/CursorRenderLayer.ts b/src/renderer/CursorRenderLayer.ts index 4534603e..dbf11d55 100644 --- a/src/renderer/CursorRenderLayer.ts +++ b/src/renderer/CursorRenderLayer.ts @@ -6,8 +6,8 @@ import { IRenderDimensions } from './Types'; import { BaseRenderLayer } from './BaseRenderLayer'; import { ITerminal } from '../Types'; -import { ICellData } from 'core/Types'; -import { CellData } from 'core/buffer/BufferLine'; +import { ICellData } from 'common/Types'; +import { CellData } from 'common/buffer/BufferLine'; import { IColorSet } from 'ui/Types'; interface ICursorState { diff --git a/src/renderer/TextRenderLayer.ts b/src/renderer/TextRenderLayer.ts index 52d8b0f8..4594a2c8 100644 --- a/src/renderer/TextRenderLayer.ts +++ b/src/renderer/TextRenderLayer.ts @@ -5,10 +5,10 @@ import { IRenderDimensions, ICharacterJoinerRegistry } from './Types'; import { ITerminal } from '../Types'; -import { CharData, ICellData } from 'core/Types'; +import { CharData, ICellData } from 'common/Types'; import { GridCache } from './GridCache'; import { BaseRenderLayer } from './BaseRenderLayer'; -import { CellData, AttributeData, Content, NULL_CELL_CODE } from 'core/buffer/BufferLine'; +import { CellData, AttributeData, Content, NULL_CELL_CODE } from 'common/buffer/BufferLine'; import { JoinedCellData } from './CharacterJoinerRegistry'; import { IColorSet } from 'ui/Types'; diff --git a/src/renderer/dom/DomRendererRowFactory.test.ts b/src/renderer/dom/DomRendererRowFactory.test.ts index e3b26e5d..28ee0a7e 100644 --- a/src/renderer/dom/DomRendererRowFactory.test.ts +++ b/src/renderer/dom/DomRendererRowFactory.test.ts @@ -6,9 +6,9 @@ import jsdom = require('jsdom'); import { assert } from 'chai'; import { DomRendererRowFactory } from './DomRendererRowFactory'; -import { BufferLine, CellData, FgFlags, BgFlags, Attributes, NULL_CELL_CODE, NULL_CELL_WIDTH, NULL_CELL_CHAR, DEFAULT_ATTR, DEFAULT_ATTR_DATA } from 'core/buffer/BufferLine'; +import { BufferLine, CellData, FgFlags, BgFlags, Attributes, NULL_CELL_CODE, NULL_CELL_WIDTH, NULL_CELL_CHAR, DEFAULT_ATTR, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; import { ITerminalOptions } from '../../Types'; -import { IBufferLine } from 'core/Types'; +import { IBufferLine } from 'common/Types'; describe('DomRendererRowFactory', () => { let dom: jsdom.JSDOM; diff --git a/src/renderer/dom/DomRendererRowFactory.ts b/src/renderer/dom/DomRendererRowFactory.ts index d3685923..8c31aa44 100644 --- a/src/renderer/dom/DomRendererRowFactory.ts +++ b/src/renderer/dom/DomRendererRowFactory.ts @@ -4,9 +4,9 @@ */ import { ITerminalOptions } from '../../Types'; -import { IBufferLine } from '../../core/Types'; +import { IBufferLine } from 'common/Types'; import { INVERTED_DEFAULT_COLOR } from '../atlas/Types'; -import { CellData, AttributeData, NULL_CELL_CODE, WHITESPACE_CELL_CHAR } from '../../core/buffer/BufferLine'; +import { CellData, AttributeData, NULL_CELL_CODE, WHITESPACE_CELL_CHAR } from 'common/buffer/BufferLine'; export const BOLD_CLASS = 'xterm-bold'; export const DIM_CLASS = 'xterm-dim'; diff --git a/src/tsconfig.json b/src/tsconfig.json index a42c8338..c99f2b19 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -14,7 +14,6 @@ "baseUrl": ".", "paths": { "common/*": [ "./common/*" ], - "core/*": [ "./core/*" ], "ui/*": [ "./ui/*" ] }, @@ -30,7 +29,6 @@ ], "references": [ { "path": "./common" }, - { "path": "./core" }, { "path": "./ui" } ] }