Skip to content

Commit

Permalink
Merge pull request #175647 from microsoft/tyriar/165169_2
Browse files Browse the repository at this point in the history
Remove 2 terminal theme participants
  • Loading branch information
Tyriar authored Feb 28, 2023
2 parents 6ef1ac8 + 4b98001 commit 4e73225
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 35 deletions.
4 changes: 4 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/media/terminal.css
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@
background-color: var(--vscode-scrollbarSlider-background) !important;
}

.monaco-workbench .integrated-terminal .hoverHighlight {
background-color: var(--vscode-terminal-hoverHighlightBackground);
}

.monaco-workbench .editor-instance .xterm-viewport,
.monaco-workbench .pane-body.integrated-terminal .xterm-viewport {
scrollbar-color: var(--vscode-scrollbarSlider-background) transparent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { ITerminalWidget } from 'vs/workbench/contrib/terminal/browser/widgets/w
import * as dom from 'vs/base/browser/dom';
import type { IViewportRange } from 'xterm';
import { IHoverTarget, IHoverService, IHoverAction } from 'vs/workbench/services/hover/browser/hover';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { editorHoverHighlight } from 'vs/platform/theme/common/colorRegistry';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { TerminalSettingId } from 'vs/platform/terminal/common/terminal';

Expand Down Expand Up @@ -131,13 +129,3 @@ class CellHoverTarget extends Widget implements IHoverTarget {
super.dispose();
}
}

registerThemingParticipant((theme, collector) => {
let editorHoverHighlightColor = theme.getColor(editorHoverHighlight);
if (editorHoverHighlightColor) {
if (editorHoverHighlightColor.isOpaque()) {
editorHoverHighlightColor = editorHoverHighlightColor.transparent(0.5);
}
collector.addRule(`.integrated-terminal .hoverHighlight { background-color: ${editorHoverHighlightColor}; }`);
}
});
35 changes: 13 additions & 22 deletions src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import * as dom from 'vs/base/browser/dom';
import { IAction, Separator } from 'vs/base/common/actions';
import { Color } from 'vs/base/common/color';
import { Emitter } from 'vs/base/common/event';
import { Disposable, dispose, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { localize } from 'vs/nls';
Expand All @@ -18,7 +17,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
import { CommandInvalidationReason, ICommandDetectionCapability, IMarkProperties, ITerminalCapabilityStore, TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
import { TerminalSettingId } from 'vs/platform/terminal/common/terminal';
import { IColorTheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ThemeIcon } from 'vs/base/common/themables';
import { terminalDecorationError, terminalDecorationIncomplete, terminalDecorationMark, terminalDecorationSuccess } from 'vs/workbench/contrib/terminal/browser/terminalIcons';
import { DecorationSelector, TerminalDecorationHoverManager, updateLayout } from 'vs/workbench/contrib/terminal/browser/xterm/decorationStyles';
Expand Down Expand Up @@ -158,12 +157,7 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
private _refreshStyles(refreshOverviewRulerColors?: boolean): void {
if (refreshOverviewRulerColors) {
for (const decoration of this._decorations.values()) {
let color = decoration.exitCode === undefined ? defaultColor : decoration.exitCode ? errorColor : successColor;
if (color && typeof color !== 'string') {
color = color.toString();
} else {
color = '';
}
const color = this._getDecorationCssColor(decoration)?.toString() ?? '';
if (decoration.decoration.options?.overviewRulerOptions) {
decoration.decoration.options.overviewRulerOptions.color = color;
} else if (decoration.decoration.options) {
Expand Down Expand Up @@ -264,12 +258,7 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
throw new Error(`cannot add a decoration for a command ${JSON.stringify(command)} with no marker`);
}
this._clearPlaceholder();
let color = command?.exitCode === undefined ? defaultColor : command.exitCode ? errorColor : successColor;
if (color && typeof color !== 'string') {
color = color.toString();
} else {
color = '';
}
const color = this._getDecorationCssColor(command)?.toString() ?? '';
const decoration = this._terminal.registerDecoration({
marker,
overviewRulerOptions: this._showOverviewRulerDecorations ? (beforeCommandExecution
Expand Down Expand Up @@ -475,12 +464,14 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
quickPick.ok = false;
quickPick.show();
}

private _getDecorationCssColor(decorationOrCommand?: IDisposableDecoration | ITerminalCommand): string | undefined {
let colorId: string;
if (decorationOrCommand?.exitCode === undefined) {
colorId = TERMINAL_COMMAND_DECORATION_DEFAULT_BACKGROUND_COLOR;
} else {
colorId = decorationOrCommand.exitCode ? TERMINAL_COMMAND_DECORATION_ERROR_BACKGROUND_COLOR : TERMINAL_COMMAND_DECORATION_SUCCESS_BACKGROUND_COLOR;
}
return this._themeService.getColorTheme().getColor(colorId)?.toString();
}
}
let successColor: string | Color | undefined;
let errorColor: string | Color | undefined;
let defaultColor: string | Color | undefined;
registerThemingParticipant((theme: IColorTheme) => {
successColor = theme.getColor(TERMINAL_COMMAND_DECORATION_SUCCESS_BACKGROUND_COLOR);
errorColor = theme.getColor(TERMINAL_COMMAND_DECORATION_ERROR_BACKGROUND_COLOR);
defaultColor = theme.getColor(TERMINAL_COMMAND_DECORATION_DEFAULT_BACKGROUND_COLOR);
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import * as nls from 'vs/nls';

import { registerColor, ColorIdentifier, ColorDefaults, editorFindMatch, editorFindMatchHighlight, overviewRulerFindMatchForeground, editorSelectionBackground, transparent } from 'vs/platform/theme/common/colorRegistry';
import { registerColor, ColorIdentifier, ColorDefaults, editorFindMatch, editorFindMatchHighlight, overviewRulerFindMatchForeground, editorSelectionBackground, transparent, editorHoverHighlight } from 'vs/platform/theme/common/colorRegistry';
import { EDITOR_DRAG_AND_DROP_BACKGROUND, PANEL_BORDER, TAB_ACTIVE_BORDER } from 'vs/workbench/common/theme';

/**
Expand Down Expand Up @@ -78,6 +78,12 @@ export const TERMINAL_FIND_MATCH_BACKGROUND_COLOR = registerColor('terminal.find
hcDark: null,
hcLight: '#0F4A85'
}, nls.localize('terminal.findMatchBackground', 'Color of the current search match in the terminal. The color must not be opaque so as not to hide underlying terminal content.'));
export const TERMINAL_HOVER_HIGHLIGHT_BACKGROUND_COLOR = registerColor('terminal.hoverHighlightBackground', {
dark: transparent(editorHoverHighlight, 0.5),
light: transparent(editorHoverHighlight, 0.5),
hcDark: transparent(editorHoverHighlight, 0.5),
hcLight: transparent(editorHoverHighlight, 0.5)
}, nls.localize('terminal.findMatchHighlightBorder', 'Border color of the other search matches in the terminal.'));
export const TERMINAL_FIND_MATCH_BORDER_COLOR = registerColor('terminal.findMatchBorder', {
dark: null,
light: null,
Expand Down

0 comments on commit 4e73225

Please sign in to comment.