From 948976f7ee708f813606588af9de3798d4641130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=8D=9A=E5=87=AF?= Date: Sat, 14 Dec 2024 22:33:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=B7=AF=E5=BE=84=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E7=8A=B6=E6=80=81=E6=A0=8F=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/extension.ts | 3 ++- src/handler/status-bar-handler.ts | 42 ++++++++++++++++++++++--------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 8b47527..047319e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -66,8 +66,9 @@ export function activate(context: vscode.ExtensionContext) { // 循环转换:记录当前选中内容,并且进行转换 let eol: EOL = textEditor.document.eol === vscode.EndOfLine.CRLF ? '\r\n' : '\n'; + // 变量循环转换 2024.04.09 CyclicConversionVariable.onUserSelectionUpdated(selections, textList, eol); - + // 路径循环转换 2024.12.14 CyclicConversionPath.onUserSelectionUpdated(selections, textList, eol); }; diff --git a/src/handler/status-bar-handler.ts b/src/handler/status-bar-handler.ts index cca2e05..3a8d5c4 100644 --- a/src/handler/status-bar-handler.ts +++ b/src/handler/status-bar-handler.ts @@ -2,7 +2,7 @@ import * as vscode from 'vscode'; // docs: https://code.visualstudio.com/api/references/vscode-api#StatusBarItem -let statusBar: vscode.StatusBarItem; +let statusBarItemList: Array = []; /** * 创建状态栏按钮 @@ -10,11 +10,29 @@ let statusBar: vscode.StatusBarItem; * @since 2024-04-07 */ export function createStatusBarItem() { - statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left); - statusBar.text = '$(find-replace)变量转换'; - statusBar.command = 'variable-conversion.convertCase'; - // statusBar.color = 'red'; - // statusBar.show(); + // 变量转换状态栏 2024.04.07 + const createVariableConvertStatusBarItem = () => { + const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left); + // Icon Listing docs: https://code.visualstudio.com/api/references/icons-in-labels#icon-listing + 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 */ export function updateStatusBarItemVisable(selectTextLength: number) { - if (!statusBar) { - return; - } - let editor = vscode.window.activeTextEditor; if (editor && selectTextLength > 0) { - statusBar.show(); + statusBarItemList.forEach(statusBarItem => { + statusBarItem.show(); + }); return; } - statusBar.hide(); + statusBarItemList.forEach(statusBarItem => { + statusBarItem.hide(); + }); } \ No newline at end of file