comparison libqterminal/unix/Vt102Emulation.h @ 15651:845cebf281aa

Added files of QConsole.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Mon, 30 Jan 2012 11:23:13 +0100
parents
children 35c891dce299
comparison
equal deleted inserted replaced
15650:ba360324035e 15651:845cebf281aa
1 /*
2 This file is part of Konsole, an X terminal.
3
4 Copyright (C) 2007 by Robert Knight <robertknight@gmail.com>
5 Copyright (C) 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
6
7 Rewritten for QT4 by e_k <e_k at users.sourceforge.net>, Copyright (C)2008
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 02110-1301 USA.
23 */
24
25 #ifndef VT102EMULATION_H
26 #define VT102EMULATION_H
27
28 // Standard Library
29 #include <stdio.h>
30
31 // Qt
32 #include <QtGui/QKeyEvent>
33 #include <QtCore/QHash>
34 #include <QtCore/QTimer>
35
36 // Konsole
37 #include "Emulation.h"
38 #include "Screen.h"
39
40 #define MODE_AppScreen (MODES_SCREEN+0)
41 #define MODE_AppCuKeys (MODES_SCREEN+1)
42 #define MODE_AppKeyPad (MODES_SCREEN+2)
43 #define MODE_Mouse1000 (MODES_SCREEN+3)
44 #define MODE_Mouse1001 (MODES_SCREEN+4)
45 #define MODE_Mouse1002 (MODES_SCREEN+5)
46 #define MODE_Mouse1003 (MODES_SCREEN+6)
47 #define MODE_Ansi (MODES_SCREEN+7)
48 #define MODE_total (MODES_SCREEN+8)
49
50 struct DECpar
51 {
52 bool mode[MODE_total];
53 };
54
55 struct CharCodes
56 {
57 // coding info
58 char charset[4]; //
59 int cu_cs; // actual charset.
60 bool graphic; // Some VT100 tricks
61 bool pound ; // Some VT100 tricks
62 bool sa_graphic; // saved graphic
63 bool sa_pound; // saved pound
64 };
65
66 /**
67 * Provides an xterm compatible terminal emulation based on the DEC VT102 terminal.
68 * A full description of this terminal can be found at http://vt100.net/docs/vt102-ug/
69 *
70 * In addition, various additional xterm escape sequences are supported to provide
71 * features such as mouse input handling.
72 * See http://rtfm.etla.org/xterm/ctlseq.html for a description of xterm's escape
73 * sequences.
74 *
75 */
76 class Vt102Emulation : public Emulation
77 {
78 Q_OBJECT
79
80 public:
81
82 /** Constructs a new emulation */
83 Vt102Emulation();
84 ~Vt102Emulation();
85
86 // reimplemented
87 virtual void clearEntireScreen();
88 virtual void reset();
89
90 // reimplemented
91 virtual char getErase() const;
92
93 public slots:
94
95 // reimplemented
96 virtual void sendString(const char*,int length = -1);
97 virtual void sendText(const QString& text);
98 virtual void sendKeyEvent(QKeyEvent*);
99 virtual void sendMouseEvent( int buttons, int column, int line , int eventType );
100
101 protected:
102 // reimplemented
103 virtual void setMode (int mode);
104 virtual void resetMode (int mode);
105
106 // reimplemented
107 virtual void receiveChar(int cc);
108
109
110 private slots:
111
112 //causes changeTitle() to be emitted for each (int,QString) pair in pendingTitleUpdates
113 //used to buffer multiple title updates
114 void updateTitle();
115
116
117 private:
118 unsigned short applyCharset(unsigned short c);
119 void setCharset(int n, int cs);
120 void useCharset(int n);
121 void setAndUseCharset(int n, int cs);
122 void saveCursor();
123 void restoreCursor();
124 void resetCharset(int scrno);
125
126 void setMargins(int top, int bottom);
127 //set margins for all screens back to their defaults
128 void setDefaultMargins();
129
130 // returns true if 'mode' is set or false otherwise
131 bool getMode (int mode);
132 // saves the current boolean value of 'mode'
133 void saveMode (int mode);
134 // restores the boolean value of 'mode'
135 void restoreMode(int mode);
136 // resets all modes
137 void resetModes();
138
139 void resetToken();
140 #define MAXPBUF 80
141 void pushToToken(int cc);
142 int pbuf[MAXPBUF]; //FIXME: overflow?
143 int ppos;
144 #define MAXARGS 15
145 void addDigit(int dig);
146 void addArgument();
147 int argv[MAXARGS];
148 int argc;
149 void initTokenizer();
150 int tbl[256];
151
152 void scan_buffer_report(); //FIXME: rename
153 void ReportErrorToken(); //FIXME: rename
154
155 void tau(int code, int p, int q);
156 void XtermHack();
157
158 void reportTerminalType();
159 void reportSecondaryAttributes();
160 void reportStatus();
161 void reportAnswerBack();
162 void reportCursorPosition();
163 void reportTerminalParms(int p);
164
165 void onScrollLock();
166 void scrollLock(const bool lock);
167
168 // clears the screen and resizes it to the specified
169 // number of columns
170 void clearScreenAndSetColumns(int columnCount);
171
172 CharCodes _charset[2];
173
174 DECpar _currParm;
175 DECpar _saveParm;
176
177 //hash table and timer for buffering calls to the session instance
178 //to update the name of the session
179 //or window title.
180 //these calls occur when certain escape sequences are seen in the
181 //output from the terminal
182 QHash<int,QString> _pendingTitleUpdates;
183 QTimer* _titleUpdateTimer;
184
185 };
186
187 #endif // VT102EMULATION_H