.TH "FBB::OneKey" "3bobcat" "2005\-2023" "libbobcat\-dev_6\&.04\&.00" "One keystroke input" .PP .SH "NAME" FBB::OneKey \- Single keystroke input, not requiring `Return\(cq\& .PP .SH "SYNOPSIS" \fB#include \fP .br Linking option: \fI\-lbobcat\fP .PP .SH "DESCRIPTION" \fBOneKey\fP objects may be used to realize `direct keyboard input\(cq\&: a pressed key becomes available without the need for pressing \fIEnter\fP\&. The characters are obtained from the standard input stream\&. Direct key entry remains in effect for as long as the \fBOneKey\fP object exists\&. Once the object is destroyed the standard input stream will return to its default mode of operation, in which input is `confirmed\(cq\& by a newline character\&. .PP .SH "NAMESPACE" \fBFBB\fP .br All constructors, members, operators and manipulators, mentioned in this man\-page, are defined in the namespace \fBFBB\fP\&. .PP .SH "INHERITS FROM" \- .PP .SH "ENUMERATION" The \fBOneKey::Mode\fP enumeration is used to control echoing of returned characters\&. It has two values: .IP o \fBOFF\fP: returned characters are \fInot\fP echoed to the standard output stream; .IP o \fBON\fP: returned characters \fIare\fP echoed to the standard output stream\&. .SH "CONSTRUCTORS" .IP o \fBOneKey(OneKey::Mode state = OneKey::OFF)\fP: .br This constructor initializes the \fBOneKey\fP input object\&. By default, entered characters are not echoed\&. By constructing the object with the \fBOneKey::ON\fP argument, entered characters are echoed to the standard output stream\&. .IP This construct throws an \fIException\fP exception if it not properly complete\&. The constructor may fail for the following reasons: .IP o the standard input stream is not a tty (e\&.g\&., when the standard input stream is redirected to a file); .IP o the current state of the standard input stream can\(cq\&t be determined; .IP o the standard input stream\(cq\&s state can\(cq\&t be changed to the `direct keyboard input\(cq\& mode\&. .PP Copy and move constructors (and assignment operators) are not available\&. .PP .SH "MEMBER FUNCTIONS" .IP o \fBint get() const\fP: .br Returns the next character from the standard input stream, without the need for pressing \fIEnter\fP\&. .IP o \fBvoid setEcho(OneKey::Mode state)\fP: .br Changes the echo\-state of the \fBOneKey\fP object\&. The argument may be either \fBOneKey::ON\fP or \fBOneKey::OFF\fP\&. .PP .SH "EXAMPLE" .nf /* driver\&.cc */ #include #include #include using namespace std; using namespace FBB; int main() { try { OneKey onekey; cout << \(dq\&Usage: 1: next chars are echoed, 0: no echo, q: quits\en\(dq\&; while (true) { char c; cout << \(dq\&ready\&.\&.\&.\en\(dq\&; cout << \(dq\&Got character \(cq\&\(dq\& << (c = onekey\&.get()) << \(dq\&\(cq\&\en\(dq\&; switch (c) { case \(cq\&1\(cq\&: onekey\&.setEcho(OneKey::ON); break; case \(cq\&0\(cq\&: onekey\&.setEcho(OneKey::OFF); break; case \(cq\&q\(cq\&: return 0; } } } catch (exception const &e) { cout << e\&.what() << endl; return 1; } } .fi .PP .SH "FILES" \fIbobcat/onekey\fP \- defines the class interface .PP .SH "SEE ALSO" \fBbobcat\fP(7), \fBtty\fP(3bobcat) .PP .SH "BUGS" None Reported\&. .PP .SH "BOBCAT PROJECT FILES" .PP .IP o \fIhttps://fbb\-git\&.gitlab\&.io/bobcat/\fP: gitlab project page; .IP o \fIbobcat_6\&.04\&.00\-x\&.dsc\fP: detached signature; .IP o \fIbobcat_6\&.04\&.00\-x\&.tar\&.gz\fP: source archive; .IP o \fIbobcat_6\&.04\&.00\-x_i386\&.changes\fP: change log; .IP o \fIlibbobcat1_6\&.04\&.00\-x_*\&.deb\fP: debian package containing the libraries; .IP o \fIlibbobcat1\-dev_6\&.04\&.00\-x_*\&.deb\fP: debian package containing the libraries, headers and manual pages; .PP .SH "BOBCAT" Bobcat is an acronym of `Brokken\(cq\&s Own Base Classes And Templates\(cq\&\&. .PP .SH "COPYRIGHT" This is free software, distributed under the terms of the GNU General Public License (GPL)\&. .PP .SH "AUTHOR" Frank B\&. Brokken (\fBf\&.b\&.brokken@rug\&.nl\fP)\&. .PP