From f8e7ff24d9af0daea8df15dcad89da8a07670561 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 8 Jun 2019 16:09:27 -0700 Subject: [PATCH 1/3] 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" } ] } From 98cda5ca868b57950ad40f09cc60ce0ae898145b Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 8 Jun 2019 16:12:20 -0700 Subject: [PATCH 2/3] Remove duplicate imports --- src/Terminal.ts | 3 +-- src/TestUtils.test.ts | 3 +-- src/Types.ts | 3 +-- src/renderer/BaseRenderLayer.ts | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Terminal.ts b/src/Terminal.ts index 5bc6c6a6..3608b3bf 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -44,9 +44,8 @@ import { AccessibilityManager } from './AccessibilityManager'; 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 { IKeyboardEvent, KeyboardResultType, ICharset, IBufferLine, IAttributeData } from 'common/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 'common/buffer/BufferLine'; import { applyWindowsMode } from './WindowsMode'; diff --git a/src/TestUtils.test.ts b/src/TestUtils.test.ts index eb2f43fc..914477ca 100644 --- a/src/TestUtils.test.ts +++ b/src/TestUtils.test.ts @@ -5,8 +5,7 @@ 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 'common/Types'; -import { ICircularList, XtermListener } from 'common/Types'; +import { IBufferLine, ICellData, IAttributeData, ICircularList, XtermListener } from 'common/Types'; import { Buffer } from './Buffer'; import * as Browser from 'common/Platform'; import { IDisposable, IMarker, IEvent, ISelectionPosition } from 'xterm'; diff --git a/src/Types.ts b/src/Types.ts index c0ce984a..b5c2bd29 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -4,8 +4,7 @@ */ import { ITerminalOptions as IPublicTerminalOptions, IEventEmitter, IDisposable, IMarker, ISelectionPosition } from 'xterm'; -import { ICharset, IAttributeData, ICellData, IBufferLine, CharData } from 'common/Types'; -import { ICircularList } from 'common/Types'; +import { ICharset, IAttributeData, ICellData, IBufferLine, CharData, ICircularList } from 'common/Types'; import { IEvent } from 'common/EventEmitter2'; import { IColorSet } from 'ui/Types'; import { IOptionsService } from 'common/services/Services'; diff --git a/src/renderer/BaseRenderLayer.ts b/src/renderer/BaseRenderLayer.ts index 4b31e270..b5836ed9 100644 --- a/src/renderer/BaseRenderLayer.ts +++ b/src/renderer/BaseRenderLayer.ts @@ -5,8 +5,7 @@ import { IRenderLayer, IRenderDimensions } from './Types'; import { ITerminal } from '../Types'; -import { ICellData } from 'common/Types'; -import { DEFAULT_COLOR } from 'common/Types'; +import { ICellData, 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'; From 6e91875bc4c77f4075c906b91cfeb91765f16840 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 8 Jun 2019 16:14:29 -0700 Subject: [PATCH 3/3] Rename ui to browser --- demo/start.js | 3 +-- src/AccessibilityManager.ts | 6 +++--- src/CompositionHelper.ts | 2 +- src/MouseHelper.ts | 2 +- src/MouseZoneManager.ts | 2 +- src/SelectionManager.ts | 2 +- src/Terminal.ts | 8 ++++---- src/TestUtils.test.ts | 4 ++-- src/Types.ts | 2 +- src/Viewport.ts | 6 +++--- src/{ui => browser}/ColorManager.test.ts | 2 +- src/{ui => browser}/ColorManager.ts | 2 +- src/{ui => browser}/Lifecycle.ts | 0 src/{ui => browser}/RenderDebouncer.ts | 0 src/{ui => browser}/ScreenDprMonitor.ts | 0 src/{ui => browser}/Types.ts | 0 src/{ui => browser}/services/CharSizeService.ts | 2 +- src/{ui => browser}/services/Services.d.ts | 0 src/{ui => browser}/tsconfig.json | 0 src/renderer/BaseRenderLayer.ts | 2 +- src/renderer/CursorRenderLayer.ts | 2 +- src/renderer/LinkRenderLayer.ts | 2 +- src/renderer/RenderCoordinator.ts | 10 +++++----- src/renderer/Renderer.ts | 4 ++-- src/renderer/SelectionRenderLayer.ts | 2 +- src/renderer/TextRenderLayer.ts | 2 +- src/renderer/Types.ts | 2 +- src/renderer/atlas/CharAtlasCache.ts | 2 +- src/renderer/atlas/CharAtlasUtils.ts | 2 +- src/renderer/atlas/DynamicCharAtlas.ts | 4 ++-- src/renderer/atlas/Types.ts | 2 +- src/renderer/dom/DomRenderer.ts | 4 ++-- src/tsconfig.json | 4 ++-- webpack.config.js | 3 +-- 34 files changed, 44 insertions(+), 46 deletions(-) rename src/{ui => browser}/ColorManager.test.ts (99%) rename src/{ui => browser}/ColorManager.ts (98%) rename src/{ui => browser}/Lifecycle.ts (100%) rename src/{ui => browser}/RenderDebouncer.ts (100%) rename src/{ui => browser}/ScreenDprMonitor.ts (100%) rename src/{ui => browser}/Types.ts (100%) rename src/{ui => browser}/services/CharSizeService.ts (97%) rename src/{ui => browser}/services/Services.d.ts (100%) rename src/{ui => browser}/tsconfig.json (100%) diff --git a/demo/start.js b/demo/start.js index 20195215..a054e939 100644 --- a/demo/start.js +++ b/demo/start.js @@ -51,8 +51,7 @@ const clientConfig = { extensions: [ '.tsx', '.ts', '.js' ], alias: { common: path.resolve('./out/common'), - core: path.resolve('./out/core'), - ui: path.resolve('./out/ui') + browser: path.resolve('./out/browser') } }, output: { diff --git a/src/AccessibilityManager.ts b/src/AccessibilityManager.ts index a2a6209c..4ff359d0 100644 --- a/src/AccessibilityManager.ts +++ b/src/AccessibilityManager.ts @@ -6,10 +6,10 @@ import * as Strings from './Strings'; import { ITerminal, IBuffer } from './Types'; import { isMac } from 'common/Platform'; -import { RenderDebouncer } from 'ui/RenderDebouncer'; -import { addDisposableDomListener } from 'ui/Lifecycle'; +import { RenderDebouncer } from 'browser/RenderDebouncer'; +import { addDisposableDomListener } from 'browser/Lifecycle'; import { Disposable } from 'common/Lifecycle'; -import { ScreenDprMonitor } from 'ui/ScreenDprMonitor'; +import { ScreenDprMonitor } from 'browser/ScreenDprMonitor'; import { IRenderDimensions } from './renderer/Types'; const MAX_ROWS_TO_READ = 20; diff --git a/src/CompositionHelper.ts b/src/CompositionHelper.ts index e1179fed..2b2d3042 100644 --- a/src/CompositionHelper.ts +++ b/src/CompositionHelper.ts @@ -4,7 +4,7 @@ */ import { ITerminal } from './Types'; -import { ICharSizeService } from 'ui/services/Services'; +import { ICharSizeService } from 'browser/services/Services'; interface IPosition { start: number; diff --git a/src/MouseHelper.ts b/src/MouseHelper.ts index d5662ab0..cf4811a5 100644 --- a/src/MouseHelper.ts +++ b/src/MouseHelper.ts @@ -5,7 +5,7 @@ import { IMouseHelper } from './Types'; import { RenderCoordinator } from './renderer/RenderCoordinator'; -import { ICharSizeService } from 'ui/services/Services'; +import { ICharSizeService } from 'browser/services/Services'; export class MouseHelper implements IMouseHelper { constructor( diff --git a/src/MouseZoneManager.ts b/src/MouseZoneManager.ts index 109bc517..b2ee9b14 100644 --- a/src/MouseZoneManager.ts +++ b/src/MouseZoneManager.ts @@ -5,7 +5,7 @@ import { ITerminal, IMouseZoneManager, IMouseZone } from './Types'; import { Disposable } from 'common/Lifecycle'; -import { addDisposableDomListener } from 'ui/Lifecycle'; +import { addDisposableDomListener } from 'browser/Lifecycle'; const HOVER_DURATION = 500; diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index 33a087e2..498b4abe 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -12,7 +12,7 @@ import { AltClickHandler } from './handlers/AltClickHandler'; import { CellData } from 'common/buffer/BufferLine'; import { IDisposable } from 'xterm'; import { EventEmitter2, IEvent } from 'common/EventEmitter2'; -import { ICharSizeService } from 'ui/services/Services'; +import { ICharSizeService } from 'browser/services/Services'; /** * The number of pixels the mouse needs to be above or below the viewport in diff --git a/src/Terminal.ts b/src/Terminal.ts index 3608b3bf..a5348568 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -35,7 +35,7 @@ import { Renderer } from './renderer/Renderer'; import { Linkifier } from './Linkifier'; import { SelectionManager } from './SelectionManager'; import * as Browser from 'common/Platform'; -import { addDisposableDomListener } from 'ui/Lifecycle'; +import { addDisposableDomListener } from 'browser/Lifecycle'; import * as Strings from './Strings'; import { MouseHelper } from './MouseHelper'; import { SoundManager } from './SoundManager'; @@ -49,12 +49,12 @@ import { evaluateKeyboardEvent } from 'common/input/Keyboard'; import { EventEmitter2, IEvent } from 'common/EventEmitter2'; import { Attributes, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; import { applyWindowsMode } from './WindowsMode'; -import { ColorManager } from 'ui/ColorManager'; +import { ColorManager } from 'browser/ColorManager'; import { RenderCoordinator } from './renderer/RenderCoordinator'; import { IOptionsService } from 'common/services/Services'; import { OptionsService } from 'common/services/OptionsService'; -import { ICharSizeService } from 'ui/services/Services'; -import { CharSizeService } from 'ui/services/CharSizeService'; +import { ICharSizeService } from 'browser/services/Services'; +import { CharSizeService } from 'browser/services/CharSizeService'; // Let it work inside Node.js for automated testing purposes. const document = (typeof window !== 'undefined') ? window.document : null; diff --git a/src/TestUtils.test.ts b/src/TestUtils.test.ts index 914477ca..e8fdeeba 100644 --- a/src/TestUtils.test.ts +++ b/src/TestUtils.test.ts @@ -11,9 +11,9 @@ import * as Browser from 'common/Platform'; import { IDisposable, IMarker, IEvent, ISelectionPosition } from 'xterm'; import { Terminal } from './Terminal'; import { AttributeData } from 'common/buffer/BufferLine'; -import { IColorManager, IColorSet } from 'ui/Types'; +import { IColorManager, IColorSet } from 'browser/Types'; import { IOptionsService } from 'common/services/Services'; -import { ICharSizeService } from 'ui/services/Services'; +import { ICharSizeService } from 'browser/services/Services'; export class TestTerminal extends Terminal { writeSync(data: string): void { diff --git a/src/Types.ts b/src/Types.ts index b5c2bd29..cb6f4178 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -6,7 +6,7 @@ import { ITerminalOptions as IPublicTerminalOptions, IEventEmitter, IDisposable, IMarker, ISelectionPosition } from 'xterm'; import { ICharset, IAttributeData, ICellData, IBufferLine, CharData, ICircularList } from 'common/Types'; import { IEvent } from 'common/EventEmitter2'; -import { IColorSet } from 'ui/Types'; +import { IColorSet } from 'browser/Types'; import { IOptionsService } from 'common/services/Services'; export type CustomKeyEventHandler = (event: KeyboardEvent) => boolean; diff --git a/src/Viewport.ts b/src/Viewport.ts index 90565a34..6fa51bf8 100644 --- a/src/Viewport.ts +++ b/src/Viewport.ts @@ -5,10 +5,10 @@ import { ITerminal, IViewport } from './Types'; import { Disposable } from 'common/Lifecycle'; -import { addDisposableDomListener } from 'ui/Lifecycle'; -import { IColorSet } from 'ui/Types'; +import { addDisposableDomListener } from 'browser/Lifecycle'; +import { IColorSet } from 'browser/Types'; import { IRenderDimensions } from './renderer/Types'; -import { ICharSizeService } from 'ui/services/Services'; +import { ICharSizeService } from 'browser/services/Services'; const FALLBACK_SCROLL_BAR_WIDTH = 15; diff --git a/src/ui/ColorManager.test.ts b/src/browser/ColorManager.test.ts similarity index 99% rename from src/ui/ColorManager.test.ts rename to src/browser/ColorManager.test.ts index e4d79092..a213c616 100644 --- a/src/ui/ColorManager.test.ts +++ b/src/browser/ColorManager.test.ts @@ -5,7 +5,7 @@ import jsdom = require('jsdom'); import { assert } from 'chai'; -import { ColorManager } from 'ui/ColorManager'; +import { ColorManager } from 'browser/ColorManager'; describe('ColorManager', () => { let cm: ColorManager; diff --git a/src/ui/ColorManager.ts b/src/browser/ColorManager.ts similarity index 98% rename from src/ui/ColorManager.ts rename to src/browser/ColorManager.ts index f1fe5842..9a574e4a 100644 --- a/src/ui/ColorManager.ts +++ b/src/browser/ColorManager.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { IColorManager, IColor, IColorSet, ITheme } from 'ui/Types'; +import { IColorManager, IColor, IColorSet, ITheme } from 'browser/Types'; const DEFAULT_FOREGROUND = fromHex('#ffffff'); const DEFAULT_BACKGROUND = fromHex('#000000'); diff --git a/src/ui/Lifecycle.ts b/src/browser/Lifecycle.ts similarity index 100% rename from src/ui/Lifecycle.ts rename to src/browser/Lifecycle.ts diff --git a/src/ui/RenderDebouncer.ts b/src/browser/RenderDebouncer.ts similarity index 100% rename from src/ui/RenderDebouncer.ts rename to src/browser/RenderDebouncer.ts diff --git a/src/ui/ScreenDprMonitor.ts b/src/browser/ScreenDprMonitor.ts similarity index 100% rename from src/ui/ScreenDprMonitor.ts rename to src/browser/ScreenDprMonitor.ts diff --git a/src/ui/Types.ts b/src/browser/Types.ts similarity index 100% rename from src/ui/Types.ts rename to src/browser/Types.ts diff --git a/src/ui/services/CharSizeService.ts b/src/browser/services/CharSizeService.ts similarity index 97% rename from src/ui/services/CharSizeService.ts rename to src/browser/services/CharSizeService.ts index 61405909..60ce685e 100644 --- a/src/ui/services/CharSizeService.ts +++ b/src/browser/services/CharSizeService.ts @@ -5,7 +5,7 @@ import { IOptionsService } from 'common/services/Services'; import { IEvent, EventEmitter2 } from 'common/EventEmitter2'; -import { ICharSizeService } from 'ui/services/Services'; +import { ICharSizeService } from 'browser/services/Services'; export class CharSizeService implements ICharSizeService { public width: number = 0; diff --git a/src/ui/services/Services.d.ts b/src/browser/services/Services.d.ts similarity index 100% rename from src/ui/services/Services.d.ts rename to src/browser/services/Services.d.ts diff --git a/src/ui/tsconfig.json b/src/browser/tsconfig.json similarity index 100% rename from src/ui/tsconfig.json rename to src/browser/tsconfig.json diff --git a/src/renderer/BaseRenderLayer.ts b/src/renderer/BaseRenderLayer.ts index b5836ed9..8a06b1c4 100644 --- a/src/renderer/BaseRenderLayer.ts +++ b/src/renderer/BaseRenderLayer.ts @@ -10,7 +10,7 @@ import { DIM_OPACITY, INVERTED_DEFAULT_COLOR, IGlyphIdentifier } from './atlas/T import { BaseCharAtlas } from './atlas/BaseCharAtlas'; import { acquireCharAtlas } from './atlas/CharAtlasCache'; import { CellData, AttributeData, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE } from 'common/buffer/BufferLine'; -import { IColorSet } from 'ui/Types'; +import { IColorSet } from 'browser/Types'; export abstract class BaseRenderLayer implements IRenderLayer { private _canvas: HTMLCanvasElement; diff --git a/src/renderer/CursorRenderLayer.ts b/src/renderer/CursorRenderLayer.ts index dbf11d55..b5dfcd0f 100644 --- a/src/renderer/CursorRenderLayer.ts +++ b/src/renderer/CursorRenderLayer.ts @@ -8,7 +8,7 @@ import { BaseRenderLayer } from './BaseRenderLayer'; import { ITerminal } from '../Types'; import { ICellData } from 'common/Types'; import { CellData } from 'common/buffer/BufferLine'; -import { IColorSet } from 'ui/Types'; +import { IColorSet } from 'browser/Types'; interface ICursorState { x: number; diff --git a/src/renderer/LinkRenderLayer.ts b/src/renderer/LinkRenderLayer.ts index 38dcf4b1..63cf0335 100644 --- a/src/renderer/LinkRenderLayer.ts +++ b/src/renderer/LinkRenderLayer.ts @@ -8,7 +8,7 @@ import { IRenderDimensions } from './Types'; import { BaseRenderLayer } from './BaseRenderLayer'; import { INVERTED_DEFAULT_COLOR } from './atlas/Types'; import { is256Color } from './atlas/CharAtlasUtils'; -import { IColorSet } from 'ui/Types'; +import { IColorSet } from 'browser/Types'; export class LinkRenderLayer extends BaseRenderLayer { private _state: ILinkifierEvent = null; diff --git a/src/renderer/RenderCoordinator.ts b/src/renderer/RenderCoordinator.ts index dc6e0694..f5916b1d 100644 --- a/src/renderer/RenderCoordinator.ts +++ b/src/renderer/RenderCoordinator.ts @@ -4,15 +4,15 @@ */ import { IRenderer, IRenderDimensions } from './Types'; -import { RenderDebouncer } from 'ui/RenderDebouncer'; +import { RenderDebouncer } from 'browser/RenderDebouncer'; import { EventEmitter2, IEvent } from 'common/EventEmitter2'; import { Disposable } from 'common/Lifecycle'; -import { ScreenDprMonitor } from 'ui/ScreenDprMonitor'; -import { addDisposableDomListener } from 'ui/Lifecycle'; -import { IColorSet } from 'ui/Types'; +import { ScreenDprMonitor } from 'browser/ScreenDprMonitor'; +import { addDisposableDomListener } from 'browser/Lifecycle'; +import { IColorSet } from 'browser/Types'; import { CharacterJoinerHandler } from '../Types'; import { IOptionsService } from 'common/services/Services'; -import { ICharSizeService } from 'ui/services/Services'; +import { ICharSizeService } from 'browser/services/Services'; export class RenderCoordinator extends Disposable { private _renderDebouncer: RenderDebouncer; diff --git a/src/renderer/Renderer.ts b/src/renderer/Renderer.ts index 19adddbf..c56327df 100644 --- a/src/renderer/Renderer.ts +++ b/src/renderer/Renderer.ts @@ -11,8 +11,8 @@ import { ITerminal, CharacterJoinerHandler } from '../Types'; import { LinkRenderLayer } from './LinkRenderLayer'; import { CharacterJoinerRegistry } from '../renderer/CharacterJoinerRegistry'; import { Disposable } from 'common/Lifecycle'; -import { IColorSet } from 'ui/Types'; -import { ICharSizeService } from 'ui/services/Services'; +import { IColorSet } from 'browser/Types'; +import { ICharSizeService } from 'browser/services/Services'; export class Renderer extends Disposable implements IRenderer { private _renderLayers: IRenderLayer[]; diff --git a/src/renderer/SelectionRenderLayer.ts b/src/renderer/SelectionRenderLayer.ts index 96bf6ec3..b555ac98 100644 --- a/src/renderer/SelectionRenderLayer.ts +++ b/src/renderer/SelectionRenderLayer.ts @@ -6,7 +6,7 @@ import { ITerminal } from '../Types'; import { IRenderDimensions } from './Types'; import { BaseRenderLayer } from './BaseRenderLayer'; -import { IColorSet } from 'ui/Types'; +import { IColorSet } from 'browser/Types'; interface ISelectionState { start: [number, number]; diff --git a/src/renderer/TextRenderLayer.ts b/src/renderer/TextRenderLayer.ts index 4594a2c8..3aeb96c8 100644 --- a/src/renderer/TextRenderLayer.ts +++ b/src/renderer/TextRenderLayer.ts @@ -10,7 +10,7 @@ import { GridCache } from './GridCache'; import { BaseRenderLayer } from './BaseRenderLayer'; import { CellData, AttributeData, Content, NULL_CELL_CODE } from 'common/buffer/BufferLine'; import { JoinedCellData } from './CharacterJoinerRegistry'; -import { IColorSet } from 'ui/Types'; +import { IColorSet } from 'browser/Types'; /** * This CharData looks like a null character, which will forc a clear and render diff --git a/src/renderer/Types.ts b/src/renderer/Types.ts index d8f637eb..017285d8 100644 --- a/src/renderer/Types.ts +++ b/src/renderer/Types.ts @@ -5,7 +5,7 @@ import { ITerminal, CharacterJoinerHandler } from '../Types'; import { IDisposable } from 'xterm'; -import { IColorSet } from 'ui/Types'; +import { IColorSet } from 'browser/Types'; /** * Flags used to render terminal text properly. diff --git a/src/renderer/atlas/CharAtlasCache.ts b/src/renderer/atlas/CharAtlasCache.ts index 80c05d6f..43b5eb83 100644 --- a/src/renderer/atlas/CharAtlasCache.ts +++ b/src/renderer/atlas/CharAtlasCache.ts @@ -8,7 +8,7 @@ import { generateConfig, configEquals } from './CharAtlasUtils'; import { BaseCharAtlas } from './BaseCharAtlas'; import { DynamicCharAtlas } from './DynamicCharAtlas'; import { ICharAtlasConfig } from './Types'; -import { IColorSet } from 'ui/Types'; +import { IColorSet } from 'browser/Types'; interface ICharAtlasCacheEntry { atlas: BaseCharAtlas; diff --git a/src/renderer/atlas/CharAtlasUtils.ts b/src/renderer/atlas/CharAtlasUtils.ts index ab0f3240..b68793f6 100644 --- a/src/renderer/atlas/CharAtlasUtils.ts +++ b/src/renderer/atlas/CharAtlasUtils.ts @@ -6,7 +6,7 @@ import { ITerminal } from '../../Types'; import { ICharAtlasConfig } from './Types'; import { DEFAULT_COLOR } from 'common/Types'; -import { IColorSet } from 'ui/Types'; +import { IColorSet } from 'browser/Types'; export function generateConfig(scaledCharWidth: number, scaledCharHeight: number, terminal: ITerminal, colors: IColorSet): ICharAtlasConfig { // null out some fields that don't matter diff --git a/src/renderer/atlas/DynamicCharAtlas.ts b/src/renderer/atlas/DynamicCharAtlas.ts index 695162c1..c8ccefcb 100644 --- a/src/renderer/atlas/DynamicCharAtlas.ts +++ b/src/renderer/atlas/DynamicCharAtlas.ts @@ -5,10 +5,10 @@ import { DIM_OPACITY, IGlyphIdentifier, INVERTED_DEFAULT_COLOR, ICharAtlasConfig } from './Types'; import { BaseCharAtlas } from './BaseCharAtlas'; -import { DEFAULT_ANSI_COLORS } from 'ui/ColorManager'; +import { DEFAULT_ANSI_COLORS } from 'browser/ColorManager'; import { LRUMap } from './LRUMap'; import { isFirefox, isSafari } from 'common/Platform'; -import { IColor } from 'ui/Types'; +import { IColor } from 'browser/Types'; // In practice we're probably never going to exhaust a texture this large. For debugging purposes, // however, it can be useful to set this to a really tiny value, to verify that LRU eviction works. diff --git a/src/renderer/atlas/Types.ts b/src/renderer/atlas/Types.ts index 5bfd83bf..2cb1db40 100644 --- a/src/renderer/atlas/Types.ts +++ b/src/renderer/atlas/Types.ts @@ -4,7 +4,7 @@ */ import { FontWeight } from 'xterm'; -import { IColorSet } from 'ui/Types'; +import { IColorSet } from 'browser/Types'; export const INVERTED_DEFAULT_COLOR = 257; export const DIM_OPACITY = 0.5; diff --git a/src/renderer/dom/DomRenderer.ts b/src/renderer/dom/DomRenderer.ts index 77cfcba8..7c41f028 100644 --- a/src/renderer/dom/DomRenderer.ts +++ b/src/renderer/dom/DomRenderer.ts @@ -8,8 +8,8 @@ import { ILinkifierEvent, ITerminal, CharacterJoinerHandler } 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 { Disposable } from 'common/Lifecycle'; -import { IColorSet } from 'ui/Types'; -import { ICharSizeService } from 'ui/services/Services'; +import { IColorSet } from 'browser/Types'; +import { ICharSizeService } from 'browser/services/Services'; const TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-'; const ROW_CONTAINER_CLASS = 'xterm-rows'; diff --git a/src/tsconfig.json b/src/tsconfig.json index c99f2b19..97576668 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -14,7 +14,7 @@ "baseUrl": ".", "paths": { "common/*": [ "./common/*" ], - "ui/*": [ "./ui/*" ] + "browser/*": [ "./browser/*" ] }, "noUnusedLocals": true, @@ -29,6 +29,6 @@ ], "references": [ { "path": "./common" }, - { "path": "./ui" } + { "path": "./browser" } ] } diff --git a/webpack.config.js b/webpack.config.js index 5e0a2754..3f55dda3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -29,8 +29,7 @@ module.exports = { extensions: [ '.js' ], alias: { common: path.resolve('./out/common'), - core: path.resolve('./out/core'), - ui: path.resolve('./out/ui') + browser: path.resolve('./out/browser') } }, output: {