File: onekey

package info (click to toggle)
bobcat 2.08.01-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,668 kB
  • ctags: 953
  • sloc: cpp: 10,403; makefile: 9,042; perl: 401; sh: 195
file content (49 lines) | stat: -rw-r--r-- 926 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef INCLUDED_BOBCAT_ONEKEY_
#define INCLUDED_BOBCAT_ONEKEY_

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

namespace FBB
{

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

    public:
        enum Mode
        {
            OFF,      
            ON      
        };

        explicit OneKey(Mode state = OFF);    
//  with g++4-4
//        OneKey(OneKey const &other) = delete;

        ~OneKey();

//  with g++4-4
//        OneKey const &operator=(OneKey const &other) = delete;
        
        int get() const;                // get the next char
        void setEcho(Mode state);

        void verify() const;            // kept for backward compat.

    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