Skip to content

Commit 1567372

Browse files
committed
[new] allow show all project variables
1 parent bdfe1e4 commit 1567372

5 files changed

Lines changed: 83 additions & 0 deletions

File tree

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"mathjs": "^11.5.0",
101101
"micromatch": "^4.0.4",
102102
"node-7z": "^3.0.0",
103+
"table": "^6.8.1",
103104
"vscode-cpptools": "^5.0.0",
104105
"x2js": "3.4.1",
105106
"xml-formatter": "^2.6.1",
@@ -560,6 +561,10 @@
560561
"category": "eide",
561562
"title": "Create a new .clang-format template file"
562563
},
564+
{
565+
"command": "_cl.eide.project.show_proj_vars",
566+
"title": "%eide.project.show_project_vars%"
567+
},
563568
{
564569
"command": "_cl.eide.workspace.build",
565570
"title": "%eide.workspace.build%",
@@ -1325,6 +1330,10 @@
13251330
"command": "_cl.eide.project.close",
13261331
"when": "viewItem == SOLUTION && view == cl.eide.view.projects"
13271332
},
1333+
{
1334+
"command": "_cl.eide.project.show_proj_vars",
1335+
"when": "viewItem == SOLUTION && view == cl.eide.view.projects"
1336+
},
13281337
{
13291338
"command": "_cl.eide.project.excludeSource",
13301339
"group": "inline",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"eide.function.reload.stm8.dev.list": "Reload STM8 Devices List",
1313
"eide.function.reinstall.binaries": "Reinstall eide binaries",
1414

15+
"eide.project.show_project_vars": "Show All Project Variables",
1516
"eide.project.save": "Save Project",
1617
"eide.project.refresh": "Refresh",
1718
"eide.project.save.all": "Save All Projects",

package.nls.zh-CN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"eide.function.reload.stm8.dev.list": "重新加载 STM8 芯片信息列表",
1313
"eide.function.reinstall.binaries": "重新安装 eide binaries",
1414

15+
"eide.project.show_project_vars": "显示所有可用的项目变量",
1516
"eide.project.save": "保存项目",
1617
"eide.project.refresh": "刷新",
1718
"eide.project.save.all": "保存所有项目",

src/EIDEProjectExplorer.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ import * as iarParser from './IarProjectParser';
110110
import * as ArmCpuUtils from './ArmCpuUtils';
111111
import { ShellFlasherIndexItem } from './WebInterface/WebInterface';
112112
import { jsonc } from 'jsonc';
113+
import * as TxtTable from 'table'
113114

114115
enum TreeItemType {
115116
SOLUTION,
@@ -4453,6 +4454,76 @@ export class ProjectExplorer implements CustomConfigurationProvider {
44534454
this.exportLocked = false;
44544455
}
44554456

4457+
async ShowProjectVariables(item: ProjTreeItem) {
4458+
4459+
const prj = this.dataProvider.GetProjectByIndex(item.val.projectIndex);
4460+
const prjVars = prj.getProjectVariables();
4461+
4462+
let key_max_len = 0;
4463+
let val_max_len = 0;
4464+
4465+
let var_lines: string[][] = [
4466+
['Name', 'Value']
4467+
];
4468+
4469+
for (const key in prjVars) {
4470+
4471+
const val = prjVars[key] || '';
4472+
4473+
if (key.length > key_max_len)
4474+
key_max_len = key.length;
4475+
4476+
if (val.length > val_max_len)
4477+
val_max_len = val.length;
4478+
4479+
var_lines.push([key, val]);
4480+
}
4481+
4482+
//
4483+
// make txt table
4484+
//
4485+
4486+
const tableCfg: TxtTable.TableUserConfig = {
4487+
4488+
header: {
4489+
alignment: 'center',
4490+
content: 'Project Variables'
4491+
},
4492+
4493+
columns: {
4494+
0: { width: key_max_len },
4495+
1: { width: val_max_len },
4496+
},
4497+
4498+
border: {
4499+
topBody: `─`,
4500+
topJoin: `┬`,
4501+
topLeft: `┌`,
4502+
topRight: `┐`,
4503+
4504+
bottomBody: `─`,
4505+
bottomJoin: `┴`,
4506+
bottomLeft: `└`,
4507+
bottomRight: `┘`,
4508+
4509+
bodyLeft: `│`,
4510+
bodyRight: `│`,
4511+
bodyJoin: `│`,
4512+
4513+
joinBody: `─`,
4514+
joinLeft: `├`,
4515+
joinRight: `┤`,
4516+
joinJoin: `┼`
4517+
}
4518+
};
4519+
4520+
const vpath = prj.toAbsolutePath('project-variables');
4521+
VirtualDocument.instance().updateDocument(vpath, TxtTable.table(var_lines, tableCfg));
4522+
vscode.window.showTextDocument(
4523+
vscode.Uri.parse(VirtualDocument.instance().getUriByPath(vpath)),
4524+
{ preview: true });
4525+
}
4526+
44564527
async AddSrcDir(item: ProjTreeItem) {
44574528

44584529
const prj = this.dataProvider.GetProjectByIndex(item.val.projectIndex);

src/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export async function activate(context: vscode.ExtensionContext) {
163163
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.refresh', () => projectExplorer.Refresh()));
164164
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.switchMode', (item) => projectExplorer.switchTarget(item)));
165165
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.exportAsTemplate', (item) => projectExplorer.ExportProjectTemplate(item)));
166+
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.show_proj_vars', (item) => projectExplorer.ShowProjectVariables(item)));
166167

167168
// project explorer
168169
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.addSrcDir', (item) => projectExplorer.AddSrcDir(item)));

0 commit comments

Comments
 (0)