From 69977be4a1bf14256f9bd870207e995552c05144 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 7 Jun 2017 12:55:15 -0700 Subject: [PATCH 1/8] Use beta xterm.js build --- npm-shrinkwrap.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 3e962373c7d9d..9d6c80bfb68b5 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -440,9 +440,9 @@ "resolved": "https://registry.npmjs.org/winreg/-/winreg-1.2.0.tgz" }, "xterm": { - "version": "2.6.0", - "from": "Tyriar/xterm.js#vscode-release/1.13", - "resolved": "git+https://github.com/Tyriar/xterm.js.git#32c9eac8ee5a958093d126a06c1c06a7cd6052bf" + "version": "2.7.0", + "from": "Tyriar/xterm.js#vscode-release/1.14-beta", + "resolved": "git+https://github.com/Tyriar/xterm.js.git#2697bd2f9560b7ce28cfcd368cd68008276219a0" }, "yauzl": { "version": "2.3.1", diff --git a/package.json b/package.json index 333ee2253b61c..588c630f9af34 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "vscode-ripgrep": "0.0.12", "vscode-textmate": "^3.1.5", "winreg": "1.2.0", - "xterm": "Tyriar/xterm.js#vscode-release/1.13", + "xterm": "Tyriar/xterm.js#vscode-release/1.14-beta", "yauzl": "2.3.1" }, "devDependencies": { From 68f9d22c6ccc8aee617a1cfacd3f0103ca16537a Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 7 Jun 2017 12:55:57 -0700 Subject: [PATCH 2/8] Integrate new xterm.js changes --- .../terminal/electron-browser/media/xterm.css | 17 +++++++++++++++++ .../electron-browser/terminalInstance.ts | 18 ++++++++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/parts/terminal/electron-browser/media/xterm.css b/src/vs/workbench/parts/terminal/electron-browser/media/xterm.css index 4ee863dbecb2d..a2b453ef22877 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/media/xterm.css +++ b/src/vs/workbench/parts/terminal/electron-browser/media/xterm.css @@ -6,6 +6,7 @@ .monaco-workbench .panel.integrated-terminal .xterm { position: relative; height: 100%; + user-select: none; } .monaco-workbench .panel.integrated-terminal .xterm:focus { @@ -170,6 +171,22 @@ left: -9999em; } +.monaco-workbench .panel.integrated-terminal .xterm.enable-mouse-events { + /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */ + cursor: default; +} + +.monaco-workbench .panel.integrated-terminal .xterm .xterm-selection { + position: absolute; + left: 0; + bottom: 0; +} + +.monaco-workbench .panel.integrated-terminal .xterm .xterm-selection div { + position: absolute; + background-color: #555; +} + .monaco-workbench .panel.integrated-terminal .xterm .xterm-bold { font-weight: bold; } diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index 4b70c062ba879..1db0be29dd7c7 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -31,7 +31,8 @@ import { TerminalLinkHandler } from 'vs/workbench/parts/terminal/electron-browse import { TerminalWidgetManager } from 'vs/workbench/parts/terminal/browser/terminalWidgetManager'; import { registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService'; import { scrollbarSliderBackground, scrollbarSliderHoverBackground, scrollbarSliderActiveBackground } from 'vs/platform/theme/common/colorRegistry'; -import { TPromise } from "vs/base/common/winjs.base"; +import { TPromise } from 'vs/base/common/winjs.base'; +import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; /** The amount of time to consider terminal errors to be related to the launch */ const LAUNCHING_DURATION = 500; @@ -99,7 +100,8 @@ export class TerminalInstance implements ITerminalInstance { @IPanelService private _panelService: IPanelService, @IWorkspaceContextService private _contextService: IWorkspaceContextService, @IWorkbenchEditorService private _editorService: IWorkbenchEditorService, - @IInstantiationService private _instantiationService: IInstantiationService + @IInstantiationService private _instantiationService: IInstantiationService, + @IClipboardService private _clipboardService: IClipboardService ) { this._instanceDisposables = []; this._processDisposables = []; @@ -323,14 +325,14 @@ export class TerminalInstance implements ITerminalInstance { } public hasSelection(): boolean { - return !document.getSelection().isCollapsed; + return this._xterm.hasSelection(); } public copySelection(): void { - if (document.activeElement.classList.contains('xterm')) { - document.execCommand('copy'); + if (this.hasSelection()) { + this._clipboardService.writeText(this._xterm.getSelection()); } else { - this._messageService.show(Severity.Warning, nls.localize('terminal.integrated.copySelection.noSelection', 'Cannot copy terminal selection when terminal does not have focus')); + this._messageService.show(Severity.Warning, nls.localize('terminal.integrated.copySelection.noSelection', 'The terminal has no selection to copy')); } } @@ -439,8 +441,8 @@ export class TerminalInstance implements ITerminalInstance { private _refreshSelectionContextKey() { const activePanel = this._panelService.getActivePanel(); - const isFocused = activePanel && activePanel.getId() === TERMINAL_PANEL_ID; - this._terminalHasTextContextKey.set(isFocused && !window.getSelection().isCollapsed); + const isActive = activePanel && activePanel.getId() === TERMINAL_PANEL_ID; + this._terminalHasTextContextKey.set(isActive && this.hasSelection()); } private _sanitizeInput(data: any) { From 50c2bc406e5cbda99a137f2f382c4c84e734439f Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 7 Jun 2017 13:34:12 -0700 Subject: [PATCH 3/8] Fix clear selection, add select all command --- npm-shrinkwrap.json | 2 +- .../parts/terminal/common/terminal.ts | 5 +++++ .../electron-browser/terminal.contribution.ts | 14 +++++++++++-- .../electron-browser/terminalActions.ts | 21 +++++++++++++++++++ .../electron-browser/terminalInstance.ts | 6 +++++- 5 files changed, 44 insertions(+), 4 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 9d6c80bfb68b5..91bff39ee52ae 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -442,7 +442,7 @@ "xterm": { "version": "2.7.0", "from": "Tyriar/xterm.js#vscode-release/1.14-beta", - "resolved": "git+https://github.com/Tyriar/xterm.js.git#2697bd2f9560b7ce28cfcd368cd68008276219a0" + "resolved": "git+https://github.com/Tyriar/xterm.js.git#2c61d9c26c0265b8a4ce1542d25dd1258c3e4f5b" }, "yauzl": { "version": "2.3.1", diff --git a/src/vs/workbench/parts/terminal/common/terminal.ts b/src/vs/workbench/parts/terminal/common/terminal.ts index 1093b3ee7e075..e2458c190e7e8 100644 --- a/src/vs/workbench/parts/terminal/common/terminal.ts +++ b/src/vs/workbench/parts/terminal/common/terminal.ts @@ -230,6 +230,11 @@ export interface ITerminalInstance { */ clearSelection(): void; + /** + * Select all text in the terminal. + */ + selectAll(): void; + /** * Focuses the terminal instance. * diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts index 94e7e9a4b5215..09af3cb19c61d 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts @@ -18,7 +18,7 @@ import { TERMINAL_DEFAULT_SHELL_LINUX, TERMINAL_DEFAULT_SHELL_OSX, TERMINAL_DEFA import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actionRegistry'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; -import { KillTerminalAction, CopyTerminalSelectionAction, CreateNewTerminalAction, FocusActiveTerminalAction, FocusNextTerminalAction, FocusPreviousTerminalAction, FocusTerminalAtIndexAction, SelectDefaultShellWindowsTerminalAction, RunSelectedTextInTerminalAction, RunActiveFileInTerminalAction, ScrollDownTerminalAction, ScrollDownPageTerminalAction, ScrollToBottomTerminalAction, ScrollUpTerminalAction, ScrollUpPageTerminalAction, ScrollToTopTerminalAction, TerminalPasteAction, ToggleTerminalAction, ClearTerminalAction, AllowWorkspaceShellTerminalCommand, DisallowWorkspaceShellTerminalCommand } from 'vs/workbench/parts/terminal/electron-browser/terminalActions'; +import { KillTerminalAction, CopyTerminalSelectionAction, CreateNewTerminalAction, FocusActiveTerminalAction, FocusNextTerminalAction, FocusPreviousTerminalAction, FocusTerminalAtIndexAction, SelectDefaultShellWindowsTerminalAction, RunSelectedTextInTerminalAction, RunActiveFileInTerminalAction, ScrollDownTerminalAction, ScrollDownPageTerminalAction, ScrollToBottomTerminalAction, ScrollUpTerminalAction, ScrollUpPageTerminalAction, ScrollToTopTerminalAction, TerminalPasteAction, ToggleTerminalAction, ClearTerminalAction, AllowWorkspaceShellTerminalCommand, DisallowWorkspaceShellTerminalCommand, SelectAllTerminalAction } from 'vs/workbench/parts/terminal/electron-browser/terminalActions'; import { Registry } from 'vs/platform/platform'; import { ShowAllCommandsAction } from 'vs/workbench/parts/quickopen/browser/commandsHandler'; import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; @@ -185,7 +185,8 @@ configurationRegistry.registerConfiguration({ OpenPreviousRecentlyUsedEditorInGroupAction.ID, FocusFirstGroupAction.ID, FocusSecondGroupAction.ID, - FocusThirdGroupAction.ID + FocusThirdGroupAction.ID, + SelectAllTerminalAction.ID ].sort() } } @@ -229,6 +230,15 @@ actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(TerminalPasteAct // Don't apply to Mac since cmd+v works mac: { primary: null } }, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Paste into Active Terminal', category); +actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SelectAllTerminalAction, SelectAllTerminalAction.ID, SelectAllTerminalAction.LABEL, { + // Don't use ctrl+a by default as that would override the common go to start + // of prompt shell binding + primary: null, + // Technically this doesn't need to be here as it will fall back to this + // behavior anyway when handed to xterm.js, having this handled by VS Code + // makes it easier for users to see how it works though. + mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_A } +}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Select All', category); actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(RunSelectedTextInTerminalAction, RunSelectedTextInTerminalAction.ID, RunSelectedTextInTerminalAction.LABEL), 'Terminal: Run Selected Text In Active Terminal', category); actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(RunActiveFileInTerminalAction, RunActiveFileInTerminalAction.ID, RunActiveFileInTerminalAction.LABEL), 'Terminal: Run Active File In Active Terminal', category); actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleTerminalAction, ToggleTerminalAction.ID, ToggleTerminalAction.LABEL, { diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts index 3b62f9642edb8..62780aee350d1 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts @@ -93,6 +93,27 @@ export class CopyTerminalSelectionAction extends Action { } } +export class SelectAllTerminalAction extends Action { + + public static ID = 'workbench.action.terminal.selectAll'; + public static LABEL = nls.localize('workbench.action.terminal.selectAll', "Select All"); + + constructor( + id: string, label: string, + @ITerminalService private terminalService: ITerminalService + ) { + super(id, label); + } + + public run(event?: any): TPromise { + let terminalInstance = this.terminalService.getActiveInstance(); + if (terminalInstance) { + terminalInstance.selectAll(); + } + return TPromise.as(void 0); + } +} + export class CreateNewTerminalAction extends Action { public static ID = 'workbench.action.terminal.new'; diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index 1db0be29dd7c7..919dd7dbdff23 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -337,7 +337,11 @@ export class TerminalInstance implements ITerminalInstance { } public clearSelection(): void { - window.getSelection().empty(); + this._xterm.clearSelection(); + } + + public selectAll(): void { + this._xterm.selectAll(); } public dispose(): void { From 0fe479a0f833e5fa272f14bf7dbfcd03f97e9cbc Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 9 Jun 2017 12:10:44 -0700 Subject: [PATCH 4/8] Fix cmd+a keybinding on mac --- .../parts/terminal/electron-browser/terminal.contribution.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts index 09af3cb19c61d..84dc99b921274 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts @@ -210,9 +210,7 @@ let actionRegistry = Registry.as(ActionExtensions.Work actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(KillTerminalAction, KillTerminalAction.ID, KillTerminalAction.LABEL), 'Terminal: Kill the Active Terminal Instance', category); actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(CopyTerminalSelectionAction, CopyTerminalSelectionAction.ID, CopyTerminalSelectionAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_C, - linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_C }, - // Don't apply to Mac since cmd+c works - mac: { primary: null } + linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_C } }, ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, KEYBINDING_CONTEXT_TERMINAL_FOCUS)), 'Terminal: Copy Selection', category); actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(CreateNewTerminalAction, CreateNewTerminalAction.ID, CreateNewTerminalAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_BACKTICK, From a32c0803778cc346e9424567d38a3bd75ee10315 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 9 Jun 2017 12:34:57 -0700 Subject: [PATCH 5/8] Uplevel xterm.js Brings in fix for link duplication --- npm-shrinkwrap.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 91bff39ee52ae..58d2fcc6cde18 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -442,7 +442,7 @@ "xterm": { "version": "2.7.0", "from": "Tyriar/xterm.js#vscode-release/1.14-beta", - "resolved": "git+https://github.com/Tyriar/xterm.js.git#2c61d9c26c0265b8a4ce1542d25dd1258c3e4f5b" + "resolved": "git+https://github.com/Tyriar/xterm.js.git#e6130919622e238221ee9c8806cca8f084cfec2c" }, "yauzl": { "version": "2.3.1", From 979923ad4dc72f99fbef07113b5fab7b34801903 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 8 Jun 2017 14:02:56 -0700 Subject: [PATCH 6/8] Remove terminal selection colors --- .../parts/terminal/electron-browser/terminalPanel.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts index 51ddb07c92b88..7b7869bbe2e40 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts @@ -243,13 +243,8 @@ export class TerminalPanel extends Panel { ansiColorIdentifiers.forEach((colorId: ColorIdentifier, index: number) => { if (colorId) { // should not happen, all indices should have a color defined. let color = theme.getColor(colorId); - let rgba = color.transparent(0.996); css += `.monaco-workbench .panel.integrated-terminal .xterm .xterm-color-${index} { color: ${color}; }` + - `.monaco-workbench .panel.integrated-terminal .xterm .xterm-color-${index}::selection,` + - `.monaco-workbench .panel.integrated-terminal .xterm .xterm-color-${index} *::selection { background-color: ${rgba}; }` + - `.monaco-workbench .panel.integrated-terminal .xterm .xterm-bg-color-${index} { background-color: ${color}; }` + - `.monaco-workbench .panel.integrated-terminal .xterm .xterm-bg-color-${index}::selection,` + - `.monaco-workbench .panel.integrated-terminal .xterm .xterm-bg-color-${index} *::selection { color: ${color}; }`; + `.monaco-workbench .panel.integrated-terminal .xterm .xterm-bg-color-${index} { background-color: ${color}; }`; } }); const bgColor = theme.getColor(TERMINAL_BACKGROUND_COLOR); From dd7277720b217a46eb6b9e21e3b9bbfd48f1bb7e Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 9 Jun 2017 14:05:57 -0700 Subject: [PATCH 7/8] Uplevel xterm.js --- npm-shrinkwrap.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 58d2fcc6cde18..01a089f82644a 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -441,8 +441,8 @@ }, "xterm": { "version": "2.7.0", - "from": "Tyriar/xterm.js#vscode-release/1.14-beta", - "resolved": "git+https://github.com/Tyriar/xterm.js.git#e6130919622e238221ee9c8806cca8f084cfec2c" + "from": "Tyriar/xterm.js#vscode-release/1.14", + "resolved": "git+https://github.com/Tyriar/xterm.js.git#1d7007669dec1f60e5878aa102a36473d8cbd97f" }, "yauzl": { "version": "2.3.1", diff --git a/package.json b/package.json index 588c630f9af34..09d83d51cb262 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "vscode-ripgrep": "0.0.12", "vscode-textmate": "^3.1.5", "winreg": "1.2.0", - "xterm": "Tyriar/xterm.js#vscode-release/1.14-beta", + "xterm": "Tyriar/xterm.js#vscode-release/1.14", "yauzl": "2.3.1" }, "devDependencies": { From dea0e91074fea2f421120429d51bb363211827e5 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 9 Jun 2017 16:11:02 -0700 Subject: [PATCH 8/8] Use selection.background for the terminal The new selection model in xterm.js doesn't allow inverting colors right now so piggyback on selection.background. Ideally the terminal would have its own selection key since it has a terminal.background, but this is hopefully just temporary until selection color inverting is done upstream. --- src/vs/platform/theme/common/colorRegistry.ts | 2 +- .../terminal/electron-browser/media/xterm.css | 19 +------------------ .../electron-browser/terminalPanel.ts | 8 +++++++- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/vs/platform/theme/common/colorRegistry.ts b/src/vs/platform/theme/common/colorRegistry.ts index d790e964b0cf8..2cd9b78d5ec6c 100644 --- a/src/vs/platform/theme/common/colorRegistry.ts +++ b/src/vs/platform/theme/common/colorRegistry.ts @@ -137,7 +137,7 @@ export const focusBorder = registerColor('focusBorder', { dark: Color.fromHex('# export const contrastBorder = registerColor('contrastBorder', { light: null, dark: null, hc: '#6FC3DF' }, nls.localize('contrastBorder', "An extra border around elements to separate them from others for greater contrast.")); export const activeContrastBorder = registerColor('contrastActiveBorder', { light: null, dark: null, hc: focusBorder }, nls.localize('activeContrastBorder', "An extra border around active elements to separate them from others for greater contrast.")); -export const selectionBackground = registerColor('selection.background', { light: null, dark: null, hc: null }, nls.localize('selectionBackground', "The background color of text selections in the workbench (e.g. for input fields or text areas). Note that this does not apply to selections within the editor and the terminal.")); +export const selectionBackground = registerColor('selection.background', { light: null, dark: null, hc: null }, nls.localize('selectionBackground', "The background color of text selections in the workbench (e.g. for input fields or text areas). Note that this does not apply to selections within the editor.")); // ------ text colors diff --git a/src/vs/workbench/parts/terminal/electron-browser/media/xterm.css b/src/vs/workbench/parts/terminal/electron-browser/media/xterm.css index e30500606de78..fe96994dcc95e 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/media/xterm.css +++ b/src/vs/workbench/parts/terminal/electron-browser/media/xterm.css @@ -140,7 +140,7 @@ .monaco-workbench .panel.integrated-terminal .xterm .xterm-selection div { position: absolute; - background-color: #555; + opacity: 0.5; } .monaco-workbench .panel.integrated-terminal .xterm .xterm-bold { @@ -174,23 +174,6 @@ display: block; } -/* Base selection colors */ - -.monaco-workbench .panel.integrated-terminal .xterm ::selection { - color: #FFF; - background-color: rgba(51, 51, 51, 0.996); -} - -.vs-dark .monaco-workbench .panel.integrated-terminal .xterm ::selection { - color: #1e1e1e; - background-color: rgba(204, 204, 204, 0.996); -} - -.hc-black .monaco-workbench .panel.integrated-terminal .xterm ::selection { - color: #000; - background-color: rgba(255, 255, 255, 0.996); -} - /* Terminal colors 16-255 */ .monaco-workbench .panel.integrated-terminal .xterm .xterm-color-16 { diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts index 1a7238730c130..dc7558d33e91c 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts @@ -16,7 +16,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITerminalService, ITerminalFont, TERMINAL_PANEL_ID } from 'vs/workbench/parts/terminal/common/terminal'; import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService'; import { ansiColorIdentifiers, TERMINAL_BACKGROUND_COLOR, TERMINAL_FOREGROUND_COLOR } from './terminalColorRegistry'; -import { ColorIdentifier } from 'vs/platform/theme/common/colorRegistry'; +import { ColorIdentifier, selectionBackground } from 'vs/platform/theme/common/colorRegistry'; import { KillTerminalAction, CreateNewTerminalAction, SwitchTerminalInstanceAction, SwitchTerminalInstanceActionItem, CopyTerminalSelectionAction, TerminalPasteAction, ClearTerminalAction } from 'vs/workbench/parts/terminal/electron-browser/terminalActions'; import { Panel } from 'vs/workbench/browser/panel'; import { StandardMouseEvent } from 'vs/base/browser/mouseEvent'; @@ -262,6 +262,12 @@ export class TerminalPanel extends Panel { `.monaco-workbench .panel.integrated-terminal .xterm.xterm-cursor-style-bar.focus.xterm-cursor-blink .terminal-cursor::before,` + `.monaco-workbench .panel.integrated-terminal .xterm.xterm-cursor-style-underline.focus.xterm-cursor-blink .terminal-cursor::before { background-color: ${fgColor}; }`; } + // Use selection.background as the terminal selection, this is temporary + // until proper color inverting is implemented to ensure contrast. + const selectionColor = theme.getColor(selectionBackground); + if (selectionColor) { + css += `.monaco-workbench .panel.integrated-terminal .xterm .xterm-selection div { background-color: ${selectionColor}; }`; + } this._themeStyleElement.innerHTML = css; }