• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Konsole

  • sources
  • kde-4.12
  • applications
  • konsole
  • src
Vt102Emulation.h
Go to the documentation of this file.
1 /*
2  This file is part of Konsole, an X terminal.
3 
4  Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
5  Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
6 
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.
11 
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.
16 
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.
21 */
22 
23 #ifndef VT102EMULATION_H
24 #define VT102EMULATION_H
25 
26 // Qt
27 #include <QtCore/QHash>
28 
29 // Konsole
30 #include "Emulation.h"
31 #include "Screen.h"
32 
33 class QTimer;
34 class QKeyEvent;
35 
36 #define MODE_AppScreen (MODES_SCREEN+0) // Mode #1
37 #define MODE_AppCuKeys (MODES_SCREEN+1) // Application cursor keys (DECCKM)
38 #define MODE_AppKeyPad (MODES_SCREEN+2) //
39 #define MODE_Mouse1000 (MODES_SCREEN+3) // Send mouse X,Y position on press and release
40 #define MODE_Mouse1001 (MODES_SCREEN+4) // Use Hilight mouse tracking
41 #define MODE_Mouse1002 (MODES_SCREEN+5) // Use cell motion mouse tracking
42 #define MODE_Mouse1003 (MODES_SCREEN+6) // Use all motion mouse tracking
43 #define MODE_Mouse1005 (MODES_SCREEN+7) // Xterm-style extended coordinates
44 #define MODE_Mouse1006 (MODES_SCREEN+8) // 2nd Xterm-style extended coordinates
45 #define MODE_Mouse1015 (MODES_SCREEN+9) // Urxvt-style extended coordinates
46 #define MODE_Ansi (MODES_SCREEN+10) // Use US Ascii for character sets G0-G3 (DECANM)
47 #define MODE_132Columns (MODES_SCREEN+11) // 80 <-> 132 column mode switch (DECCOLM)
48 #define MODE_Allow132Columns (MODES_SCREEN+12) // Allow DECCOLM mode
49 #define MODE_total (MODES_SCREEN+13)
50 
51 namespace Konsole
52 {
53 extern unsigned short vt100_graphics[32];
54 
55 struct CharCodes {
56  // coding info
57  char charset[4]; //
58  int cu_cs; // actual charset.
59  bool graphic; // Some VT100 tricks
60  bool pound; // Some VT100 tricks
61  bool sa_graphic; // saved graphic
62  bool sa_pound; // saved pound
63 };
64 
75 class Vt102Emulation : public Emulation
76 {
77  Q_OBJECT
78 
79 public:
81  Vt102Emulation();
82  ~Vt102Emulation();
83 
84  // reimplemented from Emulation
85  virtual void clearEntireScreen();
86  virtual void reset();
87  virtual char eraseChar() const;
88 
89 public slots:
90  // reimplemented from Emulation
91  virtual void sendString(const char*, int length = -1);
92  virtual void sendText(const QString& text);
93  virtual void sendKeyEvent(QKeyEvent*);
94  virtual void sendMouseEvent(int buttons, int column, int line, int eventType);
95 
96 protected:
97  // reimplemented from Emulation
98  virtual void setMode(int mode);
99  virtual void resetMode(int mode);
100  virtual void receiveChar(int cc);
101 
102 private slots:
103  //causes changeTitle() to be emitted for each (int,QString) pair in pendingTitleUpdates
104  //used to buffer multiple title updates
105  void updateTitle();
106 
107 private:
108  unsigned short applyCharset(unsigned short c);
109  void setCharset(int n, int cs);
110  void useCharset(int n);
111  void setAndUseCharset(int n, int cs);
112  void saveCursor();
113  void restoreCursor();
114  void resetCharset(int scrno);
115 
116  void setMargins(int top, int bottom);
117  //set margins for all screens back to their defaults
118  void setDefaultMargins();
119 
120  // returns true if 'mode' is set or false otherwise
121  bool getMode(int mode);
122  // saves the current boolean value of 'mode'
123  void saveMode(int mode);
124  // restores the boolean value of 'mode'
125  void restoreMode(int mode);
126  // resets all modes
127  // (except MODE_Allow132Columns)
128  void resetModes();
129 
130  void resetTokenizer();
131 #define MAX_TOKEN_LENGTH 256 // Max length of tokens (e.g. window title)
132  void addToCurrentToken(int cc);
133  int tokenBuffer[MAX_TOKEN_LENGTH]; //FIXME: overflow?
134  int tokenBufferPos;
135 #define MAXARGS 15
136  void addDigit(int dig);
137  void addArgument();
138  int argv[MAXARGS];
139  int argc;
140  void initTokenizer();
141 
142  // Set of flags for each of the ASCII characters which indicates
143  // what category they fall into (printable character, control, digit etc.)
144  // for the purposes of decoding terminal output
145  int charClass[256];
146 
147  void reportDecodingError();
148 
149  void processToken(int code, int p, int q);
150  void processWindowAttributeChange();
151 
152  void reportTerminalType();
153  void reportSecondaryAttributes();
154  void reportStatus();
155  void reportAnswerBack();
156  void reportCursorPosition();
157  void reportTerminalParms(int p);
158 
159  // clears the screen and resizes it to the specified
160  // number of columns
161  void clearScreenAndSetColumns(int columnCount);
162 
163  CharCodes _charset[2];
164 
165  class TerminalState
166  {
167  public:
168  // Initializes all modes to false
169  TerminalState() {
170  memset(&mode, false, MODE_total * sizeof(bool));
171  }
172 
173  bool mode[MODE_total];
174  };
175 
176  TerminalState _currentModes;
177  TerminalState _savedModes;
178 
179  //hash table and timer for buffering calls to the session instance
180  //to update the name of the session
181  //or window title.
182  //these calls occur when certain escape sequences are seen in the
183  //output from the terminal
184  QHash<int, QString> _pendingTitleUpdates;
185  QTimer* _titleUpdateTimer;
186 };
187 }
188 
189 #endif // VT102EMULATION_H
Konsole::Vt102Emulation::~Vt102Emulation
~Vt102Emulation()
Definition: Vt102Emulation.cpp:79
Konsole::vt100_graphics
unsigned short vt100_graphics[32]
Definition: Vt102Emulation.cpp:60
MODE_total
#define MODE_total
Definition: Vt102Emulation.h:49
Emulation.h
Screen.h
Konsole::Vt102Emulation::reset
virtual void reset()
Resets the state of the terminal.
Definition: Vt102Emulation.cpp:88
Konsole::Vt102Emulation::sendMouseEvent
virtual void sendMouseEvent(int buttons, int column, int line, int eventType)
Definition: Vt102Emulation.cpp:912
Konsole::Vt102Emulation::receiveChar
virtual void receiveChar(int cc)
Processes an incoming character.
Definition: Vt102Emulation.cpp:291
MAXARGS
#define MAXARGS
Definition: Vt102Emulation.h:135
Konsole::Vt102Emulation::Vt102Emulation
Vt102Emulation()
Constructs a new emulation.
Definition: Vt102Emulation.cpp:68
Konsole::CharCodes::pound
bool pound
Definition: Vt102Emulation.h:60
MAX_TOKEN_LENGTH
#define MAX_TOKEN_LENGTH
Definition: Vt102Emulation.h:131
Konsole::Vt102Emulation::eraseChar
virtual char eraseChar() const
Returns the special character used for erasing character.
Definition: Vt102Emulation.cpp:1283
Konsole::Vt102Emulation::sendText
virtual void sendText(const QString &text)
Definition: Vt102Emulation.cpp:957
Konsole::Vt102Emulation::resetMode
virtual void resetMode(int mode)
Definition: Vt102Emulation.cpp:1237
Konsole::Vt102Emulation::clearEntireScreen
virtual void clearEntireScreen()
Copies the current image into the history and clears the screen.
Definition: Vt102Emulation.cpp:82
Konsole::Vt102Emulation::sendString
virtual void sendString(const char *, int length=-1)
Definition: Vt102Emulation.cpp:830
Konsole::CharCodes::graphic
bool graphic
Definition: Vt102Emulation.h:59
Konsole::Emulation
Base class for terminal emulation back-ends.
Definition: Emulation.h:117
Konsole::CharCodes::sa_graphic
bool sa_graphic
Definition: Vt102Emulation.h:61
Konsole::CharCodes::sa_pound
bool sa_pound
Definition: Vt102Emulation.h:62
Konsole::CharCodes::cu_cs
int cu_cs
Definition: Vt102Emulation.h:58
Konsole::Vt102Emulation
Provides an xterm compatible terminal emulation based on the DEC VT102 terminal.
Definition: Vt102Emulation.h:75
Konsole::CharCodes
Definition: Vt102Emulation.h:55
Konsole::CharCodes::charset
char charset[4]
Definition: Vt102Emulation.h:57
Konsole::Vt102Emulation::setMode
virtual void setMode(int mode)
Definition: Vt102Emulation.cpp:1207
Konsole::Vt102Emulation::sendKeyEvent
virtual void sendKeyEvent(QKeyEvent *)
Definition: Vt102Emulation.cpp:967
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:24 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Konsole

Skip menu "Konsole"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Applications
  •   Libraries
  •     libkonq
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal