44#include <OpenMesh/Tools/Utils/conio.hh>
54int kbhit() { return ::_kbhit(); }
55int getch() { return ::_getch(); }
56int getche() { return ::_getche(); }
62#elif defined(WIN32) || defined(__MINGW32__)
69int kbhit() { return ::kbhit(); }
70int getch() { return ::getch(); }
71int getche() { return ::getche(); }
81#if !defined(POSIX_1003_1_2001)
105 static struct termios Otty, Ntty;
112 Ntty.c_lflag &= ~ICANON;
113 Ntty.c_cc[VMIN] = CMIN;
114 Ntty.c_cc[VTIME] = CTIME;
116 if (0 == (error = tcsetattr(0, TCSANOW, &Ntty)))
119 error += ioctl(0, FIONREAD, &cnt);
120 error += tcsetattr(0, TCSANOW, &Otty);
123 select(1,
nullptr,
nullptr,
nullptr, &tv);
125 return (error == 0 ? cnt : -1 );
133 static struct termios Otty, Ntty;
141 Ntty.c_lflag &= ~ICANON;
142 Ntty.c_lflag &= ~ECHO;
143 Ntty.c_cc[VMIN] = CMIN;
144 Ntty.c_cc[VTIME] = CTIME;
150# define FLAG TCSAFLUSH
157 if (0 == (error = tcsetattr(0, FLAG, &Ntty)))
159 error = read(0, &ch, 1 );
160 error += tcsetattr(0, FLAG, &Otty);
162 return (error == 1 ? (
int) ch : -1 );
170 static struct termios Otty, Ntty;
178 Ntty.c_lflag &= ~ICANON;
179 Ntty.c_lflag |= ECHO;
180 Ntty.c_cc[VMIN] = CMIN;
181 Ntty.c_cc[VTIME] = CTIME;
187# define FLAG TCSAFLUSH
194 if (0 == (error = tcsetattr(0, FLAG, &Ntty))) {
195 error = read(0, &ch, 1 );
196 error += tcsetattr(0, FLAG, &Otty);
199 return (error == 1 ? (
int) ch : -1 );
215 char msg[] =
"press key to continue...";
221 *ptr = islower(tmp) ? toupper(tmp) : tolower(tmp);
222 printf(
"\r%s", msg); fflush(stdout);
229 printf(
"\r%s.", msg); fflush(stdout);
231 printf(
"\r%s..", msg); fflush(stdout);