fix: better keyboard handling
This commit is contained in:
parent
3cf6e728d0
commit
760cda8c47
|
@ -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;
|
try {
|
||||||
|
//read one, and eat the rest
|
||||||
|
current = System.in.read();
|
||||||
|
eatInput();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
return (current == 13) ? 10 : current;
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
protected void eatInput() {
|
||||||
lastchar = ch;
|
try {
|
||||||
try {
|
while(System.in.available() > 0) {
|
||||||
ch = System.in.read();
|
int eaten = System.in.read();
|
||||||
System.in.read();
|
|
||||||
} catch (IOException ioe) {
|
|
||||||
}
|
}
|
||||||
} while (ch != 10);
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
return lastchar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue