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

[theming] place editor theming participants next to the css

上级 cfb44d55
......@@ -10,6 +10,8 @@ import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay';
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { RenderingContext } from 'vs/editor/common/view/renderingContext';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { editorLineHighlight, editorLineHighlightBorder } from 'vs/editor/common/view/editorColorRegistry';
export class CurrentLineHighlightOverlay extends DynamicViewOverlay {
private _context: ViewContext;
......@@ -127,3 +129,15 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay {
this._primaryCursorIsInEditableRange;
}
}
registerThemingParticipant((theme, collector) => {
let lineHighlight = theme.getColor(editorLineHighlight);
if (lineHighlight) {
collector.addRule(`.monaco-editor.${theme.selector} .view-overlays .current-line { background-color: ${lineHighlight}; border: none; }`);
} else {
let lineHighlightBorder = theme.getColor(editorLineHighlightBorder);
if (lineHighlightBorder) {
collector.addRule(`.monaco-editor.${theme.selector} .view-overlays .current-line { border: 2px solid ${lineHighlightBorder}; }`);
}
}
});
......@@ -10,6 +10,8 @@ import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay';
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { RenderingContext } from 'vs/editor/common/view/renderingContext';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { editorLineHighlight, editorLineHighlightBorder } from 'vs/editor/common/view/editorColorRegistry';
export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay {
private _context: ViewContext;
......@@ -103,3 +105,15 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay {
return (this._renderLineHighlight === 'gutter' || this._renderLineHighlight === 'all') && this._primaryCursorIsInEditableRange;
}
}
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; }`);
} else {
let lineHighlightBorder = theme.getColor(editorLineHighlightBorder);
if (lineHighlightBorder) {
collector.addRule(`.monaco-editor.${theme.selector} .margin-view-overlays .current-line-margin { border: 2px solid ${lineHighlightBorder}; }`);
}
}
});
......@@ -11,6 +11,9 @@ import { ViewContext } from 'vs/editor/common/view/viewContext';
import { RenderingContext } from 'vs/editor/common/view/renderingContext';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { editorBackground } from 'vs/platform/theme/common/colorRegistry';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
export class DecorationToRender {
_decorationToRenderBrand: void;
......@@ -205,4 +208,11 @@ export class GlyphMarginOverlay extends DedupOverlay {
}
return this._renderResult[lineIndex];
}
}
\ No newline at end of file
}
registerThemingParticipant((theme, collector) => {
let editorBackgroundColor = theme.getColor(editorBackground);
if (editorBackgroundColor) {
collector.addRule(`.monaco-editor.${theme.selector} .glyph-margin { background-color: ${editorBackgroundColor}; }`);
}
});
\ No newline at end of file
......@@ -10,6 +10,8 @@ import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay';
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { RenderingContext } from 'vs/editor/common/view/renderingContext';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { editorGuide } from 'vs/editor/common/view/editorColorRegistry';
export class IndentGuidesOverlay extends DynamicViewOverlay {
......@@ -111,3 +113,10 @@ export class IndentGuidesOverlay extends DynamicViewOverlay {
return this._renderResult[lineIndex];
}
}
registerThemingParticipant((theme, collector) => {
let editorGuideColor = theme.getColor(editorGuide);
if (editorGuideColor) {
collector.addRule(`.monaco-editor.${theme.selector} .lines-content .cigr { background-color: ${editorGuideColor}; }`);
}
});
......@@ -6,6 +6,9 @@
'use strict';
import 'vs/css!./selections';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { editorSelection, editorInactiveSelection } from 'vs/platform/theme/common/colorRegistry';
import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay';
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { HorizontalRange, LineVisibleRanges, RenderingContext } from 'vs/editor/common/view/renderingContext';
......@@ -396,3 +399,14 @@ export class SelectionsOverlay extends DynamicViewOverlay {
return this._renderResult[lineIndex];
}
}
registerThemingParticipant((theme, collector) => {
let editorSelectionColor = theme.getColor(editorSelection);
if (editorSelectionColor) {
collector.addRule(`.monaco-editor.${theme.selector} .focused .selected-text { background-color: ${editorSelectionColor}; }`);
}
let editorInactiveSelectionColor = theme.getColor(editorInactiveSelection);
if (editorInactiveSelectionColor) {
collector.addRule(`.monaco-editor.${theme.selector} .selected-text { background-color: ${editorInactiveSelectionColor}; }`);
}
});
\ No newline at end of file
......@@ -16,6 +16,8 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
import { TimeoutTimer } from 'vs/base/common/async';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { editorCursor } from 'vs/editor/common/view/editorColorRegistry';
export class ViewCursors extends ViewPart {
......@@ -326,3 +328,11 @@ export class ViewCursors extends ViewPart {
return this._renderData;
}
}
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}; }`);
}
});
\ No newline at end of file
......@@ -5,6 +5,7 @@
'use strict';
import 'vs/css!./media/editor';
import 'vs/editor/common/view/editorColorRegistry'; // initialze editor theming partcicpants
import 'vs/css!./media/tokens';
import { onUnexpectedError } from 'vs/base/common/errors';
import { TPromise } from 'vs/base/common/winjs.base';
......
......@@ -22,12 +22,8 @@ function registerColor(id: string, defaults: colorRegistry.ColorDefaults, descri
return colorReg.registerColor(id, defaults, description);
}
export const editorHoverHighlight = registerColor('editorHoverHighlight', { light: '#ADD6FF26', dark: '#264f7840', hc: '#ADD6FF26' }, nls.localize('hoverHighlight', 'Background color of the editor hover'));
export const editorActiveLinkForeground = registerColor('editorActiveLinkForeground', { dark: '#4E94CE', light: Color.black, hc: Color.cyan }, nls.localize('activeLinkForeground', 'Color of active links'));
export const editorLinkForeground = registerColor('editorLinkForeground', { dark: null, light: null, hc: null }, nls.localize('linkForeground', 'Color of links'));
export const referencesFindMatchHighlight = registerColor('referencesFindMatchHighlight', { dark: '#ea5c004d', light: '#ea5c004d', hc: null }, nls.localize('referencesFindMatchHighlight', 'References view match highlight color'));
export const referencesReferenceHighlight = registerColor('referencesReferenceHighlight', { dark: '#ff8f0099', light: '#f5d802de', hc: null }, nls.localize('referencesReferenceHighlight', 'References range highlight color'));
export const editorLineHighlight = registerColor('editorLineHighlight', { dark: null, light: null, hc: null }, nls.localize('lineHighlight', 'Editor line highlight color'));
export const editorLineHighlightBorder = registerColor('editorLineHighlightBorderCox', { dark: '#282828', light: '#eeeeee', hc: '#f38518' }, nls.localize('lineHighlightBorderBox', 'Editor line highlight border box color'));
export const editorRangeHighlight = registerColor('editorRangeHighlight', { dark: '#ffffff0b', light: '#fdff0033', hc: null }, nls.localize('rangeHighlight', 'Background color of range highlighted, like by Quick open and Find features'));
export const editorCursor = registerColor('editorCursor', { dark: '#AEAFAD', light: Color.black, hc: Color.white }, nls.localize('caret', 'Editor cursor color'));
export const editorInvisibles = registerColor('editorInvisibles', { dark: '#e3e4e229', light: '#33333333', hc: '#e3e4e229' }, nls.localize('invisibles', 'Editor invisibles color'));
......@@ -39,35 +35,9 @@ function applyEditorStyles(theme: ITheme, collector: ICssStyleCollector) {
let background = theme.getColor(colorRegistry.editorBackground);
if (background) {
addBackgroundColorRule(theme, '.monaco-editor-background', background, collector);
addBackgroundColorRule(theme, '.glyph-margin', background, collector);
collector.addRule(`.${theme.selector} .monaco-workbench .monaco-editor-background { background-color: ${background}; }`);
}
addBackgroundColorRule(theme, '.hoverHighlight', theme.getColor(editorHoverHighlight), collector);
let activeLinkForeground = theme.getColor(editorActiveLinkForeground);
if (activeLinkForeground) {
collector.addRule(`.monaco-editor.${theme.selector} .detected-link-active { color: ${activeLinkForeground} !important; }`);
collector.addRule(`.monaco-editor.${theme.selector} .goto-definition-link { color: ${activeLinkForeground} !important; }`);
}
let linkForeground = theme.getColor(editorLinkForeground);
if (linkForeground) {
collector.addRule(`.monaco-editor.${theme.selector} .detected-link { color: ${linkForeground} !important; }`);
}
let selection = theme.getColor(colorRegistry.editorSelection);
if (selection) {
addBackgroundColorRule(theme, '.focused .selected-text', selection, collector);
}
let inactiveSelection = theme.getColor(colorRegistry.editorInactiveSelection);
if (inactiveSelection) {
addBackgroundColorRule(theme, '.selected-text', inactiveSelection, collector);
}
addBackgroundColorRule(theme, '.reference-zone-widget .ref-tree .referenceMatch', theme.getColor(referencesFindMatchHighlight), collector);
addBackgroundColorRule(theme, '.reference-zone-widget .preview .reference-decoration', theme.getColor(referencesReferenceHighlight), collector);
let lineHighlight = theme.getColor(editorLineHighlight);
if (lineHighlight) {
collector.addRule(`.monaco-editor.${theme.selector} .view-overlays .current-line { background-color: ${lineHighlight}; border: none; }`);
......@@ -77,21 +47,10 @@ function applyEditorStyles(theme: ITheme, collector: ICssStyleCollector) {
}
addBackgroundColorRule(theme, '.rangeHighlight', theme.getColor(editorRangeHighlight), 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}; }`);
}
let invisibles = theme.getColor(editorInvisibles);
if (invisibles) {
collector.addRule(`.vs-whitespace { color: ${invisibles} !important; }`);
}
let color = theme.getColor(editorGuide);
if (color) {
collector.addRule(`.monaco-editor.${theme.selector} .lines-content .cigr { background: ${color}; }`);
}
}
function addBackgroundColorRule(theme: ITheme, selector: string, color: Color, collector: ICssStyleCollector): void {
......
......@@ -38,6 +38,10 @@ import * as corePosition from 'vs/editor/common/core/position';
import ModeContextKeys = editorCommon.ModeContextKeys;
import EditorContextKeys = editorCommon.EditorContextKeys;
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { editorActiveLinkForeground } from 'vs/platform/theme/common/colorRegistry';
export class DefinitionActionConfig {
constructor(
......@@ -624,3 +628,10 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
this.toUnhook = dispose(this.toUnhook);
}
}
registerThemingParticipant((theme, collector) => {
let activeLinkForeground = theme.getColor(editorActiveLinkForeground);
if (activeLinkForeground) {
collector.addRule(`.monaco-editor.${theme.selector} .goto-definition-link { color: ${activeLinkForeground} !important; }`);
}
});
\ No newline at end of file
......@@ -21,8 +21,13 @@ import { ModesContentHoverWidget } from './modesContentHover';
import { ModesGlyphHoverWidget } from './modesGlyphHover';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { ITheme, ICssStyleCollector, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { registerColor } from 'vs/platform/theme/common/colorRegistry';
import EditorContextKeys = editorCommon.EditorContextKeys;
export const editorHoverHighlight = registerColor('editorHoverHighlight', { light: '#ADD6FF26', dark: '#264f7840', hc: '#ADD6FF26' }, nls.localize('hoverHighlight', 'Background color of the editor hover'));
@editorContribution
export class ModesHoverController implements editorCommon.IEditorContribution {
......@@ -170,3 +175,10 @@ class ShowHoverAction extends EditorAction {
controller.showContentHover(range, true);
}
}
registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
let editorHoverHighlightColor = theme.getColor(editorHoverHighlight);
if (editorHoverHighlightColor) {
collector.addRule(`.monaco-editor.${theme.selector} .hoverHighlight { background-color: ${editorHoverHighlightColor}; }`);
}
});
......@@ -23,6 +23,8 @@ import { IEditorMouseEvent, ICodeEditor } from 'vs/editor/browser/editorBrowser'
import { getLinks, Link } from 'vs/editor/contrib/links/common/links';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { editorContribution } from 'vs/editor/browser/editorBrowserExtensions';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { editorLinkForeground, editorActiveLinkForeground } from 'vs/platform/theme/common/colorRegistry';
class LinkOccurence {
......@@ -341,3 +343,14 @@ 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; }`);
}
let linkForeground = theme.getColor(editorLinkForeground);
if (linkForeground) {
collector.addRule(`.monaco-editor.${theme.selector} .detected-link { color: ${linkForeground} !important; }`);
}
});
\ No newline at end of file
......@@ -37,6 +37,11 @@ import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeE
import { PeekViewWidget, IPeekViewService } from 'vs/editor/contrib/zoneWidget/browser/peekViewWidget';
import { FileReferences, OneReference, ReferencesModel } from './referencesModel';
import { ITextModelResolverService, ITextEditorModel } from 'vs/editor/common/services/resolverService';
import { registerColor } from 'vs/platform/theme/common/colorRegistry';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
export const referencesFindMatchHighlight = registerColor('referencesFindMatchHighlight', { dark: '#ea5c004d', light: '#ea5c004d', hc: null }, nls.localize('referencesFindMatchHighlight', 'References view match highlight color'));
export const referencesReferenceHighlight = registerColor('referencesReferenceHighlight', { dark: '#ff8f0099', light: '#f5d802de', hc: null }, nls.localize('referencesReferenceHighlight', 'References range highlight color'));
class DecorationsManager implements IDisposable {
......@@ -752,3 +757,14 @@ export class ReferenceWidget extends PeekViewWidget {
}, onUnexpectedError);
}
}
registerThemingParticipant((theme, collector) => {
let referencesFindMatchHighlightColor = theme.getColor(referencesFindMatchHighlight);
if (referencesFindMatchHighlightColor) {
collector.addRule(`.monaco-editor.${theme.selector} .reference-zone-widget .ref-tree .referenceMatch { background-color: ${referencesFindMatchHighlightColor}; }`);
}
let referencesReferenceHighlightColor = theme.getColor(referencesReferenceHighlight);
if (referencesReferenceHighlightColor) {
collector.addRule(`.monaco-editor.${theme.selector} .reference-zone-widget .preview .reference-decoration { background-color: ${referencesReferenceHighlightColor}; }`);
}
});
\ No newline at end of file
......@@ -145,6 +145,12 @@ export const editorFindMatchHighlight = registerColor('editorFindMatchHighlight'
export const editorCurrentFindMatchHighlight = registerColor('editorCurrentFindMatchHighlight', { light: '#A8AC94', dark: '#515C6A', hc: null }, nls.localize('currentFindMatchHighlight', "Background color of the current region matching the search"));
export const editorFindRangeHighlight = registerColor('editorFindRangeHighlight', { dark: '#3a3d4166', light: '#b4b4b44d', hc: null }, nls.localize('findRangeHighlight', "Background color of regions selected for search"));
/**
* Editor link colors
*/
export const editorActiveLinkForeground = registerColor('editorActiveLinkForeground', { dark: '#4E94CE', light: Color.black, hc: Color.cyan }, nls.localize('activeLinkForeground', 'Color of active links'));
export const editorLinkForeground = registerColor('editorLinkForeground', { dark: null, light: null, hc: null }, nls.localize('linkForeground', 'Color of links'));
// ----- color functions
......
......@@ -10,6 +10,8 @@ import * as colorRegistry from 'vs/platform/theme/common/colorRegistry';
import * as editorColorRegistry from 'vs/editor/common/view/editorColorRegistry';
import * as wordHighlighter from 'vs/editor/contrib/wordHighlighter/common/wordHighlighter';
import { ansiColorIdentifiers } from 'vs/workbench/parts/terminal/electron-browser/terminalColorRegistry';
import { editorHoverHighlight } from "vs/editor/contrib/hover/browser/hover";
import { referencesReferenceHighlight, referencesFindMatchHighlight } from "vs/editor/contrib/referenceSearch/browser/referencesWidget";
const settingToColorIdMapping: { [settingId: string]: string[] } = {};
......@@ -52,14 +54,14 @@ addSettingMapping('inactiveSelection', colorRegistry.editorInactiveSelection);
addSettingMapping('selectionHighlightColor', colorRegistry.editorSelectionHighlightColor);
addSettingMapping('findMatchHighlight', colorRegistry.editorFindMatchHighlight);
addSettingMapping('currentFindMatchHighlight', colorRegistry.editorCurrentFindMatchHighlight);
addSettingMapping('hoverHighlight', editorColorRegistry.editorHoverHighlight);
addSettingMapping('hoverHighlight', editorColorRegistry.editorHoverHighlight);
addSettingMapping('linkForeground', editorColorRegistry.editorLinkForeground);
addSettingMapping('hoverHighlight', editorHoverHighlight);
addSettingMapping('hoverHighlight', editorHoverHighlight);
addSettingMapping('linkForeground', colorRegistry.editorLinkForeground);
addSettingMapping('wordHighlight', wordHighlighter.editorWordHighlight);
addSettingMapping('wordHighlightStrong', wordHighlighter.editorWordHighlightString);
addSettingMapping('findRangeHighlight', colorRegistry.editorFindRangeHighlight);
addSettingMapping('findMatchHighlight', editorColorRegistry.referencesFindMatchHighlight);
addSettingMapping('referenceHighlight', editorColorRegistry.referencesReferenceHighlight);
addSettingMapping('findMatchHighlight', referencesFindMatchHighlight);
addSettingMapping('referenceHighlight', referencesReferenceHighlight);
addSettingMapping('lineHighlight', editorColorRegistry.editorLineHighlight);
addSettingMapping('rangeHighlight', editorColorRegistry.editorRangeHighlight);
addSettingMapping('caret', editorColorRegistry.editorCursor);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册