UNPKG

monaco-editor

Version:
98 lines • 7.75 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { BugIndicatingError } from '../../../../../../base/common/errors.js'; import { observableFromEventOpts } from '../../../../../../base/common/observable.js'; import { localize } from '../../../../../../nls.js'; import { buttonBackground, buttonForeground, buttonSecondaryBackground, buttonSecondaryForeground, diffInserted, diffInsertedLine, diffRemoved, editorBackground } from '../../../../../../platform/theme/common/colorRegistry.js'; import { darken, registerColor, transparent } from '../../../../../../platform/theme/common/colorUtils.js'; import { InlineEditTabAction } from './inlineEditsViewInterface.js'; export const originalBackgroundColor = registerColor('inlineEdit.originalBackground', transparent(diffRemoved, 0.2), localize(1210, 'Background color for the original text in inline edits.'), true); export const modifiedBackgroundColor = registerColor('inlineEdit.modifiedBackground', transparent(diffInserted, 0.3), localize(1211, 'Background color for the modified text in inline edits.'), true); export const originalChangedLineBackgroundColor = registerColor('inlineEdit.originalChangedLineBackground', transparent(diffRemoved, 0.8), localize(1212, 'Background color for the changed lines in the original text of inline edits.'), true); export const originalChangedTextOverlayColor = registerColor('inlineEdit.originalChangedTextBackground', transparent(diffRemoved, 0.8), localize(1213, 'Overlay color for the changed text in the original text of inline edits.'), true); export const modifiedChangedLineBackgroundColor = registerColor('inlineEdit.modifiedChangedLineBackground', { light: transparent(diffInsertedLine, 0.7), dark: transparent(diffInsertedLine, 0.7), hcDark: diffInsertedLine, hcLight: diffInsertedLine }, localize(1214, 'Background color for the changed lines in the modified text of inline edits.'), true); export const modifiedChangedTextOverlayColor = registerColor('inlineEdit.modifiedChangedTextBackground', transparent(diffInserted, 0.7), localize(1215, 'Overlay color for the changed text in the modified text of inline edits.'), true); // ------- GUTTER INDICATOR ------- export const inlineEditIndicatorPrimaryForeground = registerColor('inlineEdit.gutterIndicator.primaryForeground', buttonForeground, localize(1216, 'Foreground color for the primary inline edit gutter indicator.')); export const inlineEditIndicatorPrimaryBorder = registerColor('inlineEdit.gutterIndicator.primaryBorder', buttonBackground, localize(1217, 'Border color for the primary inline edit gutter indicator.')); export const inlineEditIndicatorPrimaryBackground = registerColor('inlineEdit.gutterIndicator.primaryBackground', { light: transparent(inlineEditIndicatorPrimaryBorder, 0.5), dark: transparent(inlineEditIndicatorPrimaryBorder, 0.4), hcDark: transparent(inlineEditIndicatorPrimaryBorder, 0.4), hcLight: transparent(inlineEditIndicatorPrimaryBorder, 0.5), }, localize(1218, 'Background color for the primary inline edit gutter indicator.')); export const inlineEditIndicatorSecondaryForeground = registerColor('inlineEdit.gutterIndicator.secondaryForeground', buttonSecondaryForeground, localize(1219, 'Foreground color for the secondary inline edit gutter indicator.')); export const inlineEditIndicatorSecondaryBorder = registerColor('inlineEdit.gutterIndicator.secondaryBorder', buttonSecondaryBackground, localize(1220, 'Border color for the secondary inline edit gutter indicator.')); export const inlineEditIndicatorSecondaryBackground = registerColor('inlineEdit.gutterIndicator.secondaryBackground', inlineEditIndicatorSecondaryBorder, localize(1221, 'Background color for the secondary inline edit gutter indicator.')); export const inlineEditIndicatorsuccessfulForeground = registerColor('inlineEdit.gutterIndicator.successfulForeground', buttonForeground, localize(1222, 'Foreground color for the successful inline edit gutter indicator.')); export const inlineEditIndicatorsuccessfulBorder = registerColor('inlineEdit.gutterIndicator.successfulBorder', buttonBackground, localize(1223, 'Border color for the successful inline edit gutter indicator.')); export const inlineEditIndicatorsuccessfulBackground = registerColor('inlineEdit.gutterIndicator.successfulBackground', inlineEditIndicatorsuccessfulBorder, localize(1224, 'Background color for the successful inline edit gutter indicator.')); export const inlineEditIndicatorBackground = registerColor('inlineEdit.gutterIndicator.background', { hcDark: transparent('tab.inactiveBackground', 0.5), hcLight: transparent('tab.inactiveBackground', 0.5), dark: transparent('tab.inactiveBackground', 0.5), light: '#5f5f5f18', }, localize(1225, 'Background color for the inline edit gutter indicator.')); // ------- BORDER COLORS ------- const originalBorder = registerColor('inlineEdit.originalBorder', { light: diffRemoved, dark: diffRemoved, hcDark: diffRemoved, hcLight: diffRemoved }, localize(1226, 'Border color for the original text in inline edits.')); const modifiedBorder = registerColor('inlineEdit.modifiedBorder', { light: darken(diffInserted, 0.6), dark: diffInserted, hcDark: diffInserted, hcLight: diffInserted }, localize(1227, 'Border color for the modified text in inline edits.')); const tabWillAcceptModifiedBorder = registerColor('inlineEdit.tabWillAcceptModifiedBorder', { light: darken(modifiedBorder, 0), dark: darken(modifiedBorder, 0), hcDark: darken(modifiedBorder, 0), hcLight: darken(modifiedBorder, 0) }, localize(1228, 'Modified border color for the inline edits widget when tab will accept it.')); const tabWillAcceptOriginalBorder = registerColor('inlineEdit.tabWillAcceptOriginalBorder', { light: darken(originalBorder, 0), dark: darken(originalBorder, 0), hcDark: darken(originalBorder, 0), hcLight: darken(originalBorder, 0) }, localize(1229, 'Original border color for the inline edits widget over the original text when tab will accept it.')); export function getModifiedBorderColor(tabAction) { return tabAction.map(a => a === InlineEditTabAction.Accept ? tabWillAcceptModifiedBorder : modifiedBorder); } export function getOriginalBorderColor(tabAction) { return tabAction.map(a => a === InlineEditTabAction.Accept ? tabWillAcceptOriginalBorder : originalBorder); } export function getEditorBlendedColor(colorIdentifier, themeService) { let color; if (typeof colorIdentifier === 'string') { color = observeColor(colorIdentifier, themeService); } else { color = colorIdentifier.map((identifier, reader) => observeColor(identifier, themeService).read(reader)); } const backgroundColor = observeColor(editorBackground, themeService); return color.map((c, reader) => /** @description makeOpaque */ c.makeOpaque(backgroundColor.read(reader))); } export function observeColor(colorIdentifier, themeService) { return observableFromEventOpts({ owner: { observeColor: colorIdentifier }, equalsFn: (a, b) => a.equals(b), debugName: () => `observeColor(${colorIdentifier})` }, themeService.onDidColorThemeChange, () => { const color = themeService.getColorTheme().getColor(colorIdentifier); if (!color) { throw new BugIndicatingError(`Missing color: ${colorIdentifier}`); } return color; }); } //# sourceMappingURL=theme.js.map