From a61ba2e140affbc1a247a93204bdc2ed6bafe71f Mon Sep 17 00:00:00 2001 From: pro-src Date: Thu, 26 Apr 2018 09:18:18 -0500 Subject: [PATCH 01/19] closes #1361 --- .npmignore | 55 ++++++++++++++++++++++++++++++++++++++++------------ package.json | 27 -------------------------- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/.npmignore b/.npmignore index 63069bda..eeb46409 100644 --- a/.npmignore +++ b/.npmignore @@ -1,16 +1,47 @@ -node_modules/ -*.swp -.lock-wscript -lib/*.test.js -lib/*.test.js.map +# Blacklist - exclude everything except npm defaults such as LICENSE, etc +* +!*/ + +# Whitelist - entries to be included must be negated with "!" +!*.js +!*.json + +# Whitelist - dist/ +!dist/**/*.js +!dist/**/*.js.map + +!dist/**/*.css + +# Whitelist - lib/ +!lib/**/*.d.ts + +!lib/**/*.js +!lib/**/*.js.map + +!lib/**/*.css + +# Whitelist - src/ +!src/**/*.ts +!src/**/*.d.ts + +!src/**/*.js +!src/**/*.js.map + +!src/**/*.css + +# Whitelist - typings/ +!typings/*.d.ts + +# Blacklist - (normal behavior) these will override any whitelist +*.test.ts +*.test.d.ts +*.test.js +*.test.js.map lib/test/ -Makefile.gyp -*.Makefile -*.target.gyp.mk -*.node -example/*.log + docs/ -npm-debug.log /.idea/ -.env +.vscode/ build/ +fixtures/ +coverage/ diff --git a/package.json b/package.json index d4a06f82..4db430bc 100644 --- a/package.json +++ b/package.json @@ -11,33 +11,6 @@ "types": "typings/xterm.d.ts", "repository": "https://github.com/xtermjs/xterm.js", "license": "MIT", - "files": [ - "*.js", - "*.json", - "dist/*.css", - "dist/**/*.css", - "dist/*.js", - "dist/*.js.map", - "dist/**/*.js", - "dist/**/*.js.map", - "lib/*.css", - "lib/**/*.css", - "lib/*.d.ts", - "lib/*.js", - "lib/*.js.map", - "lib/**/*.d.ts", - "lib/**/*.js", - "lib/**/*.js.map", - "src/*.css", - "src/**/*.css", - "src/*.js", - "src/*.js.map", - "src/*.ts", - "src/**/*.js", - "src/**/*.js.map", - "src/**/*.ts", - "typings/*.d.ts" - ], "devDependencies": { "@types/chai": "^3.4.34", "@types/jsdom": "^11.0.1", From 30b88113a879d05a79a9c52b60408f580ca62f30 Mon Sep 17 00:00:00 2001 From: pro-src Date: Thu, 26 Apr 2018 12:09:21 -0500 Subject: [PATCH 02/19] explicitly exclude demo --- .npmignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.npmignore b/.npmignore index eeb46409..517ba0bd 100644 --- a/.npmignore +++ b/.npmignore @@ -45,3 +45,4 @@ docs/ build/ fixtures/ coverage/ +demo/ From 9bcecd4e2e3dfb56e17133121174a968789aab64 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 4 May 2018 10:20:09 -0700 Subject: [PATCH 03/19] Run tslint on all of source (for good this time) --- package.json | 2 +- src/renderer/atlas/CharAtlas.ts | 15 +++++++-------- src/shared/atlas/CharAtlasGenerator.ts | 5 ++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index d4a06f82..b0c36c54 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "scripts": { "start": "node demo/app", "start-zmodem": "node demo/zmodem/app", - "lint": "tslint src/*.ts src/**/*.ts src/addons/**/*.ts", + "lint": "tslint 'src/**/*.ts'", "test": "npm-run-all mocha lint", "mocha": "gulp test", "build:docs": "jsdoc -c jsdoc.json", diff --git a/src/renderer/atlas/CharAtlas.ts b/src/renderer/atlas/CharAtlas.ts index f516919f..db5c92f6 100644 --- a/src/renderer/atlas/CharAtlas.ts +++ b/src/renderer/atlas/CharAtlas.ts @@ -35,15 +35,14 @@ export function acquireCharAtlas(terminal: ITerminal, colors: IColorSet, scaledC if (ownedByIndex >= 0) { if (configEquals(entry.config, newConfig)) { return entry.bitmap; - } else { - // The configs differ, release the terminal from the entry - if (entry.ownedBy.length === 1) { - charAtlasCache.splice(i, 1); - } else { - entry.ownedBy.splice(ownedByIndex, 1); - } - break; } + // The configs differ, release the terminal from the entry + if (entry.ownedBy.length === 1) { + charAtlasCache.splice(i, 1); + } else { + entry.ownedBy.splice(ownedByIndex, 1); + } + break; } } diff --git a/src/shared/atlas/CharAtlasGenerator.ts b/src/shared/atlas/CharAtlasGenerator.ts index fc83c7ce..ee8bfcfa 100644 --- a/src/shared/atlas/CharAtlasGenerator.ts +++ b/src/shared/atlas/CharAtlasGenerator.ts @@ -91,10 +91,9 @@ export function generateCharAtlas(context: Window, canvasFactory: (width: number if (canvas instanceof HTMLCanvasElement) { // Just return the HTMLCanvas if it's a HTMLCanvasElement return canvas; - } else { - // Transfer to an ImageBitmap is this is an OffscreenCanvas - return new Promise(r => r(canvas.transferToImageBitmap())); } + // Transfer to an ImageBitmap is this is an OffscreenCanvas + return new Promise(r => r(canvas.transferToImageBitmap())); } const charAtlasImageData = ctx.getImageData(0, 0, canvas.width, canvas.height); From 41fd563144e58be506a1f9c069e8340ea8d72e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 17 Apr 2018 11:24:21 +0100 Subject: [PATCH 04/19] Separate bright and bold --- src/renderer/BaseRenderLayer.ts | 4 ++-- src/renderer/TextRenderLayer.ts | 7 ------- src/shared/atlas/CharAtlasGenerator.ts | 22 +++++++++++++++++----- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/renderer/BaseRenderLayer.ts b/src/renderer/BaseRenderLayer.ts index 7a655163..a46bc391 100644 --- a/src/renderer/BaseRenderLayer.ts +++ b/src/renderer/BaseRenderLayer.ts @@ -245,7 +245,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { protected drawChar(terminal: ITerminal, char: string, code: number, width: number, x: number, y: number, fg: number, bg: number, bold: boolean, dim: boolean, italic: boolean): void { let colorIndex = 0; if (fg < 256) { - colorIndex = fg + 2; + colorIndex = fg + 2 + (bold && terminal.options.enableBold ? 16 : 0); } else { // If default color and bold if (bold && terminal.options.enableBold) { @@ -273,7 +273,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { if (bold && !terminal.options.enableBold) { // Ignore default color as it's not touched above if (colorIndex > 1) { - colorIndex -= 8; + colorIndex -= 16; } } diff --git a/src/renderer/TextRenderLayer.ts b/src/renderer/TextRenderLayer.ts index 8d8d6d4d..0dca11b2 100644 --- a/src/renderer/TextRenderLayer.ts +++ b/src/renderer/TextRenderLayer.ts @@ -116,13 +116,6 @@ export class TextRenderLayer extends BaseRenderLayer { } } - if (flags & FLAGS.BOLD) { - // Convert the FG color to the bold variant - if (fg < 8) { - fg += 8; - } - } - callback(code, char, width, x, y, fg, bg, flags); } } diff --git a/src/shared/atlas/CharAtlasGenerator.ts b/src/shared/atlas/CharAtlasGenerator.ts index fc83c7ce..ba9b0d27 100644 --- a/src/shared/atlas/CharAtlasGenerator.ts +++ b/src/shared/atlas/CharAtlasGenerator.ts @@ -27,7 +27,7 @@ export function generateCharAtlas(context: Window, canvasFactory: (width: number const cellHeight = config.scaledCharHeight + CHAR_ATLAS_CELL_SPACING; const canvas = canvasFactory( /*255 ascii chars*/255 * cellWidth, - (/*default+default bold*/2 + /*0-15*/16) * cellHeight + (/*default+default bold*/2 + /*0-15*/16 + /*0-15 bold*/16) * cellHeight ); const ctx = canvas.getContext('2d', {alpha: config.allowTransparency}); @@ -64,10 +64,6 @@ export function generateCharAtlas(context: Window, canvasFactory: (width: number // Colors 0-15 ctx.font = getFont(config.fontWeight, config); for (let colorIndex = 0; colorIndex < 16; colorIndex++) { - // colors 8-15 are bold - if (colorIndex === 8) { - ctx.font = getFont(config.fontWeightBold, config); - } const y = (colorIndex + 2) * cellHeight; // Draw ascii characters for (let i = 0; i < 256; i++) { @@ -80,6 +76,22 @@ export function generateCharAtlas(context: Window, canvasFactory: (width: number ctx.restore(); } } + + // Colors 0-15 bold + ctx.font = getFont(config.fontWeightBold, config); + for (let colorIndex = 0; colorIndex < 16; colorIndex++) { + const y = (colorIndex + 2 + 16) * cellHeight; + // Draw ascii characters + for (let i = 0; i < 256; i++) { + ctx.save(); + ctx.beginPath(); + ctx.rect(i * cellWidth, y, cellWidth, cellHeight); + ctx.clip(); + ctx.fillStyle = config.colors.ansi[colorIndex].css; + ctx.fillText(String.fromCharCode(i), i * cellWidth, y); + ctx.restore(); + } + } ctx.restore(); // Support is patchy for createImageBitmap at the moment, pass a canvas back From a23354f0181f357c002d2ffebd85390920cc775b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Fri, 20 Apr 2018 10:20:10 +0100 Subject: [PATCH 05/19] Fully use char atlas for bright & bold colors --- src/renderer/BaseRenderLayer.ts | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/renderer/BaseRenderLayer.ts b/src/renderer/BaseRenderLayer.ts index a46bc391..5bc4f33b 100644 --- a/src/renderer/BaseRenderLayer.ts +++ b/src/renderer/BaseRenderLayer.ts @@ -243,23 +243,19 @@ export abstract class BaseRenderLayer implements IRenderLayer { * @param bold Whether the text is bold. */ protected drawChar(terminal: ITerminal, char: string, code: number, width: number, x: number, y: number, fg: number, bg: number, bold: boolean, dim: boolean, italic: boolean): void { - let colorIndex = 0; - if (fg < 256) { - colorIndex = fg + 2 + (bold && terminal.options.enableBold ? 16 : 0); - } else { - // If default color and bold - if (bold && terminal.options.enableBold) { - colorIndex = 1; - } - } const isAscii = code < 256; - // A color is basic if it is one of the standard normal or bold weight - // colors of the characters held in the char atlas. Note that this excludes - // the normal weight _light_ color characters. - const isBasicColor = (colorIndex > 1 && fg < 16) && (fg < 8 || bold); + // A color is basic if it is one of the 4 bit ANSI colors. + const isBasicColor = fg < 16; const isDefaultColor = fg >= 256; const isDefaultBackground = bg >= 256; if (this._charAtlas && isAscii && (isBasicColor || isDefaultColor) && isDefaultBackground && !italic) { + let colorIndex: number; + if (isDefaultColor) { + colorIndex = (bold && terminal.options.enableBold ? 1 : 0); + } else { + colorIndex = 2 + fg + (bold && terminal.options.enableBold ? 16 : 0); + } + // ImageBitmap's draw about twice as fast as from a canvas const charAtlasCellWidth = this._scaledCharWidth + CHAR_ATLAS_CELL_SPACING; const charAtlasCellHeight = this._scaledCharHeight + CHAR_ATLAS_CELL_SPACING; @@ -269,14 +265,6 @@ export abstract class BaseRenderLayer implements IRenderLayer { this._ctx.globalAlpha = DIM_OPACITY; } - // Draw the non-bold version of the same color if bold is not enabled - if (bold && !terminal.options.enableBold) { - // Ignore default color as it's not touched above - if (colorIndex > 1) { - colorIndex -= 16; - } - } - this._ctx.drawImage(this._charAtlas, code * charAtlasCellWidth, colorIndex * charAtlasCellHeight, From ce6139e604c8d23dd6e3be957f5bed6d7e30bc5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Fri, 20 Apr 2018 10:35:07 +0100 Subject: [PATCH 06/19] Add drawBoldTextInBrightColors option --- src/renderer/BaseRenderLayer.ts | 5 +++-- typings/xterm.d.ts | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/renderer/BaseRenderLayer.ts b/src/renderer/BaseRenderLayer.ts index 5bc4f33b..f80c6df0 100644 --- a/src/renderer/BaseRenderLayer.ts +++ b/src/renderer/BaseRenderLayer.ts @@ -248,12 +248,13 @@ export abstract class BaseRenderLayer implements IRenderLayer { const isBasicColor = fg < 16; const isDefaultColor = fg >= 256; const isDefaultBackground = bg >= 256; + const drawInBrightColor = (terminal.options.drawBoldTextInBrightColors !== false && bold && fg < 8); if (this._charAtlas && isAscii && (isBasicColor || isDefaultColor) && isDefaultBackground && !italic) { let colorIndex: number; if (isDefaultColor) { colorIndex = (bold && terminal.options.enableBold ? 1 : 0); } else { - colorIndex = 2 + fg + (bold && terminal.options.enableBold ? 16 : 0); + colorIndex = 2 + fg + (bold && terminal.options.enableBold ? 16 : 0) + (drawInBrightColor ? 8 : 0); } // ImageBitmap's draw about twice as fast as from a canvas @@ -275,7 +276,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { charAtlasCellWidth, this._scaledCharHeight); } else { - this._drawUncachedChar(terminal, char, width, fg, x, y, bold && terminal.options.enableBold, dim, italic); + this._drawUncachedChar(terminal, char, width, fg + (drawInBrightColor ? 8 : 0), x, y, bold && terminal.options.enableBold, dim, italic); } // This draws the atlas (for debugging purposes) // this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height); diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 65d533de..3107589e 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -54,6 +54,11 @@ declare module 'xterm' { */ disableStdin?: boolean; + /** + * Whether to draw bold text in bright colors. The default is true. + */ + drawBoldTextInBrightColors?: boolean; + /** * Whether to enable the rendering of bold text. * From cfdec9ff904ad412fc30f7695e878a94f938fddd Mon Sep 17 00:00:00 2001 From: Ledion Bitincka Date: Tue, 8 May 2018 16:27:54 -0700 Subject: [PATCH 07/19] add diag.ai --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 07baec5a..2b0944e6 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,7 @@ computational environment for Jupyter, supporting interactive data science and s - [**FreeMAN**](https://github.com/matthew-matvei/freeman): A free, cross-platform file manager for power users - [**Fluent Terminal**](https://github.com/felixse/FluentTerminal): A terminal emulator based on UWP and web technologies. - [**Hyper**](https://hyper.is): A terminal built on web technologies +- [**Diag**](https://diag.ai): A better way to troubleshoot problems faster. Capture, share and reapply troubleshooting knowledge so you can focus on solving problems that matter. Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it in our list. From 9893338020cc66efb8180f8f4df6852a0880bfae Mon Sep 17 00:00:00 2001 From: Benjamin Woodruff Date: Tue, 8 May 2018 18:34:23 -0700 Subject: [PATCH 08/19] Add drawBoldTextInBrightColors to DEFAULT_OPTIONS This lets term.setOption() work for drawBoldTextInBrightColors. --- src/Terminal.ts | 1 + src/renderer/BaseRenderLayer.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Terminal.ts b/src/Terminal.ts index ba1fff3d..05781b96 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -103,6 +103,7 @@ const DEFAULT_OPTIONS: ITerminalOptions = { cursorStyle: 'block', bellSound: DEFAULT_BELL_SOUND, bellStyle: 'none', + drawBoldTextInBrightColors: true, enableBold: true, fontFamily: 'courier-new, courier, monospace', fontSize: 15, diff --git a/src/renderer/BaseRenderLayer.ts b/src/renderer/BaseRenderLayer.ts index f80c6df0..ca848b73 100644 --- a/src/renderer/BaseRenderLayer.ts +++ b/src/renderer/BaseRenderLayer.ts @@ -248,7 +248,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { const isBasicColor = fg < 16; const isDefaultColor = fg >= 256; const isDefaultBackground = bg >= 256; - const drawInBrightColor = (terminal.options.drawBoldTextInBrightColors !== false && bold && fg < 8); + const drawInBrightColor = (terminal.options.drawBoldTextInBrightColors && bold && fg < 8); if (this._charAtlas && isAscii && (isBasicColor || isDefaultColor) && isDefaultBackground && !italic) { let colorIndex: number; if (isDefaultColor) { From b162582e668398179d440aca8629a0f2b6cbfc6d Mon Sep 17 00:00:00 2001 From: npezza93 Date: Sat, 21 Apr 2018 08:52:12 -0400 Subject: [PATCH 09/19] Handle if getCoords returns null in the AltClickHandler Fixes #1397 --- src/handlers/AltClickHandler.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/handlers/AltClickHandler.ts b/src/handlers/AltClickHandler.ts index 85465272..6b980fe6 100644 --- a/src/handlers/AltClickHandler.ts +++ b/src/handlers/AltClickHandler.ts @@ -28,7 +28,7 @@ export class AltClickHandler { this._startCol = this._terminal.buffer.x; this._startRow = this._terminal.buffer.y; - [this._endCol, this._endRow] = this._terminal.mouseHelper.getCoords( + let coordinates = this._terminal.mouseHelper.getCoords( this._mouseEvent, this._terminal.element, this._terminal.charMeasure, @@ -36,7 +36,13 @@ export class AltClickHandler { this._terminal.cols, this._terminal.rows, false - ).map((coordinate: number) => { + ); + + if (!coordinates) { + return null; + } + + [this._endCol, this._endRow] = coordinates.map((coordinate: number) => { return coordinate - 1; }); } From 4edbd507e5717669ebe57c20657053fa9bae06c9 Mon Sep 17 00:00:00 2001 From: npezza93 Date: Wed, 9 May 2018 19:35:02 -0400 Subject: [PATCH 10/19] Check if endCol and endRow are present before handling an alt click --- src/handlers/AltClickHandler.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/handlers/AltClickHandler.ts b/src/handlers/AltClickHandler.ts index 6b980fe6..7f2e4f05 100644 --- a/src/handlers/AltClickHandler.ts +++ b/src/handlers/AltClickHandler.ts @@ -38,20 +38,18 @@ export class AltClickHandler { false ); - if (!coordinates) { - return null; + if (coordinates) { + [this._endCol, this._endRow] = coordinates.map((coordinate: number) => { + return coordinate - 1; + }); } - - [this._endCol, this._endRow] = coordinates.map((coordinate: number) => { - return coordinate - 1; - }); } /** * Writes the escape sequences of arrows to the terminal */ public move(): void { - if (this._mouseEvent.altKey) { + if (this._mouseEvent.altKey && this._endCol !== undefined && this._endRow !== undefined) { this._terminal.send(this._arrowSequences()); } } From 3971fc9b4e21c1030908da172886dc2f8253edfd Mon Sep 17 00:00:00 2001 From: Benjamin Woodruff Date: Wed, 9 May 2018 20:34:55 -0700 Subject: [PATCH 11/19] Save and restore the ctx for cached characters Drawing dim colors sets the globalAlpha to 0.5, so we need to save/restore the ctx state. Otherwise, every time we draw some dim content, our display will get progressively dimmer. I tested this by running `echo '\u001b[2mfoo'` a few times in zsh. Fixes #1424 --- src/renderer/BaseRenderLayer.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/renderer/BaseRenderLayer.ts b/src/renderer/BaseRenderLayer.ts index ca848b73..c2b65e16 100644 --- a/src/renderer/BaseRenderLayer.ts +++ b/src/renderer/BaseRenderLayer.ts @@ -250,6 +250,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { const isDefaultBackground = bg >= 256; const drawInBrightColor = (terminal.options.drawBoldTextInBrightColors && bold && fg < 8); if (this._charAtlas && isAscii && (isBasicColor || isDefaultColor) && isDefaultBackground && !italic) { + this._ctx.save(); // we may set globalAlpha, so we need to be able to restore let colorIndex: number; if (isDefaultColor) { colorIndex = (bold && terminal.options.enableBold ? 1 : 0); @@ -275,6 +276,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { y * this._scaledCellHeight + this._scaledCharTop, charAtlasCellWidth, this._scaledCharHeight); + this._ctx.restore(); } else { this._drawUncachedChar(terminal, char, width, fg + (drawInBrightColor ? 8 : 0), x, y, bold && terminal.options.enableBold, dim, italic); } From bce81f304ef284f42a2f9596d13adf3a1169955e Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Thu, 10 May 2018 16:11:25 +0800 Subject: [PATCH 12/19] Update how to use addons with Typescript --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 07baec5a..65f016c4 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,18 @@ The proposed way to load xterm.js is via the ES6 module syntax. import { Terminal } from 'xterm'; ``` -*Note: There are currently no typings for addons so you will need to upcast if using TypeScript, eg. `(xterm).fit()`.* +*Note: There are currently no typings for addons if they are accessed via extending Terminal prototype, so you will need to upcast if using TypeScript, eg. `(xterm).fit()`.* + +It is recommended to import addon function and enhance the terminal on demand. This would have better typing support and is friendly to treeshaking. E.g.: + +```typescript +import { Terminal } from 'xterm'; +import { fit } from 'xterm/lib/addons/fit/fit'; +const xterm = new Terminal(); + +// Fit the terminal when necessary: +fit(xterm); +``` ### Addons From ef4cda2cc635597f838078057b766225108c39cf Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Fri, 11 May 2018 11:20:02 +0800 Subject: [PATCH 13/19] revise importing addons in ts --- README.md | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 65f016c4..dc14f853 100644 --- a/README.md +++ b/README.md @@ -57,19 +57,6 @@ The proposed way to load xterm.js is via the ES6 module syntax. import { Terminal } from 'xterm'; ``` -*Note: There are currently no typings for addons if they are accessed via extending Terminal prototype, so you will need to upcast if using TypeScript, eg. `(xterm).fit()`.* - -It is recommended to import addon function and enhance the terminal on demand. This would have better typing support and is friendly to treeshaking. E.g.: - -```typescript -import { Terminal } from 'xterm'; -import { fit } from 'xterm/lib/addons/fit/fit'; -const xterm = new Terminal(); - -// Fit the terminal when necessary: -fit(xterm); -``` - ### Addons Addons are JavaScript modules that extend the `Terminal` prototype with new methods and attributes to provide additional functionality. There are a handful available in the main repository in the `src/addons` directory and you can even write your own, by using xterm.js' public API. @@ -87,6 +74,21 @@ var xterm = new Terminal(); // Instantiate the terminal xterm.fit(); // Use the `fit` method, provided by the `fit` addon ``` +#### Importing Addons in TypeScript + +There are currently no typings for addons if they are accessed via extending Terminal prototype, so you will need to upcast if using TypeScript, eg. `(xterm).fit()`. + +Alternatively, you can import addon function and enhance the terminal on demand. This would have better typing support and is friendly to treeshaking. E.g.: + +```typescript +import { Terminal } from 'xterm'; +import { fit } from 'xterm/lib/addons/fit/fit'; +const xterm = new Terminal(); + +// Fit the terminal when necessary: +fit(xterm); +``` + #### Third party addons There are also the following third party addons available: From 9c1bee300d0983440c0f40447d90619ec781164e Mon Sep 17 00:00:00 2001 From: pro-src Date: Thu, 10 May 2018 23:03:12 -0500 Subject: [PATCH 14/19] Fix tsc --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d4a06f82..ee03147b 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@types/chai": "^3.4.34", "@types/jsdom": "^11.0.1", "@types/mocha": "^2.2.33", - "@types/node": "^6.0.41", + "@types/node": "6.0.108", "@types/text-encoding": "0.0.32", "browserify": "^13.3.0", "chai": "3.5.0", From 210a312fbff4a06f83f033ffdd3464cb4d1073c9 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 11 May 2018 07:49:37 -0700 Subject: [PATCH 15/19] Remove ignore key from package.json --- package.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/package.json b/package.json index ce58b98f..d060b08d 100644 --- a/package.json +++ b/package.json @@ -2,11 +2,6 @@ "name": "xterm", "description": "Full xterm terminal, in your browser", "version": "3.3.0", - "ignore": [ - "demo", - "test", - ".gitignore" - ], "main": "lib/Terminal.js", "types": "typings/xterm.d.ts", "repository": "https://github.com/xtermjs/xterm.js", @@ -61,6 +56,5 @@ "coveralls": "gulp coveralls", "webpack": "gulp webpack", "watch": "gulp watch" - }, - "dependencies": {} + } } From 0375e0064bef71efc10cbebe752ae61da4ca739e Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 11 May 2018 10:03:43 -0700 Subject: [PATCH 16/19] Fix link cursor CSS Ensure pointer overrides the default mouse events mode cursor. Fixes #1437 --- src/xterm.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xterm.css b/src/xterm.css index eec41a05..2fae4588 100644 --- a/src/xterm.css +++ b/src/xterm.css @@ -135,6 +135,10 @@ cursor: text; } +.xterm.xterm-cursor-pointer { + cursor: pointer !important; +} + .xterm .xterm-accessibility, .xterm .xterm-message { position: absolute; @@ -153,7 +157,3 @@ height: 1px; overflow: hidden; } - -.xterm-cursor-pointer { - cursor: pointer; -} From 9dfce63e5588bd64b3911870f1ecaa405c1c7715 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 12 May 2018 07:44:30 -0700 Subject: [PATCH 17/19] Simplify cursor styles --- src/xterm.css | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/xterm.css b/src/xterm.css index 2fae4588..6e7d2f96 100644 --- a/src/xterm.css +++ b/src/xterm.css @@ -126,17 +126,17 @@ line-height: normal; } +.xterm { + cursor: text; +} + .xterm.enable-mouse-events { /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */ cursor: default; } -.xterm:not(.enable-mouse-events) { - cursor: text; -} - .xterm.xterm-cursor-pointer { - cursor: pointer !important; + cursor: pointer; } .xterm .xterm-accessibility, From 6e451f58b87d78010b0a08c91db500148953f331 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 14 May 2018 11:13:01 -0700 Subject: [PATCH 18/19] Update tagline --- demo/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/index.html b/demo/index.html index 760d5990..9c19ea83 100644 --- a/demo/index.html +++ b/demo/index.html @@ -9,7 +9,7 @@ -

xterm.js: xterm, in the browser

+

xterm.js: A terminal for the web

Actions

From 3acd1eaecc45e6842640742cdaf1b68274deb05f Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 14 May 2018 11:48:13 -0700 Subject: [PATCH 19/19] Update coveralls This broke after we moved the organization Fixes #1451 --- .travis.yml | 1 - README.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c41ebf79..1f3c9079 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,4 +17,3 @@ env: notifications: email: false script: npm run $NPM_COMMAND -after_success: npm run coveralls diff --git a/README.md b/README.md index dc14f853..caa0eea7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [![xterm.js logo](logo-full.png)](https://xtermjs.org) -[![xterm.js build status](https://api.travis-ci.org/xtermjs/xterm.js.svg)](https://travis-ci.org/xtermjs/xterm.js) [![Coverage Status](https://coveralls.io/repos/github/sourcelair/xterm.js/badge.svg)](https://coveralls.io/github/sourcelair/xterm.js) [![Gitter](https://badges.gitter.im/sourcelair/xterm.js.svg)](https://gitter.im/sourcelair/xterm.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/xterm/badge?style=rounded)](https://www.jsdelivr.com/package/npm/xterm) +[![xterm.js build status](https://api.travis-ci.org/xtermjs/xterm.js.svg)](https://travis-ci.org/xtermjs/xterm.js) [![Coverage Status](https://coveralls.io/repos/github/xtermjs/xterm.js/badge.svg?branch=master)](https://coveralls.io/github/xtermjs/xterm.js?branch=master) [![Gitter](https://badges.gitter.im/sourcelair/xterm.js.svg)](https://gitter.im/sourcelair/xterm.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/xterm/badge?style=rounded)](https://www.jsdelivr.com/package/npm/xterm) Xterm.js is a terminal front-end component written in JavaScript that works in the browser.