move up octicon logic so that it can be reused in quick open
parent
c2b4f23fee
commit
9eebf6657f
|
@ -56,11 +56,11 @@ var vscodeResources = [
|
|||
'out-build/vs/base/node/{stdForkStart.js,terminateProcess.sh}',
|
||||
'out-build/vs/base/worker/workerMainCompatibility.html',
|
||||
'out-build/vs/base/worker/workerMain.{js,js.map}',
|
||||
'out-build/vs/base/browser/ui/octiconLabel/octicons/**',
|
||||
'out-build/vs/editor/css/*.css',
|
||||
'out-build/vs/languages/typescript/common/lib/lib.{d.ts,es6.d.ts}',
|
||||
'out-build/vs/languages/markdown/common/*.css',
|
||||
'out-build/vs/workbench/browser/media/*-theme.css',
|
||||
'out-build/vs/workbench/browser/media/octicons/**',
|
||||
'out-build/vs/workbench/electron-browser/index.html',
|
||||
'out-build/vs/workbench/electron-main/bootstrap.js',
|
||||
'out-build/vs/workbench/parts/debug/**/*.json',
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
|
||||
import 'vs/css!./octicons/octicons';
|
||||
import {escape} from 'vs/base/common/strings';
|
||||
|
||||
export function expand(text: string): string {
|
||||
return text.replace(/\$\((\w+)\)/g, (match, g1) => {
|
||||
return `<span class="octicon octicon-${g1}"></span>`;
|
||||
});
|
||||
}
|
||||
|
||||
export class OcticonLabel {
|
||||
|
||||
private _container: HTMLElement;
|
||||
|
||||
constructor(container: HTMLElement) {
|
||||
this._container = container;
|
||||
}
|
||||
|
||||
set text(text: string) {
|
||||
let innerHTML = text || '';
|
||||
innerHTML = escape(innerHTML);
|
||||
innerHTML = expand(innerHTML)
|
||||
this._container.innerHTML = innerHTML;
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
|
@ -13,6 +13,7 @@ import {toErrorMessage} from 'vs/base/common/errors';
|
|||
import {Promise} from 'vs/base/common/winjs.base';
|
||||
import {disposeAll, IDisposable} from 'vs/base/common/lifecycle';
|
||||
import {Builder, $} from 'vs/base/browser/builder';
|
||||
import {OcticonLabel} from 'vs/base/browser/ui/octiconLabel/octiconLabel';
|
||||
import {Registry} from 'vs/platform/platform';
|
||||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {IAction} from 'vs/base/common/actions';
|
||||
|
@ -178,54 +179,8 @@ class StatusBarEntryItem implements IStatusbarItem {
|
|||
textContainer = document.createElement('span');
|
||||
}
|
||||
|
||||
// Text Value with support for icons
|
||||
// For example: '${zap} Power is ${zap} on'
|
||||
let textBuffer = '';
|
||||
let iconBuffer = '';
|
||||
let inPlaceholder = false;
|
||||
let text = this.entry.text || '';
|
||||
for (let i = 0, len = text.length; i < len; i++) {
|
||||
|
||||
// Opening $(...
|
||||
if (text[i] === '$' && text[i + 1] === '(') {
|
||||
inPlaceholder = true;
|
||||
i++; // unread the opening '('
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inPlaceholder) {
|
||||
|
||||
// Closing ...)
|
||||
if (text[i] === ')') {
|
||||
if (textBuffer) {
|
||||
textContainer.appendChild(document.createTextNode(textBuffer));
|
||||
textBuffer = '';
|
||||
}
|
||||
|
||||
let iconContainer = document.createElement('span');
|
||||
dom.addClass(iconContainer, `octicon octicon-${iconBuffer}`);
|
||||
textContainer.appendChild(iconContainer);
|
||||
|
||||
iconBuffer = '';
|
||||
inPlaceholder = false;
|
||||
}
|
||||
|
||||
// Icon value
|
||||
else {
|
||||
iconBuffer += text[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Any normal text
|
||||
else {
|
||||
textBuffer += text[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (textBuffer) {
|
||||
textContainer.appendChild(document.createTextNode(textBuffer));
|
||||
}
|
||||
// Label
|
||||
new OcticonLabel(textContainer).text = this.entry.text;
|
||||
|
||||
// Tooltip
|
||||
if (this.entry.tooltip) {
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
'use strict';
|
||||
|
||||
import 'vs/css!./media/workbench';
|
||||
import 'vs/css!./media/octicons/octicons';
|
||||
import {TPromise, Promise, ValueCallback} from 'vs/base/common/winjs.base';
|
||||
import types = require('vs/base/common/types');
|
||||
import {IDisposable, disposeAll} from 'vs/base/common/lifecycle';
|
||||
|
|
Loading…
Reference in New Issue