#ifndef INCLUDED_BOBCAT_ONEKEY_
#define INCLUDED_BOBCAT_ONEKEY_

#include <termios.h>
#include <bobcat/exception>

namespace FBB
{

class OneKey
{
    termios     d_saved;
    bool        d_useEcho;          // default false

    public:
        enum Mode
        {
            OFF,
            ON
        };

        explicit OneKey(Mode state = OFF);

        ~OneKey();

        int get() const;                // get the next char
        void setEcho(Mode state);                                   // .f

    private:
        OneKey(OneKey const &other) = delete;
        OneKey const &operator=(OneKey const &other) = delete;

};

inline void OneKey::setEcho(Mode state)
{
    d_useEcho = (state == ON);
}

} // FBB

#endif
