1 (function(f
){if(typeof exports
==="object"&&typeof module
!=="undefined"){module
.exports
=f()}else if(typeof define
==="function"&&define
.amd
){define([],f
)}else{var g
;if(typeof window
!=="undefined"){g
=window
}else if(typeof global
!=="undefined"){g
=global
}else if(typeof self
!=="undefined"){g
=self
}else{g
=this}g
.Terminal
= f()}})(function(){var define
,module
,exports
;return (function(){function r(e
,n
,t
){function o(i
,f
){if(!n
[i
]){if(!e
[i
]){var c
="function"==typeof require
&&require
;if(!f
&&c
)return c(i
,!0);if(u
)return u(i
,!0);var a
=new Error("Cannot find module '"+i
+"'");throw a
.code
="MODULE_NOT_FOUND",a
}var p
=n
[i
]={exports
:{}};e
[i
][0].call(p
.exports
,function(r
){var n
=e
[i
][1][r
];return o(n
||r
)},p
,p
.exports
,r
,e
,n
,t
)}return n
[i
].exports
}for(var u
="function"==typeof require
&&require
,i
=0;i
<t
.length
;i
++)o(t
[i
]);return o
}return r
})()({1:[function(require
,module
,exports
){
3 var __extends
= (this && this.__extends
) || (function () {
4 var extendStatics = function (d
, b
) {
5 extendStatics
= Object
.setPrototypeOf
||
6 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
7 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
8 return extendStatics(d
, b
);
10 return function (d
, b
) {
12 function __() { this.constructor = d
; }
13 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
16 Object
.defineProperty(exports
, "__esModule", { value
: true });
17 var Strings
= require("./Strings");
18 var Platform_1
= require("./common/Platform");
19 var RenderDebouncer_1
= require("./ui/RenderDebouncer");
20 var Lifecycle_1
= require("./ui/Lifecycle");
21 var Lifecycle_2
= require("./common/Lifecycle");
22 var MAX_ROWS_TO_READ
= 20;
23 var AccessibilityManager
= (function (_super
) {
24 __extends(AccessibilityManager
, _super
);
25 function AccessibilityManager(_terminal
) {
26 var _this
= _super
.call(this) || this;
27 _this
._terminal
= _terminal
;
28 _this
._liveRegionLineCount
= 0;
29 _this
._charsToConsume
= [];
30 _this
._accessibilityTreeRoot
= document
.createElement('div');
31 _this
._accessibilityTreeRoot
.classList
.add('xterm-accessibility');
32 _this
._rowContainer
= document
.createElement('div');
33 _this
._rowContainer
.classList
.add('xterm-accessibility-tree');
34 _this
._rowElements
= [];
35 for (var i
= 0; i
< _this
._terminal
.rows
; i
++) {
36 _this
._rowElements
[i
] = _this
._createAccessibilityTreeNode();
37 _this
._rowContainer
.appendChild(_this
._rowElements
[i
]);
39 _this
._topBoundaryFocusListener = function (e
) { return _this
._onBoundaryFocus(e
, 0); };
40 _this
._bottomBoundaryFocusListener = function (e
) { return _this
._onBoundaryFocus(e
, 1); };
41 _this
._rowElements
[0].addEventListener('focus', _this
._topBoundaryFocusListener
);
42 _this
._rowElements
[_this
._rowElements
.length
- 1].addEventListener('focus', _this
._bottomBoundaryFocusListener
);
43 _this
._refreshRowsDimensions();
44 _this
._accessibilityTreeRoot
.appendChild(_this
._rowContainer
);
45 _this
._renderRowsDebouncer
= new RenderDebouncer_1
.RenderDebouncer(_this
._renderRows
.bind(_this
));
47 _this
._liveRegion
= document
.createElement('div');
48 _this
._liveRegion
.classList
.add('live-region');
49 _this
._liveRegion
.setAttribute('aria-live', 'assertive');
50 _this
._accessibilityTreeRoot
.appendChild(_this
._liveRegion
);
51 _this
._terminal
.element
.insertAdjacentElement('afterbegin', _this
._accessibilityTreeRoot
);
52 _this
.register(_this
._renderRowsDebouncer
);
53 _this
.register(_this
._terminal
.onResize(function (e
) { return _this
._onResize(e
.rows
); }));
54 _this
.register(_this
._terminal
.onRender(function (e
) { return _this
._refreshRows(e
.start
, e
.end
); }));
55 _this
.register(_this
._terminal
.onScroll(function () { return _this
._refreshRows(); }));
56 _this
.register(_this
._terminal
.addDisposableListener('a11y.char', function (char) { return _this
._onChar(char); }));
57 _this
.register(_this
._terminal
.onLineFeed(function () { return _this
._onChar('\n'); }));
58 _this
.register(_this
._terminal
.addDisposableListener('a11y.tab', function (spaceCount
) { return _this
._onTab(spaceCount
); }));
59 _this
.register(_this
._terminal
.onKey(function (e
) { return _this
._onKey(e
.key
); }));
60 _this
.register(_this
._terminal
.addDisposableListener('blur', function () { return _this
._clearLiveRegion(); }));
61 _this
.register(_this
._terminal
.addDisposableListener('dprchange', function () { return _this
._refreshRowsDimensions(); }));
62 _this
.register(_this
._terminal
.renderer
.onCanvasResize(function () { return _this
._refreshRowsDimensions(); }));
63 _this
.register(Lifecycle_1
.addDisposableDomListener(window
, 'resize', function () { return _this
._refreshRowsDimensions(); }));
66 AccessibilityManager
.prototype.dispose = function () {
67 _super
.prototype.dispose
.call(this);
68 this._terminal
.element
.removeChild(this._accessibilityTreeRoot
);
69 this._rowElements
.length
= 0;
71 AccessibilityManager
.prototype._onBoundaryFocus = function (e
, position
) {
72 var boundaryElement
= e
.target
;
73 var beforeBoundaryElement
= this._rowElements
[position
=== 0 ? 1 : this._rowElements
.length
- 2];
74 var posInSet
= boundaryElement
.getAttribute('aria-posinset');
75 var lastRowPos
= position
=== 0 ? '1' : "" + this._terminal
.buffer
.lines
.length
;
76 if (posInSet
=== lastRowPos
) {
79 if (e
.relatedTarget
!== beforeBoundaryElement
) {
82 var topBoundaryElement
;
83 var bottomBoundaryElement
;
85 topBoundaryElement
= boundaryElement
;
86 bottomBoundaryElement
= this._rowElements
.pop();
87 this._rowContainer
.removeChild(bottomBoundaryElement
);
90 topBoundaryElement
= this._rowElements
.shift();
91 bottomBoundaryElement
= boundaryElement
;
92 this._rowContainer
.removeChild(topBoundaryElement
);
94 topBoundaryElement
.removeEventListener('focus', this._topBoundaryFocusListener
);
95 bottomBoundaryElement
.removeEventListener('focus', this._bottomBoundaryFocusListener
);
97 var newElement
= this._createAccessibilityTreeNode();
98 this._rowElements
.unshift(newElement
);
99 this._rowContainer
.insertAdjacentElement('afterbegin', newElement
);
102 var newElement
= this._createAccessibilityTreeNode();
103 this._rowElements
.push(newElement
);
104 this._rowContainer
.appendChild(newElement
);
106 this._rowElements
[0].addEventListener('focus', this._topBoundaryFocusListener
);
107 this._rowElements
[this._rowElements
.length
- 1].addEventListener('focus', this._bottomBoundaryFocusListener
);
108 this._terminal
.scrollLines(position
=== 0 ? -1 : 1);
109 this._rowElements
[position
=== 0 ? 1 : this._rowElements
.length
- 2].focus();
111 e
.stopImmediatePropagation();
113 AccessibilityManager
.prototype._onResize = function (rows
) {
114 this._rowElements
[this._rowElements
.length
- 1].removeEventListener('focus', this._bottomBoundaryFocusListener
);
115 for (var i
= this._rowContainer
.children
.length
; i
< this._terminal
.rows
; i
++) {
116 this._rowElements
[i
] = this._createAccessibilityTreeNode();
117 this._rowContainer
.appendChild(this._rowElements
[i
]);
119 while (this._rowElements
.length
> rows
) {
120 this._rowContainer
.removeChild(this._rowElements
.pop());
122 this._rowElements
[this._rowElements
.length
- 1].addEventListener('focus', this._bottomBoundaryFocusListener
);
123 this._refreshRowsDimensions();
125 AccessibilityManager
.prototype._createAccessibilityTreeNode = function () {
126 var element
= document
.createElement('div');
127 element
.setAttribute('role', 'listitem');
128 element
.tabIndex
= -1;
129 this._refreshRowDimensions(element
);
132 AccessibilityManager
.prototype._onTab = function (spaceCount
) {
133 for (var i
= 0; i
< spaceCount
; i
++) {
137 AccessibilityManager
.prototype._onChar = function (char) {
139 if (this._liveRegionLineCount
< MAX_ROWS_TO_READ
+ 1) {
140 if (this._charsToConsume
.length
> 0) {
141 var shiftedChar
= this._charsToConsume
.shift();
142 if (shiftedChar
!== char) {
143 this._announceCharacter(char);
147 this._announceCharacter(char);
150 this._liveRegionLineCount
++;
151 if (this._liveRegionLineCount
=== MAX_ROWS_TO_READ
+ 1) {
152 this._liveRegion
.textContent
+= Strings
.tooMuchOutput
;
155 if (Platform_1
.isMac
) {
156 if (this._liveRegion
.textContent
&& this._liveRegion
.textContent
.length
> 0 && !this._liveRegion
.parentNode
) {
157 setTimeout(function () {
158 _this
._accessibilityTreeRoot
.appendChild(_this
._liveRegion
);
164 AccessibilityManager
.prototype._clearLiveRegion = function () {
165 this._liveRegion
.textContent
= '';
166 this._liveRegionLineCount
= 0;
167 if (Platform_1
.isMac
) {
168 if (this._liveRegion
.parentNode
) {
169 this._accessibilityTreeRoot
.removeChild(this._liveRegion
);
173 AccessibilityManager
.prototype._onKey = function (keyChar
) {
174 this._clearLiveRegion();
175 this._charsToConsume
.push(keyChar
);
177 AccessibilityManager
.prototype._refreshRows = function (start
, end
) {
178 this._renderRowsDebouncer
.refresh(start
, end
, this._terminal
.rows
);
180 AccessibilityManager
.prototype._renderRows = function (start
, end
) {
181 var buffer
= this._terminal
.buffer
;
182 var setSize
= buffer
.lines
.length
.toString();
183 for (var i
= start
; i
<= end
; i
++) {
184 var lineData
= buffer
.translateBufferLineToString(buffer
.ydisp
+ i
, true);
185 var posInSet
= (buffer
.ydisp
+ i
+ 1).toString();
186 var element
= this._rowElements
[i
];
188 element
.textContent
= lineData
.length
=== 0 ? Strings
.blankLine
: lineData
;
189 element
.setAttribute('aria-posinset', posInSet
);
190 element
.setAttribute('aria-setsize', setSize
);
194 AccessibilityManager
.prototype._refreshRowsDimensions = function () {
195 if (!this._terminal
.renderer
.dimensions
.actualCellHeight
) {
198 if (this._rowElements
.length
!== this._terminal
.rows
) {
199 this._onResize(this._terminal
.rows
);
201 for (var i
= 0; i
< this._terminal
.rows
; i
++) {
202 this._refreshRowDimensions(this._rowElements
[i
]);
205 AccessibilityManager
.prototype._refreshRowDimensions = function (element
) {
206 element
.style
.height
= this._terminal
.renderer
.dimensions
.actualCellHeight
+ "px";
208 AccessibilityManager
.prototype._announceCharacter = function (char) {
210 this._liveRegion
.innerHTML
+= ' ';
213 this._liveRegion
.textContent
+= char;
216 return AccessibilityManager
;
217 }(Lifecycle_2
.Disposable
));
218 exports
.AccessibilityManager
= AccessibilityManager
;
220 },{"./Strings":18,"./common/Lifecycle":26,"./common/Platform":27,"./ui/Lifecycle":55,"./ui/RenderDebouncer":56}],2:[function(require
,module
,exports
){
222 var __extends
= (this && this.__extends
) || (function () {
223 var extendStatics = function (d
, b
) {
224 extendStatics
= Object
.setPrototypeOf
||
225 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
226 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
227 return extendStatics(d
, b
);
229 return function (d
, b
) {
231 function __() { this.constructor = d
; }
232 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
235 Object
.defineProperty(exports
, "__esModule", { value
: true });
236 var CircularList_1
= require("./common/CircularList");
237 var BufferLine_1
= require("./BufferLine");
238 var BufferReflow_1
= require("./BufferReflow");
239 var Types_1
= require("./renderer/atlas/Types");
240 var EventEmitter2_1
= require("./common/EventEmitter2");
241 var Lifecycle_1
= require("../lib/common/Lifecycle");
242 exports
.DEFAULT_ATTR
= (0 << 18) | (Types_1
.DEFAULT_COLOR
<< 9) | (256 << 0);
243 exports
.DEFAULT_ATTR_DATA
= new BufferLine_1
.AttributeData();
244 exports
.CHAR_DATA_ATTR_INDEX
= 0;
245 exports
.CHAR_DATA_CHAR_INDEX
= 1;
246 exports
.CHAR_DATA_WIDTH_INDEX
= 2;
247 exports
.CHAR_DATA_CODE_INDEX
= 3;
248 exports
.MAX_BUFFER_SIZE
= 4294967295;
249 exports
.NULL_CELL_CHAR
= '';
250 exports
.NULL_CELL_WIDTH
= 1;
251 exports
.NULL_CELL_CODE
= 0;
252 exports
.WHITESPACE_CELL_CHAR
= ' ';
253 exports
.WHITESPACE_CELL_WIDTH
= 1;
254 exports
.WHITESPACE_CELL_CODE
= 32;
255 var Buffer
= (function () {
256 function Buffer(_terminal
, _hasScrollback
) {
257 this._terminal
= _terminal
;
258 this._hasScrollback
= _hasScrollback
;
259 this.savedCurAttrData
= exports
.DEFAULT_ATTR_DATA
.clone();
261 this._nullCell
= BufferLine_1
.CellData
.fromCharData([0, exports
.NULL_CELL_CHAR
, exports
.NULL_CELL_WIDTH
, exports
.NULL_CELL_CODE
]);
262 this._whitespaceCell
= BufferLine_1
.CellData
.fromCharData([0, exports
.WHITESPACE_CELL_CHAR
, exports
.WHITESPACE_CELL_WIDTH
, exports
.WHITESPACE_CELL_CODE
]);
263 this._cols
= this._terminal
.cols
;
264 this._rows
= this._terminal
.rows
;
267 Buffer
.prototype.getNullCell = function (attr
) {
269 this._nullCell
.fg
= attr
.fg
;
270 this._nullCell
.bg
= attr
.bg
;
273 this._nullCell
.fg
= 0;
274 this._nullCell
.bg
= 0;
276 return this._nullCell
;
278 Buffer
.prototype.getWhitespaceCell = function (attr
) {
280 this._whitespaceCell
.fg
= attr
.fg
;
281 this._whitespaceCell
.bg
= attr
.bg
;
284 this._whitespaceCell
.fg
= 0;
285 this._whitespaceCell
.bg
= 0;
287 return this._whitespaceCell
;
289 Buffer
.prototype.getBlankLine = function (attr
, isWrapped
) {
290 return new BufferLine_1
.BufferLine(this._terminal
.cols
, this.getNullCell(attr
), isWrapped
);
292 Object
.defineProperty(Buffer
.prototype, "hasScrollback", {
294 return this._hasScrollback
&& this.lines
.maxLength
> this._rows
;
299 Object
.defineProperty(Buffer
.prototype, "isCursorInViewport", {
301 var absoluteY
= this.ybase
+ this.y
;
302 var relativeY
= absoluteY
- this.ydisp
;
303 return (relativeY
>= 0 && relativeY
< this._rows
);
308 Buffer
.prototype._getCorrectBufferLength = function (rows
) {
309 if (!this._hasScrollback
) {
312 var correctBufferLength
= rows
+ this._terminal
.options
.scrollback
;
313 return correctBufferLength
> exports
.MAX_BUFFER_SIZE
? exports
.MAX_BUFFER_SIZE
: correctBufferLength
;
315 Buffer
.prototype.fillViewportRows = function (fillAttr
) {
316 if (this.lines
.length
=== 0) {
317 if (fillAttr
=== undefined) {
318 fillAttr
= exports
.DEFAULT_ATTR_DATA
;
322 this.lines
.push(this.getBlankLine(fillAttr
));
326 Buffer
.prototype.clear = function () {
331 this.lines
= new CircularList_1
.CircularList(this._getCorrectBufferLength(this._rows
));
333 this.scrollBottom
= this._rows
- 1;
334 this.setupTabStops();
336 Buffer
.prototype.resize = function (newCols
, newRows
) {
337 var nullCell
= this.getNullCell(exports
.DEFAULT_ATTR_DATA
);
338 var newMaxLength
= this._getCorrectBufferLength(newRows
);
339 if (newMaxLength
> this.lines
.maxLength
) {
340 this.lines
.maxLength
= newMaxLength
;
342 if (this.lines
.length
> 0) {
343 if (this._cols
< newCols
) {
344 for (var i
= 0; i
< this.lines
.length
; i
++) {
345 this.lines
.get(i
).resize(newCols
, nullCell
);
349 if (this._rows
< newRows
) {
350 for (var y
= this._rows
; y
< newRows
; y
++) {
351 if (this.lines
.length
< newRows
+ this.ybase
) {
352 if (this.ybase
> 0 && this.lines
.length
<= this.ybase
+ this.y
+ addToY
+ 1) {
355 if (this.ydisp
> 0) {
360 this.lines
.push(new BufferLine_1
.BufferLine(newCols
, nullCell
));
366 for (var y
= this._rows
; y
> newRows
; y
--) {
367 if (this.lines
.length
> newRows
+ this.ybase
) {
368 if (this.lines
.length
> this.ybase
+ this.y
+ 1) {
378 if (newMaxLength
< this.lines
.maxLength
) {
379 var amountToTrim
= this.lines
.length
- newMaxLength
;
380 if (amountToTrim
> 0) {
381 this.lines
.trimStart(amountToTrim
);
382 this.ybase
= Math
.max(this.ybase
- amountToTrim
, 0);
383 this.ydisp
= Math
.max(this.ydisp
- amountToTrim
, 0);
385 this.lines
.maxLength
= newMaxLength
;
387 this.x
= Math
.min(this.x
, newCols
- 1);
388 this.y
= Math
.min(this.y
, newRows
- 1);
392 this.savedY
= Math
.min(this.savedY
, newRows
- 1);
393 this.savedX
= Math
.min(this.savedX
, newCols
- 1);
396 this.scrollBottom
= newRows
- 1;
397 if (this._isReflowEnabled
) {
398 this._reflow(newCols
, newRows
);
399 if (this._cols
> newCols
) {
400 for (var i
= 0; i
< this.lines
.length
; i
++) {
401 this.lines
.get(i
).resize(newCols
, nullCell
);
405 this._cols
= newCols
;
406 this._rows
= newRows
;
408 Object
.defineProperty(Buffer
.prototype, "_isReflowEnabled", {
410 return this._hasScrollback
&& !this._terminal
.options
.windowsMode
;
415 Buffer
.prototype._reflow = function (newCols
, newRows
) {
416 if (this._cols
=== newCols
) {
419 if (newCols
> this._cols
) {
420 this._reflowLarger(newCols
, newRows
);
423 this._reflowSmaller(newCols
, newRows
);
426 Buffer
.prototype._reflowLarger = function (newCols
, newRows
) {
427 var toRemove
= BufferReflow_1
.reflowLargerGetLinesToRemove(this.lines
, this._cols
, newCols
, this.ybase
+ this.y
, this.getNullCell(exports
.DEFAULT_ATTR_DATA
));
428 if (toRemove
.length
> 0) {
429 var newLayoutResult
= BufferReflow_1
.reflowLargerCreateNewLayout(this.lines
, toRemove
);
430 BufferReflow_1
.reflowLargerApplyNewLayout(this.lines
, newLayoutResult
.layout
);
431 this._reflowLargerAdjustViewport(newCols
, newRows
, newLayoutResult
.countRemoved
);
434 Buffer
.prototype._reflowLargerAdjustViewport = function (newCols
, newRows
, countRemoved
) {
435 var nullCell
= this.getNullCell(exports
.DEFAULT_ATTR_DATA
);
436 var viewportAdjustments
= countRemoved
;
437 while (viewportAdjustments
-- > 0) {
438 if (this.ybase
=== 0) {
442 if (this.lines
.length
< newRows
) {
443 this.lines
.push(new BufferLine_1
.BufferLine(newCols
, nullCell
));
447 if (this.ydisp
=== this.ybase
) {
454 Buffer
.prototype._reflowSmaller = function (newCols
, newRows
) {
455 var nullCell
= this.getNullCell(exports
.DEFAULT_ATTR_DATA
);
457 var countToInsert
= 0;
458 for (var y
= this.lines
.length
- 1; y
>= 0; y
--) {
459 var nextLine
= this.lines
.get(y
);
460 if (!nextLine
.isWrapped
&& nextLine
.getTrimmedLength() <= newCols
) {
463 var wrappedLines
= [nextLine
];
464 while (nextLine
.isWrapped
&& y
> 0) {
465 nextLine
= this.lines
.get(--y
);
466 wrappedLines
.unshift(nextLine
);
468 var absoluteY
= this.ybase
+ this.y
;
469 if (absoluteY
>= y
&& absoluteY
< y
+ wrappedLines
.length
) {
472 var lastLineLength
= wrappedLines
[wrappedLines
.length
- 1].getTrimmedLength();
473 var destLineLengths
= BufferReflow_1
.reflowSmallerGetNewLineLengths(wrappedLines
, this._cols
, newCols
);
474 var linesToAdd
= destLineLengths
.length
- wrappedLines
.length
;
475 var trimmedLines
= void 0;
476 if (this.ybase
=== 0 && this.y
!== this.lines
.length
- 1) {
477 trimmedLines
= Math
.max(0, this.y
- this.lines
.maxLength
+ linesToAdd
);
480 trimmedLines
= Math
.max(0, this.lines
.length
- this.lines
.maxLength
+ linesToAdd
);
483 for (var i
= 0; i
< linesToAdd
; i
++) {
484 var newLine
= this.getBlankLine(exports
.DEFAULT_ATTR_DATA
, true);
485 newLines
.push(newLine
);
487 if (newLines
.length
> 0) {
489 start
: y
+ wrappedLines
.length
+ countToInsert
,
492 countToInsert
+= newLines
.length
;
494 wrappedLines
.push
.apply(wrappedLines
, newLines
);
495 var destLineIndex
= destLineLengths
.length
- 1;
496 var destCol
= destLineLengths
[destLineIndex
];
499 destCol
= destLineLengths
[destLineIndex
];
501 var srcLineIndex
= wrappedLines
.length
- linesToAdd
- 1;
502 var srcCol
= lastLineLength
;
503 while (srcLineIndex
>= 0) {
504 var cellsToCopy
= Math
.min(srcCol
, destCol
);
505 wrappedLines
[destLineIndex
].copyCellsFrom(wrappedLines
[srcLineIndex
], srcCol
- cellsToCopy
, destCol
- cellsToCopy
, cellsToCopy
, true);
506 destCol
-= cellsToCopy
;
509 destCol
= destLineLengths
[destLineIndex
];
511 srcCol
-= cellsToCopy
;
514 var wrappedLinesIndex
= Math
.max(srcLineIndex
, 0);
515 srcCol
= BufferReflow_1
.getWrappedLineTrimmedLength(wrappedLines
, wrappedLinesIndex
, this._cols
);
518 for (var i
= 0; i
< wrappedLines
.length
; i
++) {
519 if (destLineLengths
[i
] < newCols
) {
520 wrappedLines
[i
].setCell(destLineLengths
[i
], nullCell
);
523 var viewportAdjustments
= linesToAdd
- trimmedLines
;
524 while (viewportAdjustments
-- > 0) {
525 if (this.ybase
=== 0) {
526 if (this.y
< newRows
- 1) {
536 if (this.ybase
< Math
.min(this.lines
.maxLength
, this.lines
.length
+ countToInsert
) - newRows
) {
537 if (this.ybase
=== this.ydisp
) {
545 if (toInsert
.length
> 0) {
546 var insertEvents
= [];
547 var originalLines
= [];
548 for (var i
= 0; i
< this.lines
.length
; i
++) {
549 originalLines
.push(this.lines
.get(i
));
551 var originalLinesLength
= this.lines
.length
;
552 var originalLineIndex
= originalLinesLength
- 1;
553 var nextToInsertIndex
= 0;
554 var nextToInsert
= toInsert
[nextToInsertIndex
];
555 this.lines
.length
= Math
.min(this.lines
.maxLength
, this.lines
.length
+ countToInsert
);
556 var countInsertedSoFar
= 0;
557 for (var i
= Math
.min(this.lines
.maxLength
- 1, originalLinesLength
+ countToInsert
- 1); i
>= 0; i
--) {
558 if (nextToInsert
&& nextToInsert
.start
> originalLineIndex
+ countInsertedSoFar
) {
559 for (var nextI
= nextToInsert
.newLines
.length
- 1; nextI
>= 0; nextI
--) {
560 this.lines
.set(i
--, nextToInsert
.newLines
[nextI
]);
564 index
: originalLineIndex
+ 1,
565 amount
: nextToInsert
.newLines
.length
567 countInsertedSoFar
+= nextToInsert
.newLines
.length
;
568 nextToInsert
= toInsert
[++nextToInsertIndex
];
571 this.lines
.set(i
, originalLines
[originalLineIndex
--]);
574 var insertCountEmitted
= 0;
575 for (var i
= insertEvents
.length
- 1; i
>= 0; i
--) {
576 insertEvents
[i
].index
+= insertCountEmitted
;
577 this.lines
.onInsertEmitter
.fire(insertEvents
[i
]);
578 insertCountEmitted
+= insertEvents
[i
].amount
;
580 var amountToTrim
= Math
.max(0, originalLinesLength
+ countToInsert
- this.lines
.maxLength
);
581 if (amountToTrim
> 0) {
582 this.lines
.onTrimEmitter
.fire(amountToTrim
);
586 Buffer
.prototype.stringIndexToBufferIndex = function (lineIndex
, stringIndex
, trimRight
) {
587 if (trimRight
=== void 0) { trimRight
= false; }
588 while (stringIndex
) {
589 var line
= this.lines
.get(lineIndex
);
593 var length_1
= (trimRight
) ? line
.getTrimmedLength() : line
.length
;
594 for (var i
= 0; i
< length_1
; ++i
) {
595 if (line
.get(i
)[exports
.CHAR_DATA_WIDTH_INDEX
]) {
596 stringIndex
-= line
.get(i
)[exports
.CHAR_DATA_CHAR_INDEX
].length
|| 1;
598 if (stringIndex
< 0) {
599 return [lineIndex
, i
];
604 return [lineIndex
, 0];
606 Buffer
.prototype.translateBufferLineToString = function (lineIndex
, trimRight
, startCol
, endCol
) {
607 if (startCol
=== void 0) { startCol
= 0; }
608 var line
= this.lines
.get(lineIndex
);
612 return line
.translateToString(trimRight
, startCol
, endCol
);
614 Buffer
.prototype.getWrappedRangeForLine = function (y
) {
617 while (first
> 0 && this.lines
.get(first
).isWrapped
) {
620 while (last
+ 1 < this.lines
.length
&& this.lines
.get(last
+ 1).isWrapped
) {
623 return { first
: first
, last
: last
};
625 Buffer
.prototype.setupTabStops = function (i
) {
626 if (i
!== null && i
!== undefined) {
628 i
= this.prevStop(i
);
635 for (; i
< this._cols
; i
+= this._terminal
.options
.tabStopWidth
) {
639 Buffer
.prototype.prevStop = function (x
) {
640 if (x
=== null || x
=== undefined) {
643 while (!this.tabs
[--x
] && x
> 0)
645 return x
>= this._cols
? this._cols
- 1 : x
< 0 ? 0 : x
;
647 Buffer
.prototype.nextStop = function (x
) {
648 if (x
=== null || x
=== undefined) {
651 while (!this.tabs
[++x
] && x
< this._cols
)
653 return x
>= this._cols
? this._cols
- 1 : x
< 0 ? 0 : x
;
655 Buffer
.prototype.addMarker = function (y
) {
657 var marker
= new Marker(y
);
658 this.markers
.push(marker
);
659 marker
.register(this.lines
.onTrim(function (amount
) {
660 marker
.line
-= amount
;
661 if (marker
.line
< 0) {
665 marker
.register(this.lines
.onInsert(function (event
) {
666 if (marker
.line
>= event
.index
) {
667 marker
.line
+= event
.amount
;
670 marker
.register(this.lines
.onDelete(function (event
) {
671 if (marker
.line
>= event
.index
&& marker
.line
< event
.index
+ event
.amount
) {
674 if (marker
.line
> event
.index
) {
675 marker
.line
-= event
.amount
;
678 marker
.register(marker
.onDispose(function () { return _this
._removeMarker(marker
); }));
681 Buffer
.prototype._removeMarker = function (marker
) {
682 this.markers
.splice(this.markers
.indexOf(marker
), 1);
684 Buffer
.prototype.iterator = function (trimRight
, startIndex
, endIndex
, startOverscan
, endOverscan
) {
685 return new BufferStringIterator(this, trimRight
, startIndex
, endIndex
, startOverscan
, endOverscan
);
689 exports
.Buffer
= Buffer
;
690 var Marker
= (function (_super
) {
691 __extends(Marker
, _super
);
692 function Marker(line
) {
693 var _this
= _super
.call(this) || this;
695 _this
._id
= Marker
._nextId
++;
696 _this
.isDisposed
= false;
697 _this
._onDispose
= new EventEmitter2_1
.EventEmitter2();
700 Object
.defineProperty(Marker
.prototype, "id", {
701 get: function () { return this._id
; },
705 Object
.defineProperty(Marker
.prototype, "onDispose", {
706 get: function () { return this._onDispose
.event
; },
710 Marker
.prototype.dispose = function () {
711 if (this.isDisposed
) {
714 this.isDisposed
= true;
715 this._onDispose
.fire();
719 }(Lifecycle_1
.Disposable
));
720 exports
.Marker
= Marker
;
721 var BufferStringIterator
= (function () {
722 function BufferStringIterator(_buffer
, _trimRight
, _startIndex
, _endIndex
, _startOverscan
, _endOverscan
) {
723 if (_startIndex
=== void 0) { _startIndex
= 0; }
724 if (_endIndex
=== void 0) { _endIndex
= _buffer
.lines
.length
; }
725 if (_startOverscan
=== void 0) { _startOverscan
= 0; }
726 if (_endOverscan
=== void 0) { _endOverscan
= 0; }
727 this._buffer
= _buffer
;
728 this._trimRight
= _trimRight
;
729 this._startIndex
= _startIndex
;
730 this._endIndex
= _endIndex
;
731 this._startOverscan
= _startOverscan
;
732 this._endOverscan
= _endOverscan
;
733 if (this._startIndex
< 0) {
734 this._startIndex
= 0;
736 if (this._endIndex
> this._buffer
.lines
.length
) {
737 this._endIndex
= this._buffer
.lines
.length
;
739 this._current
= this._startIndex
;
741 BufferStringIterator
.prototype.hasNext = function () {
742 return this._current
< this._endIndex
;
744 BufferStringIterator
.prototype.next = function () {
745 var range
= this._buffer
.getWrappedRangeForLine(this._current
);
746 if (range
.first
< this._startIndex
- this._startOverscan
) {
747 range
.first
= this._startIndex
- this._startOverscan
;
749 if (range
.last
> this._endIndex
+ this._endOverscan
) {
750 range
.last
= this._endIndex
+ this._endOverscan
;
752 range
.first
= Math
.max(range
.first
, 0);
753 range
.last
= Math
.min(range
.last
, this._buffer
.lines
.length
);
755 for (var i
= range
.first
; i
<= range
.last
; ++i
) {
756 result
+= this._buffer
.translateBufferLineToString(i
, this._trimRight
);
758 this._current
= range
.last
+ 1;
759 return { range
: range
, content
: result
};
761 return BufferStringIterator
;
763 exports
.BufferStringIterator
= BufferStringIterator
;
765 },{"../lib/common/Lifecycle":26,"./BufferLine":3,"./BufferReflow":4,"./common/CircularList":22,"./common/EventEmitter2":25,"./renderer/atlas/Types":52}],3:[function(require
,module
,exports
){
767 var __extends
= (this && this.__extends
) || (function () {
768 var extendStatics = function (d
, b
) {
769 extendStatics
= Object
.setPrototypeOf
||
770 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
771 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
772 return extendStatics(d
, b
);
774 return function (d
, b
) {
776 function __() { this.constructor = d
; }
777 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
780 Object
.defineProperty(exports
, "__esModule", { value
: true });
781 var Buffer_1
= require("./Buffer");
782 var TextDecoder_1
= require("./core/input/TextDecoder");
784 var AttributeData
= (function () {
785 function AttributeData() {
789 AttributeData
.toColorRGB = function (value
) {
796 AttributeData
.fromColorRGB = function (value
) {
797 return (value
[0] & 255) << 16 | (value
[1] & 255) << 8 | value
[2] & 255;
799 AttributeData
.prototype.clone = function () {
800 var newObj
= new AttributeData();
805 AttributeData
.prototype.isInverse = function () { return this.fg
& 67108864; };
806 AttributeData
.prototype.isBold = function () { return this.fg
& 134217728; };
807 AttributeData
.prototype.isUnderline = function () { return this.fg
& 268435456; };
808 AttributeData
.prototype.isBlink = function () { return this.fg
& 536870912; };
809 AttributeData
.prototype.isInvisible = function () { return this.fg
& 1073741824; };
810 AttributeData
.prototype.isItalic = function () { return this.bg
& 67108864; };
811 AttributeData
.prototype.isDim = function () { return this.bg
& 134217728; };
812 AttributeData
.prototype.getFgColorMode = function () { return this.fg
& 50331648; };
813 AttributeData
.prototype.getBgColorMode = function () { return this.bg
& 50331648; };
814 AttributeData
.prototype.isFgRGB = function () { return (this.fg
& 50331648) === 50331648; };
815 AttributeData
.prototype.isBgRGB = function () { return (this.bg
& 50331648) === 50331648; };
816 AttributeData
.prototype.isFgPalette = function () { return (this.fg
& 50331648) === 16777216 || (this.fg
& 50331648) === 33554432; };
817 AttributeData
.prototype.isBgPalette = function () { return (this.bg
& 50331648) === 16777216 || (this.bg
& 50331648) === 33554432; };
818 AttributeData
.prototype.isFgDefault = function () { return (this.fg
& 50331648) === 0; };
819 AttributeData
.prototype.isBgDefault = function () { return (this.bg
& 50331648) === 0; };
820 AttributeData
.prototype.getFgColor = function () {
821 switch (this.fg
& 50331648) {
823 case 33554432: return this.fg
& 255;
824 case 50331648: return this.fg
& 16777215;
828 AttributeData
.prototype.getBgColor = function () {
829 switch (this.bg
& 50331648) {
831 case 33554432: return this.bg
& 255;
832 case 50331648: return this.bg
& 16777215;
836 return AttributeData
;
838 exports
.AttributeData
= AttributeData
;
839 var CellData
= (function (_super
) {
840 __extends(CellData
, _super
);
841 function CellData() {
842 var _this
= _super
!== null && _super
.apply(this, arguments
) || this;
846 _this
.combinedData
= '';
849 CellData
.fromCharData = function (value
) {
850 var obj
= new CellData();
851 obj
.setFromCharData(value
);
854 CellData
.prototype.isCombined = function () {
855 return this.content
& 2097152;
857 CellData
.prototype.getWidth = function () {
858 return this.content
>> 22;
860 CellData
.prototype.getChars = function () {
861 if (this.content
& 2097152) {
862 return this.combinedData
;
864 if (this.content
& 2097151) {
865 return TextDecoder_1
.stringFromCodePoint(this.content
& 2097151);
869 CellData
.prototype.getCode = function () {
870 return (this.isCombined())
871 ? this.combinedData
.charCodeAt(this.combinedData
.length
- 1)
872 : this.content
& 2097151;
874 CellData
.prototype.setFromCharData = function (value
) {
875 this.fg
= value
[Buffer_1
.CHAR_DATA_ATTR_INDEX
];
877 var combined
= false;
878 if (value
[Buffer_1
.CHAR_DATA_CHAR_INDEX
].length
> 2) {
881 else if (value
[Buffer_1
.CHAR_DATA_CHAR_INDEX
].length
=== 2) {
882 var code
= value
[Buffer_1
.CHAR_DATA_CHAR_INDEX
].charCodeAt(0);
883 if (0xD800 <= code
&& code
<= 0xDBFF) {
884 var second
= value
[Buffer_1
.CHAR_DATA_CHAR_INDEX
].charCodeAt(1);
885 if (0xDC00 <= second
&& second
<= 0xDFFF) {
886 this.content
= ((code
- 0xD800) * 0x400 + second
- 0xDC00 + 0x10000) | (value
[Buffer_1
.CHAR_DATA_WIDTH_INDEX
] << 22);
897 this.content
= value
[Buffer_1
.CHAR_DATA_CHAR_INDEX
].charCodeAt(0) | (value
[Buffer_1
.CHAR_DATA_WIDTH_INDEX
] << 22);
900 this.combinedData
= value
[Buffer_1
.CHAR_DATA_CHAR_INDEX
];
901 this.content
= 2097152 | (value
[Buffer_1
.CHAR_DATA_WIDTH_INDEX
] << 22);
904 CellData
.prototype.getAsCharData = function () {
905 return [this.fg
, this.getChars(), this.getWidth(), this.getCode()];
909 exports
.CellData
= CellData
;
910 var BufferLine
= (function () {
911 function BufferLine(cols
, fillCellData
, isWrapped
) {
912 if (isWrapped
=== void 0) { isWrapped
= false; }
913 this.isWrapped
= isWrapped
;
917 this._data
= new Uint32Array(cols
* CELL_SIZE
);
918 var cell
= fillCellData
|| CellData
.fromCharData([0, Buffer_1
.NULL_CELL_CHAR
, Buffer_1
.NULL_CELL_WIDTH
, Buffer_1
.NULL_CELL_CODE
]);
919 for (var i
= 0; i
< cols
; ++i
) {
920 this.setCell(i
, cell
);
925 BufferLine
.prototype.get = function (index
) {
926 var content
= this._data
[index
* CELL_SIZE
+ 0];
927 var cp
= content
& 2097151;
929 this._data
[index
* CELL_SIZE
+ 1],
931 ? this._combined
[index
]
932 : (cp
) ? TextDecoder_1
.stringFromCodePoint(cp
) : '',
935 ? this._combined
[index
].charCodeAt(this._combined
[index
].length
- 1)
939 BufferLine
.prototype.set = function (index
, value
) {
940 this._data
[index
* CELL_SIZE
+ 1] = value
[Buffer_1
.CHAR_DATA_ATTR_INDEX
];
941 if (value
[Buffer_1
.CHAR_DATA_CHAR_INDEX
].length
> 1) {
942 this._combined
[index
] = value
[1];
943 this._data
[index
* CELL_SIZE
+ 0] = index
| 2097152 | (value
[Buffer_1
.CHAR_DATA_WIDTH_INDEX
] << 22);
946 this._data
[index
* CELL_SIZE
+ 0] = value
[Buffer_1
.CHAR_DATA_CHAR_INDEX
].charCodeAt(0) | (value
[Buffer_1
.CHAR_DATA_WIDTH_INDEX
] << 22);
949 BufferLine
.prototype.getWidth = function (index
) {
950 return this._data
[index
* CELL_SIZE
+ 0] >> 22;
952 BufferLine
.prototype.hasWidth = function (index
) {
953 return this._data
[index
* CELL_SIZE
+ 0] & 12582912;
955 BufferLine
.prototype.getFg = function (index
) {
956 return this._data
[index
* CELL_SIZE
+ 1];
958 BufferLine
.prototype.getBg = function (index
) {
959 return this._data
[index
* CELL_SIZE
+ 2];
961 BufferLine
.prototype.hasContent = function (index
) {
962 return this._data
[index
* CELL_SIZE
+ 0] & 4194303;
964 BufferLine
.prototype.getCodePoint = function (index
) {
965 var content
= this._data
[index
* CELL_SIZE
+ 0];
966 if (content
& 2097152) {
967 return this._combined
[index
].charCodeAt(this._combined
[index
].length
- 1);
969 return content
& 2097151;
971 BufferLine
.prototype.isCombined = function (index
) {
972 return this._data
[index
* CELL_SIZE
+ 0] & 2097152;
974 BufferLine
.prototype.getString = function (index
) {
975 var content
= this._data
[index
* CELL_SIZE
+ 0];
976 if (content
& 2097152) {
977 return this._combined
[index
];
979 if (content
& 2097151) {
980 return TextDecoder_1
.stringFromCodePoint(content
& 2097151);
984 BufferLine
.prototype.loadCell = function (index
, cell
) {
985 var startIndex
= index
* CELL_SIZE
;
986 cell
.content
= this._data
[startIndex
+ 0];
987 cell
.fg
= this._data
[startIndex
+ 1];
988 cell
.bg
= this._data
[startIndex
+ 2];
989 if (cell
.content
& 2097152) {
990 cell
.combinedData
= this._combined
[index
];
994 BufferLine
.prototype.setCell = function (index
, cell
) {
995 if (cell
.content
& 2097152) {
996 this._combined
[index
] = cell
.combinedData
;
998 this._data
[index
* CELL_SIZE
+ 0] = cell
.content
;
999 this._data
[index
* CELL_SIZE
+ 1] = cell
.fg
;
1000 this._data
[index
* CELL_SIZE
+ 2] = cell
.bg
;
1002 BufferLine
.prototype.setCellFromCodePoint = function (index
, codePoint
, width
, fg
, bg
) {
1003 this._data
[index
* CELL_SIZE
+ 0] = codePoint
| (width
<< 22);
1004 this._data
[index
* CELL_SIZE
+ 1] = fg
;
1005 this._data
[index
* CELL_SIZE
+ 2] = bg
;
1007 BufferLine
.prototype.addCodepointToCell = function (index
, codePoint
) {
1008 var content
= this._data
[index
* CELL_SIZE
+ 0];
1009 if (content
& 2097152) {
1010 this._combined
[index
] += TextDecoder_1
.stringFromCodePoint(codePoint
);
1013 if (content
& 2097151) {
1014 this._combined
[index
] = TextDecoder_1
.stringFromCodePoint(content
& 2097151) + TextDecoder_1
.stringFromCodePoint(codePoint
);
1015 content
&= ~2097151;
1019 content
= codePoint
| (1 << 22);
1021 this._data
[index
* CELL_SIZE
+ 0] = content
;
1024 BufferLine
.prototype.insertCells = function (pos
, n
, fillCellData
) {
1026 if (n
< this.length
- pos
) {
1027 var cell
= new CellData();
1028 for (var i
= this.length
- pos
- n
- 1; i
>= 0; --i
) {
1029 this.setCell(pos
+ n
+ i
, this.loadCell(pos
+ i
, cell
));
1031 for (var i
= 0; i
< n
; ++i
) {
1032 this.setCell(pos
+ i
, fillCellData
);
1036 for (var i
= pos
; i
< this.length
; ++i
) {
1037 this.setCell(i
, fillCellData
);
1041 BufferLine
.prototype.deleteCells = function (pos
, n
, fillCellData
) {
1043 if (n
< this.length
- pos
) {
1044 var cell
= new CellData();
1045 for (var i
= 0; i
< this.length
- pos
- n
; ++i
) {
1046 this.setCell(pos
+ i
, this.loadCell(pos
+ n
+ i
, cell
));
1048 for (var i
= this.length
- n
; i
< this.length
; ++i
) {
1049 this.setCell(i
, fillCellData
);
1053 for (var i
= pos
; i
< this.length
; ++i
) {
1054 this.setCell(i
, fillCellData
);
1058 BufferLine
.prototype.replaceCells = function (start
, end
, fillCellData
) {
1059 while (start
< end
&& start
< this.length
) {
1060 this.setCell(start
++, fillCellData
);
1063 BufferLine
.prototype.resize = function (cols
, fillCellData
) {
1064 if (cols
=== this.length
) {
1067 if (cols
> this.length
) {
1068 var data
= new Uint32Array(cols
* CELL_SIZE
);
1070 if (cols
* CELL_SIZE
< this._data
.length
) {
1071 data
.set(this._data
.subarray(0, cols
* CELL_SIZE
));
1074 data
.set(this._data
);
1078 for (var i
= this.length
; i
< cols
; ++i
) {
1079 this.setCell(i
, fillCellData
);
1084 var data
= new Uint32Array(cols
* CELL_SIZE
);
1085 data
.set(this._data
.subarray(0, cols
* CELL_SIZE
));
1087 var keys
= Object
.keys(this._combined
);
1088 for (var i
= 0; i
< keys
.length
; i
++) {
1089 var key
= parseInt(keys
[i
], 10);
1091 delete this._combined
[key
];
1097 this._combined
= {};
1102 BufferLine
.prototype.fill = function (fillCellData
) {
1103 this._combined
= {};
1104 for (var i
= 0; i
< this.length
; ++i
) {
1105 this.setCell(i
, fillCellData
);
1108 BufferLine
.prototype.copyFrom = function (line
) {
1109 if (this.length
!== line
.length
) {
1110 this._data
= new Uint32Array(line
._data
);
1113 this._data
.set(line
._data
);
1115 this.length
= line
.length
;
1116 this._combined
= {};
1117 for (var el
in line
._combined
) {
1118 this._combined
[el
] = line
._combined
[el
];
1120 this.isWrapped
= line
.isWrapped
;
1122 BufferLine
.prototype.clone = function () {
1123 var newLine
= new BufferLine(0);
1124 newLine
._data
= new Uint32Array(this._data
);
1125 newLine
.length
= this.length
;
1126 for (var el
in this._combined
) {
1127 newLine
._combined
[el
] = this._combined
[el
];
1129 newLine
.isWrapped
= this.isWrapped
;
1132 BufferLine
.prototype.getTrimmedLength = function () {
1133 for (var i
= this.length
- 1; i
>= 0; --i
) {
1134 if ((this._data
[i
* CELL_SIZE
+ 0] & 4194303)) {
1135 return i
+ (this._data
[i
* CELL_SIZE
+ 0] >> 22);
1140 BufferLine
.prototype.copyCellsFrom = function (src
, srcCol
, destCol
, length
, applyInReverse
) {
1141 var srcData
= src
._data
;
1142 if (applyInReverse
) {
1143 for (var cell
= length
- 1; cell
>= 0; cell
--) {
1144 for (var i
= 0; i
< CELL_SIZE
; i
++) {
1145 this._data
[(destCol
+ cell
) * CELL_SIZE
+ i
] = srcData
[(srcCol
+ cell
) * CELL_SIZE
+ i
];
1150 for (var cell
= 0; cell
< length
; cell
++) {
1151 for (var i
= 0; i
< CELL_SIZE
; i
++) {
1152 this._data
[(destCol
+ cell
) * CELL_SIZE
+ i
] = srcData
[(srcCol
+ cell
) * CELL_SIZE
+ i
];
1156 var srcCombinedKeys
= Object
.keys(src
._combined
);
1157 for (var i
= 0; i
< srcCombinedKeys
.length
; i
++) {
1158 var key
= parseInt(srcCombinedKeys
[i
], 10);
1159 if (key
>= srcCol
) {
1160 this._combined
[key
- srcCol
+ destCol
] = src
._combined
[key
];
1164 BufferLine
.prototype.translateToString = function (trimRight
, startCol
, endCol
) {
1165 if (trimRight
=== void 0) { trimRight
= false; }
1166 if (startCol
=== void 0) { startCol
= 0; }
1167 if (endCol
=== void 0) { endCol
= this.length
; }
1169 endCol
= Math
.min(endCol
, this.getTrimmedLength());
1172 while (startCol
< endCol
) {
1173 var content
= this._data
[startCol
* CELL_SIZE
+ 0];
1174 var cp
= content
& 2097151;
1175 result
+= (content
& 2097152) ? this._combined
[startCol
] : (cp
) ? TextDecoder_1
.stringFromCodePoint(cp
) : Buffer_1
.WHITESPACE_CELL_CHAR
;
1176 startCol
+= (content
>> 22) || 1;
1182 exports
.BufferLine
= BufferLine
;
1184 },{"./Buffer":2,"./core/input/TextDecoder":32}],4:[function(require
,module
,exports
){
1186 Object
.defineProperty(exports
, "__esModule", { value
: true });
1187 function reflowLargerGetLinesToRemove(lines
, oldCols
, newCols
, bufferAbsoluteY
, nullCell
) {
1189 for (var y
= 0; y
< lines
.length
- 1; y
++) {
1191 var nextLine
= lines
.get(++i
);
1192 if (!nextLine
.isWrapped
) {
1195 var wrappedLines
= [lines
.get(y
)];
1196 while (i
< lines
.length
&& nextLine
.isWrapped
) {
1197 wrappedLines
.push(nextLine
);
1198 nextLine
= lines
.get(++i
);
1200 if (bufferAbsoluteY
>= y
&& bufferAbsoluteY
< i
) {
1201 y
+= wrappedLines
.length
- 1;
1204 var destLineIndex
= 0;
1205 var destCol
= getWrappedLineTrimmedLength(wrappedLines
, destLineIndex
, oldCols
);
1206 var srcLineIndex
= 1;
1208 while (srcLineIndex
< wrappedLines
.length
) {
1209 var srcTrimmedTineLength
= getWrappedLineTrimmedLength(wrappedLines
, srcLineIndex
, oldCols
);
1210 var srcRemainingCells
= srcTrimmedTineLength
- srcCol
;
1211 var destRemainingCells
= newCols
- destCol
;
1212 var cellsToCopy
= Math
.min(srcRemainingCells
, destRemainingCells
);
1213 wrappedLines
[destLineIndex
].copyCellsFrom(wrappedLines
[srcLineIndex
], srcCol
, destCol
, cellsToCopy
, false);
1214 destCol
+= cellsToCopy
;
1215 if (destCol
=== newCols
) {
1219 srcCol
+= cellsToCopy
;
1220 if (srcCol
=== srcTrimmedTineLength
) {
1224 if (destCol
=== 0 && destLineIndex
!== 0) {
1225 if (wrappedLines
[destLineIndex
- 1].getWidth(newCols
- 1) === 2) {
1226 wrappedLines
[destLineIndex
].copyCellsFrom(wrappedLines
[destLineIndex
- 1], newCols
- 1, destCol
++, 1, false);
1227 wrappedLines
[destLineIndex
- 1].setCell(newCols
- 1, nullCell
);
1231 wrappedLines
[destLineIndex
].replaceCells(destCol
, newCols
, nullCell
);
1232 var countToRemove
= 0;
1233 for (var i_1
= wrappedLines
.length
- 1; i_1
> 0; i_1
--) {
1234 if (i_1
> destLineIndex
|| wrappedLines
[i_1
].getTrimmedLength() === 0) {
1241 if (countToRemove
> 0) {
1242 toRemove
.push(y
+ wrappedLines
.length
- countToRemove
);
1243 toRemove
.push(countToRemove
);
1245 y
+= wrappedLines
.length
- 1;
1249 exports
.reflowLargerGetLinesToRemove
= reflowLargerGetLinesToRemove
;
1250 function reflowLargerCreateNewLayout(lines
, toRemove
) {
1252 var nextToRemoveIndex
= 0;
1253 var nextToRemoveStart
= toRemove
[nextToRemoveIndex
];
1254 var countRemovedSoFar
= 0;
1255 for (var i
= 0; i
< lines
.length
; i
++) {
1256 if (nextToRemoveStart
=== i
) {
1257 var countToRemove
= toRemove
[++nextToRemoveIndex
];
1258 lines
.onDeleteEmitter
.fire({
1259 index
: i
- countRemovedSoFar
,
1260 amount
: countToRemove
1262 i
+= countToRemove
- 1;
1263 countRemovedSoFar
+= countToRemove
;
1264 nextToRemoveStart
= toRemove
[++nextToRemoveIndex
];
1272 countRemoved
: countRemovedSoFar
1275 exports
.reflowLargerCreateNewLayout
= reflowLargerCreateNewLayout
;
1276 function reflowLargerApplyNewLayout(lines
, newLayout
) {
1277 var newLayoutLines
= [];
1278 for (var i
= 0; i
< newLayout
.length
; i
++) {
1279 newLayoutLines
.push(lines
.get(newLayout
[i
]));
1281 for (var i
= 0; i
< newLayoutLines
.length
; i
++) {
1282 lines
.set(i
, newLayoutLines
[i
]);
1284 lines
.length
= newLayout
.length
;
1286 exports
.reflowLargerApplyNewLayout
= reflowLargerApplyNewLayout
;
1287 function reflowSmallerGetNewLineLengths(wrappedLines
, oldCols
, newCols
) {
1288 var newLineLengths
= [];
1289 var cellsNeeded
= wrappedLines
.map(function (l
, i
) { return getWrappedLineTrimmedLength(wrappedLines
, i
, oldCols
); }).reduce(function (p
, c
) { return p
+ c
; });
1292 var cellsAvailable
= 0;
1293 while (cellsAvailable
< cellsNeeded
) {
1294 if (cellsNeeded
- cellsAvailable
< newCols
) {
1295 newLineLengths
.push(cellsNeeded
- cellsAvailable
);
1299 var oldTrimmedLength
= getWrappedLineTrimmedLength(wrappedLines
, srcLine
, oldCols
);
1300 if (srcCol
> oldTrimmedLength
) {
1301 srcCol
-= oldTrimmedLength
;
1304 var endsWithWide
= wrappedLines
[srcLine
].getWidth(srcCol
- 1) === 2;
1308 var lineLength
= endsWithWide
? newCols
- 1 : newCols
;
1309 newLineLengths
.push(lineLength
);
1310 cellsAvailable
+= lineLength
;
1312 return newLineLengths
;
1314 exports
.reflowSmallerGetNewLineLengths
= reflowSmallerGetNewLineLengths
;
1315 function getWrappedLineTrimmedLength(lines
, i
, cols
) {
1316 if (i
=== lines
.length
- 1) {
1317 return lines
[i
].getTrimmedLength();
1319 var endsInNull
= !(lines
[i
].hasContent(cols
- 1)) && lines
[i
].getWidth(cols
- 1) === 1;
1320 var followingLineStartsWithWide
= lines
[i
+ 1].getWidth(0) === 2;
1321 if (endsInNull
&& followingLineStartsWithWide
) {
1326 exports
.getWrappedLineTrimmedLength
= getWrappedLineTrimmedLength
;
1328 },{}],5:[function(require
,module
,exports
){
1330 Object
.defineProperty(exports
, "__esModule", { value
: true });
1331 var Buffer_1
= require("./Buffer");
1332 var EventEmitter2_1
= require("./common/EventEmitter2");
1333 var BufferSet
= (function () {
1334 function BufferSet(_terminal
) {
1335 this._terminal
= _terminal
;
1336 this._onBufferActivate
= new EventEmitter2_1
.EventEmitter2();
1337 this._normal
= new Buffer_1
.Buffer(this._terminal
, true);
1338 this._normal
.fillViewportRows();
1339 this._alt
= new Buffer_1
.Buffer(this._terminal
, false);
1340 this._activeBuffer
= this._normal
;
1341 this.setupTabStops();
1343 Object
.defineProperty(BufferSet
.prototype, "onBufferActivate", {
1344 get: function () { return this._onBufferActivate
.event
; },
1348 Object
.defineProperty(BufferSet
.prototype, "alt", {
1355 Object
.defineProperty(BufferSet
.prototype, "active", {
1357 return this._activeBuffer
;
1362 Object
.defineProperty(BufferSet
.prototype, "normal", {
1364 return this._normal
;
1369 BufferSet
.prototype.activateNormalBuffer = function () {
1370 if (this._activeBuffer
=== this._normal
) {
1373 this._normal
.x
= this._alt
.x
;
1374 this._normal
.y
= this._alt
.y
;
1376 this._activeBuffer
= this._normal
;
1377 this._onBufferActivate
.fire({
1378 activeBuffer
: this._normal
,
1379 inactiveBuffer
: this._alt
1382 BufferSet
.prototype.activateAltBuffer = function (fillAttr
) {
1383 if (this._activeBuffer
=== this._alt
) {
1386 this._alt
.fillViewportRows(fillAttr
);
1387 this._alt
.x
= this._normal
.x
;
1388 this._alt
.y
= this._normal
.y
;
1389 this._activeBuffer
= this._alt
;
1390 this._onBufferActivate
.fire({
1391 activeBuffer
: this._alt
,
1392 inactiveBuffer
: this._normal
1395 BufferSet
.prototype.resize = function (newCols
, newRows
) {
1396 this._normal
.resize(newCols
, newRows
);
1397 this._alt
.resize(newCols
, newRows
);
1399 BufferSet
.prototype.setupTabStops = function (i
) {
1400 this._normal
.setupTabStops(i
);
1401 this._alt
.setupTabStops(i
);
1405 exports
.BufferSet
= BufferSet
;
1407 },{"./Buffer":2,"./common/EventEmitter2":25}],6:[function(require
,module
,exports
){
1409 Object
.defineProperty(exports
, "__esModule", { value
: true });
1410 var EventEmitter2_1
= require("./common/EventEmitter2");
1411 var CharMeasure
= (function () {
1412 function CharMeasure(document
, parentElement
) {
1413 this._onCharSizeChanged
= new EventEmitter2_1
.EventEmitter2();
1414 this._document
= document
;
1415 this._parentElement
= parentElement
;
1416 this._measureElement
= this._document
.createElement('span');
1417 this._measureElement
.classList
.add('xterm-char-measure-element');
1418 this._measureElement
.textContent
= 'W';
1419 this._measureElement
.setAttribute('aria-hidden', 'true');
1420 this._parentElement
.appendChild(this._measureElement
);
1422 Object
.defineProperty(CharMeasure
.prototype, "onCharSizeChanged", {
1423 get: function () { return this._onCharSizeChanged
.event
; },
1427 Object
.defineProperty(CharMeasure
.prototype, "width", {
1434 Object
.defineProperty(CharMeasure
.prototype, "height", {
1436 return this._height
;
1441 CharMeasure
.prototype.measure = function (options
) {
1442 this._measureElement
.style
.fontFamily
= options
.fontFamily
;
1443 this._measureElement
.style
.fontSize
= options
.fontSize
+ "px";
1444 var geometry
= this._measureElement
.getBoundingClientRect();
1445 if (geometry
.width
=== 0 || geometry
.height
=== 0) {
1448 var adjustedHeight
= Math
.ceil(geometry
.height
);
1449 if (this._width
!== geometry
.width
|| this._height
!== adjustedHeight
) {
1450 this._width
= geometry
.width
;
1451 this._height
= adjustedHeight
;
1452 this._onCharSizeChanged
.fire();
1457 exports
.CharMeasure
= CharMeasure
;
1459 },{"./common/EventEmitter2":25}],7:[function(require
,module
,exports
){
1461 Object
.defineProperty(exports
, "__esModule", { value
: true });
1462 var TypedArrayUtils_1
= require("./common/TypedArrayUtils");
1463 exports
.wcwidth
= (function (opts
) {
1464 var COMBINING_BMP
= [
1465 [0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489],
1466 [0x0591, 0x05BD], [0x05BF, 0x05BF], [0x05C1, 0x05C2],
1467 [0x05C4, 0x05C5], [0x05C7, 0x05C7], [0x0600, 0x0603],
1468 [0x0610, 0x0615], [0x064B, 0x065E], [0x0670, 0x0670],
1469 [0x06D6, 0x06E4], [0x06E7, 0x06E8], [0x06EA, 0x06ED],
1470 [0x070F, 0x070F], [0x0711, 0x0711], [0x0730, 0x074A],
1471 [0x07A6, 0x07B0], [0x07EB, 0x07F3], [0x0901, 0x0902],
1472 [0x093C, 0x093C], [0x0941, 0x0948], [0x094D, 0x094D],
1473 [0x0951, 0x0954], [0x0962, 0x0963], [0x0981, 0x0981],
1474 [0x09BC, 0x09BC], [0x09C1, 0x09C4], [0x09CD, 0x09CD],
1475 [0x09E2, 0x09E3], [0x0A01, 0x0A02], [0x0A3C, 0x0A3C],
1476 [0x0A41, 0x0A42], [0x0A47, 0x0A48], [0x0A4B, 0x0A4D],
1477 [0x0A70, 0x0A71], [0x0A81, 0x0A82], [0x0ABC, 0x0ABC],
1478 [0x0AC1, 0x0AC5], [0x0AC7, 0x0AC8], [0x0ACD, 0x0ACD],
1479 [0x0AE2, 0x0AE3], [0x0B01, 0x0B01], [0x0B3C, 0x0B3C],
1480 [0x0B3F, 0x0B3F], [0x0B41, 0x0B43], [0x0B4D, 0x0B4D],
1481 [0x0B56, 0x0B56], [0x0B82, 0x0B82], [0x0BC0, 0x0BC0],
1482 [0x0BCD, 0x0BCD], [0x0C3E, 0x0C40], [0x0C46, 0x0C48],
1483 [0x0C4A, 0x0C4D], [0x0C55, 0x0C56], [0x0CBC, 0x0CBC],
1484 [0x0CBF, 0x0CBF], [0x0CC6, 0x0CC6], [0x0CCC, 0x0CCD],
1485 [0x0CE2, 0x0CE3], [0x0D41, 0x0D43], [0x0D4D, 0x0D4D],
1486 [0x0DCA, 0x0DCA], [0x0DD2, 0x0DD4], [0x0DD6, 0x0DD6],
1487 [0x0E31, 0x0E31], [0x0E34, 0x0E3A], [0x0E47, 0x0E4E],
1488 [0x0EB1, 0x0EB1], [0x0EB4, 0x0EB9], [0x0EBB, 0x0EBC],
1489 [0x0EC8, 0x0ECD], [0x0F18, 0x0F19], [0x0F35, 0x0F35],
1490 [0x0F37, 0x0F37], [0x0F39, 0x0F39], [0x0F71, 0x0F7E],
1491 [0x0F80, 0x0F84], [0x0F86, 0x0F87], [0x0F90, 0x0F97],
1492 [0x0F99, 0x0FBC], [0x0FC6, 0x0FC6], [0x102D, 0x1030],
1493 [0x1032, 0x1032], [0x1036, 0x1037], [0x1039, 0x1039],
1494 [0x1058, 0x1059], [0x1160, 0x11FF], [0x135F, 0x135F],
1495 [0x1712, 0x1714], [0x1732, 0x1734], [0x1752, 0x1753],
1496 [0x1772, 0x1773], [0x17B4, 0x17B5], [0x17B7, 0x17BD],
1497 [0x17C6, 0x17C6], [0x17C9, 0x17D3], [0x17DD, 0x17DD],
1498 [0x180B, 0x180D], [0x18A9, 0x18A9], [0x1920, 0x1922],
1499 [0x1927, 0x1928], [0x1932, 0x1932], [0x1939, 0x193B],
1500 [0x1A17, 0x1A18], [0x1B00, 0x1B03], [0x1B34, 0x1B34],
1501 [0x1B36, 0x1B3A], [0x1B3C, 0x1B3C], [0x1B42, 0x1B42],
1502 [0x1B6B, 0x1B73], [0x1DC0, 0x1DCA], [0x1DFE, 0x1DFF],
1503 [0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2063],
1504 [0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F],
1505 [0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B],
1506 [0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F],
1507 [0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB]
1509 var COMBINING_HIGH
= [
1510 [0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F],
1511 [0x10A38, 0x10A3A], [0x10A3F, 0x10A3F], [0x1D167, 0x1D169],
1512 [0x1D173, 0x1D182], [0x1D185, 0x1D18B], [0x1D1AA, 0x1D1AD],
1513 [0x1D242, 0x1D244], [0xE0001, 0xE0001], [0xE0020, 0xE007F],
1516 function bisearch(ucs
, data
) {
1518 var max
= data
.length
- 1;
1520 if (ucs
< data
[0][0] || ucs
> data
[max
][1]) {
1523 while (max
>= min
) {
1524 mid
= (min
+ max
) >> 1;
1525 if (ucs
> data
[mid
][1]) {
1528 else if (ucs
< data
[mid
][0]) {
1537 function wcwidthHigh(ucs
) {
1538 if (bisearch(ucs
, COMBINING_HIGH
)) {
1541 if ((ucs
>= 0x20000 && ucs
<= 0x2fffd) || (ucs
>= 0x30000 && ucs
<= 0x3fffd)) {
1546 var control
= opts
.control
| 0;
1547 var table
= new Uint8Array(65536);
1548 TypedArrayUtils_1
.fill(table
, 1);
1549 table
[0] = opts
.nul
;
1550 TypedArrayUtils_1
.fill(table
, opts
.control
, 1, 32);
1551 TypedArrayUtils_1
.fill(table
, opts
.control
, 0x7f, 0xa0);
1552 TypedArrayUtils_1
.fill(table
, 2, 0x1100, 0x1160);
1555 TypedArrayUtils_1
.fill(table
, 2, 0x2e80, 0xa4d0);
1557 TypedArrayUtils_1
.fill(table
, 2, 0xac00, 0xd7a4);
1558 TypedArrayUtils_1
.fill(table
, 2, 0xf900, 0xfb00);
1559 TypedArrayUtils_1
.fill(table
, 2, 0xfe10, 0xfe1a);
1560 TypedArrayUtils_1
.fill(table
, 2, 0xfe30, 0xfe70);
1561 TypedArrayUtils_1
.fill(table
, 2, 0xff00, 0xff61);
1562 TypedArrayUtils_1
.fill(table
, 2, 0xffe0, 0xffe7);
1563 for (var r
= 0; r
< COMBINING_BMP
.length
; ++r
) {
1564 TypedArrayUtils_1
.fill(table
, 0, COMBINING_BMP
[r
][0], COMBINING_BMP
[r
][1] + 1);
1566 return function (num
) {
1576 return wcwidthHigh(num
);
1578 })({ nul
: 0, control
: 0 });
1579 function getStringCellWidth(s
) {
1581 var length
= s
.length
;
1582 for (var i
= 0; i
< length
; ++i
) {
1583 var code
= s
.charCodeAt(i
);
1584 if (0xD800 <= code
&& code
<= 0xDBFF) {
1585 if (++i
>= length
) {
1586 return result
+ exports
.wcwidth(code
);
1588 var second
= s
.charCodeAt(i
);
1589 if (0xDC00 <= second
&& second
<= 0xDFFF) {
1590 code
= (code
- 0xD800) * 0x400 + second
- 0xDC00 + 0x10000;
1593 result
+= exports
.wcwidth(second
);
1596 result
+= exports
.wcwidth(code
);
1600 exports
.getStringCellWidth
= getStringCellWidth
;
1602 },{"./common/TypedArrayUtils":28}],8:[function(require
,module
,exports
){
1604 Object
.defineProperty(exports
, "__esModule", { value
: true });
1605 function prepareTextForTerminal(text
) {
1606 return text
.replace(/\r?\n/g, '\r');
1608 exports
.prepareTextForTerminal
= prepareTextForTerminal
;
1609 function bracketTextForPaste(text
, bracketedPasteMode
) {
1610 if (bracketedPasteMode
) {
1611 return '\x1b[200~' + text
+ '\x1b[201~';
1615 exports
.bracketTextForPaste
= bracketTextForPaste
;
1616 function copyHandler(ev
, term
, selectionManager
) {
1617 if (term
.browser
.isMSIE
) {
1618 window
.clipboardData
.setData('Text', selectionManager
.selectionText
);
1621 ev
.clipboardData
.setData('text/plain', selectionManager
.selectionText
);
1623 ev
.preventDefault();
1625 exports
.copyHandler
= copyHandler
;
1626 function pasteHandler(ev
, term
) {
1627 ev
.stopPropagation();
1629 var dispatchPaste = function (text
) {
1630 text
= prepareTextForTerminal(text
);
1631 text
= bracketTextForPaste(text
, term
.bracketedPasteMode
);
1633 term
.textarea
.value
= '';
1634 term
.emit('paste', text
);
1637 if (term
.browser
.isMSIE
) {
1638 if (window
.clipboardData
) {
1639 text
= window
.clipboardData
.getData('Text');
1640 dispatchPaste(text
);
1644 if (ev
.clipboardData
) {
1645 text
= ev
.clipboardData
.getData('text/plain');
1646 dispatchPaste(text
);
1650 exports
.pasteHandler
= pasteHandler
;
1651 function moveTextAreaUnderMouseCursor(ev
, term
) {
1652 var pos
= term
.screenElement
.getBoundingClientRect();
1653 var left
= ev
.clientX
- pos
.left
- 10;
1654 var top
= ev
.clientY
- pos
.top
- 10;
1655 term
.textarea
.style
.position
= 'absolute';
1656 term
.textarea
.style
.width
= '20px';
1657 term
.textarea
.style
.height
= '20px';
1658 term
.textarea
.style
.left
= left
+ "px";
1659 term
.textarea
.style
.top
= top
+ "px";
1660 term
.textarea
.style
.zIndex
= '1000';
1661 term
.textarea
.focus();
1662 setTimeout(function () {
1663 term
.textarea
.style
.position
= null;
1664 term
.textarea
.style
.width
= null;
1665 term
.textarea
.style
.height
= null;
1666 term
.textarea
.style
.left
= null;
1667 term
.textarea
.style
.top
= null;
1668 term
.textarea
.style
.zIndex
= null;
1671 exports
.moveTextAreaUnderMouseCursor
= moveTextAreaUnderMouseCursor
;
1672 function rightClickHandler(ev
, term
, selectionManager
, shouldSelectWord
) {
1673 moveTextAreaUnderMouseCursor(ev
, term
);
1674 if (shouldSelectWord
&& !selectionManager
.isClickInSelection(ev
)) {
1675 selectionManager
.selectWordAtCursor(ev
);
1677 term
.textarea
.value
= selectionManager
.selectionText
;
1678 term
.textarea
.select();
1680 exports
.rightClickHandler
= rightClickHandler
;
1682 },{}],9:[function(require
,module
,exports
){
1684 Object
.defineProperty(exports
, "__esModule", { value
: true });
1685 var CompositionHelper
= (function () {
1686 function CompositionHelper(_textarea
, _compositionView
, _terminal
) {
1687 this._textarea
= _textarea
;
1688 this._compositionView
= _compositionView
;
1689 this._terminal
= _terminal
;
1690 this._isComposing
= false;
1691 this._isSendingComposition
= false;
1692 this._compositionPosition
= { start
: null, end
: null };
1694 CompositionHelper
.prototype.compositionstart = function () {
1695 this._isComposing
= true;
1696 this._compositionPosition
.start
= this._textarea
.value
.length
;
1697 this._compositionView
.textContent
= '';
1698 this._compositionView
.classList
.add('active');
1700 CompositionHelper
.prototype.compositionupdate = function (ev
) {
1702 this._compositionView
.textContent
= ev
.data
;
1703 this.updateCompositionElements();
1704 setTimeout(function () {
1705 _this
._compositionPosition
.end
= _this
._textarea
.value
.length
;
1708 CompositionHelper
.prototype.compositionend = function () {
1709 this._finalizeComposition(true);
1711 CompositionHelper
.prototype.keydown = function (ev
) {
1712 if (this._isComposing
|| this._isSendingComposition
) {
1713 if (ev
.keyCode
=== 229) {
1716 else if (ev
.keyCode
=== 16 || ev
.keyCode
=== 17 || ev
.keyCode
=== 18) {
1719 this._finalizeComposition(false);
1721 if (ev
.keyCode
=== 229) {
1722 this._handleAnyTextareaChanges();
1727 CompositionHelper
.prototype._finalizeComposition = function (waitForPropagation
) {
1729 this._compositionView
.classList
.remove('active');
1730 this._isComposing
= false;
1731 this._clearTextareaPosition();
1732 if (!waitForPropagation
) {
1733 this._isSendingComposition
= false;
1734 var input
= this._textarea
.value
.substring(this._compositionPosition
.start
, this._compositionPosition
.end
);
1735 this._terminal
.handler(input
);
1738 var currentCompositionPosition_1
= {
1739 start
: this._compositionPosition
.start
,
1740 end
: this._compositionPosition
.end
1742 this._isSendingComposition
= true;
1743 setTimeout(function () {
1744 if (_this
._isSendingComposition
) {
1745 _this
._isSendingComposition
= false;
1747 if (_this
._isComposing
) {
1748 input
= _this
._textarea
.value
.substring(currentCompositionPosition_1
.start
, currentCompositionPosition_1
.end
);
1751 input
= _this
._textarea
.value
.substring(currentCompositionPosition_1
.start
);
1753 _this
._terminal
.handler(input
);
1758 CompositionHelper
.prototype._handleAnyTextareaChanges = function () {
1760 var oldValue
= this._textarea
.value
;
1761 setTimeout(function () {
1762 if (!_this
._isComposing
) {
1763 var newValue
= _this
._textarea
.value
;
1764 var diff
= newValue
.replace(oldValue
, '');
1765 if (diff
.length
> 0) {
1766 _this
._terminal
.handler(diff
);
1771 CompositionHelper
.prototype.updateCompositionElements = function (dontRecurse
) {
1773 if (!this._isComposing
) {
1776 if (this._terminal
.buffer
.isCursorInViewport
) {
1777 var cellHeight
= Math
.ceil(this._terminal
.charMeasure
.height
* this._terminal
.options
.lineHeight
);
1778 var cursorTop
= this._terminal
.buffer
.y
* cellHeight
;
1779 var cursorLeft
= this._terminal
.buffer
.x
* this._terminal
.charMeasure
.width
;
1780 this._compositionView
.style
.left
= cursorLeft
+ 'px';
1781 this._compositionView
.style
.top
= cursorTop
+ 'px';
1782 this._compositionView
.style
.height
= cellHeight
+ 'px';
1783 this._compositionView
.style
.lineHeight
= cellHeight
+ 'px';
1784 this._compositionView
.style
.fontFamily
= this._terminal
.options
.fontFamily
;
1785 this._compositionView
.style
.fontSize
= this._terminal
.options
.fontSize
+ 'px';
1786 var compositionViewBounds
= this._compositionView
.getBoundingClientRect();
1787 this._textarea
.style
.left
= cursorLeft
+ 'px';
1788 this._textarea
.style
.top
= cursorTop
+ 'px';
1789 this._textarea
.style
.width
= compositionViewBounds
.width
+ 'px';
1790 this._textarea
.style
.height
= compositionViewBounds
.height
+ 'px';
1791 this._textarea
.style
.lineHeight
= compositionViewBounds
.height
+ 'px';
1794 setTimeout(function () { return _this
.updateCompositionElements(true); }, 0);
1797 CompositionHelper
.prototype._clearTextareaPosition = function () {
1798 this._textarea
.style
.left
= '';
1799 this._textarea
.style
.top
= '';
1801 return CompositionHelper
;
1803 exports
.CompositionHelper
= CompositionHelper
;
1805 },{}],10:[function(require
,module
,exports
){
1807 var __extends
= (this && this.__extends
) || (function () {
1808 var extendStatics = function (d
, b
) {
1809 extendStatics
= Object
.setPrototypeOf
||
1810 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
1811 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
1812 return extendStatics(d
, b
);
1814 return function (d
, b
) {
1815 extendStatics(d
, b
);
1816 function __() { this.constructor = d
; }
1817 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
1820 Object
.defineProperty(exports
, "__esModule", { value
: true });
1821 var Lifecycle_1
= require("./common/Lifecycle");
1822 var TextDecoder_1
= require("./core/input/TextDecoder");
1823 function r(low
, high
) {
1825 var arr
= new Array(c
);
1831 var TransitionTable
= (function () {
1832 function TransitionTable(length
) {
1833 this.table
= (typeof Uint8Array
=== 'undefined')
1835 : new Uint8Array(length
);
1837 TransitionTable
.prototype.add = function (code
, state
, action
, next
) {
1838 this.table
[state
<< 8 | code
] = ((action
| 0) << 4) | ((next
=== undefined) ? state
: next
);
1840 TransitionTable
.prototype.addMany = function (codes
, state
, action
, next
) {
1841 for (var i
= 0; i
< codes
.length
; i
++) {
1842 this.add(codes
[i
], state
, action
, next
);
1845 return TransitionTable
;
1847 exports
.TransitionTable
= TransitionTable
;
1848 var PRINTABLES
= r(0x20, 0x7f);
1849 var EXECUTABLES
= r(0x00, 0x18);
1850 EXECUTABLES
.push(0x19);
1851 EXECUTABLES
.push
.apply(EXECUTABLES
, r(0x1c, 0x20));
1852 var NON_ASCII_PRINTABLE
= 0xA0;
1853 exports
.VT500_TRANSITION_TABLE
= (function () {
1854 var table
= new TransitionTable(4095);
1855 var states
= r(0, 13 + 1);
1857 for (state
in states
) {
1858 for (var code
= 0; code
<= NON_ASCII_PRINTABLE
; ++code
) {
1859 table
.add(code
, state
, 1, 0);
1862 table
.addMany(PRINTABLES
, 0, 2, 0);
1863 for (state
in states
) {
1864 table
.addMany([0x18, 0x1a, 0x99, 0x9a], state
, 3, 0);
1865 table
.addMany(r(0x80, 0x90), state
, 3, 0);
1866 table
.addMany(r(0x90, 0x98), state
, 3, 0);
1867 table
.add(0x9c, state
, 0, 0);
1868 table
.add(0x1b, state
, 11, 1);
1869 table
.add(0x9d, state
, 4, 8);
1870 table
.addMany([0x98, 0x9e, 0x9f], state
, 0, 7);
1871 table
.add(0x9b, state
, 11, 3);
1872 table
.add(0x90, state
, 11, 9);
1874 table
.addMany(EXECUTABLES
, 0, 3, 0);
1875 table
.addMany(EXECUTABLES
, 1, 3, 1);
1876 table
.add(0x7f, 1, 0, 1);
1877 table
.addMany(EXECUTABLES
, 8, 0, 8);
1878 table
.addMany(EXECUTABLES
, 3, 3, 3);
1879 table
.add(0x7f, 3, 0, 3);
1880 table
.addMany(EXECUTABLES
, 4, 3, 4);
1881 table
.add(0x7f, 4, 0, 4);
1882 table
.addMany(EXECUTABLES
, 6, 3, 6);
1883 table
.addMany(EXECUTABLES
, 5, 3, 5);
1884 table
.add(0x7f, 5, 0, 5);
1885 table
.addMany(EXECUTABLES
, 2, 3, 2);
1886 table
.add(0x7f, 2, 0, 2);
1887 table
.add(0x5d, 1, 4, 8);
1888 table
.addMany(PRINTABLES
, 8, 5, 8);
1889 table
.add(0x7f, 8, 5, 8);
1890 table
.addMany([0x9c, 0x1b, 0x18, 0x1a, 0x07], 8, 6, 0);
1891 table
.addMany(r(0x1c, 0x20), 8, 0, 8);
1892 table
.addMany([0x58, 0x5e, 0x5f], 1, 0, 7);
1893 table
.addMany(PRINTABLES
, 7, 0, 7);
1894 table
.addMany(EXECUTABLES
, 7, 0, 7);
1895 table
.add(0x9c, 7, 0, 0);
1896 table
.add(0x7f, 7, 0, 7);
1897 table
.add(0x5b, 1, 11, 3);
1898 table
.addMany(r(0x40, 0x7f), 3, 7, 0);
1899 table
.addMany(r(0x30, 0x3a), 3, 8, 4);
1900 table
.add(0x3b, 3, 8, 4);
1901 table
.addMany([0x3c, 0x3d, 0x3e, 0x3f], 3, 9, 4);
1902 table
.addMany(r(0x30, 0x3a), 4, 8, 4);
1903 table
.add(0x3b, 4, 8, 4);
1904 table
.addMany(r(0x40, 0x7f), 4, 7, 0);
1905 table
.addMany([0x3a, 0x3c, 0x3d, 0x3e, 0x3f], 4, 0, 6);
1906 table
.addMany(r(0x20, 0x40), 6, 0, 6);
1907 table
.add(0x7f, 6, 0, 6);
1908 table
.addMany(r(0x40, 0x7f), 6, 0, 0);
1909 table
.add(0x3a, 3, 0, 6);
1910 table
.addMany(r(0x20, 0x30), 3, 9, 5);
1911 table
.addMany(r(0x20, 0x30), 5, 9, 5);
1912 table
.addMany(r(0x30, 0x40), 5, 0, 6);
1913 table
.addMany(r(0x40, 0x7f), 5, 7, 0);
1914 table
.addMany(r(0x20, 0x30), 4, 9, 5);
1915 table
.addMany(r(0x20, 0x30), 1, 9, 2);
1916 table
.addMany(r(0x20, 0x30), 2, 9, 2);
1917 table
.addMany(r(0x30, 0x7f), 2, 10, 0);
1918 table
.addMany(r(0x30, 0x50), 1, 10, 0);
1919 table
.addMany(r(0x51, 0x58), 1, 10, 0);
1920 table
.addMany([0x59, 0x5a, 0x5c], 1, 10, 0);
1921 table
.addMany(r(0x60, 0x7f), 1, 10, 0);
1922 table
.add(0x50, 1, 11, 9);
1923 table
.addMany(EXECUTABLES
, 9, 0, 9);
1924 table
.add(0x7f, 9, 0, 9);
1925 table
.addMany(r(0x1c, 0x20), 9, 0, 9);
1926 table
.addMany(r(0x20, 0x30), 9, 9, 12);
1927 table
.add(0x3a, 9, 0, 11);
1928 table
.addMany(r(0x30, 0x3a), 9, 8, 10);
1929 table
.add(0x3b, 9, 8, 10);
1930 table
.addMany([0x3c, 0x3d, 0x3e, 0x3f], 9, 9, 10);
1931 table
.addMany(EXECUTABLES
, 11, 0, 11);
1932 table
.addMany(r(0x20, 0x80), 11, 0, 11);
1933 table
.addMany(r(0x1c, 0x20), 11, 0, 11);
1934 table
.addMany(EXECUTABLES
, 10, 0, 10);
1935 table
.add(0x7f, 10, 0, 10);
1936 table
.addMany(r(0x1c, 0x20), 10, 0, 10);
1937 table
.addMany(r(0x30, 0x3a), 10, 8, 10);
1938 table
.add(0x3b, 10, 8, 10);
1939 table
.addMany([0x3a, 0x3c, 0x3d, 0x3e, 0x3f], 10, 0, 11);
1940 table
.addMany(r(0x20, 0x30), 10, 9, 12);
1941 table
.addMany(EXECUTABLES
, 12, 0, 12);
1942 table
.add(0x7f, 12, 0, 12);
1943 table
.addMany(r(0x1c, 0x20), 12, 0, 12);
1944 table
.addMany(r(0x20, 0x30), 12, 9, 12);
1945 table
.addMany(r(0x30, 0x40), 12, 0, 11);
1946 table
.addMany(r(0x40, 0x7f), 12, 12, 13);
1947 table
.addMany(r(0x40, 0x7f), 10, 12, 13);
1948 table
.addMany(r(0x40, 0x7f), 9, 12, 13);
1949 table
.addMany(EXECUTABLES
, 13, 13, 13);
1950 table
.addMany(PRINTABLES
, 13, 13, 13);
1951 table
.add(0x7f, 13, 0, 13);
1952 table
.addMany([0x1b, 0x9c], 13, 14, 0);
1953 table
.add(NON_ASCII_PRINTABLE
, 8, 5, 8);
1956 var DcsDummy
= (function () {
1957 function DcsDummy() {
1959 DcsDummy
.prototype.hook = function (collect
, params
, flag
) { };
1960 DcsDummy
.prototype.put = function (data
, start
, end
) { };
1961 DcsDummy
.prototype.unhook = function () { };
1964 var EscapeSequenceParser
= (function (_super
) {
1965 __extends(EscapeSequenceParser
, _super
);
1966 function EscapeSequenceParser(TRANSITIONS
) {
1967 if (TRANSITIONS
=== void 0) { TRANSITIONS
= exports
.VT500_TRANSITION_TABLE
; }
1968 var _this
= _super
.call(this) || this;
1969 _this
.TRANSITIONS
= TRANSITIONS
;
1970 _this
.initialState
= 0;
1971 _this
.currentState
= _this
.initialState
;
1973 _this
._params
= [0];
1974 _this
._collect
= '';
1975 _this
._printHandlerFb = function (data
, start
, end
) { };
1976 _this
._executeHandlerFb = function (code
) { };
1977 _this
._csiHandlerFb = function (collect
, params
, flag
) { };
1978 _this
._escHandlerFb = function (collect
, flag
) { };
1979 _this
._oscHandlerFb = function (identifier
, data
) { };
1980 _this
._dcsHandlerFb
= new DcsDummy();
1981 _this
._errorHandlerFb = function (state
) { return state
; };
1982 _this
._printHandler
= _this
._printHandlerFb
;
1983 _this
._executeHandlers
= Object
.create(null);
1984 _this
._csiHandlers
= Object
.create(null);
1985 _this
._escHandlers
= Object
.create(null);
1986 _this
._oscHandlers
= Object
.create(null);
1987 _this
._dcsHandlers
= Object
.create(null);
1988 _this
._activeDcsHandler
= null;
1989 _this
._errorHandler
= _this
._errorHandlerFb
;
1990 _this
.setEscHandler('\\', function () { });
1993 EscapeSequenceParser
.prototype.dispose = function () {
1994 this._printHandlerFb
= null;
1995 this._executeHandlerFb
= null;
1996 this._csiHandlerFb
= null;
1997 this._escHandlerFb
= null;
1998 this._oscHandlerFb
= null;
1999 this._dcsHandlerFb
= null;
2000 this._errorHandlerFb
= null;
2001 this._printHandler
= null;
2002 this._executeHandlers
= null;
2003 this._escHandlers
= null;
2004 this._csiHandlers
= null;
2005 this._oscHandlers
= null;
2006 this._dcsHandlers
= null;
2007 this._activeDcsHandler
= null;
2008 this._errorHandler
= null;
2010 EscapeSequenceParser
.prototype.setPrintHandler = function (callback
) {
2011 this._printHandler
= callback
;
2013 EscapeSequenceParser
.prototype.clearPrintHandler = function () {
2014 this._printHandler
= this._printHandlerFb
;
2016 EscapeSequenceParser
.prototype.setExecuteHandler = function (flag
, callback
) {
2017 this._executeHandlers
[flag
.charCodeAt(0)] = callback
;
2019 EscapeSequenceParser
.prototype.clearExecuteHandler = function (flag
) {
2020 if (this._executeHandlers
[flag
.charCodeAt(0)])
2021 delete this._executeHandlers
[flag
.charCodeAt(0)];
2023 EscapeSequenceParser
.prototype.setExecuteHandlerFallback = function (callback
) {
2024 this._executeHandlerFb
= callback
;
2026 EscapeSequenceParser
.prototype.addCsiHandler = function (flag
, callback
) {
2027 var index
= flag
.charCodeAt(0);
2028 if (this._csiHandlers
[index
] === undefined) {
2029 this._csiHandlers
[index
] = [];
2031 var handlerList
= this._csiHandlers
[index
];
2032 handlerList
.push(callback
);
2034 dispose: function () {
2035 var handlerIndex
= handlerList
.indexOf(callback
);
2036 if (handlerIndex
!== -1) {
2037 handlerList
.splice(handlerIndex
, 1);
2042 EscapeSequenceParser
.prototype.setCsiHandler = function (flag
, callback
) {
2043 this._csiHandlers
[flag
.charCodeAt(0)] = [callback
];
2045 EscapeSequenceParser
.prototype.clearCsiHandler = function (flag
) {
2046 if (this._csiHandlers
[flag
.charCodeAt(0)])
2047 delete this._csiHandlers
[flag
.charCodeAt(0)];
2049 EscapeSequenceParser
.prototype.setCsiHandlerFallback = function (callback
) {
2050 this._csiHandlerFb
= callback
;
2052 EscapeSequenceParser
.prototype.setEscHandler = function (collectAndFlag
, callback
) {
2053 this._escHandlers
[collectAndFlag
] = callback
;
2055 EscapeSequenceParser
.prototype.clearEscHandler = function (collectAndFlag
) {
2056 if (this._escHandlers
[collectAndFlag
])
2057 delete this._escHandlers
[collectAndFlag
];
2059 EscapeSequenceParser
.prototype.setEscHandlerFallback = function (callback
) {
2060 this._escHandlerFb
= callback
;
2062 EscapeSequenceParser
.prototype.addOscHandler = function (ident
, callback
) {
2063 if (this._oscHandlers
[ident
] === undefined) {
2064 this._oscHandlers
[ident
] = [];
2066 var handlerList
= this._oscHandlers
[ident
];
2067 handlerList
.push(callback
);
2069 dispose: function () {
2070 var handlerIndex
= handlerList
.indexOf(callback
);
2071 if (handlerIndex
!== -1) {
2072 handlerList
.splice(handlerIndex
, 1);
2077 EscapeSequenceParser
.prototype.setOscHandler = function (ident
, callback
) {
2078 this._oscHandlers
[ident
] = [callback
];
2080 EscapeSequenceParser
.prototype.clearOscHandler = function (ident
) {
2081 if (this._oscHandlers
[ident
])
2082 delete this._oscHandlers
[ident
];
2084 EscapeSequenceParser
.prototype.setOscHandlerFallback = function (callback
) {
2085 this._oscHandlerFb
= callback
;
2087 EscapeSequenceParser
.prototype.setDcsHandler = function (collectAndFlag
, handler
) {
2088 this._dcsHandlers
[collectAndFlag
] = handler
;
2090 EscapeSequenceParser
.prototype.clearDcsHandler = function (collectAndFlag
) {
2091 if (this._dcsHandlers
[collectAndFlag
])
2092 delete this._dcsHandlers
[collectAndFlag
];
2094 EscapeSequenceParser
.prototype.setDcsHandlerFallback = function (handler
) {
2095 this._dcsHandlerFb
= handler
;
2097 EscapeSequenceParser
.prototype.setErrorHandler = function (callback
) {
2098 this._errorHandler
= callback
;
2100 EscapeSequenceParser
.prototype.clearErrorHandler = function () {
2101 this._errorHandler
= this._errorHandlerFb
;
2103 EscapeSequenceParser
.prototype.reset = function () {
2104 this.currentState
= this.initialState
;
2108 this._activeDcsHandler
= null;
2110 EscapeSequenceParser
.prototype.parse = function (data
, length
) {
2114 var currentState
= this.currentState
;
2117 var osc
= this._osc
;
2118 var collect
= this._collect
;
2119 var params
= this._params
;
2120 var table
= this.TRANSITIONS
.table
;
2121 var dcsHandler
= this._activeDcsHandler
;
2122 var callback
= null;
2123 for (var i
= 0; i
< length
; ++i
) {
2125 if (currentState
=== 0 && code
> 0x1f && code
< 0x80) {
2126 print
= (~print
) ? print
: i
;
2129 while (i
< length
&& data
[i
] > 0x1f && data
[i
] < 0x80);
2133 if (currentState
=== 4 && (code
> 0x2f && code
< 0x39)) {
2134 params
[params
.length
- 1] = params
[params
.length
- 1] * 10 + code
- 48;
2137 transition
= table
[currentState
<< 8 | (code
< 0xa0 ? code
: NON_ASCII_PRINTABLE
)];
2138 switch (transition
>> 4) {
2140 print
= (~print
) ? print
: i
;
2144 this._printHandler(data
, print
, i
);
2147 callback
= this._executeHandlers
[code
];
2151 this._executeHandlerFb(code
);
2155 this._printHandler(data
, print
, i
);
2159 dcsHandler
.put(data
, dcs
, i
);
2165 switch (currentState
) {
2167 print
= (~print
) ? print
: i
;
2176 dcs
= (~dcs
) ? dcs
: i
;
2187 var inject
= this._errorHandler({
2190 currentState
: currentState
,
2204 var handlers
= this._csiHandlers
[code
];
2205 var j
= handlers
? handlers
.length
- 1 : -1;
2206 for (; j
>= 0; j
--) {
2207 if (handlers
[j
](params
, collect
) !== false) {
2212 this._csiHandlerFb(collect
, params
, code
);
2219 params
[params
.length
- 1] = params
[params
.length
- 1] * 10 + code
- 48;
2222 collect
+= String
.fromCharCode(code
);
2225 callback
= this._escHandlers
[collect
+ String
.fromCharCode(code
)];
2227 callback(collect
, code
);
2229 this._escHandlerFb(collect
, code
);
2233 this._printHandler(data
, print
, i
);
2242 dcsHandler
= this._dcsHandlers
[collect
+ String
.fromCharCode(code
)];
2244 dcsHandler
= this._dcsHandlerFb
;
2245 dcsHandler
.hook(collect
, params
, code
);
2248 dcs
= (~dcs
) ? dcs
: i
;
2253 dcsHandler
.put(data
, dcs
, i
);
2254 dcsHandler
.unhook();
2266 this._printHandler(data
, print
, i
);
2272 for (var j_1
= i
+ 1;; j_1
++) {
2274 || (code
= data
[j_1
]) < 0x20
2275 || (code
> 0x7f && code
<= 0x9f)) {
2276 osc
+= TextDecoder_1
.utf32ToString(data
, i
, j_1
);
2283 if (osc
&& code
!== 0x18 && code
!== 0x1a) {
2284 var idx
= osc
.indexOf(';');
2286 this._oscHandlerFb(-1, osc
);
2289 var identifier
= parseInt(osc
.substring(0, idx
));
2290 var content
= osc
.substring(idx
+ 1);
2291 var handlers_1
= this._oscHandlers
[identifier
];
2292 var j_2
= handlers_1
? handlers_1
.length
- 1 : -1;
2293 for (; j_2
>= 0; j_2
--) {
2294 if (handlers_1
[j_2
](content
) !== false) {
2299 this._oscHandlerFb(identifier
, content
);
2311 currentState
= transition
& 15;
2313 if (currentState
=== 0 && ~print
) {
2314 this._printHandler(data
, print
, length
);
2316 else if (currentState
=== 13 && ~dcs
&& dcsHandler
) {
2317 dcsHandler
.put(data
, dcs
, length
);
2320 this._collect
= collect
;
2321 this._params
= params
;
2322 this._activeDcsHandler
= dcsHandler
;
2323 this.currentState
= currentState
;
2325 return EscapeSequenceParser
;
2326 }(Lifecycle_1
.Disposable
));
2327 exports
.EscapeSequenceParser
= EscapeSequenceParser
;
2329 },{"./common/Lifecycle":26,"./core/input/TextDecoder":32}],11:[function(require
,module
,exports
){
2331 var __extends
= (this && this.__extends
) || (function () {
2332 var extendStatics = function (d
, b
) {
2333 extendStatics
= Object
.setPrototypeOf
||
2334 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
2335 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
2336 return extendStatics(d
, b
);
2338 return function (d
, b
) {
2339 extendStatics(d
, b
);
2340 function __() { this.constructor = d
; }
2341 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
2344 Object
.defineProperty(exports
, "__esModule", { value
: true });
2345 var EscapeSequences_1
= require("./common/data/EscapeSequences");
2346 var Charsets_1
= require("./core/data/Charsets");
2347 var Buffer_1
= require("./Buffer");
2348 var CharWidth_1
= require("./CharWidth");
2349 var EscapeSequenceParser_1
= require("./EscapeSequenceParser");
2350 var Lifecycle_1
= require("./common/Lifecycle");
2351 var TypedArrayUtils_1
= require("./common/TypedArrayUtils");
2352 var TextDecoder_1
= require("./core/input/TextDecoder");
2353 var BufferLine_1
= require("./BufferLine");
2354 var EventEmitter2_1
= require("./common/EventEmitter2");
2355 var GLEVEL
= { '(': 0, ')': 1, '*': 2, '+': 3, '-': 1, '.': 2 };
2356 var DECRQSS
= (function () {
2357 function DECRQSS(_terminal
) {
2358 this._terminal
= _terminal
;
2359 this._data
= new Uint32Array(0);
2361 DECRQSS
.prototype.hook = function (collect
, params
, flag
) {
2362 this._data
= new Uint32Array(0);
2364 DECRQSS
.prototype.put = function (data
, start
, end
) {
2365 this._data
= TypedArrayUtils_1
.concat(this._data
, data
.subarray(start
, end
));
2367 DECRQSS
.prototype.unhook = function () {
2368 var data
= TextDecoder_1
.utf32ToString(this._data
);
2369 this._data
= new Uint32Array(0);
2372 return this._terminal
.handler(EscapeSequences_1
.C0
.ESC
+ "P1$r0\"q" + EscapeSequences_1
.C0
.ESC
+ "\\");
2374 return this._terminal
.handler(EscapeSequences_1
.C0
.ESC
+ "P1$r61\"p" + EscapeSequences_1
.C0
.ESC
+ "\\");
2376 var pt
= '' + (this._terminal
.buffer
.scrollTop
+ 1) +
2377 ';' + (this._terminal
.buffer
.scrollBottom
+ 1) + 'r';
2378 return this._terminal
.handler(EscapeSequences_1
.C0
.ESC
+ "P1$r" + pt
+ EscapeSequences_1
.C0
.ESC
+ "\\");
2380 return this._terminal
.handler(EscapeSequences_1
.C0
.ESC
+ "P1$r0m" + EscapeSequences_1
.C0
.ESC
+ "\\");
2382 var STYLES
= { 'block': 2, 'underline': 4, 'bar': 6 };
2383 var style
= STYLES
[this._terminal
.getOption('cursorStyle')];
2384 style
-= this._terminal
.getOption('cursorBlink');
2385 return this._terminal
.handler(EscapeSequences_1
.C0
.ESC
+ "P1$r" + style
+ " q" + EscapeSequences_1
.C0
.ESC
+ "\\");
2387 this._terminal
.error('Unknown DCS $q %s', data
);
2388 this._terminal
.handler(EscapeSequences_1
.C0
.ESC
+ "P0$r" + EscapeSequences_1
.C0
.ESC
+ "\\");
2393 var InputHandler
= (function (_super
) {
2394 __extends(InputHandler
, _super
);
2395 function InputHandler(_terminal
, _parser
) {
2396 if (_parser
=== void 0) { _parser
= new EscapeSequenceParser_1
.EscapeSequenceParser(); }
2397 var _this
= _super
.call(this) || this;
2398 _this
._terminal
= _terminal
;
2399 _this
._parser
= _parser
;
2400 _this
._parseBuffer
= new Uint32Array(4096);
2401 _this
._stringDecoder
= new TextDecoder_1
.StringToUtf32();
2402 _this
._workCell
= new BufferLine_1
.CellData();
2403 _this
._onCursorMove
= new EventEmitter2_1
.EventEmitter2();
2404 _this
._onData
= new EventEmitter2_1
.EventEmitter2();
2405 _this
._onLineFeed
= new EventEmitter2_1
.EventEmitter2();
2406 _this
._onScroll
= new EventEmitter2_1
.EventEmitter2();
2407 _this
.register(_this
._parser
);
2408 _this
._parser
.setCsiHandlerFallback(function (collect
, params
, flag
) {
2409 _this
._terminal
.error('Unknown CSI code: ', { collect
: collect
, params
: params
, flag
: String
.fromCharCode(flag
) });
2411 _this
._parser
.setEscHandlerFallback(function (collect
, flag
) {
2412 _this
._terminal
.error('Unknown ESC code: ', { collect
: collect
, flag
: String
.fromCharCode(flag
) });
2414 _this
._parser
.setExecuteHandlerFallback(function (code
) {
2415 _this
._terminal
.error('Unknown EXECUTE code: ', { code
: code
});
2417 _this
._parser
.setOscHandlerFallback(function (identifier
, data
) {
2418 _this
._terminal
.error('Unknown OSC code: ', { identifier
: identifier
, data
: data
});
2420 _this
._parser
.setPrintHandler(function (data
, start
, end
) { return _this
.print(data
, start
, end
); });
2421 _this
._parser
.setCsiHandler('@', function (params
, collect
) { return _this
.insertChars(params
); });
2422 _this
._parser
.setCsiHandler('A', function (params
, collect
) { return _this
.cursorUp(params
); });
2423 _this
._parser
.setCsiHandler('B', function (params
, collect
) { return _this
.cursorDown(params
); });
2424 _this
._parser
.setCsiHandler('C', function (params
, collect
) { return _this
.cursorForward(params
); });
2425 _this
._parser
.setCsiHandler('D', function (params
, collect
) { return _this
.cursorBackward(params
); });
2426 _this
._parser
.setCsiHandler('E', function (params
, collect
) { return _this
.cursorNextLine(params
); });
2427 _this
._parser
.setCsiHandler('F', function (params
, collect
) { return _this
.cursorPrecedingLine(params
); });
2428 _this
._parser
.setCsiHandler('G', function (params
, collect
) { return _this
.cursorCharAbsolute(params
); });
2429 _this
._parser
.setCsiHandler('H', function (params
, collect
) { return _this
.cursorPosition(params
); });
2430 _this
._parser
.setCsiHandler('I', function (params
, collect
) { return _this
.cursorForwardTab(params
); });
2431 _this
._parser
.setCsiHandler('J', function (params
, collect
) { return _this
.eraseInDisplay(params
); });
2432 _this
._parser
.setCsiHandler('K', function (params
, collect
) { return _this
.eraseInLine(params
); });
2433 _this
._parser
.setCsiHandler('L', function (params
, collect
) { return _this
.insertLines(params
); });
2434 _this
._parser
.setCsiHandler('M', function (params
, collect
) { return _this
.deleteLines(params
); });
2435 _this
._parser
.setCsiHandler('P', function (params
, collect
) { return _this
.deleteChars(params
); });
2436 _this
._parser
.setCsiHandler('S', function (params
, collect
) { return _this
.scrollUp(params
); });
2437 _this
._parser
.setCsiHandler('T', function (params
, collect
) { return _this
.scrollDown(params
, collect
); });
2438 _this
._parser
.setCsiHandler('X', function (params
, collect
) { return _this
.eraseChars(params
); });
2439 _this
._parser
.setCsiHandler('Z', function (params
, collect
) { return _this
.cursorBackwardTab(params
); });
2440 _this
._parser
.setCsiHandler('`', function (params
, collect
) { return _this
.charPosAbsolute(params
); });
2441 _this
._parser
.setCsiHandler('a', function (params
, collect
) { return _this
.hPositionRelative(params
); });
2442 _this
._parser
.setCsiHandler('b', function (params
, collect
) { return _this
.repeatPrecedingCharacter(params
); });
2443 _this
._parser
.setCsiHandler('c', function (params
, collect
) { return _this
.sendDeviceAttributes(params
, collect
); });
2444 _this
._parser
.setCsiHandler('d', function (params
, collect
) { return _this
.linePosAbsolute(params
); });
2445 _this
._parser
.setCsiHandler('e', function (params
, collect
) { return _this
.vPositionRelative(params
); });
2446 _this
._parser
.setCsiHandler('f', function (params
, collect
) { return _this
.hVPosition(params
); });
2447 _this
._parser
.setCsiHandler('g', function (params
, collect
) { return _this
.tabClear(params
); });
2448 _this
._parser
.setCsiHandler('h', function (params
, collect
) { return _this
.setMode(params
, collect
); });
2449 _this
._parser
.setCsiHandler('l', function (params
, collect
) { return _this
.resetMode(params
, collect
); });
2450 _this
._parser
.setCsiHandler('m', function (params
, collect
) { return _this
.charAttributes(params
); });
2451 _this
._parser
.setCsiHandler('n', function (params
, collect
) { return _this
.deviceStatus(params
, collect
); });
2452 _this
._parser
.setCsiHandler('p', function (params
, collect
) { return _this
.softReset(params
, collect
); });
2453 _this
._parser
.setCsiHandler('q', function (params
, collect
) { return _this
.setCursorStyle(params
, collect
); });
2454 _this
._parser
.setCsiHandler('r', function (params
, collect
) { return _this
.setScrollRegion(params
, collect
); });
2455 _this
._parser
.setCsiHandler('s', function (params
, collect
) { return _this
.saveCursor(params
); });
2456 _this
._parser
.setCsiHandler('u', function (params
, collect
) { return _this
.restoreCursor(params
); });
2457 _this
._parser
.setExecuteHandler(EscapeSequences_1
.C0
.BEL
, function () { return _this
.bell(); });
2458 _this
._parser
.setExecuteHandler(EscapeSequences_1
.C0
.LF
, function () { return _this
.lineFeed(); });
2459 _this
._parser
.setExecuteHandler(EscapeSequences_1
.C0
.VT
, function () { return _this
.lineFeed(); });
2460 _this
._parser
.setExecuteHandler(EscapeSequences_1
.C0
.FF
, function () { return _this
.lineFeed(); });
2461 _this
._parser
.setExecuteHandler(EscapeSequences_1
.C0
.CR
, function () { return _this
.carriageReturn(); });
2462 _this
._parser
.setExecuteHandler(EscapeSequences_1
.C0
.BS
, function () { return _this
.backspace(); });
2463 _this
._parser
.setExecuteHandler(EscapeSequences_1
.C0
.HT
, function () { return _this
.tab(); });
2464 _this
._parser
.setExecuteHandler(EscapeSequences_1
.C0
.SO
, function () { return _this
.shiftOut(); });
2465 _this
._parser
.setExecuteHandler(EscapeSequences_1
.C0
.SI
, function () { return _this
.shiftIn(); });
2466 _this
._parser
.setExecuteHandler(EscapeSequences_1
.C1
.IND
, function () { return _this
.index(); });
2467 _this
._parser
.setExecuteHandler(EscapeSequences_1
.C1
.NEL
, function () { return _this
.nextLine(); });
2468 _this
._parser
.setExecuteHandler(EscapeSequences_1
.C1
.HTS
, function () { return _this
.tabSet(); });
2469 _this
._parser
.setOscHandler(0, function (data
) { return _this
.setTitle(data
); });
2470 _this
._parser
.setOscHandler(2, function (data
) { return _this
.setTitle(data
); });
2471 _this
._parser
.setEscHandler('7', function () { return _this
.saveCursor([]); });
2472 _this
._parser
.setEscHandler('8', function () { return _this
.restoreCursor([]); });
2473 _this
._parser
.setEscHandler('D', function () { return _this
.index(); });
2474 _this
._parser
.setEscHandler('E', function () { return _this
.nextLine(); });
2475 _this
._parser
.setEscHandler('H', function () { return _this
.tabSet(); });
2476 _this
._parser
.setEscHandler('M', function () { return _this
.reverseIndex(); });
2477 _this
._parser
.setEscHandler('=', function () { return _this
.keypadApplicationMode(); });
2478 _this
._parser
.setEscHandler('>', function () { return _this
.keypadNumericMode(); });
2479 _this
._parser
.setEscHandler('c', function () { return _this
.reset(); });
2480 _this
._parser
.setEscHandler('n', function () { return _this
.setgLevel(2); });
2481 _this
._parser
.setEscHandler('o', function () { return _this
.setgLevel(3); });
2482 _this
._parser
.setEscHandler('|', function () { return _this
.setgLevel(3); });
2483 _this
._parser
.setEscHandler('}', function () { return _this
.setgLevel(2); });
2484 _this
._parser
.setEscHandler('~', function () { return _this
.setgLevel(1); });
2485 _this
._parser
.setEscHandler('%@', function () { return _this
.selectDefaultCharset(); });
2486 _this
._parser
.setEscHandler('%G', function () { return _this
.selectDefaultCharset(); });
2487 var _loop_1 = function (flag
) {
2488 this_1
._parser
.setEscHandler('(' + flag
, function () { return _this
.selectCharset('(' + flag
); });
2489 this_1
._parser
.setEscHandler(')' + flag
, function () { return _this
.selectCharset(')' + flag
); });
2490 this_1
._parser
.setEscHandler('*' + flag
, function () { return _this
.selectCharset('*' + flag
); });
2491 this_1
._parser
.setEscHandler('+' + flag
, function () { return _this
.selectCharset('+' + flag
); });
2492 this_1
._parser
.setEscHandler('-' + flag
, function () { return _this
.selectCharset('-' + flag
); });
2493 this_1
._parser
.setEscHandler('.' + flag
, function () { return _this
.selectCharset('.' + flag
); });
2494 this_1
._parser
.setEscHandler('/' + flag
, function () { return _this
.selectCharset('/' + flag
); });
2497 for (var flag
in Charsets_1
.CHARSETS
) {
2500 _this
._parser
.setErrorHandler(function (state
) {
2501 _this
._terminal
.error('Parsing error: ', state
);
2504 _this
._parser
.setDcsHandler('$q', new DECRQSS(_this
._terminal
));
2507 Object
.defineProperty(InputHandler
.prototype, "onCursorMove", {
2508 get: function () { return this._onCursorMove
.event
; },
2512 Object
.defineProperty(InputHandler
.prototype, "onData", {
2513 get: function () { return this._onData
.event
; },
2517 Object
.defineProperty(InputHandler
.prototype, "onLineFeed", {
2518 get: function () { return this._onLineFeed
.event
; },
2522 Object
.defineProperty(InputHandler
.prototype, "onScroll", {
2523 get: function () { return this._onScroll
.event
; },
2527 InputHandler
.prototype.dispose = function () {
2528 _super
.prototype.dispose
.call(this);
2529 this._terminal
= null;
2531 InputHandler
.prototype.parse = function (data
) {
2532 if (!this._terminal
) {
2535 var buffer
= this._terminal
.buffer
;
2536 var cursorStartX
= buffer
.x
;
2537 var cursorStartY
= buffer
.y
;
2538 if (this._terminal
.debug
) {
2539 this._terminal
.log('data: ' + data
);
2541 if (this._parseBuffer
.length
< data
.length
) {
2542 this._parseBuffer
= new Uint32Array(data
.length
);
2544 this._parser
.parse(this._parseBuffer
, this._stringDecoder
.decode(data
, this._parseBuffer
));
2545 buffer
= this._terminal
.buffer
;
2546 if (buffer
.x
!== cursorStartX
|| buffer
.y
!== cursorStartY
) {
2547 this._onCursorMove
.fire();
2550 InputHandler
.prototype.print = function (data
, start
, end
) {
2553 var buffer
= this._terminal
.buffer
;
2554 var charset
= this._terminal
.charset
;
2555 var screenReaderMode
= this._terminal
.options
.screenReaderMode
;
2556 var cols
= this._terminal
.cols
;
2557 var wraparoundMode
= this._terminal
.wraparoundMode
;
2558 var insertMode
= this._terminal
.insertMode
;
2559 var curAttr
= this._terminal
.curAttrData
;
2560 var bufferRow
= buffer
.lines
.get(buffer
.y
+ buffer
.ybase
);
2561 this._terminal
.updateRange(buffer
.y
);
2562 for (var pos
= start
; pos
< end
; ++pos
) {
2564 chWidth
= CharWidth_1
.wcwidth(code
);
2565 if (code
< 127 && charset
) {
2566 var ch
= charset
[String
.fromCharCode(code
)];
2568 code
= ch
.charCodeAt(0);
2571 if (screenReaderMode
) {
2572 this._terminal
.emit('a11y.char', TextDecoder_1
.stringFromCodePoint(code
));
2574 if (!chWidth
&& buffer
.x
) {
2575 if (!bufferRow
.getWidth(buffer
.x
- 1)) {
2576 bufferRow
.addCodepointToCell(buffer
.x
- 2, code
);
2579 bufferRow
.addCodepointToCell(buffer
.x
- 1, code
);
2583 if (buffer
.x
+ chWidth
- 1 >= cols
) {
2584 if (wraparoundMode
) {
2587 if (buffer
.y
> buffer
.scrollBottom
) {
2589 this._terminal
.scroll(true);
2592 buffer
.lines
.get(buffer
.y
).isWrapped
= true;
2594 bufferRow
= buffer
.lines
.get(buffer
.y
+ buffer
.ybase
);
2597 if (chWidth
=== 2) {
2603 bufferRow
.insertCells(buffer
.x
, chWidth
, buffer
.getNullCell(curAttr
));
2604 if (bufferRow
.getWidth(cols
- 1) === 2) {
2605 bufferRow
.setCellFromCodePoint(cols
- 1, Buffer_1
.NULL_CELL_CODE
, Buffer_1
.NULL_CELL_WIDTH
, curAttr
.fg
, curAttr
.bg
);
2608 bufferRow
.setCellFromCodePoint(buffer
.x
++, code
, chWidth
, curAttr
.fg
, curAttr
.bg
);
2611 bufferRow
.setCellFromCodePoint(buffer
.x
++, 0, 0, curAttr
.fg
, curAttr
.bg
);
2615 this._terminal
.updateRange(buffer
.y
);
2617 InputHandler
.prototype.addCsiHandler = function (flag
, callback
) {
2618 return this._parser
.addCsiHandler(flag
, callback
);
2620 InputHandler
.prototype.addOscHandler = function (ident
, callback
) {
2621 return this._parser
.addOscHandler(ident
, callback
);
2623 InputHandler
.prototype.bell = function () {
2624 this._terminal
.bell();
2626 InputHandler
.prototype.lineFeed = function () {
2627 var buffer
= this._terminal
.buffer
;
2628 if (this._terminal
.options
.convertEol
) {
2632 if (buffer
.y
> buffer
.scrollBottom
) {
2634 this._terminal
.scroll();
2636 if (buffer
.x
>= this._terminal
.cols
) {
2639 this._onLineFeed
.fire();
2641 InputHandler
.prototype.carriageReturn = function () {
2642 this._terminal
.buffer
.x
= 0;
2644 InputHandler
.prototype.backspace = function () {
2645 if (this._terminal
.buffer
.x
> 0) {
2646 this._terminal
.buffer
.x
--;
2649 InputHandler
.prototype.tab = function () {
2650 var originalX
= this._terminal
.buffer
.x
;
2651 this._terminal
.buffer
.x
= this._terminal
.buffer
.nextStop();
2652 if (this._terminal
.options
.screenReaderMode
) {
2653 this._terminal
.emit('a11y.tab', this._terminal
.buffer
.x
- originalX
);
2656 InputHandler
.prototype.shiftOut = function () {
2657 this._terminal
.setgLevel(1);
2659 InputHandler
.prototype.shiftIn = function () {
2660 this._terminal
.setgLevel(0);
2662 InputHandler
.prototype.insertChars = function (params
) {
2663 this._terminal
.buffer
.lines
.get(this._terminal
.buffer
.y
+ this._terminal
.buffer
.ybase
).insertCells(this._terminal
.buffer
.x
, params
[0] || 1, this._terminal
.buffer
.getNullCell(this._terminal
.eraseAttrData()));
2664 this._terminal
.updateRange(this._terminal
.buffer
.y
);
2666 InputHandler
.prototype.cursorUp = function (params
) {
2667 var param
= params
[0];
2671 this._terminal
.buffer
.y
-= param
;
2672 if (this._terminal
.buffer
.y
< 0) {
2673 this._terminal
.buffer
.y
= 0;
2676 InputHandler
.prototype.cursorDown = function (params
) {
2677 var param
= params
[0];
2681 this._terminal
.buffer
.y
+= param
;
2682 if (this._terminal
.buffer
.y
>= this._terminal
.rows
) {
2683 this._terminal
.buffer
.y
= this._terminal
.rows
- 1;
2685 if (this._terminal
.buffer
.x
>= this._terminal
.cols
) {
2686 this._terminal
.buffer
.x
--;
2689 InputHandler
.prototype.cursorForward = function (params
) {
2690 var param
= params
[0];
2694 this._terminal
.buffer
.x
+= param
;
2695 if (this._terminal
.buffer
.x
>= this._terminal
.cols
) {
2696 this._terminal
.buffer
.x
= this._terminal
.cols
- 1;
2699 InputHandler
.prototype.cursorBackward = function (params
) {
2700 var param
= params
[0];
2704 if (this._terminal
.buffer
.x
>= this._terminal
.cols
) {
2705 this._terminal
.buffer
.x
--;
2707 this._terminal
.buffer
.x
-= param
;
2708 if (this._terminal
.buffer
.x
< 0) {
2709 this._terminal
.buffer
.x
= 0;
2712 InputHandler
.prototype.cursorNextLine = function (params
) {
2713 var param
= params
[0];
2717 this._terminal
.buffer
.y
+= param
;
2718 if (this._terminal
.buffer
.y
>= this._terminal
.rows
) {
2719 this._terminal
.buffer
.y
= this._terminal
.rows
- 1;
2721 this._terminal
.buffer
.x
= 0;
2723 InputHandler
.prototype.cursorPrecedingLine = function (params
) {
2724 var param
= params
[0];
2728 this._terminal
.buffer
.y
-= param
;
2729 if (this._terminal
.buffer
.y
< 0) {
2730 this._terminal
.buffer
.y
= 0;
2732 this._terminal
.buffer
.x
= 0;
2734 InputHandler
.prototype.cursorCharAbsolute = function (params
) {
2735 var param
= params
[0];
2739 this._terminal
.buffer
.x
= param
- 1;
2741 InputHandler
.prototype.cursorPosition = function (params
) {
2743 var row
= params
[0] - 1;
2744 if (params
.length
>= 2) {
2745 col
= params
[1] - 1;
2753 else if (row
>= this._terminal
.rows
) {
2754 row
= this._terminal
.rows
- 1;
2759 else if (col
>= this._terminal
.cols
) {
2760 col
= this._terminal
.cols
- 1;
2762 this._terminal
.buffer
.x
= col
;
2763 this._terminal
.buffer
.y
= row
;
2765 InputHandler
.prototype.cursorForwardTab = function (params
) {
2766 var param
= params
[0] || 1;
2768 this._terminal
.buffer
.x
= this._terminal
.buffer
.nextStop();
2771 InputHandler
.prototype._eraseInBufferLine = function (y
, start
, end
, clearWrap
) {
2772 if (clearWrap
=== void 0) { clearWrap
= false; }
2773 var line
= this._terminal
.buffer
.lines
.get(this._terminal
.buffer
.ybase
+ y
);
2774 line
.replaceCells(start
, end
, this._terminal
.buffer
.getNullCell(this._terminal
.eraseAttrData()));
2776 line
.isWrapped
= false;
2779 InputHandler
.prototype._resetBufferLine = function (y
) {
2780 this._eraseInBufferLine(y
, 0, this._terminal
.cols
, true);
2782 InputHandler
.prototype.eraseInDisplay = function (params
) {
2784 switch (params
[0]) {
2786 j
= this._terminal
.buffer
.y
;
2787 this._terminal
.updateRange(j
);
2788 this._eraseInBufferLine(j
++, this._terminal
.buffer
.x
, this._terminal
.cols
, this._terminal
.buffer
.x
=== 0);
2789 for (; j
< this._terminal
.rows
; j
++) {
2790 this._resetBufferLine(j
);
2792 this._terminal
.updateRange(j
);
2795 j
= this._terminal
.buffer
.y
;
2796 this._terminal
.updateRange(j
);
2797 this._eraseInBufferLine(j
, 0, this._terminal
.buffer
.x
+ 1, true);
2798 if (this._terminal
.buffer
.x
+ 1 >= this._terminal
.cols
) {
2799 this._terminal
.buffer
.lines
.get(j
+ 1).isWrapped
= false;
2802 this._resetBufferLine(j
);
2804 this._terminal
.updateRange(0);
2807 j
= this._terminal
.rows
;
2808 this._terminal
.updateRange(j
- 1);
2810 this._resetBufferLine(j
);
2812 this._terminal
.updateRange(0);
2815 var scrollBackSize
= this._terminal
.buffer
.lines
.length
- this._terminal
.rows
;
2816 if (scrollBackSize
> 0) {
2817 this._terminal
.buffer
.lines
.trimStart(scrollBackSize
);
2818 this._terminal
.buffer
.ybase
= Math
.max(this._terminal
.buffer
.ybase
- scrollBackSize
, 0);
2819 this._terminal
.buffer
.ydisp
= Math
.max(this._terminal
.buffer
.ydisp
- scrollBackSize
, 0);
2820 this._onScroll
.fire(0);
2825 InputHandler
.prototype.eraseInLine = function (params
) {
2826 switch (params
[0]) {
2828 this._eraseInBufferLine(this._terminal
.buffer
.y
, this._terminal
.buffer
.x
, this._terminal
.cols
);
2831 this._eraseInBufferLine(this._terminal
.buffer
.y
, 0, this._terminal
.buffer
.x
+ 1);
2834 this._eraseInBufferLine(this._terminal
.buffer
.y
, 0, this._terminal
.cols
);
2837 this._terminal
.updateRange(this._terminal
.buffer
.y
);
2839 InputHandler
.prototype.insertLines = function (params
) {
2840 var param
= params
[0];
2844 var buffer
= this._terminal
.buffer
;
2845 var row
= buffer
.y
+ buffer
.ybase
;
2846 var scrollBottomRowsOffset
= this._terminal
.rows
- 1 - buffer
.scrollBottom
;
2847 var scrollBottomAbsolute
= this._terminal
.rows
- 1 + buffer
.ybase
- scrollBottomRowsOffset
+ 1;
2849 buffer
.lines
.splice(scrollBottomAbsolute
- 1, 1);
2850 buffer
.lines
.splice(row
, 0, buffer
.getBlankLine(this._terminal
.eraseAttrData()));
2852 this._terminal
.updateRange(buffer
.y
);
2853 this._terminal
.updateRange(buffer
.scrollBottom
);
2855 InputHandler
.prototype.deleteLines = function (params
) {
2856 var param
= params
[0];
2860 var buffer
= this._terminal
.buffer
;
2861 var row
= buffer
.y
+ buffer
.ybase
;
2863 j
= this._terminal
.rows
- 1 - buffer
.scrollBottom
;
2864 j
= this._terminal
.rows
- 1 + buffer
.ybase
- j
;
2866 buffer
.lines
.splice(row
, 1);
2867 buffer
.lines
.splice(j
, 0, buffer
.getBlankLine(this._terminal
.eraseAttrData()));
2869 this._terminal
.updateRange(buffer
.y
);
2870 this._terminal
.updateRange(buffer
.scrollBottom
);
2872 InputHandler
.prototype.deleteChars = function (params
) {
2873 this._terminal
.buffer
.lines
.get(this._terminal
.buffer
.y
+ this._terminal
.buffer
.ybase
).deleteCells(this._terminal
.buffer
.x
, params
[0] || 1, this._terminal
.buffer
.getNullCell(this._terminal
.eraseAttrData()));
2874 this._terminal
.updateRange(this._terminal
.buffer
.y
);
2876 InputHandler
.prototype.scrollUp = function (params
) {
2877 var param
= params
[0] || 1;
2878 var buffer
= this._terminal
.buffer
;
2880 buffer
.lines
.splice(buffer
.ybase
+ buffer
.scrollTop
, 1);
2881 buffer
.lines
.splice(buffer
.ybase
+ buffer
.scrollBottom
, 0, buffer
.getBlankLine(Buffer_1
.DEFAULT_ATTR_DATA
));
2883 this._terminal
.updateRange(buffer
.scrollTop
);
2884 this._terminal
.updateRange(buffer
.scrollBottom
);
2886 InputHandler
.prototype.scrollDown = function (params
, collect
) {
2887 if (params
.length
< 2 && !collect
) {
2888 var param
= params
[0] || 1;
2889 var buffer
= this._terminal
.buffer
;
2891 buffer
.lines
.splice(buffer
.ybase
+ buffer
.scrollBottom
, 1);
2892 buffer
.lines
.splice(buffer
.ybase
+ buffer
.scrollTop
, 0, buffer
.getBlankLine(Buffer_1
.DEFAULT_ATTR_DATA
));
2894 this._terminal
.updateRange(buffer
.scrollTop
);
2895 this._terminal
.updateRange(buffer
.scrollBottom
);
2898 InputHandler
.prototype.eraseChars = function (params
) {
2899 this._terminal
.buffer
.lines
.get(this._terminal
.buffer
.y
+ this._terminal
.buffer
.ybase
).replaceCells(this._terminal
.buffer
.x
, this._terminal
.buffer
.x
+ (params
[0] || 1), this._terminal
.buffer
.getNullCell(this._terminal
.eraseAttrData()));
2901 InputHandler
.prototype.cursorBackwardTab = function (params
) {
2902 var param
= params
[0] || 1;
2903 var buffer
= this._terminal
.buffer
;
2905 buffer
.x
= buffer
.prevStop();
2908 InputHandler
.prototype.charPosAbsolute = function (params
) {
2909 var param
= params
[0];
2913 this._terminal
.buffer
.x
= param
- 1;
2914 if (this._terminal
.buffer
.x
>= this._terminal
.cols
) {
2915 this._terminal
.buffer
.x
= this._terminal
.cols
- 1;
2918 InputHandler
.prototype.hPositionRelative = function (params
) {
2919 var param
= params
[0];
2923 this._terminal
.buffer
.x
+= param
;
2924 if (this._terminal
.buffer
.x
>= this._terminal
.cols
) {
2925 this._terminal
.buffer
.x
= this._terminal
.cols
- 1;
2928 InputHandler
.prototype.repeatPrecedingCharacter = function (params
) {
2929 var buffer
= this._terminal
.buffer
;
2930 var line
= buffer
.lines
.get(buffer
.ybase
+ buffer
.y
);
2931 line
.loadCell(buffer
.x
- 1, this._workCell
);
2932 line
.replaceCells(buffer
.x
, buffer
.x
+ (params
[0] || 1), (this._workCell
.content
!== undefined) ? this._workCell
: buffer
.getNullCell(Buffer_1
.DEFAULT_ATTR_DATA
));
2934 InputHandler
.prototype.sendDeviceAttributes = function (params
, collect
) {
2935 if (params
[0] > 0) {
2939 if (this._terminal
.is('xterm') || this._terminal
.is('rxvt-unicode') || this._terminal
.is('screen')) {
2940 this._terminal
.handler(EscapeSequences_1
.C0
.ESC
+ '[?1;2c');
2942 else if (this._terminal
.is('linux')) {
2943 this._terminal
.handler(EscapeSequences_1
.C0
.ESC
+ '[?6c');
2946 else if (collect
=== '>') {
2947 if (this._terminal
.is('xterm')) {
2948 this._terminal
.handler(EscapeSequences_1
.C0
.ESC
+ '[>0;276;0c');
2950 else if (this._terminal
.is('rxvt-unicode')) {
2951 this._terminal
.handler(EscapeSequences_1
.C0
.ESC
+ '[>85;95;0c');
2953 else if (this._terminal
.is('linux')) {
2954 this._terminal
.handler(params
[0] + 'c');
2956 else if (this._terminal
.is('screen')) {
2957 this._terminal
.handler(EscapeSequences_1
.C0
.ESC
+ '[>83;40003;0c');
2961 InputHandler
.prototype.linePosAbsolute = function (params
) {
2962 var param
= params
[0];
2966 this._terminal
.buffer
.y
= param
- 1;
2967 if (this._terminal
.buffer
.y
>= this._terminal
.rows
) {
2968 this._terminal
.buffer
.y
= this._terminal
.rows
- 1;
2971 InputHandler
.prototype.vPositionRelative = function (params
) {
2972 var param
= params
[0];
2976 this._terminal
.buffer
.y
+= param
;
2977 if (this._terminal
.buffer
.y
>= this._terminal
.rows
) {
2978 this._terminal
.buffer
.y
= this._terminal
.rows
- 1;
2980 if (this._terminal
.buffer
.x
>= this._terminal
.cols
) {
2981 this._terminal
.buffer
.x
--;
2984 InputHandler
.prototype.hVPosition = function (params
) {
2989 this._terminal
.buffer
.y
= params
[0] - 1;
2990 if (this._terminal
.buffer
.y
>= this._terminal
.rows
) {
2991 this._terminal
.buffer
.y
= this._terminal
.rows
- 1;
2993 this._terminal
.buffer
.x
= params
[1] - 1;
2994 if (this._terminal
.buffer
.x
>= this._terminal
.cols
) {
2995 this._terminal
.buffer
.x
= this._terminal
.cols
- 1;
2998 InputHandler
.prototype.tabClear = function (params
) {
2999 var param
= params
[0];
3001 delete this._terminal
.buffer
.tabs
[this._terminal
.buffer
.x
];
3003 else if (param
=== 3) {
3004 this._terminal
.buffer
.tabs
= {};
3007 InputHandler
.prototype.setMode = function (params
, collect
) {
3008 if (params
.length
> 1) {
3009 for (var i
= 0; i
< params
.length
; i
++) {
3010 this.setMode([params
[i
]]);
3015 switch (params
[0]) {
3017 this._terminal
.insertMode
= true;
3023 else if (collect
=== '?') {
3024 switch (params
[0]) {
3026 this._terminal
.applicationCursor
= true;
3029 this._terminal
.setgCharset(0, Charsets_1
.DEFAULT_CHARSET
);
3030 this._terminal
.setgCharset(1, Charsets_1
.DEFAULT_CHARSET
);
3031 this._terminal
.setgCharset(2, Charsets_1
.DEFAULT_CHARSET
);
3032 this._terminal
.setgCharset(3, Charsets_1
.DEFAULT_CHARSET
);
3035 this._terminal
.savedCols
= this._terminal
.cols
;
3036 this._terminal
.resize(132, this._terminal
.rows
);
3039 this._terminal
.originMode
= true;
3042 this._terminal
.wraparoundMode
= true;
3047 this._terminal
.log('Serial port requested application keypad.');
3048 this._terminal
.applicationKeypad
= true;
3049 if (this._terminal
.viewport
) {
3050 this._terminal
.viewport
.syncScrollArea();
3057 this._terminal
.x10Mouse
= params
[0] === 9;
3058 this._terminal
.vt200Mouse
= params
[0] === 1000;
3059 this._terminal
.normalMouse
= params
[0] > 1000;
3060 this._terminal
.mouseEvents
= true;
3061 if (this._terminal
.element
) {
3062 this._terminal
.element
.classList
.add('enable-mouse-events');
3064 if (this._terminal
.selectionManager
) {
3065 this._terminal
.selectionManager
.disable();
3067 this._terminal
.log('Binding to mouse events.');
3070 this._terminal
.sendFocus
= true;
3073 this._terminal
.utfMouse
= true;
3076 this._terminal
.sgrMouse
= true;
3079 this._terminal
.urxvtMouse
= true;
3082 this._terminal
.cursorHidden
= false;
3085 this.saveCursor(params
);
3088 this.saveCursor(params
);
3091 this._terminal
.buffers
.activateAltBuffer(this._terminal
.eraseAttrData());
3092 this._terminal
.refresh(0, this._terminal
.rows
- 1);
3093 if (this._terminal
.viewport
) {
3094 this._terminal
.viewport
.syncScrollArea();
3096 this._terminal
.showCursor();
3099 this._terminal
.bracketedPasteMode
= true;
3104 InputHandler
.prototype.resetMode = function (params
, collect
) {
3105 if (params
.length
> 1) {
3106 for (var i
= 0; i
< params
.length
; i
++) {
3107 this.resetMode([params
[i
]]);
3112 switch (params
[0]) {
3114 this._terminal
.insertMode
= false;
3120 else if (collect
=== '?') {
3121 switch (params
[0]) {
3123 this._terminal
.applicationCursor
= false;
3126 if (this._terminal
.cols
=== 132 && this._terminal
.savedCols
) {
3127 this._terminal
.resize(this._terminal
.savedCols
, this._terminal
.rows
);
3129 delete this._terminal
.savedCols
;
3132 this._terminal
.originMode
= false;
3135 this._terminal
.wraparoundMode
= false;
3140 this._terminal
.log('Switching back to normal keypad.');
3141 this._terminal
.applicationKeypad
= false;
3142 if (this._terminal
.viewport
) {
3143 this._terminal
.viewport
.syncScrollArea();
3150 this._terminal
.x10Mouse
= false;
3151 this._terminal
.vt200Mouse
= false;
3152 this._terminal
.normalMouse
= false;
3153 this._terminal
.mouseEvents
= false;
3154 if (this._terminal
.element
) {
3155 this._terminal
.element
.classList
.remove('enable-mouse-events');
3157 if (this._terminal
.selectionManager
) {
3158 this._terminal
.selectionManager
.enable();
3162 this._terminal
.sendFocus
= false;
3165 this._terminal
.utfMouse
= false;
3168 this._terminal
.sgrMouse
= false;
3171 this._terminal
.urxvtMouse
= false;
3174 this._terminal
.cursorHidden
= true;
3177 this.restoreCursor(params
);
3182 this._terminal
.buffers
.activateNormalBuffer();
3183 if (params
[0] === 1049) {
3184 this.restoreCursor(params
);
3186 this._terminal
.refresh(0, this._terminal
.rows
- 1);
3187 if (this._terminal
.viewport
) {
3188 this._terminal
.viewport
.syncScrollArea();
3190 this._terminal
.showCursor();
3193 this._terminal
.bracketedPasteMode
= false;
3198 InputHandler
.prototype.charAttributes = function (params
) {
3199 if (params
.length
=== 1 && params
[0] === 0) {
3200 this._terminal
.curAttrData
.fg
= Buffer_1
.DEFAULT_ATTR_DATA
.fg
;
3201 this._terminal
.curAttrData
.bg
= Buffer_1
.DEFAULT_ATTR_DATA
.bg
;
3204 var l
= params
.length
;
3206 var attr
= this._terminal
.curAttrData
;
3207 for (var i
= 0; i
< l
; i
++) {
3209 if (p
>= 30 && p
<= 37) {
3210 attr
.fg
&= ~(50331648 | 255);
3211 attr
.fg
|= 16777216 | (p
- 30);
3213 else if (p
>= 40 && p
<= 47) {
3214 attr
.bg
&= ~(50331648 | 255);
3215 attr
.bg
|= 16777216 | (p
- 40);
3217 else if (p
>= 90 && p
<= 97) {
3218 attr
.fg
&= ~(50331648 | 255);
3219 attr
.fg
|= 16777216 | (p
- 90) | 8;
3221 else if (p
>= 100 && p
<= 107) {
3222 attr
.bg
&= ~(50331648 | 255);
3223 attr
.bg
|= 16777216 | (p
- 100) | 8;
3226 attr
.fg
= Buffer_1
.DEFAULT_ATTR_DATA
.fg
;
3227 attr
.bg
= Buffer_1
.DEFAULT_ATTR_DATA
.bg
;
3230 attr
.fg
|= 134217728;
3233 attr
.bg
|= 67108864;
3236 attr
.fg
|= 268435456;
3239 attr
.fg
|= 536870912;
3242 attr
.fg
|= 67108864;
3245 attr
.fg
|= 1073741824;
3248 attr
.bg
|= 134217728;
3250 else if (p
=== 22) {
3251 attr
.fg
&= ~134217728;
3252 attr
.bg
&= ~134217728;
3254 else if (p
=== 23) {
3255 attr
.bg
&= ~67108864;
3257 else if (p
=== 24) {
3258 attr
.fg
&= ~268435456;
3260 else if (p
=== 25) {
3261 attr
.fg
&= ~536870912;
3263 else if (p
=== 27) {
3264 attr
.fg
&= ~67108864;
3266 else if (p
=== 28) {
3267 attr
.fg
&= ~1073741824;
3269 else if (p
=== 39) {
3270 attr
.fg
&= ~(50331648 | 16777215);
3271 attr
.fg
|= Buffer_1
.DEFAULT_ATTR_DATA
.fg
& (255 | 16777215);
3273 else if (p
=== 49) {
3274 attr
.bg
&= ~(50331648 | 16777215);
3275 attr
.bg
|= Buffer_1
.DEFAULT_ATTR_DATA
.bg
& (255 | 16777215);
3277 else if (p
=== 38) {
3278 if (params
[i
+ 1] === 2) {
3280 attr
.fg
|= 50331648;
3281 attr
.fg
&= ~16777215;
3282 attr
.fg
|= BufferLine_1
.AttributeData
.fromColorRGB([params
[i
], params
[i
+ 1], params
[i
+ 2]]);
3285 else if (params
[i
+ 1] === 5) {
3287 p
= params
[i
] & 0xff;
3289 attr
.fg
|= 33554432 | p
;
3292 else if (p
=== 48) {
3293 if (params
[i
+ 1] === 2) {
3295 attr
.bg
|= 50331648;
3296 attr
.bg
&= ~16777215;
3297 attr
.bg
|= BufferLine_1
.AttributeData
.fromColorRGB([params
[i
], params
[i
+ 1], params
[i
+ 2]]);
3300 else if (params
[i
+ 1] === 5) {
3302 p
= params
[i
] & 0xff;
3304 attr
.bg
|= 33554432 | p
;
3307 else if (p
=== 100) {
3308 attr
.fg
&= ~(50331648 | 16777215);
3309 attr
.fg
|= Buffer_1
.DEFAULT_ATTR_DATA
.fg
& (255 | 16777215);
3310 attr
.bg
&= ~(50331648 | 16777215);
3311 attr
.bg
|= Buffer_1
.DEFAULT_ATTR_DATA
.bg
& (255 | 16777215);
3314 this._terminal
.error('Unknown SGR attribute: %d.', p
);
3318 InputHandler
.prototype.deviceStatus = function (params
, collect
) {
3320 switch (params
[0]) {
3322 this._onData
.fire(EscapeSequences_1
.C0
.ESC
+ "[0n");
3325 var y
= this._terminal
.buffer
.y
+ 1;
3326 var x
= this._terminal
.buffer
.x
+ 1;
3327 this._onData
.fire(EscapeSequences_1
.C0
.ESC
+ "[" + y
+ ";" + x
+ "R");
3331 else if (collect
=== '?') {
3332 switch (params
[0]) {
3334 var y
= this._terminal
.buffer
.y
+ 1;
3335 var x
= this._terminal
.buffer
.x
+ 1;
3336 this._onData
.fire(EscapeSequences_1
.C0
.ESC
+ "[?" + y
+ ";" + x
+ "R");
3349 InputHandler
.prototype.softReset = function (params
, collect
) {
3350 if (collect
=== '!') {
3351 this._terminal
.cursorHidden
= false;
3352 this._terminal
.insertMode
= false;
3353 this._terminal
.originMode
= false;
3354 this._terminal
.wraparoundMode
= true;
3355 this._terminal
.applicationKeypad
= false;
3356 if (this._terminal
.viewport
) {
3357 this._terminal
.viewport
.syncScrollArea();
3359 this._terminal
.applicationCursor
= false;
3360 this._terminal
.buffer
.scrollTop
= 0;
3361 this._terminal
.buffer
.scrollBottom
= this._terminal
.rows
- 1;
3362 this._terminal
.curAttrData
= Buffer_1
.DEFAULT_ATTR_DATA
;
3363 this._terminal
.buffer
.x
= this._terminal
.buffer
.y
= 0;
3364 this._terminal
.charset
= null;
3365 this._terminal
.glevel
= 0;
3366 this._terminal
.charsets
= [null];
3369 InputHandler
.prototype.setCursorStyle = function (params
, collect
) {
3370 if (collect
=== ' ') {
3371 var param
= params
[0] < 1 ? 1 : params
[0];
3375 this._terminal
.setOption('cursorStyle', 'block');
3379 this._terminal
.setOption('cursorStyle', 'underline');
3383 this._terminal
.setOption('cursorStyle', 'bar');
3386 var isBlinking
= param
% 2 === 1;
3387 this._terminal
.setOption('cursorBlink', isBlinking
);
3390 InputHandler
.prototype.setScrollRegion = function (params
, collect
) {
3394 this._terminal
.buffer
.scrollTop
= (params
[0] || 1) - 1;
3395 this._terminal
.buffer
.scrollBottom
= (params
[1] && params
[1] <= this._terminal
.rows
? params
[1] : this._terminal
.rows
) - 1;
3396 this._terminal
.buffer
.x
= 0;
3397 this._terminal
.buffer
.y
= 0;
3399 InputHandler
.prototype.saveCursor = function (params
) {
3400 this._terminal
.buffer
.savedX
= this._terminal
.buffer
.x
;
3401 this._terminal
.buffer
.savedY
= this._terminal
.buffer
.y
;
3402 this._terminal
.buffer
.savedCurAttrData
.fg
= this._terminal
.curAttrData
.fg
;
3403 this._terminal
.buffer
.savedCurAttrData
.bg
= this._terminal
.curAttrData
.bg
;
3405 InputHandler
.prototype.restoreCursor = function (params
) {
3406 this._terminal
.buffer
.x
= this._terminal
.buffer
.savedX
|| 0;
3407 this._terminal
.buffer
.y
= this._terminal
.buffer
.savedY
|| 0;
3408 this._terminal
.curAttrData
.fg
= this._terminal
.buffer
.savedCurAttrData
.fg
;
3409 this._terminal
.curAttrData
.bg
= this._terminal
.buffer
.savedCurAttrData
.bg
;
3411 InputHandler
.prototype.setTitle = function (data
) {
3412 this._terminal
.handleTitle(data
);
3414 InputHandler
.prototype.nextLine = function () {
3415 this._terminal
.buffer
.x
= 0;
3418 InputHandler
.prototype.keypadApplicationMode = function () {
3419 this._terminal
.log('Serial port requested application keypad.');
3420 this._terminal
.applicationKeypad
= true;
3421 if (this._terminal
.viewport
) {
3422 this._terminal
.viewport
.syncScrollArea();
3425 InputHandler
.prototype.keypadNumericMode = function () {
3426 this._terminal
.log('Switching back to normal keypad.');
3427 this._terminal
.applicationKeypad
= false;
3428 if (this._terminal
.viewport
) {
3429 this._terminal
.viewport
.syncScrollArea();
3432 InputHandler
.prototype.selectDefaultCharset = function () {
3433 this._terminal
.setgLevel(0);
3434 this._terminal
.setgCharset(0, Charsets_1
.DEFAULT_CHARSET
);
3436 InputHandler
.prototype.selectCharset = function (collectAndFlag
) {
3437 if (collectAndFlag
.length
!== 2) {
3438 this.selectDefaultCharset();
3441 if (collectAndFlag
[0] === '/') {
3444 this._terminal
.setgCharset(GLEVEL
[collectAndFlag
[0]], Charsets_1
.CHARSETS
[collectAndFlag
[1]] || Charsets_1
.DEFAULT_CHARSET
);
3447 InputHandler
.prototype.index = function () {
3448 this._terminal
.index();
3450 InputHandler
.prototype.tabSet = function () {
3451 this._terminal
.tabSet();
3453 InputHandler
.prototype.reverseIndex = function () {
3454 this._terminal
.reverseIndex();
3456 InputHandler
.prototype.reset = function () {
3457 this._parser
.reset();
3458 this._terminal
.reset();
3460 InputHandler
.prototype.setgLevel = function (level
) {
3461 this._terminal
.setgLevel(level
);
3463 return InputHandler
;
3464 }(Lifecycle_1
.Disposable
));
3465 exports
.InputHandler
= InputHandler
;
3467 },{"./Buffer":2,"./BufferLine":3,"./CharWidth":7,"./EscapeSequenceParser":10,"./common/EventEmitter2":25,"./common/Lifecycle":26,"./common/TypedArrayUtils":28,"./common/data/EscapeSequences":29,"./core/data/Charsets":30,"./core/input/TextDecoder":32}],12:[function(require
,module
,exports
){
3469 Object
.defineProperty(exports
, "__esModule", { value
: true });
3470 var MouseZoneManager_1
= require("./MouseZoneManager");
3471 var CharWidth_1
= require("./CharWidth");
3472 var EventEmitter2_1
= require("./common/EventEmitter2");
3473 var Linkifier
= (function () {
3474 function Linkifier(_terminal
) {
3475 this._terminal
= _terminal
;
3476 this._linkMatchers
= [];
3477 this._nextLinkMatcherId
= 0;
3478 this._onLinkHover
= new EventEmitter2_1
.EventEmitter2();
3479 this._onLinkLeave
= new EventEmitter2_1
.EventEmitter2();
3480 this._onLinkTooltip
= new EventEmitter2_1
.EventEmitter2();
3481 this._rowsToLinkify
= {
3486 Object
.defineProperty(Linkifier
.prototype, "onLinkHover", {
3487 get: function () { return this._onLinkHover
.event
; },
3491 Object
.defineProperty(Linkifier
.prototype, "onLinkLeave", {
3492 get: function () { return this._onLinkLeave
.event
; },
3496 Object
.defineProperty(Linkifier
.prototype, "onLinkTooltip", {
3497 get: function () { return this._onLinkTooltip
.event
; },
3501 Linkifier
.prototype.attachToDom = function (mouseZoneManager
) {
3502 this._mouseZoneManager
= mouseZoneManager
;
3504 Linkifier
.prototype.linkifyRows = function (start
, end
) {
3506 if (!this._mouseZoneManager
) {
3509 if (this._rowsToLinkify
.start
=== null) {
3510 this._rowsToLinkify
.start
= start
;
3511 this._rowsToLinkify
.end
= end
;
3514 this._rowsToLinkify
.start
= Math
.min(this._rowsToLinkify
.start
, start
);
3515 this._rowsToLinkify
.end
= Math
.max(this._rowsToLinkify
.end
, end
);
3517 this._mouseZoneManager
.clearAll(start
, end
);
3518 if (this._rowsTimeoutId
) {
3519 clearTimeout(this._rowsTimeoutId
);
3521 this._rowsTimeoutId
= setTimeout(function () { return _this
._linkifyRows(); }, Linkifier
.TIME_BEFORE_LINKIFY
);
3523 Linkifier
.prototype._linkifyRows = function () {
3524 this._rowsTimeoutId
= null;
3525 var buffer
= this._terminal
.buffer
;
3526 var absoluteRowIndexStart
= buffer
.ydisp
+ this._rowsToLinkify
.start
;
3527 if (absoluteRowIndexStart
>= buffer
.lines
.length
) {
3530 var absoluteRowIndexEnd
= buffer
.ydisp
+ Math
.min(this._rowsToLinkify
.end
, this._terminal
.rows
) + 1;
3531 var overscanLineLimit
= Math
.ceil(Linkifier
.OVERSCAN_CHAR_LIMIT
/ this._terminal
.cols
);
3532 var iterator
= this._terminal
.buffer
.iterator(false, absoluteRowIndexStart
, absoluteRowIndexEnd
, overscanLineLimit
, overscanLineLimit
);
3533 while (iterator
.hasNext()) {
3534 var lineData
= iterator
.next();
3535 for (var i
= 0; i
< this._linkMatchers
.length
; i
++) {
3536 this._doLinkifyRow(lineData
.range
.first
, lineData
.content
, this._linkMatchers
[i
]);
3539 this._rowsToLinkify
.start
= null;
3540 this._rowsToLinkify
.end
= null;
3542 Linkifier
.prototype.registerLinkMatcher = function (regex
, handler
, options
) {
3543 if (options
=== void 0) { options
= {}; }
3545 throw new Error('handler must be defined');
3548 id
: this._nextLinkMatcherId
++,
3551 matchIndex
: options
.matchIndex
,
3552 validationCallback
: options
.validationCallback
,
3553 hoverTooltipCallback
: options
.tooltipCallback
,
3554 hoverLeaveCallback
: options
.leaveCallback
,
3555 willLinkActivate
: options
.willLinkActivate
,
3556 priority
: options
.priority
|| 0
3558 this._addLinkMatcherToList(matcher
);
3561 Linkifier
.prototype._addLinkMatcherToList = function (matcher
) {
3562 if (this._linkMatchers
.length
=== 0) {
3563 this._linkMatchers
.push(matcher
);
3566 for (var i
= this._linkMatchers
.length
- 1; i
>= 0; i
--) {
3567 if (matcher
.priority
<= this._linkMatchers
[i
].priority
) {
3568 this._linkMatchers
.splice(i
+ 1, 0, matcher
);
3572 this._linkMatchers
.splice(0, 0, matcher
);
3574 Linkifier
.prototype.deregisterLinkMatcher = function (matcherId
) {
3575 for (var i
= 0; i
< this._linkMatchers
.length
; i
++) {
3576 if (this._linkMatchers
[i
].id
=== matcherId
) {
3577 this._linkMatchers
.splice(i
, 1);
3583 Linkifier
.prototype._doLinkifyRow = function (rowIndex
, text
, matcher
) {
3585 var rex
= new RegExp(matcher
.regex
.source
, matcher
.regex
.flags
+ 'g');
3587 var stringIndex
= -1;
3588 var _loop_1 = function () {
3589 var uri
= match
[typeof matcher
.matchIndex
!== 'number' ? 0 : matcher
.matchIndex
];
3591 if (this_1
._terminal
.debug
) {
3592 console
.log({ match
: match
, matcher
: matcher
});
3593 throw new Error('match found without corresponding matchIndex');
3597 stringIndex
= text
.indexOf(uri
, stringIndex
+ 1);
3598 rex
.lastIndex
= stringIndex
+ uri
.length
;
3599 if (stringIndex
< 0) {
3602 var bufferIndex
= this_1
._terminal
.buffer
.stringIndexToBufferIndex(rowIndex
, stringIndex
);
3603 if (bufferIndex
[0] < 0) {
3606 var line
= this_1
._terminal
.buffer
.lines
.get(bufferIndex
[0]);
3607 var attr
= line
.getFg(bufferIndex
[1]);
3610 fg
= (attr
>> 9) & 0x1ff;
3612 if (matcher
.validationCallback
) {
3613 matcher
.validationCallback(uri
, function (isValid
) {
3614 if (_this
._rowsTimeoutId
) {
3618 _this
._addLink(bufferIndex
[1], bufferIndex
[0] - _this
._terminal
.buffer
.ydisp
, uri
, matcher
, fg
);
3623 this_1
._addLink(bufferIndex
[1], bufferIndex
[0] - this_1
._terminal
.buffer
.ydisp
, uri
, matcher
, fg
);
3627 while ((match
= rex
.exec(text
)) !== null) {
3628 var state_1
= _loop_1();
3629 if (state_1
=== "break")
3633 Linkifier
.prototype._addLink = function (x
, y
, uri
, matcher
, fg
) {
3635 var width
= CharWidth_1
.getStringCellWidth(uri
);
3636 var x1
= x
% this._terminal
.cols
;
3637 var y1
= y
+ Math
.floor(x
/ this._terminal
.cols
);
3638 var x2
= (x1
+ width
) % this._terminal
.cols
;
3639 var y2
= y1
+ Math
.floor((x1
+ width
) / this._terminal
.cols
);
3641 x2
= this._terminal
.cols
;
3644 this._mouseZoneManager
.add(new MouseZoneManager_1
.MouseZone(x1
+ 1, y1
+ 1, x2
+ 1, y2
+ 1, function (e
) {
3645 if (matcher
.handler
) {
3646 return matcher
.handler(e
, uri
);
3648 window
.open(uri
, '_blank');
3650 _this
._onLinkHover
.fire(_this
._createLinkHoverEvent(x1
, y1
, x2
, y2
, fg
));
3651 _this
._terminal
.element
.classList
.add('xterm-cursor-pointer');
3653 _this
._onLinkTooltip
.fire(_this
._createLinkHoverEvent(x1
, y1
, x2
, y2
, fg
));
3654 if (matcher
.hoverTooltipCallback
) {
3655 matcher
.hoverTooltipCallback(e
, uri
);
3658 _this
._onLinkLeave
.fire(_this
._createLinkHoverEvent(x1
, y1
, x2
, y2
, fg
));
3659 _this
._terminal
.element
.classList
.remove('xterm-cursor-pointer');
3660 if (matcher
.hoverLeaveCallback
) {
3661 matcher
.hoverLeaveCallback();
3664 if (matcher
.willLinkActivate
) {
3665 return matcher
.willLinkActivate(e
, uri
);
3670 Linkifier
.prototype._createLinkHoverEvent = function (x1
, y1
, x2
, y2
, fg
) {
3671 return { x1
: x1
, y1
: y1
, x2
: x2
, y2
: y2
, cols
: this._terminal
.cols
, fg
: fg
};
3673 Linkifier
.TIME_BEFORE_LINKIFY
= 200;
3674 Linkifier
.OVERSCAN_CHAR_LIMIT
= 2000;
3677 exports
.Linkifier
= Linkifier
;
3679 },{"./CharWidth":7,"./MouseZoneManager":14,"./common/EventEmitter2":25}],13:[function(require
,module
,exports
){
3681 Object
.defineProperty(exports
, "__esModule", { value
: true });
3682 var MouseHelper
= (function () {
3683 function MouseHelper(_renderer
) {
3684 this._renderer
= _renderer
;
3686 MouseHelper
.prototype.setRenderer = function (renderer
) {
3687 this._renderer
= renderer
;
3689 MouseHelper
.getCoordsRelativeToElement = function (event
, element
) {
3690 var rect
= element
.getBoundingClientRect();
3691 return [event
.clientX
- rect
.left
, event
.clientY
- rect
.top
];
3693 MouseHelper
.prototype.getCoords = function (event
, element
, charMeasure
, colCount
, rowCount
, isSelection
) {
3694 if (!charMeasure
.width
|| !charMeasure
.height
) {
3697 var coords
= MouseHelper
.getCoordsRelativeToElement(event
, element
);
3701 coords
[0] = Math
.ceil((coords
[0] + (isSelection
? this._renderer
.dimensions
.actualCellWidth
/ 2 : 0)) / this._renderer
.dimensions
.actualCellWidth
);
3702 coords
[1] = Math
.ceil(coords
[1] / this._renderer
.dimensions
.actualCellHeight
);
3703 coords
[0] = Math
.min(Math
.max(coords
[0], 1), colCount
+ (isSelection
? 1 : 0));
3704 coords
[1] = Math
.min(Math
.max(coords
[1], 1), rowCount
);
3707 MouseHelper
.prototype.getRawByteCoords = function (event
, element
, charMeasure
, colCount
, rowCount
) {
3708 var coords
= this.getCoords(event
, element
, charMeasure
, colCount
, rowCount
);
3713 return { x
: x
, y
: y
};
3717 exports
.MouseHelper
= MouseHelper
;
3719 },{}],14:[function(require
,module
,exports
){
3721 var __extends
= (this && this.__extends
) || (function () {
3722 var extendStatics = function (d
, b
) {
3723 extendStatics
= Object
.setPrototypeOf
||
3724 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
3725 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
3726 return extendStatics(d
, b
);
3728 return function (d
, b
) {
3729 extendStatics(d
, b
);
3730 function __() { this.constructor = d
; }
3731 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
3734 Object
.defineProperty(exports
, "__esModule", { value
: true });
3735 var Lifecycle_1
= require("./common/Lifecycle");
3736 var Lifecycle_2
= require("./ui/Lifecycle");
3737 var HOVER_DURATION
= 500;
3738 var MouseZoneManager
= (function (_super
) {
3739 __extends(MouseZoneManager
, _super
);
3740 function MouseZoneManager(_terminal
) {
3741 var _this
= _super
.call(this) || this;
3742 _this
._terminal
= _terminal
;
3744 _this
._areZonesActive
= false;
3745 _this
._tooltipTimeout
= null;
3746 _this
._currentZone
= null;
3747 _this
._lastHoverCoords
= [null, null];
3748 _this
.register(Lifecycle_2
.addDisposableDomListener(_this
._terminal
.element
, 'mousedown', function (e
) { return _this
._onMouseDown(e
); }));
3749 _this
._mouseMoveListener = function (e
) { return _this
._onMouseMove(e
); };
3750 _this
._mouseLeaveListener = function (e
) { return _this
._onMouseLeave(e
); };
3751 _this
._clickListener = function (e
) { return _this
._onClick(e
); };
3754 MouseZoneManager
.prototype.dispose = function () {
3755 _super
.prototype.dispose
.call(this);
3758 MouseZoneManager
.prototype.add = function (zone
) {
3759 this._zones
.push(zone
);
3760 if (this._zones
.length
=== 1) {
3764 MouseZoneManager
.prototype.clearAll = function (start
, end
) {
3765 if (this._zones
.length
=== 0) {
3770 end
= this._terminal
.rows
- 1;
3772 for (var i
= 0; i
< this._zones
.length
; i
++) {
3773 var zone
= this._zones
[i
];
3774 if ((zone
.y1
> start
&& zone
.y1
<= end
+ 1) ||
3775 (zone
.y2
> start
&& zone
.y2
<= end
+ 1) ||
3776 (zone
.y1
< start
&& zone
.y2
> end
+ 1)) {
3777 if (this._currentZone
&& this._currentZone
=== zone
) {
3778 this._currentZone
.leaveCallback();
3779 this._currentZone
= null;
3781 this._zones
.splice(i
--, 1);
3784 if (this._zones
.length
=== 0) {
3788 MouseZoneManager
.prototype._activate = function () {
3789 if (!this._areZonesActive
) {
3790 this._areZonesActive
= true;
3791 this._terminal
.element
.addEventListener('mousemove', this._mouseMoveListener
);
3792 this._terminal
.element
.addEventListener('mouseleave', this._mouseLeaveListener
);
3793 this._terminal
.element
.addEventListener('click', this._clickListener
);
3796 MouseZoneManager
.prototype._deactivate = function () {
3797 if (this._areZonesActive
) {
3798 this._areZonesActive
= false;
3799 this._terminal
.element
.removeEventListener('mousemove', this._mouseMoveListener
);
3800 this._terminal
.element
.removeEventListener('mouseleave', this._mouseLeaveListener
);
3801 this._terminal
.element
.removeEventListener('click', this._clickListener
);
3804 MouseZoneManager
.prototype._onMouseMove = function (e
) {
3805 if (this._lastHoverCoords
[0] !== e
.pageX
|| this._lastHoverCoords
[1] !== e
.pageY
) {
3807 this._lastHoverCoords
= [e
.pageX
, e
.pageY
];
3810 MouseZoneManager
.prototype._onHover = function (e
) {
3812 var zone
= this._findZoneEventAt(e
);
3813 if (zone
=== this._currentZone
) {
3816 if (this._currentZone
) {
3817 this._currentZone
.leaveCallback();
3818 this._currentZone
= null;
3819 if (this._tooltipTimeout
) {
3820 clearTimeout(this._tooltipTimeout
);
3826 this._currentZone
= zone
;
3827 if (zone
.hoverCallback
) {
3828 zone
.hoverCallback(e
);
3830 this._tooltipTimeout
= setTimeout(function () { return _this
._onTooltip(e
); }, HOVER_DURATION
);
3832 MouseZoneManager
.prototype._onTooltip = function (e
) {
3833 this._tooltipTimeout
= null;
3834 var zone
= this._findZoneEventAt(e
);
3835 if (zone
&& zone
.tooltipCallback
) {
3836 zone
.tooltipCallback(e
);
3839 MouseZoneManager
.prototype._onMouseDown = function (e
) {
3840 this._initialSelectionLength
= this._terminal
.getSelection().length
;
3841 if (!this._areZonesActive
) {
3844 var zone
= this._findZoneEventAt(e
);
3846 if (zone
.willLinkActivate(e
)) {
3848 e
.stopImmediatePropagation();
3852 MouseZoneManager
.prototype._onMouseLeave = function (e
) {
3853 if (this._currentZone
) {
3854 this._currentZone
.leaveCallback();
3855 this._currentZone
= null;
3856 if (this._tooltipTimeout
) {
3857 clearTimeout(this._tooltipTimeout
);
3861 MouseZoneManager
.prototype._onClick = function (e
) {
3862 var zone
= this._findZoneEventAt(e
);
3863 var currentSelectionLength
= this._terminal
.getSelection().length
;
3864 if (zone
&& currentSelectionLength
=== this._initialSelectionLength
) {
3865 zone
.clickCallback(e
);
3867 e
.stopImmediatePropagation();
3870 MouseZoneManager
.prototype._findZoneEventAt = function (e
) {
3871 var coords
= this._terminal
.mouseHelper
.getCoords(e
, this._terminal
.screenElement
, this._terminal
.charMeasure
, this._terminal
.cols
, this._terminal
.rows
);
3877 for (var i
= 0; i
< this._zones
.length
; i
++) {
3878 var zone
= this._zones
[i
];
3879 if (zone
.y1
=== zone
.y2
) {
3880 if (y
=== zone
.y1
&& x
>= zone
.x1
&& x
< zone
.x2
) {
3885 if ((y
=== zone
.y1
&& x
>= zone
.x1
) ||
3886 (y
=== zone
.y2
&& x
< zone
.x2
) ||
3887 (y
> zone
.y1
&& y
< zone
.y2
)) {
3894 return MouseZoneManager
;
3895 }(Lifecycle_1
.Disposable
));
3896 exports
.MouseZoneManager
= MouseZoneManager
;
3897 var MouseZone
= (function () {
3898 function MouseZone(x1
, y1
, x2
, y2
, clickCallback
, hoverCallback
, tooltipCallback
, leaveCallback
, willLinkActivate
) {
3903 this.clickCallback
= clickCallback
;
3904 this.hoverCallback
= hoverCallback
;
3905 this.tooltipCallback
= tooltipCallback
;
3906 this.leaveCallback
= leaveCallback
;
3907 this.willLinkActivate
= willLinkActivate
;
3911 exports
.MouseZone
= MouseZone
;
3913 },{"./common/Lifecycle":26,"./ui/Lifecycle":55}],15:[function(require
,module
,exports
){
3915 Object
.defineProperty(exports
, "__esModule", { value
: true });
3916 var MouseHelper_1
= require("./MouseHelper");
3917 var Browser
= require("./common/Platform");
3918 var SelectionModel_1
= require("./SelectionModel");
3919 var AltClickHandler_1
= require("./handlers/AltClickHandler");
3920 var BufferLine_1
= require("./BufferLine");
3921 var EventEmitter2_1
= require("./common/EventEmitter2");
3922 var DRAG_SCROLL_MAX_THRESHOLD
= 50;
3923 var DRAG_SCROLL_MAX_SPEED
= 15;
3924 var DRAG_SCROLL_INTERVAL
= 50;
3925 var ALT_CLICK_MOVE_CURSOR_TIME
= 500;
3926 var WORD_SEPARATORS
= ' ()[]{}\'"';
3927 var NON_BREAKING_SPACE_CHAR
= String
.fromCharCode(160);
3928 var ALL_NON_BREAKING_SPACE_REGEX
= new RegExp(NON_BREAKING_SPACE_CHAR
, 'g');
3929 var SelectionManager
= (function () {
3930 function SelectionManager(_terminal
, _charMeasure
) {
3931 this._terminal
= _terminal
;
3932 this._charMeasure
= _charMeasure
;
3933 this._enabled
= true;
3934 this._workCell
= new BufferLine_1
.CellData();
3935 this._onLinuxMouseSelection
= new EventEmitter2_1
.EventEmitter2();
3936 this._onRedrawRequest
= new EventEmitter2_1
.EventEmitter2();
3937 this._onSelectionChange
= new EventEmitter2_1
.EventEmitter2();
3938 this._initListeners();
3940 this._model
= new SelectionModel_1
.SelectionModel(_terminal
);
3941 this._activeSelectionMode
= 0;
3943 Object
.defineProperty(SelectionManager
.prototype, "onLinuxMouseSelection", {
3944 get: function () { return this._onLinuxMouseSelection
.event
; },
3948 Object
.defineProperty(SelectionManager
.prototype, "onRedrawRequest", {
3949 get: function () { return this._onRedrawRequest
.event
; },
3953 Object
.defineProperty(SelectionManager
.prototype, "onSelectionChange", {
3954 get: function () { return this._onSelectionChange
.event
; },
3958 SelectionManager
.prototype.dispose = function () {
3959 this._removeMouseDownListeners();
3961 Object
.defineProperty(SelectionManager
.prototype, "_buffer", {
3963 return this._terminal
.buffers
.active
;
3968 SelectionManager
.prototype._initListeners = function () {
3970 this._mouseMoveListener = function (event
) { return _this
._onMouseMove(event
); };
3971 this._mouseUpListener = function (event
) { return _this
._onMouseUp(event
); };
3972 this.initBuffersListeners();
3974 SelectionManager
.prototype.initBuffersListeners = function () {
3976 this._trimListener
= this._terminal
.buffer
.lines
.onTrim(function (amount
) { return _this
._onTrim(amount
); });
3977 this._terminal
.buffers
.onBufferActivate(function (e
) { return _this
._onBufferActivate(e
); });
3979 SelectionManager
.prototype.disable = function () {
3980 this.clearSelection();
3981 this._enabled
= false;
3983 SelectionManager
.prototype.enable = function () {
3984 this._enabled
= true;
3986 Object
.defineProperty(SelectionManager
.prototype, "selectionStart", {
3987 get: function () { return this._model
.finalSelectionStart
; },
3991 Object
.defineProperty(SelectionManager
.prototype, "selectionEnd", {
3992 get: function () { return this._model
.finalSelectionEnd
; },
3996 Object
.defineProperty(SelectionManager
.prototype, "hasSelection", {
3998 var start
= this._model
.finalSelectionStart
;
3999 var end
= this._model
.finalSelectionEnd
;
4000 if (!start
|| !end
) {
4003 return start
[0] !== end
[0] || start
[1] !== end
[1];
4008 Object
.defineProperty(SelectionManager
.prototype, "selectionText", {
4010 var start
= this._model
.finalSelectionStart
;
4011 var end
= this._model
.finalSelectionEnd
;
4012 if (!start
|| !end
) {
4016 if (this._activeSelectionMode
=== 3) {
4017 if (start
[0] === end
[0]) {
4020 for (var i
= start
[1]; i
<= end
[1]; i
++) {
4021 var lineText
= this._buffer
.translateBufferLineToString(i
, true, start
[0], end
[0]);
4022 result
.push(lineText
);
4026 var startRowEndCol
= start
[1] === end
[1] ? end
[0] : undefined;
4027 result
.push(this._buffer
.translateBufferLineToString(start
[1], true, start
[0], startRowEndCol
));
4028 for (var i
= start
[1] + 1; i
<= end
[1] - 1; i
++) {
4029 var bufferLine
= this._buffer
.lines
.get(i
);
4030 var lineText
= this._buffer
.translateBufferLineToString(i
, true);
4031 if (bufferLine
.isWrapped
) {
4032 result
[result
.length
- 1] += lineText
;
4035 result
.push(lineText
);
4038 if (start
[1] !== end
[1]) {
4039 var bufferLine
= this._buffer
.lines
.get(end
[1]);
4040 var lineText
= this._buffer
.translateBufferLineToString(end
[1], true, 0, end
[0]);
4041 if (bufferLine
.isWrapped
) {
4042 result
[result
.length
- 1] += lineText
;
4045 result
.push(lineText
);
4049 var formattedResult
= result
.map(function (line
) {
4050 return line
.replace(ALL_NON_BREAKING_SPACE_REGEX
, ' ');
4051 }).join(Browser
.isMSWindows
? '\r\n' : '\n');
4052 return formattedResult
;
4057 SelectionManager
.prototype.clearSelection = function () {
4058 this._model
.clearSelection();
4059 this._removeMouseDownListeners();
4062 SelectionManager
.prototype.refresh = function (isLinuxMouseSelection
) {
4064 if (!this._refreshAnimationFrame
) {
4065 this._refreshAnimationFrame
= window
.requestAnimationFrame(function () { return _this
._refresh(); });
4067 if (Browser
.isLinux
&& isLinuxMouseSelection
) {
4068 var selectionText
= this.selectionText
;
4069 if (selectionText
.length
) {
4070 this._onLinuxMouseSelection
.fire(this.selectionText
);
4074 SelectionManager
.prototype._refresh = function () {
4075 this._refreshAnimationFrame
= null;
4076 this._onRedrawRequest
.fire({
4077 start
: this._model
.finalSelectionStart
,
4078 end
: this._model
.finalSelectionEnd
,
4079 columnSelectMode
: this._activeSelectionMode
=== 3
4082 SelectionManager
.prototype.isClickInSelection = function (event
) {
4083 var coords
= this._getMouseBufferCoords(event
);
4084 var start
= this._model
.finalSelectionStart
;
4085 var end
= this._model
.finalSelectionEnd
;
4086 if (!start
|| !end
) {
4089 return this._areCoordsInSelection(coords
, start
, end
);
4091 SelectionManager
.prototype._areCoordsInSelection = function (coords
, start
, end
) {
4092 return (coords
[1] > start
[1] && coords
[1] < end
[1]) ||
4093 (start
[1] === end
[1] && coords
[1] === start
[1] && coords
[0] >= start
[0] && coords
[0] < end
[0]) ||
4094 (start
[1] < end
[1] && coords
[1] === end
[1] && coords
[0] < end
[0]) ||
4095 (start
[1] < end
[1] && coords
[1] === start
[1] && coords
[0] >= start
[0]);
4097 SelectionManager
.prototype.selectWordAtCursor = function (event
) {
4098 var coords
= this._getMouseBufferCoords(event
);
4100 this._selectWordAt(coords
, false);
4101 this._model
.selectionEnd
= null;
4105 SelectionManager
.prototype.selectAll = function () {
4106 this._model
.isSelectAllActive
= true;
4108 this._onSelectionChange
.fire();
4110 SelectionManager
.prototype.selectLines = function (start
, end
) {
4111 this._model
.clearSelection();
4112 start
= Math
.max(start
, 0);
4113 end
= Math
.min(end
, this._terminal
.buffer
.lines
.length
- 1);
4114 this._model
.selectionStart
= [0, start
];
4115 this._model
.selectionEnd
= [this._terminal
.cols
, end
];
4117 this._onSelectionChange
.fire();
4119 SelectionManager
.prototype._onTrim = function (amount
) {
4120 var needsRefresh
= this._model
.onTrim(amount
);
4125 SelectionManager
.prototype._getMouseBufferCoords = function (event
) {
4126 var coords
= this._terminal
.mouseHelper
.getCoords(event
, this._terminal
.screenElement
, this._charMeasure
, this._terminal
.cols
, this._terminal
.rows
, true);
4132 coords
[1] += this._terminal
.buffer
.ydisp
;
4135 SelectionManager
.prototype._getMouseEventScrollAmount = function (event
) {
4136 var offset
= MouseHelper_1
.MouseHelper
.getCoordsRelativeToElement(event
, this._terminal
.screenElement
)[1];
4137 var terminalHeight
= this._terminal
.rows
* Math
.ceil(this._charMeasure
.height
* this._terminal
.options
.lineHeight
);
4138 if (offset
>= 0 && offset
<= terminalHeight
) {
4141 if (offset
> terminalHeight
) {
4142 offset
-= terminalHeight
;
4144 offset
= Math
.min(Math
.max(offset
, -DRAG_SCROLL_MAX_THRESHOLD
), DRAG_SCROLL_MAX_THRESHOLD
);
4145 offset
/= DRAG_SCROLL_MAX_THRESHOLD
;
4146 return (offset
/ Math
.abs(offset
)) + Math
.round(offset
* (DRAG_SCROLL_MAX_SPEED
- 1));
4148 SelectionManager
.prototype.shouldForceSelection = function (event
) {
4149 if (Browser
.isMac
) {
4150 return event
.altKey
&& this._terminal
.options
.macOptionClickForcesSelection
;
4152 return event
.shiftKey
;
4154 SelectionManager
.prototype.onMouseDown = function (event
) {
4155 this._mouseDownTimeStamp
= event
.timeStamp
;
4156 if (event
.button
=== 2 && this.hasSelection
) {
4159 if (event
.button
!== 0) {
4162 if (!this._enabled
) {
4163 if (!this.shouldForceSelection(event
)) {
4166 event
.stopPropagation();
4168 event
.preventDefault();
4169 this._dragScrollAmount
= 0;
4170 if (this._enabled
&& event
.shiftKey
) {
4171 this._onIncrementalClick(event
);
4174 if (event
.detail
=== 1) {
4175 this._onSingleClick(event
);
4177 else if (event
.detail
=== 2) {
4178 this._onDoubleClick(event
);
4180 else if (event
.detail
=== 3) {
4181 this._onTripleClick(event
);
4184 this._addMouseDownListeners();
4187 SelectionManager
.prototype._addMouseDownListeners = function () {
4189 this._terminal
.element
.ownerDocument
.addEventListener('mousemove', this._mouseMoveListener
);
4190 this._terminal
.element
.ownerDocument
.addEventListener('mouseup', this._mouseUpListener
);
4191 this._dragScrollIntervalTimer
= setInterval(function () { return _this
._dragScroll(); }, DRAG_SCROLL_INTERVAL
);
4193 SelectionManager
.prototype._removeMouseDownListeners = function () {
4194 if (this._terminal
.element
.ownerDocument
) {
4195 this._terminal
.element
.ownerDocument
.removeEventListener('mousemove', this._mouseMoveListener
);
4196 this._terminal
.element
.ownerDocument
.removeEventListener('mouseup', this._mouseUpListener
);
4198 clearInterval(this._dragScrollIntervalTimer
);
4199 this._dragScrollIntervalTimer
= null;
4201 SelectionManager
.prototype._onIncrementalClick = function (event
) {
4202 if (this._model
.selectionStart
) {
4203 this._model
.selectionEnd
= this._getMouseBufferCoords(event
);
4206 SelectionManager
.prototype._onSingleClick = function (event
) {
4207 this._model
.selectionStartLength
= 0;
4208 this._model
.isSelectAllActive
= false;
4209 this._activeSelectionMode
= this.shouldColumnSelect(event
) ? 3 : 0;
4210 this._model
.selectionStart
= this._getMouseBufferCoords(event
);
4211 if (!this._model
.selectionStart
) {
4214 this._model
.selectionEnd
= null;
4215 var line
= this._buffer
.lines
.get(this._model
.selectionStart
[1]);
4219 if (line
.length
>= this._model
.selectionStart
[0]) {
4222 if (line
.hasWidth(this._model
.selectionStart
[0]) === 0) {
4223 this._model
.selectionStart
[0]++;
4226 SelectionManager
.prototype._onDoubleClick = function (event
) {
4227 var coords
= this._getMouseBufferCoords(event
);
4229 this._activeSelectionMode
= 1;
4230 this._selectWordAt(coords
, true);
4233 SelectionManager
.prototype._onTripleClick = function (event
) {
4234 var coords
= this._getMouseBufferCoords(event
);
4236 this._activeSelectionMode
= 2;
4237 this._selectLineAt(coords
[1]);
4240 SelectionManager
.prototype.shouldColumnSelect = function (event
) {
4241 return event
.altKey
&& !(Browser
.isMac
&& this._terminal
.options
.macOptionClickForcesSelection
);
4243 SelectionManager
.prototype._onMouseMove = function (event
) {
4244 event
.stopImmediatePropagation();
4245 var previousSelectionEnd
= this._model
.selectionEnd
? [this._model
.selectionEnd
[0], this._model
.selectionEnd
[1]] : null;
4246 this._model
.selectionEnd
= this._getMouseBufferCoords(event
);
4247 if (!this._model
.selectionEnd
) {
4251 if (this._activeSelectionMode
=== 2) {
4252 if (this._model
.selectionEnd
[1] < this._model
.selectionStart
[1]) {
4253 this._model
.selectionEnd
[0] = 0;
4256 this._model
.selectionEnd
[0] = this._terminal
.cols
;
4259 else if (this._activeSelectionMode
=== 1) {
4260 this._selectToWordAt(this._model
.selectionEnd
);
4262 this._dragScrollAmount
= this._getMouseEventScrollAmount(event
);
4263 if (this._activeSelectionMode
!== 3) {
4264 if (this._dragScrollAmount
> 0) {
4265 this._model
.selectionEnd
[0] = this._terminal
.cols
;
4267 else if (this._dragScrollAmount
< 0) {
4268 this._model
.selectionEnd
[0] = 0;
4271 if (this._model
.selectionEnd
[1] < this._buffer
.lines
.length
) {
4272 if (this._buffer
.lines
.get(this._model
.selectionEnd
[1]).hasWidth(this._model
.selectionEnd
[0]) === 0) {
4273 this._model
.selectionEnd
[0]++;
4276 if (!previousSelectionEnd
||
4277 previousSelectionEnd
[0] !== this._model
.selectionEnd
[0] ||
4278 previousSelectionEnd
[1] !== this._model
.selectionEnd
[1]) {
4282 SelectionManager
.prototype._dragScroll = function () {
4283 if (this._dragScrollAmount
) {
4284 this._terminal
.scrollLines(this._dragScrollAmount
, false);
4285 if (this._dragScrollAmount
> 0) {
4286 if (this._activeSelectionMode
!== 3) {
4287 this._model
.selectionEnd
[0] = this._terminal
.cols
;
4289 this._model
.selectionEnd
[1] = Math
.min(this._terminal
.buffer
.ydisp
+ this._terminal
.rows
, this._terminal
.buffer
.lines
.length
- 1);
4292 if (this._activeSelectionMode
!== 3) {
4293 this._model
.selectionEnd
[0] = 0;
4295 this._model
.selectionEnd
[1] = this._terminal
.buffer
.ydisp
;
4300 SelectionManager
.prototype._onMouseUp = function (event
) {
4301 var timeElapsed
= event
.timeStamp
- this._mouseDownTimeStamp
;
4302 this._removeMouseDownListeners();
4303 if (this.selectionText
.length
<= 1 && timeElapsed
< ALT_CLICK_MOVE_CURSOR_TIME
) {
4304 (new AltClickHandler_1
.AltClickHandler(event
, this._terminal
)).move();
4306 else if (this.hasSelection
) {
4307 this._onSelectionChange
.fire();
4310 SelectionManager
.prototype._onBufferActivate = function (e
) {
4312 this.clearSelection();
4313 if (this._trimListener
) {
4314 this._trimListener
.dispose();
4316 this._trimListener
= e
.activeBuffer
.lines
.onTrim(function (amount
) { return _this
._onTrim(amount
); });
4318 SelectionManager
.prototype._convertViewportColToCharacterIndex = function (bufferLine
, coords
) {
4319 var charIndex
= coords
[0];
4320 for (var i
= 0; coords
[0] >= i
; i
++) {
4321 var length_1
= bufferLine
.loadCell(i
, this._workCell
).getChars().length
;
4322 if (this._workCell
.getWidth() === 0) {
4325 else if (length_1
> 1 && coords
[0] !== i
) {
4326 charIndex
+= length_1
- 1;
4331 SelectionManager
.prototype.setSelection = function (col
, row
, length
) {
4332 this._model
.clearSelection();
4333 this._removeMouseDownListeners();
4334 this._model
.selectionStart
= [col
, row
];
4335 this._model
.selectionStartLength
= length
;
4338 SelectionManager
.prototype._getWordAt = function (coords
, allowWhitespaceOnlySelection
, followWrappedLinesAbove
, followWrappedLinesBelow
) {
4339 if (followWrappedLinesAbove
=== void 0) { followWrappedLinesAbove
= true; }
4340 if (followWrappedLinesBelow
=== void 0) { followWrappedLinesBelow
= true; }
4341 if (coords
[0] >= this._terminal
.cols
) {
4344 var bufferLine
= this._buffer
.lines
.get(coords
[1]);
4348 var line
= this._buffer
.translateBufferLineToString(coords
[1], false);
4349 var startIndex
= this._convertViewportColToCharacterIndex(bufferLine
, coords
);
4350 var endIndex
= startIndex
;
4351 var charOffset
= coords
[0] - startIndex
;
4352 var leftWideCharCount
= 0;
4353 var rightWideCharCount
= 0;
4354 var leftLongCharOffset
= 0;
4355 var rightLongCharOffset
= 0;
4356 if (line
.charAt(startIndex
) === ' ') {
4357 while (startIndex
> 0 && line
.charAt(startIndex
- 1) === ' ') {
4360 while (endIndex
< line
.length
&& line
.charAt(endIndex
+ 1) === ' ') {
4365 var startCol
= coords
[0];
4366 var endCol
= coords
[0];
4367 if (bufferLine
.getWidth(startCol
) === 0) {
4368 leftWideCharCount
++;
4371 if (bufferLine
.getWidth(endCol
) === 2) {
4372 rightWideCharCount
++;
4375 var length_2
= bufferLine
.getString(endCol
).length
;
4377 rightLongCharOffset
+= length_2
- 1;
4378 endIndex
+= length_2
- 1;
4380 while (startCol
> 0 && startIndex
> 0 && !this._isCharWordSeparator(bufferLine
.loadCell(startCol
- 1, this._workCell
))) {
4381 bufferLine
.loadCell(startCol
- 1, this._workCell
);
4382 var length_3
= this._workCell
.getChars().length
;
4383 if (this._workCell
.getWidth() === 0) {
4384 leftWideCharCount
++;
4387 else if (length_3
> 1) {
4388 leftLongCharOffset
+= length_3
- 1;
4389 startIndex
-= length_3
- 1;
4394 while (endCol
< bufferLine
.length
&& endIndex
+ 1 < line
.length
&& !this._isCharWordSeparator(bufferLine
.loadCell(endCol
+ 1, this._workCell
))) {
4395 bufferLine
.loadCell(endCol
+ 1, this._workCell
);
4396 var length_4
= this._workCell
.getChars().length
;
4397 if (this._workCell
.getWidth() === 2) {
4398 rightWideCharCount
++;
4401 else if (length_4
> 1) {
4402 rightLongCharOffset
+= length_4
- 1;
4403 endIndex
+= length_4
- 1;
4410 var start
= startIndex
4413 + leftLongCharOffset
;
4414 var length
= Math
.min(this._terminal
.cols
, endIndex
4417 + rightWideCharCount
4418 - leftLongCharOffset
4419 - rightLongCharOffset
);
4420 if (!allowWhitespaceOnlySelection
&& line
.slice(startIndex
, endIndex
).trim() === '') {
4423 if (followWrappedLinesAbove
) {
4424 if (start
=== 0 && bufferLine
.getCodePoint(0) !== 32) {
4425 var previousBufferLine
= this._buffer
.lines
.get(coords
[1] - 1);
4426 if (previousBufferLine
&& bufferLine
.isWrapped
&& previousBufferLine
.getCodePoint(this._terminal
.cols
- 1) !== 32) {
4427 var previousLineWordPosition
= this._getWordAt([this._terminal
.cols
- 1, coords
[1] - 1], false, true, false);
4428 if (previousLineWordPosition
) {
4429 var offset
= this._terminal
.cols
- previousLineWordPosition
.start
;
4436 if (followWrappedLinesBelow
) {
4437 if (start
+ length
=== this._terminal
.cols
&& bufferLine
.getCodePoint(this._terminal
.cols
- 1) !== 32) {
4438 var nextBufferLine
= this._buffer
.lines
.get(coords
[1] + 1);
4439 if (nextBufferLine
&& nextBufferLine
.isWrapped
&& nextBufferLine
.getCodePoint(0) !== 32) {
4440 var nextLineWordPosition
= this._getWordAt([0, coords
[1] + 1], false, false, true);
4441 if (nextLineWordPosition
) {
4442 length
+= nextLineWordPosition
.length
;
4447 return { start
: start
, length
: length
};
4449 SelectionManager
.prototype._selectWordAt = function (coords
, allowWhitespaceOnlySelection
) {
4450 var wordPosition
= this._getWordAt(coords
, allowWhitespaceOnlySelection
);
4452 while (wordPosition
.start
< 0) {
4453 wordPosition
.start
+= this._terminal
.cols
;
4456 this._model
.selectionStart
= [wordPosition
.start
, coords
[1]];
4457 this._model
.selectionStartLength
= wordPosition
.length
;
4460 SelectionManager
.prototype._selectToWordAt = function (coords
) {
4461 var wordPosition
= this._getWordAt(coords
, true);
4463 var endRow
= coords
[1];
4464 while (wordPosition
.start
< 0) {
4465 wordPosition
.start
+= this._terminal
.cols
;
4468 if (!this._model
.areSelectionValuesReversed()) {
4469 while (wordPosition
.start
+ wordPosition
.length
> this._terminal
.cols
) {
4470 wordPosition
.length
-= this._terminal
.cols
;
4474 this._model
.selectionEnd
= [this._model
.areSelectionValuesReversed() ? wordPosition
.start
: wordPosition
.start
+ wordPosition
.length
, endRow
];
4477 SelectionManager
.prototype._isCharWordSeparator = function (cell
) {
4478 if (cell
.getWidth() === 0) {
4481 return WORD_SEPARATORS
.indexOf(cell
.getChars()) >= 0;
4483 SelectionManager
.prototype._selectLineAt = function (line
) {
4484 var wrappedRange
= this._buffer
.getWrappedRangeForLine(line
);
4485 this._model
.selectionStart
= [0, wrappedRange
.first
];
4486 this._model
.selectionEnd
= [this._terminal
.cols
, wrappedRange
.last
];
4487 this._model
.selectionStartLength
= 0;
4489 return SelectionManager
;
4491 exports
.SelectionManager
= SelectionManager
;
4493 },{"./BufferLine":3,"./MouseHelper":13,"./SelectionModel":16,"./common/EventEmitter2":25,"./common/Platform":27,"./handlers/AltClickHandler":33}],16:[function(require
,module
,exports
){
4495 Object
.defineProperty(exports
, "__esModule", { value
: true });
4496 var SelectionModel
= (function () {
4497 function SelectionModel(_terminal
) {
4498 this._terminal
= _terminal
;
4499 this.clearSelection();
4501 SelectionModel
.prototype.clearSelection = function () {
4502 this.selectionStart
= null;
4503 this.selectionEnd
= null;
4504 this.isSelectAllActive
= false;
4505 this.selectionStartLength
= 0;
4507 Object
.defineProperty(SelectionModel
.prototype, "finalSelectionStart", {
4509 if (this.isSelectAllActive
) {
4512 if (!this.selectionEnd
|| !this.selectionStart
) {
4513 return this.selectionStart
;
4515 return this.areSelectionValuesReversed() ? this.selectionEnd
: this.selectionStart
;
4520 Object
.defineProperty(SelectionModel
.prototype, "finalSelectionEnd", {
4522 if (this.isSelectAllActive
) {
4523 return [this._terminal
.cols
, this._terminal
.buffer
.ybase
+ this._terminal
.rows
- 1];
4525 if (!this.selectionStart
) {
4528 if (!this.selectionEnd
|| this.areSelectionValuesReversed()) {
4529 var startPlusLength
= this.selectionStart
[0] + this.selectionStartLength
;
4530 if (startPlusLength
> this._terminal
.cols
) {
4531 return [startPlusLength
% this._terminal
.cols
, this.selectionStart
[1] + Math
.floor(startPlusLength
/ this._terminal
.cols
)];
4533 return [startPlusLength
, this.selectionStart
[1]];
4535 if (this.selectionStartLength
) {
4536 if (this.selectionEnd
[1] === this.selectionStart
[1]) {
4537 return [Math
.max(this.selectionStart
[0] + this.selectionStartLength
, this.selectionEnd
[0]), this.selectionEnd
[1]];
4540 return this.selectionEnd
;
4545 SelectionModel
.prototype.areSelectionValuesReversed = function () {
4546 var start
= this.selectionStart
;
4547 var end
= this.selectionEnd
;
4548 if (!start
|| !end
) {
4551 return start
[1] > end
[1] || (start
[1] === end
[1] && start
[0] > end
[0]);
4553 SelectionModel
.prototype.onTrim = function (amount
) {
4554 if (this.selectionStart
) {
4555 this.selectionStart
[1] -= amount
;
4557 if (this.selectionEnd
) {
4558 this.selectionEnd
[1] -= amount
;
4560 if (this.selectionEnd
&& this.selectionEnd
[1] < 0) {
4561 this.clearSelection();
4564 if (this.selectionStart
&& this.selectionStart
[1] < 0) {
4565 this.selectionStart
[1] = 0;
4569 return SelectionModel
;
4571 exports
.SelectionModel
= SelectionModel
;
4573 },{}],17:[function(require
,module
,exports
){
4575 Object
.defineProperty(exports
, "__esModule", { value
: true });
4576 exports
.DEFAULT_BELL_SOUND
= 'data:audio/wav;base64,UklGRigBAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQBAADpAFgCwAMlBZoG/wdmCcoKRAypDQ8PbRDBEQQTOxRtFYcWlBePGIUZXhoiG88bcBz7HHIdzh0WHlMeZx51HmkeUx4WHs8dah0AHXwc3hs9G4saxRnyGBIYGBcQFv8U4RPAEoYRQBACD70NWwwHC6gJOwjWBloF7gOBAhABkf8b/qv8R/ve+Xf4Ife79W/0JfPZ8Z/wde9N7ijtE+wU6xvqM+lb6H7nw+YX5mrlxuQz5Mzje+Ma49fioeKD4nXiYeJy4pHitOL04j/jn+MN5IPkFOWs5U3mDefM55/ogOl36m7rdOyE7abuyu8D8Unyj/Pg9D/2qfcb+Yn6/vuK/Qj/lAAlAg==';
4577 var SoundManager
= (function () {
4578 function SoundManager(_terminal
) {
4579 this._terminal
= _terminal
;
4581 Object
.defineProperty(SoundManager
, "audioContext", {
4583 if (!SoundManager
._audioContext
) {
4584 var audioContextCtor
= window
.AudioContext
|| window
.webkitAudioContext
;
4585 if (!audioContextCtor
) {
4586 console
.warn('Web Audio API is not supported by this browser. Consider upgrading to the latest version');
4589 SoundManager
._audioContext
= new audioContextCtor();
4591 return SoundManager
._audioContext
;
4596 SoundManager
.prototype.playBellSound = function () {
4597 var ctx
= SoundManager
.audioContext
;
4601 var bellAudioSource
= ctx
.createBufferSource();
4602 ctx
.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._terminal
.options
.bellSound
)), function (buffer
) {
4603 bellAudioSource
.buffer
= buffer
;
4604 bellAudioSource
.connect(ctx
.destination
);
4605 bellAudioSource
.start(0);
4608 SoundManager
.prototype._base64ToArrayBuffer = function (base64
) {
4609 var binaryString
= window
.atob(base64
);
4610 var len
= binaryString
.length
;
4611 var bytes
= new Uint8Array(len
);
4612 for (var i
= 0; i
< len
; i
++) {
4613 bytes
[i
] = binaryString
.charCodeAt(i
);
4615 return bytes
.buffer
;
4617 SoundManager
.prototype._removeMimeType = function (dataURI
) {
4618 var splitUri
= dataURI
.split(',');
4621 return SoundManager
;
4623 exports
.SoundManager
= SoundManager
;
4625 },{}],18:[function(require
,module
,exports
){
4627 Object
.defineProperty(exports
, "__esModule", { value
: true });
4628 exports
.blankLine
= 'Blank line';
4629 exports
.promptLabel
= 'Terminal input';
4630 exports
.tooMuchOutput
= 'Too much output to announce, navigate to rows manually to read';
4632 },{}],19:[function(require
,module
,exports
){
4634 var __extends
= (this && this.__extends
) || (function () {
4635 var extendStatics = function (d
, b
) {
4636 extendStatics
= Object
.setPrototypeOf
||
4637 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
4638 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
4639 return extendStatics(d
, b
);
4641 return function (d
, b
) {
4642 extendStatics(d
, b
);
4643 function __() { this.constructor = d
; }
4644 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
4647 Object
.defineProperty(exports
, "__esModule", { value
: true });
4648 var BufferSet_1
= require("./BufferSet");
4649 var Buffer_1
= require("./Buffer");
4650 var CompositionHelper_1
= require("./CompositionHelper");
4651 var EventEmitter_1
= require("./common/EventEmitter");
4652 var Viewport_1
= require("./Viewport");
4653 var Clipboard_1
= require("./Clipboard");
4654 var EscapeSequences_1
= require("./common/data/EscapeSequences");
4655 var InputHandler_1
= require("./InputHandler");
4656 var Renderer_1
= require("./renderer/Renderer");
4657 var Linkifier_1
= require("./Linkifier");
4658 var SelectionManager_1
= require("./SelectionManager");
4659 var CharMeasure_1
= require("./CharMeasure");
4660 var Browser
= require("./common/Platform");
4661 var Lifecycle_1
= require("./ui/Lifecycle");
4662 var Strings
= require("./Strings");
4663 var MouseHelper_1
= require("./MouseHelper");
4664 var SoundManager_1
= require("./SoundManager");
4665 var MouseZoneManager_1
= require("./MouseZoneManager");
4666 var AccessibilityManager_1
= require("./AccessibilityManager");
4667 var ScreenDprMonitor_1
= require("./ui/ScreenDprMonitor");
4668 var CharAtlasCache_1
= require("./renderer/atlas/CharAtlasCache");
4669 var DomRenderer_1
= require("./renderer/dom/DomRenderer");
4670 var Keyboard_1
= require("./core/input/Keyboard");
4671 var Clone_1
= require("./common/Clone");
4672 var EventEmitter2_1
= require("./common/EventEmitter2");
4673 var WindowsMode_1
= require("./WindowsMode");
4674 var document
= (typeof window
!== 'undefined') ? window
.document
: null;
4675 var WRITE_BUFFER_PAUSE_THRESHOLD
= 5;
4676 var WRITE_TIMEOUT_MS
= 12;
4677 var MINIMUM_COLS
= 2;
4678 var MINIMUM_ROWS
= 1;
4679 var CONSTRUCTOR_ONLY_OPTIONS
= ['cols', 'rows'];
4680 var DEFAULT_OPTIONS
= {
4686 cursorStyle
: 'block',
4687 bellSound
: SoundManager_1
.DEFAULT_BELL_SOUND
,
4689 drawBoldTextInBrightColors
: true,
4691 experimentalCharAtlas
: 'static',
4692 fontFamily
: 'courier-new, courier, monospace',
4694 fontWeight
: 'normal',
4695 fontWeightBold
: 'bold',
4700 screenReaderMode
: false,
4702 macOptionIsMeta
: false,
4703 macOptionClickForcesSelection
: false,
4704 cancelEvents
: false,
4705 disableStdin
: false,
4706 useFlowControl
: false,
4707 allowTransparency
: false,
4710 rightClickSelectsWord
: Browser
.isMac
,
4711 rendererType
: 'canvas',
4714 var Terminal
= (function (_super
) {
4715 __extends(Terminal
, _super
);
4716 function Terminal(options
) {
4717 if (options
=== void 0) { options
= {}; }
4718 var _this
= _super
.call(this) || this;
4719 _this
.browser
= Browser
;
4720 _this
._blankLine
= null;
4721 _this
._onCursorMove
= new EventEmitter2_1
.EventEmitter2();
4722 _this
._onData
= new EventEmitter2_1
.EventEmitter2();
4723 _this
._onKey
= new EventEmitter2_1
.EventEmitter2();
4724 _this
._onLineFeed
= new EventEmitter2_1
.EventEmitter2();
4725 _this
._onRender
= new EventEmitter2_1
.EventEmitter2();
4726 _this
._onResize
= new EventEmitter2_1
.EventEmitter2();
4727 _this
._onScroll
= new EventEmitter2_1
.EventEmitter2();
4728 _this
._onSelectionChange
= new EventEmitter2_1
.EventEmitter2();
4729 _this
._onTitleChange
= new EventEmitter2_1
.EventEmitter2();
4730 _this
.options
= Clone_1
.clone(options
);
4732 _this
.onCursorMove(function () { return _this
.emit('cursormove'); });
4733 _this
.onData(function (e
) { return _this
.emit('data', e
); });
4734 _this
.onKey(function (e
) { return _this
.emit('key', e
.key
, e
.domEvent
); });
4735 _this
.onLineFeed(function () { return _this
.emit('linefeed'); });
4736 _this
.onRender(function (e
) { return _this
.emit('refresh', e
); });
4737 _this
.onResize(function (e
) { return _this
.emit('resize', e
); });
4738 _this
.onSelectionChange(function () { return _this
.emit('selection'); });
4739 _this
.onScroll(function (e
) { return _this
.emit('scroll', e
); });
4740 _this
.onTitleChange(function (e
) { return _this
.emit('title', e
); });
4743 Object
.defineProperty(Terminal
.prototype, "onCursorMove", {
4744 get: function () { return this._onCursorMove
.event
; },
4748 Object
.defineProperty(Terminal
.prototype, "onData", {
4749 get: function () { return this._onData
.event
; },
4753 Object
.defineProperty(Terminal
.prototype, "onKey", {
4754 get: function () { return this._onKey
.event
; },
4758 Object
.defineProperty(Terminal
.prototype, "onLineFeed", {
4759 get: function () { return this._onLineFeed
.event
; },
4763 Object
.defineProperty(Terminal
.prototype, "onRender", {
4764 get: function () { return this._onRender
.event
; },
4768 Object
.defineProperty(Terminal
.prototype, "onResize", {
4769 get: function () { return this._onResize
.event
; },
4773 Object
.defineProperty(Terminal
.prototype, "onScroll", {
4774 get: function () { return this._onScroll
.event
; },
4778 Object
.defineProperty(Terminal
.prototype, "onSelectionChange", {
4779 get: function () { return this._onSelectionChange
.event
; },
4783 Object
.defineProperty(Terminal
.prototype, "onTitleChange", {
4784 get: function () { return this._onTitleChange
.event
; },
4788 Terminal
.prototype.dispose = function () {
4789 _super
.prototype.dispose
.call(this);
4790 if (this._windowsMode
) {
4791 this._windowsMode
.dispose();
4792 this._windowsMode
= undefined;
4794 this._customKeyEventHandler
= null;
4795 CharAtlasCache_1
.removeTerminalFromCache(this);
4796 this.handler = function () { };
4797 this.write = function () { };
4798 if (this.element
&& this.element
.parentNode
) {
4799 this.element
.parentNode
.removeChild(this.element
);
4802 Terminal
.prototype.destroy = function () {
4805 Terminal
.prototype._setup = function () {
4807 Object
.keys(DEFAULT_OPTIONS
).forEach(function (key
) {
4808 if (_this
.options
[key
] === null || _this
.options
[key
] === undefined) {
4809 _this
.options
[key
] = DEFAULT_OPTIONS
[key
];
4812 this._parent
= document
? document
.body
: null;
4813 this.cols
= Math
.max(this.options
.cols
, MINIMUM_COLS
);
4814 this.rows
= Math
.max(this.options
.rows
, MINIMUM_ROWS
);
4815 if (this.options
.handler
) {
4816 this.onData(this.options
.handler
);
4818 this.cursorState
= 0;
4819 this.cursorHidden
= false;
4820 this._customKeyEventHandler
= null;
4821 this.applicationKeypad
= false;
4822 this.applicationCursor
= false;
4823 this.originMode
= false;
4824 this.insertMode
= false;
4825 this.wraparoundMode
= true;
4826 this.bracketedPasteMode
= false;
4827 this.charset
= null;
4828 this.gcharset
= null;
4830 this.charsets
= [null];
4831 this.curAttrData
= Buffer_1
.DEFAULT_ATTR_DATA
.clone();
4832 this._eraseAttrData
= Buffer_1
.DEFAULT_ATTR_DATA
.clone();
4834 this.currentParam
= 0;
4835 this.writeBuffer
= [];
4836 this._writeInProgress
= false;
4837 this._xoffSentToCatchUp
= false;
4838 this._userScrolling
= false;
4839 this._inputHandler
= new InputHandler_1
.InputHandler(this);
4840 this._inputHandler
.onCursorMove(function () { return _this
._onCursorMove
.fire(); });
4841 this._inputHandler
.onLineFeed(function () { return _this
._onLineFeed
.fire(); });
4842 this._inputHandler
.onData(function (e
) { return _this
._onData
.fire(e
); });
4843 this.register(this._inputHandler
);
4844 this.renderer
= this.renderer
|| null;
4845 this.selectionManager
= this.selectionManager
|| null;
4846 this.linkifier
= this.linkifier
|| new Linkifier_1
.Linkifier(this);
4847 this._mouseZoneManager
= this._mouseZoneManager
|| null;
4848 this.soundManager
= this.soundManager
|| new SoundManager_1
.SoundManager(this);
4849 this.buffers
= new BufferSet_1
.BufferSet(this);
4850 if (this.selectionManager
) {
4851 this.selectionManager
.clearSelection();
4852 this.selectionManager
.initBuffersListeners();
4854 if (this.options
.windowsMode
) {
4855 this._windowsMode
= WindowsMode_1
.applyWindowsMode(this);
4858 Object
.defineProperty(Terminal
.prototype, "buffer", {
4860 return this.buffers
.active
;
4865 Terminal
.prototype.eraseAttrData = function () {
4866 this._eraseAttrData
.bg
&= ~(50331648 | 0xFFFFFF);
4867 this._eraseAttrData
.bg
|= this.curAttrData
.bg
& ~0xFC000000;
4868 return this._eraseAttrData
;
4870 Terminal
.prototype.focus = function () {
4871 if (this.textarea
) {
4872 this.textarea
.focus({ preventScroll
: true });
4875 Object
.defineProperty(Terminal
.prototype, "isFocused", {
4877 return document
.activeElement
=== this.textarea
&& document
.hasFocus();
4882 Terminal
.prototype.getOption = function (key
) {
4883 if (!(key
in DEFAULT_OPTIONS
)) {
4884 throw new Error('No option with key "' + key
+ '"');
4886 return this.options
[key
];
4888 Terminal
.prototype.setOption = function (key
, value
) {
4889 if (!(key
in DEFAULT_OPTIONS
)) {
4890 throw new Error('No option with key "' + key
+ '"');
4892 if (CONSTRUCTOR_ONLY_OPTIONS
.indexOf(key
) !== -1) {
4893 console
.error("Option \"" + key
+ "\" can only be set in the constructor");
4895 if (this.options
[key
] === value
) {
4914 case 'fontWeightBold':
4921 console
.warn(key
+ " cannot be less than 1, value: " + value
);
4924 case 'rendererType':
4929 case 'tabStopWidth':
4931 console
.warn(key
+ " cannot be less than 1, value: " + value
);
4936 if (this.renderer
) {
4937 this._setTheme(value
);
4942 value
= Math
.min(value
, Buffer_1
.MAX_BUFFER_SIZE
);
4944 console
.warn(key
+ " cannot be less than 0, value: " + value
);
4947 if (this.options
[key
] !== value
) {
4948 var newBufferLength
= this.rows
+ value
;
4949 if (this.buffer
.lines
.length
> newBufferLength
) {
4950 var amountToTrim
= this.buffer
.lines
.length
- newBufferLength
;
4951 var needsRefresh
= (this.buffer
.ydisp
- amountToTrim
< 0);
4952 this.buffer
.lines
.trimStart(amountToTrim
);
4953 this.buffer
.ybase
= Math
.max(this.buffer
.ybase
- amountToTrim
, 0);
4954 this.buffer
.ydisp
= Math
.max(this.buffer
.ydisp
- amountToTrim
, 0);
4956 this.refresh(0, this.rows
- 1);
4962 this.options
[key
] = value
;
4966 if (this.renderer
) {
4967 this.renderer
.clear();
4968 this.charMeasure
.measure(this.options
);
4971 case 'drawBoldTextInBrightColors':
4972 case 'experimentalCharAtlas':
4974 case 'letterSpacing':
4977 case 'fontWeightBold':
4978 if (this.renderer
) {
4979 this.renderer
.clear();
4980 this.renderer
.onResize(this.cols
, this.rows
);
4981 this.refresh(0, this.rows
- 1);
4984 case 'rendererType':
4985 if (this.renderer
) {
4986 this.unregister(this.renderer
);
4987 this.renderer
.dispose();
4988 this.renderer
= null;
4990 this._setupRenderer();
4991 this.renderer
.onCharSizeChanged();
4993 this.renderer
.setTheme(this._theme
);
4995 this.mouseHelper
.setRenderer(this.renderer
);
4998 this.buffers
.resize(this.cols
, this.rows
);
4999 if (this.viewport
) {
5000 this.viewport
.syncScrollArea();
5003 case 'screenReaderMode':
5005 if (!this._accessibilityManager
) {
5006 this._accessibilityManager
= new AccessibilityManager_1
.AccessibilityManager(this);
5010 if (this._accessibilityManager
) {
5011 this._accessibilityManager
.dispose();
5012 this._accessibilityManager
= null;
5016 case 'tabStopWidth':
5017 this.buffers
.setupTabStops();
5021 if (!this._windowsMode
) {
5022 this._windowsMode
= WindowsMode_1
.applyWindowsMode(this);
5026 if (this._windowsMode
) {
5027 this._windowsMode
.dispose();
5028 this._windowsMode
= undefined;
5033 if (this.renderer
) {
5034 this.renderer
.onOptionsChanged();
5037 Terminal
.prototype._onTextAreaFocus = function (ev
) {
5038 if (this.sendFocus
) {
5039 this.handler(EscapeSequences_1
.C0
.ESC
+ '[I');
5041 this.updateCursorStyle(ev
);
5042 this.element
.classList
.add('focus');
5046 Terminal
.prototype.blur = function () {
5047 return this.textarea
.blur();
5049 Terminal
.prototype._onTextAreaBlur = function () {
5050 this.textarea
.value
= '';
5051 this.refresh(this.buffer
.y
, this.buffer
.y
);
5052 if (this.sendFocus
) {
5053 this.handler(EscapeSequences_1
.C0
.ESC
+ '[O');
5055 this.element
.classList
.remove('focus');
5058 Terminal
.prototype._initGlobal = function () {
5061 this.register(Lifecycle_1
.addDisposableDomListener(this.element
, 'copy', function (event
) {
5062 if (!_this
.hasSelection()) {
5065 Clipboard_1
.copyHandler(event
, _this
, _this
.selectionManager
);
5067 var pasteHandlerWrapper = function (event
) { return Clipboard_1
.pasteHandler(event
, _this
); };
5068 this.register(Lifecycle_1
.addDisposableDomListener(this.textarea
, 'paste', pasteHandlerWrapper
));
5069 this.register(Lifecycle_1
.addDisposableDomListener(this.element
, 'paste', pasteHandlerWrapper
));
5070 if (Browser
.isFirefox
) {
5071 this.register(Lifecycle_1
.addDisposableDomListener(this.element
, 'mousedown', function (event
) {
5072 if (event
.button
=== 2) {
5073 Clipboard_1
.rightClickHandler(event
, _this
, _this
.selectionManager
, _this
.options
.rightClickSelectsWord
);
5078 this.register(Lifecycle_1
.addDisposableDomListener(this.element
, 'contextmenu', function (event
) {
5079 Clipboard_1
.rightClickHandler(event
, _this
, _this
.selectionManager
, _this
.options
.rightClickSelectsWord
);
5082 if (Browser
.isLinux
) {
5083 this.register(Lifecycle_1
.addDisposableDomListener(this.element
, 'auxclick', function (event
) {
5084 if (event
.button
=== 1) {
5085 Clipboard_1
.moveTextAreaUnderMouseCursor(event
, _this
);
5090 Terminal
.prototype._bindKeys = function () {
5093 this.register(Lifecycle_1
.addDisposableDomListener(this.element
, 'keydown', function (ev
) {
5094 if (document
.activeElement
!== this) {
5099 this.register(Lifecycle_1
.addDisposableDomListener(this.element
, 'keypress', function (ev
) {
5100 if (document
.activeElement
!== this) {
5105 this.register(Lifecycle_1
.addDisposableDomListener(this.element
, 'keyup', function (ev
) {
5106 if (!wasModifierKeyOnlyEvent(ev
)) {
5111 this.register(Lifecycle_1
.addDisposableDomListener(this.textarea
, 'keydown', function (ev
) { return _this
._keyDown(ev
); }, true));
5112 this.register(Lifecycle_1
.addDisposableDomListener(this.textarea
, 'keypress', function (ev
) { return _this
._keyPress(ev
); }, true));
5113 this.register(Lifecycle_1
.addDisposableDomListener(this.textarea
, 'compositionstart', function () { return _this
._compositionHelper
.compositionstart(); }));
5114 this.register(Lifecycle_1
.addDisposableDomListener(this.textarea
, 'compositionupdate', function (e
) { return _this
._compositionHelper
.compositionupdate(e
); }));
5115 this.register(Lifecycle_1
.addDisposableDomListener(this.textarea
, 'compositionend', function () { return _this
._compositionHelper
.compositionend(); }));
5116 this.register(this.onRender(function () { return _this
._compositionHelper
.updateCompositionElements(); }));
5117 this.register(this.onRender(function (e
) { return _this
._queueLinkification(e
.start
, e
.end
); }));
5119 Terminal
.prototype.open = function (parent
) {
5121 this._parent
= parent
|| this._parent
;
5122 if (!this._parent
) {
5123 throw new Error('Terminal requires a parent element.');
5125 this._context
= this._parent
.ownerDocument
.defaultView
;
5126 this._document
= this._parent
.ownerDocument
;
5127 this._screenDprMonitor
= new ScreenDprMonitor_1
.ScreenDprMonitor();
5128 this._screenDprMonitor
.setListener(function () { return _this
.emit('dprchange', window
.devicePixelRatio
); });
5129 this.register(this._screenDprMonitor
);
5130 this.element
= this._document
.createElement('div');
5131 this.element
.dir
= 'ltr';
5132 this.element
.classList
.add('terminal');
5133 this.element
.classList
.add('xterm');
5134 this.element
.setAttribute('tabindex', '0');
5135 this._parent
.appendChild(this.element
);
5136 var fragment
= document
.createDocumentFragment();
5137 this._viewportElement
= document
.createElement('div');
5138 this._viewportElement
.classList
.add('xterm-viewport');
5139 fragment
.appendChild(this._viewportElement
);
5140 this._viewportScrollArea
= document
.createElement('div');
5141 this._viewportScrollArea
.classList
.add('xterm-scroll-area');
5142 this._viewportElement
.appendChild(this._viewportScrollArea
);
5143 this.screenElement
= document
.createElement('div');
5144 this.screenElement
.classList
.add('xterm-screen');
5145 this._helperContainer
= document
.createElement('div');
5146 this._helperContainer
.classList
.add('xterm-helpers');
5147 this.screenElement
.appendChild(this._helperContainer
);
5148 fragment
.appendChild(this.screenElement
);
5149 this._mouseZoneManager
= new MouseZoneManager_1
.MouseZoneManager(this);
5150 this.register(this._mouseZoneManager
);
5151 this.register(this.onScroll(function () { return _this
._mouseZoneManager
.clearAll(); }));
5152 this.linkifier
.attachToDom(this._mouseZoneManager
);
5153 this.textarea
= document
.createElement('textarea');
5154 this.textarea
.classList
.add('xterm-helper-textarea');
5155 this.textarea
.setAttribute('aria-label', Strings
.promptLabel
);
5156 this.textarea
.setAttribute('aria-multiline', 'false');
5157 this.textarea
.setAttribute('autocorrect', 'off');
5158 this.textarea
.setAttribute('autocapitalize', 'off');
5159 this.textarea
.setAttribute('spellcheck', 'false');
5160 this.textarea
.tabIndex
= 0;
5161 this.register(Lifecycle_1
.addDisposableDomListener(this.textarea
, 'focus', function (ev
) { return _this
._onTextAreaFocus(ev
); }));
5162 this.register(Lifecycle_1
.addDisposableDomListener(this.textarea
, 'blur', function () { return _this
._onTextAreaBlur(); }));
5163 this._helperContainer
.appendChild(this.textarea
);
5164 this._compositionView
= document
.createElement('div');
5165 this._compositionView
.classList
.add('composition-view');
5166 this._compositionHelper
= new CompositionHelper_1
.CompositionHelper(this.textarea
, this._compositionView
, this);
5167 this._helperContainer
.appendChild(this._compositionView
);
5168 this.charMeasure
= new CharMeasure_1
.CharMeasure(document
, this._helperContainer
);
5169 this.element
.appendChild(fragment
);
5170 this._setupRenderer();
5171 this._theme
= this.options
.theme
;
5172 this.options
.theme
= null;
5173 this.viewport
= new Viewport_1
.Viewport(this, this._viewportElement
, this._viewportScrollArea
, this.charMeasure
);
5174 this.viewport
.onThemeChanged(this.renderer
.colorManager
.colors
);
5175 this.register(this.viewport
);
5176 this.register(this.onCursorMove(function () { return _this
.renderer
.onCursorMove(); }));
5177 this.register(this.onResize(function () { return _this
.renderer
.onResize(_this
.cols
, _this
.rows
); }));
5178 this.register(this.addDisposableListener('blur', function () { return _this
.renderer
.onBlur(); }));
5179 this.register(this.addDisposableListener('focus', function () { return _this
.renderer
.onFocus(); }));
5180 this.register(this.addDisposableListener('dprchange', function () { return _this
.renderer
.onWindowResize(window
.devicePixelRatio
); }));
5181 this.register(Lifecycle_1
.addDisposableDomListener(window
, 'resize', function () { return _this
.renderer
.onWindowResize(window
.devicePixelRatio
); }));
5182 this.register(this.charMeasure
.onCharSizeChanged(function () { return _this
.renderer
.onCharSizeChanged(); }));
5183 this.register(this.renderer
.onCanvasResize(function () { return _this
.viewport
.syncScrollArea(); }));
5184 this.selectionManager
= new SelectionManager_1
.SelectionManager(this, this.charMeasure
);
5185 this.register(this.selectionManager
.onSelectionChange(function () { return _this
._onSelectionChange
.fire(); }));
5186 this.register(Lifecycle_1
.addDisposableDomListener(this.element
, 'mousedown', function (e
) { return _this
.selectionManager
.onMouseDown(e
); }));
5187 this.register(this.selectionManager
.onRedrawRequest(function (e
) { return _this
.renderer
.onSelectionChanged(e
.start
, e
.end
, e
.columnSelectMode
); }));
5188 this.register(this.selectionManager
.onLinuxMouseSelection(function (text
) {
5189 _this
.textarea
.value
= text
;
5190 _this
.textarea
.focus();
5191 _this
.textarea
.select();
5193 this.register(this.onScroll(function () {
5194 _this
.viewport
.syncScrollArea();
5195 _this
.selectionManager
.refresh();
5197 this.register(Lifecycle_1
.addDisposableDomListener(this._viewportElement
, 'scroll', function () { return _this
.selectionManager
.refresh(); }));
5198 this.mouseHelper
= new MouseHelper_1
.MouseHelper(this.renderer
);
5199 this.element
.classList
.toggle('enable-mouse-events', this.mouseEvents
);
5200 if (this.mouseEvents
) {
5201 this.selectionManager
.disable();
5204 this.selectionManager
.enable();
5206 if (this.options
.screenReaderMode
) {
5207 this._accessibilityManager
= new AccessibilityManager_1
.AccessibilityManager(this);
5209 this.charMeasure
.measure(this.options
);
5210 this.refresh(0, this.rows
- 1);
5214 Terminal
.prototype._setupRenderer = function () {
5216 switch (this.options
.rendererType
) {
5218 this.renderer
= new Renderer_1
.Renderer(this, this.options
.theme
);
5221 this.renderer
= new DomRenderer_1
.DomRenderer(this, this.options
.theme
);
5223 default: throw new Error("Unrecognized rendererType \"" + this.options
.rendererType
+ "\"");
5225 this.renderer
.onRender(function (e
) { return _this
._onRender
.fire(e
); });
5226 this.register(this.renderer
);
5228 Terminal
.prototype._setTheme = function (theme
) {
5229 this._theme
= theme
;
5230 var colors
= this.renderer
.setTheme(theme
);
5231 if (this.viewport
) {
5232 this.viewport
.onThemeChanged(colors
);
5235 Terminal
.prototype.bindMouse = function () {
5237 var el
= this.element
;
5240 function sendButton(ev
) {
5243 button
= getButton(ev
);
5244 pos
= self
.mouseHelper
.getRawByteCoords(ev
, self
.screenElement
, self
.charMeasure
, self
.cols
, self
.rows
);
5247 sendEvent(button
, pos
);
5248 switch (ev
.overrideType
|| ev
.type
) {
5259 function sendMove(ev
) {
5260 var button
= pressed
;
5261 var pos
= self
.mouseHelper
.getRawByteCoords(ev
, self
.screenElement
, self
.charMeasure
, self
.cols
, self
.rows
);
5265 sendEvent(button
, pos
);
5267 function encode(data
, ch
) {
5268 if (!self
.utfMouse
) {
5285 function sendEvent(button
, pos
) {
5286 if (self
._vt300Mouse
) {
5290 var data_1
= EscapeSequences_1
.C0
.ESC
+ '[24';
5293 else if (button
=== 1)
5295 else if (button
=== 2)
5297 else if (button
=== 3)
5301 data_1
+= '~[' + pos
.x
+ ',' + pos
.y
+ ']\r';
5302 self
.handler(data_1
);
5305 if (self
._decLocator
) {
5311 else if (button
=== 1)
5313 else if (button
=== 2)
5315 else if (button
=== 3)
5317 self
.handler(EscapeSequences_1
.C0
.ESC
+ '['
5320 + (button
=== 3 ? 4 : 0)
5330 if (self
.urxvtMouse
) {
5335 self
.handler(EscapeSequences_1
.C0
.ESC
+ '[' + button
+ ';' + pos
.x
+ ';' + pos
.y
+ 'M');
5338 if (self
.sgrMouse
) {
5341 self
.handler(EscapeSequences_1
.C0
.ESC
+ '[<'
5342 + (((button
& 3) === 3 ? button
& ~3 : button
) - 32)
5347 + ((button
& 3) === 3 ? 'm' : 'M'));
5351 encode(data
, button
);
5352 encode(data
, pos
.x
);
5353 encode(data
, pos
.y
);
5354 self
.handler(EscapeSequences_1
.C0
.ESC
+ '[M' + String
.fromCharCode
.apply(String
, data
));
5356 function getButton(ev
) {
5362 switch (ev
.overrideType
|| ev
.type
) {
5364 button
= ev
.button
!== null && ev
.button
!== undefined
5366 : ev
.which
!== null && ev
.which
!== undefined
5369 if (Browser
.isMSIE
) {
5370 button
= button
=== 1 ? 0 : button
=== 4 ? 1 : button
;
5376 case 'DOMMouseScroll':
5377 button
= ev
.detail
< 0
5382 button
= ev
.deltaY
< 0
5387 shift
= ev
.shiftKey
? 4 : 0;
5388 meta
= ev
.metaKey
? 8 : 0;
5389 ctrl
= ev
.ctrlKey
? 16 : 0;
5390 mod
= shift
| meta
| ctrl
;
5391 if (self
.vt200Mouse
) {
5394 else if (!self
.normalMouse
) {
5397 button
= (32 + (mod
<< 2)) + button
;
5400 this.register(Lifecycle_1
.addDisposableDomListener(el
, 'mousedown', function (ev
) {
5401 ev
.preventDefault();
5403 if (!_this
.mouseEvents
|| _this
.selectionManager
.shouldForceSelection(ev
)) {
5407 if (_this
.vt200Mouse
) {
5408 ev
.overrideType
= 'mouseup';
5410 return _this
.cancel(ev
);
5413 if (_this
.normalMouse
) {
5414 moveHandler = function (event
) {
5415 if (!_this
.normalMouse
) {
5420 _this
._document
.addEventListener('mousemove', moveHandler
);
5422 var handler = function (ev
) {
5423 if (_this
.normalMouse
&& !_this
.x10Mouse
) {
5427 _this
._document
.removeEventListener('mousemove', moveHandler
);
5430 _this
._document
.removeEventListener('mouseup', handler
);
5431 return _this
.cancel(ev
);
5433 _this
._document
.addEventListener('mouseup', handler
);
5434 return _this
.cancel(ev
);
5436 this.register(Lifecycle_1
.addDisposableDomListener(el
, 'wheel', function (ev
) {
5437 if (!_this
.mouseEvents
) {
5438 if (!_this
.buffer
.hasScrollback
) {
5439 var amount
= _this
.viewport
.getLinesScrolled(ev
);
5443 var sequence
= EscapeSequences_1
.C0
.ESC
+ (_this
.applicationCursor
? 'O' : '[') + (ev
.deltaY
< 0 ? 'A' : 'B');
5445 for (var i
= 0; i
< Math
.abs(amount
); i
++) {
5448 _this
.handler(data
);
5452 if (_this
.x10Mouse
|| _this
._vt300Mouse
|| _this
._decLocator
)
5455 ev
.preventDefault();
5457 this.register(Lifecycle_1
.addDisposableDomListener(el
, 'wheel', function (ev
) {
5458 if (_this
.mouseEvents
)
5460 _this
.viewport
.onWheel(ev
);
5461 return _this
.cancel(ev
);
5463 this.register(Lifecycle_1
.addDisposableDomListener(el
, 'touchstart', function (ev
) {
5464 if (_this
.mouseEvents
)
5466 _this
.viewport
.onTouchStart(ev
);
5467 return _this
.cancel(ev
);
5469 this.register(Lifecycle_1
.addDisposableDomListener(el
, 'touchmove', function (ev
) {
5470 if (_this
.mouseEvents
)
5472 _this
.viewport
.onTouchMove(ev
);
5473 return _this
.cancel(ev
);
5476 Terminal
.prototype.refresh = function (start
, end
) {
5477 if (this.renderer
) {
5478 this.renderer
.refreshRows(start
, end
);
5481 Terminal
.prototype._queueLinkification = function (start
, end
) {
5482 if (this.linkifier
) {
5483 this.linkifier
.linkifyRows(start
, end
);
5486 Terminal
.prototype.updateCursorStyle = function (ev
) {
5487 if (this.selectionManager
&& this.selectionManager
.shouldColumnSelect(ev
)) {
5488 this.element
.classList
.add('column-select');
5491 this.element
.classList
.remove('column-select');
5494 Terminal
.prototype.showCursor = function () {
5495 if (!this.cursorState
) {
5496 this.cursorState
= 1;
5497 this.refresh(this.buffer
.y
, this.buffer
.y
);
5500 Terminal
.prototype.scroll = function (isWrapped
) {
5501 if (isWrapped
=== void 0) { isWrapped
= false; }
5503 newLine
= this._blankLine
;
5504 var eraseAttr
= this.eraseAttrData();
5505 if (!newLine
|| newLine
.length
!== this.cols
|| newLine
.getFg(0) !== eraseAttr
.fg
|| newLine
.getBg(0) !== eraseAttr
.bg
) {
5506 newLine
= this.buffer
.getBlankLine(eraseAttr
, isWrapped
);
5507 this._blankLine
= newLine
;
5509 newLine
.isWrapped
= isWrapped
;
5510 var topRow
= this.buffer
.ybase
+ this.buffer
.scrollTop
;
5511 var bottomRow
= this.buffer
.ybase
+ this.buffer
.scrollBottom
;
5512 if (this.buffer
.scrollTop
=== 0) {
5513 var willBufferBeTrimmed
= this.buffer
.lines
.isFull
;
5514 if (bottomRow
=== this.buffer
.lines
.length
- 1) {
5515 if (willBufferBeTrimmed
) {
5516 this.buffer
.lines
.recycle().copyFrom(newLine
);
5519 this.buffer
.lines
.push(newLine
.clone());
5523 this.buffer
.lines
.splice(bottomRow
+ 1, 0, newLine
.clone());
5525 if (!willBufferBeTrimmed
) {
5526 this.buffer
.ybase
++;
5527 if (!this._userScrolling
) {
5528 this.buffer
.ydisp
++;
5532 if (this._userScrolling
) {
5533 this.buffer
.ydisp
= Math
.max(this.buffer
.ydisp
- 1, 0);
5538 var scrollRegionHeight
= bottomRow
- topRow
+ 1;
5539 this.buffer
.lines
.shiftElements(topRow
+ 1, scrollRegionHeight
- 1, -1);
5540 this.buffer
.lines
.set(bottomRow
, newLine
.clone());
5542 if (!this._userScrolling
) {
5543 this.buffer
.ydisp
= this.buffer
.ybase
;
5545 this.updateRange(this.buffer
.scrollTop
);
5546 this.updateRange(this.buffer
.scrollBottom
);
5547 this._onScroll
.fire(this.buffer
.ydisp
);
5549 Terminal
.prototype.scrollLines = function (disp
, suppressScrollEvent
) {
5551 if (this.buffer
.ydisp
=== 0) {
5554 this._userScrolling
= true;
5556 else if (disp
+ this.buffer
.ydisp
>= this.buffer
.ybase
) {
5557 this._userScrolling
= false;
5559 var oldYdisp
= this.buffer
.ydisp
;
5560 this.buffer
.ydisp
= Math
.max(Math
.min(this.buffer
.ydisp
+ disp
, this.buffer
.ybase
), 0);
5561 if (oldYdisp
=== this.buffer
.ydisp
) {
5564 if (!suppressScrollEvent
) {
5565 this._onScroll
.fire(this.buffer
.ydisp
);
5567 this.refresh(0, this.rows
- 1);
5569 Terminal
.prototype.scrollPages = function (pageCount
) {
5570 this.scrollLines(pageCount
* (this.rows
- 1));
5572 Terminal
.prototype.scrollToTop = function () {
5573 this.scrollLines(-this.buffer
.ydisp
);
5575 Terminal
.prototype.scrollToBottom = function () {
5576 this.scrollLines(this.buffer
.ybase
- this.buffer
.ydisp
);
5578 Terminal
.prototype.scrollToLine = function (line
) {
5579 var scrollAmount
= line
- this.buffer
.ydisp
;
5580 if (scrollAmount
!== 0) {
5581 this.scrollLines(scrollAmount
);
5584 Terminal
.prototype.write = function (data
) {
5586 if (this._isDisposed
) {
5592 this.writeBuffer
.push(data
);
5593 if (this.options
.useFlowControl
&& !this._xoffSentToCatchUp
&& this.writeBuffer
.length
>= WRITE_BUFFER_PAUSE_THRESHOLD
) {
5594 this.handler(EscapeSequences_1
.C0
.DC3
);
5595 this._xoffSentToCatchUp
= true;
5597 if (!this._writeInProgress
&& this.writeBuffer
.length
> 0) {
5598 this._writeInProgress
= true;
5599 setTimeout(function () {
5600 _this
._innerWrite();
5604 Terminal
.prototype._innerWrite = function (bufferOffset
) {
5606 if (bufferOffset
=== void 0) { bufferOffset
= 0; }
5607 if (this._isDisposed
) {
5608 this.writeBuffer
= [];
5610 var startTime
= Date
.now();
5611 while (this.writeBuffer
.length
> bufferOffset
) {
5612 var data
= this.writeBuffer
[bufferOffset
];
5614 if (this._xoffSentToCatchUp
&& this.writeBuffer
.length
=== bufferOffset
) {
5615 this.handler(EscapeSequences_1
.C0
.DC1
);
5616 this._xoffSentToCatchUp
= false;
5618 this._refreshStart
= this.buffer
.y
;
5619 this._refreshEnd
= this.buffer
.y
;
5620 this._inputHandler
.parse(data
);
5621 this.updateRange(this.buffer
.y
);
5622 this.refresh(this._refreshStart
, this._refreshEnd
);
5623 if (Date
.now() - startTime
>= WRITE_TIMEOUT_MS
) {
5627 if (this.writeBuffer
.length
> bufferOffset
) {
5628 setTimeout(function () { return _this
._innerWrite(bufferOffset
); }, 0);
5631 this._writeInProgress
= false;
5632 this.writeBuffer
= [];
5635 Terminal
.prototype.writeln = function (data
) {
5636 this.write(data
+ '\r\n');
5638 Terminal
.prototype.attachCustomKeyEventHandler = function (customKeyEventHandler
) {
5639 this._customKeyEventHandler
= customKeyEventHandler
;
5641 Terminal
.prototype.addCsiHandler = function (flag
, callback
) {
5642 return this._inputHandler
.addCsiHandler(flag
, callback
);
5644 Terminal
.prototype.addOscHandler = function (ident
, callback
) {
5645 return this._inputHandler
.addOscHandler(ident
, callback
);
5647 Terminal
.prototype.registerLinkMatcher = function (regex
, handler
, options
) {
5648 var matcherId
= this.linkifier
.registerLinkMatcher(regex
, handler
, options
);
5649 this.refresh(0, this.rows
- 1);
5652 Terminal
.prototype.deregisterLinkMatcher = function (matcherId
) {
5653 if (this.linkifier
.deregisterLinkMatcher(matcherId
)) {
5654 this.refresh(0, this.rows
- 1);
5657 Terminal
.prototype.registerCharacterJoiner = function (handler
) {
5658 var joinerId
= this.renderer
.registerCharacterJoiner(handler
);
5659 this.refresh(0, this.rows
- 1);
5662 Terminal
.prototype.deregisterCharacterJoiner = function (joinerId
) {
5663 if (this.renderer
.deregisterCharacterJoiner(joinerId
)) {
5664 this.refresh(0, this.rows
- 1);
5667 Object
.defineProperty(Terminal
.prototype, "markers", {
5669 return this.buffer
.markers
;
5674 Terminal
.prototype.addMarker = function (cursorYOffset
) {
5675 if (this.buffer
!== this.buffers
.normal
) {
5678 return this.buffer
.addMarker(this.buffer
.ybase
+ this.buffer
.y
+ cursorYOffset
);
5680 Terminal
.prototype.hasSelection = function () {
5681 return this.selectionManager
? this.selectionManager
.hasSelection
: false;
5683 Terminal
.prototype.getSelection = function () {
5684 return this.selectionManager
? this.selectionManager
.selectionText
: '';
5686 Terminal
.prototype.clearSelection = function () {
5687 if (this.selectionManager
) {
5688 this.selectionManager
.clearSelection();
5691 Terminal
.prototype.selectAll = function () {
5692 if (this.selectionManager
) {
5693 this.selectionManager
.selectAll();
5696 Terminal
.prototype.selectLines = function (start
, end
) {
5697 if (this.selectionManager
) {
5698 this.selectionManager
.selectLines(start
, end
);
5701 Terminal
.prototype._keyDown = function (event
) {
5702 if (this._customKeyEventHandler
&& this._customKeyEventHandler(event
) === false) {
5705 if (!this._compositionHelper
.keydown(event
)) {
5706 if (this.buffer
.ybase
!== this.buffer
.ydisp
) {
5707 this.scrollToBottom();
5711 var result
= Keyboard_1
.evaluateKeyboardEvent(event
, this.applicationCursor
, this.browser
.isMac
, this.options
.macOptionIsMeta
);
5712 this.updateCursorStyle(event
);
5713 if (result
.type
=== 3 || result
.type
=== 2) {
5714 var scrollCount
= this.rows
- 1;
5715 this.scrollLines(result
.type
=== 2 ? -scrollCount
: scrollCount
);
5716 return this.cancel(event
, true);
5718 if (result
.type
=== 1) {
5721 if (this._isThirdLevelShift(this.browser
, event
)) {
5724 if (result
.cancel
) {
5725 this.cancel(event
, true);
5730 this.emit('keydown', event
);
5731 this._onKey
.fire({ key
: result
.key
, domEvent
: event
});
5733 this.handler(result
.key
);
5734 return this.cancel(event
, true);
5736 Terminal
.prototype._isThirdLevelShift = function (browser
, ev
) {
5737 var thirdLevelKey
= (browser
.isMac
&& !this.options
.macOptionIsMeta
&& ev
.altKey
&& !ev
.ctrlKey
&& !ev
.metaKey
) ||
5738 (browser
.isMSWindows
&& ev
.altKey
&& ev
.ctrlKey
&& !ev
.metaKey
);
5739 if (ev
.type
=== 'keypress') {
5740 return thirdLevelKey
;
5742 return thirdLevelKey
&& (!ev
.keyCode
|| ev
.keyCode
> 47);
5744 Terminal
.prototype.setgLevel = function (g
) {
5746 this.charset
= this.charsets
[g
];
5748 Terminal
.prototype.setgCharset = function (g
, charset
) {
5749 this.charsets
[g
] = charset
;
5750 if (this.glevel
=== g
) {
5751 this.charset
= charset
;
5754 Terminal
.prototype._keyUp = function (ev
) {
5755 this.updateCursorStyle(ev
);
5757 Terminal
.prototype._keyPress = function (ev
) {
5759 if (this._customKeyEventHandler
&& this._customKeyEventHandler(ev
) === false) {
5766 else if (ev
.which
=== null || ev
.which
=== undefined) {
5769 else if (ev
.which
!== 0 && ev
.charCode
!== 0) {
5775 if (!key
|| ((ev
.altKey
|| ev
.ctrlKey
|| ev
.metaKey
) && !this._isThirdLevelShift(this.browser
, ev
))) {
5778 key
= String
.fromCharCode(key
);
5779 this.emit('keypress', key
, ev
);
5780 this._onKey
.fire({ key
: key
, domEvent
: ev
});
5785 Terminal
.prototype.bell = function () {
5788 if (this._soundBell()) {
5789 this.soundManager
.playBellSound();
5791 if (this._visualBell()) {
5792 this.element
.classList
.add('visual-bell-active');
5793 clearTimeout(this._visualBellTimer
);
5794 this._visualBellTimer
= window
.setTimeout(function () {
5795 _this
.element
.classList
.remove('visual-bell-active');
5799 Terminal
.prototype.log = function (text
, data
) {
5800 if (!this.options
.debug
)
5802 if (!this._context
.console
|| !this._context
.console
.log
)
5804 this._context
.console
.log(text
, data
);
5806 Terminal
.prototype.error = function (text
, data
) {
5807 if (!this.options
.debug
)
5809 if (!this._context
.console
|| !this._context
.console
.error
)
5811 this._context
.console
.error(text
, data
);
5813 Terminal
.prototype.resize = function (x
, y
) {
5814 if (isNaN(x
) || isNaN(y
)) {
5817 if (x
=== this.cols
&& y
=== this.rows
) {
5818 if (this.charMeasure
&& (!this.charMeasure
.width
|| !this.charMeasure
.height
)) {
5819 this.charMeasure
.measure(this.options
);
5823 if (x
< MINIMUM_COLS
)
5825 if (y
< MINIMUM_ROWS
)
5827 this.buffers
.resize(x
, y
);
5830 this.buffers
.setupTabStops(this.cols
);
5831 if (this.charMeasure
) {
5832 this.charMeasure
.measure(this.options
);
5834 this.refresh(0, this.rows
- 1);
5835 this._onResize
.fire({ cols
: x
, rows
: y
});
5837 Terminal
.prototype.updateRange = function (y
) {
5838 if (y
< this._refreshStart
)
5839 this._refreshStart
= y
;
5840 if (y
> this._refreshEnd
)
5841 this._refreshEnd
= y
;
5843 Terminal
.prototype.maxRange = function () {
5844 this._refreshStart
= 0;
5845 this._refreshEnd
= this.rows
- 1;
5847 Terminal
.prototype.clear = function () {
5848 if (this.buffer
.ybase
=== 0 && this.buffer
.y
=== 0) {
5851 this.buffer
.lines
.set(0, this.buffer
.lines
.get(this.buffer
.ybase
+ this.buffer
.y
));
5852 this.buffer
.lines
.length
= 1;
5853 this.buffer
.ydisp
= 0;
5854 this.buffer
.ybase
= 0;
5856 for (var i
= 1; i
< this.rows
; i
++) {
5857 this.buffer
.lines
.push(this.buffer
.getBlankLine(Buffer_1
.DEFAULT_ATTR_DATA
));
5859 this.refresh(0, this.rows
- 1);
5860 this._onScroll
.fire(this.buffer
.ydisp
);
5862 Terminal
.prototype.is = function (term
) {
5863 return (this.options
.termName
+ '').indexOf(term
) === 0;
5865 Terminal
.prototype.handler = function (data
) {
5866 if (this.options
.disableStdin
) {
5869 if (this.selectionManager
&& this.selectionManager
.hasSelection
) {
5870 this.selectionManager
.clearSelection();
5872 if (this.buffer
.ybase
!== this.buffer
.ydisp
) {
5873 this.scrollToBottom();
5875 this._onData
.fire(data
);
5877 Terminal
.prototype.handleTitle = function (title
) {
5878 this._onTitleChange
.fire(title
);
5880 Terminal
.prototype.index = function () {
5882 if (this.buffer
.y
> this.buffer
.scrollBottom
) {
5886 if (this.buffer
.x
>= this.cols
) {
5890 Terminal
.prototype.reverseIndex = function () {
5891 if (this.buffer
.y
=== this.buffer
.scrollTop
) {
5892 var scrollRegionHeight
= this.buffer
.scrollBottom
- this.buffer
.scrollTop
;
5893 this.buffer
.lines
.shiftElements(this.buffer
.y
+ this.buffer
.ybase
, scrollRegionHeight
, 1);
5894 this.buffer
.lines
.set(this.buffer
.y
+ this.buffer
.ybase
, this.buffer
.getBlankLine(this.eraseAttrData()));
5895 this.updateRange(this.buffer
.scrollTop
);
5896 this.updateRange(this.buffer
.scrollBottom
);
5902 Terminal
.prototype.reset = function () {
5903 this.options
.rows
= this.rows
;
5904 this.options
.cols
= this.cols
;
5905 var customKeyEventHandler
= this._customKeyEventHandler
;
5906 var inputHandler
= this._inputHandler
;
5907 var cursorState
= this.cursorState
;
5909 this._customKeyEventHandler
= customKeyEventHandler
;
5910 this._inputHandler
= inputHandler
;
5911 this.cursorState
= cursorState
;
5912 this.refresh(0, this.rows
- 1);
5913 if (this.viewport
) {
5914 this.viewport
.syncScrollArea();
5917 Terminal
.prototype.tabSet = function () {
5918 this.buffer
.tabs
[this.buffer
.x
] = true;
5920 Terminal
.prototype.cancel = function (ev
, force
) {
5921 if (!this.options
.cancelEvents
&& !force
) {
5924 ev
.preventDefault();
5925 ev
.stopPropagation();
5928 Terminal
.prototype._visualBell = function () {
5931 Terminal
.prototype._soundBell = function () {
5932 return this.options
.bellStyle
=== 'sound';
5935 }(EventEmitter_1
.EventEmitter
));
5936 exports
.Terminal
= Terminal
;
5937 function wasModifierKeyOnlyEvent(ev
) {
5938 return ev
.keyCode
=== 16 ||
5939 ev
.keyCode
=== 17 ||
5943 },{"./AccessibilityManager":1,"./Buffer":2,"./BufferSet":5,"./CharMeasure":6,"./Clipboard":8,"./CompositionHelper":9,"./InputHandler":11,"./Linkifier":12,"./MouseHelper":13,"./MouseZoneManager":14,"./SelectionManager":15,"./SoundManager":17,"./Strings":18,"./Viewport":20,"./WindowsMode":21,"./common/Clone":23,"./common/EventEmitter":24,"./common/EventEmitter2":25,"./common/Platform":27,"./common/data/EscapeSequences":29,"./core/input/Keyboard":31,"./renderer/Renderer":41,"./renderer/atlas/CharAtlasCache":45,"./renderer/dom/DomRenderer":53,"./ui/Lifecycle":55,"./ui/ScreenDprMonitor":57}],20:[function(require
,module
,exports
){
5945 var __extends
= (this && this.__extends
) || (function () {
5946 var extendStatics = function (d
, b
) {
5947 extendStatics
= Object
.setPrototypeOf
||
5948 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
5949 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
5950 return extendStatics(d
, b
);
5952 return function (d
, b
) {
5953 extendStatics(d
, b
);
5954 function __() { this.constructor = d
; }
5955 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
5958 Object
.defineProperty(exports
, "__esModule", { value
: true });
5959 var Lifecycle_1
= require("./common/Lifecycle");
5960 var Lifecycle_2
= require("./ui/Lifecycle");
5961 var FALLBACK_SCROLL_BAR_WIDTH
= 15;
5962 var Viewport
= (function (_super
) {
5963 __extends(Viewport
, _super
);
5964 function Viewport(_terminal
, _viewportElement
, _scrollArea
, _charMeasure
) {
5965 var _this
= _super
.call(this) || this;
5966 _this
._terminal
= _terminal
;
5967 _this
._viewportElement
= _viewportElement
;
5968 _this
._scrollArea
= _scrollArea
;
5969 _this
._charMeasure
= _charMeasure
;
5970 _this
.scrollBarWidth
= 0;
5971 _this
._currentRowHeight
= 0;
5972 _this
._lastRecordedBufferLength
= 0;
5973 _this
._lastRecordedViewportHeight
= 0;
5974 _this
._lastRecordedBufferHeight
= 0;
5975 _this
._lastScrollTop
= 0;
5976 _this
._wheelPartialScroll
= 0;
5977 _this
._refreshAnimationFrame
= null;
5978 _this
._ignoreNextScrollEvent
= false;
5979 _this
.scrollBarWidth
= (_this
._viewportElement
.offsetWidth
- _this
._scrollArea
.offsetWidth
) || FALLBACK_SCROLL_BAR_WIDTH
;
5980 _this
.register(Lifecycle_2
.addDisposableDomListener(_this
._viewportElement
, 'scroll', _this
._onScroll
.bind(_this
)));
5981 setTimeout(function () { return _this
.syncScrollArea(); }, 0);
5984 Viewport
.prototype.onThemeChanged = function (colors
) {
5985 this._viewportElement
.style
.backgroundColor
= colors
.background
.css
;
5987 Viewport
.prototype._refresh = function () {
5989 if (this._refreshAnimationFrame
=== null) {
5990 this._refreshAnimationFrame
= requestAnimationFrame(function () { return _this
._innerRefresh(); });
5993 Viewport
.prototype._innerRefresh = function () {
5994 if (this._charMeasure
.height
> 0) {
5995 this._currentRowHeight
= this._terminal
.renderer
.dimensions
.scaledCellHeight
/ window
.devicePixelRatio
;
5996 this._lastRecordedViewportHeight
= this._viewportElement
.offsetHeight
;
5997 var newBufferHeight
= Math
.round(this._currentRowHeight
* this._lastRecordedBufferLength
) + (this._lastRecordedViewportHeight
- this._terminal
.renderer
.dimensions
.canvasHeight
);
5998 if (this._lastRecordedBufferHeight
!== newBufferHeight
) {
5999 this._lastRecordedBufferHeight
= newBufferHeight
;
6000 this._scrollArea
.style
.height
= this._lastRecordedBufferHeight
+ 'px';
6003 var scrollTop
= this._terminal
.buffer
.ydisp
* this._currentRowHeight
;
6004 if (this._viewportElement
.scrollTop
!== scrollTop
) {
6005 this._ignoreNextScrollEvent
= true;
6006 this._viewportElement
.scrollTop
= scrollTop
;
6008 this._refreshAnimationFrame
= null;
6010 Viewport
.prototype.syncScrollArea = function () {
6011 if (this._lastRecordedBufferLength
!== this._terminal
.buffer
.lines
.length
) {
6012 this._lastRecordedBufferLength
= this._terminal
.buffer
.lines
.length
;
6016 if (this._lastRecordedViewportHeight
!== this._terminal
.renderer
.dimensions
.canvasHeight
) {
6020 var newScrollTop
= this._terminal
.buffer
.ydisp
* this._currentRowHeight
;
6021 if (this._lastScrollTop
!== newScrollTop
) {
6025 if (this._lastScrollTop
!== this._viewportElement
.scrollTop
) {
6029 if (this._terminal
.renderer
.dimensions
.scaledCellHeight
/ window
.devicePixelRatio
!== this._currentRowHeight
) {
6034 Viewport
.prototype._onScroll = function (ev
) {
6035 this._lastScrollTop
= this._viewportElement
.scrollTop
;
6036 if (!this._viewportElement
.offsetParent
) {
6039 if (this._ignoreNextScrollEvent
) {
6040 this._ignoreNextScrollEvent
= false;
6043 var newRow
= Math
.round(this._lastScrollTop
/ this._currentRowHeight
);
6044 var diff
= newRow
- this._terminal
.buffer
.ydisp
;
6045 this._terminal
.scrollLines(diff
, true);
6047 Viewport
.prototype.onWheel = function (ev
) {
6048 var amount
= this._getPixelsScrolled(ev
);
6052 this._viewportElement
.scrollTop
+= amount
;
6053 ev
.preventDefault();
6055 Viewport
.prototype._getPixelsScrolled = function (ev
) {
6056 if (ev
.deltaY
=== 0) {
6059 var amount
= ev
.deltaY
;
6060 if (ev
.deltaMode
=== WheelEvent
.DOM_DELTA_LINE
) {
6061 amount
*= this._currentRowHeight
;
6063 else if (ev
.deltaMode
=== WheelEvent
.DOM_DELTA_PAGE
) {
6064 amount
*= this._currentRowHeight
* this._terminal
.rows
;
6068 Viewport
.prototype.getLinesScrolled = function (ev
) {
6069 if (ev
.deltaY
=== 0) {
6072 var amount
= ev
.deltaY
;
6073 if (ev
.deltaMode
=== WheelEvent
.DOM_DELTA_PIXEL
) {
6074 amount
/= this._currentRowHeight
+ 0.0;
6075 this._wheelPartialScroll
+= amount
;
6076 amount
= Math
.floor(Math
.abs(this._wheelPartialScroll
)) * (this._wheelPartialScroll
> 0 ? 1 : -1);
6077 this._wheelPartialScroll
%= 1;
6079 else if (ev
.deltaMode
=== WheelEvent
.DOM_DELTA_PAGE
) {
6080 amount
*= this._terminal
.rows
;
6084 Viewport
.prototype.onTouchStart = function (ev
) {
6085 this._lastTouchY
= ev
.touches
[0].pageY
;
6087 Viewport
.prototype.onTouchMove = function (ev
) {
6088 var deltaY
= this._lastTouchY
- ev
.touches
[0].pageY
;
6089 this._lastTouchY
= ev
.touches
[0].pageY
;
6093 this._viewportElement
.scrollTop
+= deltaY
;
6094 ev
.preventDefault();
6097 }(Lifecycle_1
.Disposable
));
6098 exports
.Viewport
= Viewport
;
6100 },{"./common/Lifecycle":26,"./ui/Lifecycle":55}],21:[function(require
,module
,exports
){
6102 Object
.defineProperty(exports
, "__esModule", { value
: true });
6103 var Buffer_1
= require("./Buffer");
6104 function applyWindowsMode(terminal
) {
6105 return terminal
.onLineFeed(function () {
6106 var line
= terminal
.buffer
.lines
.get(terminal
.buffer
.ybase
+ terminal
.buffer
.y
- 1);
6107 var lastChar
= line
.get(terminal
.cols
- 1);
6108 if (lastChar
[Buffer_1
.CHAR_DATA_CODE_INDEX
] !== Buffer_1
.NULL_CELL_CODE
&& lastChar
[Buffer_1
.CHAR_DATA_CODE_INDEX
] !== Buffer_1
.WHITESPACE_CELL_CODE
) {
6109 var nextLine
= terminal
.buffer
.lines
.get(terminal
.buffer
.ybase
+ terminal
.buffer
.y
);
6110 nextLine
.isWrapped
= true;
6114 exports
.applyWindowsMode
= applyWindowsMode
;
6116 },{"./Buffer":2}],22:[function(require
,module
,exports
){
6118 Object
.defineProperty(exports
, "__esModule", { value
: true });
6119 var EventEmitter2_1
= require("./EventEmitter2");
6120 var CircularList
= (function () {
6121 function CircularList(_maxLength
) {
6122 this._maxLength
= _maxLength
;
6123 this.onDeleteEmitter
= new EventEmitter2_1
.EventEmitter2();
6124 this.onInsertEmitter
= new EventEmitter2_1
.EventEmitter2();
6125 this.onTrimEmitter
= new EventEmitter2_1
.EventEmitter2();
6126 this._array
= new Array(this._maxLength
);
6127 this._startIndex
= 0;
6130 Object
.defineProperty(CircularList
.prototype, "onDelete", {
6131 get: function () { return this.onDeleteEmitter
.event
; },
6135 Object
.defineProperty(CircularList
.prototype, "onInsert", {
6136 get: function () { return this.onInsertEmitter
.event
; },
6140 Object
.defineProperty(CircularList
.prototype, "onTrim", {
6141 get: function () { return this.onTrimEmitter
.event
; },
6145 Object
.defineProperty(CircularList
.prototype, "maxLength", {
6147 return this._maxLength
;
6149 set: function (newMaxLength
) {
6150 if (this._maxLength
=== newMaxLength
) {
6153 var newArray
= new Array(newMaxLength
);
6154 for (var i
= 0; i
< Math
.min(newMaxLength
, this.length
); i
++) {
6155 newArray
[i
] = this._array
[this._getCyclicIndex(i
)];
6157 this._array
= newArray
;
6158 this._maxLength
= newMaxLength
;
6159 this._startIndex
= 0;
6164 Object
.defineProperty(CircularList
.prototype, "length", {
6166 return this._length
;
6168 set: function (newLength
) {
6169 if (newLength
> this._length
) {
6170 for (var i
= this._length
; i
< newLength
; i
++) {
6171 this._array
[i
] = undefined;
6174 this._length
= newLength
;
6179 CircularList
.prototype.get = function (index
) {
6180 return this._array
[this._getCyclicIndex(index
)];
6182 CircularList
.prototype.set = function (index
, value
) {
6183 this._array
[this._getCyclicIndex(index
)] = value
;
6185 CircularList
.prototype.push = function (value
) {
6186 this._array
[this._getCyclicIndex(this._length
)] = value
;
6187 if (this._length
=== this._maxLength
) {
6188 this._startIndex
= ++this._startIndex
% this._maxLength
;
6189 this.onTrimEmitter
.fire(1);
6195 CircularList
.prototype.recycle = function () {
6196 if (this._length
!== this._maxLength
) {
6197 throw new Error('Can only recycle when the buffer is full');
6199 this._startIndex
= ++this._startIndex
% this._maxLength
;
6200 this.onTrimEmitter
.fire(1);
6201 return this._array
[this._getCyclicIndex(this._length
- 1)];
6203 Object
.defineProperty(CircularList
.prototype, "isFull", {
6205 return this._length
=== this._maxLength
;
6210 CircularList
.prototype.pop = function () {
6211 return this._array
[this._getCyclicIndex(this._length
-- - 1)];
6213 CircularList
.prototype.splice = function (start
, deleteCount
) {
6215 for (var _i
= 2; _i
< arguments
.length
; _i
++) {
6216 items
[_i
- 2] = arguments
[_i
];
6219 for (var i
= start
; i
< this._length
- deleteCount
; i
++) {
6220 this._array
[this._getCyclicIndex(i
)] = this._array
[this._getCyclicIndex(i
+ deleteCount
)];
6222 this._length
-= deleteCount
;
6224 for (var i
= this._length
- 1; i
>= start
; i
--) {
6225 this._array
[this._getCyclicIndex(i
+ items
.length
)] = this._array
[this._getCyclicIndex(i
)];
6227 for (var i
= 0; i
< items
.length
; i
++) {
6228 this._array
[this._getCyclicIndex(start
+ i
)] = items
[i
];
6230 if (this._length
+ items
.length
> this._maxLength
) {
6231 var countToTrim
= (this._length
+ items
.length
) - this._maxLength
;
6232 this._startIndex
+= countToTrim
;
6233 this._length
= this._maxLength
;
6234 this.onTrimEmitter
.fire(countToTrim
);
6237 this._length
+= items
.length
;
6240 CircularList
.prototype.trimStart = function (count
) {
6241 if (count
> this._length
) {
6242 count
= this._length
;
6244 this._startIndex
+= count
;
6245 this._length
-= count
;
6246 this.onTrimEmitter
.fire(count
);
6248 CircularList
.prototype.shiftElements = function (start
, count
, offset
) {
6252 if (start
< 0 || start
>= this._length
) {
6253 throw new Error('start argument out of range');
6255 if (start
+ offset
< 0) {
6256 throw new Error('Cannot shift elements in list beyond index 0');
6259 for (var i
= count
- 1; i
>= 0; i
--) {
6260 this.set(start
+ i
+ offset
, this.get(start
+ i
));
6262 var expandListBy
= (start
+ count
+ offset
) - this._length
;
6263 if (expandListBy
> 0) {
6264 this._length
+= expandListBy
;
6265 while (this._length
> this._maxLength
) {
6268 this.onTrimEmitter
.fire(1);
6273 for (var i
= 0; i
< count
; i
++) {
6274 this.set(start
+ i
+ offset
, this.get(start
+ i
));
6278 CircularList
.prototype._getCyclicIndex = function (index
) {
6279 return (this._startIndex
+ index
) % this._maxLength
;
6281 return CircularList
;
6283 exports
.CircularList
= CircularList
;
6285 },{"./EventEmitter2":25}],23:[function(require
,module
,exports
){
6287 Object
.defineProperty(exports
, "__esModule", { value
: true });
6288 function clone(val
, depth
) {
6289 if (depth
=== void 0) { depth
= 5; }
6290 if (typeof val
!== 'object') {
6296 var clonedObject
= Array
.isArray(val
) ? [] : {};
6297 for (var key
in val
) {
6298 clonedObject
[key
] = depth
<= 1 ? val
[key
] : clone(val
[key
], depth
- 1);
6300 return clonedObject
;
6302 exports
.clone
= clone
;
6304 },{}],24:[function(require
,module
,exports
){
6306 var __extends
= (this && this.__extends
) || (function () {
6307 var extendStatics = function (d
, b
) {
6308 extendStatics
= Object
.setPrototypeOf
||
6309 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
6310 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
6311 return extendStatics(d
, b
);
6313 return function (d
, b
) {
6314 extendStatics(d
, b
);
6315 function __() { this.constructor = d
; }
6316 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
6319 Object
.defineProperty(exports
, "__esModule", { value
: true });
6320 var Lifecycle_1
= require("./Lifecycle");
6321 var EventEmitter
= (function (_super
) {
6322 __extends(EventEmitter
, _super
);
6323 function EventEmitter() {
6324 var _this
= _super
.call(this) || this;
6325 _this
._events
= _this
._events
|| {};
6328 EventEmitter
.prototype.on = function (type
, listener
) {
6329 this._events
[type
] = this._events
[type
] || [];
6330 this._events
[type
].push(listener
);
6332 EventEmitter
.prototype.addDisposableListener = function (type
, handler
) {
6334 this.on(type
, handler
);
6335 var disposed
= false;
6337 dispose: function () {
6341 _this
.off(type
, handler
);
6346 EventEmitter
.prototype.off = function (type
, listener
) {
6347 if (!this._events
[type
]) {
6350 var obj
= this._events
[type
];
6353 if (obj
[i
] === listener
) {
6359 EventEmitter
.prototype.removeAllListeners = function (type
) {
6360 if (this._events
[type
]) {
6361 delete this._events
[type
];
6364 EventEmitter
.prototype.emit = function (type
) {
6366 for (var _i
= 1; _i
< arguments
.length
; _i
++) {
6367 args
[_i
- 1] = arguments
[_i
];
6369 if (!this._events
[type
]) {
6372 var obj
= this._events
[type
];
6373 for (var i
= 0; i
< obj
.length
; i
++) {
6374 obj
[i
].apply(this, args
);
6377 EventEmitter
.prototype.emitMayRemoveListeners = function (type
) {
6379 for (var _i
= 1; _i
< arguments
.length
; _i
++) {
6380 args
[_i
- 1] = arguments
[_i
];
6382 if (!this._events
[type
]) {
6385 var obj
= this._events
[type
];
6386 var length
= obj
.length
;
6387 for (var i
= 0; i
< obj
.length
; i
++) {
6388 obj
[i
].apply(this, args
);
6389 i
-= length
- obj
.length
;
6390 length
= obj
.length
;
6393 EventEmitter
.prototype.listeners = function (type
) {
6394 return this._events
[type
] || [];
6396 EventEmitter
.prototype.dispose = function () {
6397 _super
.prototype.dispose
.call(this);
6400 return EventEmitter
;
6401 }(Lifecycle_1
.Disposable
));
6402 exports
.EventEmitter
= EventEmitter
;
6404 },{"./Lifecycle":26}],25:[function(require
,module
,exports
){
6406 Object
.defineProperty(exports
, "__esModule", { value
: true });
6407 var EventEmitter2
= (function () {
6408 function EventEmitter2() {
6409 this._listeners
= [];
6411 Object
.defineProperty(EventEmitter2
.prototype, "event", {
6415 this._event = function (listener
) {
6416 _this
._listeners
.push(listener
);
6418 dispose: function () {
6419 for (var i
= 0; i
< _this
._listeners
.length
; i
++) {
6420 if (_this
._listeners
[i
] === listener
) {
6421 _this
._listeners
.splice(i
, 1);
6435 EventEmitter2
.prototype.fire = function (data
) {
6437 for (var i
= 0; i
< this._listeners
.length
; i
++) {
6438 queue
.push(this._listeners
[i
]);
6440 for (var i
= 0; i
< queue
.length
; i
++) {
6441 queue
[i
].call(undefined, data
);
6444 return EventEmitter2
;
6446 exports
.EventEmitter2
= EventEmitter2
;
6448 },{}],26:[function(require
,module
,exports
){
6450 Object
.defineProperty(exports
, "__esModule", { value
: true });
6451 var Disposable
= (function () {
6452 function Disposable() {
6453 this._disposables
= [];
6454 this._isDisposed
= false;
6456 Disposable
.prototype.dispose = function () {
6457 this._isDisposed
= true;
6458 this._disposables
.forEach(function (d
) { return d
.dispose(); });
6459 this._disposables
.length
= 0;
6461 Disposable
.prototype.register = function (d
) {
6462 this._disposables
.push(d
);
6464 Disposable
.prototype.unregister = function (d
) {
6465 var index
= this._disposables
.indexOf(d
);
6467 this._disposables
.splice(index
, 1);
6472 exports
.Disposable
= Disposable
;
6474 },{}],27:[function(require
,module
,exports
){
6476 Object
.defineProperty(exports
, "__esModule", { value
: true });
6477 var isNode
= (typeof navigator
=== 'undefined') ? true : false;
6478 var userAgent
= (isNode
) ? 'node' : navigator
.userAgent
;
6479 var platform
= (isNode
) ? 'node' : navigator
.platform
;
6480 exports
.isFirefox
= !!~userAgent
.indexOf('Firefox');
6481 exports
.isSafari
= /^((?!chrome|android).)*safari/i.test(userAgent
);
6482 exports
.isMSIE
= !!~userAgent
.indexOf('MSIE') || !!~userAgent
.indexOf('Trident');
6483 exports
.isMac
= contains(['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], platform
);
6484 exports
.isIpad
= platform
=== 'iPad';
6485 exports
.isIphone
= platform
=== 'iPhone';
6486 exports
.isMSWindows
= contains(['Windows', 'Win16', 'Win32', 'WinCE'], platform
);
6487 exports
.isLinux
= platform
.indexOf('Linux') >= 0;
6488 function contains(arr
, el
) {
6489 return arr
.indexOf(el
) >= 0;
6492 },{}],28:[function(require
,module
,exports
){
6494 Object
.defineProperty(exports
, "__esModule", { value
: true });
6495 function fill(array
, value
, start
, end
) {
6497 return array
.fill(value
, start
, end
);
6499 return fillFallback(array
, value
, start
, end
);
6501 exports
.fill
= fill
;
6502 function fillFallback(array
, value
, start
, end
) {
6503 if (start
=== void 0) { start
= 0; }
6504 if (end
=== void 0) { end
= array
.length
; }
6505 if (start
>= array
.length
) {
6508 start
= (array
.length
+ start
) % array
.length
;
6509 if (end
>= array
.length
) {
6513 end
= (array
.length
+ end
) % array
.length
;
6515 for (var i
= start
; i
< end
; ++i
) {
6520 exports
.fillFallback
= fillFallback
;
6521 function concat(a
, b
) {
6522 var result
= new a
.constructor(a
.length
+ b
.length
);
6524 result
.set(b
, a
.length
);
6527 exports
.concat
= concat
;
6529 },{}],29:[function(require
,module
,exports
){
6531 Object
.defineProperty(exports
, "__esModule", { value
: true });
6568 })(C0
= exports
.C0
|| (exports
.C0
= {}));
6603 })(C1
= exports
.C1
|| (exports
.C1
= {}));
6605 },{}],30:[function(require
,module
,exports
){
6607 Object
.defineProperty(exports
, "__esModule", { value
: true });
6608 exports
.CHARSETS
= {};
6609 exports
.DEFAULT_CHARSET
= exports
.CHARSETS
['B'];
6610 exports
.CHARSETS
['0'] = {
6643 exports
.CHARSETS
['A'] = {
6646 exports
.CHARSETS
['B'] = null;
6647 exports
.CHARSETS
['4'] = {
6658 exports
.CHARSETS
['C'] =
6659 exports
.CHARSETS
['5'] = {
6670 exports
.CHARSETS
['R'] = {
6681 exports
.CHARSETS
['Q'] = {
6693 exports
.CHARSETS
['K'] = {
6703 exports
.CHARSETS
['Y'] = {
6715 exports
.CHARSETS
['E'] =
6716 exports
.CHARSETS
['6'] = {
6728 exports
.CHARSETS
['Z'] = {
6738 exports
.CHARSETS
['H'] =
6739 exports
.CHARSETS
['7'] = {
6751 exports
.CHARSETS
['='] = {
6766 },{}],31:[function(require
,module
,exports
){
6768 Object
.defineProperty(exports
, "__esModule", { value
: true });
6769 var EscapeSequences_1
= require("../../common/data/EscapeSequences");
6770 var KEYCODE_KEY_MAPPINGS
= {
6793 function evaluateKeyboardEvent(ev
, applicationCursorMode
, isMac
, macOptionIsMeta
) {
6799 var modifiers
= (ev
.shiftKey
? 1 : 0) | (ev
.altKey
? 2 : 0) | (ev
.ctrlKey
? 4 : 0) | (ev
.metaKey
? 8 : 0);
6800 switch (ev
.keyCode
) {
6802 if (ev
.key
=== 'UIKeyInputUpArrow') {
6803 if (applicationCursorMode
) {
6804 result
.key
= EscapeSequences_1
.C0
.ESC
+ 'OA';
6807 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[A';
6810 else if (ev
.key
=== 'UIKeyInputLeftArrow') {
6811 if (applicationCursorMode
) {
6812 result
.key
= EscapeSequences_1
.C0
.ESC
+ 'OD';
6815 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[D';
6818 else if (ev
.key
=== 'UIKeyInputRightArrow') {
6819 if (applicationCursorMode
) {
6820 result
.key
= EscapeSequences_1
.C0
.ESC
+ 'OC';
6823 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[C';
6826 else if (ev
.key
=== 'UIKeyInputDownArrow') {
6827 if (applicationCursorMode
) {
6828 result
.key
= EscapeSequences_1
.C0
.ESC
+ 'OB';
6831 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[B';
6837 result
.key
= EscapeSequences_1
.C0
.BS
;
6840 else if (ev
.altKey
) {
6841 result
.key
= EscapeSequences_1
.C0
.ESC
+ EscapeSequences_1
.C0
.DEL
;
6844 result
.key
= EscapeSequences_1
.C0
.DEL
;
6848 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[Z';
6851 result
.key
= EscapeSequences_1
.C0
.HT
;
6852 result
.cancel
= true;
6855 result
.key
= EscapeSequences_1
.C0
.CR
;
6856 result
.cancel
= true;
6859 result
.key
= EscapeSequences_1
.C0
.ESC
;
6860 result
.cancel
= true;
6864 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[1;' + (modifiers
+ 1) + 'D';
6865 if (result
.key
=== EscapeSequences_1
.C0
.ESC
+ '[1;3D') {
6866 result
.key
= isMac
? EscapeSequences_1
.C0
.ESC
+ 'b' : EscapeSequences_1
.C0
.ESC
+ '[1;5D';
6869 else if (applicationCursorMode
) {
6870 result
.key
= EscapeSequences_1
.C0
.ESC
+ 'OD';
6873 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[D';
6878 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[1;' + (modifiers
+ 1) + 'C';
6879 if (result
.key
=== EscapeSequences_1
.C0
.ESC
+ '[1;3C') {
6880 result
.key
= isMac
? EscapeSequences_1
.C0
.ESC
+ 'f' : EscapeSequences_1
.C0
.ESC
+ '[1;5C';
6883 else if (applicationCursorMode
) {
6884 result
.key
= EscapeSequences_1
.C0
.ESC
+ 'OC';
6887 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[C';
6892 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[1;' + (modifiers
+ 1) + 'A';
6893 if (result
.key
=== EscapeSequences_1
.C0
.ESC
+ '[1;3A') {
6894 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[1;5A';
6897 else if (applicationCursorMode
) {
6898 result
.key
= EscapeSequences_1
.C0
.ESC
+ 'OA';
6901 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[A';
6906 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[1;' + (modifiers
+ 1) + 'B';
6907 if (result
.key
=== EscapeSequences_1
.C0
.ESC
+ '[1;3B') {
6908 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[1;5B';
6911 else if (applicationCursorMode
) {
6912 result
.key
= EscapeSequences_1
.C0
.ESC
+ 'OB';
6915 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[B';
6919 if (!ev
.shiftKey
&& !ev
.ctrlKey
) {
6920 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[2~';
6925 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[3;' + (modifiers
+ 1) + '~';
6928 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[3~';
6933 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[1;' + (modifiers
+ 1) + 'H';
6935 else if (applicationCursorMode
) {
6936 result
.key
= EscapeSequences_1
.C0
.ESC
+ 'OH';
6939 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[H';
6944 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[1;' + (modifiers
+ 1) + 'F';
6946 else if (applicationCursorMode
) {
6947 result
.key
= EscapeSequences_1
.C0
.ESC
+ 'OF';
6950 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[F';
6958 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[5~';
6966 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[6~';
6971 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[1;' + (modifiers
+ 1) + 'P';
6974 result
.key
= EscapeSequences_1
.C0
.ESC
+ 'OP';
6979 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[1;' + (modifiers
+ 1) + 'Q';
6982 result
.key
= EscapeSequences_1
.C0
.ESC
+ 'OQ';
6987 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[1;' + (modifiers
+ 1) + 'R';
6990 result
.key
= EscapeSequences_1
.C0
.ESC
+ 'OR';
6995 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[1;' + (modifiers
+ 1) + 'S';
6998 result
.key
= EscapeSequences_1
.C0
.ESC
+ 'OS';
7003 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[15;' + (modifiers
+ 1) + '~';
7006 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[15~';
7011 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[17;' + (modifiers
+ 1) + '~';
7014 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[17~';
7019 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[18;' + (modifiers
+ 1) + '~';
7022 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[18~';
7027 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[19;' + (modifiers
+ 1) + '~';
7030 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[19~';
7035 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[20;' + (modifiers
+ 1) + '~';
7038 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[20~';
7043 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[21;' + (modifiers
+ 1) + '~';
7046 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[21~';
7051 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[23;' + (modifiers
+ 1) + '~';
7054 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[23~';
7059 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[24;' + (modifiers
+ 1) + '~';
7062 result
.key
= EscapeSequences_1
.C0
.ESC
+ '[24~';
7066 if (ev
.ctrlKey
&& !ev
.shiftKey
&& !ev
.altKey
&& !ev
.metaKey
) {
7067 if (ev
.keyCode
>= 65 && ev
.keyCode
<= 90) {
7068 result
.key
= String
.fromCharCode(ev
.keyCode
- 64);
7070 else if (ev
.keyCode
=== 32) {
7071 result
.key
= String
.fromCharCode(0);
7073 else if (ev
.keyCode
>= 51 && ev
.keyCode
<= 55) {
7074 result
.key
= String
.fromCharCode(ev
.keyCode
- 51 + 27);
7076 else if (ev
.keyCode
=== 56) {
7077 result
.key
= String
.fromCharCode(127);
7079 else if (ev
.keyCode
=== 219) {
7080 result
.key
= String
.fromCharCode(27);
7082 else if (ev
.keyCode
=== 220) {
7083 result
.key
= String
.fromCharCode(28);
7085 else if (ev
.keyCode
=== 221) {
7086 result
.key
= String
.fromCharCode(29);
7089 else if ((!isMac
|| macOptionIsMeta
) && ev
.altKey
&& !ev
.metaKey
) {
7090 var keyMapping
= KEYCODE_KEY_MAPPINGS
[ev
.keyCode
];
7091 var key
= keyMapping
&& keyMapping
[!ev
.shiftKey
? 0 : 1];
7093 result
.key
= EscapeSequences_1
.C0
.ESC
+ key
;
7095 else if (ev
.keyCode
>= 65 && ev
.keyCode
<= 90) {
7096 var keyCode
= ev
.ctrlKey
? ev
.keyCode
- 64 : ev
.keyCode
+ 32;
7097 result
.key
= EscapeSequences_1
.C0
.ESC
+ String
.fromCharCode(keyCode
);
7100 else if (isMac
&& !ev
.altKey
&& !ev
.ctrlKey
&& ev
.metaKey
) {
7101 if (ev
.keyCode
=== 65) {
7105 else if (ev
.key
&& !ev
.ctrlKey
&& !ev
.altKey
&& !ev
.metaKey
&& ev
.keyCode
>= 48 && ev
.key
.length
=== 1) {
7106 result
.key
= ev
.key
;
7108 else if (ev
.key
&& ev
.ctrlKey
) {
7109 if (ev
.key
=== '_') {
7110 result
.key
= EscapeSequences_1
.C0
.US
;
7117 exports
.evaluateKeyboardEvent
= evaluateKeyboardEvent
;
7119 },{"../../common/data/EscapeSequences":29}],32:[function(require
,module
,exports
){
7121 Object
.defineProperty(exports
, "__esModule", { value
: true });
7122 var StringToUtf32
= (function () {
7123 function StringToUtf32() {
7126 StringToUtf32
.prototype.clear = function () {
7129 StringToUtf32
.prototype.decode = function (input
, target
) {
7130 var length
= input
.length
;
7136 if (this._interim
) {
7137 var second
= input
.charCodeAt(startPos
++);
7138 if (0xDC00 <= second
&& second
<= 0xDFFF) {
7139 target
[size
++] = (this._interim
- 0xD800) * 0x400 + second
- 0xDC00 + 0x10000;
7142 target
[size
++] = this._interim
;
7143 target
[size
++] = second
;
7147 for (var i
= startPos
; i
< length
; ++i
) {
7148 var code
= input
.charCodeAt(i
);
7149 if (0xD800 <= code
&& code
<= 0xDBFF) {
7150 if (++i
>= length
) {
7151 this._interim
= code
;
7154 var second
= input
.charCodeAt(i
);
7155 if (0xDC00 <= second
&& second
<= 0xDFFF) {
7156 target
[size
++] = (code
- 0xD800) * 0x400 + second
- 0xDC00 + 0x10000;
7159 target
[size
++] = code
;
7160 target
[size
++] = second
;
7164 target
[size
++] = code
;
7168 return StringToUtf32
;
7170 exports
.StringToUtf32
= StringToUtf32
;
7171 function stringFromCodePoint(codePoint
) {
7172 if (codePoint
> 0xFFFF) {
7173 codePoint
-= 0x10000;
7174 return String
.fromCharCode((codePoint
>> 10) + 0xD800) + String
.fromCharCode((codePoint
% 0x400) + 0xDC00);
7176 return String
.fromCharCode(codePoint
);
7178 exports
.stringFromCodePoint
= stringFromCodePoint
;
7179 function utf32ToString(data
, start
, end
) {
7180 if (start
=== void 0) { start
= 0; }
7181 if (end
=== void 0) { end
= data
.length
; }
7183 for (var i
= start
; i
< end
; ++i
) {
7184 var codepoint
= data
[i
];
7185 if (codepoint
> 0xFFFF) {
7186 codepoint
-= 0x10000;
7187 result
+= String
.fromCharCode((codepoint
>> 10) + 0xD800) + String
.fromCharCode((codepoint
% 0x400) + 0xDC00);
7190 result
+= String
.fromCharCode(codepoint
);
7195 exports
.utf32ToString
= utf32ToString
;
7197 },{}],33:[function(require
,module
,exports
){
7199 Object
.defineProperty(exports
, "__esModule", { value
: true });
7200 var EscapeSequences_1
= require("../common/data/EscapeSequences");
7201 var AltClickHandler
= (function () {
7202 function AltClickHandler(_mouseEvent
, _terminal
) {
7204 this._mouseEvent
= _mouseEvent
;
7205 this._terminal
= _terminal
;
7206 this._lines
= this._terminal
.buffer
.lines
;
7207 this._startCol
= this._terminal
.buffer
.x
;
7208 this._startRow
= this._terminal
.buffer
.y
;
7209 var coordinates
= this._terminal
.mouseHelper
.getCoords(this._mouseEvent
, this._terminal
.element
, this._terminal
.charMeasure
, this._terminal
.cols
, this._terminal
.rows
, false);
7211 _a
= coordinates
.map(function (coordinate
) {
7212 return coordinate
- 1;
7213 }), this._endCol
= _a
[0], this._endRow
= _a
[1];
7216 AltClickHandler
.prototype.move = function () {
7217 if (this._mouseEvent
.altKey
&& this._endCol
!== undefined && this._endRow
!== undefined) {
7218 this._terminal
.handler(this._arrowSequences());
7221 AltClickHandler
.prototype._arrowSequences = function () {
7222 if (!this._terminal
.buffer
.hasScrollback
) {
7223 return this._resetStartingRow() + this._moveToRequestedRow() + this._moveToRequestedCol();
7225 return this._moveHorizontallyOnly();
7227 AltClickHandler
.prototype._resetStartingRow = function () {
7228 if (this._moveToRequestedRow().length
=== 0) {
7231 return repeat(this._bufferLine(this._startCol
, this._startRow
, this._startCol
, this._startRow
- this._wrappedRowsForRow(this._startRow
), false).length
, this._sequence("D"));
7233 AltClickHandler
.prototype._moveToRequestedRow = function () {
7234 var startRow
= this._startRow
- this._wrappedRowsForRow(this._startRow
);
7235 var endRow
= this._endRow
- this._wrappedRowsForRow(this._endRow
);
7236 var rowsToMove
= Math
.abs(startRow
- endRow
) - this._wrappedRowsCount();
7237 return repeat(rowsToMove
, this._sequence(this._verticalDirection()));
7239 AltClickHandler
.prototype._moveToRequestedCol = function () {
7241 if (this._moveToRequestedRow().length
> 0) {
7242 startRow
= this._endRow
- this._wrappedRowsForRow(this._endRow
);
7245 startRow
= this._startRow
;
7247 var endRow
= this._endRow
;
7248 var direction
= this._horizontalDirection();
7249 return repeat(this._bufferLine(this._startCol
, startRow
, this._endCol
, endRow
, direction
=== "C").length
, this._sequence(direction
));
7251 AltClickHandler
.prototype._moveHorizontallyOnly = function () {
7252 var direction
= this._horizontalDirection();
7253 return repeat(Math
.abs(this._startCol
- this._endCol
), this._sequence(direction
));
7255 AltClickHandler
.prototype._wrappedRowsCount = function () {
7256 var wrappedRows
= 0;
7257 var startRow
= this._startRow
- this._wrappedRowsForRow(this._startRow
);
7258 var endRow
= this._endRow
- this._wrappedRowsForRow(this._endRow
);
7259 for (var i
= 0; i
< Math
.abs(startRow
- endRow
); i
++) {
7260 var direction
= this._verticalDirection() === "A" ? -1 : 1;
7261 if (this._lines
.get(startRow
+ (direction
* i
)).isWrapped
) {
7267 AltClickHandler
.prototype._wrappedRowsForRow = function (currentRow
) {
7269 var lineWraps
= this._lines
.get(currentRow
).isWrapped
;
7270 while (lineWraps
&& currentRow
>= 0 && currentRow
< this._terminal
.rows
) {
7273 lineWraps
= this._lines
.get(currentRow
).isWrapped
;
7277 AltClickHandler
.prototype._horizontalDirection = function () {
7279 if (this._moveToRequestedRow().length
> 0) {
7280 startRow
= this._endRow
- this._wrappedRowsForRow(this._endRow
);
7283 startRow
= this._startRow
;
7285 if ((this._startCol
< this._endCol
&&
7286 startRow
<= this._endRow
) ||
7287 (this._startCol
>= this._endCol
&&
7288 startRow
< this._endRow
)) {
7293 AltClickHandler
.prototype._verticalDirection = function () {
7294 if (this._startRow
> this._endRow
) {
7299 AltClickHandler
.prototype._bufferLine = function (startCol
, startRow
, endCol
, endRow
, forward
) {
7300 var currentCol
= startCol
;
7301 var currentRow
= startRow
;
7303 while (currentCol
!== endCol
|| currentRow
!== endRow
) {
7304 currentCol
+= forward
? 1 : -1;
7305 if (forward
&& currentCol
> this._terminal
.cols
- 1) {
7306 bufferStr
+= this._terminal
.buffer
.translateBufferLineToString(currentRow
, false, startCol
, currentCol
);
7311 else if (!forward
&& currentCol
< 0) {
7312 bufferStr
+= this._terminal
.buffer
.translateBufferLineToString(currentRow
, false, 0, startCol
+ 1);
7313 currentCol
= this._terminal
.cols
- 1;
7314 startCol
= currentCol
;
7318 return bufferStr
+ this._terminal
.buffer
.translateBufferLineToString(currentRow
, false, startCol
, currentCol
);
7320 AltClickHandler
.prototype._sequence = function (direction
) {
7321 var mod
= this._terminal
.applicationCursor
? 'O' : '[';
7322 return EscapeSequences_1
.C0
.ESC
+ mod
+ direction
;
7324 return AltClickHandler
;
7326 exports
.AltClickHandler
= AltClickHandler
;
7327 function repeat(count
, str
) {
7328 count
= Math
.floor(count
);
7330 for (var i
= 0; i
< count
; i
++) {
7336 },{"../common/data/EscapeSequences":29}],34:[function(require
,module
,exports
){
7338 Object
.defineProperty(exports
, "__esModule", { value
: true });
7339 var Terminal_1
= require("../Terminal");
7340 var Strings
= require("../Strings");
7341 var Terminal
= (function () {
7342 function Terminal(options
) {
7343 this._core
= new Terminal_1
.Terminal(options
);
7345 Object
.defineProperty(Terminal
.prototype, "onCursorMove", {
7346 get: function () { return this._core
.onCursorMove
; },
7350 Object
.defineProperty(Terminal
.prototype, "onLineFeed", {
7351 get: function () { return this._core
.onLineFeed
; },
7355 Object
.defineProperty(Terminal
.prototype, "onSelectionChange", {
7356 get: function () { return this._core
.onSelectionChange
; },
7360 Object
.defineProperty(Terminal
.prototype, "onData", {
7361 get: function () { return this._core
.onData
; },
7365 Object
.defineProperty(Terminal
.prototype, "onTitleChange", {
7366 get: function () { return this._core
.onTitleChange
; },
7370 Object
.defineProperty(Terminal
.prototype, "onScroll", {
7371 get: function () { return this._core
.onScroll
; },
7375 Object
.defineProperty(Terminal
.prototype, "onKey", {
7376 get: function () { return this._core
.onKey
; },
7380 Object
.defineProperty(Terminal
.prototype, "onRender", {
7381 get: function () { return this._core
.onRender
; },
7385 Object
.defineProperty(Terminal
.prototype, "onResize", {
7386 get: function () { return this._core
.onResize
; },
7390 Object
.defineProperty(Terminal
.prototype, "element", {
7391 get: function () { return this._core
.element
; },
7395 Object
.defineProperty(Terminal
.prototype, "textarea", {
7396 get: function () { return this._core
.textarea
; },
7400 Object
.defineProperty(Terminal
.prototype, "rows", {
7401 get: function () { return this._core
.rows
; },
7405 Object
.defineProperty(Terminal
.prototype, "cols", {
7406 get: function () { return this._core
.cols
; },
7410 Object
.defineProperty(Terminal
.prototype, "markers", {
7411 get: function () { return this._core
.markers
; },
7415 Terminal
.prototype.blur = function () {
7418 Terminal
.prototype.focus = function () {
7421 Terminal
.prototype.on = function (type
, listener
) {
7422 this._core
.on(type
, listener
);
7424 Terminal
.prototype.off = function (type
, listener
) {
7425 this._core
.off(type
, listener
);
7427 Terminal
.prototype.emit = function (type
, data
) {
7428 this._core
.emit(type
, data
);
7430 Terminal
.prototype.addDisposableListener = function (type
, handler
) {
7431 return this._core
.addDisposableListener(type
, handler
);
7433 Terminal
.prototype.resize = function (columns
, rows
) {
7434 this._core
.resize(columns
, rows
);
7436 Terminal
.prototype.writeln = function (data
) {
7437 this._core
.writeln(data
);
7439 Terminal
.prototype.open = function (parent
) {
7440 this._core
.open(parent
);
7442 Terminal
.prototype.attachCustomKeyEventHandler = function (customKeyEventHandler
) {
7443 this._core
.attachCustomKeyEventHandler(customKeyEventHandler
);
7445 Terminal
.prototype.addCsiHandler = function (flag
, callback
) {
7446 return this._core
.addCsiHandler(flag
, callback
);
7448 Terminal
.prototype.addOscHandler = function (ident
, callback
) {
7449 return this._core
.addOscHandler(ident
, callback
);
7451 Terminal
.prototype.registerLinkMatcher = function (regex
, handler
, options
) {
7452 return this._core
.registerLinkMatcher(regex
, handler
, options
);
7454 Terminal
.prototype.deregisterLinkMatcher = function (matcherId
) {
7455 this._core
.deregisterLinkMatcher(matcherId
);
7457 Terminal
.prototype.registerCharacterJoiner = function (handler
) {
7458 return this._core
.registerCharacterJoiner(handler
);
7460 Terminal
.prototype.deregisterCharacterJoiner = function (joinerId
) {
7461 this._core
.deregisterCharacterJoiner(joinerId
);
7463 Terminal
.prototype.addMarker = function (cursorYOffset
) {
7464 return this._core
.addMarker(cursorYOffset
);
7466 Terminal
.prototype.hasSelection = function () {
7467 return this._core
.hasSelection();
7469 Terminal
.prototype.getSelection = function () {
7470 return this._core
.getSelection();
7472 Terminal
.prototype.clearSelection = function () {
7473 this._core
.clearSelection();
7475 Terminal
.prototype.selectAll = function () {
7476 this._core
.selectAll();
7478 Terminal
.prototype.selectLines = function (start
, end
) {
7479 this._core
.selectLines(start
, end
);
7481 Terminal
.prototype.dispose = function () {
7482 this._core
.dispose();
7484 Terminal
.prototype.destroy = function () {
7485 this._core
.destroy();
7487 Terminal
.prototype.scrollLines = function (amount
) {
7488 this._core
.scrollLines(amount
);
7490 Terminal
.prototype.scrollPages = function (pageCount
) {
7491 this._core
.scrollPages(pageCount
);
7493 Terminal
.prototype.scrollToTop = function () {
7494 this._core
.scrollToTop();
7496 Terminal
.prototype.scrollToBottom = function () {
7497 this._core
.scrollToBottom();
7499 Terminal
.prototype.scrollToLine = function (line
) {
7500 this._core
.scrollToLine(line
);
7502 Terminal
.prototype.clear = function () {
7505 Terminal
.prototype.write = function (data
) {
7506 this._core
.write(data
);
7508 Terminal
.prototype.getOption = function (key
) {
7509 return this._core
.getOption(key
);
7511 Terminal
.prototype.setOption = function (key
, value
) {
7512 this._core
.setOption(key
, value
);
7514 Terminal
.prototype.refresh = function (start
, end
) {
7515 this._core
.refresh(start
, end
);
7517 Terminal
.prototype.reset = function () {
7520 Terminal
.applyAddon = function (addon
) {
7521 addon
.apply(Terminal
);
7523 Object
.defineProperty(Terminal
, "strings", {
7532 exports
.Terminal
= Terminal
;
7534 },{"../Strings":18,"../Terminal":19}],35:[function(require
,module
,exports
){
7536 Object
.defineProperty(exports
, "__esModule", { value
: true });
7537 var Types_1
= require("./atlas/Types");
7538 var CharAtlasCache_1
= require("./atlas/CharAtlasCache");
7539 var BufferLine_1
= require("../BufferLine");
7540 var Buffer_1
= require("../Buffer");
7541 var CharacterJoinerRegistry_1
= require("./CharacterJoinerRegistry");
7542 var BaseRenderLayer
= (function () {
7543 function BaseRenderLayer(_container
, id
, zIndex
, _alpha
, _colors
) {
7544 this._container
= _container
;
7545 this._alpha
= _alpha
;
7546 this._colors
= _colors
;
7547 this._scaledCharWidth
= 0;
7548 this._scaledCharHeight
= 0;
7549 this._scaledCellWidth
= 0;
7550 this._scaledCellHeight
= 0;
7551 this._scaledCharLeft
= 0;
7552 this._scaledCharTop
= 0;
7553 this._currentGlyphIdentifier
= {
7562 this._canvas
= document
.createElement('canvas');
7563 this._canvas
.classList
.add("xterm-" + id
+ "-layer");
7564 this._canvas
.style
.zIndex
= zIndex
.toString();
7566 this._container
.appendChild(this._canvas
);
7568 BaseRenderLayer
.prototype.dispose = function () {
7569 this._container
.removeChild(this._canvas
);
7570 if (this._charAtlas
) {
7571 this._charAtlas
.dispose();
7574 BaseRenderLayer
.prototype._initCanvas = function () {
7575 this._ctx
= this._canvas
.getContext('2d', { alpha
: this._alpha
});
7580 BaseRenderLayer
.prototype.onOptionsChanged = function (terminal
) { };
7581 BaseRenderLayer
.prototype.onBlur = function (terminal
) { };
7582 BaseRenderLayer
.prototype.onFocus = function (terminal
) { };
7583 BaseRenderLayer
.prototype.onCursorMove = function (terminal
) { };
7584 BaseRenderLayer
.prototype.onGridChanged = function (terminal
, startRow
, endRow
) { };
7585 BaseRenderLayer
.prototype.onSelectionChanged = function (terminal
, start
, end
, columnSelectMode
) {
7586 if (columnSelectMode
=== void 0) { columnSelectMode
= false; }
7588 BaseRenderLayer
.prototype.onThemeChanged = function (terminal
, colorSet
) {
7589 this._refreshCharAtlas(terminal
, colorSet
);
7591 BaseRenderLayer
.prototype.setTransparency = function (terminal
, alpha
) {
7592 if (alpha
=== this._alpha
) {
7595 var oldCanvas
= this._canvas
;
7596 this._alpha
= alpha
;
7597 this._canvas
= this._canvas
.cloneNode();
7599 this._container
.replaceChild(this._canvas
, oldCanvas
);
7600 this._refreshCharAtlas(terminal
, this._colors
);
7601 this.onGridChanged(terminal
, 0, terminal
.rows
- 1);
7603 BaseRenderLayer
.prototype._refreshCharAtlas = function (terminal
, colorSet
) {
7604 if (this._scaledCharWidth
<= 0 && this._scaledCharHeight
<= 0) {
7607 this._charAtlas
= CharAtlasCache_1
.acquireCharAtlas(terminal
, colorSet
, this._scaledCharWidth
, this._scaledCharHeight
);
7608 this._charAtlas
.warmUp();
7610 BaseRenderLayer
.prototype.resize = function (terminal
, dim
) {
7611 this._scaledCellWidth
= dim
.scaledCellWidth
;
7612 this._scaledCellHeight
= dim
.scaledCellHeight
;
7613 this._scaledCharWidth
= dim
.scaledCharWidth
;
7614 this._scaledCharHeight
= dim
.scaledCharHeight
;
7615 this._scaledCharLeft
= dim
.scaledCharLeft
;
7616 this._scaledCharTop
= dim
.scaledCharTop
;
7617 this._canvas
.width
= dim
.scaledCanvasWidth
;
7618 this._canvas
.height
= dim
.scaledCanvasHeight
;
7619 this._canvas
.style
.width
= dim
.canvasWidth
+ "px";
7620 this._canvas
.style
.height
= dim
.canvasHeight
+ "px";
7624 this._refreshCharAtlas(terminal
, this._colors
);
7626 BaseRenderLayer
.prototype.fillCells = function (x
, y
, width
, height
) {
7627 this._ctx
.fillRect(x
* this._scaledCellWidth
, y
* this._scaledCellHeight
, width
* this._scaledCellWidth
, height
* this._scaledCellHeight
);
7629 BaseRenderLayer
.prototype.fillBottomLineAtCells = function (x
, y
, width
) {
7630 if (width
=== void 0) { width
= 1; }
7631 this._ctx
.fillRect(x
* this._scaledCellWidth
, (y
+ 1) * this._scaledCellHeight
- window
.devicePixelRatio
- 1, width
* this._scaledCellWidth
, window
.devicePixelRatio
);
7633 BaseRenderLayer
.prototype.fillLeftLineAtCell = function (x
, y
) {
7634 this._ctx
.fillRect(x
* this._scaledCellWidth
, y
* this._scaledCellHeight
, window
.devicePixelRatio
, this._scaledCellHeight
);
7636 BaseRenderLayer
.prototype.strokeRectAtCell = function (x
, y
, width
, height
) {
7637 this._ctx
.lineWidth
= window
.devicePixelRatio
;
7638 this._ctx
.strokeRect(x
* this._scaledCellWidth
+ window
.devicePixelRatio
/ 2, y
* this._scaledCellHeight
+ (window
.devicePixelRatio
/ 2), width
* this._scaledCellWidth
- window
.devicePixelRatio
, (height
* this._scaledCellHeight
) - window
.devicePixelRatio
);
7640 BaseRenderLayer
.prototype.clearAll = function () {
7642 this._ctx
.clearRect(0, 0, this._canvas
.width
, this._canvas
.height
);
7645 this._ctx
.fillStyle
= this._colors
.background
.css
;
7646 this._ctx
.fillRect(0, 0, this._canvas
.width
, this._canvas
.height
);
7649 BaseRenderLayer
.prototype.clearCells = function (x
, y
, width
, height
) {
7651 this._ctx
.clearRect(x
* this._scaledCellWidth
, y
* this._scaledCellHeight
, width
* this._scaledCellWidth
, height
* this._scaledCellHeight
);
7654 this._ctx
.fillStyle
= this._colors
.background
.css
;
7655 this._ctx
.fillRect(x
* this._scaledCellWidth
, y
* this._scaledCellHeight
, width
* this._scaledCellWidth
, height
* this._scaledCellHeight
);
7658 BaseRenderLayer
.prototype.fillCharTrueColor = function (terminal
, cell
, x
, y
) {
7659 this._ctx
.font
= this._getFont(terminal
, false, false);
7660 this._ctx
.textBaseline
= 'middle';
7661 this._clipRow(terminal
, y
);
7662 this._ctx
.fillText(cell
.getChars(), x
* this._scaledCellWidth
+ this._scaledCharLeft
, y
* this._scaledCellHeight
+ this._scaledCharTop
+ this._scaledCharHeight
/ 2);
7664 BaseRenderLayer
.prototype.drawChars = function (terminal
, cell
, x
, y
) {
7665 if (cell
.isFgRGB() || cell
.isBgRGB() || cell
instanceof CharacterJoinerRegistry_1
.JoinedCellData
) {
7666 this._drawUncachedChars(terminal
, cell
, x
, y
);
7671 if (cell
.isInverse()) {
7672 fg
= (cell
.isBgDefault()) ? Types_1
.INVERTED_DEFAULT_COLOR
: cell
.getBgColor();
7673 bg
= (cell
.isFgDefault()) ? Types_1
.INVERTED_DEFAULT_COLOR
: cell
.getFgColor();
7676 bg
= (cell
.isBgDefault()) ? Types_1
.DEFAULT_COLOR
: cell
.getBgColor();
7677 fg
= (cell
.isFgDefault()) ? Types_1
.DEFAULT_COLOR
: cell
.getFgColor();
7679 var drawInBrightColor
= terminal
.options
.drawBoldTextInBrightColors
&& cell
.isBold() && fg
< 8 && fg
!== Types_1
.INVERTED_DEFAULT_COLOR
;
7680 fg
+= drawInBrightColor
? 8 : 0;
7681 this._currentGlyphIdentifier
.chars
= cell
.getChars() || Buffer_1
.WHITESPACE_CELL_CHAR
;
7682 this._currentGlyphIdentifier
.code
= cell
.getCode() || Buffer_1
.WHITESPACE_CELL_CODE
;
7683 this._currentGlyphIdentifier
.bg
= bg
;
7684 this._currentGlyphIdentifier
.fg
= fg
;
7685 this._currentGlyphIdentifier
.bold
= cell
.isBold() && terminal
.options
.enableBold
;
7686 this._currentGlyphIdentifier
.dim
= !!cell
.isDim();
7687 this._currentGlyphIdentifier
.italic
= !!cell
.isItalic();
7688 var atlasDidDraw
= this._charAtlas
&& this._charAtlas
.draw(this._ctx
, this._currentGlyphIdentifier
, x
* this._scaledCellWidth
+ this._scaledCharLeft
, y
* this._scaledCellHeight
+ this._scaledCharTop
);
7689 if (!atlasDidDraw
) {
7690 this._drawUncachedChars(terminal
, cell
, x
, y
);
7693 BaseRenderLayer
.prototype._drawUncachedChars = function (terminal
, cell
, x
, y
) {
7695 this._ctx
.font
= this._getFont(terminal
, cell
.isBold() && terminal
.options
.enableBold
, !!cell
.isItalic());
7696 this._ctx
.textBaseline
= 'middle';
7697 if (cell
.isInverse()) {
7698 if (cell
.isBgDefault()) {
7699 this._ctx
.fillStyle
= this._colors
.background
.css
;
7701 else if (cell
.isBgRGB()) {
7702 this._ctx
.fillStyle
= "rgb(" + BufferLine_1
.AttributeData
.toColorRGB(cell
.getBgColor()).join(',') + ")";
7705 this._ctx
.fillStyle
= this._colors
.ansi
[cell
.getBgColor()].css
;
7709 if (cell
.isFgDefault()) {
7710 this._ctx
.fillStyle
= this._colors
.foreground
.css
;
7712 else if (cell
.isFgRGB()) {
7713 this._ctx
.fillStyle
= "rgb(" + BufferLine_1
.AttributeData
.toColorRGB(cell
.getFgColor()).join(',') + ")";
7716 var fg
= cell
.getFgColor();
7717 if (terminal
.options
.drawBoldTextInBrightColors
&& cell
.isBold() && fg
< 8) {
7720 this._ctx
.fillStyle
= this._colors
.ansi
[fg
].css
;
7723 this._clipRow(terminal
, y
);
7725 this._ctx
.globalAlpha
= Types_1
.DIM_OPACITY
;
7727 this._ctx
.fillText(cell
.getChars(), x
* this._scaledCellWidth
+ this._scaledCharLeft
, y
* this._scaledCellHeight
+ this._scaledCharTop
+ this._scaledCharHeight
/ 2);
7728 this._ctx
.restore();
7730 BaseRenderLayer
.prototype._clipRow = function (terminal
, y
) {
7731 this._ctx
.beginPath();
7732 this._ctx
.rect(0, y
* this._scaledCellHeight
, terminal
.cols
* this._scaledCellWidth
, this._scaledCellHeight
);
7735 BaseRenderLayer
.prototype._getFont = function (terminal
, isBold
, isItalic
) {
7736 var fontWeight
= isBold
? terminal
.options
.fontWeightBold
: terminal
.options
.fontWeight
;
7737 var fontStyle
= isItalic
? 'italic' : '';
7738 return fontStyle
+ " " + fontWeight
+ " " + terminal
.options
.fontSize
* window
.devicePixelRatio
+ "px " + terminal
.options
.fontFamily
;
7740 return BaseRenderLayer
;
7742 exports
.BaseRenderLayer
= BaseRenderLayer
;
7744 },{"../Buffer":2,"../BufferLine":3,"./CharacterJoinerRegistry":36,"./atlas/CharAtlasCache":45,"./atlas/Types":52}],36:[function(require
,module
,exports
){
7746 var __extends
= (this && this.__extends
) || (function () {
7747 var extendStatics = function (d
, b
) {
7748 extendStatics
= Object
.setPrototypeOf
||
7749 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
7750 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
7751 return extendStatics(d
, b
);
7753 return function (d
, b
) {
7754 extendStatics(d
, b
);
7755 function __() { this.constructor = d
; }
7756 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
7759 Object
.defineProperty(exports
, "__esModule", { value
: true });
7760 var BufferLine_1
= require("../BufferLine");
7761 var Buffer_1
= require("../Buffer");
7762 var JoinedCellData
= (function (_super
) {
7763 __extends(JoinedCellData
, _super
);
7764 function JoinedCellData(firstCell
, chars
, width
) {
7765 var _this
= _super
.call(this) || this;
7767 _this
.combinedData
= '';
7768 _this
.fg
= firstCell
.fg
;
7769 _this
.bg
= firstCell
.bg
;
7770 _this
.combinedData
= chars
;
7771 _this
._width
= width
;
7774 JoinedCellData
.prototype.isCombined = function () {
7777 JoinedCellData
.prototype.getWidth = function () {
7780 JoinedCellData
.prototype.getChars = function () {
7781 return this.combinedData
;
7783 JoinedCellData
.prototype.getCode = function () {
7786 JoinedCellData
.prototype.setFromCharData = function (value
) {
7787 throw new Error('not implemented');
7789 JoinedCellData
.prototype.getAsCharData = function () {
7790 return [this.fg
, this.getChars(), this.getWidth(), this.getCode()];
7792 return JoinedCellData
;
7793 }(BufferLine_1
.AttributeData
));
7794 exports
.JoinedCellData
= JoinedCellData
;
7795 var CharacterJoinerRegistry
= (function () {
7796 function CharacterJoinerRegistry(_terminal
) {
7797 this._terminal
= _terminal
;
7798 this._characterJoiners
= [];
7799 this._nextCharacterJoinerId
= 0;
7800 this._workCell
= new BufferLine_1
.CellData();
7802 CharacterJoinerRegistry
.prototype.registerCharacterJoiner = function (handler
) {
7804 id
: this._nextCharacterJoinerId
++,
7807 this._characterJoiners
.push(joiner
);
7810 CharacterJoinerRegistry
.prototype.deregisterCharacterJoiner = function (joinerId
) {
7811 for (var i
= 0; i
< this._characterJoiners
.length
; i
++) {
7812 if (this._characterJoiners
[i
].id
=== joinerId
) {
7813 this._characterJoiners
.splice(i
, 1);
7819 CharacterJoinerRegistry
.prototype.getJoinedCharacters = function (row
) {
7820 if (this._characterJoiners
.length
=== 0) {
7823 var line
= this._terminal
.buffer
.lines
.get(row
);
7824 if (line
.length
=== 0) {
7828 var lineStr
= line
.translateToString(true);
7829 var rangeStartColumn
= 0;
7830 var currentStringIndex
= 0;
7831 var rangeStartStringIndex
= 0;
7832 var rangeAttrFG
= line
.getFg(0);
7833 var rangeAttrBG
= line
.getBg(0);
7834 for (var x
= 0; x
< line
.getTrimmedLength(); x
++) {
7835 line
.loadCell(x
, this._workCell
);
7836 if (this._workCell
.getWidth() === 0) {
7839 if (this._workCell
.fg
!== rangeAttrFG
|| this._workCell
.bg
!== rangeAttrBG
) {
7840 if (x
- rangeStartColumn
> 1) {
7841 var joinedRanges
= this._getJoinedRanges(lineStr
, rangeStartStringIndex
, currentStringIndex
, line
, rangeStartColumn
);
7842 for (var i
= 0; i
< joinedRanges
.length
; i
++) {
7843 ranges
.push(joinedRanges
[i
]);
7846 rangeStartColumn
= x
;
7847 rangeStartStringIndex
= currentStringIndex
;
7848 rangeAttrFG
= this._workCell
.fg
;
7849 rangeAttrBG
= this._workCell
.bg
;
7851 currentStringIndex
+= this._workCell
.getChars().length
|| Buffer_1
.WHITESPACE_CELL_CHAR
.length
;
7853 if (this._terminal
.cols
- rangeStartColumn
> 1) {
7854 var joinedRanges
= this._getJoinedRanges(lineStr
, rangeStartStringIndex
, currentStringIndex
, line
, rangeStartColumn
);
7855 for (var i
= 0; i
< joinedRanges
.length
; i
++) {
7856 ranges
.push(joinedRanges
[i
]);
7861 CharacterJoinerRegistry
.prototype._getJoinedRanges = function (line
, startIndex
, endIndex
, lineData
, startCol
) {
7862 var text
= line
.substring(startIndex
, endIndex
);
7863 var joinedRanges
= this._characterJoiners
[0].handler(text
);
7864 for (var i
= 1; i
< this._characterJoiners
.length
; i
++) {
7865 var joinerRanges
= this._characterJoiners
[i
].handler(text
);
7866 for (var j
= 0; j
< joinerRanges
.length
; j
++) {
7867 CharacterJoinerRegistry
._mergeRanges(joinedRanges
, joinerRanges
[j
]);
7870 this._stringRangesToCellRanges(joinedRanges
, lineData
, startCol
);
7871 return joinedRanges
;
7873 CharacterJoinerRegistry
.prototype._stringRangesToCellRanges = function (ranges
, line
, startCol
) {
7874 var currentRangeIndex
= 0;
7875 var currentRangeStarted
= false;
7876 var currentStringIndex
= 0;
7877 var currentRange
= ranges
[currentRangeIndex
];
7878 if (!currentRange
) {
7881 for (var x
= startCol
; x
< this._terminal
.cols
; x
++) {
7882 var width
= line
.getWidth(x
);
7883 var length_1
= line
.getString(x
).length
|| Buffer_1
.WHITESPACE_CELL_CHAR
.length
;
7887 if (!currentRangeStarted
&& currentRange
[0] <= currentStringIndex
) {
7888 currentRange
[0] = x
;
7889 currentRangeStarted
= true;
7891 if (currentRange
[1] <= currentStringIndex
) {
7892 currentRange
[1] = x
;
7893 currentRange
= ranges
[++currentRangeIndex
];
7894 if (!currentRange
) {
7897 if (currentRange
[0] <= currentStringIndex
) {
7898 currentRange
[0] = x
;
7899 currentRangeStarted
= true;
7902 currentRangeStarted
= false;
7905 currentStringIndex
+= length_1
;
7908 currentRange
[1] = this._terminal
.cols
;
7911 CharacterJoinerRegistry
._mergeRanges = function (ranges
, newRange
) {
7912 var inRange
= false;
7913 for (var i
= 0; i
< ranges
.length
; i
++) {
7914 var range
= ranges
[i
];
7916 if (newRange
[1] <= range
[0]) {
7917 ranges
.splice(i
, 0, newRange
);
7920 if (newRange
[1] <= range
[1]) {
7921 range
[0] = Math
.min(newRange
[0], range
[0]);
7924 if (newRange
[0] < range
[1]) {
7925 range
[0] = Math
.min(newRange
[0], range
[0]);
7931 if (newRange
[1] <= range
[0]) {
7932 ranges
[i
- 1][1] = newRange
[1];
7935 if (newRange
[1] <= range
[1]) {
7936 ranges
[i
- 1][1] = Math
.max(newRange
[1], range
[1]);
7937 ranges
.splice(i
, 1);
7941 ranges
.splice(i
, 1);
7946 ranges
[ranges
.length
- 1][1] = newRange
[1];
7949 ranges
.push(newRange
);
7953 return CharacterJoinerRegistry
;
7955 exports
.CharacterJoinerRegistry
= CharacterJoinerRegistry
;
7957 },{"../Buffer":2,"../BufferLine":3}],37:[function(require
,module
,exports
){
7959 Object
.defineProperty(exports
, "__esModule", { value
: true });
7960 var DEFAULT_FOREGROUND
= fromHex('#ffffff');
7961 var DEFAULT_BACKGROUND
= fromHex('#000000');
7962 var DEFAULT_CURSOR
= fromHex('#ffffff');
7963 var DEFAULT_CURSOR_ACCENT
= fromHex('#000000');
7964 var DEFAULT_SELECTION
= {
7965 css
: 'rgba(255, 255, 255, 0.3)',
7968 exports
.DEFAULT_ANSI_COLORS
= (function () {
7987 var v
= [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
7988 for (var i
= 0; i
< 216; i
++) {
7989 var r
= v
[(i
/ 36) % 6 | 0];
7990 var g
= v
[(i
/ 6) % 6 | 0];
7993 css
: "#" + toPaddedHex(r
) + toPaddedHex(g
) + toPaddedHex(b
),
7994 rgba
: ((r
<< 24) | (g
<< 16) | (b
<< 8) | 0xFF) >>> 0
7997 for (var i
= 0; i
< 24; i
++) {
7999 var ch
= toPaddedHex(c
);
8001 css
: "#" + ch
+ ch
+ ch
,
8002 rgba
: ((c
<< 24) | (c
<< 16) | (c
<< 8) | 0xFF) >>> 0
8007 function fromHex(css
) {
8010 rgba
: parseInt(css
.slice(1), 16) << 8 | 0xFF
8013 function toPaddedHex(c
) {
8014 var s
= c
.toString(16);
8015 return s
.length
< 2 ? '0' + s
: s
;
8017 var ColorManager
= (function () {
8018 function ColorManager(document
, allowTransparency
) {
8019 this.allowTransparency
= allowTransparency
;
8020 var canvas
= document
.createElement('canvas');
8023 this._ctx
= canvas
.getContext('2d');
8024 this._ctx
.globalCompositeOperation
= 'copy';
8025 this._litmusColor
= this._ctx
.createLinearGradient(0, 0, 1, 1);
8027 foreground
: DEFAULT_FOREGROUND
,
8028 background
: DEFAULT_BACKGROUND
,
8029 cursor
: DEFAULT_CURSOR
,
8030 cursorAccent
: DEFAULT_CURSOR_ACCENT
,
8031 selection
: DEFAULT_SELECTION
,
8032 ansi
: exports
.DEFAULT_ANSI_COLORS
.slice()
8035 ColorManager
.prototype.setTheme = function (theme
) {
8036 this.colors
.foreground
= this._parseColor(theme
.foreground
, DEFAULT_FOREGROUND
);
8037 this.colors
.background
= this._parseColor(theme
.background
, DEFAULT_BACKGROUND
);
8038 this.colors
.cursor
= this._parseColor(theme
.cursor
, DEFAULT_CURSOR
, true);
8039 this.colors
.cursorAccent
= this._parseColor(theme
.cursorAccent
, DEFAULT_CURSOR_ACCENT
, true);
8040 this.colors
.selection
= this._parseColor(theme
.selection
, DEFAULT_SELECTION
, true);
8041 this.colors
.ansi
[0] = this._parseColor(theme
.black
, exports
.DEFAULT_ANSI_COLORS
[0]);
8042 this.colors
.ansi
[1] = this._parseColor(theme
.red
, exports
.DEFAULT_ANSI_COLORS
[1]);
8043 this.colors
.ansi
[2] = this._parseColor(theme
.green
, exports
.DEFAULT_ANSI_COLORS
[2]);
8044 this.colors
.ansi
[3] = this._parseColor(theme
.yellow
, exports
.DEFAULT_ANSI_COLORS
[3]);
8045 this.colors
.ansi
[4] = this._parseColor(theme
.blue
, exports
.DEFAULT_ANSI_COLORS
[4]);
8046 this.colors
.ansi
[5] = this._parseColor(theme
.magenta
, exports
.DEFAULT_ANSI_COLORS
[5]);
8047 this.colors
.ansi
[6] = this._parseColor(theme
.cyan
, exports
.DEFAULT_ANSI_COLORS
[6]);
8048 this.colors
.ansi
[7] = this._parseColor(theme
.white
, exports
.DEFAULT_ANSI_COLORS
[7]);
8049 this.colors
.ansi
[8] = this._parseColor(theme
.brightBlack
, exports
.DEFAULT_ANSI_COLORS
[8]);
8050 this.colors
.ansi
[9] = this._parseColor(theme
.brightRed
, exports
.DEFAULT_ANSI_COLORS
[9]);
8051 this.colors
.ansi
[10] = this._parseColor(theme
.brightGreen
, exports
.DEFAULT_ANSI_COLORS
[10]);
8052 this.colors
.ansi
[11] = this._parseColor(theme
.brightYellow
, exports
.DEFAULT_ANSI_COLORS
[11]);
8053 this.colors
.ansi
[12] = this._parseColor(theme
.brightBlue
, exports
.DEFAULT_ANSI_COLORS
[12]);
8054 this.colors
.ansi
[13] = this._parseColor(theme
.brightMagenta
, exports
.DEFAULT_ANSI_COLORS
[13]);
8055 this.colors
.ansi
[14] = this._parseColor(theme
.brightCyan
, exports
.DEFAULT_ANSI_COLORS
[14]);
8056 this.colors
.ansi
[15] = this._parseColor(theme
.brightWhite
, exports
.DEFAULT_ANSI_COLORS
[15]);
8058 ColorManager
.prototype._parseColor = function (css
, fallback
, allowTransparency
) {
8059 if (allowTransparency
=== void 0) { allowTransparency
= this.allowTransparency
; }
8063 this._ctx
.fillStyle
= this._litmusColor
;
8064 this._ctx
.fillStyle
= css
;
8065 if (typeof this._ctx
.fillStyle
!== 'string') {
8066 console
.warn("Color: " + css
+ " is invalid using fallback " + fallback
.css
);
8069 this._ctx
.fillRect(0, 0, 1, 1);
8070 var data
= this._ctx
.getImageData(0, 0, 1, 1).data
;
8071 if (!allowTransparency
&& data
[3] !== 0xFF) {
8072 console
.warn("Color: " + css
+ " is using transparency, but allowTransparency is false. " +
8073 ("Using fallback " + fallback
.css
+ "."));
8078 rgba
: (data
[0] << 24 | data
[1] << 16 | data
[2] << 8 | data
[3]) >>> 0
8081 return ColorManager
;
8083 exports
.ColorManager
= ColorManager
;
8085 },{}],38:[function(require
,module
,exports
){
8087 var __extends
= (this && this.__extends
) || (function () {
8088 var extendStatics = function (d
, b
) {
8089 extendStatics
= Object
.setPrototypeOf
||
8090 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
8091 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
8092 return extendStatics(d
, b
);
8094 return function (d
, b
) {
8095 extendStatics(d
, b
);
8096 function __() { this.constructor = d
; }
8097 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
8100 Object
.defineProperty(exports
, "__esModule", { value
: true });
8101 var BaseRenderLayer_1
= require("./BaseRenderLayer");
8102 var BufferLine_1
= require("../BufferLine");
8103 var BLINK_INTERVAL
= 600;
8104 var CursorRenderLayer
= (function (_super
) {
8105 __extends(CursorRenderLayer
, _super
);
8106 function CursorRenderLayer(container
, zIndex
, colors
) {
8107 var _this
= _super
.call(this, container
, 'cursor', zIndex
, true, colors
) || this;
8108 _this
._cell
= new BufferLine_1
.CellData();
8116 _this
._cursorRenderers
= {
8117 'bar': _this
._renderBarCursor
.bind(_this
),
8118 'block': _this
._renderBlockCursor
.bind(_this
),
8119 'underline': _this
._renderUnderlineCursor
.bind(_this
)
8123 CursorRenderLayer
.prototype.resize = function (terminal
, dim
) {
8124 _super
.prototype.resize
.call(this, terminal
, dim
);
8133 CursorRenderLayer
.prototype.reset = function (terminal
) {
8134 this._clearCursor();
8135 if (this._cursorBlinkStateManager
) {
8136 this._cursorBlinkStateManager
.dispose();
8137 this._cursorBlinkStateManager
= null;
8138 this.onOptionsChanged(terminal
);
8141 CursorRenderLayer
.prototype.onBlur = function (terminal
) {
8142 if (this._cursorBlinkStateManager
) {
8143 this._cursorBlinkStateManager
.pause();
8145 terminal
.refresh(terminal
.buffer
.y
, terminal
.buffer
.y
);
8147 CursorRenderLayer
.prototype.onFocus = function (terminal
) {
8148 if (this._cursorBlinkStateManager
) {
8149 this._cursorBlinkStateManager
.resume(terminal
);
8152 terminal
.refresh(terminal
.buffer
.y
, terminal
.buffer
.y
);
8155 CursorRenderLayer
.prototype.onOptionsChanged = function (terminal
) {
8157 if (terminal
.options
.cursorBlink
) {
8158 if (!this._cursorBlinkStateManager
) {
8159 this._cursorBlinkStateManager
= new CursorBlinkStateManager(terminal
, function () {
8160 _this
._render(terminal
, true);
8165 if (this._cursorBlinkStateManager
) {
8166 this._cursorBlinkStateManager
.dispose();
8167 this._cursorBlinkStateManager
= null;
8169 terminal
.refresh(terminal
.buffer
.y
, terminal
.buffer
.y
);
8172 CursorRenderLayer
.prototype.onCursorMove = function (terminal
) {
8173 if (this._cursorBlinkStateManager
) {
8174 this._cursorBlinkStateManager
.restartBlinkAnimation(terminal
);
8177 CursorRenderLayer
.prototype.onGridChanged = function (terminal
, startRow
, endRow
) {
8178 if (!this._cursorBlinkStateManager
|| this._cursorBlinkStateManager
.isPaused
) {
8179 this._render(terminal
, false);
8182 this._cursorBlinkStateManager
.restartBlinkAnimation(terminal
);
8185 CursorRenderLayer
.prototype._render = function (terminal
, triggeredByAnimationFrame
) {
8186 if (!terminal
.cursorState
|| terminal
.cursorHidden
) {
8187 this._clearCursor();
8190 var cursorY
= terminal
.buffer
.ybase
+ terminal
.buffer
.y
;
8191 var viewportRelativeCursorY
= cursorY
- terminal
.buffer
.ydisp
;
8192 if (viewportRelativeCursorY
< 0 || viewportRelativeCursorY
>= terminal
.rows
) {
8193 this._clearCursor();
8196 terminal
.buffer
.lines
.get(cursorY
).loadCell(terminal
.buffer
.x
, this._cell
);
8197 if (this._cell
.content
=== undefined) {
8200 if (!terminal
.isFocused
) {
8201 this._clearCursor();
8203 this._ctx
.fillStyle
= this._colors
.cursor
.css
;
8204 this._renderBlurCursor(terminal
, terminal
.buffer
.x
, viewportRelativeCursorY
, this._cell
);
8205 this._ctx
.restore();
8206 this._state
.x
= terminal
.buffer
.x
;
8207 this._state
.y
= viewportRelativeCursorY
;
8208 this._state
.isFocused
= false;
8209 this._state
.style
= terminal
.options
.cursorStyle
;
8210 this._state
.width
= this._cell
.getWidth();
8213 if (this._cursorBlinkStateManager
&& !this._cursorBlinkStateManager
.isCursorVisible
) {
8214 this._clearCursor();
8218 if (this._state
.x
=== terminal
.buffer
.x
&&
8219 this._state
.y
=== viewportRelativeCursorY
&&
8220 this._state
.isFocused
=== terminal
.isFocused
&&
8221 this._state
.style
=== terminal
.options
.cursorStyle
&&
8222 this._state
.width
=== this._cell
.getWidth()) {
8225 this._clearCursor();
8228 this._cursorRenderers
[terminal
.options
.cursorStyle
|| 'block'](terminal
, terminal
.buffer
.x
, viewportRelativeCursorY
, this._cell
);
8229 this._ctx
.restore();
8230 this._state
.x
= terminal
.buffer
.x
;
8231 this._state
.y
= viewportRelativeCursorY
;
8232 this._state
.isFocused
= false;
8233 this._state
.style
= terminal
.options
.cursorStyle
;
8234 this._state
.width
= this._cell
.getWidth();
8236 CursorRenderLayer
.prototype._clearCursor = function () {
8238 this.clearCells(this._state
.x
, this._state
.y
, this._state
.width
, 1);
8248 CursorRenderLayer
.prototype._renderBarCursor = function (terminal
, x
, y
, cell
) {
8250 this._ctx
.fillStyle
= this._colors
.cursor
.css
;
8251 this.fillLeftLineAtCell(x
, y
);
8252 this._ctx
.restore();
8254 CursorRenderLayer
.prototype._renderBlockCursor = function (terminal
, x
, y
, cell
) {
8256 this._ctx
.fillStyle
= this._colors
.cursor
.css
;
8257 this.fillCells(x
, y
, cell
.getWidth(), 1);
8258 this._ctx
.fillStyle
= this._colors
.cursorAccent
.css
;
8259 this.fillCharTrueColor(terminal
, cell
, x
, y
);
8260 this._ctx
.restore();
8262 CursorRenderLayer
.prototype._renderUnderlineCursor = function (terminal
, x
, y
, cell
) {
8264 this._ctx
.fillStyle
= this._colors
.cursor
.css
;
8265 this.fillBottomLineAtCells(x
, y
);
8266 this._ctx
.restore();
8268 CursorRenderLayer
.prototype._renderBlurCursor = function (terminal
, x
, y
, cell
) {
8270 this._ctx
.strokeStyle
= this._colors
.cursor
.css
;
8271 this.strokeRectAtCell(x
, y
, cell
.getWidth(), 1);
8272 this._ctx
.restore();
8274 return CursorRenderLayer
;
8275 }(BaseRenderLayer_1
.BaseRenderLayer
));
8276 exports
.CursorRenderLayer
= CursorRenderLayer
;
8277 var CursorBlinkStateManager
= (function () {
8278 function CursorBlinkStateManager(terminal
, _renderCallback
) {
8279 this._renderCallback
= _renderCallback
;
8280 this.isCursorVisible
= true;
8281 if (terminal
.isFocused
) {
8282 this._restartInterval();
8285 Object
.defineProperty(CursorBlinkStateManager
.prototype, "isPaused", {
8286 get: function () { return !(this._blinkStartTimeout
|| this._blinkInterval
); },
8290 CursorBlinkStateManager
.prototype.dispose = function () {
8291 if (this._blinkInterval
) {
8292 window
.clearInterval(this._blinkInterval
);
8293 this._blinkInterval
= null;
8295 if (this._blinkStartTimeout
) {
8296 window
.clearTimeout(this._blinkStartTimeout
);
8297 this._blinkStartTimeout
= null;
8299 if (this._animationFrame
) {
8300 window
.cancelAnimationFrame(this._animationFrame
);
8301 this._animationFrame
= null;
8304 CursorBlinkStateManager
.prototype.restartBlinkAnimation = function (terminal
) {
8306 if (this.isPaused
) {
8309 this._animationTimeRestarted
= Date
.now();
8310 this.isCursorVisible
= true;
8311 if (!this._animationFrame
) {
8312 this._animationFrame
= window
.requestAnimationFrame(function () {
8313 _this
._renderCallback();
8314 _this
._animationFrame
= null;
8318 CursorBlinkStateManager
.prototype._restartInterval = function (timeToStart
) {
8320 if (timeToStart
=== void 0) { timeToStart
= BLINK_INTERVAL
; }
8321 if (this._blinkInterval
) {
8322 window
.clearInterval(this._blinkInterval
);
8324 this._blinkStartTimeout
= setTimeout(function () {
8325 if (_this
._animationTimeRestarted
) {
8326 var time
= BLINK_INTERVAL
- (Date
.now() - _this
._animationTimeRestarted
);
8327 _this
._animationTimeRestarted
= null;
8329 _this
._restartInterval(time
);
8333 _this
.isCursorVisible
= false;
8334 _this
._animationFrame
= window
.requestAnimationFrame(function () {
8335 _this
._renderCallback();
8336 _this
._animationFrame
= null;
8338 _this
._blinkInterval
= setInterval(function () {
8339 if (_this
._animationTimeRestarted
) {
8340 var time
= BLINK_INTERVAL
- (Date
.now() - _this
._animationTimeRestarted
);
8341 _this
._animationTimeRestarted
= null;
8342 _this
._restartInterval(time
);
8345 _this
.isCursorVisible
= !_this
.isCursorVisible
;
8346 _this
._animationFrame
= window
.requestAnimationFrame(function () {
8347 _this
._renderCallback();
8348 _this
._animationFrame
= null;
8353 CursorBlinkStateManager
.prototype.pause = function () {
8354 this.isCursorVisible
= true;
8355 if (this._blinkInterval
) {
8356 window
.clearInterval(this._blinkInterval
);
8357 this._blinkInterval
= null;
8359 if (this._blinkStartTimeout
) {
8360 window
.clearTimeout(this._blinkStartTimeout
);
8361 this._blinkStartTimeout
= null;
8363 if (this._animationFrame
) {
8364 window
.cancelAnimationFrame(this._animationFrame
);
8365 this._animationFrame
= null;
8368 CursorBlinkStateManager
.prototype.resume = function (terminal
) {
8369 this._animationTimeRestarted
= null;
8370 this._restartInterval();
8371 this.restartBlinkAnimation(terminal
);
8373 return CursorBlinkStateManager
;
8376 },{"../BufferLine":3,"./BaseRenderLayer":35}],39:[function(require
,module
,exports
){
8378 Object
.defineProperty(exports
, "__esModule", { value
: true });
8379 var GridCache
= (function () {
8380 function GridCache() {
8383 GridCache
.prototype.resize = function (width
, height
) {
8384 for (var x
= 0; x
< width
; x
++) {
8385 if (this.cache
.length
<= x
) {
8386 this.cache
.push([]);
8388 for (var y
= this.cache
[x
].length
; y
< height
; y
++) {
8389 this.cache
[x
].push(null);
8391 this.cache
[x
].length
= height
;
8393 this.cache
.length
= width
;
8395 GridCache
.prototype.clear = function () {
8396 for (var x
= 0; x
< this.cache
.length
; x
++) {
8397 for (var y
= 0; y
< this.cache
[x
].length
; y
++) {
8398 this.cache
[x
][y
] = null;
8404 exports
.GridCache
= GridCache
;
8406 },{}],40:[function(require
,module
,exports
){
8408 var __extends
= (this && this.__extends
) || (function () {
8409 var extendStatics = function (d
, b
) {
8410 extendStatics
= Object
.setPrototypeOf
||
8411 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
8412 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
8413 return extendStatics(d
, b
);
8415 return function (d
, b
) {
8416 extendStatics(d
, b
);
8417 function __() { this.constructor = d
; }
8418 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
8421 Object
.defineProperty(exports
, "__esModule", { value
: true });
8422 var BaseRenderLayer_1
= require("./BaseRenderLayer");
8423 var Types_1
= require("./atlas/Types");
8424 var CharAtlasUtils_1
= require("./atlas/CharAtlasUtils");
8425 var LinkRenderLayer
= (function (_super
) {
8426 __extends(LinkRenderLayer
, _super
);
8427 function LinkRenderLayer(container
, zIndex
, colors
, terminal
) {
8428 var _this
= _super
.call(this, container
, 'link', zIndex
, true, colors
) || this;
8429 _this
._state
= null;
8430 terminal
.linkifier
.onLinkHover(function (e
) { return _this
._onLinkHover(e
); });
8431 terminal
.linkifier
.onLinkLeave(function (e
) { return _this
._onLinkLeave(e
); });
8434 LinkRenderLayer
.prototype.resize = function (terminal
, dim
) {
8435 _super
.prototype.resize
.call(this, terminal
, dim
);
8438 LinkRenderLayer
.prototype.reset = function (terminal
) {
8439 this._clearCurrentLink();
8441 LinkRenderLayer
.prototype._clearCurrentLink = function () {
8443 this.clearCells(this._state
.x1
, this._state
.y1
, this._state
.cols
- this._state
.x1
, 1);
8444 var middleRowCount
= this._state
.y2
- this._state
.y1
- 1;
8445 if (middleRowCount
> 0) {
8446 this.clearCells(0, this._state
.y1
+ 1, this._state
.cols
, middleRowCount
);
8448 this.clearCells(0, this._state
.y2
, this._state
.x2
, 1);
8452 LinkRenderLayer
.prototype._onLinkHover = function (e
) {
8453 if (e
.fg
=== Types_1
.INVERTED_DEFAULT_COLOR
) {
8454 this._ctx
.fillStyle
= this._colors
.background
.css
;
8456 else if (CharAtlasUtils_1
.is256Color(e
.fg
)) {
8457 this._ctx
.fillStyle
= this._colors
.ansi
[e
.fg
].css
;
8460 this._ctx
.fillStyle
= this._colors
.foreground
.css
;
8462 if (e
.y1
=== e
.y2
) {
8463 this.fillBottomLineAtCells(e
.x1
, e
.y1
, e
.x2
- e
.x1
);
8466 this.fillBottomLineAtCells(e
.x1
, e
.y1
, e
.cols
- e
.x1
);
8467 for (var y
= e
.y1
+ 1; y
< e
.y2
; y
++) {
8468 this.fillBottomLineAtCells(0, y
, e
.cols
);
8470 this.fillBottomLineAtCells(0, e
.y2
, e
.x2
);
8474 LinkRenderLayer
.prototype._onLinkLeave = function (e
) {
8475 this._clearCurrentLink();
8477 return LinkRenderLayer
;
8478 }(BaseRenderLayer_1
.BaseRenderLayer
));
8479 exports
.LinkRenderLayer
= LinkRenderLayer
;
8481 },{"./BaseRenderLayer":35,"./atlas/CharAtlasUtils":47,"./atlas/Types":52}],41:[function(require
,module
,exports
){
8483 var __extends
= (this && this.__extends
) || (function () {
8484 var extendStatics = function (d
, b
) {
8485 extendStatics
= Object
.setPrototypeOf
||
8486 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
8487 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
8488 return extendStatics(d
, b
);
8490 return function (d
, b
) {
8491 extendStatics(d
, b
);
8492 function __() { this.constructor = d
; }
8493 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
8496 Object
.defineProperty(exports
, "__esModule", { value
: true });
8497 var TextRenderLayer_1
= require("./TextRenderLayer");
8498 var SelectionRenderLayer_1
= require("./SelectionRenderLayer");
8499 var CursorRenderLayer_1
= require("./CursorRenderLayer");
8500 var ColorManager_1
= require("./ColorManager");
8501 var LinkRenderLayer_1
= require("./LinkRenderLayer");
8502 var RenderDebouncer_1
= require("../ui/RenderDebouncer");
8503 var ScreenDprMonitor_1
= require("../ui/ScreenDprMonitor");
8504 var CharacterJoinerRegistry_1
= require("../renderer/CharacterJoinerRegistry");
8505 var EventEmitter2_1
= require("../common/EventEmitter2");
8506 var Lifecycle_1
= require("../common/Lifecycle");
8507 var Renderer
= (function (_super
) {
8508 __extends(Renderer
, _super
);
8509 function Renderer(_terminal
, theme
) {
8510 var _this
= _super
.call(this) || this;
8511 _this
._terminal
= _terminal
;
8512 _this
._isPaused
= false;
8513 _this
._needsFullRefresh
= false;
8514 _this
._onCanvasResize
= new EventEmitter2_1
.EventEmitter2();
8515 _this
._onRender
= new EventEmitter2_1
.EventEmitter2();
8516 var allowTransparency
= _this
._terminal
.options
.allowTransparency
;
8517 _this
.colorManager
= new ColorManager_1
.ColorManager(document
, allowTransparency
);
8518 _this
._characterJoinerRegistry
= new CharacterJoinerRegistry_1
.CharacterJoinerRegistry(_terminal
);
8520 _this
.colorManager
.setTheme(theme
);
8522 _this
._renderLayers
= [
8523 new TextRenderLayer_1
.TextRenderLayer(_this
._terminal
.screenElement
, 0, _this
.colorManager
.colors
, _this
._characterJoinerRegistry
, allowTransparency
),
8524 new SelectionRenderLayer_1
.SelectionRenderLayer(_this
._terminal
.screenElement
, 1, _this
.colorManager
.colors
),
8525 new LinkRenderLayer_1
.LinkRenderLayer(_this
._terminal
.screenElement
, 2, _this
.colorManager
.colors
, _this
._terminal
),
8526 new CursorRenderLayer_1
.CursorRenderLayer(_this
._terminal
.screenElement
, 3, _this
.colorManager
.colors
)
8528 _this
.dimensions
= {
8529 scaledCharWidth
: null,
8530 scaledCharHeight
: null,
8531 scaledCellWidth
: null,
8532 scaledCellHeight
: null,
8533 scaledCharLeft
: null,
8534 scaledCharTop
: null,
8535 scaledCanvasWidth
: null,
8536 scaledCanvasHeight
: null,
8539 actualCellWidth
: null,
8540 actualCellHeight
: null
8542 _this
._devicePixelRatio
= window
.devicePixelRatio
;
8543 _this
._updateDimensions();
8544 _this
.onOptionsChanged();
8545 _this
._renderDebouncer
= new RenderDebouncer_1
.RenderDebouncer(_this
._renderRows
.bind(_this
));
8546 _this
._screenDprMonitor
= new ScreenDprMonitor_1
.ScreenDprMonitor();
8547 _this
._screenDprMonitor
.setListener(function () { return _this
.onWindowResize(window
.devicePixelRatio
); });
8548 _this
.register(_this
._screenDprMonitor
);
8549 if ('IntersectionObserver' in window
) {
8550 var observer_1
= new IntersectionObserver(function (e
) { return _this
.onIntersectionChange(e
[e
.length
- 1]); }, { threshold
: 0 });
8551 observer_1
.observe(_this
._terminal
.element
);
8552 _this
.register({ dispose: function () { return observer_1
.disconnect(); } });
8556 Object
.defineProperty(Renderer
.prototype, "onCanvasResize", {
8557 get: function () { return this._onCanvasResize
.event
; },
8561 Object
.defineProperty(Renderer
.prototype, "onRender", {
8562 get: function () { return this._onRender
.event
; },
8566 Renderer
.prototype.dispose = function () {
8567 _super
.prototype.dispose
.call(this);
8568 this._renderLayers
.forEach(function (l
) { return l
.dispose(); });
8570 Renderer
.prototype.onIntersectionChange = function (entry
) {
8571 this._isPaused
= entry
.intersectionRatio
=== 0;
8572 if (!this._isPaused
&& this._needsFullRefresh
) {
8573 this._terminal
.refresh(0, this._terminal
.rows
- 1);
8574 this._needsFullRefresh
= false;
8577 Renderer
.prototype.onWindowResize = function (devicePixelRatio
) {
8578 if (this._devicePixelRatio
!== devicePixelRatio
) {
8579 this._devicePixelRatio
= devicePixelRatio
;
8580 this.onResize(this._terminal
.cols
, this._terminal
.rows
);
8583 Renderer
.prototype.setTheme = function (theme
) {
8585 this.colorManager
.setTheme(theme
);
8586 this._renderLayers
.forEach(function (l
) {
8587 l
.onThemeChanged(_this
._terminal
, _this
.colorManager
.colors
);
8588 l
.reset(_this
._terminal
);
8590 if (this._isPaused
) {
8591 this._needsFullRefresh
= true;
8594 this._terminal
.refresh(0, this._terminal
.rows
- 1);
8596 return this.colorManager
.colors
;
8598 Renderer
.prototype.onResize = function (cols
, rows
) {
8600 this._updateDimensions();
8601 this._renderLayers
.forEach(function (l
) { return l
.resize(_this
._terminal
, _this
.dimensions
); });
8602 if (this._isPaused
) {
8603 this._needsFullRefresh
= true;
8606 this._terminal
.refresh(0, this._terminal
.rows
- 1);
8608 this._terminal
.screenElement
.style
.width
= this.dimensions
.canvasWidth
+ "px";
8609 this._terminal
.screenElement
.style
.height
= this.dimensions
.canvasHeight
+ "px";
8610 this._onCanvasResize
.fire({
8611 width
: this.dimensions
.canvasWidth
,
8612 height
: this.dimensions
.canvasHeight
8615 Renderer
.prototype.onCharSizeChanged = function () {
8616 this.onResize(this._terminal
.cols
, this._terminal
.rows
);
8618 Renderer
.prototype.onBlur = function () {
8620 this._runOperation(function (l
) { return l
.onBlur(_this
._terminal
); });
8622 Renderer
.prototype.onFocus = function () {
8624 this._runOperation(function (l
) { return l
.onFocus(_this
._terminal
); });
8626 Renderer
.prototype.onSelectionChanged = function (start
, end
, columnSelectMode
) {
8628 if (columnSelectMode
=== void 0) { columnSelectMode
= false; }
8629 this._runOperation(function (l
) { return l
.onSelectionChanged(_this
._terminal
, start
, end
, columnSelectMode
); });
8631 Renderer
.prototype.onCursorMove = function () {
8633 this._runOperation(function (l
) { return l
.onCursorMove(_this
._terminal
); });
8635 Renderer
.prototype.onOptionsChanged = function () {
8637 this.colorManager
.allowTransparency
= this._terminal
.options
.allowTransparency
;
8638 this._runOperation(function (l
) { return l
.onOptionsChanged(_this
._terminal
); });
8640 Renderer
.prototype.clear = function () {
8642 this._runOperation(function (l
) { return l
.reset(_this
._terminal
); });
8644 Renderer
.prototype._runOperation = function (operation
) {
8645 if (this._isPaused
) {
8646 this._needsFullRefresh
= true;
8649 this._renderLayers
.forEach(function (l
) { return operation(l
); });
8652 Renderer
.prototype.refreshRows = function (start
, end
) {
8653 if (this._isPaused
) {
8654 this._needsFullRefresh
= true;
8657 this._renderDebouncer
.refresh(start
, end
, this._terminal
.rows
);
8659 Renderer
.prototype._renderRows = function (start
, end
) {
8661 this._renderLayers
.forEach(function (l
) { return l
.onGridChanged(_this
._terminal
, start
, end
); });
8662 this._onRender
.fire({ start
: start
, end
: end
});
8664 Renderer
.prototype._updateDimensions = function () {
8665 if (!this._terminal
.charMeasure
.width
|| !this._terminal
.charMeasure
.height
) {
8668 this.dimensions
.scaledCharWidth
= Math
.floor(this._terminal
.charMeasure
.width
* window
.devicePixelRatio
);
8669 this.dimensions
.scaledCharHeight
= Math
.ceil(this._terminal
.charMeasure
.height
* window
.devicePixelRatio
);
8670 this.dimensions
.scaledCellHeight
= Math
.floor(this.dimensions
.scaledCharHeight
* this._terminal
.options
.lineHeight
);
8671 this.dimensions
.scaledCharTop
= this._terminal
.options
.lineHeight
=== 1 ? 0 : Math
.round((this.dimensions
.scaledCellHeight
- this.dimensions
.scaledCharHeight
) / 2);
8672 this.dimensions
.scaledCellWidth
= this.dimensions
.scaledCharWidth
+ Math
.round(this._terminal
.options
.letterSpacing
);
8673 this.dimensions
.scaledCharLeft
= Math
.floor(this._terminal
.options
.letterSpacing
/ 2);
8674 this.dimensions
.scaledCanvasHeight
= this._terminal
.rows
* this.dimensions
.scaledCellHeight
;
8675 this.dimensions
.scaledCanvasWidth
= this._terminal
.cols
* this.dimensions
.scaledCellWidth
;
8676 this.dimensions
.canvasHeight
= Math
.round(this.dimensions
.scaledCanvasHeight
/ window
.devicePixelRatio
);
8677 this.dimensions
.canvasWidth
= Math
.round(this.dimensions
.scaledCanvasWidth
/ window
.devicePixelRatio
);
8678 this.dimensions
.actualCellHeight
= this.dimensions
.canvasHeight
/ this._terminal
.rows
;
8679 this.dimensions
.actualCellWidth
= this.dimensions
.canvasWidth
/ this._terminal
.cols
;
8681 Renderer
.prototype.registerCharacterJoiner = function (handler
) {
8682 return this._characterJoinerRegistry
.registerCharacterJoiner(handler
);
8684 Renderer
.prototype.deregisterCharacterJoiner = function (joinerId
) {
8685 return this._characterJoinerRegistry
.deregisterCharacterJoiner(joinerId
);
8688 }(Lifecycle_1
.Disposable
));
8689 exports
.Renderer
= Renderer
;
8691 },{"../common/EventEmitter2":25,"../common/Lifecycle":26,"../renderer/CharacterJoinerRegistry":36,"../ui/RenderDebouncer":56,"../ui/ScreenDprMonitor":57,"./ColorManager":37,"./CursorRenderLayer":38,"./LinkRenderLayer":40,"./SelectionRenderLayer":42,"./TextRenderLayer":43}],42:[function(require
,module
,exports
){
8693 var __extends
= (this && this.__extends
) || (function () {
8694 var extendStatics = function (d
, b
) {
8695 extendStatics
= Object
.setPrototypeOf
||
8696 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
8697 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
8698 return extendStatics(d
, b
);
8700 return function (d
, b
) {
8701 extendStatics(d
, b
);
8702 function __() { this.constructor = d
; }
8703 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
8706 Object
.defineProperty(exports
, "__esModule", { value
: true });
8707 var BaseRenderLayer_1
= require("./BaseRenderLayer");
8708 var SelectionRenderLayer
= (function (_super
) {
8709 __extends(SelectionRenderLayer
, _super
);
8710 function SelectionRenderLayer(container
, zIndex
, colors
) {
8711 var _this
= _super
.call(this, container
, 'selection', zIndex
, true, colors
) || this;
8712 _this
._clearState();
8715 SelectionRenderLayer
.prototype._clearState = function () {
8719 columnSelectMode
: null,
8723 SelectionRenderLayer
.prototype.resize = function (terminal
, dim
) {
8724 _super
.prototype.resize
.call(this, terminal
, dim
);
8727 SelectionRenderLayer
.prototype.reset = function (terminal
) {
8728 if (this._state
.start
&& this._state
.end
) {
8733 SelectionRenderLayer
.prototype.onSelectionChanged = function (terminal
, start
, end
, columnSelectMode
) {
8734 if (!this._didStateChange(start
, end
, columnSelectMode
, terminal
.buffer
.ydisp
)) {
8738 if (!start
|| !end
) {
8742 var viewportStartRow
= start
[1] - terminal
.buffer
.ydisp
;
8743 var viewportEndRow
= end
[1] - terminal
.buffer
.ydisp
;
8744 var viewportCappedStartRow
= Math
.max(viewportStartRow
, 0);
8745 var viewportCappedEndRow
= Math
.min(viewportEndRow
, terminal
.rows
- 1);
8746 if (viewportCappedStartRow
>= terminal
.rows
|| viewportCappedEndRow
< 0) {
8749 this._ctx
.fillStyle
= this._colors
.selection
.css
;
8750 if (columnSelectMode
) {
8751 var startCol
= start
[0];
8752 var width
= end
[0] - startCol
;
8753 var height
= viewportCappedEndRow
- viewportCappedStartRow
+ 1;
8754 this.fillCells(startCol
, viewportCappedStartRow
, width
, height
);
8757 var startCol
= viewportStartRow
=== viewportCappedStartRow
? start
[0] : 0;
8758 var startRowEndCol
= viewportCappedStartRow
=== viewportCappedEndRow
? end
[0] : terminal
.cols
;
8759 this.fillCells(startCol
, viewportCappedStartRow
, startRowEndCol
- startCol
, 1);
8760 var middleRowsCount
= Math
.max(viewportCappedEndRow
- viewportCappedStartRow
- 1, 0);
8761 this.fillCells(0, viewportCappedStartRow
+ 1, terminal
.cols
, middleRowsCount
);
8762 if (viewportCappedStartRow
!== viewportCappedEndRow
) {
8763 var endCol
= viewportEndRow
=== viewportCappedEndRow
? end
[0] : terminal
.cols
;
8764 this.fillCells(0, viewportCappedEndRow
, endCol
, 1);
8767 this._state
.start
= [start
[0], start
[1]];
8768 this._state
.end
= [end
[0], end
[1]];
8769 this._state
.columnSelectMode
= columnSelectMode
;
8770 this._state
.ydisp
= terminal
.buffer
.ydisp
;
8772 SelectionRenderLayer
.prototype._didStateChange = function (start
, end
, columnSelectMode
, ydisp
) {
8773 return !this._areCoordinatesEqual(start
, this._state
.start
) ||
8774 !this._areCoordinatesEqual(end
, this._state
.end
) ||
8775 columnSelectMode
!== this._state
.columnSelectMode
||
8776 ydisp
!== this._state
.ydisp
;
8778 SelectionRenderLayer
.prototype._areCoordinatesEqual = function (coord1
, coord2
) {
8779 if (!coord1
|| !coord2
) {
8782 return coord1
[0] === coord2
[0] && coord1
[1] === coord2
[1];
8784 return SelectionRenderLayer
;
8785 }(BaseRenderLayer_1
.BaseRenderLayer
));
8786 exports
.SelectionRenderLayer
= SelectionRenderLayer
;
8788 },{"./BaseRenderLayer":35}],43:[function(require
,module
,exports
){
8790 var __extends
= (this && this.__extends
) || (function () {
8791 var extendStatics = function (d
, b
) {
8792 extendStatics
= Object
.setPrototypeOf
||
8793 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
8794 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
8795 return extendStatics(d
, b
);
8797 return function (d
, b
) {
8798 extendStatics(d
, b
);
8799 function __() { this.constructor = d
; }
8800 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
8803 Object
.defineProperty(exports
, "__esModule", { value
: true });
8804 var Buffer_1
= require("../Buffer");
8805 var GridCache_1
= require("./GridCache");
8806 var BaseRenderLayer_1
= require("./BaseRenderLayer");
8807 var BufferLine_1
= require("../BufferLine");
8808 var CharacterJoinerRegistry_1
= require("./CharacterJoinerRegistry");
8809 var TextRenderLayer
= (function (_super
) {
8810 __extends(TextRenderLayer
, _super
);
8811 function TextRenderLayer(container
, zIndex
, colors
, characterJoinerRegistry
, alpha
) {
8812 var _this
= _super
.call(this, container
, 'text', zIndex
, alpha
, colors
) || this;
8813 _this
._characterOverlapCache
= {};
8814 _this
._workCell
= new BufferLine_1
.CellData();
8815 _this
._state
= new GridCache_1
.GridCache();
8816 _this
._characterJoinerRegistry
= characterJoinerRegistry
;
8819 TextRenderLayer
.prototype.resize = function (terminal
, dim
) {
8820 _super
.prototype.resize
.call(this, terminal
, dim
);
8821 var terminalFont
= this._getFont(terminal
, false, false);
8822 if (this._characterWidth
!== dim
.scaledCharWidth
|| this._characterFont
!== terminalFont
) {
8823 this._characterWidth
= dim
.scaledCharWidth
;
8824 this._characterFont
= terminalFont
;
8825 this._characterOverlapCache
= {};
8827 this._state
.clear();
8828 this._state
.resize(terminal
.cols
, terminal
.rows
);
8830 TextRenderLayer
.prototype.reset = function (terminal
) {
8831 this._state
.clear();
8834 TextRenderLayer
.prototype._forEachCell = function (terminal
, firstRow
, lastRow
, joinerRegistry
, callback
) {
8835 for (var y
= firstRow
; y
<= lastRow
; y
++) {
8836 var row
= y
+ terminal
.buffer
.ydisp
;
8837 var line
= terminal
.buffer
.lines
.get(row
);
8838 var joinedRanges
= joinerRegistry
? joinerRegistry
.getJoinedCharacters(row
) : [];
8839 for (var x
= 0; x
< terminal
.cols
; x
++) {
8840 line
.loadCell(x
, this._workCell
);
8841 var cell
= this._workCell
;
8842 var isJoined
= false;
8844 if (cell
.getWidth() === 0) {
8847 if (joinedRanges
.length
> 0 && x
=== joinedRanges
[0][0]) {
8849 var range
= joinedRanges
.shift();
8850 cell
= new CharacterJoinerRegistry_1
.JoinedCellData(this._workCell
, line
.translateToString(true, range
[0], range
[1]), range
[1] - range
[0]);
8851 lastCharX
= range
[1] - 1;
8853 if (!isJoined
&& this._isOverlapping(cell
)) {
8854 if (lastCharX
< line
.length
- 1 && line
.getCodePoint(lastCharX
+ 1) === Buffer_1
.NULL_CELL_CODE
) {
8855 cell
.content
&= ~12582912;
8856 cell
.content
|= 2 << 22;
8859 callback(cell
, x
, y
);
8864 TextRenderLayer
.prototype._drawBackground = function (terminal
, firstRow
, lastRow
) {
8866 var ctx
= this._ctx
;
8867 var cols
= terminal
.cols
;
8870 var prevFillStyle
= null;
8872 this._forEachCell(terminal
, firstRow
, lastRow
, null, function (cell
, x
, y
) {
8873 var nextFillStyle
= null;
8874 if (cell
.isInverse()) {
8875 if (cell
.isFgDefault()) {
8876 nextFillStyle
= _this
._colors
.foreground
.css
;
8878 else if (cell
.isFgRGB()) {
8879 nextFillStyle
= "rgb(" + BufferLine_1
.AttributeData
.toColorRGB(cell
.getFgColor()).join(',') + ")";
8882 nextFillStyle
= _this
._colors
.ansi
[cell
.getFgColor()].css
;
8885 else if (cell
.isBgRGB()) {
8886 nextFillStyle
= "rgb(" + BufferLine_1
.AttributeData
.toColorRGB(cell
.getBgColor()).join(',') + ")";
8888 else if (cell
.isBgPalette()) {
8889 nextFillStyle
= _this
._colors
.ansi
[cell
.getBgColor()].css
;
8891 if (prevFillStyle
=== null) {
8896 ctx
.fillStyle
= prevFillStyle
;
8897 _this
.fillCells(startX
, startY
, cols
- startX
, 1);
8901 else if (prevFillStyle
!== nextFillStyle
) {
8902 ctx
.fillStyle
= prevFillStyle
;
8903 _this
.fillCells(startX
, startY
, x
- startX
, 1);
8907 prevFillStyle
= nextFillStyle
;
8909 if (prevFillStyle
!== null) {
8910 ctx
.fillStyle
= prevFillStyle
;
8911 this.fillCells(startX
, startY
, cols
- startX
, 1);
8915 TextRenderLayer
.prototype._drawForeground = function (terminal
, firstRow
, lastRow
) {
8917 this._forEachCell(terminal
, firstRow
, lastRow
, this._characterJoinerRegistry
, function (cell
, x
, y
) {
8918 if (cell
.isInvisible()) {
8921 if (cell
.isUnderline()) {
8923 if (cell
.isInverse()) {
8924 if (cell
.isBgDefault()) {
8925 _this
._ctx
.fillStyle
= _this
._colors
.background
.css
;
8927 else if (cell
.isBgRGB()) {
8928 _this
._ctx
.fillStyle
= "rgb(" + BufferLine_1
.AttributeData
.toColorRGB(cell
.getBgColor()).join(',') + ")";
8931 _this
._ctx
.fillStyle
= _this
._colors
.ansi
[cell
.getBgColor()].css
;
8935 if (cell
.isFgDefault()) {
8936 _this
._ctx
.fillStyle
= _this
._colors
.foreground
.css
;
8938 else if (cell
.isFgRGB()) {
8939 _this
._ctx
.fillStyle
= "rgb(" + BufferLine_1
.AttributeData
.toColorRGB(cell
.getFgColor()).join(',') + ")";
8942 var fg
= cell
.getFgColor();
8943 if (terminal
.options
.drawBoldTextInBrightColors
&& cell
.isBold() && fg
< 8) {
8946 _this
._ctx
.fillStyle
= _this
._colors
.ansi
[fg
].css
;
8949 _this
.fillBottomLineAtCells(x
, y
, cell
.getWidth());
8950 _this
._ctx
.restore();
8952 _this
.drawChars(terminal
, cell
, x
, y
);
8955 TextRenderLayer
.prototype.onGridChanged = function (terminal
, firstRow
, lastRow
) {
8956 if (this._state
.cache
.length
=== 0) {
8959 if (this._charAtlas
) {
8960 this._charAtlas
.beginFrame();
8962 this.clearCells(0, firstRow
, terminal
.cols
, lastRow
- firstRow
+ 1);
8963 this._drawBackground(terminal
, firstRow
, lastRow
);
8964 this._drawForeground(terminal
, firstRow
, lastRow
);
8966 TextRenderLayer
.prototype.onOptionsChanged = function (terminal
) {
8967 this.setTransparency(terminal
, terminal
.options
.allowTransparency
);
8969 TextRenderLayer
.prototype._isOverlapping = function (cell
) {
8970 if (cell
.getWidth() !== 1) {
8973 if (cell
.getCode() < 256) {
8976 var chars
= cell
.getChars();
8977 if (this._characterOverlapCache
.hasOwnProperty(chars
)) {
8978 return this._characterOverlapCache
[chars
];
8981 this._ctx
.font
= this._characterFont
;
8982 var overlaps
= Math
.floor(this._ctx
.measureText(chars
).width
) > this._characterWidth
;
8983 this._ctx
.restore();
8984 this._characterOverlapCache
[chars
] = overlaps
;
8987 return TextRenderLayer
;
8988 }(BaseRenderLayer_1
.BaseRenderLayer
));
8989 exports
.TextRenderLayer
= TextRenderLayer
;
8991 },{"../Buffer":2,"../BufferLine":3,"./BaseRenderLayer":35,"./CharacterJoinerRegistry":36,"./GridCache":39}],44:[function(require
,module
,exports
){
8993 Object
.defineProperty(exports
, "__esModule", { value
: true });
8994 var BaseCharAtlas
= (function () {
8995 function BaseCharAtlas() {
8996 this._didWarmUp
= false;
8998 BaseCharAtlas
.prototype.dispose = function () { };
8999 BaseCharAtlas
.prototype.warmUp = function () {
9000 if (!this._didWarmUp
) {
9002 this._didWarmUp
= true;
9005 BaseCharAtlas
.prototype._doWarmUp = function () { };
9006 BaseCharAtlas
.prototype.beginFrame = function () { };
9007 return BaseCharAtlas
;
9009 exports
.default = BaseCharAtlas
;
9011 },{}],45:[function(require
,module
,exports
){
9013 Object
.defineProperty(exports
, "__esModule", { value
: true });
9014 var CharAtlasUtils_1
= require("./CharAtlasUtils");
9015 var DynamicCharAtlas_1
= require("./DynamicCharAtlas");
9016 var NoneCharAtlas_1
= require("./NoneCharAtlas");
9017 var StaticCharAtlas_1
= require("./StaticCharAtlas");
9018 var charAtlasImplementations
= {
9019 'none': NoneCharAtlas_1
.default,
9020 'static': StaticCharAtlas_1
.default,
9021 'dynamic': DynamicCharAtlas_1
.default
9023 var charAtlasCache
= [];
9024 function acquireCharAtlas(terminal
, colors
, scaledCharWidth
, scaledCharHeight
) {
9025 var newConfig
= CharAtlasUtils_1
.generateConfig(scaledCharWidth
, scaledCharHeight
, terminal
, colors
);
9026 for (var i
= 0; i
< charAtlasCache
.length
; i
++) {
9027 var entry
= charAtlasCache
[i
];
9028 var ownedByIndex
= entry
.ownedBy
.indexOf(terminal
);
9029 if (ownedByIndex
>= 0) {
9030 if (CharAtlasUtils_1
.configEquals(entry
.config
, newConfig
)) {
9033 if (entry
.ownedBy
.length
=== 1) {
9034 entry
.atlas
.dispose();
9035 charAtlasCache
.splice(i
, 1);
9038 entry
.ownedBy
.splice(ownedByIndex
, 1);
9043 for (var i
= 0; i
< charAtlasCache
.length
; i
++) {
9044 var entry
= charAtlasCache
[i
];
9045 if (CharAtlasUtils_1
.configEquals(entry
.config
, newConfig
)) {
9046 entry
.ownedBy
.push(terminal
);
9051 atlas
: new charAtlasImplementations
[terminal
.options
.experimentalCharAtlas
](document
, newConfig
),
9055 charAtlasCache
.push(newEntry
);
9056 return newEntry
.atlas
;
9058 exports
.acquireCharAtlas
= acquireCharAtlas
;
9059 function removeTerminalFromCache(terminal
) {
9060 for (var i
= 0; i
< charAtlasCache
.length
; i
++) {
9061 var index
= charAtlasCache
[i
].ownedBy
.indexOf(terminal
);
9063 if (charAtlasCache
[i
].ownedBy
.length
=== 1) {
9064 charAtlasCache
[i
].atlas
.dispose();
9065 charAtlasCache
.splice(i
, 1);
9068 charAtlasCache
[i
].ownedBy
.splice(index
, 1);
9074 exports
.removeTerminalFromCache
= removeTerminalFromCache
;
9076 },{"./CharAtlasUtils":47,"./DynamicCharAtlas":48,"./NoneCharAtlas":50,"./StaticCharAtlas":51}],46:[function(require
,module
,exports
){
9078 Object
.defineProperty(exports
, "__esModule", { value
: true });
9079 var Platform_1
= require("../../common/Platform");
9080 var Types_1
= require("./Types");
9081 function generateStaticCharAtlasTexture(context
, canvasFactory
, config
) {
9082 var cellWidth
= config
.scaledCharWidth
+ Types_1
.CHAR_ATLAS_CELL_SPACING
;
9083 var cellHeight
= config
.scaledCharHeight
+ Types_1
.CHAR_ATLAS_CELL_SPACING
;
9084 var canvas
= canvasFactory(255 * cellWidth
, (2 + 16 + 16) * cellHeight
);
9085 var ctx
= canvas
.getContext('2d', { alpha
: config
.allowTransparency
});
9086 ctx
.fillStyle
= config
.colors
.background
.css
;
9087 ctx
.fillRect(0, 0, canvas
.width
, canvas
.height
);
9089 ctx
.fillStyle
= config
.colors
.foreground
.css
;
9090 ctx
.font
= getFont(config
.fontWeight
, config
);
9091 ctx
.textBaseline
= 'middle';
9092 for (var i
= 0; i
< 256; i
++) {
9095 ctx
.rect(i
* cellWidth
, 0, cellWidth
, cellHeight
);
9097 ctx
.fillText(String
.fromCharCode(i
), i
* cellWidth
, cellHeight
/ 2);
9101 ctx
.font
= getFont(config
.fontWeightBold
, config
);
9102 for (var i
= 0; i
< 256; i
++) {
9105 ctx
.rect(i
* cellWidth
, cellHeight
, cellWidth
, cellHeight
);
9107 ctx
.fillText(String
.fromCharCode(i
), i
* cellWidth
, cellHeight
* 1.5);
9111 ctx
.font
= getFont(config
.fontWeight
, config
);
9112 for (var colorIndex
= 0; colorIndex
< 16; colorIndex
++) {
9113 var y
= (colorIndex
+ 2) * cellHeight
;
9114 for (var i
= 0; i
< 256; i
++) {
9117 ctx
.rect(i
* cellWidth
, y
, cellWidth
, cellHeight
);
9119 ctx
.fillStyle
= config
.colors
.ansi
[colorIndex
].css
;
9120 ctx
.fillText(String
.fromCharCode(i
), i
* cellWidth
, y
+ cellHeight
/ 2);
9124 ctx
.font
= getFont(config
.fontWeightBold
, config
);
9125 for (var colorIndex
= 0; colorIndex
< 16; colorIndex
++) {
9126 var y
= (colorIndex
+ 2 + 16) * cellHeight
;
9127 for (var i
= 0; i
< 256; i
++) {
9130 ctx
.rect(i
* cellWidth
, y
, cellWidth
, cellHeight
);
9132 ctx
.fillStyle
= config
.colors
.ansi
[colorIndex
].css
;
9133 ctx
.fillText(String
.fromCharCode(i
), i
* cellWidth
, y
+ cellHeight
/ 2);
9138 if (!('createImageBitmap' in context
) || Platform_1
.isFirefox
|| Platform_1
.isSafari
) {
9141 var charAtlasImageData
= ctx
.getImageData(0, 0, canvas
.width
, canvas
.height
);
9142 clearColor(charAtlasImageData
, config
.colors
.background
);
9143 return context
.createImageBitmap(charAtlasImageData
);
9145 exports
.generateStaticCharAtlasTexture
= generateStaticCharAtlasTexture
;
9146 function clearColor(imageData
, color
) {
9148 var r
= color
.rgba
>>> 24;
9149 var g
= color
.rgba
>>> 16 & 0xFF;
9150 var b
= color
.rgba
>>> 8 & 0xFF;
9151 for (var offset
= 0; offset
< imageData
.data
.length
; offset
+= 4) {
9152 if (imageData
.data
[offset
] === r
&&
9153 imageData
.data
[offset
+ 1] === g
&&
9154 imageData
.data
[offset
+ 2] === b
) {
9155 imageData
.data
[offset
+ 3] = 0;
9163 exports
.clearColor
= clearColor
;
9164 function getFont(fontWeight
, config
) {
9165 return fontWeight
+ " " + config
.fontSize
* config
.devicePixelRatio
+ "px " + config
.fontFamily
;
9168 },{"../../common/Platform":27,"./Types":52}],47:[function(require
,module
,exports
){
9170 Object
.defineProperty(exports
, "__esModule", { value
: true });
9171 var Types_1
= require("./Types");
9172 function generateConfig(scaledCharWidth
, scaledCharHeight
, terminal
, colors
) {
9173 var clonedColors
= {
9174 foreground
: colors
.foreground
,
9175 background
: colors
.background
,
9179 ansi
: colors
.ansi
.slice(0, 16)
9182 type
: terminal
.options
.experimentalCharAtlas
,
9183 devicePixelRatio
: window
.devicePixelRatio
,
9184 scaledCharWidth
: scaledCharWidth
,
9185 scaledCharHeight
: scaledCharHeight
,
9186 fontFamily
: terminal
.options
.fontFamily
,
9187 fontSize
: terminal
.options
.fontSize
,
9188 fontWeight
: terminal
.options
.fontWeight
,
9189 fontWeightBold
: terminal
.options
.fontWeightBold
,
9190 allowTransparency
: terminal
.options
.allowTransparency
,
9191 colors
: clonedColors
9194 exports
.generateConfig
= generateConfig
;
9195 function configEquals(a
, b
) {
9196 for (var i
= 0; i
< a
.colors
.ansi
.length
; i
++) {
9197 if (a
.colors
.ansi
[i
].rgba
!== b
.colors
.ansi
[i
].rgba
) {
9201 return a
.type
=== b
.type
&&
9202 a
.devicePixelRatio
=== b
.devicePixelRatio
&&
9203 a
.fontFamily
=== b
.fontFamily
&&
9204 a
.fontSize
=== b
.fontSize
&&
9205 a
.fontWeight
=== b
.fontWeight
&&
9206 a
.fontWeightBold
=== b
.fontWeightBold
&&
9207 a
.allowTransparency
=== b
.allowTransparency
&&
9208 a
.scaledCharWidth
=== b
.scaledCharWidth
&&
9209 a
.scaledCharHeight
=== b
.scaledCharHeight
&&
9210 a
.colors
.foreground
=== b
.colors
.foreground
&&
9211 a
.colors
.background
=== b
.colors
.background
;
9213 exports
.configEquals
= configEquals
;
9214 function is256Color(colorCode
) {
9215 return colorCode
< Types_1
.DEFAULT_COLOR
;
9217 exports
.is256Color
= is256Color
;
9219 },{"./Types":52}],48:[function(require
,module
,exports
){
9221 var __extends
= (this && this.__extends
) || (function () {
9222 var extendStatics = function (d
, b
) {
9223 extendStatics
= Object
.setPrototypeOf
||
9224 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
9225 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
9226 return extendStatics(d
, b
);
9228 return function (d
, b
) {
9229 extendStatics(d
, b
);
9230 function __() { this.constructor = d
; }
9231 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
9234 Object
.defineProperty(exports
, "__esModule", { value
: true });
9235 var Types_1
= require("./Types");
9236 var BaseCharAtlas_1
= require("./BaseCharAtlas");
9237 var ColorManager_1
= require("../ColorManager");
9238 var CharAtlasGenerator_1
= require("./CharAtlasGenerator");
9239 var LRUMap_1
= require("./LRUMap");
9240 var Platform_1
= require("../../common/Platform");
9241 var TEXTURE_WIDTH
= 1024;
9242 var TEXTURE_HEIGHT
= 1024;
9243 var TRANSPARENT_COLOR
= {
9244 css
: 'rgba(0, 0, 0, 0)',
9247 var FRAME_CACHE_DRAW_LIMIT
= 100;
9248 var GLYPH_BITMAP_COMMIT_DELAY
= 100;
9249 function getGlyphCacheKey(glyph
) {
9250 return glyph
.code
<< 21 | glyph
.bg
<< 12 | glyph
.fg
<< 3 | (glyph
.bold
? 0 : 4) + (glyph
.dim
? 0 : 2) + (glyph
.italic
? 0 : 1);
9252 exports
.getGlyphCacheKey
= getGlyphCacheKey
;
9253 var DynamicCharAtlas
= (function (_super
) {
9254 __extends(DynamicCharAtlas
, _super
);
9255 function DynamicCharAtlas(document
, _config
) {
9256 var _this
= _super
.call(this) || this;
9257 _this
._config
= _config
;
9258 _this
._drawToCacheCount
= 0;
9259 _this
._glyphsWaitingOnBitmap
= [];
9260 _this
._bitmapCommitTimeout
= null;
9261 _this
._bitmap
= null;
9262 _this
._cacheCanvas
= document
.createElement('canvas');
9263 _this
._cacheCanvas
.width
= TEXTURE_WIDTH
;
9264 _this
._cacheCanvas
.height
= TEXTURE_HEIGHT
;
9265 _this
._cacheCtx
= _this
._cacheCanvas
.getContext('2d', { alpha
: true });
9266 var tmpCanvas
= document
.createElement('canvas');
9267 tmpCanvas
.width
= _this
._config
.scaledCharWidth
;
9268 tmpCanvas
.height
= _this
._config
.scaledCharHeight
;
9269 _this
._tmpCtx
= tmpCanvas
.getContext('2d', { alpha
: _this
._config
.allowTransparency
});
9270 _this
._width
= Math
.floor(TEXTURE_WIDTH
/ _this
._config
.scaledCharWidth
);
9271 _this
._height
= Math
.floor(TEXTURE_HEIGHT
/ _this
._config
.scaledCharHeight
);
9272 var capacity
= _this
._width
* _this
._height
;
9273 _this
._cacheMap
= new LRUMap_1
.default(capacity
);
9274 _this
._cacheMap
.prealloc(capacity
);
9277 DynamicCharAtlas
.prototype.dispose = function () {
9278 if (this._bitmapCommitTimeout
!== null) {
9279 window
.clearTimeout(this._bitmapCommitTimeout
);
9280 this._bitmapCommitTimeout
= null;
9283 DynamicCharAtlas
.prototype.beginFrame = function () {
9284 this._drawToCacheCount
= 0;
9286 DynamicCharAtlas
.prototype.draw = function (ctx
, glyph
, x
, y
) {
9287 if (glyph
.code
=== 32) {
9290 if (!this._canCache(glyph
)) {
9293 var glyphKey
= getGlyphCacheKey(glyph
);
9294 var cacheValue
= this._cacheMap
.get(glyphKey
);
9295 if (cacheValue
!== null && cacheValue
!== undefined) {
9296 this._drawFromCache(ctx
, cacheValue
, x
, y
);
9299 else if (this._drawToCacheCount
< FRAME_CACHE_DRAW_LIMIT
) {
9301 if (this._cacheMap
.size
< this._cacheMap
.capacity
) {
9302 index
= this._cacheMap
.size
;
9305 index
= this._cacheMap
.peek().index
;
9307 var cacheValue_1
= this._drawToCache(glyph
, index
);
9308 this._cacheMap
.set(glyphKey
, cacheValue_1
);
9309 this._drawFromCache(ctx
, cacheValue_1
, x
, y
);
9314 DynamicCharAtlas
.prototype._canCache = function (glyph
) {
9315 return glyph
.code
< 256;
9317 DynamicCharAtlas
.prototype._toCoordinateX = function (index
) {
9318 return (index
% this._width
) * this._config
.scaledCharWidth
;
9320 DynamicCharAtlas
.prototype._toCoordinateY = function (index
) {
9321 return Math
.floor(index
/ this._width
) * this._config
.scaledCharHeight
;
9323 DynamicCharAtlas
.prototype._drawFromCache = function (ctx
, cacheValue
, x
, y
) {
9324 if (cacheValue
.isEmpty
) {
9327 var cacheX
= this._toCoordinateX(cacheValue
.index
);
9328 var cacheY
= this._toCoordinateY(cacheValue
.index
);
9329 ctx
.drawImage(cacheValue
.inBitmap
? this._bitmap
: this._cacheCanvas
, cacheX
, cacheY
, this._config
.scaledCharWidth
, this._config
.scaledCharHeight
, x
, y
, this._config
.scaledCharWidth
, this._config
.scaledCharHeight
);
9331 DynamicCharAtlas
.prototype._getColorFromAnsiIndex = function (idx
) {
9332 if (idx
< this._config
.colors
.ansi
.length
) {
9333 return this._config
.colors
.ansi
[idx
];
9335 return ColorManager_1
.DEFAULT_ANSI_COLORS
[idx
];
9337 DynamicCharAtlas
.prototype._getBackgroundColor = function (glyph
) {
9338 if (this._config
.allowTransparency
) {
9339 return TRANSPARENT_COLOR
;
9341 else if (glyph
.bg
=== Types_1
.INVERTED_DEFAULT_COLOR
) {
9342 return this._config
.colors
.foreground
;
9344 else if (glyph
.bg
< 256) {
9345 return this._getColorFromAnsiIndex(glyph
.bg
);
9347 return this._config
.colors
.background
;
9349 DynamicCharAtlas
.prototype._getForegroundColor = function (glyph
) {
9350 if (glyph
.fg
=== Types_1
.INVERTED_DEFAULT_COLOR
) {
9351 return this._config
.colors
.background
;
9353 else if (glyph
.fg
< 256) {
9354 return this._getColorFromAnsiIndex(glyph
.fg
);
9356 return this._config
.colors
.foreground
;
9358 DynamicCharAtlas
.prototype._drawToCache = function (glyph
, index
) {
9359 this._drawToCacheCount
++;
9360 this._tmpCtx
.save();
9361 var backgroundColor
= this._getBackgroundColor(glyph
);
9362 this._tmpCtx
.globalCompositeOperation
= 'copy';
9363 this._tmpCtx
.fillStyle
= backgroundColor
.css
;
9364 this._tmpCtx
.fillRect(0, 0, this._config
.scaledCharWidth
, this._config
.scaledCharHeight
);
9365 this._tmpCtx
.globalCompositeOperation
= 'source-over';
9366 var fontWeight
= glyph
.bold
? this._config
.fontWeightBold
: this._config
.fontWeight
;
9367 var fontStyle
= glyph
.italic
? 'italic' : '';
9369 fontStyle
+ " " + fontWeight
+ " " + this._config
.fontSize
* this._config
.devicePixelRatio
+ "px " + this._config
.fontFamily
;
9370 this._tmpCtx
.textBaseline
= 'middle';
9371 this._tmpCtx
.fillStyle
= this._getForegroundColor(glyph
).css
;
9373 this._tmpCtx
.globalAlpha
= Types_1
.DIM_OPACITY
;
9375 this._tmpCtx
.fillText(glyph
.chars
, 0, this._config
.scaledCharHeight
/ 2);
9376 this._tmpCtx
.restore();
9377 var imageData
= this._tmpCtx
.getImageData(0, 0, this._config
.scaledCharWidth
, this._config
.scaledCharHeight
);
9378 var isEmpty
= false;
9379 if (!this._config
.allowTransparency
) {
9380 isEmpty
= CharAtlasGenerator_1
.clearColor(imageData
, backgroundColor
);
9382 var x
= this._toCoordinateX(index
);
9383 var y
= this._toCoordinateY(index
);
9384 this._cacheCtx
.putImageData(imageData
, x
, y
);
9390 this._addGlyphToBitmap(cacheValue
);
9393 DynamicCharAtlas
.prototype._addGlyphToBitmap = function (cacheValue
) {
9395 if (!('createImageBitmap' in window
) || Platform_1
.isFirefox
|| Platform_1
.isSafari
) {
9398 this._glyphsWaitingOnBitmap
.push(cacheValue
);
9399 if (this._bitmapCommitTimeout
!== null) {
9402 this._bitmapCommitTimeout
= window
.setTimeout(function () { return _this
._generateBitmap(); }, GLYPH_BITMAP_COMMIT_DELAY
);
9404 DynamicCharAtlas
.prototype._generateBitmap = function () {
9406 var glyphsMovingToBitmap
= this._glyphsWaitingOnBitmap
;
9407 this._glyphsWaitingOnBitmap
= [];
9408 window
.createImageBitmap(this._cacheCanvas
).then(function (bitmap
) {
9409 _this
._bitmap
= bitmap
;
9410 for (var i
= 0; i
< glyphsMovingToBitmap
.length
; i
++) {
9411 var value
= glyphsMovingToBitmap
[i
];
9412 value
.inBitmap
= true;
9415 this._bitmapCommitTimeout
= null;
9417 return DynamicCharAtlas
;
9418 }(BaseCharAtlas_1
.default));
9419 exports
.default = DynamicCharAtlas
;
9421 },{"../../common/Platform":27,"../ColorManager":37,"./BaseCharAtlas":44,"./CharAtlasGenerator":46,"./LRUMap":49,"./Types":52}],49:[function(require
,module
,exports
){
9423 Object
.defineProperty(exports
, "__esModule", { value
: true });
9424 var LRUMap
= (function () {
9425 function LRUMap(capacity
) {
9426 this.capacity
= capacity
;
9430 this._nodePool
= [];
9433 LRUMap
.prototype._unlinkNode = function (node
) {
9434 var prev
= node
.prev
;
9435 var next
= node
.next
;
9436 if (node
=== this._head
) {
9439 if (node
=== this._tail
) {
9442 if (prev
!== null) {
9445 if (next
!== null) {
9449 LRUMap
.prototype._appendNode = function (node
) {
9450 var tail
= this._tail
;
9451 if (tail
!== null) {
9457 if (this._head
=== null) {
9461 LRUMap
.prototype.prealloc = function (count
) {
9462 var nodePool
= this._nodePool
;
9463 for (var i
= 0; i
< count
; i
++) {
9472 LRUMap
.prototype.get = function (key
) {
9473 var node
= this._map
[key
];
9474 if (node
!== undefined) {
9475 this._unlinkNode(node
);
9476 this._appendNode(node
);
9481 LRUMap
.prototype.peekValue = function (key
) {
9482 var node
= this._map
[key
];
9483 if (node
!== undefined) {
9488 LRUMap
.prototype.peek = function () {
9489 var head
= this._head
;
9490 return head
=== null ? null : head
.value
;
9492 LRUMap
.prototype.set = function (key
, value
) {
9493 var node
= this._map
[key
];
9494 if (node
!== undefined) {
9495 node
= this._map
[key
];
9496 this._unlinkNode(node
);
9499 else if (this.size
>= this.capacity
) {
9501 this._unlinkNode(node
);
9502 delete this._map
[node
.key
];
9505 this._map
[key
] = node
;
9508 var nodePool
= this._nodePool
;
9509 if (nodePool
.length
> 0) {
9510 node
= nodePool
.pop();
9522 this._map
[key
] = node
;
9525 this._appendNode(node
);
9529 exports
.default = LRUMap
;
9531 },{}],50:[function(require
,module
,exports
){
9533 var __extends
= (this && this.__extends
) || (function () {
9534 var extendStatics = function (d
, b
) {
9535 extendStatics
= Object
.setPrototypeOf
||
9536 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
9537 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
9538 return extendStatics(d
, b
);
9540 return function (d
, b
) {
9541 extendStatics(d
, b
);
9542 function __() { this.constructor = d
; }
9543 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
9546 Object
.defineProperty(exports
, "__esModule", { value
: true });
9547 var BaseCharAtlas_1
= require("./BaseCharAtlas");
9548 var NoneCharAtlas
= (function (_super
) {
9549 __extends(NoneCharAtlas
, _super
);
9550 function NoneCharAtlas(document
, config
) {
9551 return _super
.call(this) || this;
9553 NoneCharAtlas
.prototype.draw = function (ctx
, glyph
, x
, y
) {
9556 return NoneCharAtlas
;
9557 }(BaseCharAtlas_1
.default));
9558 exports
.default = NoneCharAtlas
;
9560 },{"./BaseCharAtlas":44}],51:[function(require
,module
,exports
){
9562 var __extends
= (this && this.__extends
) || (function () {
9563 var extendStatics = function (d
, b
) {
9564 extendStatics
= Object
.setPrototypeOf
||
9565 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
9566 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
9567 return extendStatics(d
, b
);
9569 return function (d
, b
) {
9570 extendStatics(d
, b
);
9571 function __() { this.constructor = d
; }
9572 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
9575 Object
.defineProperty(exports
, "__esModule", { value
: true });
9576 var Types_1
= require("./Types");
9577 var CharAtlasGenerator_1
= require("./CharAtlasGenerator");
9578 var BaseCharAtlas_1
= require("./BaseCharAtlas");
9579 var CharAtlasUtils_1
= require("./CharAtlasUtils");
9580 var StaticCharAtlas
= (function (_super
) {
9581 __extends(StaticCharAtlas
, _super
);
9582 function StaticCharAtlas(_document
, _config
) {
9583 var _this
= _super
.call(this) || this;
9584 _this
._document
= _document
;
9585 _this
._config
= _config
;
9586 _this
._canvasFactory = function (width
, height
) {
9587 var canvas
= _this
._document
.createElement('canvas');
9588 canvas
.width
= width
;
9589 canvas
.height
= height
;
9594 StaticCharAtlas
.prototype._doWarmUp = function () {
9596 var result
= CharAtlasGenerator_1
.generateStaticCharAtlasTexture(window
, this._canvasFactory
, this._config
);
9597 if (result
instanceof HTMLCanvasElement
) {
9598 this._texture
= result
;
9601 result
.then(function (texture
) {
9602 _this
._texture
= texture
;
9606 StaticCharAtlas
.prototype._isCached = function (glyph
, colorIndex
) {
9607 var isAscii
= glyph
.code
< 256;
9608 var isBasicColor
= glyph
.fg
< 16;
9609 var isDefaultColor
= glyph
.fg
=== Types_1
.DEFAULT_COLOR
;
9610 var isDefaultBackground
= glyph
.bg
=== Types_1
.DEFAULT_COLOR
;
9611 return isAscii
&& (isBasicColor
|| isDefaultColor
) && isDefaultBackground
&& !glyph
.italic
;
9613 StaticCharAtlas
.prototype.draw = function (ctx
, glyph
, x
, y
) {
9614 if (this._texture
=== null || this._texture
=== undefined) {
9618 if (CharAtlasUtils_1
.is256Color(glyph
.fg
)) {
9619 colorIndex
= 2 + glyph
.fg
+ (glyph
.bold
? 16 : 0);
9621 else if (glyph
.fg
=== Types_1
.DEFAULT_COLOR
) {
9626 if (!this._isCached(glyph
, colorIndex
)) {
9630 var charAtlasCellWidth
= this._config
.scaledCharWidth
+ Types_1
.CHAR_ATLAS_CELL_SPACING
;
9631 var charAtlasCellHeight
= this._config
.scaledCharHeight
+ Types_1
.CHAR_ATLAS_CELL_SPACING
;
9633 ctx
.globalAlpha
= Types_1
.DIM_OPACITY
;
9635 ctx
.drawImage(this._texture
, glyph
.code
* charAtlasCellWidth
, colorIndex
* charAtlasCellHeight
, charAtlasCellWidth
, this._config
.scaledCharHeight
, x
, y
, charAtlasCellWidth
, this._config
.scaledCharHeight
);
9639 return StaticCharAtlas
;
9640 }(BaseCharAtlas_1
.default));
9641 exports
.default = StaticCharAtlas
;
9643 },{"./BaseCharAtlas":44,"./CharAtlasGenerator":46,"./CharAtlasUtils":47,"./Types":52}],52:[function(require
,module
,exports
){
9645 Object
.defineProperty(exports
, "__esModule", { value
: true });
9646 exports
.DEFAULT_COLOR
= 256;
9647 exports
.INVERTED_DEFAULT_COLOR
= 257;
9648 exports
.DIM_OPACITY
= 0.5;
9649 exports
.CHAR_ATLAS_CELL_SPACING
= 1;
9651 },{}],53:[function(require
,module
,exports
){
9653 var __extends
= (this && this.__extends
) || (function () {
9654 var extendStatics = function (d
, b
) {
9655 extendStatics
= Object
.setPrototypeOf
||
9656 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
9657 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
9658 return extendStatics(d
, b
);
9660 return function (d
, b
) {
9661 extendStatics(d
, b
);
9662 function __() { this.constructor = d
; }
9663 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
9666 Object
.defineProperty(exports
, "__esModule", { value
: true });
9667 var ColorManager_1
= require("../ColorManager");
9668 var RenderDebouncer_1
= require("../../ui/RenderDebouncer");
9669 var DomRendererRowFactory_1
= require("./DomRendererRowFactory");
9670 var Types_1
= require("../atlas/Types");
9671 var EventEmitter2_1
= require("../../common/EventEmitter2");
9672 var Lifecycle_1
= require("../../common/Lifecycle");
9673 var TERMINAL_CLASS_PREFIX
= 'xterm-dom-renderer-owner-';
9674 var ROW_CONTAINER_CLASS
= 'xterm-rows';
9675 var FG_CLASS_PREFIX
= 'xterm-fg-';
9676 var BG_CLASS_PREFIX
= 'xterm-bg-';
9677 var FOCUS_CLASS
= 'xterm-focus';
9678 var SELECTION_CLASS
= 'xterm-selection';
9679 var nextTerminalId
= 1;
9680 var DomRenderer
= (function (_super
) {
9681 __extends(DomRenderer
, _super
);
9682 function DomRenderer(_terminal
, theme
) {
9683 var _this
= _super
.call(this) || this;
9684 _this
._terminal
= _terminal
;
9685 _this
._terminalClass
= nextTerminalId
++;
9686 _this
._rowElements
= [];
9687 _this
._onCanvasResize
= new EventEmitter2_1
.EventEmitter2();
9688 _this
._onRender
= new EventEmitter2_1
.EventEmitter2();
9689 var allowTransparency
= _this
._terminal
.options
.allowTransparency
;
9690 _this
.colorManager
= new ColorManager_1
.ColorManager(document
, allowTransparency
);
9691 _this
.setTheme(theme
);
9692 _this
._rowContainer
= document
.createElement('div');
9693 _this
._rowContainer
.classList
.add(ROW_CONTAINER_CLASS
);
9694 _this
._rowContainer
.style
.lineHeight
= 'normal';
9695 _this
._rowContainer
.setAttribute('aria-hidden', 'true');
9696 _this
._refreshRowElements(_this
._terminal
.cols
, _this
._terminal
.rows
);
9697 _this
._selectionContainer
= document
.createElement('div');
9698 _this
._selectionContainer
.classList
.add(SELECTION_CLASS
);
9699 _this
._selectionContainer
.setAttribute('aria-hidden', 'true');
9700 _this
.dimensions
= {
9701 scaledCharWidth
: null,
9702 scaledCharHeight
: null,
9703 scaledCellWidth
: null,
9704 scaledCellHeight
: null,
9705 scaledCharLeft
: null,
9706 scaledCharTop
: null,
9707 scaledCanvasWidth
: null,
9708 scaledCanvasHeight
: null,
9711 actualCellWidth
: null,
9712 actualCellHeight
: null
9714 _this
._updateDimensions();
9715 _this
._renderDebouncer
= new RenderDebouncer_1
.RenderDebouncer(_this
._renderRows
.bind(_this
));
9716 _this
._rowFactory
= new DomRendererRowFactory_1
.DomRendererRowFactory(_terminal
.options
, document
);
9717 _this
._terminal
.element
.classList
.add(TERMINAL_CLASS_PREFIX
+ _this
._terminalClass
);
9718 _this
._terminal
.screenElement
.appendChild(_this
._rowContainer
);
9719 _this
._terminal
.screenElement
.appendChild(_this
._selectionContainer
);
9720 _this
._terminal
.linkifier
.onLinkHover(function (e
) { return _this
._onLinkHover(e
); });
9721 _this
._terminal
.linkifier
.onLinkLeave(function (e
) { return _this
._onLinkLeave(e
); });
9724 Object
.defineProperty(DomRenderer
.prototype, "onCanvasResize", {
9725 get: function () { return this._onCanvasResize
.event
; },
9729 Object
.defineProperty(DomRenderer
.prototype, "onRender", {
9730 get: function () { return this._onRender
.event
; },
9734 DomRenderer
.prototype.dispose = function () {
9735 this._terminal
.element
.classList
.remove(TERMINAL_CLASS_PREFIX
+ this._terminalClass
);
9736 this._terminal
.screenElement
.removeChild(this._rowContainer
);
9737 this._terminal
.screenElement
.removeChild(this._selectionContainer
);
9738 this._terminal
.screenElement
.removeChild(this._themeStyleElement
);
9739 this._terminal
.screenElement
.removeChild(this._dimensionsStyleElement
);
9740 _super
.prototype.dispose
.call(this);
9742 DomRenderer
.prototype._updateDimensions = function () {
9744 this.dimensions
.scaledCharWidth
= Math
.floor(this._terminal
.charMeasure
.width
* window
.devicePixelRatio
);
9745 this.dimensions
.scaledCharHeight
= Math
.ceil(this._terminal
.charMeasure
.height
* window
.devicePixelRatio
);
9746 this.dimensions
.scaledCellWidth
= this.dimensions
.scaledCharWidth
+ Math
.round(this._terminal
.options
.letterSpacing
);
9747 this.dimensions
.scaledCellHeight
= Math
.floor(this.dimensions
.scaledCharHeight
* this._terminal
.options
.lineHeight
);
9748 this.dimensions
.scaledCharLeft
= 0;
9749 this.dimensions
.scaledCharTop
= 0;
9750 this.dimensions
.scaledCanvasWidth
= this.dimensions
.scaledCellWidth
* this._terminal
.cols
;
9751 this.dimensions
.scaledCanvasHeight
= this.dimensions
.scaledCellHeight
* this._terminal
.rows
;
9752 this.dimensions
.canvasWidth
= Math
.round(this.dimensions
.scaledCanvasWidth
/ window
.devicePixelRatio
);
9753 this.dimensions
.canvasHeight
= Math
.round(this.dimensions
.scaledCanvasHeight
/ window
.devicePixelRatio
);
9754 this.dimensions
.actualCellWidth
= this.dimensions
.canvasWidth
/ this._terminal
.cols
;
9755 this.dimensions
.actualCellHeight
= this.dimensions
.canvasHeight
/ this._terminal
.rows
;
9756 this._rowElements
.forEach(function (element
) {
9757 element
.style
.width
= _this
.dimensions
.canvasWidth
+ "px";
9758 element
.style
.height
= _this
.dimensions
.actualCellHeight
+ "px";
9759 element
.style
.lineHeight
= _this
.dimensions
.actualCellHeight
+ "px";
9760 element
.style
.overflow
= 'hidden';
9762 if (!this._dimensionsStyleElement
) {
9763 this._dimensionsStyleElement
= document
.createElement('style');
9764 this._terminal
.screenElement
.appendChild(this._dimensionsStyleElement
);
9766 var styles
= this._terminalSelector
+ " ." + ROW_CONTAINER_CLASS
+ " span {" +
9767 " display: inline-block;" +
9769 " vertical-align: top;" +
9770 (" width: " + this.dimensions
.actualCellWidth
+ "px") +
9772 this._dimensionsStyleElement
.innerHTML
= styles
;
9773 this._selectionContainer
.style
.height
= this._terminal
._viewportElement
.style
.height
;
9774 this._terminal
.screenElement
.style
.width
= this.dimensions
.canvasWidth
+ "px";
9775 this._terminal
.screenElement
.style
.height
= this.dimensions
.canvasHeight
+ "px";
9777 DomRenderer
.prototype.setTheme = function (theme
) {
9780 this.colorManager
.setTheme(theme
);
9782 if (!this._themeStyleElement
) {
9783 this._themeStyleElement
= document
.createElement('style');
9784 this._terminal
.screenElement
.appendChild(this._themeStyleElement
);
9786 var styles
= this._terminalSelector
+ " ." + ROW_CONTAINER_CLASS
+ " {" +
9787 (" color: " + this.colorManager
.colors
.foreground
.css
+ ";") +
9788 (" background-color: " + this.colorManager
.colors
.background
.css
+ ";") +
9789 (" font-family: " + this._terminal
.getOption('fontFamily') + ";") +
9790 (" font-size: " + this._terminal
.getOption('fontSize') + "px;") +
9793 this._terminalSelector
+ " span:not(." + DomRendererRowFactory_1
.BOLD_CLASS
+ ") {" +
9794 (" font-weight: " + this._terminal
.options
.fontWeight
+ ";") +
9796 (this._terminalSelector
+ " span." + DomRendererRowFactory_1
.BOLD_CLASS
+ " {") +
9797 (" font-weight: " + this._terminal
.options
.fontWeightBold
+ ";") +
9799 (this._terminalSelector
+ " span." + DomRendererRowFactory_1
.ITALIC_CLASS
+ " {") +
9800 " font-style: italic;" +
9803 "@keyframes blink {" +
9804 " 0% { opacity: 1.0; }" +
9805 " 50% { opacity: 0.0; }" +
9806 " 100% { opacity: 1.0; }" +
9809 this._terminalSelector
+ " ." + ROW_CONTAINER_CLASS
+ ":not(." + FOCUS_CLASS
+ ") ." + DomRendererRowFactory_1
.CURSOR_CLASS
+ " {" +
9810 (" outline: 1px solid " + this.colorManager
.colors
.cursor
.css
+ ";") +
9811 " outline-offset: -1px;" +
9813 (this._terminalSelector
+ " ." + ROW_CONTAINER_CLASS
+ "." + FOCUS_CLASS
+ " ." + DomRendererRowFactory_1
.CURSOR_CLASS
+ "." + DomRendererRowFactory_1
.CURSOR_BLINK_CLASS
+ " {") +
9814 " animation: blink 1s step-end infinite;" +
9816 (this._terminalSelector
+ " ." + ROW_CONTAINER_CLASS
+ "." + FOCUS_CLASS
+ " ." + DomRendererRowFactory_1
.CURSOR_CLASS
+ "." + DomRendererRowFactory_1
.CURSOR_STYLE_BLOCK_CLASS
+ " {") +
9817 (" background-color: " + this.colorManager
.colors
.cursor
.css
+ ";") +
9818 (" color: " + this.colorManager
.colors
.cursorAccent
.css
+ ";") +
9820 (this._terminalSelector
+ " ." + ROW_CONTAINER_CLASS
+ "." + FOCUS_CLASS
+ " ." + DomRendererRowFactory_1
.CURSOR_CLASS
+ "." + DomRendererRowFactory_1
.CURSOR_STYLE_BAR_CLASS
+ " {") +
9821 (" box-shadow: 1px 0 0 " + this.colorManager
.colors
.cursor
.css
+ " inset;") +
9823 (this._terminalSelector
+ " ." + ROW_CONTAINER_CLASS
+ "." + FOCUS_CLASS
+ " ." + DomRendererRowFactory_1
.CURSOR_CLASS
+ "." + DomRendererRowFactory_1
.CURSOR_STYLE_UNDERLINE_CLASS
+ " {") +
9824 (" box-shadow: 0 -1px 0 " + this.colorManager
.colors
.cursor
.css
+ " inset;") +
9827 this._terminalSelector
+ " ." + SELECTION_CLASS
+ " {" +
9828 " position: absolute;" +
9832 " pointer-events: none;" +
9834 (this._terminalSelector
+ " ." + SELECTION_CLASS
+ " div {") +
9835 " position: absolute;" +
9836 (" background-color: " + this.colorManager
.colors
.selection
.css
+ ";") +
9838 this.colorManager
.colors
.ansi
.forEach(function (c
, i
) {
9840 _this
._terminalSelector
+ " ." + FG_CLASS_PREFIX
+ i
+ " { color: " + c
.css
+ "; }" +
9841 (_this
._terminalSelector
+ " ." + BG_CLASS_PREFIX
+ i
+ " { background-color: " + c
.css
+ "; }");
9844 this._terminalSelector
+ " ." + FG_CLASS_PREFIX
+ Types_1
.INVERTED_DEFAULT_COLOR
+ " { color: " + this.colorManager
.colors
.background
.css
+ "; }" +
9845 (this._terminalSelector
+ " ." + BG_CLASS_PREFIX
+ Types_1
.INVERTED_DEFAULT_COLOR
+ " { background-color: " + this.colorManager
.colors
.foreground
.css
+ "; }");
9846 this._themeStyleElement
.innerHTML
= styles
;
9847 return this.colorManager
.colors
;
9849 DomRenderer
.prototype.onWindowResize = function (devicePixelRatio
) {
9850 this._updateDimensions();
9852 DomRenderer
.prototype._refreshRowElements = function (cols
, rows
) {
9853 for (var i
= this._rowElements
.length
; i
<= rows
; i
++) {
9854 var row
= document
.createElement('div');
9855 this._rowContainer
.appendChild(row
);
9856 this._rowElements
.push(row
);
9858 while (this._rowElements
.length
> rows
) {
9859 this._rowContainer
.removeChild(this._rowElements
.pop());
9862 DomRenderer
.prototype.onResize = function (cols
, rows
) {
9863 this._refreshRowElements(cols
, rows
);
9864 this._updateDimensions();
9865 this._onCanvasResize
.fire({
9866 width
: this.dimensions
.canvasWidth
,
9867 height
: this.dimensions
.canvasHeight
9870 DomRenderer
.prototype.onCharSizeChanged = function () {
9871 this._updateDimensions();
9873 DomRenderer
.prototype.onBlur = function () {
9874 this._rowContainer
.classList
.remove(FOCUS_CLASS
);
9876 DomRenderer
.prototype.onFocus = function () {
9877 this._rowContainer
.classList
.add(FOCUS_CLASS
);
9879 DomRenderer
.prototype.onSelectionChanged = function (start
, end
, columnSelectMode
) {
9880 while (this._selectionContainer
.children
.length
) {
9881 this._selectionContainer
.removeChild(this._selectionContainer
.children
[0]);
9883 if (!start
|| !end
) {
9886 var viewportStartRow
= start
[1] - this._terminal
.buffer
.ydisp
;
9887 var viewportEndRow
= end
[1] - this._terminal
.buffer
.ydisp
;
9888 var viewportCappedStartRow
= Math
.max(viewportStartRow
, 0);
9889 var viewportCappedEndRow
= Math
.min(viewportEndRow
, this._terminal
.rows
- 1);
9890 if (viewportCappedStartRow
>= this._terminal
.rows
|| viewportCappedEndRow
< 0) {
9893 var documentFragment
= document
.createDocumentFragment();
9894 if (columnSelectMode
) {
9895 documentFragment
.appendChild(this._createSelectionElement(viewportCappedStartRow
, start
[0], end
[0], viewportCappedEndRow
- viewportCappedStartRow
+ 1));
9898 var startCol
= viewportStartRow
=== viewportCappedStartRow
? start
[0] : 0;
9899 var endCol
= viewportCappedStartRow
=== viewportCappedEndRow
? end
[0] : this._terminal
.cols
;
9900 documentFragment
.appendChild(this._createSelectionElement(viewportCappedStartRow
, startCol
, endCol
));
9901 var middleRowsCount
= viewportCappedEndRow
- viewportCappedStartRow
- 1;
9902 documentFragment
.appendChild(this._createSelectionElement(viewportCappedStartRow
+ 1, 0, this._terminal
.cols
, middleRowsCount
));
9903 if (viewportCappedStartRow
!== viewportCappedEndRow
) {
9904 var endCol_1
= viewportEndRow
=== viewportCappedEndRow
? end
[0] : this._terminal
.cols
;
9905 documentFragment
.appendChild(this._createSelectionElement(viewportCappedEndRow
, 0, endCol_1
));
9908 this._selectionContainer
.appendChild(documentFragment
);
9910 DomRenderer
.prototype._createSelectionElement = function (row
, colStart
, colEnd
, rowCount
) {
9911 if (rowCount
=== void 0) { rowCount
= 1; }
9912 var element
= document
.createElement('div');
9913 element
.style
.height
= rowCount
* this.dimensions
.actualCellHeight
+ "px";
9914 element
.style
.top
= row
* this.dimensions
.actualCellHeight
+ "px";
9915 element
.style
.left
= colStart
* this.dimensions
.actualCellWidth
+ "px";
9916 element
.style
.width
= this.dimensions
.actualCellWidth
* (colEnd
- colStart
) + "px";
9919 DomRenderer
.prototype.onCursorMove = function () {
9921 DomRenderer
.prototype.onOptionsChanged = function () {
9922 this._updateDimensions();
9923 this.setTheme(undefined);
9924 this._terminal
.refresh(0, this._terminal
.rows
- 1);
9926 DomRenderer
.prototype.clear = function () {
9927 this._rowElements
.forEach(function (e
) { return e
.innerHTML
= ''; });
9929 DomRenderer
.prototype.refreshRows = function (start
, end
) {
9930 this._renderDebouncer
.refresh(start
, end
, this._terminal
.rows
);
9932 DomRenderer
.prototype._renderRows = function (start
, end
) {
9933 var terminal
= this._terminal
;
9934 var cursorAbsoluteY
= terminal
.buffer
.ybase
+ terminal
.buffer
.y
;
9935 var cursorX
= this._terminal
.buffer
.x
;
9936 var cursorBlink
= this._terminal
.options
.cursorBlink
;
9937 for (var y
= start
; y
<= end
; y
++) {
9938 var rowElement
= this._rowElements
[y
];
9939 rowElement
.innerHTML
= '';
9940 var row
= y
+ terminal
.buffer
.ydisp
;
9941 var lineData
= terminal
.buffer
.lines
.get(row
);
9942 var cursorStyle
= terminal
.options
.cursorStyle
;
9943 rowElement
.appendChild(this._rowFactory
.createRow(lineData
, row
=== cursorAbsoluteY
, cursorStyle
, cursorX
, cursorBlink
, this.dimensions
.actualCellWidth
, terminal
.cols
));
9945 this._onRender
.fire({ start
: start
, end
: end
});
9947 Object
.defineProperty(DomRenderer
.prototype, "_terminalSelector", {
9949 return "." + TERMINAL_CLASS_PREFIX
+ this._terminalClass
;
9954 DomRenderer
.prototype.registerCharacterJoiner = function (handler
) { return -1; };
9955 DomRenderer
.prototype.deregisterCharacterJoiner = function (joinerId
) { return false; };
9956 DomRenderer
.prototype._onLinkHover = function (e
) {
9957 this._setCellUnderline(e
.x1
, e
.x2
, e
.y1
, e
.y2
, e
.cols
, true);
9959 DomRenderer
.prototype._onLinkLeave = function (e
) {
9960 this._setCellUnderline(e
.x1
, e
.x2
, e
.y1
, e
.y2
, e
.cols
, false);
9962 DomRenderer
.prototype._setCellUnderline = function (x
, x2
, y
, y2
, cols
, enabled
) {
9963 while (x
!== x2
|| y
!== y2
) {
9964 var row
= this._rowElements
[y
];
9968 var span
= row
.children
[x
];
9970 span
.style
.textDecoration
= enabled
? 'underline' : 'none';
9979 }(Lifecycle_1
.Disposable
));
9980 exports
.DomRenderer
= DomRenderer
;
9982 },{"../../common/EventEmitter2":25,"../../common/Lifecycle":26,"../../ui/RenderDebouncer":56,"../ColorManager":37,"../atlas/Types":52,"./DomRendererRowFactory":54}],54:[function(require
,module
,exports
){
9984 Object
.defineProperty(exports
, "__esModule", { value
: true });
9985 var Buffer_1
= require("../../Buffer");
9986 var Types_1
= require("../atlas/Types");
9987 var BufferLine_1
= require("../../BufferLine");
9988 exports
.BOLD_CLASS
= 'xterm-bold';
9989 exports
.DIM_CLASS
= 'xterm-dim';
9990 exports
.ITALIC_CLASS
= 'xterm-italic';
9991 exports
.UNDERLINE_CLASS
= 'xterm-underline';
9992 exports
.CURSOR_CLASS
= 'xterm-cursor';
9993 exports
.CURSOR_BLINK_CLASS
= 'xterm-cursor-blink';
9994 exports
.CURSOR_STYLE_BLOCK_CLASS
= 'xterm-cursor-block';
9995 exports
.CURSOR_STYLE_BAR_CLASS
= 'xterm-cursor-bar';
9996 exports
.CURSOR_STYLE_UNDERLINE_CLASS
= 'xterm-cursor-underline';
9997 var DomRendererRowFactory
= (function () {
9998 function DomRendererRowFactory(_terminalOptions
, _document
) {
9999 this._terminalOptions
= _terminalOptions
;
10000 this._document
= _document
;
10001 this._workCell
= new BufferLine_1
.CellData();
10003 DomRendererRowFactory
.prototype.createRow = function (lineData
, isCursorRow
, cursorStyle
, cursorX
, cursorBlink
, cellWidth
, cols
) {
10004 var fragment
= this._document
.createDocumentFragment();
10005 var lineLength
= 0;
10006 for (var x
= Math
.min(lineData
.length
, cols
) - 1; x
>= 0; x
--) {
10007 if (lineData
.loadCell(x
, this._workCell
).getCode() !== Buffer_1
.NULL_CELL_CODE
|| (isCursorRow
&& x
=== cursorX
)) {
10008 lineLength
= x
+ 1;
10012 for (var x
= 0; x
< lineLength
; x
++) {
10013 lineData
.loadCell(x
, this._workCell
);
10014 var width
= this._workCell
.getWidth();
10018 var charElement
= this._document
.createElement('span');
10020 charElement
.style
.width
= cellWidth
* width
+ "px";
10022 if (isCursorRow
&& x
=== cursorX
) {
10023 charElement
.classList
.add(exports
.CURSOR_CLASS
);
10025 charElement
.classList
.add(exports
.CURSOR_BLINK_CLASS
);
10027 switch (cursorStyle
) {
10029 charElement
.classList
.add(exports
.CURSOR_STYLE_BAR_CLASS
);
10032 charElement
.classList
.add(exports
.CURSOR_STYLE_UNDERLINE_CLASS
);
10035 charElement
.classList
.add(exports
.CURSOR_STYLE_BLOCK_CLASS
);
10039 if (this._workCell
.isBold() && this._terminalOptions
.enableBold
) {
10040 charElement
.classList
.add(exports
.BOLD_CLASS
);
10042 if (this._workCell
.isItalic()) {
10043 charElement
.classList
.add(exports
.ITALIC_CLASS
);
10045 if (this._workCell
.isDim()) {
10046 charElement
.classList
.add(exports
.DIM_CLASS
);
10048 if (this._workCell
.isUnderline()) {
10049 charElement
.classList
.add(exports
.UNDERLINE_CLASS
);
10051 charElement
.textContent
= this._workCell
.getChars() || Buffer_1
.WHITESPACE_CELL_CHAR
;
10052 var swapColor
= this._workCell
.isInverse();
10053 if (this._workCell
.isFgRGB()) {
10054 var style
= charElement
.getAttribute('style') || '';
10055 style
+= (swapColor
? 'background-' : '') + "color:rgb(" + (BufferLine_1
.AttributeData
.toColorRGB(this._workCell
.getFgColor())).join(',') + ");";
10056 charElement
.setAttribute('style', style
);
10058 else if (this._workCell
.isFgPalette()) {
10059 var fg
= this._workCell
.getFgColor();
10060 if (this._workCell
.isBold() && fg
< 8 && !swapColor
&&
10061 this._terminalOptions
.enableBold
&& this._terminalOptions
.drawBoldTextInBrightColors
) {
10064 charElement
.classList
.add("xterm-" + (swapColor
? 'b' : 'f') + "g-" + fg
);
10066 else if (swapColor
) {
10067 charElement
.classList
.add("xterm-bg-" + Types_1
.INVERTED_DEFAULT_COLOR
);
10069 if (this._workCell
.isBgRGB()) {
10070 var style
= charElement
.getAttribute('style') || '';
10071 style
+= (swapColor
? '' : 'background-') + "color:rgb(" + (BufferLine_1
.AttributeData
.toColorRGB(this._workCell
.getBgColor())).join(',') + ");";
10072 charElement
.setAttribute('style', style
);
10074 else if (this._workCell
.isBgPalette()) {
10075 charElement
.classList
.add("xterm-" + (swapColor
? 'f' : 'b') + "g-" + this._workCell
.getBgColor());
10077 else if (swapColor
) {
10078 charElement
.classList
.add("xterm-fg-" + Types_1
.INVERTED_DEFAULT_COLOR
);
10080 fragment
.appendChild(charElement
);
10084 return DomRendererRowFactory
;
10086 exports
.DomRendererRowFactory
= DomRendererRowFactory
;
10088 },{"../../Buffer":2,"../../BufferLine":3,"../atlas/Types":52}],55:[function(require
,module
,exports
){
10090 Object
.defineProperty(exports
, "__esModule", { value
: true });
10091 function addDisposableDomListener(node
, type
, handler
, useCapture
) {
10092 node
.addEventListener(type
, handler
, useCapture
);
10094 dispose: function () {
10098 node
.removeEventListener(type
, handler
, useCapture
);
10102 exports
.addDisposableDomListener
= addDisposableDomListener
;
10104 },{}],56:[function(require
,module
,exports
){
10106 Object
.defineProperty(exports
, "__esModule", { value
: true });
10107 var RenderDebouncer
= (function () {
10108 function RenderDebouncer(_renderCallback
) {
10109 this._renderCallback
= _renderCallback
;
10111 RenderDebouncer
.prototype.dispose = function () {
10112 if (this._animationFrame
) {
10113 window
.cancelAnimationFrame(this._animationFrame
);
10114 this._animationFrame
= undefined;
10117 RenderDebouncer
.prototype.refresh = function (rowStart
, rowEnd
, rowCount
) {
10119 this._rowCount
= rowCount
;
10120 rowStart
= rowStart
!== undefined ? rowStart
: 0;
10121 rowEnd
= rowEnd
!== undefined ? rowEnd
: this._rowCount
- 1;
10122 this._rowStart
= this._rowStart
!== undefined ? Math
.min(this._rowStart
, rowStart
) : rowStart
;
10123 this._rowEnd
= this._rowEnd
!== undefined ? Math
.max(this._rowEnd
, rowEnd
) : rowEnd
;
10124 if (this._animationFrame
) {
10127 this._animationFrame
= window
.requestAnimationFrame(function () { return _this
._innerRefresh(); });
10129 RenderDebouncer
.prototype._innerRefresh = function () {
10130 if (this._rowStart
=== undefined || this._rowEnd
=== undefined || this._rowCount
=== undefined) {
10133 this._rowStart
= Math
.max(this._rowStart
, 0);
10134 this._rowEnd
= Math
.min(this._rowEnd
, this._rowCount
- 1);
10135 this._renderCallback(this._rowStart
, this._rowEnd
);
10136 this._rowStart
= undefined;
10137 this._rowEnd
= undefined;
10138 this._animationFrame
= undefined;
10140 return RenderDebouncer
;
10142 exports
.RenderDebouncer
= RenderDebouncer
;
10144 },{}],57:[function(require
,module
,exports
){
10146 var __extends
= (this && this.__extends
) || (function () {
10147 var extendStatics = function (d
, b
) {
10148 extendStatics
= Object
.setPrototypeOf
||
10149 ({ __proto__
: [] } instanceof Array
&& function (d
, b
) { d
.__proto__
= b
; }) ||
10150 function (d
, b
) { for (var p
in b
) if (b
.hasOwnProperty(p
)) d
[p
] = b
[p
]; };
10151 return extendStatics(d
, b
);
10153 return function (d
, b
) {
10154 extendStatics(d
, b
);
10155 function __() { this.constructor = d
; }
10156 d
.prototype = b
=== null ? Object
.create(b
) : (__
.prototype = b
.prototype, new __());
10159 Object
.defineProperty(exports
, "__esModule", { value
: true });
10160 var Lifecycle_1
= require("../common/Lifecycle");
10161 var ScreenDprMonitor
= (function (_super
) {
10162 __extends(ScreenDprMonitor
, _super
);
10163 function ScreenDprMonitor() {
10164 var _this
= _super
!== null && _super
.apply(this, arguments
) || this;
10165 _this
._currentDevicePixelRatio
= window
.devicePixelRatio
;
10168 ScreenDprMonitor
.prototype.setListener = function (listener
) {
10170 if (this._listener
) {
10171 this.clearListener();
10173 this._listener
= listener
;
10174 this._outerListener = function () {
10175 if (!_this
._listener
) {
10178 _this
._listener(window
.devicePixelRatio
, _this
._currentDevicePixelRatio
);
10179 _this
._updateDpr();
10183 ScreenDprMonitor
.prototype.dispose = function () {
10184 _super
.prototype.dispose
.call(this);
10185 this.clearListener();
10187 ScreenDprMonitor
.prototype._updateDpr = function () {
10188 if (!this._resolutionMediaMatchList
|| !this._outerListener
) {
10191 this._resolutionMediaMatchList
.removeListener(this._outerListener
);
10192 this._currentDevicePixelRatio
= window
.devicePixelRatio
;
10193 this._resolutionMediaMatchList
= window
.matchMedia("screen and (resolution: " + window
.devicePixelRatio
+ "dppx)");
10194 this._resolutionMediaMatchList
.addListener(this._outerListener
);
10196 ScreenDprMonitor
.prototype.clearListener = function () {
10197 if (!this._resolutionMediaMatchList
|| !this._listener
|| !this._outerListener
) {
10200 this._resolutionMediaMatchList
.removeListener(this._outerListener
);
10201 this._resolutionMediaMatchList
= undefined;
10202 this._listener
= undefined;
10203 this._outerListener
= undefined;
10205 return ScreenDprMonitor
;
10206 }(Lifecycle_1
.Disposable
));
10207 exports
.ScreenDprMonitor
= ScreenDprMonitor
;
10209 },{"../common/Lifecycle":26}],58:[function(require
,module
,exports
){
10211 Object
.defineProperty(exports
, "__esModule", { value
: true });
10212 var Terminal_1
= require("./public/Terminal");
10213 module
.exports
= Terminal_1
.Terminal
;
10215 },{"./public/Terminal":34}]},{},[58])(58)
10217 //# sourceMappingURL=xterm.js.map