Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

Commit

Permalink
SUM Optimize Changes
Browse files Browse the repository at this point in the history
*M Modify resolution of command `restart` in `modules/commands.hpp`.
 : Simplify `_wsystem()` function arguments.
*D Bump version to "2.1.1 Alpha 10".
  • Loading branch information
ren-yc committed Dec 3, 2022
1 parent 76a7c98 commit f24539e
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 17 deletions.
4 changes: 3 additions & 1 deletion WCH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern vector<wstring> WCH_list_command;
extern set<tuple<int32_t, int32_t, wstring>> WCH_list_clock;
extern set<wstring> WCH_list_task;
extern set<pair<wstring, wstring>> WCH_list_work;
extern wstring WCH_path_exec;
extern wstring WCH_title_window;
extern HWND WCH_handle_window;
extern HWND WCH_handle_tray;
Expand All @@ -50,7 +51,8 @@ extern Json::Reader JSON_Reader;
extern Json::StreamWriterBuilder JSON_SWB;
extern unique_ptr<Json::StreamWriter> JSON_SW;

int32_t wmain([[maybe_unused]] int argc, [[maybe_unused]] wchar_t* argv[]) {
int32_t wmain([[maybe_unused]] int32_t _argc, wchar_t* _argv[]) {
WCH_path_exec = _argv[0];
WCH_Init();
while (true) {
if (WCH_cmd_line) {
Expand Down
1 change: 1 addition & 0 deletions modules/apis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern vector<wstring> WCH_list_command;
extern set<tuple<int32_t, int32_t, wstring>> WCH_list_clock;
extern set<wstring> WCH_list_task;
extern set<pair<wstring, wstring>> WCH_list_work;
extern wstring WCH_path_exec;
extern wstring WCH_title_window;
extern HWND WCH_handle_window;
extern HWND WCH_handle_tray;
Expand Down
2 changes: 1 addition & 1 deletion modules/basic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ vector<wstring> WCH_list_command;
set<tuple<int32_t, int32_t, wstring>> WCH_list_clock;
set<wstring> WCH_list_task;
set<pair<wstring, wstring>> WCH_list_work;
wstring WCH_path_exec;
wstring WCH_title_window;
HWND WCH_handle_window;
HWND WCH_handle_tray;
Expand All @@ -399,6 +400,5 @@ wofstream wfout;
Json::Reader JSON_Reader;
Json::StreamWriterBuilder JSON_SWB;
unique_ptr<Json::StreamWriter> JSON_SW(JSON_SWB.newStreamWriter());
wstring WCH_path_program;

#endif
22 changes: 11 additions & 11 deletions modules/commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern vector<wstring> WCH_list_command;
extern set<tuple<int32_t, int32_t, wstring>> WCH_list_clock;
extern set<wstring> WCH_list_task;
extern set<pair<wstring, wstring>> WCH_list_work;
extern wstring WCH_path_exec;
extern wstring WCH_title_window;
extern HWND WCH_handle_window;
extern HWND WCH_handle_tray;
Expand Down Expand Up @@ -53,17 +54,6 @@ extern unique_ptr<Json::StreamWriter> JSON_SW;
void WCH_save();
void WCH_check_task_loop();

void WCH_restart() {
// Restart the program.
if (WCH_list_command.size() != 1) {
WCH_InputCommandIncorrect();
return;
}
wstring wCommand = L"cd " + WCH_path_program.substr(0, WCH_path_program.rfind(L"\\")) + L" && " + L"start " + WCH_path_program.substr(WCH_path_program.rfind(L"\\") + 1, WCH_path_program.length() - 1);
_wsystem(wCommand.c_str());
WCH_exit();
}

void WCH_clear() {
// Clear console information.
if (WCH_list_command.size() != 1) {
Expand Down Expand Up @@ -109,6 +99,16 @@ void WCH_exit() {
_exit(0);
}

void WCH_restart() {
// Restart the program.
if (WCH_list_command.size() != 1) {
WCH_InputCommandIncorrect();
return;
}
_wsystem((L"START \"\" \"" + WCH_path_exec + L"\"").c_str());
WCH_exit();
}

void WCH_hide() {
// Hide the window.
if (WCH_list_command.size() != 1) {
Expand Down
1 change: 1 addition & 0 deletions modules/file-process.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern vector<wstring> WCH_list_command;
extern set<tuple<int32_t, int32_t, wstring>> WCH_list_clock;
extern set<wstring> WCH_list_task;
extern set<pair<wstring, wstring>> WCH_list_work;
extern wstring WCH_path_exec;
extern wstring WCH_title_window;
extern HWND WCH_handle_window;
extern HWND WCH_handle_tray;
Expand Down
1 change: 1 addition & 0 deletions modules/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern vector<wstring> WCH_list_command;
extern set<tuple<int32_t, int32_t, wstring>> WCH_list_clock;
extern set<wstring> WCH_list_task;
extern set<pair<wstring, wstring>> WCH_list_work;
extern wstring WCH_path_exec;
extern wstring WCH_title_window;
extern HWND WCH_handle_window;
extern HWND WCH_handle_tray;
Expand Down
4 changes: 1 addition & 3 deletions modules/init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern vector<wstring> WCH_list_command;
extern set<tuple<int32_t, int32_t, wstring>> WCH_list_clock;
extern set<wstring> WCH_list_task;
extern set<pair<wstring, wstring>> WCH_list_work;
extern wstring WCH_path_exec;
extern wstring WCH_title_window;
extern HWND WCH_handle_window;
extern HWND WCH_handle_tray;
Expand Down Expand Up @@ -139,9 +140,6 @@ void WCH_Init_Var() {
WCH_title_window.append(L" (");
WCH_title_window.append(WCH_Framework);
WCH_title_window.append(L")");
wchar_t Path[256];
GetModuleFileName(NULL, Path, sizeof(Path) - 1);
WCH_path_program = Path;
}

void WCH_Init_Win() {
Expand Down
2 changes: 1 addition & 1 deletion version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ Contributors: jsh-jsh ren-yc
#define WCH_VER_MAIN L"2.1.1"
#define WCH_VER_TYPE 1
#if WCH_VER_TYPE != 0
#define WCH_VER_BUILD 9
#define WCH_VER_BUILD 10
#endif

0 comments on commit f24539e

Please sign in to comment.