From f1abf83745f0aa96adfd134893da7dd96ff27c03 Mon Sep 17 00:00:00 2001 From: Markus Date: Wed, 22 Jul 2020 19:40:53 +0200 Subject: [PATCH] add check for term length at Load..-Msg --- build-S_New4-Desktop-Debug/.qmake.stash | 23 +++++++++++++++++++ build-S_New4-Desktop-Release/.qmake.stash | 23 +++++++++++++++++++ src/pageManager.cpp | 27 ++++++++++++++++++++++- src/pageManager.h | 2 ++ src/parameterManager.cpp | 2 +- src/parameterManager.h | 2 +- src/programManager.cpp | 1 + 7 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 build-S_New4-Desktop-Debug/.qmake.stash create mode 100644 build-S_New4-Desktop-Release/.qmake.stash diff --git a/build-S_New4-Desktop-Debug/.qmake.stash b/build-S_New4-Desktop-Debug/.qmake.stash new file mode 100644 index 0000000..d6e97ef --- /dev/null +++ b/build-S_New4-Desktop-Debug/.qmake.stash @@ -0,0 +1,23 @@ +QMAKE_CXX.QT_COMPILER_STDCXX = 201402L +QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 9 +QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3 +QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 +QMAKE_CXX.COMPILER_MACROS = \ + QT_COMPILER_STDCXX \ + QMAKE_GCC_MAJOR_VERSION \ + QMAKE_GCC_MINOR_VERSION \ + QMAKE_GCC_PATCH_VERSION +QMAKE_CXX.INCDIRS = \ + /usr/include/c++/9 \ + /usr/include/x86_64-linux-gnu/c++/9 \ + /usr/include/c++/9/backward \ + /usr/lib/gcc/x86_64-linux-gnu/9/include \ + /usr/local/include \ + /usr/include/x86_64-linux-gnu \ + /usr/include +QMAKE_CXX.LIBDIRS = \ + /usr/lib/gcc/x86_64-linux-gnu/9 \ + /usr/lib/x86_64-linux-gnu \ + /usr/lib \ + /lib/x86_64-linux-gnu \ + /lib diff --git a/build-S_New4-Desktop-Release/.qmake.stash b/build-S_New4-Desktop-Release/.qmake.stash new file mode 100644 index 0000000..d6e97ef --- /dev/null +++ b/build-S_New4-Desktop-Release/.qmake.stash @@ -0,0 +1,23 @@ +QMAKE_CXX.QT_COMPILER_STDCXX = 201402L +QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 9 +QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3 +QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 +QMAKE_CXX.COMPILER_MACROS = \ + QT_COMPILER_STDCXX \ + QMAKE_GCC_MAJOR_VERSION \ + QMAKE_GCC_MINOR_VERSION \ + QMAKE_GCC_PATCH_VERSION +QMAKE_CXX.INCDIRS = \ + /usr/include/c++/9 \ + /usr/include/x86_64-linux-gnu/c++/9 \ + /usr/include/c++/9/backward \ + /usr/lib/gcc/x86_64-linux-gnu/9/include \ + /usr/local/include \ + /usr/include/x86_64-linux-gnu \ + /usr/include +QMAKE_CXX.LIBDIRS = \ + /usr/lib/gcc/x86_64-linux-gnu/9 \ + /usr/lib/x86_64-linux-gnu \ + /usr/lib \ + /lib/x86_64-linux-gnu \ + /lib diff --git a/src/pageManager.cpp b/src/pageManager.cpp index 804d812..4ff63f1 100644 --- a/src/pageManager.cpp +++ b/src/pageManager.cpp @@ -49,6 +49,28 @@ static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) return written; } + + +#if defined(_WIN32) +#define WIN32_LEAN_AND_MEAN +#define VC_EXTRALEAN +#include +#elif defined(__linux__) +#include +#endif // Windows/Linux + +void PageManager::get_terminal_size(int& width) { +#if defined(_WIN32) + CONSOLE_SCREEN_BUFFER_INFO csbi; + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); + width = (int)(csbi.dwSize.X); +#elif defined(__linux__) + struct winsize w; + ioctl(fileno(stdout), TIOCGWINSZ, &w); + width = (int)(w.ws_col); +#endif // Windows/Linux +} + Reply PageManager::getServerRequest(std::string Url, bool useCookies, std::string data, bool generateCookieFile, bool UrlAfterRedirectOnlyNeeded) { CURL *curl; @@ -57,8 +79,11 @@ Reply PageManager::getServerRequest(std::string Url, bool useCookies, std::strin char *url; std::string returnUrl; + + int width; + get_terminal_size(width); //info ausgabe - std::cout << ( "\33[2K\rLade: '" + Url + "'..." + ((debugMode) ? "\n" : "" )) << std::flush; + std::cout << ( "\33[2K\rLade: '" + std::string(Url).erase( (((width - 12) < (int)Url.length()) ? (width - 12) : Url.length() ) ) + "'..." + ((debugMode) ? "\n" : "" )) << std::flush; curl = curl_easy_init(); if(!curl) { diff --git a/src/pageManager.h b/src/pageManager.h index cd3749c..b8777b0 100644 --- a/src/pageManager.h +++ b/src/pageManager.h @@ -30,6 +30,8 @@ public: void setCookieFilePath(std::string path); void setDebugMode(bool status); + void get_terminal_size(int& width); + Reply getServerRequest(std::string Url, bool useCookies = false, std::string data = "", bool generateCookieFile = false, bool UrlAfterRedirectOnlyNeeded = false); int downLoadToFile(std::string filePath, std::string url); diff --git a/src/parameterManager.cpp b/src/parameterManager.cpp index 421badf..f691478 100644 --- a/src/parameterManager.cpp +++ b/src/parameterManager.cpp @@ -1505,7 +1505,7 @@ int unterOption_printLogFile(Settings *settings, int argc, char **argv) } if(!printMode && !ClearMode) { - std::cout << " => Error: Fehlende Parameter: -p oder -c." << std::endl; + std::cout << " => Error: Fehlende Parameter: -p, --print oder -C, --colorless." << std::endl; std::cout << "\"" << settings->programName << " log --help\" liefert weitere Informationen." << std::endl; return 34; } diff --git a/src/parameterManager.h b/src/parameterManager.h index ed962c2..6ee6bd9 100644 --- a/src/parameterManager.h +++ b/src/parameterManager.h @@ -92,7 +92,7 @@ struct Settings { proxy_ip = "127.0.0.1", languages = "GerDub,GerSub,Eng,", genaueHoster = "", - version = "4.2.0", + version = "4.2.1", defaultFileVersion="1.8", default_checkPath = "", default_Searchmuster = "S%Staffel%E%Folge%"; diff --git a/src/programManager.cpp b/src/programManager.cpp index 81a7765..c1a1e02 100644 --- a/src/programManager.cpp +++ b/src/programManager.cpp @@ -470,6 +470,7 @@ int ProgramManager::defaultModus(Settings *settings) std::cerr << ">>> Debug In " << __FUNCTION__ << ": getServerRequest failed when download season page." << std::endl; return 40; } + int maxFolge = pageManager.counterContains(tmp_reply.html, "/episode-%i"); //Print seasons