From: Daniel Imms Date: Mon, 19 Jun 2017 14:47:40 +0000 (-0700) Subject: Merge branch 'master' into 697_select_to_word X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=1c659841faea70f97b304f876aebaee2e1b4f201;p=mirror_xterm.js.git Merge branch 'master' into 697_select_to_word --- 1c659841faea70f97b304f876aebaee2e1b4f201 diff --cc src/SelectionManager.ts index ac0e429,ec0c71e..a769afd --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@@ -649,30 -636,20 +655,39 @@@ export class SelectionManager extends E } } - // Record the resulting selection - this._model.selectionStart = [startIndex + charOffset - leftWideCharCount, coords[1]]; - this._model.selectionStartLength = Math.min(endIndex - startIndex + leftWideCharCount + rightWideCharCount + 1/*include endIndex char*/, this._terminal.cols); + const start = startIndex + charOffset - leftWideCharCount; + const length = Math.min(endIndex - startIndex + leftWideCharCount + rightWideCharCount + 1/*include endIndex char*/, this._terminal.cols); + return {start, length}; + } + + /** + * Selects the word at the coordinates specified. + * @param coords The coordinates to get the word at. + */ + protected _selectWordAt(coords: [number, number]): void { + const wordPosition = this._getWordAt(coords); + this._model.selectionStart = [wordPosition.start, coords[1]]; + this._model.selectionStartLength = wordPosition.length; + } + + /** + * Sets the selection end to the word at the coordinated specified. + * @param coords The coordinates to get the word at. + */ + private _selectToWordAt(coords: [number, number]): void { + const wordPosition = this._getWordAt(coords); + this._model.selectionEnd = [this._model.areSelectionValuesReversed() ? wordPosition.start : (wordPosition.start + wordPosition.length), coords[1]]; } + /** + * Gets whether the character is considered a word separator by the select + * word logic. + * @param char The character to check. + */ + private _isCharWordSeparator(char: string): boolean { + return WORD_SEPARATORS.indexOf(char) >= 0; + } + /** * Selects the line specified. * @param line The line index.