Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/browser/style.ts
3294 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import './media/style.css';
7
import { registerThemingParticipant } from '../../platform/theme/common/themeService.js';
8
import { WORKBENCH_BACKGROUND, TITLE_BAR_ACTIVE_BACKGROUND } from '../common/theme.js';
9
import { isWeb, isIOS } from '../../base/common/platform.js';
10
import { createMetaElement } from '../../base/browser/dom.js';
11
import { isSafari, isStandalone } from '../../base/browser/browser.js';
12
import { selectionBackground } from '../../platform/theme/common/colorRegistry.js';
13
import { mainWindow } from '../../base/browser/window.js';
14
15
registerThemingParticipant((theme, collector) => {
16
17
// Background (helps for subpixel-antialiasing on Windows)
18
const workbenchBackground = WORKBENCH_BACKGROUND(theme);
19
collector.addRule(`.monaco-workbench { background-color: ${workbenchBackground}; }`);
20
21
// Selection (do NOT remove - https://github.com/microsoft/vscode/issues/169662)
22
const windowSelectionBackground = theme.getColor(selectionBackground);
23
if (windowSelectionBackground) {
24
collector.addRule(`.monaco-workbench ::selection { background-color: ${windowSelectionBackground}; }`);
25
}
26
27
// Update <meta name="theme-color" content=""> based on selected theme
28
if (isWeb) {
29
const titleBackground = theme.getColor(TITLE_BAR_ACTIVE_BACKGROUND);
30
if (titleBackground) {
31
const metaElementId = 'monaco-workbench-meta-theme-color';
32
let metaElement = mainWindow.document.getElementById(metaElementId) as HTMLMetaElement | null;
33
if (!metaElement) {
34
metaElement = createMetaElement();
35
metaElement.name = 'theme-color';
36
metaElement.id = metaElementId;
37
}
38
39
metaElement.content = titleBackground.toString();
40
}
41
}
42
43
// We disable user select on the root element, however on Safari this seems
44
// to prevent any text selection in the monaco editor. As a workaround we
45
// allow to select text in monaco editor instances.
46
if (isSafari) {
47
collector.addRule(`
48
body.web {
49
touch-action: none;
50
}
51
.monaco-workbench .monaco-editor .view-lines {
52
user-select: text;
53
-webkit-user-select: text;
54
}
55
`);
56
}
57
58
// Update body background color to ensure the home indicator area looks similar to the workbench
59
if (isIOS && isStandalone()) {
60
collector.addRule(`body { background-color: ${workbenchBackground}; }`);
61
}
62
});
63
64