FBB::OneKey(3bobcat)

πŸ’– FBB::OneKey πŸ’–

okay bestie, you're reading the bobcat manual (that's the 3bobcat section of the manual, iykyk) and this page is literally all about FBB::OneKey ✨ put your seatbelt on πŸ¦‹


✨ NAME ✨

FBB::OneKey β€” single keystroke input, not requiring `Return’ πŸŽ€

like... you press a key and it's just there. no Return, no waiting, no drama. periodt.


🌸 SYNOPSIS 🌸

#include <bobcat/onekey>

Linking option: -lbobcat


πŸ¦‹ DESCRIPTION πŸ¦‹

So OneKey objects are how you get direct keyboard input β€” the second a key is pressed, that character is available, and you did not have to press Enter first. Not once. πŸ’…

Where do the characters come from? The standard input stream, bestie. That's the vibe.

Direct key entry stays in effect for as long as your OneKey object exists β€” it's giving main character energy and it holds that energy the whole time it's alive. Once the object is destroyed, the standard input stream goes right back to its default mode of operation, where input is confirmed by a newline character. bye bestie, back to normal 🌈


πŸ‘‘ NAMESPACE πŸ‘‘

FBB

Every single constructor, member, operator and manipulator mentioned on this man-page lives in the FBB namespace. all of them. no strays. 🫢


πŸ’œ INHERITS FROM πŸ’œ

-

(nothing. it inherits from no one. it's self-made. iconic.) 😌


πŸŽ€ ENUMERATION πŸŽ€

The OneKey::Mode enumeration is what controls echoing of the returned characters. It has two values, and only two:

  • OFF β€” the returned characters are not echoed to the standard output stream;
  • ON β€” the 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 (that's the OneKey::OFF default doing its thing ✨). If you construct the object with the OneKey::ON argument instead, then entered characters are echoed to the standard output stream.

This construct throws an Exception exception if it not properly complete. Bestie, it can fail, and here's exactly why:

  • 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.
🚨 no cap: copy and move constructors (and assignment operators) are not available. don't try it. πŸ™ˆ

πŸ’… MEMBER FUNCTIONS πŸ’…

  • int get() const β€” returns the next character from the standard input stream, without the need for pressing Enter. chef's kiss, honestly.
  • void setEcho(OneKey::Mode state) β€” changes the echo-state of the OneKey object. The argument may be either OneKey::ON or OneKey::OFF. switch it up whenever you want πŸ¦‹

πŸ”₯ EXAMPLE πŸ”₯

/*
                              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;
    }
}

πŸ“ FILES πŸ“

bobcat/onekey β€” defines the class interface


🌈 SEE ALSO 🌈

bobcat(7), tty(3bobcat)


πŸ’€ BUGS πŸ’€

None Reported.

(not a single one. we love a clean bug list πŸ’–)


🧚 BOBCAT PROJECT FILES 🧚

Debian Bobcat project files:

  • libbobcat6: debian package containing the shared library, changelog and copyright note;
  • libbobcat-dev: debian package containing the static library, headers, manual pages, and developer info;

🌸 BOBCAT 🌸

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).


πŸ‘‘ AUTHOR πŸ‘‘

Frank B. Brokken (f.b.brokken@rug.nl).


okay that's the whole page bestie, you're officially educated πŸ’…βœ¨ this was FBB::OneKey(3bobcat) from libbobcat-dev_6.15.01, dated 2005-2026 β€” mwah, go forth and read keystrokes with no Return needed πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from