From 6ea56cd85ea086946342c8b6115ee428e14844fe Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sun, 16 Sep 2018 11:42:09 -0700 Subject: [PATCH 1/8] Remove npm-run-all We can just use posttest --- package.json | 4 +-- yarn.lock | 89 ++++------------------------------------------------ 2 files changed, 8 insertions(+), 85 deletions(-) diff --git a/package.json b/package.json index 4bdac048..f83e498c 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "merge-stream": "^1.0.1", "node-pty": "0.7.6", "nodemon": "1.10.2", - "npm-run-all": "^4.1.2", "nyc": "^11.8.0", "sorcery": "^0.10.0", "source-map-loader": "^0.2.3", @@ -51,7 +50,8 @@ "start": "node demo/start", "start-zmodem": "node demo/zmodem/app", "lint": "tslint 'src/**/*.ts' './demo/**/*.ts'", - "test": "npm-run-all mocha lint", + "test": "npm run mocha", + "posttest": "npm run lint", "test-debug": "node --inspect-brk node_modules/.bin/gulp test", "test-suite": "gulp mocha-suite --test", "test-coverage": "nyc -x gulpfile.js -x '**/*test*' npm run mocha", diff --git a/yarn.lock b/yarn.lock index f12043f7..8cebcd9c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -338,7 +338,7 @@ ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" -ansi-styles@^3.2.0, ansi-styles@^3.2.1: +ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" dependencies: @@ -942,7 +942,7 @@ chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.1: +chalk@^2.0.0, chalk@^2.3.0, chalk@^2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e" dependencies: @@ -1333,7 +1333,7 @@ cross-spawn@^5.0.1: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^6.0.4, cross-spawn@^6.0.5: +cross-spawn@^6.0.5: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" dependencies: @@ -1490,13 +1490,6 @@ defaults@^1.0.0: dependencies: clone "^1.0.2" -define-properties@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94" - dependencies: - foreach "^2.0.5" - object-keys "^1.0.8" - define-property@^0.2.5: version "0.2.5" resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" @@ -1701,24 +1694,6 @@ error-ex@^1.2.0, error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" -es-abstract@^1.4.3: - version "1.12.0" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.12.0.tgz#9dbbdd27c6856f0001421ca18782d786bf8a6165" - dependencies: - es-to-primitive "^1.1.1" - function-bind "^1.1.1" - has "^1.0.1" - is-callable "^1.1.3" - is-regex "^1.0.4" - -es-to-primitive@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d" - dependencies: - is-callable "^1.1.1" - is-date-object "^1.0.1" - is-symbol "^1.0.1" - es5-ext@^0.10.35, es5-ext@^0.10.9, es5-ext@~0.10.14: version "0.10.45" resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.45.tgz#0bfdf7b473da5919d5adf3bd25ceb754fccc3653" @@ -2119,10 +2094,6 @@ for-own@^1.0.0: dependencies: for-in "^1.0.1" -foreach@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" - foreground-child@^1.5.3, foreground-child@^1.5.6: version "1.5.6" resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-1.5.6.tgz#4fd71ad2dfde96789b980a5c0a295937cb2f5ce9" @@ -2201,7 +2172,7 @@ fsevents@^1.0.0, fsevents@^1.2.2: nan "^2.9.2" node-pre-gyp "^0.10.0" -function-bind@^1.0.2, function-bind@^1.1.1: +function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" @@ -2638,7 +2609,7 @@ has-values@^1.0.0: is-number "^3.0.0" kind-of "^4.0.0" -has@^1.0.0, has@^1.0.1: +has@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" dependencies: @@ -2897,10 +2868,6 @@ is-builtin-module@^1.0.0: dependencies: builtin-modules "^1.0.0" -is-callable@^1.1.1, is-callable@^1.1.3: - version "1.1.4" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75" - is-data-descriptor@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" @@ -2913,10 +2880,6 @@ is-data-descriptor@^1.0.0: dependencies: kind-of "^6.0.0" -is-date-object@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" - is-descriptor@^0.1.0: version "0.1.6" resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" @@ -3037,12 +3000,6 @@ is-redirect@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24" -is-regex@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" - dependencies: - has "^1.0.1" - is-relative@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-relative/-/is-relative-1.0.0.tgz#a1bb6935ce8c5dba1e8b9754b9b2dcc020e2260d" @@ -3053,10 +3010,6 @@ is-stream@^1.0.0, is-stream@^1.0.1, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" -is-symbol@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572" - is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" @@ -3715,10 +3668,6 @@ memory-fs@^0.4.0, memory-fs@~0.4.1: errno "^0.1.3" readable-stream "^2.0.1" -memorystream@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2" - merge-descriptors@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" @@ -4107,20 +4056,6 @@ npm-packlist@^1.1.6: ignore-walk "^3.0.1" npm-bundled "^1.0.1" -npm-run-all@^4.1.2: - version "4.1.3" - resolved "https://registry.yarnpkg.com/npm-run-all/-/npm-run-all-4.1.3.tgz#49f15b55a66bb4101664ce270cb18e7103f8f185" - dependencies: - ansi-styles "^3.2.0" - chalk "^2.1.0" - cross-spawn "^6.0.4" - memorystream "^0.3.1" - minimatch "^3.0.4" - ps-tree "^1.1.0" - read-pkg "^3.0.0" - shell-quote "^1.6.1" - string.prototype.padend "^3.0.0" - npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" @@ -4200,10 +4135,6 @@ object-copy@^0.1.0: define-property "^0.2.5" kind-of "^3.0.3" -object-keys@^1.0.8: - version "1.0.12" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.12.tgz#09c53855377575310cca62f55bb334abff7b3ed2" - object-visit@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" @@ -4645,7 +4576,7 @@ prr@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" -ps-tree@^1.0.1, ps-tree@^1.1.0: +ps-tree@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/ps-tree/-/ps-tree-1.1.0.tgz#b421b24140d6203f1ed3c76996b4427b08e8c014" dependencies: @@ -5504,14 +5435,6 @@ string-width@^1.0.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" -string.prototype.padend@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/string.prototype.padend/-/string.prototype.padend-3.0.0.tgz#f3aaef7c1719f170c5eab1c32bf780d96e21f2f0" - dependencies: - define-properties "^1.1.2" - es-abstract "^1.4.3" - function-bind "^1.0.2" - string_decoder@^1.0.0, string_decoder@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" From f6d5abf7b3f205eac66a393bd393dfcfaf377364 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 17 Sep 2018 06:37:28 -0700 Subject: [PATCH 2/8] Fix scroll APIs not affecting scroll bar Fixes #1697 --- src/Viewport.ts | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/Viewport.ts b/src/Viewport.ts index e89676d9..50d04457 100644 --- a/src/Viewport.ts +++ b/src/Viewport.ts @@ -22,6 +22,7 @@ export class Viewport extends Disposable implements IViewport { private _lastRecordedViewportHeight: number = 0; private _lastRecordedBufferHeight: number = 0; private _lastTouchY: number; + private _lastScrollTop: number = 0; // Stores a partial line amount when scrolling, this is used to keep track of how much of a line // is scrolled so we can "scroll" over partial lines and feel natural on touchpads. This is a @@ -97,18 +98,36 @@ export class Viewport extends Disposable implements IViewport { * Updates dimensions and synchronizes the scroll area if necessary. */ public syncScrollArea(): void { + // If buffer height changed if (this._lastRecordedBufferLength !== this._terminal.buffer.lines.length) { - // If buffer height changed this._lastRecordedBufferLength = this._terminal.buffer.lines.length; this._refresh(); - } else if (this._lastRecordedViewportHeight !== (this._terminal).renderer.dimensions.canvasHeight) { - // If viewport height changed + return; + } + + // If viewport height changed + if (this._lastRecordedViewportHeight !== (this._terminal).renderer.dimensions.canvasHeight) { this._refresh(); - } else { - // If size has changed, refresh viewport - if (this._terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio !== this._currentRowHeight) { - this._refresh(); - } + return; + } + + // If the buffer position doesn't match last scroll top + const newScrollTop = this._terminal.buffer.ydisp * this._currentRowHeight; + if (this._lastScrollTop !== newScrollTop) { + this._refresh(); + return; + } + + // If element's scroll top changed, this can happen when hiding the element + if (this._lastScrollTop !== this._viewportElement.scrollTop) { + this._refresh(); + return; + } + + // If row height changed + if (this._terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio !== this._currentRowHeight) { + this._refresh(); + return; } } @@ -118,6 +137,9 @@ export class Viewport extends Disposable implements IViewport { * @param ev The scroll event. */ private _onScroll(ev: Event): void { + // Record current scroll top position + this._lastScrollTop = this._viewportElement.scrollTop; + // Don't attempt to scroll if the element is not visible, otherwise scrollTop will be corrupt // which causes the terminal to scroll the buffer to the top if (!this._viewportElement.offsetParent) { @@ -130,8 +152,7 @@ export class Viewport extends Disposable implements IViewport { return; } - - const newRow = Math.round(this._viewportElement.scrollTop / this._currentRowHeight); + const newRow = Math.round(this._lastScrollTop / this._currentRowHeight); const diff = newRow - this._terminal.buffer.ydisp; this._terminal.scrollLines(diff, true); } From 4463f8d8102c4ae490b5aca0e53e7048263c2ddf Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 19 Sep 2018 19:47:16 -0700 Subject: [PATCH 3/8] Speculative fix for NPE Fixes #1702 --- src/Linkifier.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Linkifier.ts b/src/Linkifier.ts index 4d84b1a7..eec1688c 100644 --- a/src/Linkifier.ts +++ b/src/Linkifier.ts @@ -81,18 +81,22 @@ export class Linkifier extends EventEmitter implements ILinkifier { */ private _linkifyRows(): void { this._rowsTimeoutId = null; + const buffer = this._terminal.buffer; - // Ensure the row exists - const absoluteRowIndexStart = this._terminal.buffer.ydisp + this._rowsToLinkify.start; - if (absoluteRowIndexStart >= this._terminal.buffer.lines.length) { + // Ensure the start row exists + const absoluteRowIndexStart = buffer.ydisp + this._rowsToLinkify.start; + if (absoluteRowIndexStart >= buffer.lines.length) { return; } + // Invalidate bad end row values (if a resize happened) + const absoluteRowIndexEnd = Math.min(buffer.ydisp + this._rowsToLinkify.end + 1, buffer.ydisp + this._terminal.rows); + // iterate over the range of unwrapped content strings within start..end (excluding) // _doLinkifyRow gets full unwrapped lines with the start row as buffer offset for every matcher // for wrapped content over several rows the iterator might return rows outside the viewport // we skip those later in _doLinkifyRow - const iterator = this._terminal.buffer.iterator(false, absoluteRowIndexStart, this._terminal.buffer.ydisp + this._rowsToLinkify.end + 1); + const iterator = buffer.iterator(false, absoluteRowIndexStart, absoluteRowIndexEnd); while (iterator.hasNext()) { const lineData: IBufferStringIteratorResult = iterator.next(); for (let i = 0; i < this._linkMatchers.length; i++) { From 2c62c3a8c33c8268a4fe03ffa45a10224640e3a2 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 19 Sep 2018 20:06:09 -0700 Subject: [PATCH 4/8] Fix tests --- src/Linkifier.test.ts | 2 ++ src/Linkifier.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Linkifier.test.ts b/src/Linkifier.test.ts index 35610acb..1e4c0cdc 100644 --- a/src/Linkifier.test.ts +++ b/src/Linkifier.test.ts @@ -42,6 +42,7 @@ describe('Linkifier', () => { beforeEach(() => { terminal = new MockTerminal(); terminal.cols = 100; + terminal.rows = 10; terminal.buffer = new MockBuffer(); (terminal.buffer).setLines(new CircularList(20)); terminal.buffer.ydisp = 0; @@ -64,6 +65,7 @@ describe('Linkifier', () => { function assertLinkifiesRow(rowText: string, linkMatcherRegex: RegExp, links: {x: number, length: number}[], done: MochaDone): void { addRow(rowText); linkifier.registerLinkMatcher(linkMatcherRegex, () => {}); + terminal.rows = terminal.buffer.lines.length - 1; linkifier.linkifyRows(); // Allow linkify to happen setTimeout(() => { diff --git a/src/Linkifier.ts b/src/Linkifier.ts index eec1688c..0dd33a85 100644 --- a/src/Linkifier.ts +++ b/src/Linkifier.ts @@ -90,7 +90,7 @@ export class Linkifier extends EventEmitter implements ILinkifier { } // Invalidate bad end row values (if a resize happened) - const absoluteRowIndexEnd = Math.min(buffer.ydisp + this._rowsToLinkify.end + 1, buffer.ydisp + this._terminal.rows); + const absoluteRowIndexEnd = buffer.ydisp + Math.min(this._rowsToLinkify.end, this._terminal.rows) + 1; // iterate over the range of unwrapped content strings within start..end (excluding) // _doLinkifyRow gets full unwrapped lines with the start row as buffer offset for every matcher From 478d824fa788773679c58309b1a900da580c5d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agusti=CC=81n=20Rodri=CC=81guez?= Date: Thu, 20 Sep 2018 01:52:37 -0300 Subject: [PATCH 5/8] fix underline don't appearing when using the fallback DOM renderer --- src/renderer/dom/DomRenderer.ts | 51 ++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/renderer/dom/DomRenderer.ts b/src/renderer/dom/DomRenderer.ts index 9a2ef469..399ac406 100644 --- a/src/renderer/dom/DomRenderer.ts +++ b/src/renderer/dom/DomRenderer.ts @@ -4,12 +4,13 @@ */ import { IRenderer, IRenderDimensions, IColorSet } from '../Types'; -import { ITerminal, CharacterJoinerHandler } from '../../Types'; +import { ILinkHoverEvent, ITerminal, CharacterJoinerHandler, LinkHoverEventTypes } from '../../Types'; import { ITheme } from 'xterm'; import { EventEmitter } from '../../common/EventEmitter'; import { ColorManager } from '../ColorManager'; import { RenderDebouncer } from '../../ui/RenderDebouncer'; import { BOLD_CLASS, ITALIC_CLASS, CURSOR_CLASS, CURSOR_STYLE_BLOCK_CLASS, CURSOR_STYLE_BAR_CLASS, CURSOR_STYLE_UNDERLINE_CLASS, DomRendererRowFactory } from './DomRendererRowFactory'; +import { INVERTED_DEFAULT_COLOR } from '../atlas/Types'; const TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-'; const ROW_CONTAINER_CLASS = 'xterm-rows'; @@ -79,6 +80,9 @@ export class DomRenderer extends EventEmitter implements IRenderer { this._terminal.element.classList.add(TERMINAL_CLASS_PREFIX + this._terminalClass); this._terminal.screenElement.appendChild(this._rowContainer); this._terminal.screenElement.appendChild(this._selectionContainer); + + this._terminal.linkifier.on(LinkHoverEventTypes.HOVER, (e: ILinkHoverEvent) => this._onLinkHover(e)); + this._terminal.linkifier.on(LinkHoverEventTypes.LEAVE, (e: ILinkHoverEvent) => this._onLinkLeave(e)); } public dispose(): void { @@ -116,6 +120,7 @@ export class DomRenderer extends EventEmitter implements IRenderer { const styles = `${this._terminalSelector} .${ROW_CONTAINER_CLASS} span {` + + ` box-sizing: border-box;` + ` display: inline-block;` + ` height: 100%;` + ` vertical-align: top;` + @@ -338,4 +343,48 @@ export class DomRenderer extends EventEmitter implements IRenderer { public registerCharacterJoiner(handler: CharacterJoinerHandler): number { return -1; } public deregisterCharacterJoiner(joinerId: number): boolean { return false; } + + private _onLinkHover(e: ILinkHoverEvent): void { + let color = this.colorManager.colors.foreground.css; + + if (e.fg === INVERTED_DEFAULT_COLOR) { + color = this.colorManager.colors.background.css; + } else if (e.fg < 256) { + // 256 color support + color = this.colorManager.colors.ansi[e.fg].css; + } + + this._setBorderBottomAtCells(e.x1, e.x2, e.y1, e.y2, e.cols, `1px solid ${color}`); + } + + private _onLinkLeave(e: ILinkHoverEvent): void { + this._setBorderBottomAtCells(e.x1, e.x2, e.y1, e.y2, e.cols, null); + } + + private _setBorderBottomAtCells(x1: number, x2: number, y1: number, y2: number, cols: number, value?: string) { + if (y1 === y2) { + // Single line link + for (let x = x1; x < x2; x++) { + let span = (this._rowElements[y1].children[x]); + span.style.borderBottom = value; + } + } else { + // Multi-line link + for (let x = x1; x < cols - x1; x++) { + let span = (this._rowElements[y1].children[x]); + span.style.borderBottom = value; + } + for (let y = y1 + 1; y < y2 - 1; y++) { + for (let x = 0; x < cols; x++) { + let span = (this._rowElements[y].children[x]); + span.style.borderBottom = value; + } + } + for (let x = 0; x < x2; x++) { + let span = (this._rowElements[y2].children[x]); + span.style.borderBottom = value; + } + } + } + } From d1991396e758f5d36ecce8403bf56f046b65d42f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agusti=CC=81n=20Rodri=CC=81guez?= Date: Fri, 21 Sep 2018 01:09:20 -0300 Subject: [PATCH 6/8] generalized loops to handle both single and multi line links --- src/renderer/dom/DomRenderer.ts | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/src/renderer/dom/DomRenderer.ts b/src/renderer/dom/DomRenderer.ts index 399ac406..9933276c 100644 --- a/src/renderer/dom/DomRenderer.ts +++ b/src/renderer/dom/DomRenderer.ts @@ -361,29 +361,10 @@ export class DomRenderer extends EventEmitter implements IRenderer { this._setBorderBottomAtCells(e.x1, e.x2, e.y1, e.y2, e.cols, null); } - private _setBorderBottomAtCells(x1: number, x2: number, y1: number, y2: number, cols: number, value?: string) { - if (y1 === y2) { - // Single line link - for (let x = x1; x < x2; x++) { - let span = (this._rowElements[y1].children[x]); - span.style.borderBottom = value; - } - } else { - // Multi-line link - for (let x = x1; x < cols - x1; x++) { - let span = (this._rowElements[y1].children[x]); - span.style.borderBottom = value; - } - for (let y = y1 + 1; y < y2 - 1; y++) { - for (let x = 0; x < cols; x++) { - let span = (this._rowElements[y].children[x]); - span.style.borderBottom = value; - } - } - for (let x = 0; x < x2; x++) { - let span = (this._rowElements[y2].children[x]); - span.style.borderBottom = value; - } + private _setBorderBottomAtCells(x: number, x2: number, y: number, y2: number, cols: number, value?: string) { + for (; x != x2 || y != y2; x = ++x % cols, y += +(x === 0)) { + let span = (this._rowElements[y].children[x]); + span.style.borderBottom = value; } } From 1f2d223e649e0ecf63839806252737d254a8aac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agusti=CC=81n=20Rodri=CC=81guez?= Date: Fri, 21 Sep 2018 01:42:20 -0300 Subject: [PATCH 7/8] remove line in xterm.d.ts that says link underlines are not supported --- typings/xterm.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index cc1ebcd9..49f3810f 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -148,7 +148,6 @@ declare module 'xterm' { * when canvas is too slow for the environment. The following features do * not work when the DOM renderer is used: * - * - Link underlines * - Line height * - Letter spacing * - Cursor blink From 4941d5a19e5f81b40982d95259c00b74a0a7e552 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 21 Sep 2018 07:08:17 -0700 Subject: [PATCH 8/8] Simplify loop, pass lint --- src/renderer/dom/DomRenderer.ts | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/renderer/dom/DomRenderer.ts b/src/renderer/dom/DomRenderer.ts index 9933276c..8f51c4ef 100644 --- a/src/renderer/dom/DomRenderer.ts +++ b/src/renderer/dom/DomRenderer.ts @@ -10,7 +10,6 @@ import { EventEmitter } from '../../common/EventEmitter'; import { ColorManager } from '../ColorManager'; import { RenderDebouncer } from '../../ui/RenderDebouncer'; import { BOLD_CLASS, ITALIC_CLASS, CURSOR_CLASS, CURSOR_STYLE_BLOCK_CLASS, CURSOR_STYLE_BAR_CLASS, CURSOR_STYLE_UNDERLINE_CLASS, DomRendererRowFactory } from './DomRendererRowFactory'; -import { INVERTED_DEFAULT_COLOR } from '../atlas/Types'; const TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-'; const ROW_CONTAINER_CLASS = 'xterm-rows'; @@ -120,7 +119,6 @@ export class DomRenderer extends EventEmitter implements IRenderer { const styles = `${this._terminalSelector} .${ROW_CONTAINER_CLASS} span {` + - ` box-sizing: border-box;` + ` display: inline-block;` + ` height: 100%;` + ` vertical-align: top;` + @@ -345,27 +343,21 @@ export class DomRenderer extends EventEmitter implements IRenderer { public deregisterCharacterJoiner(joinerId: number): boolean { return false; } private _onLinkHover(e: ILinkHoverEvent): void { - let color = this.colorManager.colors.foreground.css; - - if (e.fg === INVERTED_DEFAULT_COLOR) { - color = this.colorManager.colors.background.css; - } else if (e.fg < 256) { - // 256 color support - color = this.colorManager.colors.ansi[e.fg].css; - } - - this._setBorderBottomAtCells(e.x1, e.x2, e.y1, e.y2, e.cols, `1px solid ${color}`); + this._setCellUnderline(e.x1, e.x2, e.y1, e.y2, e.cols, true); } private _onLinkLeave(e: ILinkHoverEvent): void { - this._setBorderBottomAtCells(e.x1, e.x2, e.y1, e.y2, e.cols, null); + this._setCellUnderline(e.x1, e.x2, e.y1, e.y2, e.cols, false); } - private _setBorderBottomAtCells(x: number, x2: number, y: number, y2: number, cols: number, value?: string) { - for (; x != x2 || y != y2; x = ++x % cols, y += +(x === 0)) { - let span = (this._rowElements[y].children[x]); - span.style.borderBottom = value; + private _setCellUnderline(x: number, x2: number, y: number, y2: number, cols: number, enabled: boolean): void { + while (x !== x2 || y !== y2) { + const span = this._rowElements[y].children[x]; + span.style.textDecoration = enabled ? 'underline' : 'none'; + x = (x + 1) % cols; + if (x === 0) { + y++; + } } } - }