本文整理汇总了TypeScript中vscode.window.createStatusBarItem方法的典型用法代码示例。如果您正苦于以下问题:TypeScript window.createStatusBarItem方法的具体用法?TypeScript window.createStatusBarItem怎么用?TypeScript window.createStatusBarItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode.window
的用法示例。
在下文中一共展示了window.createStatusBarItem方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: activate
export function activate(context: ExtensionContext) {
let enabled = true;
let modes: { [uri: string]: Mode; } = Object.create(null);
function getMode(uri: string) {
return modes[uri] || Mode.Paren;
}
const statusBarItem = window.createStatusBarItem(StatusBarAlignment.Right);
statusBarItem.show();
statusBarItem.command = 'parinfer.switchState';
function render(editor: TextEditor) {
const uri = editor.document.uri.toString();
if (!shouldRun(editor.document.fileName)) {
statusBarItem.hide();
return;
}
if (!enabled) {
statusBarItem.text = '$(code)';
statusBarItem.color = '#ccc';
statusBarItem.tooltip = 'Parinfer is disabled';
} else {
const mode = getMode(uri) === Mode.Indent ? 'Indent' : 'Paren';
statusBarItem.text = `$(code) ${ mode }`;
statusBarItem.color = 'white';
statusBarItem.tooltip = `Parinfer is in ${ mode } mode`;
}
statusBarItem.show();
}
function toggleMode() {
const uri = window.activeTextEditor.document.uri.toString();
modes[uri] = getMode(uri) === Mode.Indent ? Mode.Paren : Mode.Indent;
render(window.activeTextEditor);
}
function toggleEnablement() {
enabled = !enabled;
render(window.activeTextEditor);
}
function switchState() {
const uri = window.activeTextEditor.document.uri.toString();
if (!enabled) {
enabled = true;
} else if (getMode(uri) === Mode.Paren) {
modes[uri] = Mode.Indent;
} else {
modes[uri] = Mode.Paren;
enabled = false;
}
render(window.activeTextEditor);
}
function parinfer(editor: TextEditor, position: Position = null) {
const document = editor.document;
const uri = document.uri.toString();
const input = document.getText();
const fn = (getMode(uri) === Mode.Indent && position) ? indentMode : parenMode;
const output = position ? fn(input, fromEditorPosition(position)) : fn(input);
if (typeof output !== 'string') {
return;
}
const range = new Range(new Position(0, 0), document.positionAt(input.length));
editor.edit(builder => builder.replace(range, output));
}
const eventuallyParinfer = debounce(parinfer, 50);
function onSelectionChange({ textEditor }: TextEditorSelectionChangeEvent) {
if (!enabled || !shouldRun(textEditor.document.fileName)) {
return;
}
eventuallyParinfer(textEditor, textEditor.selection.active);
}
function onEditorChange(editor: TextEditor) {
if (!shouldRun(editor.document.fileName)) {
render(editor);
return;
}
if (!enabled) {
return;
}
parinfer(editor);
render(editor);
}
context.subscriptions.push(
//.........这里部分代码省略.........
示例2: constructor
constructor(
private readonly normalizePath: (resource: vscode.Uri) => string | null
) {
this.versionBarEntry = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, Number.MIN_VALUE);
this.onChangeEditorSub = vscode.window.onDidChangeActiveTextEditor(this.showHideStatus, this);
}
示例3: constructor
constructor() {
if (!this._statusBarItem) {
this._statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
}
}
示例4: constructor
constructor(
private readonly telemetryReporter: TelemetryReporter
) {
this._item = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, Number.MIN_VALUE);
this._item.command = 'js.projectStatus.command';
}
示例5: activate
export function activate(context: ExtensionContext) {
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
console.log('Congratulations, your extension "rest-client" is now active!');
let outChannel = window.createOutputChannel('REST');
let statusBarItem = window.createStatusBarItem(StatusBarAlignment.Left)
let restClientSettings = new RestClientSettings();
// The command has been defined in the package.json file
// Now provide the implementation of the command with registerCommand
// The commandId parameter must match the command field in package.json
let disposable = commands.registerCommand('rest-client.request', () => {
let editor = window.activeTextEditor;
if (!editor || !editor.document) {
return;
}
// Get selected text of selected lines or full document
let selectedText: string;
if (editor.selection.isEmpty) {
selectedText = editor.document.getText();
} else {
selectedText = editor.document.getText(editor.selection);
}
if (selectedText === '') {
return;
}
if (restClientSettings.clearOutput) {
outChannel.clear();
}
// clear status bar
statusBarItem.text = `$(cloud-upload)`;
statusBarItem.show();
// parse http request
let httpRequest = RequestParser.parseHttpRequest(selectedText);
if (!httpRequest) {
return;
}
// set http request
let httpClient = new HttpClient(restClientSettings);
httpClient.send(httpRequest)
.then(response => {
let output = `HTTP/${response.httpVersion} ${response.statusCode} ${response.statusMessage}\n`
for (var header in response.headers) {
if (response.headers.hasOwnProperty(header)) {
var value = response.headers[header];
output += `${header}: ${value}\n`
}
}
let body = response.body;
let contentType = response.headers['content-type'];
if (contentType) {
let type = MimeUtility.parse(contentType).type;
if (type === 'application/json') {
body = JSON.stringify(JSON.parse(body), null, 4);
}
}
output += `\n${body}`;
outChannel.appendLine(`${output}\n`);
outChannel.show(true);
statusBarItem.text = ` $(clock) ${response.elapsedMillionSeconds}ms`;
statusBarItem.tooltip = 'duration';
})
.catch(error => {
statusBarItem.text = '';
outChannel.appendLine(`${error}\n`);
outChannel.show(true);
});
});
context.subscriptions.push(disposable);
}
示例6: constructor
constructor() {
this._statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
this._prevModeName = undefined;
}
示例7: constructor
public constructor(options: IVSCodeEditorOptions) {
this.modeStatusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
this.commandStatusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
this.commandStatusBarItem.show();
this.ApplyOptions(options);
}
示例8: doInit
public doInit(indexInProgress: boolean) {
console.log("Crane Initialised...");
this.showIndexingStatusBarMessage();
var statusBarItem: StatusBarItem = window.createStatusBarItem(StatusBarAlignment.Right);
statusBarItem.text = Config.version;
statusBarItem.tooltip = 'Crane (PHP Code-completion) version ' + Config.version;
statusBarItem.show();
var serverDebugMessage: NotificationType<{ type: string, message: string }> = { method: "serverDebugMessage" };
Crane.langClient.onNotification(serverDebugMessage, message => {
switch (message.type) {
case 'info': Debug.info(message.message); break;
case 'error': Debug.error(message.message); break;
case 'warning': Debug.warning(message.message); break;
default: Debug.info(message.message); break;
}
});
var requestType: RequestType<any, any, any> = { method: "workDone" };
Crane.langClient.onRequest(requestType, (tree) => {
// this.projectBuilding = false;
Crane.statusBarItem.text = '$(check) PHP File Indexing Complete!';
// Load settings
let craneSettings = workspace.getConfiguration("crane");
Debug.info("Processing complete!");
if (Config.showBugReport) {
setTimeout(() => {
Crane.statusBarItem.tooltip = "Found a problem with the PHP Intellisense provided by Crane? Click here to file a bug report on Github";
Crane.statusBarItem.text = "$(bug) Found a PHP Intellisense Bug?";
Crane.statusBarItem.command = "crane.reportBug";
Crane.statusBarItem.show();
}, 5000);
} else {
Crane.statusBarItem.hide();
}
});
var types = Config.phpFileTypes;
Debug.info(`Watching these files: {${types.include.join(',')}}`);
var fsw: FileSystemWatcher = workspace.createFileSystemWatcher(`{${types.include.join(',')}}`);
fsw.onDidChange(e => {
workspace.openTextDocument(e).then(document => {
if (document.languageId != 'php') return;
Debug.info('File Changed: ' + e.fsPath);
Crane.langClient.sendRequest({ method: 'buildObjectTreeForDocument' }, {
path: e.fsPath,
text: document.getText()
});
});
});
fsw.onDidCreate(e => {
workspace.openTextDocument(e).then(document => {
if (document.languageId != 'php') return;
Debug.info('File Created: ' + e.fsPath);
Crane.langClient.sendRequest({ method: 'buildObjectTreeForDocument' }, {
path: e.fsPath,
text: document.getText()
});
});
});
fsw.onDidDelete(e => {
Debug.info('File Deleted: ' + e.fsPath);
Crane.langClient.sendRequest({ method: 'deleteFile' }, {
path: e.fsPath
});
});
if (!indexInProgress) {
// Send request to server to build object tree for all workspace files
this.processAllFilesInWorkspace();
}
}
示例9: createStatusBarItem
function createStatusBarItem() {
statusBarItem = window.createStatusBarItem(StatusBarAlignment.Right);
isStatusBarVisible = true;
}
示例10: constructor
constructor(utilities?: Utilities) {
this.statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
this.statusBarItem.command = "extension.sidePreview";
this.statusBarItem.tooltip = Constants.ExtensionConstants.STATUS_BAR_TOOLTIP;
this.utilities = utilities && utilities || new Utilities();
}