else\r
return 0;\r
}\r
- \r
+\r
+static void\r
+PrintStatusStream(std::stringstream &output, int columns, int stdout_is_tty)\r
+{\r
+ s_output = output.str();\r
+\r
+ if (stdout_is_tty) {\r
+ if(s.length() > columns) {\r
+ s.resize(columns - 3);\r
+ s.append("..");\r
+ }\r
+ else if(s.length() < columns) {\r
+ for(int i = 0; i < s.length() - columns; i++)\r
+ s.append(" ");\r
+ }\r
+ }\r
+\r
+ if (stdout_is_tty) {\r
+ std::cout << s_output.c_str() << "\r";\r
+ }\r
+ else {\r
+ std::cout << s_output.c_str() << std::endl;\r
+ }\r
+\r
+ std::cout.flush();\r
+}\r
\r
void*\r
CCore::StatusLoop(void* data)\r
columns = ws.ws_col;\r
}\r
\r
-\r
while(Core->isRunning()) {\r
if(Settings->GetI("forcereannounce") > 0 && loopcount >= Settings->GetI("forcereannounce")*60) {\r
loopcount = 0;\r
eta -= (eta/60)*60;\r
}\r
output << eta << "s";\r
- s_output = output.str();\r
\r
- if (stdout_is_tty) {\r
- if(s_output.length() > columns) {\r
- s_output.resize(columns - 3);\r
- s_output.append("..");\r
- }\r
- else if(s_output.length() < columns) {\r
- for(int i = 0; i < s_output.length() - columns; i++)\r
- s_output.append(" ");\r
- }\r
- }\r
- if (stdout_is_tty) {\r
- std::cout << s_output.c_str() << "\r";\r
- }\r
- else {\r
- std::cout << s_output.c_str() << std::endl;\r
- }\r
-\r
- \r
- std::cout.flush();\r
+ PrintStatusStream(output, columns, stdout_is_tty);\r
output.str("");\r
\r
sleep(1);\r