summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/vt102emulation.cpp2
-rw-r--r--noncore/apps/opie-console/vt102emulation.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/opie-console/vt102emulation.cpp b/noncore/apps/opie-console/vt102emulation.cpp
index 7eecef3..0ebefa0 100644
--- a/noncore/apps/opie-console/vt102emulation.cpp
+++ b/noncore/apps/opie-console/vt102emulation.cpp
@@ -1,411 +1,411 @@
1/* ------------------------------------------------------------------------- */ 1/* ------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [vt102emulation.cpp] VT102 Terminal Emulation */ 3/* [vt102emulation.cpp] VT102 Terminal Emulation */
4/* */ 4/* */
5/* ------------------------------------------------------------------------- */ 5/* ------------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* ------------------------------------------------------------------------- */ 11/* ------------------------------------------------------------------------- */
12/* */ 12/* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14/* */ 14/* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16/* */ 16/* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18 18
19/*! \class Vt102Emulation 19/*! \class Vt102Emulation
20 20
21 \brief Actual Emulation for Konsole 21 \brief Actual Emulation for Konsole
22 22
23 \sa Widget \sa Screen \sa EmulationLayer 23 \sa Widget \sa Screen \sa EmulationLayer
24*/ 24*/
25 25
26#include "vt102emulation.h" 26#include "vt102emulation.h"
27#include "widget.h" 27#include "widget_layer.h"
28#include "screen.h" 28#include "screen.h"
29#include "keytrans.h" 29#include "keytrans.h"
30 30
31#include <stdio.h> 31#include <stdio.h>
32#include <unistd.h> 32#include <unistd.h>
33#include <qkeycode.h> 33#include <qkeycode.h>
34#include <qtextcodec.h> 34#include <qtextcodec.h>
35 35
36 36
37/* VT102 Terminal Emulation 37/* VT102 Terminal Emulation
38 38
39 This class puts together the screens, the pty and the widget to a 39 This class puts together the screens, the pty and the widget to a
40 complete terminal emulation. Beside combining it's componentes, it 40 complete terminal emulation. Beside combining it's componentes, it
41 handles the emulations's protocol. 41 handles the emulations's protocol.
42 42
43 This module consists of the following sections: 43 This module consists of the following sections:
44 44
45 - Constructor/Destructor 45 - Constructor/Destructor
46 - Incoming Bytes Event pipeline 46 - Incoming Bytes Event pipeline
47 - Outgoing Bytes 47 - Outgoing Bytes
48 - Mouse Events 48 - Mouse Events
49 - Keyboard Events 49 - Keyboard Events
50 - Modes and Charset State 50 - Modes and Charset State
51 - Diagnostics 51 - Diagnostics
52*/ 52*/
53 53
54 54
55/* ------------------------------------------------------------------------- */ 55/* ------------------------------------------------------------------------- */
56/* */ 56/* */
57/* Constructor / Destructor */ 57/* Constructor / Destructor */
58/* */ 58/* */
59/* ------------------------------------------------------------------------- */ 59/* ------------------------------------------------------------------------- */
60 60
61/* 61/*
62 Nothing really intesting happens here. 62 Nothing really intesting happens here.
63*/ 63*/
64 64
65/*! 65/*!
66*/ 66*/
67 67
68Vt102Emulation::Vt102Emulation(WidgetLayer* gui) : EmulationLayer(gui) 68Vt102Emulation::Vt102Emulation(WidgetLayer* gui) : EmulationLayer(gui)
69{ 69{
70 QObject::connect(gui,SIGNAL(mouseSignal(int,int,int)), 70 QObject::connect(gui,SIGNAL(mouseSignal(int,int,int)),
71 this,SLOT(onMouse(int,int,int))); 71 this,SLOT(onMouse(int,int,int)));
72 initTokenizer(); 72 initTokenizer();
73 reset(); 73 reset();
74} 74}
75 75
76/*! 76/*!
77*/ 77*/
78 78
79Vt102Emulation::~Vt102Emulation() 79Vt102Emulation::~Vt102Emulation()
80{ 80{
81} 81}
82 82
83/*! 83/*!
84*/ 84*/
85 85
86void Vt102Emulation::reset() 86void Vt102Emulation::reset()
87{ 87{
88 resetToken(); 88 resetToken();
89 resetModes(); 89 resetModes();
90 resetCharset(0); screen[0]->reset(); 90 resetCharset(0); screen[0]->reset();
91 resetCharset(1); screen[0]->reset(); 91 resetCharset(1); screen[0]->reset();
92 setCodec(0); 92 setCodec(0);
93 setKeytrans("linux.keytab"); 93 setKeytrans("linux.keytab");
94} 94}
95 95
96/* ------------------------------------------------------------------------- */ 96/* ------------------------------------------------------------------------- */
97/* */ 97/* */
98/* Processing the incoming byte stream */ 98/* Processing the incoming byte stream */
99/* */ 99/* */
100/* ------------------------------------------------------------------------- */ 100/* ------------------------------------------------------------------------- */
101 101
102/* Incoming Bytes Event pipeline 102/* Incoming Bytes Event pipeline
103 103
104 This section deals with decoding the incoming character stream. 104 This section deals with decoding the incoming character stream.
105 Decoding means here, that the stream is first seperated into `tokens' 105 Decoding means here, that the stream is first seperated into `tokens'
106 which are then mapped to a `meaning' provided as operations by the 106 which are then mapped to a `meaning' provided as operations by the
107 `TEScreen' class or by the emulation class itself. 107 `TEScreen' class or by the emulation class itself.
108 108
109 The pipeline proceeds as follows: 109 The pipeline proceeds as follows:
110 110
111 - Tokenizing the ESC codes (onRcvChar) 111 - Tokenizing the ESC codes (onRcvChar)
112 - VT100 code page translation of plain characters (applyCharset) 112 - VT100 code page translation of plain characters (applyCharset)
113 - Interpretation of ESC codes (tau) 113 - Interpretation of ESC codes (tau)
114 114
115 The escape codes and their meaning are described in the 115 The escape codes and their meaning are described in the
116 technical reference of this program. 116 technical reference of this program.
117*/ 117*/
118 118
119// Tokens ------------------------------------------------------------------ -- 119// Tokens ------------------------------------------------------------------ --
120 120
121/* 121/*
122 Since the tokens are the central notion if this section, we've put them 122 Since the tokens are the central notion if this section, we've put them
123 in front. They provide the syntactical elements used to represent the 123 in front. They provide the syntactical elements used to represent the
124 terminals operations as byte sequences. 124 terminals operations as byte sequences.
125 125
126 They are encodes here into a single machine word, so that we can later 126 They are encodes here into a single machine word, so that we can later
127 switch over them easily. Depending on the token itself, additional 127 switch over them easily. Depending on the token itself, additional
128 argument variables are filled with parameter values. 128 argument variables are filled with parameter values.
129 129
130 The tokens are defined below: 130 The tokens are defined below:
131 131
132 - CHR - Printable characters (32..255 but DEL (=127)) 132 - CHR - Printable characters (32..255 but DEL (=127))
133 - CTL - Control characters (0..31 but ESC (= 27), DEL) 133 - CTL - Control characters (0..31 but ESC (= 27), DEL)
134 - ESC - Escape codes of the form <ESC><CHR but `[]()+*#'> 134 - ESC - Escape codes of the form <ESC><CHR but `[]()+*#'>
135 - ESC_DE - Escape codes of the form <ESC><any of `()+*#%'> C 135 - ESC_DE - Escape codes of the form <ESC><any of `()+*#%'> C
136 - CSI_PN - Escape codes of the form <ESC>'[' {Pn} ';' {Pn} C 136 - CSI_PN - Escape codes of the form <ESC>'[' {Pn} ';' {Pn} C
137 - CSI_PS - Escape codes of the form <ESC>'[' {Pn} ';' ... C 137 - CSI_PS - Escape codes of the form <ESC>'[' {Pn} ';' ... C
138 - CSI_PR - Escape codes of the form <ESC>'[' '?' {Pn} ';' ... C 138 - CSI_PR - Escape codes of the form <ESC>'[' '?' {Pn} ';' ... C
139 - VT52 - VT52 escape codes 139 - VT52 - VT52 escape codes
140 - <ESC><Chr> 140 - <ESC><Chr>
141 - <ESC>'Y'{Pc}{Pc} 141 - <ESC>'Y'{Pc}{Pc}
142 - XTE_HA - Xterm hacks <ESC>`]' {Pn} `;' {Text} <BEL> 142 - XTE_HA - Xterm hacks <ESC>`]' {Pn} `;' {Text} <BEL>
143 note that this is handled differently 143 note that this is handled differently
144 144
145 The last two forms allow list of arguments. Since the elements of 145 The last two forms allow list of arguments. Since the elements of
146 the lists are treated individually the same way, they are passed 146 the lists are treated individually the same way, they are passed
147 as individual tokens to the interpretation. Further, because the 147 as individual tokens to the interpretation. Further, because the
148 meaning of the parameters are names (althought represented as numbers), 148 meaning of the parameters are names (althought represented as numbers),
149 they are includes within the token ('N'). 149 they are includes within the token ('N').
150 150
151*/ 151*/
152 152
153#define TY_CONSTR(T,A,N) ( ((((int)N) & 0xffff) << 16) | ((((int)A) & 0xff) << 8) | (((int)T) & 0xff) ) 153#define TY_CONSTR(T,A,N) ( ((((int)N) & 0xffff) << 16) | ((((int)A) & 0xff) << 8) | (((int)T) & 0xff) )
154 154
155#define TY_CHR___( ) TY_CONSTR(0,0,0) 155#define TY_CHR___( ) TY_CONSTR(0,0,0)
156#define TY_CTL___(A ) TY_CONSTR(1,A,0) 156#define TY_CTL___(A ) TY_CONSTR(1,A,0)
157#define TY_ESC___(A ) TY_CONSTR(2,A,0) 157#define TY_ESC___(A ) TY_CONSTR(2,A,0)
158#define TY_ESC_CS(A,B) TY_CONSTR(3,A,B) 158#define TY_ESC_CS(A,B) TY_CONSTR(3,A,B)
159#define TY_ESC_DE(A ) TY_CONSTR(4,A,0) 159#define TY_ESC_DE(A ) TY_CONSTR(4,A,0)
160#define TY_CSI_PS(A,N) TY_CONSTR(5,A,N) 160#define TY_CSI_PS(A,N) TY_CONSTR(5,A,N)
161#define TY_CSI_PN(A ) TY_CONSTR(6,A,0) 161#define TY_CSI_PN(A ) TY_CONSTR(6,A,0)
162#define TY_CSI_PR(A,N) TY_CONSTR(7,A,N) 162#define TY_CSI_PR(A,N) TY_CONSTR(7,A,N)
163 163
164#define TY_VT52__(A ) TY_CONSTR(8,A,0) 164#define TY_VT52__(A ) TY_CONSTR(8,A,0)
165 165
166// Tokenizer --------------------------------------------------------------- -- 166// Tokenizer --------------------------------------------------------------- --
167 167
168/* The tokenizers state 168/* The tokenizers state
169 169
170 The state is represented by the buffer (pbuf, ppos), 170 The state is represented by the buffer (pbuf, ppos),
171 and accompanied by decoded arguments kept in (argv,argc). 171 and accompanied by decoded arguments kept in (argv,argc).
172 Note that they are kept internal in the tokenizer. 172 Note that they are kept internal in the tokenizer.
173*/ 173*/
174 174
175void Vt102Emulation::resetToken() 175void Vt102Emulation::resetToken()
176{ 176{
177 ppos = 0; argc = 0; argv[0] = 0; argv[1] = 0; 177 ppos = 0; argc = 0; argv[0] = 0; argv[1] = 0;
178} 178}
179 179
180void Vt102Emulation::addDigit(int dig) 180void Vt102Emulation::addDigit(int dig)
181{ 181{
182 argv[argc] = 10*argv[argc] + dig; 182 argv[argc] = 10*argv[argc] + dig;
183} 183}
184 184
185void Vt102Emulation::addArgument() 185void Vt102Emulation::addArgument()
186{ 186{
187 argc = QMIN(argc+1,MAXARGS-1); 187 argc = QMIN(argc+1,MAXARGS-1);
188 argv[argc] = 0; 188 argv[argc] = 0;
189} 189}
190 190
191void Vt102Emulation::pushToToken(int cc) 191void Vt102Emulation::pushToToken(int cc)
192{ 192{
193 pbuf[ppos] = cc; 193 pbuf[ppos] = cc;
194 ppos = QMIN(ppos+1,MAXPBUF-1); 194 ppos = QMIN(ppos+1,MAXPBUF-1);
195} 195}
196 196
197// Character Classes used while decoding 197// Character Classes used while decoding
198 198
199#define CTL 1 199#define CTL 1
200#define CHR 2 200#define CHR 2
201#define CPN 4 201#define CPN 4
202#define DIG 8 202#define DIG 8
203#define SCS 16 203#define SCS 16
204#define GRP 32 204#define GRP 32
205 205
206void Vt102Emulation::initTokenizer() 206void Vt102Emulation::initTokenizer()
207{ int i; UINT8* s; 207{ int i; UINT8* s;
208 for(i = 0; i < 256; i++) tbl[ i] = 0; 208 for(i = 0; i < 256; i++) tbl[ i] = 0;
209 for(i = 0; i < 32; i++) tbl[ i] |= CTL; 209 for(i = 0; i < 32; i++) tbl[ i] |= CTL;
210 for(i = 32; i < 256; i++) tbl[ i] |= CHR; 210 for(i = 32; i < 256; i++) tbl[ i] |= CHR;
211 for(s = (UINT8*)"@ABCDGHLMPXcdfry"; *s; s++) tbl[*s] |= CPN; 211 for(s = (UINT8*)"@ABCDGHLMPXcdfry"; *s; s++) tbl[*s] |= CPN;
212 for(s = (UINT8*)"0123456789" ; *s; s++) tbl[*s] |= DIG; 212 for(s = (UINT8*)"0123456789" ; *s; s++) tbl[*s] |= DIG;
213 for(s = (UINT8*)"()+*%" ; *s; s++) tbl[*s] |= SCS; 213 for(s = (UINT8*)"()+*%" ; *s; s++) tbl[*s] |= SCS;
214 for(s = (UINT8*)"()+*#[]%" ; *s; s++) tbl[*s] |= GRP; 214 for(s = (UINT8*)"()+*#[]%" ; *s; s++) tbl[*s] |= GRP;
215 resetToken(); 215 resetToken();
216} 216}
217 217
218/* Ok, here comes the nasty part of the decoder. 218/* Ok, here comes the nasty part of the decoder.
219 219
220 Instead of keeping an explicit state, we deduce it from the 220 Instead of keeping an explicit state, we deduce it from the
221 token scanned so far. It is then immediately combined with 221 token scanned so far. It is then immediately combined with
222 the current character to form a scanning decision. 222 the current character to form a scanning decision.
223 223
224 This is done by the following defines. 224 This is done by the following defines.
225 225
226 - P is the length of the token scanned so far. 226 - P is the length of the token scanned so far.
227 - L (often P-1) is the position on which contents we base a decision. 227 - L (often P-1) is the position on which contents we base a decision.
228 - C is a character or a group of characters (taken from 'tbl'). 228 - C is a character or a group of characters (taken from 'tbl').
229 229
230 Note that they need to applied in proper order. 230 Note that they need to applied in proper order.
231*/ 231*/
232 232
233#define lec(P,L,C) (p == (P) && s[(L)] == (C)) 233#define lec(P,L,C) (p == (P) && s[(L)] == (C))
234#define lun( ) (p == 1 && cc >= 32 ) 234#define lun( ) (p == 1 && cc >= 32 )
235#define les(P,L,C) (p == (P) && s[L] < 256 && (tbl[s[(L)]] & (C)) == (C)) 235#define les(P,L,C) (p == (P) && s[L] < 256 && (tbl[s[(L)]] & (C)) == (C))
236#define eec(C) (p >= 3 && cc == (C)) 236#define eec(C) (p >= 3 && cc == (C))
237#define ees(C) (p >= 3 && cc < 256 && (tbl[ cc ] & (C)) == (C)) 237#define ees(C) (p >= 3 && cc < 256 && (tbl[ cc ] & (C)) == (C))
238#define eps(C) (p >= 3 && s[2] != '?' && cc < 256 && (tbl[ cc ] & (C)) == (C)) 238#define eps(C) (p >= 3 && s[2] != '?' && cc < 256 && (tbl[ cc ] & (C)) == (C))
239#define epp( ) (p >= 3 && s[2] == '?' ) 239#define epp( ) (p >= 3 && s[2] == '?' )
240#define egt( ) (p == 3 && s[2] == '>' ) 240#define egt( ) (p == 3 && s[2] == '>' )
241#define Xpe (ppos>=2 && pbuf[1] == ']' ) 241#define Xpe (ppos>=2 && pbuf[1] == ']' )
242#define Xte (Xpe && cc == 7 ) 242#define Xte (Xpe && cc == 7 )
243#define ces(C) ( cc < 256 && (tbl[ cc ] & (C)) == (C) && !Xte) 243#define ces(C) ( cc < 256 && (tbl[ cc ] & (C)) == (C) && !Xte)
244 244
245#define ESC 27 245#define ESC 27
246#define CNTL(c) ((c)-'@') 246#define CNTL(c) ((c)-'@')
247 247
248// process an incoming unicode character 248// process an incoming unicode character
249 249
250void Vt102Emulation::onRcvChar(int cc) 250void Vt102Emulation::onRcvChar(int cc)
251{ int i; 251{ int i;
252 252
253 if (cc == 127) return; //VT100: ignore. 253 if (cc == 127) return; //VT100: ignore.
254 254
255 if (ces( CTL)) 255 if (ces( CTL))
256 { // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100 256 { // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100
257 // This means, they do neither a resetToken nor a pushToToken. Some of them, do 257 // This means, they do neither a resetToken nor a pushToToken. Some of them, do
258 // of course. Guess this originates from a weakly layered handling of the X-on 258 // of course. Guess this originates from a weakly layered handling of the X-on
259 // X-off protocol, which comes really below this level. 259 // X-off protocol, which comes really below this level.
260 if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC) resetToken(); //VT100: CAN or SUB 260 if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC) resetToken(); //VT100: CAN or SUB
261 if (cc != ESC) { tau( TY_CTL___(cc+'@' ), 0, 0); return; } 261 if (cc != ESC) { tau( TY_CTL___(cc+'@' ), 0, 0); return; }
262 } 262 }
263 263
264 pushToToken(cc); // advance the state 264 pushToToken(cc); // advance the state
265 265
266 int* s = pbuf; 266 int* s = pbuf;
267 int p = ppos; 267 int p = ppos;
268 268
269 if (getMode(MODE_Ansi)) // decide on proper action 269 if (getMode(MODE_Ansi)) // decide on proper action
270 { 270 {
271 if (lec(1,0,ESC)) { return; } 271 if (lec(1,0,ESC)) { return; }
272 if (les(2,1,GRP)) { return; } 272 if (les(2,1,GRP)) { return; }
273 if (Xte ) { XtermHack(); resetToken(); return; } 273 if (Xte ) { XtermHack(); resetToken(); return; }
274 if (Xpe ) { return; } 274 if (Xpe ) { return; }
275 if (lec(3,2,'?')) { return; } 275 if (lec(3,2,'?')) { return; }
276 if (lec(3,2,'>')) { return; } 276 if (lec(3,2,'>')) { return; }
277 if (lun( )) { tau( TY_CHR___(), applyCharset(cc), 0); resetToken(); return; } 277 if (lun( )) { tau( TY_CHR___(), applyCharset(cc), 0); resetToken(); return; }
278 if (lec(2,0,ESC)) { tau( TY_ESC___(s[1]), 0, 0); resetToken(); return; } 278 if (lec(2,0,ESC)) { tau( TY_ESC___(s[1]), 0, 0); resetToken(); return; }
279 if (les(3,1,SCS)) { tau( TY_ESC_CS(s[1],s[2]), 0, 0); resetToken(); return; } 279 if (les(3,1,SCS)) { tau( TY_ESC_CS(s[1],s[2]), 0, 0); resetToken(); return; }
280 if (lec(3,1,'#')) { tau( TY_ESC_DE(s[2]), 0, 0); resetToken(); return; } 280 if (lec(3,1,'#')) { tau( TY_ESC_DE(s[2]), 0, 0); resetToken(); return; }
281// if (egt( )) { tau( TY_CSI_PG(cc ), '>', 0); resetToken(); return; } 281// if (egt( )) { tau( TY_CSI_PG(cc ), '>', 0); resetToken(); return; }
282 if (eps( CPN)) { tau( TY_CSI_PN(cc), argv[0],argv[1]); resetToken(); return; } 282 if (eps( CPN)) { tau( TY_CSI_PN(cc), argv[0],argv[1]); resetToken(); return; }
283 if (ees( DIG)) { addDigit(cc-'0'); return; } 283 if (ees( DIG)) { addDigit(cc-'0'); return; }
284 if (eec( ';')) { addArgument(); return; } 284 if (eec( ';')) { addArgument(); return; }
285 for (i=0;i<=argc;i++) 285 for (i=0;i<=argc;i++)
286 if (epp( )) tau( TY_CSI_PR(cc,argv[i]), 0, 0); else 286 if (epp( )) tau( TY_CSI_PR(cc,argv[i]), 0, 0); else
287 tau( TY_CSI_PS(cc,argv[i]), 0, 0); 287 tau( TY_CSI_PS(cc,argv[i]), 0, 0);
288 resetToken(); 288 resetToken();
289 } 289 }
290 else // mode VT52 290 else // mode VT52
291 { 291 {
292 if (lec(1,0,ESC)) return; 292 if (lec(1,0,ESC)) return;
293 if (les(1,0,CHR)) { tau( TY_CHR___( ), s[0], 0); resetToken(); return; } 293 if (les(1,0,CHR)) { tau( TY_CHR___( ), s[0], 0); resetToken(); return; }
294 if (lec(2,1,'Y')) return; 294 if (lec(2,1,'Y')) return;
295 if (lec(3,1,'Y')) return; 295 if (lec(3,1,'Y')) return;
296 if (p < 4) { tau( TY_VT52__(s[1] ), 0, 0); resetToken(); return; } 296 if (p < 4) { tau( TY_VT52__(s[1] ), 0, 0); resetToken(); return; }
297 tau( TY_VT52__(s[1] ), s[2],s[3]); resetToken(); return; 297 tau( TY_VT52__(s[1] ), s[2],s[3]); resetToken(); return;
298 } 298 }
299} 299}
300 300
301void Vt102Emulation::XtermHack() 301void Vt102Emulation::XtermHack()
302{ int i,arg = 0; 302{ int i,arg = 0;
303 for (i = 2; i < ppos && '0'<=pbuf[i] && pbuf[i]<'9' ; i++) 303 for (i = 2; i < ppos && '0'<=pbuf[i] && pbuf[i]<'9' ; i++)
304 arg = 10*arg + (pbuf[i]-'0'); 304 arg = 10*arg + (pbuf[i]-'0');
305 if (pbuf[i] != ';') { ReportErrorToken(); return; } 305 if (pbuf[i] != ';') { ReportErrorToken(); return; }
306 QChar *str = new QChar[ppos-i-2]; 306 QChar *str = new QChar[ppos-i-2];
307 for (int j = 0; j < ppos-i-2; j++) str[j] = pbuf[i+1+j]; 307 for (int j = 0; j < ppos-i-2; j++) str[j] = pbuf[i+1+j];
308 QString unistr(str,ppos-i-2); 308 QString unistr(str,ppos-i-2);
309 // arg == 1 doesn't change the title. In XTerm it only changes the icon name 309 // arg == 1 doesn't change the title. In XTerm it only changes the icon name
310 // (btw: arg=0 changes title and icon, arg=1 only icon, arg=2 only title 310 // (btw: arg=0 changes title and icon, arg=1 only icon, arg=2 only title
311 if (arg == 0 || arg == 2) emit changeTitle(arg,unistr); 311 if (arg == 0 || arg == 2) emit changeTitle(arg,unistr);
312 delete [] str; 312 delete [] str;
313} 313}
314 314
315// Interpreting Codes --------------------------------------------------------- 315// Interpreting Codes ---------------------------------------------------------
316 316
317/* 317/*
318 Now that the incoming character stream is properly tokenized, 318 Now that the incoming character stream is properly tokenized,
319 meaning is assigned to them. These are either operations of 319 meaning is assigned to them. These are either operations of
320 the current screen, or of the emulation class itself. 320 the current screen, or of the emulation class itself.
321 321
322 The token to be interpreteted comes in as a machine word 322 The token to be interpreteted comes in as a machine word
323 possibly accompanied by two parameters. 323 possibly accompanied by two parameters.
324 324
325 Likewise, the operations assigned to, come with up to two 325 Likewise, the operations assigned to, come with up to two
326 arguments. One could consider to make up a proper table 326 arguments. One could consider to make up a proper table
327 from the function below. 327 from the function below.
328 328
329 The technical reference manual provides more informations 329 The technical reference manual provides more informations
330 about this mapping. 330 about this mapping.
331*/ 331*/
332 332
333void Vt102Emulation::tau( int token, int p, int q ) 333void Vt102Emulation::tau( int token, int p, int q )
334{ 334{
335//scan_buffer_report(); 335//scan_buffer_report();
336//if (token == TY_CHR___()) printf("%c",p); else 336//if (token == TY_CHR___()) printf("%c",p); else
337//printf("tau(%d,%d,%d, %d,%d)\n",(token>>0)&0xff,(token>>8)&0xff,(token>>16)&0xffff,p,q); 337//printf("tau(%d,%d,%d, %d,%d)\n",(token>>0)&0xff,(token>>8)&0xff,(token>>16)&0xffff,p,q);
338 switch (token) 338 switch (token)
339 { 339 {
340 340
341 case TY_CHR___( ) : scr->ShowCharacter (p ); break; //UTF16 341 case TY_CHR___( ) : scr->ShowCharacter (p ); break; //UTF16
342 342
343 // 127 DEL : ignored on input 343 // 127 DEL : ignored on input
344 344
345 case TY_CTL___('@' ) : /* NUL: ignored */ break; 345 case TY_CTL___('@' ) : /* NUL: ignored */ break;
346 case TY_CTL___('A' ) : /* SOH: ignored */ break; 346 case TY_CTL___('A' ) : /* SOH: ignored */ break;
347 case TY_CTL___('B' ) : /* STX: ignored */ break; 347 case TY_CTL___('B' ) : /* STX: ignored */ break;
348 case TY_CTL___('C' ) : /* ETX: ignored */ break; 348 case TY_CTL___('C' ) : /* ETX: ignored */ break;
349 case TY_CTL___('D' ) : /* EOT: ignored */ break; 349 case TY_CTL___('D' ) : /* EOT: ignored */ break;
350 case TY_CTL___('E' ) : reportAnswerBack ( ); break; //VT100 350 case TY_CTL___('E' ) : reportAnswerBack ( ); break; //VT100
351 case TY_CTL___('F' ) : /* ACK: ignored */ break; 351 case TY_CTL___('F' ) : /* ACK: ignored */ break;
352 case TY_CTL___('G' ) : gui->bell ( ); break; //VT100 352 case TY_CTL___('G' ) : gui->bell ( ); break; //VT100
353 case TY_CTL___('H' ) : scr->BackSpace ( ); break; //VT100 353 case TY_CTL___('H' ) : scr->BackSpace ( ); break; //VT100
354 case TY_CTL___('I' ) : scr->Tabulate ( ); break; //VT100 354 case TY_CTL___('I' ) : scr->Tabulate ( ); break; //VT100
355 case TY_CTL___('J' ) : scr->NewLine ( ); break; //VT100 355 case TY_CTL___('J' ) : scr->NewLine ( ); break; //VT100
356 case TY_CTL___('K' ) : scr->NewLine ( ); break; //VT100 356 case TY_CTL___('K' ) : scr->NewLine ( ); break; //VT100
357 case TY_CTL___('L' ) : scr->NewLine ( ); break; //VT100 357 case TY_CTL___('L' ) : scr->NewLine ( ); break; //VT100
358 case TY_CTL___('M' ) : scr->Return ( ); break; //VT100 358 case TY_CTL___('M' ) : scr->Return ( ); break; //VT100
359 359
360 case TY_CTL___('N' ) : useCharset ( 1); break; //VT100 360 case TY_CTL___('N' ) : useCharset ( 1); break; //VT100
361 case TY_CTL___('O' ) : useCharset ( 0); break; //VT100 361 case TY_CTL___('O' ) : useCharset ( 0); break; //VT100
362 362
363 case TY_CTL___('P' ) : /* DLE: ignored */ break; 363 case TY_CTL___('P' ) : /* DLE: ignored */ break;
364 case TY_CTL___('Q' ) : /* DC1: XON continue */ break; //VT100 364 case TY_CTL___('Q' ) : /* DC1: XON continue */ break; //VT100
365 case TY_CTL___('R' ) : /* DC2: ignored */ break; 365 case TY_CTL___('R' ) : /* DC2: ignored */ break;
366 case TY_CTL___('S' ) : /* DC3: XOFF halt */ break; //VT100 366 case TY_CTL___('S' ) : /* DC3: XOFF halt */ break; //VT100
367 case TY_CTL___('T' ) : /* DC4: ignored */ break; 367 case TY_CTL___('T' ) : /* DC4: ignored */ break;
368 case TY_CTL___('U' ) : /* NAK: ignored */ break; 368 case TY_CTL___('U' ) : /* NAK: ignored */ break;
369 case TY_CTL___('V' ) : /* SYN: ignored */ break; 369 case TY_CTL___('V' ) : /* SYN: ignored */ break;
370 case TY_CTL___('W' ) : /* ETB: ignored */ break; 370 case TY_CTL___('W' ) : /* ETB: ignored */ break;
371 case TY_CTL___('X' ) : scr->ShowCharacter ( 0x2592); break; //VT100 371 case TY_CTL___('X' ) : scr->ShowCharacter ( 0x2592); break; //VT100
372 case TY_CTL___('Y' ) : /* EM : ignored */ break; 372 case TY_CTL___('Y' ) : /* EM : ignored */ break;
373 case TY_CTL___('Z' ) : scr->ShowCharacter ( 0x2592); break; //VT100 373 case TY_CTL___('Z' ) : scr->ShowCharacter ( 0x2592); break; //VT100
374 case TY_CTL___('[' ) : /* ESC: cannot be seen here. */ break; 374 case TY_CTL___('[' ) : /* ESC: cannot be seen here. */ break;
375 case TY_CTL___('\\' ) : /* FS : ignored */ break; 375 case TY_CTL___('\\' ) : /* FS : ignored */ break;
376 case TY_CTL___(']' ) : /* GS : ignored */ break; 376 case TY_CTL___(']' ) : /* GS : ignored */ break;
377 case TY_CTL___('^' ) : /* RS : ignored */ break; 377 case TY_CTL___('^' ) : /* RS : ignored */ break;
378 case TY_CTL___('_' ) : /* US : ignored */ break; 378 case TY_CTL___('_' ) : /* US : ignored */ break;
379 379
380 case TY_ESC___('D' ) : scr->index ( ); break; //VT100 380 case TY_ESC___('D' ) : scr->index ( ); break; //VT100
381 case TY_ESC___('E' ) : scr->NextLine ( ); break; //VT100 381 case TY_ESC___('E' ) : scr->NextLine ( ); break; //VT100
382 case TY_ESC___('H' ) : scr->changeTabStop (TRUE ); break; //VT100 382 case TY_ESC___('H' ) : scr->changeTabStop (TRUE ); break; //VT100
383 case TY_ESC___('M' ) : scr->reverseIndex ( ); break; //VT100 383 case TY_ESC___('M' ) : scr->reverseIndex ( ); break; //VT100
384 case TY_ESC___('Z' ) : reportTerminalType ( ); break; 384 case TY_ESC___('Z' ) : reportTerminalType ( ); break;
385 case TY_ESC___('c' ) : reset ( ); break; 385 case TY_ESC___('c' ) : reset ( ); break;
386 386
387 case TY_ESC___('n' ) : useCharset ( 2); break; 387 case TY_ESC___('n' ) : useCharset ( 2); break;
388 case TY_ESC___('o' ) : useCharset ( 3); break; 388 case TY_ESC___('o' ) : useCharset ( 3); break;
389 case TY_ESC___('7' ) : saveCursor ( ); break; 389 case TY_ESC___('7' ) : saveCursor ( ); break;
390 case TY_ESC___('8' ) : restoreCursor ( ); break; 390 case TY_ESC___('8' ) : restoreCursor ( ); break;
391 391
392 case TY_ESC___('=' ) : setMode (MODE_AppKeyPad); break; 392 case TY_ESC___('=' ) : setMode (MODE_AppKeyPad); break;
393 case TY_ESC___('>' ) : resetMode (MODE_AppKeyPad); break; 393 case TY_ESC___('>' ) : resetMode (MODE_AppKeyPad); break;
394 case TY_ESC___('<' ) : setMode (MODE_Ansi ); break; //VT100 394 case TY_ESC___('<' ) : setMode (MODE_Ansi ); break; //VT100
395 395
396 case TY_ESC_CS('(', '0') : setCharset (0, '0'); break; //VT100 396 case TY_ESC_CS('(', '0') : setCharset (0, '0'); break; //VT100
397 case TY_ESC_CS('(', 'A') : setCharset (0, 'A'); break; //VT100 397 case TY_ESC_CS('(', 'A') : setCharset (0, 'A'); break; //VT100
398 case TY_ESC_CS('(', 'B') : setCharset (0, 'B'); break; //VT100 398 case TY_ESC_CS('(', 'B') : setCharset (0, 'B'); break; //VT100
399 399
400 case TY_ESC_CS(')', '0') : setCharset (1, '0'); break; //VT100 400 case TY_ESC_CS(')', '0') : setCharset (1, '0'); break; //VT100
401 case TY_ESC_CS(')', 'A') : setCharset (1, 'A'); break; //VT100 401 case TY_ESC_CS(')', 'A') : setCharset (1, 'A'); break; //VT100
402 case TY_ESC_CS(')', 'B') : setCharset (1, 'B'); break; //VT100 402 case TY_ESC_CS(')', 'B') : setCharset (1, 'B'); break; //VT100
403 403
404 case TY_ESC_CS('*', '0') : setCharset (2, '0'); break; //VT100 404 case TY_ESC_CS('*', '0') : setCharset (2, '0'); break; //VT100
405 case TY_ESC_CS('*', 'A') : setCharset (2, 'A'); break; //VT100 405 case TY_ESC_CS('*', 'A') : setCharset (2, 'A'); break; //VT100
406 case TY_ESC_CS('*', 'B') : setCharset (2, 'B'); break; //VT100 406 case TY_ESC_CS('*', 'B') : setCharset (2, 'B'); break; //VT100
407 407
408 case TY_ESC_CS('+', '0') : setCharset (3, '0'); break; //VT100 408 case TY_ESC_CS('+', '0') : setCharset (3, '0'); break; //VT100
409 case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100 409 case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100
410 case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100 410 case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100
411 411
diff --git a/noncore/apps/opie-console/vt102emulation.h b/noncore/apps/opie-console/vt102emulation.h
index de4a62f..17ab449 100644
--- a/noncore/apps/opie-console/vt102emulation.h
+++ b/noncore/apps/opie-console/vt102emulation.h
@@ -1,153 +1,153 @@
1/* -------------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------------- */
2/* */ 2/* */
3/* [TEmuVt102.h] X Terminal Emulation */ 3/* [TEmuVt102.h] X Terminal Emulation */
4/* */ 4/* */
5/* -------------------------------------------------------------------------- */ 5/* -------------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* -------------------------------------------------------------------------- */ 11/* -------------------------------------------------------------------------- */
12 /* */ 12 /* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14 /* */ 14 /* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16 /* */ 16 /* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18/* Ported embedded-konsole to opie-terminal */ 18/* Ported embedded-konsole to opie-terminal */
19 /* */ 19 /* */
20/* Copyright (C) 2002 by opie developers <opie@handhelds.org> */ 20/* Copyright (C) 2002 by opie developers <opie@handhelds.org> */
21 /* */ 21 /* */
22/* -------------------------------------------------------------------------- */ 22/* -------------------------------------------------------------------------- */
23 23
24#ifndef VT102EMU_H 24#ifndef VT102EMU_H
25#define VT102EMU_H 25#define VT102EMU_H
26 26
27#include "widget.h" 27#include "widget_layer.h"
28#include "screen.h" 28#include "screen.h"
29#include "emulation_layer.h" 29#include "emulation_layer.h"
30#include <qtimer.h> 30#include <qtimer.h>
31#include <stdio.h> 31#include <stdio.h>
32 32
33// 33//
34 34
35#define MODE_AppScreen (MODES_SCREEN+0) 35#define MODE_AppScreen (MODES_SCREEN+0)
36#define MODE_AppCuKeys (MODES_SCREEN+1) 36#define MODE_AppCuKeys (MODES_SCREEN+1)
37#define MODE_AppKeyPad (MODES_SCREEN+2) 37#define MODE_AppKeyPad (MODES_SCREEN+2)
38#define MODE_Mouse1000 (MODES_SCREEN+3) 38#define MODE_Mouse1000 (MODES_SCREEN+3)
39#define MODE_Ansi (MODES_SCREEN+4) 39#define MODE_Ansi (MODES_SCREEN+4)
40#define MODE_total (MODES_SCREEN+5) 40#define MODE_total (MODES_SCREEN+5)
41 41
42struct DECpar 42struct DECpar
43{ 43{
44 BOOL mode[MODE_total]; 44 BOOL mode[MODE_total];
45}; 45};
46 46
47struct CharCodes 47struct CharCodes
48{ 48{
49 // coding info 49 // coding info
50 char charset[4]; // 50 char charset[4]; //
51 int cu_cs; // actual charset. 51 int cu_cs; // actual charset.
52 bool graphic; // Some VT100 tricks 52 bool graphic; // Some VT100 tricks
53 bool pound ; // Some VT100 tricks 53 bool pound ; // Some VT100 tricks
54 bool sa_graphic; // saved graphic 54 bool sa_graphic; // saved graphic
55 bool sa_pound; // saved pound 55 bool sa_pound; // saved pound
56}; 56};
57 57
58class Vt102Emulation: public EmulationLayer 58class Vt102Emulation: public EmulationLayer
59{ Q_OBJECT 59{ Q_OBJECT
60 60
61public: 61public:
62 62
63 Vt102Emulation(WidgetLayer* gui); 63 Vt102Emulation(WidgetLayer* gui);
64 ~Vt102Emulation(); 64 ~Vt102Emulation();
65 65
66public slots: // signals incoming from Widget 66public slots: // signals incoming from Widget
67 67
68 void onKeyPress(QKeyEvent*); 68 void onKeyPress(QKeyEvent*);
69 void onMouse(int cb, int cx, int cy); 69 void onMouse(int cb, int cx, int cy);
70 70
71signals: 71signals:
72 72
73 void changeTitle(int,const QString&); 73 void changeTitle(int,const QString&);
74 void prevSession(); 74 void prevSession();
75 void nextSession(); 75 void nextSession();
76 76
77public: 77public:
78 78
79 void reset(); 79 void reset();
80 80
81 /** 81 /**
82 * receive a char from IOLayer 82 * receive a char from IOLayer
83 */ 83 */
84 void onRcvChar(int cc); 84 void onRcvChar(int cc);
85 85
86 /** 86 /**
87 * sends a list of bytes to the IOLayer 87 * sends a list of bytes to the IOLayer
88 */ 88 */
89 void sendString(const QByteArray&); 89 void sendString(const QByteArray&);
90 90
91 /** 91 /**
92 * @deprecated use QByteArray instead 92 * @deprecated use QByteArray instead
93 * see sendString() above 93 * see sendString() above
94 */ 94 */
95 void sendString(const char *); 95 void sendString(const char *);
96 96
97public: 97public:
98 98
99 BOOL getMode (int m); 99 BOOL getMode (int m);
100 100
101 void setMode (int m); 101 void setMode (int m);
102 void resetMode (int m); 102 void resetMode (int m);
103 void saveMode (int m); 103 void saveMode (int m);
104 void restoreMode(int m); 104 void restoreMode(int m);
105 void resetModes(); 105 void resetModes();
106 106
107 void setConnect(bool r); 107 void setConnect(bool r);
108 108
109private: 109private:
110 110
111 void resetToken(); 111 void resetToken();
112#define MAXPBUF 80 112#define MAXPBUF 80
113 void pushToToken(int cc); 113 void pushToToken(int cc);
114 int pbuf[MAXPBUF]; //FIXME: overflow? 114 int pbuf[MAXPBUF]; //FIXME: overflow?
115 int ppos; 115 int ppos;
116#define MAXARGS 15 116#define MAXARGS 15
117 void addDigit(int dig); 117 void addDigit(int dig);
118 void addArgument(); 118 void addArgument();
119 int argv[MAXARGS]; 119 int argv[MAXARGS];
120 int argc; 120 int argc;
121 void initTokenizer(); 121 void initTokenizer();
122 int tbl[256]; 122 int tbl[256];
123 123
124 void scan_buffer_report(); //FIXME: rename 124 void scan_buffer_report(); //FIXME: rename
125 void ReportErrorToken(); //FIXME: rename 125 void ReportErrorToken(); //FIXME: rename
126 126
127 void tau(int code, int p, int q); 127 void tau(int code, int p, int q);
128 void XtermHack(); 128 void XtermHack();
129 129
130 // 130 //
131 131
132 void reportTerminalType(); 132 void reportTerminalType();
133 void reportStatus(); 133 void reportStatus();
134 void reportAnswerBack(); 134 void reportAnswerBack();
135 void reportCursorPosition(); 135 void reportCursorPosition();
136 void reportTerminalParms(int p); 136 void reportTerminalParms(int p);
137 137
138protected: 138protected:
139 139
140 unsigned short applyCharset(unsigned short c); 140 unsigned short applyCharset(unsigned short c);
141 void setCharset(int n, int cs); 141 void setCharset(int n, int cs);
142 void useCharset(int n); 142 void useCharset(int n);
143 void setAndUseCharset(int n, int cs); 143 void setAndUseCharset(int n, int cs);
144 void saveCursor(); 144 void saveCursor();
145 void restoreCursor(); 145 void restoreCursor();
146 void resetCharset(int scrno); 146 void resetCharset(int scrno);
147 CharCodes charset[2]; 147 CharCodes charset[2];
148 148
149 DECpar currParm; 149 DECpar currParm;
150 DECpar saveParm; 150 DECpar saveParm;
151}; 151};
152 152
153#endif // ifndef ANSIEMU_H 153#endif // ifndef ANSIEMU_H