Skip to content

Commit

Permalink
Use existing ThemeIcon interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dhuebner committed Apr 4, 2024
1 parent 7aa648c commit 9b2fb2e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/plugin-ext/src/plugin/terminal-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function getIconUris(iconPath: theia.TerminalOptions['iconPath']): Monaco
export function getIconClass(
options: theia.TerminalOptions | theia.ExtensionTerminalOptions,
sharedStyle: PluginSharedStyle, disposables: DisposableCollection
): string | { icon: string, color: string } | undefined {
): string | ThemeIcon | undefined {
const iconUriOrCodicon = getIconUris(options.iconPath);
const iconColor = MonacoThemeColor.isThemeColor(options.color) ? options.color : undefined;
let iconClass;
Expand All @@ -61,7 +61,7 @@ export function getIconClass(
} else {
iconClass = (MonacoThemeIcon.asClassName({ id: 'terminal' }));
}
return iconColor ? { icon: iconClass, color: iconColor.id } : iconClass;
return iconColor ? { id: iconClass, color: { id: iconColor.id } } : iconClass;
}

/**
Expand Down
10 changes: 3 additions & 7 deletions packages/terminal/src/browser/base/terminal-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

import { Event, ViewColumn } from '@theia/core';
import { BaseWidget } from '@theia/core/lib/browser';
import { MarkdownString } from '@theia/core/lib/common/markdown-rendering/markdown-string';
import { ThemeIcon } from '@theia/core/lib/common/theme';
import { CommandLineOptions } from '@theia/process/lib/common/shell-command-builder';
import { TerminalSearchWidget } from '../search/terminal-search-widget';
import { TerminalProcessInfo, TerminalExitReason } from '../../common/base-terminal-protocol';
import URI from '@theia/core/lib/common/uri';
import { MarkdownString } from '@theia/core/lib/common/markdown-rendering/markdown-string';

export interface TerminalDimensions {
cols: number;
Expand Down Expand Up @@ -179,11 +180,6 @@ export abstract class TerminalWidget extends BaseWidget {
abstract waitOnExit(waitOnExit?: boolean | string): void;
}

export interface TerminalIcon {
icon: string;
color?: string;
}

/**
* Terminal widget options.
*/
Expand All @@ -198,7 +194,7 @@ export interface TerminalWidgetOptions {
/**
* icon class with or without color modifier
*/
readonly iconClass?: string | TerminalIcon;
readonly iconClass?: string | ThemeIcon;

/**
* Path to the executable shell. For example: `/bin/bash`, `bash`, `sh`.
Expand Down
6 changes: 3 additions & 3 deletions packages/terminal/src/browser/terminal-widget-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
this.title.iconClass = iconClass;
} else {
const iconClasses: string[] = [];
iconClasses.push(iconClass.icon);
iconClasses.push(iconClass.id);
// TODO: Build different handling for URI icons.
if (iconClass.color && this.isTerminalAnsiColor(iconClass.color)) {
const color = this.getCodiconColor(iconClass.color);
if (iconClass.color && this.isTerminalAnsiColor(iconClass.color.id)) {
const color = this.getCodiconColor(iconClass.color.id);
iconClasses.push(color ? color : '');
}
this.title.iconClass = iconClasses.join(' ');
Expand Down

0 comments on commit 9b2fb2e

Please sign in to comment.