Refresh master with initial release/0.24 snapshot (#332)

* Initial port of release/0.24 source code

* Fix additional headers

* Fix a typo in launch.json
This commit is contained in:
Karl Burtram
2017-12-15 15:38:57 -08:00
committed by GitHub
parent 271b3a0b82
commit 6ad0df0e3e
7118 changed files with 107999 additions and 56466 deletions

View File

@@ -42,7 +42,7 @@ const configurationExtPoint = ExtensionsRegistry.registerExtensionPoint<IColorEx
type: 'string',
anyOf: [
colorReferenceSchema,
{ type: 'string', format: 'color' }
{ type: 'string', format: 'color-hex' }
]
},
dark: {
@@ -50,7 +50,7 @@ const configurationExtPoint = ExtensionsRegistry.registerExtensionPoint<IColorEx
type: 'string',
anyOf: [
colorReferenceSchema,
{ type: 'string', format: 'color' }
{ type: 'string', format: 'color-hex' }
]
},
highContrast: {
@@ -58,7 +58,7 @@ const configurationExtPoint = ExtensionsRegistry.registerExtensionPoint<IColorEx
type: 'string',
anyOf: [
colorReferenceSchema,
{ type: 'string', format: 'color' }
{ type: 'string', format: 'color-hex' }
]
}
}
@@ -71,9 +71,9 @@ export class ColorExtensionPoint {
constructor() {
configurationExtPoint.setHandler((extensions) => {
for (var i = 0; i < extensions.length; i++) {
var extensionValue = <IColorExtensionPoint[]>extensions[i].value;
var collector = extensions[i].collector;
for (let i = 0; i < extensions.length; i++) {
const extensionValue = <IColorExtensionPoint[]>extensions[i].value;
const collector = extensions[i].collector;
if (!extensionValue || !Array.isArray(extensionValue)) {
collector.error(nls.localize('invalid.colorConfiguration', "'configuration.colors' must be a array"));
@@ -93,7 +93,7 @@ export class ColorExtensionPoint {
extensionValue.forEach(extension => {
if (typeof extension.id !== 'string' || extension.id.length === 0) {
collector.error(nls.localize('invalid.id', "'configuration.colors.id' must be defined an can not be empty"));
collector.error(nls.localize('invalid.id', "'configuration.colors.id' must be defined and can not be empty"));
return;
}
if (!extension.id.match(colorIdPattern)) {
@@ -101,11 +101,11 @@ export class ColorExtensionPoint {
return;
}
if (typeof extension.description !== 'string' || extension.id.length === 0) {
collector.error(nls.localize('invalid.description', "'configuration.colors.description' must be defined an can not be empty"));
collector.error(nls.localize('invalid.description', "'configuration.colors.description' must be defined and can not be empty"));
return;
}
let defaults = extension.defaults;
if (typeof defaults !== 'object' || typeof defaults.light !== 'string' || typeof defaults.dark !== 'string' || typeof defaults.highContrast !== 'string') {
if (!defaults || typeof defaults !== 'object' || typeof defaults.light !== 'string' || typeof defaults.dark !== 'string' || typeof defaults.highContrast !== 'string') {
collector.error(nls.localize('invalid.defaults', "'configuration.colors.defaults' must be defined and must contain 'light', 'dark' and 'highContrast'"));
return;
}

View File

@@ -74,8 +74,7 @@ export interface IColorRegistry {
}
const colorPattern = '^#([0-9A-Fa-f]{3,4}|([0-9A-Fa-f]{2}){3,4})$';
const colorPatternErrorMessage = nls.localize('invalid.color', 'Invalid color format. Use #RGB, #RGBA, #RRGGBB or #RRGGBBAA');
class ColorRegistry implements IColorRegistry {
private colorsById: { [key: string]: ColorContribution };
@@ -89,7 +88,7 @@ class ColorRegistry implements IColorRegistry {
public registerColor(id: string, defaults: ColorDefaults, description: string): ColorIdentifier {
let colorContribution = { id, description, defaults };
this.colorsById[id] = colorContribution;
this.colorSchema.properties[id] = { type: 'string', description, format: 'color', pattern: colorPattern, patternErrorMessage: colorPatternErrorMessage };
this.colorSchema.properties[id] = { type: 'string', description, format: 'color-hex', default: '#ff0000' };
this.colorReferenceSchema.enum.push(id);
this.colorReferenceSchema.enumDescriptions.push(description);
return id;
@@ -187,16 +186,17 @@ export const selectBorder = registerColor('dropdown.border', { dark: selectBackg
export const listFocusBackground = registerColor('list.focusBackground', { dark: '#073655', light: '#DCEBFC', hc: null }, nls.localize('listFocusBackground', "List/Tree background color for the focused item when the list/tree is active. An active list/tree has keyboard focus, an inactive does not."));
export const listFocusForeground = registerColor('list.focusForeground', { dark: null, light: null, hc: null }, nls.localize('listFocusForeground', "List/Tree foreground color for the focused item when the list/tree is active. An active list/tree has keyboard focus, an inactive does not."));
export const listActiveSelectionBackground = registerColor('list.activeSelectionBackground', { dark: '#3062D6', light: '#3062D6', hc: null }, nls.localize('listActiveSelectionBackground', "List/Tree background color for the selected item when the list/tree is active. An active list/tree has keyboard focus, an inactive does not."));
export const listActiveSelectionBackground = registerColor('list.activeSelectionBackground', { dark: '#094771', light: '#3399FF', hc: null }, nls.localize('listActiveSelectionBackground', "List/Tree background color for the selected item when the list/tree is active. An active list/tree has keyboard focus, an inactive does not."));
export const listActiveSelectionForeground = registerColor('list.activeSelectionForeground', { dark: Color.white, light: Color.white, hc: null }, nls.localize('listActiveSelectionForeground', "List/Tree foreground color for the selected item when the list/tree is active. An active list/tree has keyboard focus, an inactive does not."));
export const listInactiveSelectionBackground = registerColor('list.inactiveSelectionBackground', { dark: '#555555', light: '#C8C8C8', hc: null }, nls.localize('listInactiveSelectionBackground', "List/Tree background color for the selected item when the list/tree is inactive. An active list/tree has keyboard focus, an inactive does not."));
export const listInactiveSelectionForeground = registerColor('list.inactiveSelectionForeground', { dark: '#FFFFFF', light: '#333333', hc: null }, nls.localize('listInactiveSelectionForeground', "List/Tree foreground color for the selected item when the list/tree is inactive. An active list/tree has keyboard focus, an inactive does not."));
export const listInactiveSelectionBackground = registerColor('list.inactiveSelectionBackground', { dark: '#3F3F46', light: '#CCCEDB', hc: null }, nls.localize('listInactiveSelectionBackground', "List/Tree background color for the selected item when the list/tree is inactive. An active list/tree has keyboard focus, an inactive does not."));
export const listInactiveSelectionForeground = registerColor('list.inactiveSelectionForeground', { dark: null, light: null, hc: null }, nls.localize('listInactiveSelectionForeground', "List/Tree foreground color for the selected item when the list/tree is inactive. An active list/tree has keyboard focus, an inactive does not."));
export const listInactiveFocusBackground = registerColor('list.inactiveFocusBackground', { dark: '#313135', light: '#d8dae6', hc: null }, nls.localize('listInactiveSelectionBackground', "List/Tree background color for the selected item when the list/tree is inactive. An active list/tree has keyboard focus, an inactive does not."));
export const listInactiveFocusForeground = registerColor('list.inactiveFocusForeground', { dark: null, light: null, hc: null }, nls.localize('listInactiveSelectionForeground', "List/Tree foreground color for the selected item when the list/tree is inactive. An active list/tree has keyboard focus, an inactive does not."));
export const listHoverBackground = registerColor('list.hoverBackground', { dark: '#444444', light: '#DCDCDC', hc: null }, nls.localize('listHoverBackground', "List/Tree background when hovering over items using the mouse."));
export const listHoverForeground = registerColor('list.hoverForeground', { dark: '#FFFFFF', light: '#333333', hc: null }, nls.localize('listHoverForeground', "List/Tree foreground when hovering over items using the mouse."));
export const listHoverBackground = registerColor('list.hoverBackground', { dark: '#2A2D2E', light: '#F0F0F0', hc: null }, nls.localize('listHoverBackground', "List/Tree background when hovering over items using the mouse."));
export const listHoverForeground = registerColor('list.hoverForeground', { dark: null, light: null, hc: null }, nls.localize('listHoverForeground', "List/Tree foreground when hovering over items using the mouse."));
export const listDropBackground = registerColor('list.dropBackground', { dark: listFocusBackground, light: listFocusBackground, hc: null }, nls.localize('listDropBackground', "List/Tree drag and drop background when moving items around using the mouse."));
export const listHighlightForeground = registerColor('list.highlightForeground', { dark: '#0097fb', light: '#007acc', hc: focusBorder }, nls.localize('highlight', 'List/Tree foreground color of the match highlights when searching inside the list/tree.'));
export const listInvalidItemForeground = registerColor('list.invalidItemForeground', { dark: '#B89500', light: '#B89500', hc: '#B89500' }, nls.localize('invalidItemForeground', 'List/Tree foreground color for invalid items, for example an unresolved root in explorer.'));
export const pickerGroupForeground = registerColor('pickerGroup.foreground', { dark: Color.fromHex('#0097FB').transparent(0.6), light: Color.fromHex('#007ACC').transparent(0.6), hc: Color.white }, nls.localize('pickerGroupForeground', "Quick picker color for grouping labels."));
export const pickerGroupBorder = registerColor('pickerGroup.border', { dark: '#3F3F46', light: '#CCCEDB', hc: Color.white }, nls.localize('pickerGroupBorder', "Quick picker color for grouping borders."));

View File

@@ -11,15 +11,23 @@ import { IDisposable } from 'vs/base/common/lifecycle';
export type styleFn = (colors: { [name: string]: ColorIdentifier }) => void;
export interface IStyleOverrides {
[color: string]: ColorIdentifier;
}
export interface IThemable {
style: styleFn;
}
export function attachStyler(themeService: IThemeService, optionsMapping: { [optionsKey: string]: ColorIdentifier | ColorFunction }, widgetOrCallback: IThemable | styleFn): IDisposable {
export interface IColorMapping {
[optionsKey: string]: ColorIdentifier | ColorFunction | undefined;
}
export function attachStyler<T extends IColorMapping>(themeService: IThemeService, optionsMapping: T, widgetOrCallback: IThemable | styleFn): IDisposable {
function applyStyles(theme: ITheme): void {
const styles = Object.create(null);
for (let key in optionsMapping) {
const value = optionsMapping[key];
const value = optionsMapping[key as string];
if (typeof value === 'string') {
styles[key] = theme.getColor(value);
} else if (typeof value === 'function') {
@@ -39,36 +47,43 @@ export function attachStyler(themeService: IThemeService, optionsMapping: { [opt
return themeService.onThemeChange(applyStyles);
}
export function attachCheckboxStyler(widget: IThemable, themeService: IThemeService, style?: { inputActiveOptionBorderColor?: ColorIdentifier }): IDisposable {
return attachStyler(themeService, {
inputActiveOptionBorder: (style && style.inputActiveOptionBorderColor) || inputActiveOptionBorder
}, widget);
export interface ICheckboxStyleOverrides extends IStyleOverrides {
inputActiveOptionBorderColor?: ColorIdentifier;
}
export function attachBadgeStyler(widget: IThemable, themeService: IThemeService, style?:
{
badgeBackground?: ColorIdentifier,
badgeForeground?: ColorIdentifier
}): IDisposable {
export function attachCheckboxStyler(widget: IThemable, themeService: IThemeService, style?: ICheckboxStyleOverrides): IDisposable {
return attachStyler(themeService, {
inputActiveOptionBorder: (style && style.inputActiveOptionBorderColor) || inputActiveOptionBorder
} as ICheckboxStyleOverrides, widget);
}
export interface IBadgeStyleOverrides extends IStyleOverrides {
badgeBackground?: ColorIdentifier;
badgeForeground?: ColorIdentifier;
}
export function attachBadgeStyler(widget: IThemable, themeService: IThemeService, style?: IBadgeStyleOverrides): IDisposable {
return attachStyler(themeService, {
badgeBackground: (style && style.badgeBackground) || badgeBackground,
badgeForeground: (style && style.badgeForeground) || badgeForeground,
badgeBorder: contrastBorder
}, widget);
} as IBadgeStyleOverrides, widget);
}
export function attachInputBoxStyler(widget: IThemable, themeService: IThemeService, style?:
{
inputBackground?: ColorIdentifier,
inputForeground?: ColorIdentifier,
inputBorder?: ColorIdentifier,
inputValidationInfoBorder?: ColorIdentifier,
inputValidationInfoBackground?: ColorIdentifier,
inputValidationWarningBorder?: ColorIdentifier,
inputValidationWarningBackground?: ColorIdentifier,
inputValidationErrorBorder?: ColorIdentifier,
inputValidationErrorBackground?: ColorIdentifier
}): IDisposable {
export interface IInputBoxStyleOverrides extends IStyleOverrides {
inputBackground?: ColorIdentifier;
inputForeground?: ColorIdentifier;
inputBorder?: ColorIdentifier;
inputActiveOptionBorder?: ColorIdentifier;
inputValidationInfoBorder?: ColorIdentifier;
inputValidationInfoBackground?: ColorIdentifier;
inputValidationWarningBorder?: ColorIdentifier;
inputValidationWarningBackground?: ColorIdentifier;
inputValidationErrorBorder?: ColorIdentifier;
inputValidationErrorBackground?: ColorIdentifier;
}
export function attachInputBoxStyler(widget: IThemable, themeService: IThemeService, style?: IInputBoxStyleOverrides): IDisposable {
return attachStyler(themeService, {
inputBackground: (style && style.inputBackground) || inputBackground,
inputForeground: (style && style.inputForeground) || inputForeground,
@@ -79,30 +94,24 @@ export function attachInputBoxStyler(widget: IThemable, themeService: IThemeServ
inputValidationWarningBackground: (style && style.inputValidationWarningBackground) || inputValidationWarningBackground,
inputValidationErrorBorder: (style && style.inputValidationErrorBorder) || inputValidationErrorBorder,
inputValidationErrorBackground: (style && style.inputValidationErrorBackground) || inputValidationErrorBackground
}, widget);
} as IInputBoxStyleOverrides, widget);
}
export function attachSelectBoxStyler(widget: IThemable, themeService: IThemeService, style?: { selectBackground?: ColorIdentifier, selectForeground?: ColorIdentifier, selectBorder?: ColorIdentifier }): IDisposable {
export interface ISelectBoxStyleOverrides extends IStyleOverrides {
selectBackground?: ColorIdentifier;
selectForeground?: ColorIdentifier;
selectBorder?: ColorIdentifier;
}
export function attachSelectBoxStyler(widget: IThemable, themeService: IThemeService, style?: ISelectBoxStyleOverrides): IDisposable {
return attachStyler(themeService, {
selectBackground: (style && style.selectBackground) || selectBackground,
selectForeground: (style && style.selectForeground) || selectForeground,
selectBorder: (style && style.selectBorder) || selectBorder
}, widget);
} as ISelectBoxStyleOverrides, widget);
}
export function attachFindInputBoxStyler(widget: IThemable, themeService: IThemeService, style?:
{
inputBackground?: ColorIdentifier,
inputForeground?: ColorIdentifier,
inputBorder?: ColorIdentifier,
inputActiveOptionBorder?: ColorIdentifier,
inputValidationInfoBorder?: ColorIdentifier,
inputValidationInfoBackground?: ColorIdentifier,
inputValidationWarningBorder?: ColorIdentifier,
inputValidationWarningBackground?: ColorIdentifier,
inputValidationErrorBorder?: ColorIdentifier,
inputValidationErrorBackground?: ColorIdentifier
}): IDisposable {
export function attachFindInputBoxStyler(widget: IThemable, themeService: IThemeService, style?: IInputBoxStyleOverrides): IDisposable {
return attachStyler(themeService, {
inputBackground: (style && style.inputBackground) || inputBackground,
inputForeground: (style && style.inputForeground) || inputForeground,
@@ -114,43 +123,19 @@ export function attachFindInputBoxStyler(widget: IThemable, themeService: ITheme
inputValidationWarningBackground: (style && style.inputValidationWarningBackground) || inputValidationWarningBackground,
inputValidationErrorBorder: (style && style.inputValidationErrorBorder) || inputValidationErrorBorder,
inputValidationErrorBackground: (style && style.inputValidationErrorBackground) || inputValidationErrorBackground
}, widget);
} as IInputBoxStyleOverrides, widget);
}
export function attachQuickOpenStyler(widget: IThemable, themeService: IThemeService, style?: {
foreground?: ColorIdentifier,
background?: ColorIdentifier,
borderColor?: ColorIdentifier,
widgetShadow?: ColorIdentifier,
progressBarBackground?: ColorIdentifier,
inputBackground?: ColorIdentifier,
inputForeground?: ColorIdentifier,
inputBorder?: ColorIdentifier,
inputValidationInfoBorder?: ColorIdentifier,
inputValidationInfoBackground?: ColorIdentifier,
inputValidationWarningBorder?: ColorIdentifier,
inputValidationWarningBackground?: ColorIdentifier,
inputValidationErrorBorder?: ColorIdentifier,
inputValidationErrorBackground?: ColorIdentifier
pickerGroupForeground?: ColorIdentifier,
pickerGroupBorder?: ColorIdentifier,
listFocusBackground?: ColorIdentifier,
listFocusForeground?: ColorIdentifier,
listActiveSelectionBackground?: ColorIdentifier,
listActiveSelectionForeground?: ColorIdentifier,
listFocusAndSelectionBackground?: ColorIdentifier,
listFocusAndSelectionForeground?: ColorIdentifier,
listInactiveSelectionBackground?: ColorIdentifier,
listInactiveSelectionForeground?: ColorIdentifier,
listInactiveFocusBackground?: ColorIdentifier,
listInactiveFocusForeground?: ColorIdentifier,
listHoverBackground?: ColorIdentifier,
listHoverForeground?: ColorIdentifier,
listDropBackground?: ColorIdentifier,
listFocusOutline?: ColorIdentifier,
listSelectionOutline?: ColorIdentifier,
listHoverOutline?: ColorIdentifier
}): IDisposable {
export interface IQuickOpenStyleOverrides extends IListStyleOverrides, IInputBoxStyleOverrides, IProgressBarStyleOverrides {
foreground?: ColorIdentifier;
background?: ColorIdentifier;
borderColor?: ColorIdentifier;
widgetShadow?: ColorIdentifier;
pickerGroupForeground?: ColorIdentifier;
pickerGroupBorder?: ColorIdentifier;
};
export function attachQuickOpenStyler(widget: IThemable, themeService: IThemeService, style?: IQuickOpenStyleOverrides): IDisposable {
return attachStyler(themeService, {
foreground: (style && style.foreground) || foreground,
background: (style && style.background) || editorBackground,
@@ -184,28 +169,30 @@ export function attachQuickOpenStyler(widget: IThemable, themeService: IThemeSer
listFocusOutline: (style && style.listFocusOutline) || activeContrastBorder,
listSelectionOutline: (style && style.listSelectionOutline) || activeContrastBorder,
listHoverOutline: (style && style.listHoverOutline) || activeContrastBorder
}, widget);
} as IQuickOpenStyleOverrides, widget);
}
export function attachListStyler(widget: IThemable, themeService: IThemeService, style?: {
listFocusBackground?: ColorIdentifier,
listFocusForeground?: ColorIdentifier,
listActiveSelectionBackground?: ColorIdentifier,
listActiveSelectionForeground?: ColorIdentifier,
listFocusAndSelectionBackground?: ColorIdentifier,
listFocusAndSelectionForeground?: ColorIdentifier,
listInactiveSelectionBackground?: ColorIdentifier,
listInactiveSelectionForeground?: ColorIdentifier,
listInactiveFocusBackground?: ColorIdentifier,
listInactiveFocusForeground?: ColorIdentifier,
listHoverBackground?: ColorIdentifier,
listHoverForeground?: ColorIdentifier,
listDropBackground?: ColorIdentifier,
listFocusOutline?: ColorIdentifier,
listInactiveFocusOutline?: ColorIdentifier,
listSelectionOutline?: ColorIdentifier,
listHoverOutline?: ColorIdentifier,
}): IDisposable {
export interface IListStyleOverrides extends IStyleOverrides {
listFocusBackground?: ColorIdentifier;
listFocusForeground?: ColorIdentifier;
listActiveSelectionBackground?: ColorIdentifier;
listActiveSelectionForeground?: ColorIdentifier;
listFocusAndSelectionBackground?: ColorIdentifier;
listFocusAndSelectionForeground?: ColorIdentifier;
listInactiveSelectionBackground?: ColorIdentifier;
listInactiveSelectionForeground?: ColorIdentifier;
listInactiveFocusBackground?: ColorIdentifier;
listInactiveFocusForeground?: ColorIdentifier;
listHoverBackground?: ColorIdentifier;
listHoverForeground?: ColorIdentifier;
listDropBackground?: ColorIdentifier;
listFocusOutline?: ColorIdentifier;
listInactiveFocusOutline?: ColorIdentifier;
listSelectionOutline?: ColorIdentifier;
listHoverOutline?: ColorIdentifier;
}
export function attachListStyler(widget: IThemable, themeService: IThemeService, style?: IListStyleOverrides): IDisposable {
return attachStyler(themeService, {
listFocusBackground: (style && style.listFocusBackground) || listFocusBackground,
listFocusForeground: (style && style.listFocusForeground) || listFocusForeground,
@@ -224,22 +211,32 @@ export function attachListStyler(widget: IThemable, themeService: IThemeService,
listSelectionOutline: (style && style.listSelectionOutline) || activeContrastBorder,
listHoverOutline: (style && style.listHoverOutline) || activeContrastBorder,
listInactiveFocusOutline: style && style.listInactiveFocusOutline // not defined by default, only opt-in
}, widget);
} as IListStyleOverrides, widget);
}
export function attachButtonStyler(widget: IThemable, themeService: IThemeService, style?: { buttonForeground?: ColorIdentifier, buttonBackground?: ColorIdentifier, buttonHoverBackground?: ColorIdentifier }): IDisposable {
export interface IButtonStyleOverrides extends IStyleOverrides {
buttonForeground?: ColorIdentifier;
buttonBackground?: ColorIdentifier;
buttonHoverBackground?: ColorIdentifier;
}
export function attachButtonStyler(widget: IThemable, themeService: IThemeService, style?: IButtonStyleOverrides): IDisposable {
return attachStyler(themeService, {
buttonForeground: (style && style.buttonForeground) || buttonForeground,
buttonBackground: (style && style.buttonBackground) || buttonBackground,
buttonHoverBackground: (style && style.buttonHoverBackground) || buttonHoverBackground,
buttonBorder: contrastBorder
}, widget);
} as IButtonStyleOverrides, widget);
}
export function attachProgressBarStyler(widget: IThemable, themeService: IThemeService, style?: { progressBarBackground?: ColorIdentifier }): IDisposable {
export interface IProgressBarStyleOverrides extends IStyleOverrides {
progressBarBackground?: ColorIdentifier;
}
export function attachProgressBarStyler(widget: IThemable, themeService: IThemeService, style?: IProgressBarStyleOverrides): IDisposable {
return attachStyler(themeService, {
progressBarBackground: (style && style.progressBarBackground) || progressBarBackground
}, widget);
} as IProgressBarStyleOverrides, widget);
}
export function attachStylerCallback(themeService: IThemeService, colors: { [name: string]: ColorIdentifier }, callback: styleFn): IDisposable {

View File

@@ -124,22 +124,4 @@ platform.Registry.add(Extensions.ThemingContribution, themingRegistry);
export function registerThemingParticipant(participant: IThemingParticipant): IDisposable {
return themingRegistry.onThemeChange(participant);
}
/**
* Tag function for strings containing css rules
*/
export function cssRule(literals, ...placeholders) {
let result = '';
for (let i = 0; i < placeholders.length; i++) {
result += literals[i];
let placeholder = placeholders[i];
if (placeholder === null) {
result += 'transparent';
} else {
result += placeholder.toString();
}
}
result += literals[literals.length - 1];
return result;
}