forked from eclipse-theia/theia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/asl/icons_contibutions_draft' …
…into icon-contributions
- Loading branch information
Showing
12 changed files
with
456 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
packages/monaco/src/browser/monaco-icon-registry-types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
|
||
// ***************************************************************************** | ||
// Copyright (C) 2023 Ericsson and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
import { Event } from '@theia/core'; | ||
import { IJSONSchema } from '@theia/core/lib/common/json-schema'; | ||
import { ThemeIcon } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService'; | ||
import { URI } from '@theia/core/shared/vscode-uri'; | ||
|
||
// ------ API types | ||
|
||
export type IconIdentifier = string; | ||
|
||
// icon registry | ||
export const Extensions = { | ||
IconContribution: 'base.contributions.icons' | ||
}; | ||
|
||
export type IconDefaults = ThemeIcon | IconDefinition; | ||
|
||
export interface IconDefinition { | ||
font?: IconFontContribution; // undefined for the default font (codicon) | ||
fontCharacter: string; | ||
} | ||
|
||
export interface IconContribution { | ||
readonly id: string; | ||
description: string | undefined; | ||
deprecationMessage?: string; | ||
readonly defaults: IconDefaults; | ||
} | ||
|
||
export interface IconFontContribution { | ||
readonly id: string; | ||
readonly definition: IconFontDefinition; | ||
} | ||
|
||
export interface IconFontDefinition { | ||
readonly weight?: string; | ||
readonly style?: string; | ||
readonly src: IconFontSource[]; | ||
} | ||
|
||
export interface IconFontSource { | ||
readonly location: URI; | ||
readonly format: string; | ||
} | ||
|
||
export const IconRegistry = Symbol('IconRegistry'); | ||
export interface IconRegistry { | ||
|
||
readonly onDidChange: Event<void>; | ||
|
||
/** | ||
* Register a icon to the registry. | ||
* @param id The icon id | ||
* @param defaults The default values | ||
* @param description The description | ||
*/ | ||
registerIcon(id: IconIdentifier, defaults: IconDefaults, description?: string): ThemeIcon; | ||
|
||
/** | ||
* Deregister a icon from the registry. | ||
*/ | ||
deregisterIcon(id: IconIdentifier): void; | ||
|
||
/** | ||
* Get all icon contributions | ||
*/ | ||
getIcons(): IconContribution[]; | ||
|
||
/** | ||
* Get the icon for the given id | ||
*/ | ||
getIcon(id: IconIdentifier): IconContribution | undefined; | ||
|
||
/** | ||
* JSON schema for an object to assign icon values to one of the icon contributions. | ||
*/ | ||
getIconSchema(): IJSONSchema; | ||
|
||
/** | ||
* JSON schema to for a reference to a icon contribution. | ||
*/ | ||
getIconReferenceSchema(): IJSONSchema; | ||
|
||
/** | ||
* Register a icon font to the registry. | ||
* @param id The icon font id | ||
* @param definition The icon font definition | ||
*/ | ||
registerIconFont(id: string, definition: IconFontDefinition): IconFontDefinition; | ||
|
||
/** | ||
* Deregister an icon font to the registry. | ||
*/ | ||
deregisterIconFont(id: string): void; | ||
|
||
/** | ||
* Get the icon font for the given id | ||
*/ | ||
getIconFont(id: string): IconFontDefinition | undefined; | ||
} | ||
|
||
export const IconsStyleSheet = Symbol('IconsStyleSheet'); | ||
export interface IconsStyleSheet { | ||
getCSS(): string; | ||
readonly onDidChange: Event<void>; | ||
} | ||
|
||
export const IconStyleSheetService = Symbol('IconStyleSheetService'); | ||
export interface IconStyleSheetService { | ||
getIconsStyleSheet(): IconsStyleSheet; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
// ***************************************************************************** | ||
// Copyright (C) 2023 Ericsson and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
|
||
import { injectable } from '@theia/core/shared/inversify'; | ||
import * as monaco from '@theia/monaco-editor-core/esm/vs/platform/theme/common/iconRegistry'; | ||
import { IconContribution, IconDefaults, IconFontDefinition, IconRegistry } from './monaco-icon-registry-types'; | ||
import { Event } from '@theia/core'; | ||
import { IJSONSchema } from '@theia/core/lib/common/json-schema'; | ||
import { ThemeIcon } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService'; | ||
|
||
@injectable() | ||
export class MonacoIconRegistry implements IconRegistry { | ||
protected readonly iconRegistry = monaco.getIconRegistry(); | ||
|
||
onDidChange: Event<void> = this.iconRegistry.onDidChange; | ||
|
||
registerIcon(id: string, defaults: IconDefaults, description?: string | undefined): ThemeIcon { | ||
return this.iconRegistry.registerIcon(id, defaults, description); | ||
} | ||
deregisterIcon(id: string): void { | ||
return this.iconRegistry.deregisterIcon(id); | ||
} | ||
getIcons(): IconContribution[] { | ||
return this.iconRegistry.getIcons(); | ||
} | ||
getIcon(id: string): IconContribution | undefined { | ||
return this.iconRegistry.getIcon(id); | ||
} | ||
getIconSchema(): IJSONSchema { | ||
return this.iconRegistry.getIconSchema(); | ||
} | ||
getIconReferenceSchema(): IJSONSchema { | ||
return this.iconRegistry.getIconReferenceSchema(); | ||
} | ||
registerIconFont(id: string, definition: IconFontDefinition): IconFontDefinition { | ||
return this.iconRegistry.registerIconFont(id, definition); | ||
} | ||
deregisterIconFont(id: string): void { | ||
return this.iconRegistry.deregisterIconFont(id); | ||
} | ||
getIconFont(id: string): IconFontDefinition | undefined { | ||
return this.iconRegistry.getIconFont(id); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
// ***************************************************************************** | ||
// Copyright (C) 2023 Ericsson and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
|
||
import { injectable } from '@theia/core/shared/inversify'; | ||
import { getIconsStyleSheet } from '@theia/monaco-editor-core/esm/vs/platform/theme/browser/iconsStyleSheet'; | ||
import { IconsStyleSheet } from './monaco-icon-registry-types'; | ||
|
||
@injectable() | ||
export class MonacoIconStyleSheetService { | ||
protected getIconsStyleSheet(): IconsStyleSheet { | ||
return getIconsStyleSheet(undefined); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.