diff --git a/src/CharWidth.ts b/src/CharWidth.ts index 512ed5f0..90673b2b 100644 --- a/src/CharWidth.ts +++ b/src/CharWidth.ts @@ -49,7 +49,7 @@ export const wcwidth = (function(opts: {nul: number, control: number}): (ucs: nu [0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F], [0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B], [0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F], - [0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB], + [0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB] ]; const COMBINING_HIGH = [ [0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F], diff --git a/src/CompositionHelper.test.ts b/src/CompositionHelper.test.ts index 09a59f72..02231723 100644 --- a/src/CompositionHelper.test.ts +++ b/src/CompositionHelper.test.ts @@ -17,7 +17,7 @@ describe('CompositionHelper', () => { compositionView = { classList: { add: () => {}, - remove: () => {}, + remove: () => {} }, getBoundingClientRect: () => { return { width: 0 }; diff --git a/src/CompositionHelper.ts b/src/CompositionHelper.ts index 387d3f8f..389cb782 100644 --- a/src/CompositionHelper.ts +++ b/src/CompositionHelper.ts @@ -132,7 +132,7 @@ export class CompositionHelper { // fire before the setTimeout executes. const currentCompositionPosition = { start: this._compositionPosition.start, - end: this._compositionPosition.end, + end: this._compositionPosition.end }; // Since composition* events happen before the changes take place in the textarea on most diff --git a/src/Linkifier.ts b/src/Linkifier.ts index 8dc27cc2..93eb9063 100644 --- a/src/Linkifier.ts +++ b/src/Linkifier.ts @@ -230,7 +230,7 @@ export class Linkifier extends EventEmitter implements ILinkifier { }, e => { this.emit(LinkHoverEventTypes.HOVER, { x, y, length: uri.length}); - this._terminal.element.style.cursor = 'pointer'; + this._terminal.element.classList.add('xterm-cursor-pointer'); }, e => { this.emit(LinkHoverEventTypes.TOOLTIP, { x, y, length: uri.length}); @@ -240,7 +240,7 @@ export class Linkifier extends EventEmitter implements ILinkifier { }, () => { this.emit(LinkHoverEventTypes.LEAVE, { x, y, length: uri.length}); - this._terminal.element.style.cursor = ''; + this._terminal.element.classList.remove('xterm-cursor-pointer'); if (matcher.hoverLeaveCallback) { matcher.hoverLeaveCallback(); } diff --git a/src/Terminal.ts b/src/Terminal.ts index b818de3d..b27d93d6 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -138,7 +138,6 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT private _viewportElement: HTMLElement; private _helperContainer: HTMLElement; private _compositionView: HTMLElement; - private _charSizeStyleElement: HTMLStyleElement; private _visualBellTimer: number; @@ -668,8 +667,6 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT this._compositionHelper = new CompositionHelper(this.textarea, this._compositionView, this); this._helperContainer.appendChild(this._compositionView); - this._charSizeStyleElement = document.createElement('style'); - this._helperContainer.appendChild(this._charSizeStyleElement); this.charMeasure = new CharMeasure(document, this._helperContainer); // Performance: Add viewport and helper elements from the fragment diff --git a/src/Types.ts b/src/Types.ts index 8f0cf380..dd1b22ca 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -275,7 +275,6 @@ export interface IBufferSet extends IEventEmitter { export interface ICircularList extends IEventEmitter { length: number; maxLength: number; - forEach: (callbackfn: (value: T, index: number) => void) => void; get(index: number): T; set(index: number, value: T): void; diff --git a/src/renderer/CursorRenderLayer.ts b/src/renderer/CursorRenderLayer.ts index bfd215ad..c63c2f14 100644 --- a/src/renderer/CursorRenderLayer.ts +++ b/src/renderer/CursorRenderLayer.ts @@ -33,7 +33,7 @@ export class CursorRenderLayer extends BaseRenderLayer { y: null, isFocused: null, style: null, - width: null, + width: null }; this._cursorRenderers = { 'bar': this._renderBarCursor.bind(this), @@ -51,7 +51,7 @@ export class CursorRenderLayer extends BaseRenderLayer { y: null, isFocused: null, style: null, - width: null, + width: null }; } @@ -183,7 +183,7 @@ export class CursorRenderLayer extends BaseRenderLayer { y: null, isFocused: null, style: null, - width: null, + width: null }; } } diff --git a/src/utils/CharMeasure.ts b/src/utils/CharMeasure.ts index b9f267e8..5ad1de76 100644 --- a/src/utils/CharMeasure.ts +++ b/src/utils/CharMeasure.ts @@ -23,10 +23,7 @@ export class CharMeasure extends EventEmitter implements ICharMeasure { this._document = document; this._parentElement = parentElement; this._measureElement = this._document.createElement('span'); - this._measureElement.style.position = 'absolute'; - this._measureElement.style.top = '0'; - this._measureElement.style.left = '-9999em'; - this._measureElement.style.lineHeight = 'normal'; + this._measureElement.classList.add('xterm-char-measure-element'); this._measureElement.textContent = 'W'; this._measureElement.setAttribute('aria-hidden', 'true'); this._parentElement.appendChild(this._measureElement); @@ -41,7 +38,7 @@ export class CharMeasure extends EventEmitter implements ICharMeasure { } public measure(options: ITerminalOptions): void { - this._measureElement.style.fontFamily = options.fontFamily; + this._measureElement.style.fontFamily = options.fontFamily; this._measureElement.style.fontSize = `${options.fontSize}px`; const geometry = this._measureElement.getBoundingClientRect(); // The element is likely currently display:none, we should retain the @@ -55,5 +52,4 @@ export class CharMeasure extends EventEmitter implements ICharMeasure { this.emit('charsizechanged'); } } - } diff --git a/src/utils/CircularList.ts b/src/utils/CircularList.ts index 7fc5dcbf..1f00ea09 100644 --- a/src/utils/CircularList.ts +++ b/src/utils/CircularList.ts @@ -58,15 +58,6 @@ export class CircularList extends EventEmitter implements ICircularList { this._length = newLength; } - public get forEach(): (callbackfn: (value: T, index: number) => void) => void { - return (callbackfn: (value: T, index: number) => void) => { - let length = this.length; - for (let i = 0; i < length; i++) { - callbackfn(this.get(i), i); - } - }; - } - /** * Gets the value at an index. * diff --git a/src/xterm.css b/src/xterm.css index 3d2e9b62..eec41a05 100644 --- a/src/xterm.css +++ b/src/xterm.css @@ -117,11 +117,13 @@ visibility: hidden; } -.xterm .xterm-char-measure-element { +.xterm-char-measure-element { display: inline-block; visibility: hidden; position: absolute; + top: 0; left: -9999em; + line-height: normal; } .xterm.enable-mouse-events { @@ -151,3 +153,7 @@ height: 1px; overflow: hidden; } + +.xterm-cursor-pointer { + cursor: pointer; +} diff --git a/tslint.json b/tslint.json index 37ede7fe..d42fda71 100644 --- a/tslint.json +++ b/tslint.json @@ -43,6 +43,18 @@ true, "always" ], + "trailing-comma": [ + true, + { + "multiline": { + "objects": "never", + "arrays": "never", + "functions": "never", + "typeLiterals": "ignore" + }, + "esSpecCompliant": true + } + ], "triple-equals": [ true, "allow-null-check" diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index ea22b076..5c9e95e5 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -23,6 +23,7 @@ declare module 'xterm' { * Warning: Enabling this option can reduce performances somewhat. */ allowTransparency?: boolean; + /** * A data uri of the sound to use for the bell (needs bellStyle = 'sound'). */ @@ -55,7 +56,7 @@ declare module 'xterm' { /** * Whether to enable the rendering of bold text. - * + * * @deprecated Use fontWeight and fontWeightBold instead. */ enableBold?: boolean;