# | Line 42 | Line 42 | |
---|---|---|
42 | ||
43 | #include <iostream> | |
44 | #include <cstdlib> | |
45 | + | |
46 | + | #ifdef _MSC_VER |
47 | + | #include <Windows.h> |
48 | + | #include <stdio.h> |
49 | + | #include <io.h> |
50 | + | #define isatty _isatty |
51 | + | #define fileno _fileno |
52 | + | #else |
53 | #include <cstdio> | |
54 | #include <sys/ioctl.h> | |
55 | #include <unistd.h> | |
56 | + | #endif |
57 | + | |
58 | #ifdef IS_MPI | |
59 | #include <mpi.h> | |
60 | #endif | |
61 | + | |
62 | #include "utils/ProgressBar.hpp" | |
63 | ||
64 | using namespace std; | |
# | Line 85 | Line 96 | namespace OpenMD { | |
96 | // only do the progress bar if we are actually running in a tty: | |
97 | if (isatty(fileno(stdout)) && (getenv("SGE_TASK_ID")==NULL)) { | |
98 | // get the window width: | |
99 | + | |
100 | + | #ifdef _MSC_VER |
101 | + | CONSOLE_SCREEN_BUFFER_INFO csbi; |
102 | + | int ret = GetConsoleScreenBufferInfo(GetStdHandle( STD_OUTPUT_HANDLE ), |
103 | + | &csbi); |
104 | + | if(ret) { |
105 | + | width = csbi.dwSize.X; |
106 | + | } |
107 | + | #else |
108 | struct winsize w; | |
109 | ioctl(fileno(stdout), TIOCGWINSZ, &w); | |
110 | width = w.ws_col; | |
111 | + | #endif |
112 | ||
113 | // handle the case when the width is returned as a nonsensical value. | |
114 | if (width <= 0) width = 80; | |
# | Line 114 | Line 135 | namespace OpenMD { | |
135 | struct tm * ender = localtime(&end_); | |
136 | char buffer[22]; | |
137 | strftime(buffer, 22, "%a %b %d @ %I:%M %p", ender); | |
138 | < | |
138 | > | |
139 | > | #ifdef _MSC_VER |
140 | > | csbi.dwCursorPosition.X = 0; |
141 | > | SetConsoleCursorPosition(hConsole, csbi.dwCursorPosition); |
142 | > | #else |
143 | cout << '\r'; | |
144 | + | #endif |
145 | cout.width(3); | |
146 | cout << right << int(percent); | |
147 | cout.width(3); |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |