#include "yconsole.h" #include #include namespace YConsole { int WaitForInput() { FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); return _getch(); } void WriteLine(std::string text) { std::cout.write(text.c_str(),int(text.length())); std::cout << std::endl; } void NewLine() { std::cout << std::endl; } void ReadLine(std::string *input) { FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); int i = _getch(); if(i == 13) { NewLine(); } else { char c = char(i); std::cout.write(&c,1); input += char(i) return ReadLine(input + char(i)); } } void SetTitle(std::string title) { int nSize = MultiByteToWideChar(CP_ACP, 0, title.c_str(), -1, NULL, 0); LPWSTR ptr_title = new WCHAR[nSize]; MultiByteToWideChar(CP_ACP, 0, title.c_str(), -1, ptr_title, nSize); SetConsoleTitle(ptr_title); delete []ptr_title; } }