Jpp  17.2.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JKeypress.cc File Reference

Example program to test key board pressings (class JSYSTEM::JKeypress). More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JSystem/JKeypress.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Detailed Description

Example program to test key board pressings (class JSYSTEM::JKeypress).

Author
mdejong

Definition in file JKeypress.cc.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 16 of file JKeypress.cc.

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:1517
then echo
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
#define FATAL(A)
Definition: JMessage.hh:67
$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 &))'