From 4a3609f8051f19bf3f53c65cfdfcead9116e2f2e Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sun, 31 Mar 2019 23:21:11 -0700 Subject: [PATCH 1/4] Move platform to common and remove dom dependence in common Because common/ imports 'xterm', it also imported dom accidentally. Fixes #1990 --- src/AccessibilityManager.ts | 2 +- src/SelectionManager.ts | 2 +- src/Terminal.ts | 2 +- src/common/EventEmitter.ts | 3 +-- src/common/Lifecycle.ts | 2 +- src/{core => common}/Platform.ts | 7 +++++++ src/common/Types.ts | 11 ++++++++++- src/common/tsconfig.json | 5 ++++- src/core/tsconfig.json | 2 +- src/renderer/atlas/CharAtlasGenerator.ts | 2 +- src/renderer/atlas/DynamicCharAtlas.ts | 2 +- src/tsconfig-base.json | 4 +--- src/tsconfig-library-base.json | 4 ---- src/tsconfig.json | 3 +-- src/ui/TestUtils.test.ts | 2 +- 15 files changed, 32 insertions(+), 21 deletions(-) rename src/{core => common}/Platform.ts (90%) diff --git a/src/AccessibilityManager.ts b/src/AccessibilityManager.ts index fa0121ad0f..877676c97b 100644 --- a/src/AccessibilityManager.ts +++ b/src/AccessibilityManager.ts @@ -5,7 +5,7 @@ import * as Strings from './Strings'; import { ITerminal, IBuffer } from './Types'; -import { isMac } from './core/Platform'; +import { isMac } from './common/Platform'; import { RenderDebouncer } from './ui/RenderDebouncer'; import { addDisposableDomListener } from './ui/Lifecycle'; import { Disposable } from './common/Lifecycle'; diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index f93328fe6f..e4bf87ea3f 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -6,7 +6,7 @@ import { ITerminal, ISelectionManager, IBuffer, CharData, IBufferLine } from './Types'; import { XtermListener } from './common/Types'; import { MouseHelper } from './ui/MouseHelper'; -import * as Browser from './core/Platform'; +import * as Browser from './common/Platform'; import { CharMeasure } from './ui/CharMeasure'; import { EventEmitter } from './common/EventEmitter'; import { SelectionModel } from './SelectionModel'; diff --git a/src/Terminal.ts b/src/Terminal.ts index c2497df440..ebdb8a89af 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -36,7 +36,7 @@ import { Renderer } from './renderer/Renderer'; import { Linkifier } from './Linkifier'; import { SelectionManager } from './SelectionManager'; import { CharMeasure } from './ui/CharMeasure'; -import * as Browser from './core/Platform'; +import * as Browser from './common/Platform'; import { addDisposableDomListener } from './ui/Lifecycle'; import * as Strings from './Strings'; import { MouseHelper } from './ui/MouseHelper'; diff --git a/src/common/EventEmitter.ts b/src/common/EventEmitter.ts index 68eb60f7a5..74a794cd0e 100644 --- a/src/common/EventEmitter.ts +++ b/src/common/EventEmitter.ts @@ -3,8 +3,7 @@ * @license MIT */ -import { XtermListener } from './Types'; -import { IEventEmitter, IDisposable } from 'xterm'; +import { IDisposable, IEventEmitter, XtermListener } from './Types'; import { Disposable } from './Lifecycle'; export class EventEmitter extends Disposable implements IEventEmitter, IDisposable { diff --git a/src/common/Lifecycle.ts b/src/common/Lifecycle.ts index 209a3e2ac5..5fac6e8251 100644 --- a/src/common/Lifecycle.ts +++ b/src/common/Lifecycle.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { IDisposable } from 'xterm'; +import { IDisposable } from './Types'; /** * A base class that can be extended to provide convenience methods for managing the lifecycle of an diff --git a/src/core/Platform.ts b/src/common/Platform.ts similarity index 90% rename from src/core/Platform.ts rename to src/common/Platform.ts index 42c20d9d24..bb0ad54bf2 100644 --- a/src/core/Platform.ts +++ b/src/common/Platform.ts @@ -3,6 +3,13 @@ * @license MIT */ +interface INavigator { + userAgent: string; + language: string; + platform: string; +} +declare const navigator: INavigator; + const isNode = (typeof navigator === 'undefined') ? true : false; const userAgent = (isNode) ? 'node' : navigator.userAgent; const platform = (isNode) ? 'node' : navigator.platform; diff --git a/src/common/Types.ts b/src/common/Types.ts index 8a416bf1ab..8ad98d99cc 100644 --- a/src/common/Types.ts +++ b/src/common/Types.ts @@ -3,7 +3,16 @@ * @license MIT */ -import { IEventEmitter } from 'xterm'; +export interface IDisposable { + dispose(): void; +} + +export interface IEventEmitter { + on(type: string, listener: (...args: any[]) => void): void; + off(type: string, listener: (...args: any[]) => void): void; + emit(type: string, data?: any): void; + addDisposableListener(type: string, handler: (...args: any[]) => void): IDisposable; +} export type XtermListener = (...args: any[]) => void; diff --git a/src/common/tsconfig.json b/src/common/tsconfig.json index b40bb2f500..6d8d1a56f5 100644 --- a/src/common/tsconfig.json +++ b/src/common/tsconfig.json @@ -1,7 +1,10 @@ { "extends": "../tsconfig-library-base", "compilerOptions": { - "outDir": "../../lib" + "outDir": "../../lib", + "types": [ + "../../node_modules/@types/mocha" + ] }, "include": [ "./**/*" diff --git a/src/core/tsconfig.json b/src/core/tsconfig.json index 41e41f0c12..1fcf9e474a 100644 --- a/src/core/tsconfig.json +++ b/src/core/tsconfig.json @@ -4,7 +4,7 @@ "outDir": "../../lib" }, "include": [ - "./**/*" + "./**/*", "../common/Platform.ts" ], "references": [ { "path": "../common" } diff --git a/src/renderer/atlas/CharAtlasGenerator.ts b/src/renderer/atlas/CharAtlasGenerator.ts index cadcce2ec1..389507661e 100644 --- a/src/renderer/atlas/CharAtlasGenerator.ts +++ b/src/renderer/atlas/CharAtlasGenerator.ts @@ -4,7 +4,7 @@ */ import { FontWeight } from 'xterm'; -import { isFirefox, isSafari } from '../../core/Platform'; +import { isFirefox, isSafari } from '../../common/Platform'; import { IColor } from '../Types'; import { ICharAtlasConfig, CHAR_ATLAS_CELL_SPACING } from './Types'; diff --git a/src/renderer/atlas/DynamicCharAtlas.ts b/src/renderer/atlas/DynamicCharAtlas.ts index e311c369a3..cb03a48f94 100644 --- a/src/renderer/atlas/DynamicCharAtlas.ts +++ b/src/renderer/atlas/DynamicCharAtlas.ts @@ -8,7 +8,7 @@ import BaseCharAtlas from './BaseCharAtlas'; import { DEFAULT_ANSI_COLORS } from '../ColorManager'; import { clearColor } from './CharAtlasGenerator'; import LRUMap from './LRUMap'; -import { isFirefox, isSafari } from '../../core/Platform'; +import { isFirefox, isSafari } from '../../common/Platform'; import { IColor } from '../Types'; // In practice we're probably never going to exhaust a texture this large. For debugging purposes, diff --git a/src/tsconfig-base.json b/src/tsconfig-base.json index 5c6afcc5b0..84d0c924de 100644 --- a/src/tsconfig-base.json +++ b/src/tsconfig-base.json @@ -8,8 +8,6 @@ "removeComments": true, "pretty": true, - "incremental": true, - - "skipLibCheck": true + "incremental": true } } diff --git a/src/tsconfig-library-base.json b/src/tsconfig-library-base.json index c82e087351..66b61f09e1 100644 --- a/src/tsconfig-library-base.json +++ b/src/tsconfig-library-base.json @@ -1,10 +1,6 @@ { "extends": "./tsconfig-base.json", "compilerOptions": { - "types": [ - "../../node_modules/@types/mocha", - "../../" - ], "composite": true, "strict": true } diff --git a/src/tsconfig.json b/src/tsconfig.json index 0aa3abb884..f0b1c7490d 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -11,7 +11,7 @@ ], "rootDir": ".", "outDir": "../lib", - + "noUnusedLocals": true, "noImplicitAny": true }, @@ -27,4 +27,3 @@ { "path": "./core" } ] } - \ No newline at end of file diff --git a/src/ui/TestUtils.test.ts b/src/ui/TestUtils.test.ts index e6e4aaa32f..b418ee6c88 100644 --- a/src/ui/TestUtils.test.ts +++ b/src/ui/TestUtils.test.ts @@ -7,7 +7,7 @@ import { IColorSet, IRenderer, IRenderDimensions, IColorManager } from '../rende import { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminal, IBuffer, IBufferSet, IBrowser, ICharMeasure, ISelectionManager, ITerminalOptions, ILinkifier, IMouseHelper, ILinkMatcherOptions, CharacterJoinerHandler, IBufferLine, IBufferStringIterator } from '../Types'; import { ICircularList, XtermListener } from '../common/Types'; import { Buffer } from '../Buffer'; -import * as Browser from '../core/Platform'; +import * as Browser from '../common/Platform'; import { ITheme, IDisposable, IMarker } from 'xterm'; import { Terminal } from '../Terminal'; From 2e10c8c25e9823dfa96a98bc12475f1b36bdf594 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 2 Apr 2019 08:04:39 -0700 Subject: [PATCH 2/4] Clean up --- src/common/Platform.ts | 3 +++ src/common/tsconfig.json | 4 +--- src/core/tsconfig.json | 9 +++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/common/Platform.ts b/src/common/Platform.ts index bb0ad54bf2..ee82cff4fb 100644 --- a/src/common/Platform.ts +++ b/src/common/Platform.ts @@ -8,6 +8,9 @@ interface INavigator { language: string; platform: string; } + +// We're declaring a navigator global here as we expect it in all runtimes (node and browser), but +// we want this module to live in common. declare const navigator: INavigator; const isNode = (typeof navigator === 'undefined') ? true : false; diff --git a/src/common/tsconfig.json b/src/common/tsconfig.json index 6d8d1a56f5..ccf742e5f7 100644 --- a/src/common/tsconfig.json +++ b/src/common/tsconfig.json @@ -6,7 +6,5 @@ "../../node_modules/@types/mocha" ] }, - "include": [ - "./**/*" - ] + "include": [ "./**/*" ] } diff --git a/src/core/tsconfig.json b/src/core/tsconfig.json index 1fcf9e474a..99bf48ca7c 100644 --- a/src/core/tsconfig.json +++ b/src/core/tsconfig.json @@ -1,11 +1,12 @@ { "extends": "../tsconfig-library-base", "compilerOptions": { - "outDir": "../../lib" + "outDir": "../../lib", + "types": [ + "../../node_modules/@types/mocha" + ] }, - "include": [ - "./**/*", "../common/Platform.ts" - ], + "include": [ "./**/*" ], "references": [ { "path": "../common" } ] From 68e3d7fa164bfff08ac143d8ef3f9f62e7b14ed0 Mon Sep 17 00:00:00 2001 From: Vadim Zakondyrin Date: Wed, 3 Apr 2019 12:10:32 +0600 Subject: [PATCH 3/4] Fix CSI scroll down handler The issue has been introduced in cd8477a942e1fac85de167eab7e8c09c85f55255 --- src/InputHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/InputHandler.ts b/src/InputHandler.ts index 37c9bbe570..237e0849f0 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -898,7 +898,7 @@ export class InputHandler extends Disposable implements IInputHandler { while (param--) { buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 1); - buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 0, buffer.getBlankLine(DEFAULT_ATTR)); + buffer.lines.splice(buffer.ybase + buffer.scrollTop, 0, buffer.getBlankLine(DEFAULT_ATTR)); } // this.maxRange(); this._terminal.updateRange(buffer.scrollTop); From b18829963cd7f7ff4598f00fd8eedf2dc035793c Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 4 Apr 2019 00:01:43 -0400 Subject: [PATCH 4/4] Fix backspace on demo buffer.x will probably be public API soon (#1994) Fixes #1989 --- demo/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/client.ts b/demo/client.ts index fa98ee4ea1..7a60189848 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -172,7 +172,7 @@ function runFakeTerminal(): void { term.prompt(); } else if (ev.keyCode === 8) { // Do not delete the prompt - if (term.x > 2) { + if (term._core.buffer.x > 2) { term.write('\b \b'); } } else if (printable) {