- Add
.gitignore and CMakeLists.txt files.
- Select
adaptive width for the process bar. when the width of the output message is larger than the width of the terminal, the message line can not be flushed. This can be solved by selecting a suitable width of the the process bar at the beginning (the origin width is 40).
- The
adaptive width module works well on both ubuntu and windows.
int width = []() {
#ifdef __linux__
struct winsize win {};
ioctl(0, TIOCGWINSZ, &win);
unsigned short width = win.ws_col;
#else
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
unsigned short width = csbi.srWindow.Right - csbi.srWindow.Left;
#endif
// return the space left for process bar
// '60' is an experience value to exclude other output info, such as percent, time elapsed, etc.
return std::max((int)width - 60, 1);
}();
