]> git.proxmox.com Git - mirror_xterm.js.git/blob - src/SelectionManager.ts
Merge branch 'master' into codeCleanUp
[mirror_xterm.js.git] / src / SelectionManager.ts
1 /**
2 * @license MIT
3 */
4
5 import * as Mouse from './utils/Mouse';
6 import * as Browser from './utils/Browser';
7 import { CharMeasure } from './utils/CharMeasure';
8 import { CircularList } from './utils/CircularList';
9 import { EventEmitter } from './EventEmitter';
10 import { ITerminal } from './Interfaces';
11 import { SelectionModel } from './SelectionModel';
12
13 /**
14 * The number of pixels the mouse needs to be above or below the viewport in
15 * order to scroll at the maximum speed.
16 */
17 const DRAG_SCROLL_MAX_THRESHOLD = 50;
18
19 /**
20 * The maximum scrolling speed
21 */
22 const DRAG_SCROLL_MAX_SPEED = 15;
23
24 /**
25 * The number of milliseconds between drag scroll updates.
26 */
27 const DRAG_SCROLL_INTERVAL = 50;
28
29 /**
30 * The amount of time before mousedown events are no longer stacked to create
31 * double/triple click events.
32 */
33 const CLEAR_MOUSE_DOWN_TIME = 400;
34
35 /**
36 * The number of pixels in each direction that the mouse must move before
37 * mousedown events are no longer stacked to create double/triple click events.
38 */
39 const CLEAR_MOUSE_DISTANCE = 10;
40
41 /**
42 * A string containing all characters that are considered word separated by the
43 * double click to select work logic.
44 */
45 const WORD_SEPARATORS = ' ()[]{}:\'"';
46
47 // TODO: Move these constants elsewhere, they belong in a buffer or buffer
48 // data/line class.
49 const LINE_DATA_CHAR_INDEX = 1;
50 const LINE_DATA_WIDTH_INDEX = 2;
51
52 const NON_BREAKING_SPACE_CHAR = String.fromCharCode(160);
53 const ALL_NON_BREAKING_SPACE_REGEX = new RegExp(NON_BREAKING_SPACE_CHAR, 'g');
54
55 /**
56 * Represents a position of a word on a line.
57 */
58 interface IWordPosition {
59 start: number;
60 length: number;
61 }
62
63 /**
64 * A selection mode, this drives how the selection behaves on mouse move.
65 */
66 enum SelectionMode {
67 NORMAL,
68 WORD,
69 LINE
70 }
71
72 /**
73 * A class that manages the selection of the terminal. With help from
74 * SelectionModel, SelectionManager handles with all logic associated with
75 * dealing with the selection, including handling mouse interaction, wide
76 * characters and fetching the actual text within the selection. Rendering is
77 * not handled by the SelectionManager but a 'refresh' event is fired when the
78 * selection is ready to be redrawn.
79 */
80 export class SelectionManager extends EventEmitter {
81 protected _model: SelectionModel;
82
83 /**
84 * The amount to scroll every drag scroll update (depends on how far the mouse
85 * drag is above or below the terminal).
86 */
87 private _dragScrollAmount: number;
88
89 /**
90 * The last time the mousedown event fired, this is used to track double and
91 * triple clicks.
92 */
93 private _lastMouseDownTime: number;
94
95 /**
96 * The last position the mouse was clicked [x, y].
97 */
98 private _lastMousePosition: [number, number];
99
100 /**
101 * The number of clicks of the mousedown event. This is used to keep track of
102 * double and triple clicks.
103 */
104 private _clickCount: number;
105
106 /**
107 * The current selection mode.
108 */
109 private _activeSelectionMode: SelectionMode;
110
111 /**
112 * A setInterval timer that is active while the mouse is down whose callback
113 * scrolls the viewport when necessary.
114 */
115 private _dragScrollIntervalTimer: NodeJS.Timer;
116
117 /**
118 * The animation frame ID used for refreshing the selection.
119 */
120 private _refreshAnimationFrame: number;
121
122 private _bufferTrimListener: any;
123 private _mouseMoveListener: EventListener;
124 private _mouseDownListener: EventListener;
125 private _mouseUpListener: EventListener;
126
127 constructor(
128 private _terminal: ITerminal,
129 private _buffer: CircularList<any>,
130 private _rowContainer: HTMLElement,
131 private _charMeasure: CharMeasure
132 ) {
133 super();
134 this._initListeners();
135 this.enable();
136
137 this._model = new SelectionModel(_terminal);
138 this._lastMouseDownTime = 0;
139 this._activeSelectionMode = SelectionMode.NORMAL;
140 }
141
142 /**
143 * Initializes listener variables.
144 */
145 private _initListeners() {
146 this._bufferTrimListener = (amount: number) => this._onTrim(amount);
147 this._mouseMoveListener = event => this._onMouseMove(<MouseEvent>event);
148 this._mouseDownListener = event => this._onMouseDown(<MouseEvent>event);
149 this._mouseUpListener = event => this._onMouseUp(<MouseEvent>event);
150 }
151
152 /**
153 * Disables the selection manager. This is useful for when terminal mouse
154 * are enabled.
155 */
156 public disable() {
157 this.clearSelection();
158 this._buffer.off('trim', this._bufferTrimListener);
159 this._rowContainer.removeEventListener('mousedown', this._mouseDownListener);
160 }
161
162 /**
163 * Enable the selection manager.
164 */
165 public enable() {
166 // Only adjust the selection on trim, shiftElements is rarely used (only in
167 // reverseIndex) and delete in a splice is only ever used when the same
168 // number of elements was just added. Given this is could actually be
169 // beneficial to leave the selection as is for these cases.
170 this._buffer.on('trim', this._bufferTrimListener);
171 this._rowContainer.addEventListener('mousedown', this._mouseDownListener);
172 }
173
174 /**
175 * Sets the active buffer, this should be called when the alt buffer is
176 * switched in or out.
177 * @param buffer The active buffer.
178 */
179 public setBuffer(buffer: CircularList<any>): void {
180 this._buffer = buffer;
181 this.clearSelection();
182 }
183
184 /**
185 * Gets whether there is an active text selection.
186 */
187 public get hasSelection(): boolean {
188 const start = this._model.finalSelectionStart;
189 const end = this._model.finalSelectionEnd;
190 if (!start || !end) {
191 return false;
192 }
193 return start[0] !== end[0] || start[1] !== end[1];
194 }
195
196 /**
197 * Gets the text currently selected.
198 */
199 public get selectionText(): string {
200 const start = this._model.finalSelectionStart;
201 const end = this._model.finalSelectionEnd;
202 if (!start || !end) {
203 return '';
204 }
205
206 // Get first row
207 const startRowEndCol = start[1] === end[1] ? end[0] : null;
208 let result: string[] = [];
209 result.push(this._translateBufferLineToString(this._buffer.get(start[1]), true, start[0], startRowEndCol));
210
211 // Get middle rows
212 for (let i = start[1] + 1; i <= end[1] - 1; i++) {
213 const bufferLine = this._buffer.get(i);
214 const lineText = this._translateBufferLineToString(bufferLine, true);
215 if (bufferLine.isWrapped) {
216 result[result.length - 1] += lineText;
217 } else {
218 result.push(lineText);
219 }
220 }
221
222 // Get final row
223 if (start[1] !== end[1]) {
224 const bufferLine = this._buffer.get(end[1]);
225 const lineText = this._translateBufferLineToString(bufferLine, true, 0, end[0]);
226 if (bufferLine.isWrapped) {
227 result[result.length - 1] += lineText;
228 } else {
229 result.push(lineText);
230 }
231 }
232
233 // Format string by replacing non-breaking space chars with regular spaces
234 // and joining the array into a multi-line string.
235 const formattedResult = result.map(line => {
236 return line.replace(ALL_NON_BREAKING_SPACE_REGEX, ' ');
237 }).join(Browser.isMSWindows ? '\r\n' : '\n');
238
239 return formattedResult;
240 }
241
242 /**
243 * Clears the current terminal selection.
244 */
245 public clearSelection(): void {
246 this._model.clearSelection();
247 this._removeMouseDownListeners();
248 this.refresh();
249 }
250
251 /**
252 * Translates a buffer line to a string, with optional start and end columns.
253 * Wide characters will count as two columns in the resulting string. This
254 * function is useful for getting the actual text underneath the raw selection
255 * position.
256 * @param line The line being translated.
257 * @param trimRight Whether to trim whitespace to the right.
258 * @param startCol The column to start at.
259 * @param endCol The column to end at.
260 */
261 private _translateBufferLineToString(line: any, trimRight: boolean, startCol: number = 0, endCol: number = null): string {
262 // TODO: This function should live in a buffer or buffer line class
263
264 // Get full line
265 let lineString = '';
266 let widthAdjustedStartCol = startCol;
267 let widthAdjustedEndCol = endCol;
268 for (let i = 0; i < line.length; i++) {
269 const char = line[i];
270 lineString += char[LINE_DATA_CHAR_INDEX];
271 // Adjust start and end cols for wide characters if they affect their
272 // column indexes
273 if (char[LINE_DATA_WIDTH_INDEX] === 0) {
274 if (startCol >= i) {
275 widthAdjustedStartCol--;
276 }
277 if (endCol >= i) {
278 widthAdjustedEndCol--;
279 }
280 }
281 }
282
283 // Calculate the final end col by trimming whitespace on the right of the
284 // line if needed.
285 let finalEndCol = widthAdjustedEndCol || line.length;
286 if (trimRight) {
287 const rightWhitespaceIndex = lineString.search(/\s+$/);
288 if (rightWhitespaceIndex !== -1) {
289 finalEndCol = Math.min(finalEndCol, rightWhitespaceIndex);
290 }
291 // Return the empty string if only trimmed whitespace is selected
292 if (finalEndCol <= widthAdjustedStartCol) {
293 return '';
294 }
295 }
296
297 return lineString.substring(widthAdjustedStartCol, finalEndCol);
298 }
299
300 /**
301 * Queues a refresh, redrawing the selection on the next opportunity.
302 * @param isNewSelection Whether the selection should be registered as a new
303 * selection on Linux.
304 */
305 public refresh(isNewSelection?: boolean): void {
306 // Queue the refresh for the renderer
307 if (!this._refreshAnimationFrame) {
308 this._refreshAnimationFrame = window.requestAnimationFrame(() => this._refresh());
309 }
310
311 // If the platform is Linux and the refresh call comes from a mouse event,
312 // we need to update the selection for middle click to paste selection.
313 if (Browser.isLinux && isNewSelection) {
314 const selectionText = this.selectionText;
315 if (selectionText.length) {
316 this.emit('newselection', this.selectionText);
317 }
318 }
319 }
320
321 /**
322 * Fires the refresh event, causing consumers to pick it up and redraw the
323 * selection state.
324 */
325 private _refresh(): void {
326 this._refreshAnimationFrame = null;
327 this.emit('refresh', { start: this._model.finalSelectionStart, end: this._model.finalSelectionEnd });
328 }
329
330 /**
331 * Selects all text within the terminal.
332 */
333 public selectAll(): void {
334 this._model.isSelectAllActive = true;
335 this.refresh();
336 }
337
338 /**
339 * Handle the buffer being trimmed, adjust the selection position.
340 * @param amount The amount the buffer is being trimmed.
341 */
342 private _onTrim(amount: number) {
343 const needsRefresh = this._model.onTrim(amount);
344 if (needsRefresh) {
345 this.refresh();
346 }
347 }
348
349 /**
350 * Gets the 0-based [x, y] buffer coordinates of the current mouse event.
351 * @param event The mouse event.
352 */
353 private _getMouseBufferCoords(event: MouseEvent): [number, number] {
354 const coords = Mouse.getCoords(event, this._rowContainer, this._charMeasure, this._terminal.cols, this._terminal.rows, true);
355 // Convert to 0-based
356 coords[0]--;
357 coords[1]--;
358 // Convert viewport coords to buffer coords
359 coords[1] += this._terminal.ydisp;
360 return coords;
361 }
362
363 /**
364 * Gets the amount the viewport should be scrolled based on how far out of the
365 * terminal the mouse is.
366 * @param event The mouse event.
367 */
368 private _getMouseEventScrollAmount(event: MouseEvent): number {
369 let offset = Mouse.getCoordsRelativeToElement(event, this._rowContainer)[1];
370 const terminalHeight = this._terminal.rows * this._charMeasure.height;
371 if (offset >= 0 && offset <= terminalHeight) {
372 return 0;
373 }
374 if (offset > terminalHeight) {
375 offset -= terminalHeight;
376 }
377
378 offset = Math.min(Math.max(offset, -DRAG_SCROLL_MAX_THRESHOLD), DRAG_SCROLL_MAX_THRESHOLD);
379 offset /= DRAG_SCROLL_MAX_THRESHOLD;
380 return (offset / Math.abs(offset)) + Math.round(offset * (DRAG_SCROLL_MAX_SPEED - 1));
381 }
382
383 /**
384 * Handles te mousedown event, setting up for a new selection.
385 * @param event The mousedown event.
386 */
387 private _onMouseDown(event: MouseEvent) {
388 // Only action the primary button
389 if (event.button !== 0) {
390 return;
391 }
392
393 // Tell the browser not to start a regular selection
394 event.preventDefault();
395
396 // Reset drag scroll state
397 this._dragScrollAmount = 0;
398
399 this._setMouseClickCount(event);
400
401 if (event.shiftKey) {
402 this._onShiftClick(event);
403 } else {
404 if (this._clickCount === 1) {
405 this._onSingleClick(event);
406 } else if (this._clickCount === 2) {
407 this._onDoubleClick(event);
408 } else if (this._clickCount === 3) {
409 this._onTripleClick(event);
410 }
411 }
412
413 this._addMouseDownListeners();
414 this.refresh(true);
415 }
416
417 /**
418 * Adds listeners when mousedown is triggered.
419 */
420 private _addMouseDownListeners(): void {
421 // Listen on the document so that dragging outside of viewport works
422 this._rowContainer.ownerDocument.addEventListener('mousemove', this._mouseMoveListener);
423 this._rowContainer.ownerDocument.addEventListener('mouseup', this._mouseUpListener);
424 this._dragScrollIntervalTimer = setInterval(() => this._dragScroll(), DRAG_SCROLL_INTERVAL);
425 }
426
427 /**
428 * Removes the listeners that are registered when mousedown is triggered.
429 */
430 private _removeMouseDownListeners(): void {
431 this._rowContainer.ownerDocument.removeEventListener('mousemove', this._mouseMoveListener);
432 this._rowContainer.ownerDocument.removeEventListener('mouseup', this._mouseUpListener);
433 clearInterval(this._dragScrollIntervalTimer);
434 this._dragScrollIntervalTimer = null;
435 }
436
437 /**
438 * Performs a shift click, setting the selection end position to the mouse
439 * position.
440 * @param event The mouse event.
441 */
442 private _onShiftClick(event: MouseEvent): void {
443 if (this._model.selectionStart) {
444 this._model.selectionEnd = this._getMouseBufferCoords(event);
445 }
446 }
447
448 /**
449 * Performs a single click, resetting relevant state and setting the selection
450 * start position.
451 * @param event The mouse event.
452 */
453 private _onSingleClick(event: MouseEvent): void {
454 this._model.selectionStartLength = 0;
455 this._model.isSelectAllActive = false;
456 this._activeSelectionMode = SelectionMode.NORMAL;
457 this._model.selectionStart = this._getMouseBufferCoords(event);
458 if (this._model.selectionStart) {
459 this._model.selectionEnd = null;
460 // If the mouse is over the second half of a wide character, adjust the
461 // selection to cover the whole character
462 const char = this._buffer.get(this._model.selectionStart[1])[this._model.selectionStart[0]];
463 if (char[LINE_DATA_WIDTH_INDEX] === 0) {
464 this._model.selectionStart[0]++;
465 }
466 }
467 }
468
469 /**
470 * Performs a double click, selecting the current work.
471 * @param event The mouse event.
472 */
473 private _onDoubleClick(event: MouseEvent): void {
474 const coords = this._getMouseBufferCoords(event);
475 if (coords) {
476 this._activeSelectionMode = SelectionMode.WORD;
477 this._selectWordAt(coords);
478 }
479 }
480
481 /**
482 * Performs a triple click, selecting the current line and activating line
483 * select mode.
484 * @param event The mouse event.
485 */
486 private _onTripleClick(event: MouseEvent): void {
487 const coords = this._getMouseBufferCoords(event);
488 if (coords) {
489 this._activeSelectionMode = SelectionMode.LINE;
490 this._selectLineAt(coords[1]);
491 }
492 }
493
494 /**
495 * Sets the number of clicks for the current mousedown event based on the time
496 * and position of the last mousedown event.
497 * @param event The mouse event.
498 */
499 private _setMouseClickCount(event: MouseEvent): void {
500 let currentTime = (new Date()).getTime();
501 if (currentTime - this._lastMouseDownTime > CLEAR_MOUSE_DOWN_TIME || this._distanceFromLastMousePosition(event) > CLEAR_MOUSE_DISTANCE) {
502 this._clickCount = 0;
503 }
504 this._lastMouseDownTime = currentTime;
505 this._lastMousePosition = [event.pageX, event.pageY];
506 this._clickCount++;
507 }
508
509 /**
510 * Gets the maximum number of pixels in each direction the mouse has moved.
511 * @param event The mouse event.
512 */
513 private _distanceFromLastMousePosition(event: MouseEvent): number {
514 const result = Math.max(
515 Math.abs(this._lastMousePosition[0] - event.pageX),
516 Math.abs(this._lastMousePosition[1] - event.pageY));
517 return result;
518 }
519
520 /**
521 * Handles the mousemove event when the mouse button is down, recording the
522 * end of the selection and refreshing the selection.
523 * @param event The mousemove event.
524 */
525 private _onMouseMove(event: MouseEvent) {
526 // Record the previous position so we know whether to redraw the selection
527 // at the end.
528 const previousSelectionEnd = this._model.selectionEnd ? [this._model.selectionEnd[0], this._model.selectionEnd[1]] : null;
529
530 // Set the initial selection end based on the mouse coordinates
531 this._model.selectionEnd = this._getMouseBufferCoords(event);
532
533 // Select the entire line if line select mode is active.
534 if (this._activeSelectionMode === SelectionMode.LINE) {
535 if (this._model.selectionEnd[1] < this._model.selectionStart[1]) {
536 this._model.selectionEnd[0] = 0;
537 } else {
538 this._model.selectionEnd[0] = this._terminal.cols;
539 }
540 } else if (this._activeSelectionMode === SelectionMode.WORD) {
541 this._selectToWordAt(this._model.selectionEnd);
542 }
543
544 // Determine the amount of scrolling that will happen.
545 this._dragScrollAmount = this._getMouseEventScrollAmount(event);
546
547 // If the cursor was above or below the viewport, make sure it's at the
548 // start or end of the viewport respectively.
549 if (this._dragScrollAmount > 0) {
550 this._model.selectionEnd[0] = this._terminal.cols - 1;
551 } else if (this._dragScrollAmount < 0) {
552 this._model.selectionEnd[0] = 0;
553 }
554
555 // If the character is a wide character include the cell to the right in the
556 // selection. Note that selections at the very end of the line will never
557 // have a character.
558 if (this._model.selectionEnd[1] < this._buffer.length) {
559 const char = this._buffer.get(this._model.selectionEnd[1])[this._model.selectionEnd[0]];
560 if (char && char[2] === 0) {
561 this._model.selectionEnd[0]++;
562 }
563 }
564
565 // Only draw here if the selection changes.
566 if (!previousSelectionEnd ||
567 previousSelectionEnd[0] !== this._model.selectionEnd[0] ||
568 previousSelectionEnd[1] !== this._model.selectionEnd[1]) {
569 this.refresh(true);
570 }
571 }
572
573 /**
574 * The callback that occurs every DRAG_SCROLL_INTERVAL ms that does the
575 * scrolling of the viewport.
576 */
577 private _dragScroll() {
578 if (this._dragScrollAmount) {
579 this._terminal.scrollDisp(this._dragScrollAmount, false);
580 // Re-evaluate selection
581 if (this._dragScrollAmount > 0) {
582 this._model.selectionEnd = [this._terminal.cols - 1, this._terminal.ydisp + this._terminal.rows];
583 } else {
584 this._model.selectionEnd = [0, this._terminal.ydisp];
585 }
586 this.refresh();
587 }
588 }
589
590 /**
591 * Handles the mouseup event, removing the mousedown listeners.
592 * @param event The mouseup event.
593 */
594 private _onMouseUp(event: MouseEvent) {
595 this._removeMouseDownListeners();
596 }
597
598 /**
599 * Converts a viewport column to the character index on the buffer line, the
600 * latter takes into account wide characters.
601 * @param coords The coordinates to find the 2 index for.
602 */
603 private _convertViewportColToCharacterIndex(bufferLine: any, coords: [number, number]): number {
604 let charIndex = coords[0];
605 for (let i = 0; coords[0] >= i; i++) {
606 const char = bufferLine[i];
607 if (char[LINE_DATA_WIDTH_INDEX] === 0) {
608 charIndex--;
609 }
610 }
611 return charIndex;
612 }
613
614 /**
615 * Gets positional information for the word at the coordinated specified.
616 * @param coords The coordinates to get the word at.
617 */
618 private _getWordAt(coords: [number, number]): IWordPosition {
619 const bufferLine = this._buffer.get(coords[1]);
620 const line = this._translateBufferLineToString(bufferLine, false);
621
622 // Get actual index, taking into consideration wide characters
623 let endIndex = this._convertViewportColToCharacterIndex(bufferLine, coords);
624 let startIndex = endIndex;
625
626 // Record offset to be used later
627 const charOffset = coords[0] - startIndex;
628 let leftWideCharCount = 0;
629 let rightWideCharCount = 0;
630
631 if (line.charAt(startIndex) === ' ') {
632 // Expand until non-whitespace is hit
633 while (startIndex > 0 && line.charAt(startIndex - 1) === ' ') {
634 startIndex--;
635 }
636 while (endIndex < line.length && line.charAt(endIndex + 1) === ' ') {
637 endIndex++;
638 }
639 } else {
640 // Expand until whitespace is hit. This algorithm works by scanning left
641 // and right from the starting position, keeping both the index format
642 // (line) and the column format (bufferLine) in sync. When a wide
643 // character is hit, it is recorded and the column index is adjusted.
644 let startCol = coords[0];
645 let endCol = coords[0];
646 // Consider the initial position, skip it and increment the wide char
647 // variable
648 if (bufferLine[startCol][LINE_DATA_WIDTH_INDEX] === 0) {
649 leftWideCharCount++;
650 startCol--;
651 }
652 if (bufferLine[endCol][LINE_DATA_WIDTH_INDEX] === 2) {
653 rightWideCharCount++;
654 endCol++;
655 }
656 // Expand the string in both directions until a space is hit
657 while (startIndex > 0 && !this._isCharWordSeparator(line.charAt(startIndex - 1))) {
658 if (bufferLine[startCol - 1][LINE_DATA_WIDTH_INDEX] === 0) {
659 // If the next character is a wide char, record it and skip the column
660 leftWideCharCount++;
661 startCol--;
662 }
663 startIndex--;
664 startCol--;
665 }
666 while (endIndex + 1 < line.length && !this._isCharWordSeparator(line.charAt(endIndex + 1))) {
667 if (bufferLine[endCol + 1][LINE_DATA_WIDTH_INDEX] === 2) {
668 // If the next character is a wide char, record it and skip the column
669 rightWideCharCount++;
670 endCol++;
671 }
672 endIndex++;
673 endCol++;
674 }
675 }
676
677 const start = startIndex + charOffset - leftWideCharCount;
678 const length = Math.min(endIndex - startIndex + leftWideCharCount + rightWideCharCount + 1/*include endIndex char*/, this._terminal.cols);
679 return {start, length};
680 }
681
682 /**
683 * Selects the word at the coordinates specified.
684 * @param coords The coordinates to get the word at.
685 */
686 protected _selectWordAt(coords: [number, number]): void {
687 const wordPosition = this._getWordAt(coords);
688 this._model.selectionStart = [wordPosition.start, coords[1]];
689 this._model.selectionStartLength = wordPosition.length;
690 }
691
692 /**
693 * Sets the selection end to the word at the coordinated specified.
694 * @param coords The coordinates to get the word at.
695 */
696 private _selectToWordAt(coords: [number, number]): void {
697 const wordPosition = this._getWordAt(coords);
698 this._model.selectionEnd = [this._model.areSelectionValuesReversed() ? wordPosition.start : (wordPosition.start + wordPosition.length), coords[1]];
699 }
700
701 /**
702 * Gets whether the character is considered a word separator by the select
703 * word logic.
704 * @param char The character to check.
705 */
706 private _isCharWordSeparator(char: string): boolean {
707 return WORD_SEPARATORS.indexOf(char) >= 0;
708 }
709
710 /**
711 * Selects the line specified.
712 * @param line The line index.
713 */
714 protected _selectLineAt(line: number): void {
715 this._model.selectionStart = [0, line];
716 this._model.selectionStartLength = this._terminal.cols;
717 }
718 }