FBB::OneKey(3bobcat) | One keystroke input | FBB::OneKey(3bobcat) |
FBB::OneKey - Single keystroke input, not requiring `Return’
#include <bobcat/onekey>
Linking option: -lbobcat
OneKey objects may be used to realize `direct keyboard input’: a pressed key becomes available without the need for pressing Enter. The characters are obtained from the standard input stream. Direct key entry remains in effect for as long as the OneKey object exists. Once the object is destroyed the standard input stream will return to its default mode of operation, in which input is `confirmed’ by a newline character.
FBB
All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace FBB.
-
The OneKey::Mode enumeration is used to control echoing of returned characters. It has two values:
Copy and move constructors (and assignment operators) are not available.
/*
driver.cc */ #include <iostream> #include <string> #include <bobcat/onekey> using namespace std; using namespace FBB; int main() {
try
{
OneKey onekey;
cout << "Usage: 1: next chars are echoed, 0: no echo, q: quits\n";
while (true)
{
char c;
cout << "ready...\n";
cout << "Got character ’" << (c = onekey.get()) << "’\n";
switch (c)
{
case ’1’:
onekey.setEcho(OneKey::ON);
break;
case ’0’:
onekey.setEcho(OneKey::OFF);
break;
case ’q’:
return 0;
}
}
}
catch (exception const &e)
{
cout << e.what() << endl;
return 1;
} }
bobcat/onekey - defines the class interface
None Reported.
Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.
This is free software, distributed under the terms of the GNU General Public License (GPL).
Frank B. Brokken (f.b.brokken@rug.nl).
2005-2022 | libbobcat-dev_6.02.02 |