From de4437a7cafe92c67c0425fb301f82fa7925b0ae Mon Sep 17 00:00:00 2001 From: taynpg Date: Thu, 9 Jan 2025 16:50:11 +0800 Subject: [PATCH] =?UTF-8?q?sub=EF=BC=9A=E6=B7=BB=E5=8A=A0=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=A1=A5=E5=85=A8=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=BA=93=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 +++ .vscode/settings.json | 5 +++-- CMakeLists.txt | 1 + client/CMakeLists.txt | 2 +- client/client.cpp | 11 ++++++----- client/client.h | 1 + filecomplete | 1 + 7 files changed, 16 insertions(+), 8 deletions(-) create mode 160000 filecomplete diff --git a/.gitmodules b/.gitmodules index f5e7bbc..9a28246 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "ofen"] path = ofen url = https://www.sinxmiao.cn/taynpg/ofen +[submodule "filecomplete"] + path = filecomplete + url = https://www.sinxmiao.cn/taynpg/filecomplete diff --git a/.vscode/settings.json b/.vscode/settings.json index a053d58..cb7812b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -21,7 +21,7 @@ ], "visualizerFile": "${workspaceRoot}/.vscode/qt5.natvis", "args": [ - "-n", "0" + "-n", "2" ] }, "cmake.environment": { @@ -145,5 +145,6 @@ "text_encoding": "cpp", "*.in": "cpp" }, - "makefile.configureOnOpen": false + "makefile.configureOnOpen": false, + "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools" } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index d381627..e74cecf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ add_subdirectory(net) add_subdirectory(util) add_subdirectory(server) add_subdirectory(client) +add_subdirectory(filecomplete) string(TIMESTAMP VERSION_BUILD_DATE "%Y-%m-%d %H:%M") execute_process( diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index b8a043f..6b44926 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -8,7 +8,7 @@ if (MSVC) endif() add_executable(tsc main.cpp client.h client.cpp config.h config.cpp) -target_link_libraries(tsc PRIVATE trans_net trans_util) +target_link_libraries(tsc PRIVATE trans_net trans_util filecomplete) if (UNIX) target_link_libraries(tsc PRIVATE pthread) endif() diff --git a/client/client.cpp b/client/client.cpp index 3cc8783..8f7601b 100644 --- a/client/client.cpp +++ b/client/client.cpp @@ -67,16 +67,17 @@ void CClient::run(const std::string& ip, const std::string& port) delete bf; logger_->warn("SupportCmd:Get|Up|Down|Cancel|Update"); - char line[512]{}; - while (std::cin.getline(line, 512)) { + fc_append('|'); + while (1) { + char* readline = fc_readline(); if (!th_run_) { break; } - - std::string cmd_input(line); + std::string cmd_input(readline); + fc_free(readline); + std::cout << "" << std::endl; cmd_input = ofen::COfStr::trim(cmd_input); - if (cmd_input == "end") { th_run_ = false; std::this_thread::sleep_for(std::chrono::milliseconds(10)); diff --git a/client/client.h b/client/client.h index 0020872..ed4c3d6 100644 --- a/client/client.h +++ b/client/client.h @@ -7,6 +7,7 @@ #include #include #include +#include using namespace ofen; struct DownClientInfo { diff --git a/filecomplete b/filecomplete new file mode 160000 index 0000000..bbd0d6a --- /dev/null +++ b/filecomplete @@ -0,0 +1 @@ +Subproject commit bbd0d6a2471443e7d019f65207a072c1294b6fd7