add check for term length at Load..-Msg

This commit is contained in:
Markus 2020-07-22 19:40:53 +02:00
parent 42bf257b6d
commit f1abf83745
7 changed files with 77 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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 <Windows.h>
#elif defined(__linux__)
#include <sys/ioctl.h>
#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) {

View File

@ -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);


View File

@ -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;
}

View File

@ -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%";

View File

@ -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