libbobcat1-dev_2.02.03-x.tar.gz One keystroke input
2005-2009
NAME
FBB::OneKey - Single keystroke input, not requiring `Return'
SYNOPSIS
#include <bobcat/onekey>
Linking option: -lbobcat
DESCRIPTION
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.
NAMESPACE
FBB
All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace FBB.
INHERITS FROM
-
ENUMERATION
The OneKey::Mode enumeration is used to control echoing of returned
characters. It has two values:
OFF: returned characters are not echoed to the standard
output stream;
ON: returned characters are echoed to the standard output
stream.
CONSTRUCTORS
OneKey(OneKey::Mode state = OneKey::OFF):
This constructor initializes the OneKey input object. By
default, entered characters are not echoed. By constructing the object
with the OneKey::ON argument, entered characters are echoed to
the standard output stream.
The proper completion of this constructor should be checked by calling
the OneKey::verify() member (see below).
The copy constructor (and the overloaded assignement operator) are not
available.
MEMBER FUNCTIONS
int get() const:
Returns the next character from the standard input stream, without the
need for pressing Enter.
void setEcho(OneKey::Mode state):
Changes the echo-state of the OneKey object. The argument may be
either OneKey::ON or OneKey::OFF.
void verify() const:
This operator throws an Errno exception if the OneKey
constructor did not properly complete. It should be called before using any
other OneKey member. The OneKey constructor may fail for the following
reasons:
the standard input stream is not a tty (e.g., when the
standard input stream is redirected to a file);
the current state of the standard input stream can't be
determined;
the standard input stream's state can't be changed to the
`direct keyboard input' mode.
EXAMPLE
/*
driver.cc
*/
#include <iostream>
#include <string>
#include <bobcat/onekey>
using namespace std;
using namespace FBB;
int main()
{
try
{
OneKey onekey;
onekey.verify();
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 (Errno const &e)
{
cout << e.what() << endl;
return e.which();
}
}
FILES
bobcat/onekey - defines the class interface
SEE ALSO
bobcat(7)
BUGS
None Reported.
DISTRIBUTION FILES
bobcat_2.02.03-x.dsc: detached signature;
bobcat_2.02.03-x.tar.gz: source archive;
bobcat_2.02.03-x_i386.changes: change log;
libbobcat1_2.02.03-x_*.deb: debian package holding the
libraries;
libbobcat1-dev_2.02.03-x_*.deb: debian package holding the
libraries, headers and manual pages;
http://sourceforge.net/projects/bobcat: public archive location;
BOBCAT
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.
COPYRIGHT
This is free software, distributed under the terms of the
GNU General Public License (GPL).