创建路径转换状态栏按钮
This commit is contained in:
parent
2a1cf5488d
commit
948976f7ee
@ -66,8 +66,9 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
|
|
||||||
// 循环转换:记录当前选中内容,并且进行转换
|
// 循环转换:记录当前选中内容,并且进行转换
|
||||||
let eol: EOL = textEditor.document.eol === vscode.EndOfLine.CRLF ? '\r\n' : '\n';
|
let eol: EOL = textEditor.document.eol === vscode.EndOfLine.CRLF ? '\r\n' : '\n';
|
||||||
|
// 变量循环转换 2024.04.09
|
||||||
CyclicConversionVariable.onUserSelectionUpdated(selections, textList, eol);
|
CyclicConversionVariable.onUserSelectionUpdated(selections, textList, eol);
|
||||||
|
// 路径循环转换 2024.12.14
|
||||||
CyclicConversionPath.onUserSelectionUpdated(selections, textList, eol);
|
CyclicConversionPath.onUserSelectionUpdated(selections, textList, eol);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import * as vscode from 'vscode';
|
|||||||
|
|
||||||
// docs: https://code.visualstudio.com/api/references/vscode-api#StatusBarItem
|
// docs: https://code.visualstudio.com/api/references/vscode-api#StatusBarItem
|
||||||
|
|
||||||
let statusBar: vscode.StatusBarItem;
|
let statusBarItemList: Array<vscode.StatusBarItem> = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建状态栏按钮
|
* 创建状态栏按钮
|
||||||
@ -10,11 +10,29 @@ let statusBar: vscode.StatusBarItem;
|
|||||||
* @since 2024-04-07
|
* @since 2024-04-07
|
||||||
*/
|
*/
|
||||||
export function createStatusBarItem() {
|
export function createStatusBarItem() {
|
||||||
statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
|
// 变量转换状态栏 2024.04.07
|
||||||
statusBar.text = '$(find-replace)变量转换';
|
const createVariableConvertStatusBarItem = () => {
|
||||||
statusBar.command = 'variable-conversion.convertCase';
|
const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
|
||||||
// statusBar.color = 'red';
|
// Icon Listing docs: https://code.visualstudio.com/api/references/icons-in-labels#icon-listing
|
||||||
// statusBar.show();
|
statusBarItem.text = '$(find-replace)变量转换';
|
||||||
|
statusBarItem.command = 'variable-conversion.convertCase';
|
||||||
|
// statusBarItem.color = 'red';
|
||||||
|
// statusBarItem.show();
|
||||||
|
return statusBarItem;
|
||||||
|
};
|
||||||
|
// 路径转换状态栏 2024.12.14
|
||||||
|
const createPathConvertStatusBarItem = () => {
|
||||||
|
const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
|
||||||
|
statusBarItem.text = '$(sync-ignored)路径转换'; // italic symbol-null
|
||||||
|
statusBarItem.command = 'variable-conversion.convertPath';
|
||||||
|
statusBarItemList.push(statusBarItem);
|
||||||
|
return statusBarItem;
|
||||||
|
};
|
||||||
|
|
||||||
|
statusBarItemList.push(
|
||||||
|
createVariableConvertStatusBarItem(),
|
||||||
|
createPathConvertStatusBarItem(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,14 +41,14 @@ export function createStatusBarItem() {
|
|||||||
* @since 2024-04-07
|
* @since 2024-04-07
|
||||||
*/
|
*/
|
||||||
export function updateStatusBarItemVisable(selectTextLength: number) {
|
export function updateStatusBarItemVisable(selectTextLength: number) {
|
||||||
if (!statusBar) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let editor = vscode.window.activeTextEditor;
|
let editor = vscode.window.activeTextEditor;
|
||||||
if (editor && selectTextLength > 0) {
|
if (editor && selectTextLength > 0) {
|
||||||
statusBar.show();
|
statusBarItemList.forEach(statusBarItem => {
|
||||||
|
statusBarItem.show();
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
statusBar.hide();
|
statusBarItemList.forEach(statusBarItem => {
|
||||||
|
statusBarItem.hide();
|
||||||
|
});
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user