提交 7df8d06a 编写于 作者: D Daniel Imms

Support terminal.selectionBackground theme key

Fixes #28397
上级 61cef0a6
......@@ -19,19 +19,13 @@ export const TERMINAL_FOREGROUND_COLOR = registerColor('terminal.foreground', {
dark: '#CCCCCC',
hc: '#FFFFFF'
}, nls.localize('terminal.foreground', 'The foreground color of the terminal.'));
export const TERMINAL_CURSOR_FOREGROUND_COLOR = registerColor('terminalCursor.foreground', {
light: '#333333',
dark: '#CCCCCC',
hc: '#FFFFFF'
}, nls.localize('terminalCursor.foreground', 'The foreground color of the terminal cursor.'));
export const TERMINAL_CURSOR_FOREGROUND_COLOR = registerColor('terminalCursor.foreground', null, nls.localize('terminalCursor.foreground', 'The foreground color of the terminal cursor.'));
export const TERMINAL_CURSOR_BACKGROUND_COLOR = registerColor('terminalCursor.background', null, nls.localize('terminalCursor.background', 'The background color of the terminal cursor. Allows customizing the color of a character overlapped by a block cursor.'));
// TODO: Reinstate, see #28397
// export const TERMINAL_SELECTION_BACKGROUND_COLOR = registerColor('terminal.selectionBackground', {
// light: '#000',
// dark: '#FFF',
// hc: '#FFF'
// }, nls.localize('terminal.selectionBackground', 'The selection background color of the terminal.'));
export const TERMINAL_SELECTION_BACKGROUND_COLOR = registerColor('terminal.selectionBackground', {
light: '#00000080',
dark: '#FFFFFF80',
hc: '#FFF'
}, nls.localize('terminal.selectionBackground', 'The selection background color of the terminal.'));
const ansiColorMap = {
'terminal.ansiBlack': {
......
......@@ -31,12 +31,13 @@ import { TerminalConfigHelper } from 'vs/workbench/parts/terminal/electron-brows
import { TerminalLinkHandler } from 'vs/workbench/parts/terminal/electron-browser/terminalLinkHandler';
import { TerminalWidgetManager } from 'vs/workbench/parts/terminal/browser/terminalWidgetManager';
import { registerThemingParticipant, ITheme, ICssStyleCollector, IThemeService } from 'vs/platform/theme/common/themeService';
import { scrollbarSliderBackground, scrollbarSliderHoverBackground, scrollbarSliderActiveBackground, editorBackground } from 'vs/platform/theme/common/colorRegistry';
import { scrollbarSliderBackground, scrollbarSliderHoverBackground, scrollbarSliderActiveBackground } from 'vs/platform/theme/common/colorRegistry';
import { TPromise } from 'vs/base/common/winjs.base';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
import pkg from 'vs/platform/node/package';
import { ansiColorIdentifiers, TERMINAL_BACKGROUND_COLOR, TERMINAL_FOREGROUND_COLOR, TERMINAL_CURSOR_FOREGROUND_COLOR, TERMINAL_CURSOR_BACKGROUND_COLOR } from 'vs/workbench/parts/terminal/electron-browser/terminalColorRegistry';
import { ansiColorIdentifiers, TERMINAL_BACKGROUND_COLOR, TERMINAL_FOREGROUND_COLOR, TERMINAL_CURSOR_FOREGROUND_COLOR, TERMINAL_CURSOR_BACKGROUND_COLOR, TERMINAL_SELECTION_BACKGROUND_COLOR } from 'vs/workbench/parts/terminal/electron-browser/terminalColorRegistry';
import { PANEL_BACKGROUND } from 'vs/workbench/common/theme';
/** The amount of time to consider terminal errors to be related to the launch */
const LAUNCHING_DURATION = 500;
......@@ -950,19 +951,17 @@ export class TerminalInstance implements ITerminalInstance {
}
const foregroundColor = theme.getColor(TERMINAL_FOREGROUND_COLOR);
let backgroundColor = theme.getColor(TERMINAL_BACKGROUND_COLOR);
if (!backgroundColor) {
// Background color is optional, so fall back to editor background color
backgroundColor = theme.getColor(editorBackground);
}
const cursorColor = theme.getColor(TERMINAL_CURSOR_FOREGROUND_COLOR);
const cursorAccentColor = theme.getColor(TERMINAL_CURSOR_BACKGROUND_COLOR);
const backgroundColor = theme.getColor(TERMINAL_BACKGROUND_COLOR) || theme.getColor(PANEL_BACKGROUND);
const cursorColor = theme.getColor(TERMINAL_CURSOR_FOREGROUND_COLOR) || foregroundColor;
const cursorAccentColor = theme.getColor(TERMINAL_CURSOR_BACKGROUND_COLOR) || backgroundColor;
const selectionColor = theme.getColor(TERMINAL_SELECTION_BACKGROUND_COLOR);
return {
background: backgroundColor ? backgroundColor.toString() : null,
foreground: foregroundColor ? foregroundColor.toString() : null,
cursor: cursorColor ? cursorColor.toString() : null,
cursorAccent: cursorAccentColor ? cursorAccentColor.toString() : null,
selection: selectionColor ? selectionColor.toString() : null,
black: theme.getColor(ansiColorIdentifiers[0]).toString(),
red: theme.getColor(ansiColorIdentifiers[1]).toString(),
green: theme.getColor(ansiColorIdentifiers[2]).toString(),
......
......@@ -18,9 +18,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 { TerminalFindWidget } from './terminalFindWidget';
import { ansiColorIdentifiers, TERMINAL_BACKGROUND_COLOR, TERMINAL_FOREGROUND_COLOR, TERMINAL_CURSOR_FOREGROUND_COLOR, TERMINAL_CURSOR_BACKGROUND_COLOR } from './terminalColorRegistry';
import { ColorIdentifier, editorHoverBackground, editorHoverBorder, editorForeground } from 'vs/platform/theme/common/colorRegistry';
import { PANEL_BACKGROUND } from 'vs/workbench/common/theme';
import { editorHoverBackground, editorHoverBorder, editorForeground } from 'vs/platform/theme/common/colorRegistry';
import { KillTerminalAction, CreateNewTerminalAction, SwitchTerminalInstanceAction, SwitchTerminalInstanceActionItem, CopyTerminalSelectionAction, TerminalPasteAction, ClearTerminalAction, SelectAllTerminalAction } from 'vs/workbench/parts/terminal/electron-browser/terminalActions';
import { Panel } from 'vs/workbench/browser/panel';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
......@@ -273,38 +271,6 @@ export class TerminalPanel extends Panel {
}
let css = '';
ansiColorIdentifiers.forEach((colorId: ColorIdentifier, index: number) => {
if (colorId) { // should not happen, all indices should have a color defined.
let color = theme.getColor(colorId);
css += `.monaco-workbench .panel.integrated-terminal .xterm .xterm-color-${index} { color: ${color}; }` +
`.monaco-workbench .panel.integrated-terminal .xterm .xterm-bg-color-${index} { background-color: ${color}; }`;
}
});
const bgColor = theme.getColor(TERMINAL_BACKGROUND_COLOR);
if (bgColor) {
css += `.monaco-workbench .panel.integrated-terminal .terminal-outer-container { background-color: ${bgColor}; }`;
}
const fgColor = theme.getColor(TERMINAL_FOREGROUND_COLOR);
if (fgColor) {
css += `.monaco-workbench .panel.integrated-terminal .xterm { color: ${fgColor}; }`;
}
const cursorFgColor = theme.getColor(TERMINAL_CURSOR_FOREGROUND_COLOR) || fgColor;
if (cursorFgColor) {
css += `.monaco-workbench .panel.integrated-terminal .xterm:not(.xterm-cursor-style-underline):not(.xterm-cursor-style-bar).focus .terminal-cursor,` +
`.monaco-workbench .panel.integrated-terminal .xterm:not(.xterm-cursor-style-underline):not(.xterm-cursor-style-bar):focus .terminal-cursor { background-color: ${cursorFgColor} }` +
`.monaco-workbench .panel.integrated-terminal .xterm:not(.focus):not(:focus) .terminal-cursor { outline-color: ${cursorFgColor}; }` +
`.monaco-workbench .panel.integrated-terminal .xterm.xterm-cursor-style-bar .terminal-cursor::before,` +
`.monaco-workbench .panel.integrated-terminal .xterm.xterm-cursor-style-underline .terminal-cursor::before { background-color: ${cursorFgColor}; }` +
`.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: ${cursorFgColor}; }`;
}
const cursorBgColor = theme.getColor(TERMINAL_CURSOR_BACKGROUND_COLOR) || bgColor || theme.getColor(PANEL_BACKGROUND);
if (cursorBgColor) {
css += `.monaco-workbench .panel.integrated-terminal .xterm:not(.xterm-cursor-style-underline):not(.xterm-cursor-style-bar).focus .terminal-cursor,` +
`.monaco-workbench .panel.integrated-terminal .xterm:not(.xterm-cursor-style-underline):not(.xterm-cursor-style-bar):focus .terminal-cursor { color: ${cursorBgColor} }`;
}
// TODO: Reinstate, see #28397
// const selectionColor = theme.getColor(TERMINAL_SELECTION_BACKGROUND_COLOR);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册