~lidaobing/+junk/zhcon

« back to all changes in this revision

Viewing changes to src/inputmanager.h

  • Committer: LI Daobing
  • Date: 2008-11-04 04:39:18 UTC
  • Revision ID: lidaobing@gmail.com-20081104043918-nfwwvgfb0uied0mt
importĀ 1:0.2.6-5.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// vi:ts=4:shiftwidth=4:expandtab
 
2
/***************************************************************************
 
3
                          inputmanager.h  -  description
 
4
                             -------------------
 
5
    begin                : Sun Sep 9 2001
 
6
    copyright            : (C) 2001 by ejoy
 
7
    email                : ejoy@users.sourceforge.net
 
8
 ***************************************************************************/
 
9
 
 
10
/***************************************************************************
 
11
 *                                                                         *
 
12
 *   This program is free software; you can redistribute it and/or modify  *
 
13
 *   it under the terms of the GNU General Public License as published by  *
 
14
 *   the Free Software Foundation; either version 2 of the License, or     *
 
15
 *   (at your option) any later version.                                   *
 
16
 *                                                                         *
 
17
 ***************************************************************************/
 
18
 
 
19
#ifndef INPUTMANAGER_H
 
20
#define INPUTMANAGER_H
 
21
 
 
22
 
 
23
/**
 
24
  *@author ejoy
 
25
  */
 
26
using namespace std;
 
27
#include <cassert>
 
28
#include <vector>
 
29
#include <sys/types.h>
 
30
 
 
31
#include "mouse.h"
 
32
#if defined(__FreeBSD__)
 
33
    #include <sys/kbio.h>
 
34
#endif
 
35
 
 
36
#define BUFSIZE 8192
 
37
class Zhcon;
 
38
class Console;
 
39
class InputServer;
 
40
class InputClient;
 
41
class ImmInfo;
 
42
class ConfigFile;
 
43
class Window;
 
44
 
 
45
typedef struct InputEvt_t {
 
46
    enum Oper {Nothing, SetEnco, AutoEncoSwitch};
 
47
    Oper oper;
 
48
    int  sub;
 
49
} InputEvt;
 
50
 
 
51
class InputManager {
 
52
    friend class ConfigServer;
 
53
    public:
 
54
    enum InputStyle {NativeBar,OverSpot};
 
55
    InputManager(Console * pCon, InputStyle style,
 
56
            string& OverSpotColors, string& NativeBarColors);
 
57
    ~InputManager();
 
58
    static void SetTty(int confd, int ttyno, int ttyfd);
 
59
    void Process(InputEvt &evt);
 
60
 
 
61
    void LoadImmInfo(ConfigFile& f);
 
62
    void Show();
 
63
    void Hide();
 
64
    void Redraw();
 
65
    void PromptMode();
 
66
    private:
 
67
    void ProcessKey(char c, InputEvt &evt);
 
68
    int  GetShiftState();
 
69
    bool ProcessSysKey(char c, InputEvt &evt);
 
70
    bool ProcessInputKey(char c);
 
71
    class Mouse mMouse;
 
72
 
 
73
    void WriteClient(char c);
 
74
    void WriteClient(string & s);
 
75
    void OutChar(char c);
 
76
    void Active();
 
77
    void DisActive();
 
78
    void SetVtSize();
 
79
    void DoCtrlShift();
 
80
    bool LoadImm(ImmInfo& rInfo);
 
81
    void DoCtrlSpace();
 
82
    void MenuMode();
 
83
 
 
84
    void KDSysSet();
 
85
    void KDSysRestore();
 
86
    void KDInputSet();
 
87
    void KDInputRestore();
 
88
    void ChangeStyle(InputStyle style);
 
89
    void HelpShow();
 
90
    void HelpHide();
 
91
 
 
92
    static int mConFd, mConNo, mTtyFd;
 
93
    fd_set mFdSet;
 
94
 
 
95
    char mInputBuf[BUFSIZE];
 
96
    char mOutputBuf[BUFSIZE];
 
97
    int mInputRead;
 
98
    int mOutputRead;
 
99
#if defined(linux)
 
100
    struct KeyMap {
 
101
        unsigned char mTable;
 
102
        unsigned char mIndex;
 
103
        unsigned short mOldValue;
 
104
        unsigned short mNewValue;
 
105
    };
 
106
    static KeyMap mKDSysMap[];
 
107
    static KeyMap mKDInputMap[];
 
108
#elif defined(__FreeBSD__)
 
109
    static keymap_t mKDSysOld, mKDSysNew;
 
110
    static keymap_t mKDInputOld, mKDInputNew;
 
111
#endif
 
112
    static bool mKDSysSaved;
 
113
    static bool mKDInputSaved;
 
114
    Zhcon *mpOwner;
 
115
    Console *mpCon;
 
116
    InputServer *mpInputServer;
 
117
    InputClient *mpInputClient;
 
118
    int mClientFd;
 
119
    bool mActive;
 
120
    bool mClientVisible;
 
121
    ImmInfo* mpCurImm;
 
122
    vector < ImmInfo > mImmTable;
 
123
    InputStyle mStyle;
 
124
    string msOverSpotColors;
 
125
    string msNativeBarColors;
 
126
    Window *mpHelpWin;
 
127
};
 
128
 
 
129
#endif