Jpp  test_elongated_shower_pde
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JKeypress.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "JSystem/JKeypress.hh"
6 #include "Jeep/JParser.hh"
7 #include "Jeep/JMessage.hh"
8 
9 
10 /**
11  * \file
12  *
13  * Example program to test key board pressings (class JSYSTEM::JKeypress).
14  * \author mdejong
15  */
16 int main(int argc, char* argv[])
17 {
18  using namespace std;
19 
20  bool echo;
21  int timeout_us;
22 
23  try {
24 
25  JParser<> zap("Example program to test key board pressings.");
26 
27  zap['c'] = make_field(echo);
28  zap['t'] = make_field(timeout_us) = 1000;
29 
30  zap(argc, argv);
31  }
32  catch(const exception &error) {
33  FATAL(error.what() << endl);
34  }
35 
36 
37  using namespace JPP;
38 
39  if (true) {
40 
41  cout << "> " << flush;
42 
43  int c = JKeypress(echo).get();
44 
45  cout << endl << "return <" << (char) c << ">" << endl;
46  }
47 
48  if (true) {
49 
50  JKeypress keypress(false);
51 
52  int c = (int) '?';
53 
54  for (int i = 0; i != 10000; ++i) {
55 
56  cout << setw(5) << i << flush << '\r';
57 
58  if (keypress.timeout(timeout_us)) {
59  c = keypress.get();
60  break;
61  }
62  }
63 
64  cout << endl << "return <" << (char) c << ">" << endl;
65  }
66 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
then echo
Keyboard settings for unbuffered input.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
$WORKDIR ev_configure_domsimulator txt echo process $DOM_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DOM_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'