Merge pull request #2244 from MaxRis/word-separator-option

Define wordSeparator option
This commit is contained in:
Daniel Imms
2019-06-21 11:53:36 -07:00
committed by GitHub
5 changed files with 16 additions and 12 deletions
+1 -7
View File
@@ -38,12 +38,6 @@ const DRAG_SCROLL_INTERVAL = 50;
*/ */
const ALT_CLICK_MOVE_CURSOR_TIME = 500; const ALT_CLICK_MOVE_CURSOR_TIME = 500;
/**
* A string containing all characters that are considered word separated by the
* double click to select work logic.
*/
const WORD_SEPARATORS = ' ()[]{}\'"';
const NON_BREAKING_SPACE_CHAR = String.fromCharCode(160); const NON_BREAKING_SPACE_CHAR = String.fromCharCode(160);
const ALL_NON_BREAKING_SPACE_REGEX = new RegExp(NON_BREAKING_SPACE_CHAR, 'g'); const ALL_NON_BREAKING_SPACE_REGEX = new RegExp(NON_BREAKING_SPACE_CHAR, 'g');
@@ -914,7 +908,7 @@ export class SelectionManager implements ISelectionManager {
if (cell.getWidth() === 0) { if (cell.getWidth() === 0) {
return false; return false;
} }
return WORD_SEPARATORS.indexOf(cell.getChars()) >= 0; return this._terminal.optionsService.options.wordSeparator.indexOf(cell.getChars()) >= 0;
} }
/** /**
+3 -1
View File
@@ -46,7 +46,8 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({
screenKeys: false, screenKeys: false,
debug: false, debug: false,
cancelEvents: false, cancelEvents: false,
useFlowControl: false useFlowControl: false,
wordSeparator: ' ()[]{}\'"'
}); });
/** /**
@@ -99,6 +100,7 @@ export class OptionsService implements IOptionsService {
case 'fontWeight': case 'fontWeight':
case 'fontWeightBold': case 'fontWeightBold':
case 'rendererType': case 'rendererType':
case 'wordSeparator':
if (!value) { if (!value) {
value = DEFAULT_OPTIONS[key]; value = DEFAULT_OPTIONS[key];
} }
+2
View File
@@ -56,6 +56,7 @@ export interface IPartialTerminalOptions {
tabStopWidth?: number; tabStopWidth?: number;
theme?: ITheme; theme?: ITheme;
windowsMode?: boolean; windowsMode?: boolean;
wordSeparator?: string;
} }
export interface ITerminalOptions { export interface ITerminalOptions {
@@ -91,6 +92,7 @@ export interface ITerminalOptions {
screenKeys: boolean; screenKeys: boolean;
termName: string; termName: string;
useFlowControl: boolean; useFlowControl: boolean;
wordSeparator?: string;
} }
export interface ITheme { export interface ITheme {
+2 -2
View File
@@ -125,7 +125,7 @@ export class Terminal implements ITerminalApi {
public writeUtf8(data: Uint8Array): void { public writeUtf8(data: Uint8Array): void {
this._core.writeUtf8(data); this._core.writeUtf8(data);
} }
public getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'fontWeight' | 'fontWeightBold' | 'rendererType' | 'termName'): string; public getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'fontWeight' | 'fontWeightBold' | 'rendererType' | 'termName' | 'wordSeparator'): string;
public getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell'): boolean; public getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell'): boolean;
public getOption(key: 'colors'): string[]; public getOption(key: 'colors'): string[];
public getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; public getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number;
@@ -134,7 +134,7 @@ export class Terminal implements ITerminalApi {
public getOption(key: any): any { public getOption(key: any): any {
return this._core.optionsService.getOption(key); return this._core.optionsService.getOption(key);
} }
public setOption(key: 'bellSound' | 'fontFamily' | 'termName', value: string): void; public setOption(key: 'bellSound' | 'fontFamily' | 'termName' | 'wordSeparator', value: string): void;
public setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'): void; public setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'): void;
public setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void; public setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void;
public setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void; public setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void;
+8 -2
View File
@@ -177,6 +177,12 @@ declare module 'xterm' {
* not whitespace. * not whitespace.
*/ */
windowsMode?: boolean; windowsMode?: boolean;
/**
* A string containing all characters that are considered word separated by the
* double click to select work logic.
*/
wordSeparator?: string;
} }
/** /**
@@ -673,7 +679,7 @@ declare module 'xterm' {
* Retrieves an option's value from the terminal. * Retrieves an option's value from the terminal.
* @param key The option key. * @param key The option key.
*/ */
getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'fontWeight' | 'fontWeightBold'| 'rendererType' | 'termName'): string; getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'fontWeight' | 'fontWeightBold'| 'rendererType' | 'termName' | 'wordSeparator'): string;
/** /**
* Retrieves an option's value from the terminal. * Retrieves an option's value from the terminal.
* @param key The option key. * @param key The option key.
@@ -705,7 +711,7 @@ declare module 'xterm' {
* @param key The option key. * @param key The option key.
* @param value The option value. * @param value The option value.
*/ */
setOption(key: 'fontFamily' | 'termName' | 'bellSound', value: string): void; setOption(key: 'fontFamily' | 'termName' | 'bellSound' | 'wordSeparator', value: string): void;
/** /**
* Sets an option on the terminal. * Sets an option on the terminal.
* @param key The option key. * @param key The option key.