浏览代码

Detect console with on Windows

Signed-off-by: Nils Maier <maierman@web.de>
Nils Maier 13 年之前
父节点
当前提交
11b9f3ebe2
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      src/ConsoleStatCalc.cc

+ 5 - 0
src/ConsoleStatCalc.cc

@@ -296,6 +296,11 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
       cols = std::max(0, (int)size.ws_col-1);
     }
 #endif // HAVE_TERMIOS_H
+#else // __MINGW32__
+    CONSOLE_SCREEN_BUFFER_INFO info;
+    if(::GetConsoleScreenBufferInfo(::GetStdHandle(STD_OUTPUT_HANDLE), &info)) {
+      cols = std::max(0, info.dwSize.X - 2);
+    }
 #endif // !__MINGW32__
     std::string line(cols, ' ');
     global::cout()->printf("\r%s\r", line.c_str());