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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
  
     | 
    
      #ifndef QTERMDECODE_H
#define QTERMDECODE_H
#include <QtCore/QObject>
#include <QtCore/QTextCodec>
class QTextDecoder;
namespace QTerm
{
class Decode;
class Buffer;
// this for FSM
typedef void (Decode::*StateFunc)();
struct StateOption {
    int byte;  // char value to look for; -1==end/default
    StateFunc action;
    StateOption *nextState;
};
class Decode : public QObject
{
    Q_OBJECT
public:
    Decode(Buffer *, QTextCodec * codec);
    ~Decode();
    // translate data from telnet socket to our own buffer
    void decode(const char *cstr, int length);
    bool bellReceive() {
        return m_bBell;
    }
//signals:
// void decodeFinished();
private:
// escape sequence actions
// you'd better see FSM structure array in Decode.cpp
    void nextLine();
    void getAttr();
    void setMargins();
    // char screen functions
    void deleteStr();
    void deleteLine();
    void insertStr();
    void insertLine();
    void eraseStr();
    void eraseLine();
    void eraseScreen();
    // cursor functions
    void saveCursor();
    void restoreCursor();
    void cursorLeft();
    void cursorDown();
    void cursorRight();
    void cursorUp();
    void cursorPosition();
    void reverseIndex();
    void index();
    /*****************************************************************************/
// other escape sequence actions
    void normalInput();
    // action parameters
    void clearParam();
    void paramDigit();
    void nextParam();
    // non-printing characters
    void cr(), lf(), ff(), bell(), tab(), bs();
    void cleanupState();
    void setMode();
    void resetMode();
    void saveMode();
    void restoreMode();
    void terminalAttribute();
    void test();
signals:
    void mouseMode(bool);
private:
    bool m_bBell;
    short m_curAttr, m_defAttr;
    // ********** ansi decoder states ****************
    StateOption *currentState;
    static StateOption normalState[], escState[], bracketState[], privateState[];
    // ********** decoder  *****************
    const char *inputData;
    int inputLength, dataIndex;
    int nParam, param[30];
    bool bParam;
    bool bSaveMode[30];
    bool bCurMode[30];
    Buffer * m_pBuffer;
    QTextCodec * m_decoder;
    QTextCodec::ConverterState * m_state;
    //bool CheckESCState(char next);
    bool m_test;
    bool m_attrHack;
};
} // namespace QTerm
#endif
 
     |