GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Vt102Emulation.h
Go to the documentation of this file.
1 /*
2  This file is part of Konsole, an X terminal.
3 
4  Copyright (C) 2007, 2013 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 <QKeyEvent>
33 #include <QtCore/QHash>
34 #include <QtCore/QTimer>
35 
36 // Konsole
37 #include "unix/Emulation.h"
38 #include "unix/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_BracketedPaste (MODES_SCREEN+8)
49 #define MODE_total (MODES_SCREEN+9)
50 
51 struct DECpar
52 {
54 };
55 
56 struct CharCodes
57 {
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
65 };
66 
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/
70  *
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.
75  *
76  */
77 class Vt102Emulation : public Emulation
78 {
79 Q_OBJECT
80 
81 public:
82 
83  /** Constructs a new emulation */
86 
87  // reimplemented
88  virtual void clearEntireScreen();
89  virtual void reset();
90 
91  // reimplemented
92  virtual char getErase() const;
93 
94 public slots:
95 
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 );
101 
102 protected:
103  // reimplemented
104  virtual void setMode (int mode);
105  virtual void resetMode (int mode);
106 
107  // reimplemented
108  virtual void receiveChar(int cc);
109 
110 
111 private slots:
112 
113  //causes changeTitle() to be emitted for each (int,QString) pair in pendingTitleUpdates
114  //used to buffer multiple title updates
115  void updateTitle();
116 
117 
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);
126 
127  void setMargins(int top, int bottom);
128  //set margins for all screens back to their defaults
129  void setDefaultMargins();
130 
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();
139 
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];
152 
153  void scan_buffer_report(); //FIXME: rename
154  void ReportErrorToken(); //FIXME: rename
155 
156  void tau(int code, int p, int q);
157  void XtermHack();
158 
159  void reportTerminalType();
161  void reportStatus();
162  void reportAnswerBack();
163  void reportCursorPosition();
164  void reportTerminalParms(int p);
165 
166  void onScrollLock();
167  void scrollLock(const bool lock);
168 
169  // clears the screen and resizes it to the specified
170  // number of columns
171  void clearScreenAndSetColumns(int columnCount);
172 
174 
177 
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;
185 
186 };
187 
188 #endif // VT102EMULATION_H
#define MODE_total
#define MAXARGS
#define MAXPBUF
Base class for terminal emulation back-ends.
Definition: Emulation.h:119
Provides an xterm compatible terminal emulation based on the DEC VT102 terminal.
QTimer * _titleUpdateTimer
void setAndUseCharset(int n, int cs)
virtual void setMode(int mode)
void scrollLock(const bool lock)
bool getMode(int mode)
void clearScreenAndSetColumns(int columnCount)
void setMargins(int top, int bottom)
virtual void reset()
Resets the state of the terminal.
void setCharset(int n, int cs)
virtual char getErase() const
TODO Document me.
void addDigit(int dig)
void reportSecondaryAttributes()
void restoreMode(int mode)
void useCharset(int n)
virtual void sendMouseEvent(int buttons, int column, int line, int eventType)
virtual void sendKeyEvent(QKeyEvent *)
virtual void receiveChar(int cc)
Processes an incoming character.
virtual void sendText(const QString &text)
void reportTerminalParms(int p)
unsigned short applyCharset(unsigned short c)
QHash< int, QString > _pendingTitleUpdates
virtual void clearEntireScreen()
Copies the current image into the history and clears the screen.
Vt102Emulation()
Constructs a new emulation.
void reportCursorPosition()
void saveMode(int mode)
void resetCharset(int scrno)
CharCodes _charset[2]
void onScrollLock()
virtual void resetMode(int mode)
virtual void sendString(const char *, int length=-1)
void tau(int code, int p, int q)
void pushToToken(int cc)
octave_idx_type n
Definition: mx-inlines.cc:753
char charset[4]
bool sa_graphic
bool mode[(MODES_SCREEN+9)]