Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / apps / konsole / src / Vt102Emulation.h
blobfd75a354859b894cd3d84fd861f55aa0927459c1
1 /*
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
20 02110-1301 USA.
23 #ifndef VT102EMULATION_H
24 #define VT102EMULATION_H
26 // Standard Library
27 #include <stdio.h>
29 // Qt
30 #include <QtGui/QKeyEvent>
31 #include <QtCore/QHash>
32 #include <QtCore/QTimer>
34 // Konsole
35 #include "Emulation.h"
36 #include "Screen.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)
48 namespace Konsole
51 struct DECpar
53 bool mode[MODE_total];
56 struct CharCodes
58 // coding info
59 char charset[4]; //
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
67 /**
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
74 * sequences.
77 class Vt102Emulation : public Emulation
79 Q_OBJECT
81 public:
83 /** Constructs a new emulation */
84 Vt102Emulation();
85 ~Vt102Emulation();
87 // reimplemented
88 virtual void clearEntireScreen();
89 virtual void reset();
91 // reimplemented
92 virtual char getErase() const;
94 public slots:
96 // reimplemented
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 );
102 protected:
103 // reimplemented
104 virtual void setMode (int mode);
105 virtual void resetMode (int mode);
107 // reimplemented
108 virtual void receiveChar(int cc);
111 private slots:
113 //causes changeTitle() to be emitted for each (int,QString) pair in pendingTitleUpdates
114 //used to buffer multiple title updates
115 void updateTitle();
118 private:
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);
123 void saveCursor();
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);
137 // resets all modes
138 void resetModes();
140 void resetToken();
141 #define MAXPBUF 80
142 void pushToToken(int cc);
143 int pbuf[MAXPBUF]; //FIXME: overflow?
144 int ppos;
145 #define MAXARGS 15
146 void addDigit(int dig);
147 void addArgument();
148 int argv[MAXARGS];
149 int argc;
150 void initTokenizer();
151 int tbl[256];
153 void scan_buffer_report(); //FIXME: rename
154 void ReportErrorToken(); //FIXME: rename
156 void tau(int code, int p, int q);
157 void XtermHack();
159 void reportTerminalType();
160 void reportSecondaryAttributes();
161 void reportStatus();
162 void reportAnswerBack();
163 void reportCursorPosition();
164 void reportTerminalParms(int p);
166 void onScrollLock();
167 void scrollLock(const bool lock);
169 // clears the screen and resizes it to the specified
170 // number of columns
171 void clearScreenAndSetColumns(int columnCount);
173 CharCodes _charset[2];
175 DECpar _currParm;
176 DECpar _saveParm;
178 //hash table and timer for buffering calls to the session instance
179 //to update the name of the session
180 //or window title.
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