Skip to content
This repository has been archived by the owner on Dec 10, 2022. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
guyutongxue committed Aug 14, 2021
1 parent fdc0072 commit c926c1e
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 29 deletions.
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"args": [
// "--help"
"--use-gui",
"--gui-address=http://localhost:3000/config.html",
"--gui-address=http://localhost:3000/pages/config.html",
"--verbose"
],
"externalConsole": false
}
},
"cmake.configureOnOpen": true
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# 更新日志 Change Log

## 3.0.2
*2021.8.14*

- 修复错误的测试文件注释

## 3.0.1
*2021.8.8*

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.21.0)

project(vscch3 VERSION 3.0.1)
project(vscch3 VERSION 3.0.2)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
2 changes: 1 addition & 1 deletion pages/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<v-row justify="center">
<v-col md="9">
<div class="text-h4 text-center pt-2">欢迎使用 VS Code Config Helper!</div>
<div class="subtitle-1 text-center pt-1">谷雨同学制作 · 版本 <code>v3.0.0~alpha</code></div>
<div class="subtitle-1 text-center pt-1">谷雨同学制作 · 版本 <code>{{backendVersion}}</code></div>
</v-col>
</v-row>
<v-row justify="center">
Expand Down
4 changes: 4 additions & 0 deletions pages/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ const vm = new Vue({
// Get folder name (not exe)
this.vscodePath = dirname(v.VscodePath);
}
if ("Version" in v) {
this.backendVersion = v.Version;
}
this.compilers = v.Compilers.map(m => ({
path: dirname(m.Path),
version: m.VersionNumber,
Expand All @@ -82,6 +85,7 @@ const vm = new Vue({
},
data: {
currentStep: 1,
backendVersion: "v3.0.0",
vscodePath: "",
vscodeStatus: "resolved",
mingwTableHeader: [
Expand Down
6 changes: 3 additions & 3 deletions pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
</div>
</v-col>
</v-row>
<v-footer fixed="70px">
<v-footer fixed height="70px">
<v-row justify="center">
<v-col cols="9">
<a href="https://guyutongxue.gitee.io/VSCodeConfigHelper" target="_blank">版本 2.x 主页</a>
Expand Down Expand Up @@ -97,9 +97,9 @@
this.latestVersion = v["tag_name"];
if (v["assets"] && v["assets"].length > 0) {
const asset = v["assets"][0];
githubUrl = asset["browser_download_url"];
this.githubUrl = asset["browser_download_url"];
} else {
githubUrl = v["html_url"];
this.githubUrl = v["html_url"];
}
});
},
Expand Down
3 changes: 3 additions & 0 deletions src/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <unordered_set>
#include <optional>

#include "config.h"

struct CompilerInfo {
std::string Path;
std::string VersionText;
Expand Down Expand Up @@ -61,4 +63,5 @@ inline void to_json(nlohmann::json& j, const Environment& e) {
j["VscodePath"] = nullptr;
}
j["Compilers"] = e.Compilers();
j["Version"] = PROJECT_VERSION;
}
33 changes: 18 additions & 15 deletions src/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ std::string Generator::generateTestFile() {
"按下 "s + (options.UseExternalTerminal ? "F6" : "Ctrl + F5") + " 编译运行。"};
const std::string compileResultComment{"按下 "s +
(options.UseExternalTerminal
? "F5 后,您将在下方弹出的终端(Terminal)"
: "F6 后,您将在弹出的") +
? "F6 后,您将在弹出的"
: "F5 后,您将在下方弹出的终端(Terminal)") +
"窗口中看到这一行字。"};
bool isCpp{options.Language == ConfigOptions::LanguageType::Cpp};
std::string (*c)(const std::string&){nullptr};
Expand All @@ -378,7 +378,7 @@ std::string Generator::generateTestFile() {
c = [](const std::string& s) { return "/* " + s + " */"; };
std::ostringstream oss;
oss << c("VS Code C/C++ 测试代码 \"Hello World\"") << '\n';
oss << c("由 VSCodeConfigHelper 生成") << '\n';
oss << c("由 VSCodeConfigHelper v" PROJECT_VERSION " 生成") << '\n';
oss << '\n';
oss << c("您可以在当前的文件夹(工作文件夹)下编写代码。") << '\n';
oss << '\n';
Expand Down Expand Up @@ -460,7 +460,6 @@ void Generator::generateShortcut() {

void Generator::generate() {
try {
fs::path mingwPath(options.MingwPath);
fs::path dotVscode(fs::path(options.WorkspacePath) / ".vscode");

ExtensionManager extensions(options.VscodePath);
Expand All @@ -475,13 +474,21 @@ void Generator::generate() {
if (options.ShouldInstallL11n) {
extensions.install("ms-ceintl.vscode-language-pack-zh-hans");
}

if (options.UseExternalTerminal) {
saveFile(mingwPath / "pause-console.ps1", Embed::PAUSE_CONSOLE_PS1);
addKeybinding("f6", "workbench.action.tasks.runTask", "run and pause");
}
if (options.ApplyNonAsciiCheck) {
saveFile(mingwPath / "check-ascii.ps1", Embed::CHECK_ASCII_PS1);
if constexpr (Native::isWindows) {
fs::path mingwPath(options.MingwPath);
if (options.UseExternalTerminal) {
saveFile(mingwPath / "pause-console.ps1", Embed::PAUSE_CONSOLE_PS1);
addKeybinding("f6", "workbench.action.tasks.runTask", "run and pause");
}
if (options.ApplyNonAsciiCheck) {
saveFile(mingwPath / "check-ascii.ps1", Embed::CHECK_ASCII_PS1);
}
if (!options.NoSetEnv) {
addToPath(mingwPath);
}
} else {
// *nix specified
// TODO
}

if (fs::exists(dotVscode)) {
Expand All @@ -492,10 +499,6 @@ void Generator::generate() {
generateTasksJson(dotVscode / "tasks.json");
generateLaunchJson(dotVscode / "launch.json");
generatePropertiesJson(dotVscode / "c_cpp_properties.json");

if (!options.NoSetEnv) {
addToPath(mingwPath);
}
if (options.GenerateTestFile == ConfigOptions::GenTestType::Auto) {
if (fs::exists(fs::path(options.WorkspacePath) / "helloworld.cpp")) {
options.GenerateTestFile = ConfigOptions::GenTestType::Never;
Expand Down
6 changes: 5 additions & 1 deletion src/native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// You should have received a copy of the GNU General Public License
// along with VS Code Config Helper. If not, see <http://www.gnu.org/licenses/>.

#ifdef _WIN32

#include "native.h"

#include <conio.h>
Expand Down Expand Up @@ -183,4 +185,6 @@ void checkSystemVersion() {
#endif
}

} // namespace Native
} // namespace Native

#endif // _WIN32
33 changes: 27 additions & 6 deletions src/native.h
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
// Copyright (C) 2021 Guyutongxue
//
//
// This file is part of VS Code Config Helper.
//
//
// VS Code Config Helper is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// VS Code Config Helper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with VS Code Config Helper. If not, see <http://www.gnu.org/licenses/>.

#pragma once

#ifdef _WIN32
#include <windows.h>
#endif

#include <boost/filesystem.hpp>
#include <optional>
#include <string>

namespace Native {

#ifdef _WIN32

std::optional<std::string> browseFolder(const std::string& initDir);

bool createLink(const std::string& link, const std::string& target,
const std::string& description = "", const std::string& args = "");

std::optional<std::string> getRegistry(HKEY hkey, const std::string& path,
const std::string& key, bool expand = false);
std::optional<std::string> getRegistry(HKEY hkey, const std::string& path, const std::string& key,
bool expand = false);

bool setRegistry(HKEY hkey, const std::string& path, const std::string& key,
const std::string& value);
Expand All @@ -48,4 +52,21 @@ char getch();

void checkSystemVersion();

constexpr const bool isWindows{true};

#else

constexpr const bool isWindows{false};

constexpr const char* cCompiler{"gcc"};
constexpr const char* cppCompiler{"g++"};

#ifdef __APPLE__

constexpr const char* cCompiler{"clang"};
constexpr const char* cppCompiler{"clang++"};

#endif // __APPLE__
#endif // _WIN32

} // namespace Native

0 comments on commit c926c1e

Please sign in to comment.