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 class DECpar
00054 {
00055 public:
00056
00057 DECpar();
00058 bool mode[MODE_total];
00059 };
00060
00061 struct CharCodes
00062 {
00063
00064 char charset[4];
00065 int cu_cs;
00066 bool graphic;
00067 bool pound ;
00068 bool sa_graphic;
00069 bool sa_pound;
00070 };
00071
00082 class Vt102Emulation : public Emulation
00083 {
00084 Q_OBJECT
00085
00086 public:
00087
00089 Vt102Emulation();
00090 ~Vt102Emulation();
00091
00092
00093 virtual void clearEntireScreen();
00094 virtual void reset();
00095
00096
00097 virtual char getErase() const;
00098
00099 public slots:
00100
00101
00102 virtual void sendString(const char*,int length = -1);
00103 virtual void sendText(const QString& text);
00104 virtual void sendKeyEvent(QKeyEvent*);
00105 virtual void sendMouseEvent( int buttons, int column, int line , int eventType );
00106
00107 protected:
00108
00109 virtual void setMode (int mode);
00110 virtual void resetMode (int mode);
00111
00112
00113 virtual void receiveChar(int cc);
00114
00115
00116 private slots:
00117
00118
00119
00120 void updateTitle();
00121
00122
00123 private:
00124 unsigned short applyCharset(unsigned short c);
00125 void setCharset(int n, int cs);
00126 void useCharset(int n);
00127 void setAndUseCharset(int n, int cs);
00128 void saveCursor();
00129 void restoreCursor();
00130 void resetCharset(int scrno);
00131
00132 void setMargins(int top, int bottom);
00133
00134 void setDefaultMargins();
00135
00136
00137 bool getMode (int mode);
00138
00139 void saveMode (int mode);
00140
00141 void restoreMode(int mode);
00142
00143
00144 void resetModes();
00145
00146 void resetToken();
00147 #define MAXPBUF 80
00148 void pushToToken(int cc);
00149 int pbuf[MAXPBUF];
00150 int ppos;
00151 #define MAXARGS 15
00152 void addDigit(int dig);
00153 void addArgument();
00154 int argv[MAXARGS];
00155 int argc;
00156 void initTokenizer();
00157 int tbl[256];
00158
00159 void scan_buffer_report();
00160 void ReportErrorToken();
00161
00162 void tau(int code, int p, int q);
00163 void XtermHack();
00164
00165 void reportTerminalType();
00166 void reportSecondaryAttributes();
00167 void reportStatus();
00168 void reportAnswerBack();
00169 void reportCursorPosition();
00170 void reportTerminalParms(int p);
00171
00172 void onScrollLock();
00173 void scrollLock(const bool lock);
00174
00175
00176
00177 void clearScreenAndSetColumns(int columnCount);
00178
00179 CharCodes _charset[2];
00180
00181 DECpar _currParm;
00182 DECpar _saveParm;
00183
00184
00185
00186
00187
00188
00189 QHash<int,QString> _pendingTitleUpdates;
00190 QTimer* _titleUpdateTimer;
00191
00192 };
00193
00194 }
00195
00196 #endif // VT102EMULATION_H