提交 fa05586f 编写于 作者: M Martin Aeschlimann

[theme] remove ITheme.selector

上级 6f7fb600
......@@ -24,7 +24,6 @@ const themingRegistry = Registry.as<IThemingRegistry>(ThemingExtensions.ThemingC
class StandaloneTheme implements IStandaloneTheme {
id: string;
selector: string;
private rules: ITokenThemeRule[];
base: string;
private colors: { [colorId: string]: Color };
......@@ -34,10 +33,8 @@ class StandaloneTheme implements IStandaloneTheme {
constructor(base: string, name: string, colors: IColors, rules: ITokenThemeRule[]) {
if (name.length > 0) {
this.id = base + ' ' + name;
this.selector = base + '.' + name;
} else {
this.id = base;
this.selector = base;
}
this.base = base;
this.rules = rules;
......
......@@ -134,14 +134,14 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay {
registerThemingParticipant((theme, collector) => {
let lineHighlight = theme.getColor(editorLineHighlight);
if (lineHighlight) {
collector.addRule(`.monaco-editor.${theme.selector} .view-overlays .current-line { background-color: ${lineHighlight}; }`);
collector.addRule(`.monaco-editor .view-overlays .current-line { background-color: ${lineHighlight}; }`);
}
if (!lineHighlight || lineHighlight.isTransparent() || theme.defines(editorLineHighlightBorder)) {
let lineHighlightBorder = theme.getColor(editorLineHighlightBorder);
if (lineHighlightBorder) {
collector.addRule(`.monaco-editor.${theme.selector} .view-overlays .current-line { border: 2px solid ${lineHighlightBorder}; }`);
collector.addRule(`.monaco-editor .view-overlays .current-line { border: 2px solid ${lineHighlightBorder}; }`);
if (theme.type === 'hc') {
collector.addRule(`.monaco-editor.${theme.selector} .view-overlays .current-line { border-width: 1px; }`);
collector.addRule(`.monaco-editor .view-overlays .current-line { border-width: 1px; }`);
}
}
}
......
......@@ -110,14 +110,14 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay {
registerThemingParticipant((theme, collector) => {
let lineHighlight = theme.getColor(editorLineHighlight);
if (lineHighlight) {
collector.addRule(`.monaco-editor.${theme.selector} .margin-view-overlays .current-line-margin { background-color: ${lineHighlight}; border: none; }`);
collector.addRule(`.monaco-editor .margin-view-overlays .current-line-margin { background-color: ${lineHighlight}; border: none; }`);
} else {
let lineHighlightBorder = theme.getColor(editorLineHighlightBorder);
if (lineHighlightBorder) {
collector.addRule(`.monaco-editor.${theme.selector} .margin-view-overlays .current-line-margin { border: 2px solid ${lineHighlightBorder}; }`);
collector.addRule(`.monaco-editor .margin-view-overlays .current-line-margin { border: 2px solid ${lineHighlightBorder}; }`);
}
if (theme.type === 'hc') {
collector.addRule(`.monaco-editor.${theme.selector} .margin-view-overlays .current-line-margin { border-width: 1px; }`);
collector.addRule(`.monaco-editor .margin-view-overlays .current-line-margin { border-width: 1px; }`);
}
}
});
......@@ -118,6 +118,6 @@ export class IndentGuidesOverlay extends DynamicViewOverlay {
registerThemingParticipant((theme, collector) => {
let editorGuideColor = theme.getColor(editorIndentGuides);
if (editorGuideColor) {
collector.addRule(`.monaco-editor.${theme.selector} .lines-content .cigr { background-color: ${editorGuideColor}; }`);
collector.addRule(`.monaco-editor .lines-content .cigr { background-color: ${editorGuideColor}; }`);
}
});
......@@ -163,6 +163,6 @@ export class LineNumbersOverlay extends DynamicViewOverlay {
registerThemingParticipant((theme, collector) => {
let lineNumbers = theme.getColor(editorLineNumbers);
if (lineNumbers) {
collector.addRule(`.monaco-editor.${theme.selector} .line-numbers { color: ${lineNumbers}; }`);
collector.addRule(`.monaco-editor .line-numbers { color: ${lineNumbers}; }`);
}
});
\ No newline at end of file
......@@ -397,11 +397,11 @@ export class SelectionsOverlay extends DynamicViewOverlay {
registerThemingParticipant((theme, collector) => {
let editorSelectionColor = theme.getColor(editorSelection);
if (editorSelectionColor) {
collector.addRule(`.monaco-editor.${theme.selector} .focused .selected-text { background-color: ${editorSelectionColor}; }`);
collector.addRule(`.monaco-editor .focused .selected-text { background-color: ${editorSelectionColor}; }`);
}
let editorInactiveSelectionColor = theme.getColor(editorInactiveSelection);
if (editorInactiveSelectionColor) {
collector.addRule(`.monaco-editor.${theme.selector} .selected-text { background-color: ${editorInactiveSelectionColor}; }`);
collector.addRule(`.monaco-editor .selected-text { background-color: ${editorInactiveSelectionColor}; }`);
}
// IE/Edge specific rules
let outline = theme.getColor(activeContrastBorder);
......
......@@ -345,9 +345,9 @@ registerThemingParticipant((theme, collector) => {
let caret = theme.getColor(editorCursor);
if (caret) {
let oppositeCaret = caret.opposite();
collector.addRule(`.monaco-editor.${theme.selector} .cursor { background-color: ${caret}; border-color: ${caret}; color: ${oppositeCaret}; }`);
collector.addRule(`.monaco-editor .cursor { background-color: ${caret}; border-color: ${caret}; color: ${oppositeCaret}; }`);
if (theme.type === 'hc') {
collector.addRule(`.monaco-editor.${theme.selector} .cursors-layer.has-selection .cursor { border-left: 1px solid ${oppositeCaret}; border-right: 1px solid ${oppositeCaret}; }`);
collector.addRule(`.monaco-editor .cursors-layer.has-selection .cursor { border-left: 1px solid ${oppositeCaret}; border-right: 1px solid ${oppositeCaret}; }`);
}
}
......
......@@ -234,16 +234,16 @@ CommonEditorRegistry.registerEditorCommand(new AccessibilityHelpCommand({
registerThemingParticipant((theme, collector) => {
let widgetBackground = theme.getColor(editorWidgetBackground);
if (widgetBackground) {
collector.addRule(`.monaco-editor.${theme.selector} .accessibilityHelpWidget { background-color: ${widgetBackground}; }`);
collector.addRule(`.monaco-editor .accessibilityHelpWidget { background-color: ${widgetBackground}; }`);
}
let widgetShadowColor = theme.getColor(widgetShadow);
if (widgetShadowColor) {
collector.addRule(`.monaco-editor.${theme.selector} .accessibilityHelpWidget { box-shadow: 0 2px 8px ${widgetShadowColor}; }`);
collector.addRule(`.monaco-editor .accessibilityHelpWidget { box-shadow: 0 2px 8px ${widgetShadowColor}; }`);
}
let hcBorder = theme.getColor(contrastBorder);
if (hcBorder) {
collector.addRule(`.monaco-editor.${theme.selector} .accessibilityHelpWidget { border: 2px solid ${hcBorder}; }`);
collector.addRule(`.monaco-editor .accessibilityHelpWidget { border: 2px solid ${hcBorder}; }`);
}
});
......@@ -633,6 +633,6 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
registerThemingParticipant((theme, collector) => {
let activeLinkForeground = theme.getColor(editorActiveLinkForeground);
if (activeLinkForeground) {
collector.addRule(`.monaco-editor.${theme.selector} .goto-definition-link { color: ${activeLinkForeground} !important; }`);
collector.addRule(`.monaco-editor .goto-definition-link { color: ${activeLinkForeground} !important; }`);
}
});
......@@ -176,15 +176,15 @@ class ShowHoverAction extends EditorAction {
registerThemingParticipant((theme, collector) => {
let editorHoverHighlightColor = theme.getColor(editorHoverHighlight);
if (editorHoverHighlightColor) {
collector.addRule(`.monaco-editor.${theme.selector} .hoverHighlight { background-color: ${editorHoverHighlightColor}; }`);
collector.addRule(`.monaco-editor .hoverHighlight { background-color: ${editorHoverHighlightColor}; }`);
}
let hoverBackground = theme.getColor(editorHoverBackground);
if (hoverBackground) {
collector.addRule(`.monaco-editor.${theme.selector} .monaco-editor-hover { background-color: ${hoverBackground}; }`);
collector.addRule(`.monaco-editor .monaco-editor-hover { background-color: ${hoverBackground}; }`);
}
let hoverBorder = theme.getColor(editorHoverBorder);
if (hoverBorder) {
collector.addRule(`.monaco-editor.${theme.selector} .monaco-editor-hover { border: 1px solid ${hoverBorder}; }`);
collector.addRule(`.monaco-editor.${theme.selector} .monaco-editor-hover .hover-row:not(:first-child):not(:empty) { border-top: 1px solid ${hoverBorder.transparent(0.5)}; }`);
collector.addRule(`.monaco-editor .monaco-editor-hover { border: 1px solid ${hoverBorder}; }`);
collector.addRule(`.monaco-editor .monaco-editor-hover .hover-row:not(:first-child):not(:empty) { border-top: 1px solid ${hoverBorder.transparent(0.5)}; }`);
}
});
......@@ -348,6 +348,6 @@ class OpenLinkAction extends EditorAction {
registerThemingParticipant((theme, collector) => {
let activeLinkForeground = theme.getColor(editorActiveLinkForeground);
if (activeLinkForeground) {
collector.addRule(`.monaco-editor.${theme.selector} .detected-link-active { color: ${activeLinkForeground} !important; }`);
collector.addRule(`.monaco-editor .detected-link-active { color: ${activeLinkForeground} !important; }`);
}
});
\ No newline at end of file
......@@ -951,10 +951,10 @@ export class SuggestWidget implements IContentWidget, IDelegate<ICompletionItem>
registerThemingParticipant((theme, collector) => {
let matchHighlight = theme.getColor(editorSuggestWidgetHighlightForeground);
if (matchHighlight) {
collector.addRule(`.monaco-editor.${theme.selector} .suggest-widget:not(.frozen) .monaco-highlighted-label .highlight { color: ${matchHighlight}; }`);
collector.addRule(`.monaco-editor .suggest-widget:not(.frozen) .monaco-highlighted-label .highlight { color: ${matchHighlight}; }`);
}
let foreground = theme.getColor(editorSuggestWidgetForeground);
if (foreground) {
collector.addRule(`.monaco-editor.${theme.selector} .suggest-widget { color: ${foreground}; }`);
collector.addRule(`.monaco-editor .suggest-widget { color: ${foreground}; }`);
}
});
......@@ -319,22 +319,22 @@ class WordHighlighterContribution implements editorCommon.IEditorContribution {
registerThemingParticipant((theme, collector) => {
let selectionHighlight = theme.getColor(editorSelectionHighlight);
if (selectionHighlight) {
collector.addRule(`.monaco-editor.${theme.selector} .focused .selectionHighlight { background-color: ${selectionHighlight}; }`);
collector.addRule(`.monaco-editor.${theme.selector} .selectionHighlight { background-color: ${selectionHighlight.transparent(0.5)}; }`);
collector.addRule(`.monaco-editor. .focused .selectionHighlight { background-color: ${selectionHighlight}; }`);
collector.addRule(`.monaco-editor. .selectionHighlight { background-color: ${selectionHighlight.transparent(0.5)}; }`);
}
let wordHighlight = theme.getColor(editorWordHighlight);
if (wordHighlight) {
collector.addRule(`.monaco-editor.${theme.selector} .wordHighlight { background-color: ${wordHighlight}; }`);
collector.addRule(`.monaco-editor. .wordHighlight { background-color: ${wordHighlight}; }`);
}
let wordHighlightStrong = theme.getColor(editorWordHighlightStrong);
if (wordHighlightStrong) {
collector.addRule(`.monaco-editor.${theme.selector} .wordHighlightStrong { background-color: ${wordHighlightStrong}; }`);
collector.addRule(`.monaco-editor. .wordHighlightStrong { background-color: ${wordHighlightStrong}; }`);
}
let hcOutline = theme.getColor(activeContrastBorder);
if (hcOutline) {
collector.addRule(`.monaco-editor.${theme.selector} .selectionHighlight { border: 1px dotted ${hcOutline}; box-sizing: border-box; }`);
collector.addRule(`.monaco-editor.${theme.selector} .wordHighlight { border: 1px dashed ${hcOutline}; box-sizing: border-box; }`);
collector.addRule(`.monaco-editor.${theme.selector} .wordHighlightStrong { border: 1px dashed ${hcOutline}; box-sizing: border-box; }`);
collector.addRule(`.monaco-editor. .selectionHighlight { border: 1px dotted ${hcOutline}; box-sizing: border-box; }`);
collector.addRule(`.monaco-editor. .wordHighlight { border: 1px dashed ${hcOutline}; box-sizing: border-box; }`);
collector.addRule(`.monaco-editor. .wordHighlightStrong { border: 1px dashed ${hcOutline}; box-sizing: border-box; }`);
}
});
\ No newline at end of file
......@@ -20,7 +20,6 @@ export const HIGH_CONTRAST = 'hc';
export type ThemeType = 'light' | 'dark' | 'hc';
export interface ITheme {
readonly selector: string;
readonly type: ThemeType;
/**
......
......@@ -33,7 +33,6 @@ export class ColorThemeData implements IColorTheme {
label: string;
settingsId: string;
description?: string;
selector: string;
tokenColors?: ITokenColorizationRule[];
isLoaded: boolean;
path?: string;
......@@ -111,7 +110,7 @@ export class ColorThemeData implements IColorTheme {
id: this.id,
label: this.label,
settingsId: this.settingsId,
selector: this.selector,
selector: this.id.split(' ').join('.'), // to not break old clients
tokenColors: this.tokenColors,
extensionData: this.extensionData,
colorMap: colorMapData
......@@ -160,7 +159,6 @@ export function fromExtensionTheme(theme: IThemeExtensionPoint, normalizedAbsolu
themeData.id = `${baseTheme} ${themeSelector}`;
themeData.label = theme.label || Paths.basename(theme.path);
themeData.settingsId = theme.id || themeData.label;
themeData.selector = `${baseTheme}.${themeSelector}`;
themeData.description = theme.description;
themeData.path = normalizedAbsolutePath;
themeData.extensionData = extensionData;
......
......@@ -246,7 +246,6 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
let initialTheme = new ColorThemeData();
initialTheme.id = isLightTheme ? VS_LIGHT_THEME : VS_DARK_THEME;
initialTheme.label = '';
initialTheme.selector = isLightTheme ? VS_LIGHT_THEME : VS_DARK_THEME;
initialTheme.settingsId = null;
initialTheme.isLoaded = false;
initialTheme.tokenColors = [{ settings: {} }];
......
......@@ -50,7 +50,7 @@ import { IWindowsService, IWindowService } from 'vs/platform/windows/common/wind
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { RawTextSource, IRawTextSource } from 'vs/editor/common/model/textSource';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IThemeService, ITheme, IThemingParticipant } from 'vs/platform/theme/common/themeService';
import { IThemeService, ITheme, IThemingParticipant, ThemeType } from 'vs/platform/theme/common/themeService';
import { IDisposable } from 'vs/base/common/lifecycle';
import { Color } from 'vs/base/common/color';
import { isLinux } from 'vs/base/common/platform';
......@@ -999,8 +999,7 @@ export class TestWindowsService implements IWindowsService {
}
export class TestTheme implements ITheme {
selector: string;
type: 'light' | 'dark' | 'hc';
type: ThemeType;
getColor(color: string, useDefault?: boolean): Color {
throw new Error('Method not implemented.');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册