2 This file is part of Konsole, an X terminal.
4 Copyright (C) 2007 by Robert Knight <robertknight@gmail.com>
5 Copyright (C) 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 #ifndef VT102EMULATION_H
24 #define VT102EMULATION_H
30 #include <QtGui/QKeyEvent>
31 #include <QtCore/QHash>
32 #include <QtCore/QTimer>
35 #include "Emulation.h"
38 #define MODE_AppScreen (MODES_SCREEN+0)
39 #define MODE_AppCuKeys (MODES_SCREEN+1)
40 #define MODE_AppKeyPad (MODES_SCREEN+2)
41 #define MODE_Mouse1000 (MODES_SCREEN+3)
42 #define MODE_Mouse1001 (MODES_SCREEN+4)
43 #define MODE_Mouse1002 (MODES_SCREEN+5)
44 #define MODE_Mouse1003 (MODES_SCREEN+6)
45 #define MODE_Ansi (MODES_SCREEN+7)
46 #define MODE_total (MODES_SCREEN+8)
53 bool mode
[MODE_total
];
60 int cu_cs
; // actual charset.
61 bool graphic
; // Some VT100 tricks
62 bool pound
; // Some VT100 tricks
63 bool sa_graphic
; // saved graphic
64 bool sa_pound
; // saved pound
68 * Provides an xterm compatible terminal emulation based on the DEC VT102 terminal.
69 * A full description of this terminal can be found at http://vt100.net/docs/vt102-ug/
71 * In addition, various additional xterm escape sequences are supported to provide
72 * features such as mouse input handling.
73 * See http://rtfm.etla.org/xterm/ctlseq.html for a description of xterm's escape
77 class Vt102Emulation
: public Emulation
83 /** Constructs a new emulation */
88 virtual void clearEntireScreen();
92 virtual char getErase() const;
97 virtual void sendString(const char*,int length
= -1);
98 virtual void sendText(const QString
& text
);
99 virtual void sendKeyEvent(QKeyEvent
*);
100 virtual void sendMouseEvent( int buttons
, int column
, int line
, int eventType
);
104 virtual void setMode (int mode
);
105 virtual void resetMode (int mode
);
108 virtual void receiveChar(int cc
);
113 //causes changeTitle() to be emitted for each (int,QString) pair in pendingTitleUpdates
114 //used to buffer multiple title updates
119 unsigned short applyCharset(unsigned short c
);
120 void setCharset(int n
, int cs
);
121 void useCharset(int n
);
122 void setAndUseCharset(int n
, int cs
);
124 void restoreCursor();
125 void resetCharset(int scrno
);
127 void setMargins(int top
, int bottom
);
128 //set margins for all screens back to their defaults
129 void setDefaultMargins();
131 // returns true if 'mode' is set or false otherwise
132 bool getMode (int mode
);
133 // saves the current boolean value of 'mode'
134 void saveMode (int mode
);
135 // restores the boolean value of 'mode'
136 void restoreMode(int mode
);
142 void pushToToken(int cc
);
143 int pbuf
[MAXPBUF
]; //FIXME: overflow?
146 void addDigit(int dig
);
150 void initTokenizer();
153 void scan_buffer_report(); //FIXME: rename
154 void ReportErrorToken(); //FIXME: rename
156 void tau(int code
, int p
, int q
);
159 void reportTerminalType();
160 void reportSecondaryAttributes();
162 void reportAnswerBack();
163 void reportCursorPosition();
164 void reportTerminalParms(int p
);
167 void scrollLock(const bool lock
);
169 // clears the screen and resizes it to the specified
171 void clearScreenAndSetColumns(int columnCount
);
173 CharCodes _charset
[2];
178 //hash table and timer for buffering calls to the session instance
179 //to update the name of the session
181 //these calls occur when certain escape sequences are seen in the
182 //output from the terminal
183 QHash
<int,QString
> _pendingTitleUpdates
;
184 QTimer
* _titleUpdateTimer
;
190 #endif // VT102EMULATION_H