Skip to content

Commit

Permalink
Add default terminal colors per theme, update immediately on theme ch…
Browse files Browse the repository at this point in the history
…ange

Part of #6766
  • Loading branch information
Tyriar committed May 25, 2016
1 parent a2d4a29 commit 2880c92
Showing 1 changed file with 71 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import path = require('path');
import URI from 'vs/base/common/uri';
import DOM = require('vs/base/browser/dom');
import platform = require('vs/base/common/platform');
import {getBaseThemeId} from 'vs/platform/theme/common/themes';
import {TPromise} from 'vs/base/common/winjs.base';
import {Builder, Dimension} from 'vs/base/browser/builder';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {IStringDictionary} from 'vs/base/common/collections';
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {IThemeService} from 'vs/workbench/services/themes/common/themeService';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {ITerminalConfiguration, ITerminalService, TERMINAL_PANEL_ID} from 'vs/workbench/parts/terminal/common/terminal';
import {Panel} from 'vs/workbench/browser/panel';
Expand All @@ -25,6 +27,63 @@ import {ScrollbarVisibility} from 'vs/base/browser/ui/scrollbar/scrollableElemen
const TERMINAL_CHAR_WIDTH = 8;
const TERMINAL_CHAR_HEIGHT = 18;

const DEFAULT_ANSI_COLORS = {
'hc-black': [
'#000000', // black
'#cd0000', // red
'#00cd00', // green
'#cdcd00', // yellow
'#0000ee', // blue
'#cd00cd', // magenta
'#00cdcd', // cyan
'#e5e5e5', // white
'#7f7f7f', // bright black
'#ff0000', // bright red
'#00ff00', // bright green
'#ffff00', // bright yellow
'#5c5cff', // bright blue
'#ff00ff', // bright magenta
'#00ffff', // bright cyan
'#ffffff' // bright white
],
'vs': [
'#000000', // black
'#cd3131', // red
'#09885a', // green
'#e5e510', // yellow
'#0451a5', // blue
'#bc05bc', // magenta
'#0598bc', // cyan
'#e5e5e5', // white
'#111111', // bright black
'#cd3131', // bright red
'#09885a', // bright green
'#e5e510', // bright yellow
'#0451a5', // bright blue
'#bc05bc', // bright magenta
'#0598bc', // bright cyan
'#e5e5e5' // bright white
],
'vs-dark': [
'#000000', // black
'#cd3131', // red
'#09885a', // green
'#e5e510', // yellow
'#0451a5', // blue
'#bc05bc', // magenta
'#0598bc', // cyan
'#e5e5e5', // white
'#111111', // bright black
'#cd3131', // bright red
'#09885a', // bright green
'#e5e510', // bright yellow
'#0451a5', // bright blue
'#bc05bc', // bright magenta
'#0598bc', // bright cyan
'#e5e5e5' // bright white
]
};

export class TerminalPanel extends Panel {

private toDispose: lifecycle.IDisposable[];
Expand All @@ -37,7 +96,8 @@ export class TerminalPanel extends Panel {
@IConfigurationService private configurationService: IConfigurationService,
@ITelemetryService telemetryService: ITelemetryService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@ITerminalService private terminalService: ITerminalService
@ITerminalService private terminalService: ITerminalService,
@IThemeService private themeService: IThemeService
) {
super(TERMINAL_PANEL_ID, telemetryService);
this.toDispose = [];
Expand Down Expand Up @@ -132,16 +192,26 @@ export class TerminalPanel extends Panel {
this.focusTerminal();
}
}));
this.toDispose.push(this.themeService.onDidThemeChange((themeId) => {
this.setTerminalTheme(themeId);
}));

this.terminal.open(this.terminalDomElement);
this.parentDomElement.appendChild(terminalScrollbar.getDomNode());

let config = this.configurationService.getConfiguration<ITerminalConfiguration>();
this.terminalDomElement.style.fontFamily = config.integratedTerminal.fontFamily;
this.setTerminalTheme(this.themeService.getTheme());
resolve(void 0);
});
}

private setTerminalTheme(themeId: string) {
let baseThemeId = getBaseThemeId(themeId);
this.terminal.colors = DEFAULT_ANSI_COLORS[baseThemeId];
this.terminal.refresh(0, this.terminal.rows);
}

public focus(): void {
this.focusTerminal(true);
}
Expand Down

0 comments on commit 2880c92

Please sign in to comment.