Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
"preLaunchTask": "npm: compile"
}
]
}
13 changes: 1 addition & 12 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,4 @@ vsc-extension-quickstart.md
**/eslint.config.mjs
**/*.map
**/*.ts
**/.vscode-test.*
**/node_modules/**
**/.git/**
**/package-lock.json
**/.DS_Store
**/Thumbs.db
**/*.log
**/coverage/**
**/dist/**
**/.cache/**
**/.temp/**
**/.tmp/**
**/.vscode-test.*
19 changes: 10 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"repository": {
"url": "https://github.com/RT-Thread/vscode-rt-smart"
},
"workspaces": [
"src/vue"
],
"engines": {
"vscode": "^1.96.0"
},
Expand Down Expand Up @@ -173,7 +170,7 @@
},
"scripts": {
"vscode:prepublish": "npm run compile",
"build:vue": "npm run build --workspace=smart-vue",
"build:vue": "cd src/vue && npm run build",
"compile": "npm run build:vue && tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "npm run compile && npm run lint",
Expand All @@ -185,7 +182,8 @@
"element-plus": "^2.4.2",
"marked": "^14.1.3",
"vue": "^3.3.8",
"vue-router": "^4.5.0"
"vue-router": "^4.5.0",
"winreg": "^1.2.4"
},
"extensionDependencies": [
"ms-python.python"
Expand Down
81 changes: 72 additions & 9 deletions src/terminal.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,99 @@
import * as vscode from 'vscode';
import * as path from 'path';
import * as os from 'os';
import { getExtensionPath, isRTThreadWorksapce } from './api';
import { Constants } from './constants';
import { getCurrentProject } from './project/cmd';

let _terminal: vscode.Terminal | undefined;

const Registry = require('winreg');

export function initTerminal() {
let terminal = vscode.window.activeTerminal;

if (terminal) {
_terminal = terminal;
// change terminal name to RT-Thread
let name = Constants.TERMINAL_LABLE;
vscode.commands.executeCommand("workbench.action.terminal.renameWithArg", { name });
};
}
}

export function getTerminal(): vscode.Terminal | undefined {
if (!_terminal) {
let extensionPath = getExtensionPath();
if (extensionPath) {
let iconPath: vscode.Uri | vscode.ThemeIcon = vscode.Uri.file(path.join(extensionPath, 'resources', "images", "rt-thread.png"));
if (os.platform() === 'win32') {
const regKey = new Registry({
hive: Registry.HKCR,
key: '\\*\\shell\\ConEmu Here'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢 怎么还会使用ConEmu?Windows下用powershell可以说是完美

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确实,那可以做一个选择,让用户自己选,主要也是习惯了RT-Thread配合ConEmu开发,比较方便

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个PR可以拆成两份提交,一份是修复打包问题,另一份是自动识别ENV的吧

});
regKey.get('Icon', async function (err: any, item: any) {
if (!err && item && item.value) {
let conEmuPath = item.value.replace(/"/g, '').split(',')[0];
let conEmuDir = path.dirname(conEmuPath);
let conEmuBaseDir = path.join(conEmuDir, 'ConEmu');
let venvPath = path.join(conEmuDir, '..', '.venv');
venvPath = path.resolve(venvPath);

vscode.workspace.getConfiguration('terminal').update(
'integrated.env.windows',
{ 'VIRTUAL_ENV': venvPath, 'PATH': `${venvPath}\\Scripts;${process.env.PATH}` },
vscode.ConfigurationTarget.Workspace
);
let conEmuInitCmd = `cmd.exe /k ""${conEmuBaseDir}\\CmdInit.cmd" "${conEmuBaseDir}\\..\\..\\bin\\env-init.bat""`;

let terminal = vscode.window.activeTerminal;
if (terminal) {
_terminal = terminal;
vscode.commands.executeCommand("workbench.action.terminal.renameWithArg", { name: Constants.TERMINAL_LABLE });
_terminal.sendText(conEmuInitCmd, true);
_terminal.show();
}else{
_terminal = terminal;
let extensionPath = getExtensionPath();
let iconPath: vscode.Uri | vscode.ThemeIcon | undefined;
if (extensionPath) {
iconPath = vscode.Uri.file(path.join(extensionPath, 'resources', "images", "rt-thread.png"));
}
const options: vscode.TerminalOptions = {
name: Constants.TERMINAL_LABLE,
iconPath: iconPath,
message: Constants.TERMINAL_LOGO,
};
_terminal = vscode.window.createTerminal(options);
_terminal.sendText(conEmuInitCmd, true);
_terminal.show();
}
} else {
vscode.window.showErrorMessage('无法获取 ConEmu 路径,请确保已安装 ConEmu 并正确注册。');
}
});
}else {
let terminal = vscode.window.activeTerminal;
if (terminal) {
_terminal = terminal;
vscode.commands.executeCommand("workbench.action.terminal.renameWithArg", { name: Constants.TERMINAL_LABLE });
_terminal.show();
}else{
_terminal = terminal;
let extensionPath = getExtensionPath();
let iconPath: vscode.Uri | vscode.ThemeIcon | undefined;
if (extensionPath) {
iconPath = vscode.Uri.file(path.join(extensionPath, 'resources', "images", "rt-thread.png"));
}
const options: vscode.TerminalOptions = {
name: Constants.TERMINAL_LABLE,
iconPath: iconPath,
message: Constants.TERMINAL_LOGO,
};

_terminal = vscode.window.createTerminal(options);
_terminal.show();
}
}
}



export function getTerminal(): vscode.Terminal | undefined {
if (!_terminal) {
initTerminal()
}
return _terminal;
}

Expand Down