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

Commit f24539e

Browse files
committed
SUM Optimize Changes
*M Modify resolution of command `restart` in `modules/commands.hpp`. : Simplify `_wsystem()` function arguments. *D Bump version to "2.1.1 Alpha 10".
1 parent 76a7c98 commit f24539e

File tree

8 files changed

+20
-17
lines changed

8 files changed

+20
-17
lines changed

WCH.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern vector<wstring> WCH_list_command;
2525
extern set<tuple<int32_t, int32_t, wstring>> WCH_list_clock;
2626
extern set<wstring> WCH_list_task;
2727
extern set<pair<wstring, wstring>> WCH_list_work;
28+
extern wstring WCH_path_exec;
2829
extern wstring WCH_title_window;
2930
extern HWND WCH_handle_window;
3031
extern HWND WCH_handle_tray;
@@ -50,7 +51,8 @@ extern Json::Reader JSON_Reader;
5051
extern Json::StreamWriterBuilder JSON_SWB;
5152
extern unique_ptr<Json::StreamWriter> JSON_SW;
5253

53-
int32_t wmain([[maybe_unused]] int argc, [[maybe_unused]] wchar_t* argv[]) {
54+
int32_t wmain([[maybe_unused]] int32_t _argc, wchar_t* _argv[]) {
55+
WCH_path_exec = _argv[0];
5456
WCH_Init();
5557
while (true) {
5658
if (WCH_cmd_line) {

modules/apis.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern vector<wstring> WCH_list_command;
2525
extern set<tuple<int32_t, int32_t, wstring>> WCH_list_clock;
2626
extern set<wstring> WCH_list_task;
2727
extern set<pair<wstring, wstring>> WCH_list_work;
28+
extern wstring WCH_path_exec;
2829
extern wstring WCH_title_window;
2930
extern HWND WCH_handle_window;
3031
extern HWND WCH_handle_tray;

modules/basic.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ vector<wstring> WCH_list_command;
375375
set<tuple<int32_t, int32_t, wstring>> WCH_list_clock;
376376
set<wstring> WCH_list_task;
377377
set<pair<wstring, wstring>> WCH_list_work;
378+
wstring WCH_path_exec;
378379
wstring WCH_title_window;
379380
HWND WCH_handle_window;
380381
HWND WCH_handle_tray;
@@ -399,6 +400,5 @@ wofstream wfout;
399400
Json::Reader JSON_Reader;
400401
Json::StreamWriterBuilder JSON_SWB;
401402
unique_ptr<Json::StreamWriter> JSON_SW(JSON_SWB.newStreamWriter());
402-
wstring WCH_path_program;
403403

404404
#endif

modules/commands.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern vector<wstring> WCH_list_command;
2525
extern set<tuple<int32_t, int32_t, wstring>> WCH_list_clock;
2626
extern set<wstring> WCH_list_task;
2727
extern set<pair<wstring, wstring>> WCH_list_work;
28+
extern wstring WCH_path_exec;
2829
extern wstring WCH_title_window;
2930
extern HWND WCH_handle_window;
3031
extern HWND WCH_handle_tray;
@@ -53,17 +54,6 @@ extern unique_ptr<Json::StreamWriter> JSON_SW;
5354
void WCH_save();
5455
void WCH_check_task_loop();
5556

56-
void WCH_restart() {
57-
// Restart the program.
58-
if (WCH_list_command.size() != 1) {
59-
WCH_InputCommandIncorrect();
60-
return;
61-
}
62-
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);
63-
_wsystem(wCommand.c_str());
64-
WCH_exit();
65-
}
66-
6757
void WCH_clear() {
6858
// Clear console information.
6959
if (WCH_list_command.size() != 1) {
@@ -109,6 +99,16 @@ void WCH_exit() {
10999
_exit(0);
110100
}
111101

102+
void WCH_restart() {
103+
// Restart the program.
104+
if (WCH_list_command.size() != 1) {
105+
WCH_InputCommandIncorrect();
106+
return;
107+
}
108+
_wsystem((L"START \"\" \"" + WCH_path_exec + L"\"").c_str());
109+
WCH_exit();
110+
}
111+
112112
void WCH_hide() {
113113
// Hide the window.
114114
if (WCH_list_command.size() != 1) {

modules/file-process.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern vector<wstring> WCH_list_command;
2525
extern set<tuple<int32_t, int32_t, wstring>> WCH_list_clock;
2626
extern set<wstring> WCH_list_task;
2727
extern set<pair<wstring, wstring>> WCH_list_work;
28+
extern wstring WCH_path_exec;
2829
extern wstring WCH_title_window;
2930
extern HWND WCH_handle_window;
3031
extern HWND WCH_handle_tray;

modules/functions.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern vector<wstring> WCH_list_command;
2525
extern set<tuple<int32_t, int32_t, wstring>> WCH_list_clock;
2626
extern set<wstring> WCH_list_task;
2727
extern set<pair<wstring, wstring>> WCH_list_work;
28+
extern wstring WCH_path_exec;
2829
extern wstring WCH_title_window;
2930
extern HWND WCH_handle_window;
3031
extern HWND WCH_handle_tray;

modules/init.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern vector<wstring> WCH_list_command;
2525
extern set<tuple<int32_t, int32_t, wstring>> WCH_list_clock;
2626
extern set<wstring> WCH_list_task;
2727
extern set<pair<wstring, wstring>> WCH_list_work;
28+
extern wstring WCH_path_exec;
2829
extern wstring WCH_title_window;
2930
extern HWND WCH_handle_window;
3031
extern HWND WCH_handle_tray;
@@ -139,9 +140,6 @@ void WCH_Init_Var() {
139140
WCH_title_window.append(L" (");
140141
WCH_title_window.append(WCH_Framework);
141142
WCH_title_window.append(L")");
142-
wchar_t Path[256];
143-
GetModuleFileName(NULL, Path, sizeof(Path) - 1);
144-
WCH_path_program = Path;
145143
}
146144

147145
void WCH_Init_Win() {

version.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ Contributors: jsh-jsh ren-yc
77
#define WCH_VER_MAIN L"2.1.1"
88
#define WCH_VER_TYPE 1
99
#if WCH_VER_TYPE != 0
10-
#define WCH_VER_BUILD 9
10+
#define WCH_VER_BUILD 10
1111
#endif

0 commit comments

Comments
 (0)