Konsole
Vt102Emulation.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef VT102EMULATION_H
00024 #define VT102EMULATION_H
00025
00026
00027 #include <stdio.h>
00028
00029
00030 #include <QtGui/QKeyEvent>
00031 #include <QtCore/QHash>
00032 #include <QtCore/QTimer>
00033
00034
00035 #include "Emulation.h"
00036 #include "Screen.h"
00037
00038 #define MODE_AppScreen (MODES_SCREEN+0) // Mode #1
00039 #define MODE_AppCuKeys (MODES_SCREEN+1) // Application cursor keys (DECCKM)
00040 #define MODE_AppKeyPad (MODES_SCREEN+2) //
00041 #define MODE_Mouse1000 (MODES_SCREEN+3) // Send mouse X,Y position on press and release
00042 #define MODE_Mouse1001 (MODES_SCREEN+4) // Use Hilight mouse tracking
00043 #define MODE_Mouse1002 (MODES_SCREEN+5) // Use cell motion mouse tracking
00044 #define MODE_Mouse1003 (MODES_SCREEN+6) // Use all motion mouse tracking
00045 #define MODE_Ansi (MODES_SCREEN+7) // Use US Ascii for character sets G0-G3 (DECANM)
00046 #define MODE_132Columns (MODES_SCREEN+8) // 80 <-> 132 column mode switch (DECCOLM)
00047 #define MODE_Allow132Columns (MODES_SCREEN+9) // Allow DECCOLM mode
00048 #define MODE_total (MODES_SCREEN+10)
00049
00050 namespace Konsole
00051 {
00052
00053 struct CharCodes
00054 {
00055
00056 char charset[4];
00057 int cu_cs;
00058 bool graphic;
00059 bool pound ;
00060 bool sa_graphic;
00061 bool sa_pound;
00062 };
00063
00074 class Vt102Emulation : public Emulation
00075 {
00076 Q_OBJECT
00077
00078 public:
00080 Vt102Emulation();
00081 ~Vt102Emulation();
00082
00083
00084 virtual void clearEntireScreen();
00085 virtual void reset();
00086 virtual char eraseChar() const;
00087
00088 public slots:
00089
00090 virtual void sendString(const char*,int length = -1);
00091 virtual void sendText(const QString& text);
00092 virtual void sendKeyEvent(QKeyEvent*);
00093 virtual void sendMouseEvent(int buttons, int column, int line, int eventType);
00094
00095 protected:
00096
00097 virtual void setMode(int mode);
00098 virtual void resetMode(int mode);
00099 virtual void receiveChar(int cc);
00100
00101 private slots:
00102
00103
00104 void updateTitle();
00105
00106 private:
00107 unsigned short applyCharset(unsigned short c);
00108 void setCharset(int n, int cs);
00109 void useCharset(int n);
00110 void setAndUseCharset(int n, int cs);
00111 void saveCursor();
00112 void restoreCursor();
00113 void resetCharset(int scrno);
00114
00115 void setMargins(int top, int bottom);
00116
00117 void setDefaultMargins();
00118
00119
00120 bool getMode (int mode);
00121
00122 void saveMode (int mode);
00123
00124 void restoreMode(int mode);
00125
00126
00127 void resetModes();
00128
00129 void resetTokenizer();
00130 #define MAX_TOKEN_LENGTH 80
00131 void addToCurrentToken(int cc);
00132 int tokenBuffer[MAX_TOKEN_LENGTH];
00133 int tokenBufferPos;
00134 #define MAXARGS 15
00135 void addDigit(int dig);
00136 void addArgument();
00137 int argv[MAXARGS];
00138 int argc;
00139 void initTokenizer();
00140
00141
00142
00143
00144 int charClass[256];
00145
00146 void reportDecodingError();
00147
00148 void processToken(int code, int p, int q);
00149 void processWindowAttributeChange();
00150
00151 void reportTerminalType();
00152 void reportSecondaryAttributes();
00153 void reportStatus();
00154 void reportAnswerBack();
00155 void reportCursorPosition();
00156 void reportTerminalParms(int p);
00157
00158 void onScrollLock();
00159 void scrollLock(const bool lock);
00160
00161
00162
00163 void clearScreenAndSetColumns(int columnCount);
00164
00165 CharCodes _charset[2];
00166
00167 class TerminalState
00168 {
00169 public:
00170
00171 TerminalState()
00172 { memset(&mode,false,MODE_total * sizeof(bool)); }
00173
00174 bool mode[MODE_total];
00175 };
00176
00177 TerminalState _currentModes;
00178 TerminalState _savedModes;
00179
00180
00181
00182
00183
00184
00185 QHash<int,QString> _pendingTitleUpdates;
00186 QTimer* _titleUpdateTimer;
00187 };
00188
00189 }
00190
00191 #endif // VT102EMULATION_H