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