当前位置:网站首页>Vscode status bar statusbar
Vscode status bar statusbar
2022-06-30 18:14:00 【Parzivval】
establish statusBar
// Create a status bar , The first parameter is position , The second parameter is priority
myStatusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
// Register commands for the status bar
myStatusBarItem.command = myCommandId;
// Status bar text display
myStatusBarItem.text="Nothing is selected!";
// The content displayed when the mouse is placed on it
myStatusBarItem.tooltip="statusBar test!";
// Add in
subscriptions.push(myStatusBarItem);
by statusBar Create command
// Command name
const myCommandId = 'sample.showSelectionCount';
// Registration order
subscriptions.push(vscode.commands.registerCommand(myCommandId, () => {
// Get the number of rows selected from the editor
const n = getNumberOfSelectedLines(vscode.window.activeTextEditor);
// When you click statusBar Feedback operation performed when : Returns the number of rows selected
vscode.window.showInformationMessage(`Yeah, ${
n} line(s) selected... Keep going!`);
}));
Related functions
// Real time update function
function updateStatusBarItem(): void {
const n = getNumberOfSelectedLines(vscode.window.activeTextEditor);
if (n > 0) {
myStatusBarItem.text = `$(megaphone) ${
n} line(s) selected`;
// Display the status bar when there is a selection
myStatusBarItem.show();
} else {
// Hide the status bar when not selected
myStatusBarItem.hide();
}
}
// Get the selection number function
function getNumberOfSelectedLines(editor: vscode.TextEditor | undefined): number {
let lines = 0;
if (editor) {
lines = editor.selections.reduce((prev: number, curr: {
end: {
line: number; }; start: {
line: number; }; }) => prev + (curr.end.line - curr.start.line), 0);
}
return lines;
}
stay activate Function to run the real-time update function
export function activate({
subscriptions }: vscode.ExtensionContext) {
// Command name
const myCommandId = 'sample.showSelectionCount';
// Registration order
subscriptions.push(vscode.commands.registerCommand(myCommandId, () => {
// Get the number of rows selected from the editor
const n = getNumberOfSelectedLines(vscode.window.activeTextEditor);
// When you click statusBar Feedback operation performed when : Returns the number of rows selected
vscode.window.showInformationMessage(`Yeah, ${
n} line(s) selected... Keep going!`);
}));
// Create a status bar , The first parameter is position , The second parameter is priority
myStatusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
// Register commands for the status bar
myStatusBarItem.command = myCommandId;
// Status bar text display
myStatusBarItem.text="Nothing is selected!";
// The content displayed when the mouse is placed on it
myStatusBarItem.tooltip="statusBar test!";
// Add in
subscriptions.push(myStatusBarItem);
// register some listener that make sure the status bar
// item always up-to-date
subscriptions.push(vscode.window.onDidChangeActiveTextEditor(updateStatusBarItem));
subscriptions.push(vscode.window.onDidChangeTextEditorSelection(updateStatusBarItem));
// update status bar item once at start
updateStatusBarItem();
}
边栏推荐
- Redis (I) - data type
- Redis (VIII) - enterprise level solution (I)
- 【机器学习】K-means聚类分析
- The gates of Europe
- If you want to learn software testing, you must see series, 2022 software testing engineer's career development
- Distributed machine learning: model average Ma and elastic average easgd (pyspark)
- [cloud resident co creation] Huawei iconnect enables IOT terminals to connect at one touch
- 报名“互联网+”大赛华为云命题,诸多礼品任你拿!
- Design and principle of tubes responsive data system
- 2022上半年盘点:20+主流数据库重大更新及技术要点汇总
猜你喜欢

又一篇CVPR 2022论文被指抄袭,平安保险研究者控诉IBM苏黎世团队

The new Post-00 Software Test Engineer in 2022 is a champion

TCP session hijacking based on hunt1.5
![The company was jailed for nonstandard bug during the test ~ [cartoon version]](/img/cd/42ab3fc0000fa7dfe2ac89de3486e4.jpg)
The company was jailed for nonstandard bug during the test ~ [cartoon version]

Zero foundation can also be an apple blockbuster! This free tool can help you render, make special effects and show silky slides

MySQL advanced - basic index and seven joins

AnimeSR:可学习的降质算子与新的真实世界动漫VSR数据集

Php8.0 environment detailed installation tutorial

Communication network electronic billing system based on SSH

Redis (VI) - master-slave replication
随机推荐
Apache parsing vulnerability (cve-2017-15715)_ Vulnerability recurrence
Openlayers 卷帘地图
Distributed machine learning: model average Ma and elastic average easgd (pyspark)
The company was jailed for nonstandard bug during the test ~ [cartoon version]
又一篇CVPR 2022论文被指抄袭,平安保险研究者控诉IBM苏黎世团队
100 examples of bug records of unity development (the first example) -- shader failure or bug after packaging
[machine learning] K-means clustering analysis
TFTP download kernel, NFS mount file system
ASP. Net generate verification code
TCP session hijacking based on hunt1.5
Deep understanding of JVM (II) - memory structure (II)
[Netease Yunxin] playback demo build: unable to convert parameter 1 from "asyncmodalrunner *" to "std:: nullptr\u T"**
Post penetration file system + uploading and downloading files
每日面试1题-蓝队基础面试题-应急响应(1)应急响应基本思路流程+Windows入侵排查思路
后渗透之文件系统+上传下载文件
基於SSH的網上商城設計
每日面试1题-如何防止CDN防护被绕过
Solve the problem of unable to connect to command metric stream and related problems in the hystrix dashboard
Redis (II) -- persistence
同济、阿里的CVPR 2022最佳学生论文奖研究了什么?这是一作的解读