From: Daniel Imms Date: Fri, 23 Jun 2017 02:37:18 +0000 (-0700) Subject: Merge branch 'master' into 553_find_api X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=baccca843c82cff7891e1f6ceb37186bba34b27a;p=mirror_xterm.js.git Merge branch 'master' into 553_find_api --- baccca843c82cff7891e1f6ceb37186bba34b27a diff --cc src/SelectionManager.ts index 0151427,b3316ae..a99cfa0 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@@ -5,10 -7,8 +7,9 @@@ import * as Browser from './utils/Brows import { CharMeasure } from './utils/CharMeasure'; import { CircularList } from './utils/CircularList'; import { EventEmitter } from './EventEmitter'; - import * as Mouse from './utils/Mouse'; import { ITerminal } from './Interfaces'; import { SelectionModel } from './SelectionModel'; +import { translateBufferLineToString } from './utils/BufferLine'; /** * The number of pixels the mouse needs to be above or below the viewport in @@@ -245,10 -247,62 +251,13 @@@ export class SelectionManager extends E this.refresh(); } - /** - * Translates a buffer line to a string, with optional start and end columns. - * Wide characters will count as two columns in the resulting string. This - * function is useful for getting the actual text underneath the raw selection - * position. - * @param line The line being translated. - * @param trimRight Whether to trim whitespace to the right. - * @param startCol The column to start at. - * @param endCol The column to end at. - */ - private _translateBufferLineToString(line: any, trimRight: boolean, startCol: number = 0, endCol: number = null): string { - // TODO: This function should live in a buffer or buffer line class - - // Get full line - let lineString = ''; - let widthAdjustedStartCol = startCol; - let widthAdjustedEndCol = endCol; - for (let i = 0; i < line.length; i++) { - const char = line[i]; - lineString += char[LINE_DATA_CHAR_INDEX]; - // Adjust start and end cols for wide characters if they affect their - // column indexes - if (char[LINE_DATA_WIDTH_INDEX] === 0) { - if (startCol >= i) { - widthAdjustedStartCol--; - } - if (endCol >= i) { - widthAdjustedEndCol--; - } - } - } - - // Calculate the final end col by trimming whitespace on the right of the - // line if needed. - let finalEndCol = widthAdjustedEndCol || line.length; - if (trimRight) { - const rightWhitespaceIndex = lineString.search(/\s+$/); - if (rightWhitespaceIndex !== -1) { - finalEndCol = Math.min(finalEndCol, rightWhitespaceIndex); - } - // Return the empty string if only trimmed whitespace is selected - if (finalEndCol <= widthAdjustedStartCol) { - return ''; - } - } - - return lineString.substring(widthAdjustedStartCol, finalEndCol); - } - /** * Queues a refresh, redrawing the selection on the next opportunity. + * @param isNewSelection Whether the selection should be registered as a new + * selection on Linux. */ - public refresh(): void { + public refresh(isNewSelection?: boolean): void { + // Queue the refresh for the renderer if (!this._refreshAnimationFrame) { this._refreshAnimationFrame = window.requestAnimationFrame(() => this._refresh()); }