src/vs/base/common/themables.ts
117 LOC · 81 covered · 36 uncovered · 20 ranges · 4832 concepts · 6 introducers · 2463 tests
File neighbourhood
The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.
Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file
In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.
Graph controls are ready.
Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.
/*---------------------------------------------------------------------------------------------
themables.ts ×14
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Codicon } from './codicons.js';
export type ColorIdentifier = string;
export type IconIdentifier = string;
export interface ThemeColor {
id: string;
}
export namespace ThemeColor {
export function isThemeColor(obj: unknown): obj is ThemeColor {
return !!obj && typeof obj === 'object' && typeof (<ThemeColor>obj).id === 'string';
themables.ts ×1
}
export function themeColorFromId(id: ColorIdentifier) {
return { id };
}
export interface ThemeIcon {
readonly id: string;
readonly color?: ThemeColor;
}
export namespace ThemeIcon {
export const iconNameSegment = '[A-Za-z0-9]+';
export const iconNameExpression = '[A-Za-z0-9-]+';
export const iconModifierExpression = '~[A-Za-z]+';
export const iconNameCharacter = '[A-Za-z0-9~-]';
const ThemeIconIdRegex = new RegExp(`^(${iconNameExpression})(${iconModifierExpression})?$`);
export function asClassNameArray(icon: ThemeIcon): string[] {
const match = ThemeIconIdRegex.exec(icon.id);
if (!match) {
return asClassNameArray(Codicon.error);
}
const [, id, modifier] = match;
const classNames = ['codicon', 'codicon-' + id];
if (modifier) {
classNames.push('codicon-modifier-' + modifier.substring(1));
}
return classNames;
}
export function asClassName(icon: ThemeIcon): string {
return asClassNameArray(icon).join(' ');
}
export function asCSSSelector(icon: ThemeIcon): string {
return '.' + asClassNameArray(icon).join('.');
}
export function isThemeIcon(obj: unknown): obj is ThemeIcon {
return !!obj && typeof obj === 'object' && typeof (<ThemeIcon>obj).id === 'string' && (typeof (<ThemeIcon>obj).color === 'undefined' || ThemeColor.isThemeColor((<ThemeIcon>obj).color));
themables.ts ×1
}
const _regexFromString = new RegExp(`^\\$\\((${ThemeIcon.iconNameExpression}(?:${ThemeIcon.iconModifierExpression})?)\\)$`);
export function fromString(str: string): ThemeIcon | undefined {
const match = _regexFromString.exec(str);
if (!match) {
return undefined;
}
const [, name] = match;
return { id: name };
}
export function fromId(id: string): ThemeIcon {
}
export function modify(icon: ThemeIcon, modifier: 'disabled' | 'spin' | undefined): ThemeIcon {
const tildeIndex = id.lastIndexOf('~');
if (tildeIndex !== -1) {
id = id.substring(0, tildeIndex);
}
id = `${id}~${modifier}`;
}
return { id };
}
export function getModifier(icon: ThemeIcon): string | undefined {
const tildeIndex = icon.id.lastIndexOf('~');
if (tildeIndex !== -1) {
return icon.id.substring(tildeIndex + 1);
}
return undefined;
}
export function isEqual(ti1: ThemeIcon, ti2: ThemeIcon): boolean {
}
/**
* Returns whether specified icon is defined and has 'file' ID.
*/
export function isFile(icon: ThemeIcon | undefined): boolean {
return icon?.id === Codicon.file.id;
}
/**
* Returns whether specified icon is defined and has 'folder' ID.
*/
export function isFolder(icon: ThemeIcon | undefined): boolean {
return icon?.id === Codicon.folder.id;
}