GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_total (MODES_SCREEN+8)
49 
50 struct DECpar
51 {
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 */
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();
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 
173 
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;
184 
185 };
186 
187 #endif // VT102EMULATION_H
void setAndUseCharset(int n, int cs)
char charset[4]
virtual char getErase() const
TODO Document me.
OCTAVE_EXPORT octave_value_list column
Definition: sparse.cc:123
virtual void resetMode(int mode)
virtual void clearEntireScreen()
Copies the current image into the history and clears the screen.
virtual void receiveChar(int cc)
Processes an incoming character.
Vt102Emulation()
Constructs a new emulation.
#define MODE_total
void reportSecondaryAttributes()
void scrollLock(const bool lock)
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
Definition: data.cc:6386
Base class for terminal emulation back-ends.
Definition: Emulation.h:118
QHash< int, QString > _pendingTitleUpdates
void reportTerminalParms(int p)
void resetCharset(int scrno)
void addDigit(int dig)
#define MAXPBUF
void setMargins(int top, int bottom)
void reportCursorPosition()
void onScrollLock()
#define MAXARGS
void tau(int code, int p, int q)
void clearScreenAndSetColumns(int columnCount)
void useCharset(int n)
virtual void sendString(const char *, int length=-1)
CharCodes _charset[2]
virtual void setMode(int mode)
unsigned short applyCharset(unsigned short c)
bool mode[(MODES_SCREEN+8)]
virtual void sendKeyEvent(QKeyEvent *)
virtual void sendText(const QString &text)
void pushToToken(int cc)
do not permute tem code
Definition: balance.cc:90
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
void restoreMode(int mode)
virtual void sendMouseEvent(int buttons, int column, int line, int eventType)
virtual void reset()
Resets the state of the terminal.
Provides an xterm compatible terminal emulation based on the DEC VT102 terminal.
p
Definition: lu.cc:138
void setCharset(int n, int cs)
bool sa_graphic
bool getMode(int mode)
void saveMode(int mode)
QTimer * _titleUpdateTimer