fix: better keyboard handling

This commit is contained in:
Brian Matzon 2002-09-03 18:08:52 +00:00
parent 3cf6e728d0
commit 760cda8c47
1 changed files with 18 additions and 15 deletions

View File

@ -552,7 +552,7 @@ public class ALTest extends BasicTest {
try { try {
ch = System.in.read(); ch = System.in.read();
System.in.read(); eatInput();
} catch (IOException ioe) { } catch (IOException ioe) {
} }
@ -999,31 +999,34 @@ public class ALTest extends BasicTest {
if ((ch == 'S') || (ch == 's')) { if ((ch == 'S') || (ch == 's')) {
return 0; return 0;
} }
if (ch == 0) { if (ch == 10) {
return 1; return 1;
} }
} }
} }
protected int CRToContinue() { protected int CRToContinue() {
int ch = 0; int current = -1;
int lastchar = 0;
do {
lastchar = ch;
try { try {
ch = System.in.read(); //read one, and eat the rest
System.in.read(); current = System.in.read();
} catch (IOException ioe) { eatInput();
} catch (Exception e) {
}
return (current == 13) ? 10 : current;
} }
} while (ch != 10);
return lastchar; protected void eatInput() {
try {
while(System.in.available() > 0) {
int eaten = System.in.read();
}
} catch (Exception e) {
}
} }
protected void CRForNextTest() { protected void CRForNextTest() {
System.out.print("\nPress Return to continue on to the next test.\n"); System.out.print("\nPress Return to continue on to the next test.\n");
CRToContinue(); CRToContinue();
} }