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

Konsole

  • kde-4.14
  • applications
  • konsole
  • src
Vt102Emulation.cpp
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 <robert.knight@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 // Own
24 #include "Vt102Emulation.h"
25 
26 // Standard
27 #include <stdio.h>
28 #include <unistd.h>
29 
30 // Qt
31 #include <QtCore/QEvent>
32 #include <QtCore/QTimer>
33 #include <QtGui/QKeyEvent>
34 
35 // KDE
36 #include <KLocalizedString>
37 #include <KDebug>
38 
39 // Konsole
40 #include "KeyboardTranslator.h"
41 #include "Screen.h"
42 #include "TerminalDisplay.h"
43 
44 using Konsole::Vt102Emulation;
45 
46 /*
47  The VT100 has 32 special graphical characters. The usual vt100 extended
48  xterm fonts have these at 0x00..0x1f.
49 
50  QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals
51  come in here as proper unicode characters.
52 
53  We treat non-iso10646 fonts as VT100 extended and do the required mapping
54  from unicode to 0x00..0x1f. The remaining translation is then left to the
55  QCodec.
56 */
57 
58 // assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i.
59 
60 unsigned short Konsole::vt100_graphics[32] = {
61  // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15
62  0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0,
63  0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
64  0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534,
65  0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7
66 };
67 
68 Vt102Emulation::Vt102Emulation()
69  : Emulation(),
70  _titleUpdateTimer(new QTimer(this))
71 {
72  _titleUpdateTimer->setSingleShot(true);
73  QObject::connect(_titleUpdateTimer , SIGNAL(timeout()) , this , SLOT(updateTitle()));
74 
75  initTokenizer();
76  reset();
77 }
78 
79 Vt102Emulation::~Vt102Emulation()
80 {}
81 
82 void Vt102Emulation::clearEntireScreen()
83 {
84  _currentScreen->clearEntireScreen();
85  bufferedUpdate();
86 }
87 
88 void Vt102Emulation::reset()
89 {
90  // Save the current codec so we can set it later.
91  // Ideally we would want to use the profile setting
92  const QTextCodec* currentCodec = codec();
93 
94  resetTokenizer();
95  resetModes();
96  resetCharset(0);
97  _screen[0]->reset();
98  resetCharset(1);
99  _screen[1]->reset();
100 
101  if (currentCodec)
102  setCodec(currentCodec);
103  else
104  setCodec(LocaleCodec);
105 
106  bufferedUpdate();
107 }
108 
109 /* ------------------------------------------------------------------------- */
110 /* */
111 /* Processing the incoming byte stream */
112 /* */
113 /* ------------------------------------------------------------------------- */
114 
115 /* Incoming Bytes Event pipeline
116 
117  This section deals with decoding the incoming character stream.
118  Decoding means here, that the stream is first separated into `tokens'
119  which are then mapped to a `meaning' provided as operations by the
120  `Screen' class or by the emulation class itself.
121 
122  The pipeline proceeds as follows:
123 
124  - Tokenizing the ESC codes (onReceiveChar)
125  - VT100 code page translation of plain characters (applyCharset)
126  - Interpretation of ESC codes (processToken)
127 
128  The escape codes and their meaning are described in the
129  technical reference of this program.
130 */
131 
132 // Tokens ------------------------------------------------------------------ --
133 
134 /*
135  Since the tokens are the central notion if this section, we've put them
136  in front. They provide the syntactical elements used to represent the
137  terminals operations as byte sequences.
138 
139  They are encodes here into a single machine word, so that we can later
140  switch over them easily. Depending on the token itself, additional
141  argument variables are filled with parameter values.
142 
143  The tokens are defined below:
144 
145  - CHR - Printable characters (32..255 but DEL (=127))
146  - CTL - Control characters (0..31 but ESC (= 27), DEL)
147  - ESC - Escape codes of the form <ESC><CHR but `[]()+*#'>
148  - ESC_DE - Escape codes of the form <ESC><any of `()+*#%'> C
149  - CSI_PN - Escape codes of the form <ESC>'[' {Pn} ';' {Pn} C
150  - CSI_PS - Escape codes of the form <ESC>'[' {Pn} ';' ... C
151  - CSI_PR - Escape codes of the form <ESC>'[' '?' {Pn} ';' ... C
152  - CSI_PE - Escape codes of the form <ESC>'[' '!' {Pn} ';' ... C
153  - VT52 - VT52 escape codes
154  - <ESC><Chr>
155  - <ESC>'Y'{Pc}{Pc}
156  - XTE_HA - Xterm window/terminal attribute commands
157  of the form <ESC>`]' {Pn} `;' {Text} <BEL>
158  (Note that these are handled differently to the other formats)
159 
160  The last two forms allow list of arguments. Since the elements of
161  the lists are treated individually the same way, they are passed
162  as individual tokens to the interpretation. Further, because the
163  meaning of the parameters are names (although represented as numbers),
164  they are includes within the token ('N').
165 
166 */
167 
168 #define TY_CONSTRUCT(T,A,N) ( ((((int)N) & 0xffff) << 16) | ((((int)A) & 0xff) << 8) | (((int)T) & 0xff) )
169 
170 #define TY_CHR( ) TY_CONSTRUCT(0,0,0)
171 #define TY_CTL(A ) TY_CONSTRUCT(1,A,0)
172 #define TY_ESC(A ) TY_CONSTRUCT(2,A,0)
173 #define TY_ESC_CS(A,B) TY_CONSTRUCT(3,A,B)
174 #define TY_ESC_DE(A ) TY_CONSTRUCT(4,A,0)
175 #define TY_CSI_PS(A,N) TY_CONSTRUCT(5,A,N)
176 #define TY_CSI_PN(A ) TY_CONSTRUCT(6,A,0)
177 #define TY_CSI_PR(A,N) TY_CONSTRUCT(7,A,N)
178 
179 #define TY_VT52(A) TY_CONSTRUCT(8,A,0)
180 #define TY_CSI_PG(A) TY_CONSTRUCT(9,A,0)
181 #define TY_CSI_PE(A) TY_CONSTRUCT(10,A,0)
182 
183 const int MAX_ARGUMENT = 4096;
184 
185 // Tokenizer --------------------------------------------------------------- --
186 
187 /* The tokenizer's state
188 
189  The state is represented by the buffer (tokenBuffer, tokenBufferPos),
190  and accompanied by decoded arguments kept in (argv,argc).
191  Note that they are kept internal in the tokenizer.
192 */
193 
194 void Vt102Emulation::resetTokenizer()
195 {
196  tokenBufferPos = 0;
197  argc = 0;
198  argv[0] = 0;
199  argv[1] = 0;
200 }
201 
202 void Vt102Emulation::addDigit(int digit)
203 {
204  if (argv[argc] < MAX_ARGUMENT)
205  argv[argc] = 10 * argv[argc] + digit;
206 }
207 
208 void Vt102Emulation::addArgument()
209 {
210  argc = qMin(argc + 1, MAXARGS - 1);
211  argv[argc] = 0;
212 }
213 
214 void Vt102Emulation::addToCurrentToken(int cc)
215 {
216  tokenBuffer[tokenBufferPos] = cc;
217  tokenBufferPos = qMin(tokenBufferPos + 1, MAX_TOKEN_LENGTH - 1);
218 }
219 
220 // Character Class flags used while decoding
221 const int CTL = 1; // Control character
222 const int CHR = 2; // Printable character
223 const int CPN = 4; // TODO: Document me
224 const int DIG = 8; // Digit
225 const int SCS = 16; // Select Character Set
226 const int GRP = 32; // TODO: Document me
227 const int CPS = 64; // Character which indicates end of window resize
228 
229 void Vt102Emulation::initTokenizer()
230 {
231  int i;
232  quint8* s;
233  for (i = 0; i < 256; ++i)
234  charClass[i] = 0;
235  for (i = 0; i < 32; ++i)
236  charClass[i] |= CTL;
237  for (i = 32; i < 256; ++i)
238  charClass[i] |= CHR;
239  for (s = (quint8*)"@ABCDGHILMPSTXZcdfry"; *s; ++s)
240  charClass[*s] |= CPN;
241  // resize = \e[8;<row>;<col>t
242  for (s = (quint8*)"t"; *s; ++s)
243  charClass[*s] |= CPS;
244  for (s = (quint8*)"0123456789"; *s; ++s)
245  charClass[*s] |= DIG;
246  for (s = (quint8*)"()+*%"; *s; ++s)
247  charClass[*s] |= SCS;
248  for (s = (quint8*)"()+*#[]%"; *s; ++s)
249  charClass[*s] |= GRP;
250 
251  resetTokenizer();
252 }
253 
254 /* Ok, here comes the nasty part of the decoder.
255 
256  Instead of keeping an explicit state, we deduce it from the
257  token scanned so far. It is then immediately combined with
258  the current character to form a scanning decision.
259 
260  This is done by the following defines.
261 
262  - P is the length of the token scanned so far.
263  - L (often P-1) is the position on which contents we base a decision.
264  - C is a character or a group of characters (taken from 'charClass').
265 
266  - 'cc' is the current character
267  - 's' is a pointer to the start of the token buffer
268  - 'p' is the current position within the token buffer
269 
270  Note that they need to applied in proper order.
271 */
272 
273 #define lec(P,L,C) (p == (P) && s[(L)] == (C))
274 #define lun( ) (p == 1 && cc >= 32 )
275 #define les(P,L,C) (p == (P) && s[L] < 256 && (charClass[s[(L)]] & (C)) == (C))
276 #define eec(C) (p >= 3 && cc == (C))
277 #define ees(C) (p >= 3 && cc < 256 && (charClass[cc] & (C)) == (C))
278 #define eps(C) (p >= 3 && s[2] != '?' && s[2] != '!' && s[2] != '>' && cc < 256 && (charClass[cc] & (C)) == (C))
279 #define epp( ) (p >= 3 && s[2] == '?')
280 #define epe( ) (p >= 3 && s[2] == '!')
281 #define egt( ) (p >= 3 && s[2] == '>')
282 #define Xpe (tokenBufferPos >= 2 && tokenBuffer[1] == ']')
283 #define Xte (Xpe && cc == 7 )
284 #define ces(C) (cc < 256 && (charClass[cc] & (C)) == (C) && !Xte)
285 
286 #define CNTL(c) ((c)-'@')
287 const int ESC = 27;
288 const int DEL = 127;
289 
290 // process an incoming unicode character
291 void Vt102Emulation::receiveChar(int cc)
292 {
293  if (cc == DEL)
294  return; //VT100: ignore.
295 
296  if (ces(CTL))
297  {
298  // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100
299  // This means, they do neither a resetTokenizer() nor a pushToToken(). Some of them, do
300  // of course. Guess this originates from a weakly layered handling of the X-on
301  // X-off protocol, which comes really below this level.
302  if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC)
303  resetTokenizer(); //VT100: CAN or SUB
304  if (cc != ESC)
305  {
306  processToken(TY_CTL(cc+'@' ),0,0);
307  return;
308  }
309  }
310  // advance the state
311  addToCurrentToken(cc);
312 
313  int* s = tokenBuffer;
314  const int p = tokenBufferPos;
315 
316  if (getMode(MODE_Ansi))
317  {
318  if (lec(1,0,ESC)) { return; }
319  if (lec(1,0,ESC+128)) { s[0] = ESC; receiveChar('['); return; }
320  if (les(2,1,GRP)) { return; }
321  if (Xte ) { processWindowAttributeChange(); resetTokenizer(); return; }
322  if (Xpe ) { return; }
323  if (lec(3,2,'?')) { return; }
324  if (lec(3,2,'>')) { return; }
325  if (lec(3,2,'!')) { return; }
326  if (lun( )) { processToken( TY_CHR(), applyCharset(cc), 0); resetTokenizer(); return; }
327  if (lec(2,0,ESC)) { processToken( TY_ESC(s[1]), 0, 0); resetTokenizer(); return; }
328  if (les(3,1,SCS)) { processToken( TY_ESC_CS(s[1],s[2]), 0, 0); resetTokenizer(); return; }
329  if (lec(3,1,'#')) { processToken( TY_ESC_DE(s[2]), 0, 0); resetTokenizer(); return; }
330  if (eps( CPN)) { processToken( TY_CSI_PN(cc), argv[0],argv[1]); resetTokenizer(); return; }
331 
332  // resize = \e[8;<row>;<col>t
333  if (eps(CPS))
334  {
335  processToken( TY_CSI_PS(cc, argv[0]), argv[1], argv[2]);
336  resetTokenizer();
337  return;
338  }
339 
340  if (epe( )) { processToken( TY_CSI_PE(cc), 0, 0); resetTokenizer(); return; }
341  if (ees(DIG)) { addDigit(cc-'0'); return; }
342  if (eec(';')) { addArgument(); return; }
343  for (int i = 0; i <= argc; i++)
344  {
345  if (epp())
346  processToken(TY_CSI_PR(cc,argv[i]), 0, 0);
347  else if (egt())
348  processToken(TY_CSI_PG(cc), 0, 0); // spec. case for ESC]>0c or ESC]>c
349  else if (cc == 'm' && argc - i >= 4 && (argv[i] == 38 || argv[i] == 48) && argv[i+1] == 2)
350  {
351  // ESC[ ... 48;2;<red>;<green>;<blue> ... m -or- ESC[ ... 38;2;<red>;<green>;<blue> ... m
352  i += 2;
353  processToken(TY_CSI_PS(cc, argv[i-2]), COLOR_SPACE_RGB, (argv[i] << 16) | (argv[i+1] << 8) | argv[i+2]);
354  i += 2;
355  }
356  else if (cc == 'm' && argc - i >= 2 && (argv[i] == 38 || argv[i] == 48) && argv[i+1] == 5)
357  {
358  // ESC[ ... 48;5;<index> ... m -or- ESC[ ... 38;5;<index> ... m
359  i += 2;
360  processToken(TY_CSI_PS(cc, argv[i-2]), COLOR_SPACE_256, argv[i]);
361  }
362  else
363  processToken(TY_CSI_PS(cc,argv[i]), 0, 0);
364  }
365  resetTokenizer();
366  }
367  else
368  {
369  // VT52 Mode
370  if (lec(1,0,ESC))
371  return;
372  if (les(1,0,CHR))
373  {
374  processToken( TY_CHR(), s[0], 0);
375  resetTokenizer();
376  return;
377  }
378  if (lec(2,1,'Y'))
379  return;
380  if (lec(3,1,'Y'))
381  return;
382  if (p < 4)
383  {
384  processToken(TY_VT52(s[1] ), 0, 0);
385  resetTokenizer();
386  return;
387  }
388  processToken(TY_VT52(s[1]), s[2], s[3]);
389  resetTokenizer();
390  return;
391  }
392 }
393 void Vt102Emulation::processWindowAttributeChange()
394 {
395  // Describes the window or terminal session attribute to change
396  // See Session::UserTitleChange for possible values
397  int attributeToChange = 0;
398  int i;
399  for (i = 2; i < tokenBufferPos &&
400  tokenBuffer[i] >= '0' &&
401  tokenBuffer[i] <= '9'; i++)
402  {
403  attributeToChange = 10 * attributeToChange + (tokenBuffer[i]-'0');
404  }
405 
406  if (tokenBuffer[i] != ';')
407  {
408  reportDecodingError();
409  return;
410  }
411 
412  QString newValue;
413  newValue.reserve(tokenBufferPos-i-2);
414  for (int j = 0; j < tokenBufferPos-i-2; j++)
415  newValue[j] = tokenBuffer[i+1+j];
416 
417  _pendingTitleUpdates[attributeToChange] = newValue;
418  _titleUpdateTimer->start(20);
419 }
420 
421 void Vt102Emulation::updateTitle()
422 {
423  QListIterator<int> iter( _pendingTitleUpdates.keys() );
424  while (iter.hasNext()) {
425  int arg = iter.next();
426  emit titleChanged( arg , _pendingTitleUpdates[arg] );
427  }
428  _pendingTitleUpdates.clear();
429 }
430 
431 // Interpreting Codes ---------------------------------------------------------
432 
433 /*
434  Now that the incoming character stream is properly tokenized,
435  meaning is assigned to them. These are either operations of
436  the current _screen, or of the emulation class itself.
437 
438  The token to be interpreted comes in as a machine word
439  possibly accompanied by two parameters.
440 
441  Likewise, the operations assigned to, come with up to two
442  arguments. One could consider to make up a proper table
443  from the function below.
444 
445  The technical reference manual provides more information
446  about this mapping.
447 */
448 
449 void Vt102Emulation::processToken(int token, int p, int q)
450 {
451  switch (token)
452  {
453  case TY_CHR( ) : _currentScreen->displayCharacter (p ); break; //UTF16
454 
455  // 127 DEL : ignored on input
456 
457  case TY_CTL('@' ) : /* NUL: ignored */ break;
458  case TY_CTL('A' ) : /* SOH: ignored */ break;
459  case TY_CTL('B' ) : /* STX: ignored */ break;
460  case TY_CTL('C' ) : /* ETX: ignored */ break;
461  case TY_CTL('D' ) : /* EOT: ignored */ break;
462  case TY_CTL('E' ) : reportAnswerBack ( ); break; //VT100
463  case TY_CTL('F' ) : /* ACK: ignored */ break;
464  case TY_CTL('G' ) : emit stateSet(NOTIFYBELL);
465  break; //VT100
466  case TY_CTL('H' ) : _currentScreen->backspace ( ); break; //VT100
467  case TY_CTL('I' ) : _currentScreen->tab ( ); break; //VT100
468  case TY_CTL('J' ) : _currentScreen->newLine ( ); break; //VT100
469  case TY_CTL('K' ) : _currentScreen->newLine ( ); break; //VT100
470  case TY_CTL('L' ) : _currentScreen->newLine ( ); break; //VT100
471  case TY_CTL('M' ) : _currentScreen->toStartOfLine ( ); break; //VT100
472 
473  case TY_CTL('N' ) : useCharset ( 1); break; //VT100
474  case TY_CTL('O' ) : useCharset ( 0); break; //VT100
475 
476  case TY_CTL('P' ) : /* DLE: ignored */ break;
477  case TY_CTL('Q' ) : /* DC1: XON continue */ break; //VT100
478  case TY_CTL('R' ) : /* DC2: ignored */ break;
479  case TY_CTL('S' ) : /* DC3: XOFF halt */ break; //VT100
480  case TY_CTL('T' ) : /* DC4: ignored */ break;
481  case TY_CTL('U' ) : /* NAK: ignored */ break;
482  case TY_CTL('V' ) : /* SYN: ignored */ break;
483  case TY_CTL('W' ) : /* ETB: ignored */ break;
484  case TY_CTL('X' ) : _currentScreen->displayCharacter ( 0x2592); break; //VT100
485  case TY_CTL('Y' ) : /* EM : ignored */ break;
486  case TY_CTL('Z' ) : _currentScreen->displayCharacter ( 0x2592); break; //VT100
487  case TY_CTL('[' ) : /* ESC: cannot be seen here. */ break;
488  case TY_CTL('\\' ) : /* FS : ignored */ break;
489  case TY_CTL(']' ) : /* GS : ignored */ break;
490  case TY_CTL('^' ) : /* RS : ignored */ break;
491  case TY_CTL('_' ) : /* US : ignored */ break;
492 
493  case TY_ESC('D' ) : _currentScreen->index ( ); break; //VT100
494  case TY_ESC('E' ) : _currentScreen->nextLine ( ); break; //VT100
495  case TY_ESC('H' ) : _currentScreen->changeTabStop (true ); break; //VT100
496  case TY_ESC('M' ) : _currentScreen->reverseIndex ( ); break; //VT100
497  case TY_ESC('Z' ) : reportTerminalType ( ); break;
498  case TY_ESC('c' ) : reset ( ); break;
499 
500  case TY_ESC('n' ) : useCharset ( 2); break;
501  case TY_ESC('o' ) : useCharset ( 3); break;
502  case TY_ESC('7' ) : saveCursor ( ); break;
503  case TY_ESC('8' ) : restoreCursor ( ); break;
504 
505  case TY_ESC('=' ) : setMode (MODE_AppKeyPad); break;
506  case TY_ESC('>' ) : resetMode (MODE_AppKeyPad); break;
507  case TY_ESC('<' ) : setMode (MODE_Ansi ); break; //VT100
508 
509  case TY_ESC_CS('(', '0') : setCharset (0, '0'); break; //VT100
510  case TY_ESC_CS('(', 'A') : setCharset (0, 'A'); break; //VT100
511  case TY_ESC_CS('(', 'B') : setCharset (0, 'B'); break; //VT100
512 
513  case TY_ESC_CS(')', '0') : setCharset (1, '0'); break; //VT100
514  case TY_ESC_CS(')', 'A') : setCharset (1, 'A'); break; //VT100
515  case TY_ESC_CS(')', 'B') : setCharset (1, 'B'); break; //VT100
516 
517  case TY_ESC_CS('*', '0') : setCharset (2, '0'); break; //VT100
518  case TY_ESC_CS('*', 'A') : setCharset (2, 'A'); break; //VT100
519  case TY_ESC_CS('*', 'B') : setCharset (2, 'B'); break; //VT100
520 
521  case TY_ESC_CS('+', '0') : setCharset (3, '0'); break; //VT100
522  case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100
523  case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100
524 
525  case TY_ESC_CS('%', 'G') : setCodec (Utf8Codec ); break; //LINUX
526  case TY_ESC_CS('%', '@') : setCodec (LocaleCodec ); break; //LINUX
527 
528  case TY_ESC_DE('3' ) : /* Double height line, top half */
529  _currentScreen->setLineProperty( LINE_DOUBLEWIDTH , true );
530  _currentScreen->setLineProperty( LINE_DOUBLEHEIGHT , true );
531  break;
532  case TY_ESC_DE('4' ) : /* Double height line, bottom half */
533  _currentScreen->setLineProperty( LINE_DOUBLEWIDTH , true );
534  _currentScreen->setLineProperty( LINE_DOUBLEHEIGHT , true );
535  break;
536  case TY_ESC_DE('5' ) : /* Single width, single height line*/
537  _currentScreen->setLineProperty( LINE_DOUBLEWIDTH , false);
538  _currentScreen->setLineProperty( LINE_DOUBLEHEIGHT , false);
539  break;
540  case TY_ESC_DE('6' ) : /* Double width, single height line*/
541  _currentScreen->setLineProperty( LINE_DOUBLEWIDTH , true);
542  _currentScreen->setLineProperty( LINE_DOUBLEHEIGHT , false);
543  break;
544  case TY_ESC_DE('8' ) : _currentScreen->helpAlign ( ); break;
545 
546 // resize = \e[8;<row>;<col>t
547  case TY_CSI_PS('t', 8) : setImageSize( p /*lines */, q /* columns */ );
548  emit imageResizeRequest(QSize(q, p));
549  break;
550 
551 // change tab text color : \e[28;<color>t color: 0-16,777,215
552  case TY_CSI_PS('t', 28) : emit changeTabTextColorRequest ( p ); break;
553 
554  case TY_CSI_PS('K', 0) : _currentScreen->clearToEndOfLine ( ); break;
555  case TY_CSI_PS('K', 1) : _currentScreen->clearToBeginOfLine ( ); break;
556  case TY_CSI_PS('K', 2) : _currentScreen->clearEntireLine ( ); break;
557  case TY_CSI_PS('J', 0) : _currentScreen->clearToEndOfScreen ( ); break;
558  case TY_CSI_PS('J', 1) : _currentScreen->clearToBeginOfScreen ( ); break;
559  case TY_CSI_PS('J', 2) : _currentScreen->clearEntireScreen ( ); break;
560  case TY_CSI_PS('J', 3) : clearHistory(); break;
561  case TY_CSI_PS('g', 0) : _currentScreen->changeTabStop (false ); break; //VT100
562  case TY_CSI_PS('g', 3) : _currentScreen->clearTabStops ( ); break; //VT100
563  case TY_CSI_PS('h', 4) : _currentScreen-> setMode (MODE_Insert ); break;
564  case TY_CSI_PS('h', 20) : setMode (MODE_NewLine ); break;
565  case TY_CSI_PS('i', 0) : /* IGNORE: attached printer */ break; //VT100
566  case TY_CSI_PS('l', 4) : _currentScreen-> resetMode (MODE_Insert ); break;
567  case TY_CSI_PS('l', 20) : resetMode (MODE_NewLine ); break;
568  case TY_CSI_PS('s', 0) : saveCursor ( ); break;
569  case TY_CSI_PS('u', 0) : restoreCursor ( ); break;
570 
571  case TY_CSI_PS('m', 0) : _currentScreen->setDefaultRendition ( ); break;
572  case TY_CSI_PS('m', 1) : _currentScreen-> setRendition (RE_BOLD ); break; //VT100
573  case TY_CSI_PS('m', 3) : _currentScreen-> setRendition (RE_ITALIC ); break; //VT100
574  case TY_CSI_PS('m', 4) : _currentScreen-> setRendition (RE_UNDERLINE); break; //VT100
575  case TY_CSI_PS('m', 5) : _currentScreen-> setRendition (RE_BLINK ); break; //VT100
576  case TY_CSI_PS('m', 7) : _currentScreen-> setRendition (RE_REVERSE ); break;
577  case TY_CSI_PS('m', 10) : /* IGNORED: mapping related */ break; //LINUX
578  case TY_CSI_PS('m', 11) : /* IGNORED: mapping related */ break; //LINUX
579  case TY_CSI_PS('m', 12) : /* IGNORED: mapping related */ break; //LINUX
580  case TY_CSI_PS('m', 22) : _currentScreen->resetRendition (RE_BOLD ); break;
581  case TY_CSI_PS('m', 23) : _currentScreen->resetRendition (RE_ITALIC ); break; //VT100
582  case TY_CSI_PS('m', 24) : _currentScreen->resetRendition (RE_UNDERLINE); break;
583  case TY_CSI_PS('m', 25) : _currentScreen->resetRendition (RE_BLINK ); break;
584  case TY_CSI_PS('m', 27) : _currentScreen->resetRendition (RE_REVERSE ); break;
585 
586  case TY_CSI_PS('m', 30) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 0); break;
587  case TY_CSI_PS('m', 31) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 1); break;
588  case TY_CSI_PS('m', 32) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 2); break;
589  case TY_CSI_PS('m', 33) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 3); break;
590  case TY_CSI_PS('m', 34) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 4); break;
591  case TY_CSI_PS('m', 35) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 5); break;
592  case TY_CSI_PS('m', 36) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 6); break;
593  case TY_CSI_PS('m', 37) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 7); break;
594 
595  case TY_CSI_PS('m', 38) : _currentScreen->setForeColor (p, q); break;
596 
597  case TY_CSI_PS('m', 39) : _currentScreen->setForeColor (COLOR_SPACE_DEFAULT, 0); break;
598 
599  case TY_CSI_PS('m', 40) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 0); break;
600  case TY_CSI_PS('m', 41) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 1); break;
601  case TY_CSI_PS('m', 42) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 2); break;
602  case TY_CSI_PS('m', 43) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 3); break;
603  case TY_CSI_PS('m', 44) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 4); break;
604  case TY_CSI_PS('m', 45) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 5); break;
605  case TY_CSI_PS('m', 46) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 6); break;
606  case TY_CSI_PS('m', 47) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 7); break;
607 
608  case TY_CSI_PS('m', 48) : _currentScreen->setBackColor (p, q); break;
609 
610  case TY_CSI_PS('m', 49) : _currentScreen->setBackColor (COLOR_SPACE_DEFAULT, 1); break;
611 
612  case TY_CSI_PS('m', 90) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 8); break;
613  case TY_CSI_PS('m', 91) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 9); break;
614  case TY_CSI_PS('m', 92) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 10); break;
615  case TY_CSI_PS('m', 93) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 11); break;
616  case TY_CSI_PS('m', 94) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 12); break;
617  case TY_CSI_PS('m', 95) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 13); break;
618  case TY_CSI_PS('m', 96) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 14); break;
619  case TY_CSI_PS('m', 97) : _currentScreen->setForeColor (COLOR_SPACE_SYSTEM, 15); break;
620 
621  case TY_CSI_PS('m', 100) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 8); break;
622  case TY_CSI_PS('m', 101) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 9); break;
623  case TY_CSI_PS('m', 102) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 10); break;
624  case TY_CSI_PS('m', 103) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 11); break;
625  case TY_CSI_PS('m', 104) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 12); break;
626  case TY_CSI_PS('m', 105) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 13); break;
627  case TY_CSI_PS('m', 106) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 14); break;
628  case TY_CSI_PS('m', 107) : _currentScreen->setBackColor (COLOR_SPACE_SYSTEM, 15); break;
629 
630  case TY_CSI_PS('n', 5) : reportStatus ( ); break;
631  case TY_CSI_PS('n', 6) : reportCursorPosition ( ); break;
632  case TY_CSI_PS('q', 0) : /* IGNORED: LEDs off */ break; //VT100
633  case TY_CSI_PS('q', 1) : /* IGNORED: LED1 on */ break; //VT100
634  case TY_CSI_PS('q', 2) : /* IGNORED: LED2 on */ break; //VT100
635  case TY_CSI_PS('q', 3) : /* IGNORED: LED3 on */ break; //VT100
636  case TY_CSI_PS('q', 4) : /* IGNORED: LED4 on */ break; //VT100
637  case TY_CSI_PS('x', 0) : reportTerminalParms ( 2); break; //VT100
638  case TY_CSI_PS('x', 1) : reportTerminalParms ( 3); break; //VT100
639 
640  case TY_CSI_PN('@' ) : _currentScreen->insertChars (p ); break;
641  case TY_CSI_PN('A' ) : _currentScreen->cursorUp (p ); break; //VT100
642  case TY_CSI_PN('B' ) : _currentScreen->cursorDown (p ); break; //VT100
643  case TY_CSI_PN('C' ) : _currentScreen->cursorRight (p ); break; //VT100
644  case TY_CSI_PN('D' ) : _currentScreen->cursorLeft (p ); break; //VT100
645  case TY_CSI_PN('E' ) : /* Not implemented: cursor next p lines */ break; //VT100
646  case TY_CSI_PN('F' ) : /* Not implemented: cursor preceding p lines */ break; //VT100
647  case TY_CSI_PN('G' ) : _currentScreen->setCursorX (p ); break; //LINUX
648  case TY_CSI_PN('H' ) : _currentScreen->setCursorYX (p, q); break; //VT100
649  case TY_CSI_PN('I' ) : _currentScreen->tab (p ); break;
650  case TY_CSI_PN('L' ) : _currentScreen->insertLines (p ); break;
651  case TY_CSI_PN('M' ) : _currentScreen->deleteLines (p ); break;
652  case TY_CSI_PN('P' ) : _currentScreen->deleteChars (p ); break;
653  case TY_CSI_PN('S' ) : _currentScreen->scrollUp (p ); break;
654  case TY_CSI_PN('T' ) : _currentScreen->scrollDown (p ); break;
655  case TY_CSI_PN('X' ) : _currentScreen->eraseChars (p ); break;
656  case TY_CSI_PN('Z' ) : _currentScreen->backtab (p ); break;
657  case TY_CSI_PN('c' ) : reportTerminalType ( ); break; //VT100
658  case TY_CSI_PN('d' ) : _currentScreen->setCursorY (p ); break; //LINUX
659  case TY_CSI_PN('f' ) : _currentScreen->setCursorYX (p, q); break; //VT100
660  case TY_CSI_PN('r' ) : setMargins (p, q); break; //VT100
661  case TY_CSI_PN('y' ) : /* IGNORED: Confidence test */ break; //VT100
662 
663  case TY_CSI_PR('h', 1) : setMode (MODE_AppCuKeys); break; //VT100
664  case TY_CSI_PR('l', 1) : resetMode (MODE_AppCuKeys); break; //VT100
665  case TY_CSI_PR('s', 1) : saveMode (MODE_AppCuKeys); break; //FIXME
666  case TY_CSI_PR('r', 1) : restoreMode (MODE_AppCuKeys); break; //FIXME
667 
668  case TY_CSI_PR('l', 2) : resetMode (MODE_Ansi ); break; //VT100
669 
670  case TY_CSI_PR('h', 3) : setMode (MODE_132Columns); break; //VT100
671  case TY_CSI_PR('l', 3) : resetMode (MODE_132Columns); break; //VT100
672 
673  case TY_CSI_PR('h', 4) : /* IGNORED: soft scrolling */ break; //VT100
674  case TY_CSI_PR('l', 4) : /* IGNORED: soft scrolling */ break; //VT100
675 
676  case TY_CSI_PR('h', 5) : _currentScreen-> setMode (MODE_Screen ); break; //VT100
677  case TY_CSI_PR('l', 5) : _currentScreen-> resetMode (MODE_Screen ); break; //VT100
678 
679  case TY_CSI_PR('h', 6) : _currentScreen-> setMode (MODE_Origin ); break; //VT100
680  case TY_CSI_PR('l', 6) : _currentScreen-> resetMode (MODE_Origin ); break; //VT100
681  case TY_CSI_PR('s', 6) : _currentScreen-> saveMode (MODE_Origin ); break; //FIXME
682  case TY_CSI_PR('r', 6) : _currentScreen->restoreMode (MODE_Origin ); break; //FIXME
683 
684  case TY_CSI_PR('h', 7) : _currentScreen-> setMode (MODE_Wrap ); break; //VT100
685  case TY_CSI_PR('l', 7) : _currentScreen-> resetMode (MODE_Wrap ); break; //VT100
686  case TY_CSI_PR('s', 7) : _currentScreen-> saveMode (MODE_Wrap ); break; //FIXME
687  case TY_CSI_PR('r', 7) : _currentScreen->restoreMode (MODE_Wrap ); break; //FIXME
688 
689  case TY_CSI_PR('h', 8) : /* IGNORED: autorepeat on */ break; //VT100
690  case TY_CSI_PR('l', 8) : /* IGNORED: autorepeat off */ break; //VT100
691  case TY_CSI_PR('s', 8) : /* IGNORED: autorepeat on */ break; //VT100
692  case TY_CSI_PR('r', 8) : /* IGNORED: autorepeat off */ break; //VT100
693 
694  case TY_CSI_PR('h', 9) : /* IGNORED: interlace */ break; //VT100
695  case TY_CSI_PR('l', 9) : /* IGNORED: interlace */ break; //VT100
696  case TY_CSI_PR('s', 9) : /* IGNORED: interlace */ break; //VT100
697  case TY_CSI_PR('r', 9) : /* IGNORED: interlace */ break; //VT100
698 
699  case TY_CSI_PR('h', 12) : /* IGNORED: Cursor blink */ break; //att610
700  case TY_CSI_PR('l', 12) : /* IGNORED: Cursor blink */ break; //att610
701  case TY_CSI_PR('s', 12) : /* IGNORED: Cursor blink */ break; //att610
702  case TY_CSI_PR('r', 12) : /* IGNORED: Cursor blink */ break; //att610
703 
704  case TY_CSI_PR('h', 25) : setMode (MODE_Cursor ); break; //VT100
705  case TY_CSI_PR('l', 25) : resetMode (MODE_Cursor ); break; //VT100
706  case TY_CSI_PR('s', 25) : saveMode (MODE_Cursor ); break; //VT100
707  case TY_CSI_PR('r', 25) : restoreMode (MODE_Cursor ); break; //VT100
708 
709  case TY_CSI_PR('h', 40) : setMode(MODE_Allow132Columns ); break; // XTERM
710  case TY_CSI_PR('l', 40) : resetMode(MODE_Allow132Columns ); break; // XTERM
711 
712  case TY_CSI_PR('h', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM
713  case TY_CSI_PR('l', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM
714  case TY_CSI_PR('s', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM
715  case TY_CSI_PR('r', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM
716 
717  case TY_CSI_PR('h', 47) : setMode (MODE_AppScreen); break; //VT100
718  case TY_CSI_PR('l', 47) : resetMode (MODE_AppScreen); break; //VT100
719  case TY_CSI_PR('s', 47) : saveMode (MODE_AppScreen); break; //XTERM
720  case TY_CSI_PR('r', 47) : restoreMode (MODE_AppScreen); break; //XTERM
721 
722  case TY_CSI_PR('h', 67) : /* IGNORED: DECBKM */ break; //XTERM
723  case TY_CSI_PR('l', 67) : /* IGNORED: DECBKM */ break; //XTERM
724  case TY_CSI_PR('s', 67) : /* IGNORED: DECBKM */ break; //XTERM
725  case TY_CSI_PR('r', 67) : /* IGNORED: DECBKM */ break; //XTERM
726 
727  // XTerm defines the following modes:
728  // SET_VT200_MOUSE 1000
729  // SET_VT200_HIGHLIGHT_MOUSE 1001
730  // SET_BTN_EVENT_MOUSE 1002
731  // SET_ANY_EVENT_MOUSE 1003
732  //
733 
734  //Note about mouse modes:
735  //There are four mouse modes which xterm-compatible terminals can support - 1000,1001,1002,1003
736  //Konsole currently supports mode 1000 (basic mouse press and release) and mode 1002 (dragging the mouse).
737  //TODO: Implementation of mouse modes 1001 (something called hilight tracking) and
738  //1003 (a slight variation on dragging the mouse)
739  //
740 
741  case TY_CSI_PR('h', 1000) : setMode (MODE_Mouse1000); break; //XTERM
742  case TY_CSI_PR('l', 1000) : resetMode (MODE_Mouse1000); break; //XTERM
743  case TY_CSI_PR('s', 1000) : saveMode (MODE_Mouse1000); break; //XTERM
744  case TY_CSI_PR('r', 1000) : restoreMode (MODE_Mouse1000); break; //XTERM
745 
746  case TY_CSI_PR('h', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM
747  case TY_CSI_PR('l', 1001) : resetMode (MODE_Mouse1001); break; //XTERM
748  case TY_CSI_PR('s', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM
749  case TY_CSI_PR('r', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM
750 
751  case TY_CSI_PR('h', 1002) : setMode (MODE_Mouse1002); break; //XTERM
752  case TY_CSI_PR('l', 1002) : resetMode (MODE_Mouse1002); break; //XTERM
753  case TY_CSI_PR('s', 1002) : saveMode (MODE_Mouse1002); break; //XTERM
754  case TY_CSI_PR('r', 1002) : restoreMode (MODE_Mouse1002); break; //XTERM
755 
756  case TY_CSI_PR('h', 1003) : setMode (MODE_Mouse1003); break; //XTERM
757  case TY_CSI_PR('l', 1003) : resetMode (MODE_Mouse1003); break; //XTERM
758  case TY_CSI_PR('s', 1003) : saveMode (MODE_Mouse1003); break; //XTERM
759  case TY_CSI_PR('r', 1003) : restoreMode (MODE_Mouse1003); break; //XTERM
760 
761  case TY_CSI_PR('h', 1005) : setMode (MODE_Mouse1005); break; //XTERM
762  case TY_CSI_PR('l', 1005) : resetMode (MODE_Mouse1005); break; //XTERM
763  case TY_CSI_PR('s', 1005) : saveMode (MODE_Mouse1005); break; //XTERM
764  case TY_CSI_PR('r', 1005) : restoreMode (MODE_Mouse1005); break; //XTERM
765 
766  case TY_CSI_PR('h', 1006) : setMode (MODE_Mouse1006); break; //XTERM
767  case TY_CSI_PR('l', 1006) : resetMode (MODE_Mouse1006); break; //XTERM
768  case TY_CSI_PR('s', 1006) : saveMode (MODE_Mouse1006); break; //XTERM
769  case TY_CSI_PR('r', 1006) : restoreMode (MODE_Mouse1006); break; //XTERM
770 
771  case TY_CSI_PR('h', 1015) : setMode (MODE_Mouse1015); break; //URXVT
772  case TY_CSI_PR('l', 1015) : resetMode (MODE_Mouse1015); break; //URXVT
773  case TY_CSI_PR('s', 1015) : saveMode (MODE_Mouse1015); break; //URXVT
774  case TY_CSI_PR('r', 1015) : restoreMode (MODE_Mouse1015); break; //URXVT
775 
776  case TY_CSI_PR('h', 1034) : /* IGNORED: 8bitinput activation */ break; //XTERM
777 
778  case TY_CSI_PR('h', 1047) : setMode (MODE_AppScreen); break; //XTERM
779  case TY_CSI_PR('l', 1047) : _screen[1]->clearEntireScreen(); resetMode(MODE_AppScreen); break; //XTERM
780  case TY_CSI_PR('s', 1047) : saveMode (MODE_AppScreen); break; //XTERM
781  case TY_CSI_PR('r', 1047) : restoreMode (MODE_AppScreen); break; //XTERM
782 
783  //FIXME: Unitoken: save translations
784  case TY_CSI_PR('h', 1048) : saveCursor ( ); break; //XTERM
785  case TY_CSI_PR('l', 1048) : restoreCursor ( ); break; //XTERM
786  case TY_CSI_PR('s', 1048) : saveCursor ( ); break; //XTERM
787  case TY_CSI_PR('r', 1048) : restoreCursor ( ); break; //XTERM
788 
789  //FIXME: every once new sequences like this pop up in xterm.
790  // Here's a guess of what they could mean.
791  case TY_CSI_PR('h', 1049) : saveCursor(); _screen[1]->clearEntireScreen(); setMode(MODE_AppScreen); break; //XTERM
792  case TY_CSI_PR('l', 1049) : resetMode(MODE_AppScreen); restoreCursor(); break; //XTERM
793 
794  case TY_CSI_PR('h', 2004) : setMode (MODE_BracketedPaste); break; //XTERM
795  case TY_CSI_PR('l', 2004) : resetMode (MODE_BracketedPaste); break; //XTERM
796  case TY_CSI_PR('s', 2004) : saveMode (MODE_BracketedPaste); break; //XTERM
797  case TY_CSI_PR('r', 2004) : restoreMode (MODE_BracketedPaste); break; //XTERM
798 
799  //FIXME: weird DEC reset sequence
800  case TY_CSI_PE('p' ) : /* IGNORED: reset ( ) */ break;
801 
802  //FIXME: when changing between vt52 and ansi mode evtl do some resetting.
803  case TY_VT52('A' ) : _currentScreen->cursorUp ( 1); break; //VT52
804  case TY_VT52('B' ) : _currentScreen->cursorDown ( 1); break; //VT52
805  case TY_VT52('C' ) : _currentScreen->cursorRight ( 1); break; //VT52
806  case TY_VT52('D' ) : _currentScreen->cursorLeft ( 1); break; //VT52
807 
808  case TY_VT52('F' ) : setAndUseCharset (0, '0'); break; //VT52
809  case TY_VT52('G' ) : setAndUseCharset (0, 'B'); break; //VT52
810 
811  case TY_VT52('H' ) : _currentScreen->setCursorYX (1,1 ); break; //VT52
812  case TY_VT52('I' ) : _currentScreen->reverseIndex ( ); break; //VT52
813  case TY_VT52('J' ) : _currentScreen->clearToEndOfScreen ( ); break; //VT52
814  case TY_VT52('K' ) : _currentScreen->clearToEndOfLine ( ); break; //VT52
815  case TY_VT52('Y' ) : _currentScreen->setCursorYX (p-31,q-31 ); break; //VT52
816  case TY_VT52('Z' ) : reportTerminalType ( ); break; //VT52
817  case TY_VT52('<' ) : setMode (MODE_Ansi ); break; //VT52
818  case TY_VT52('=' ) : setMode (MODE_AppKeyPad); break; //VT52
819  case TY_VT52('>' ) : resetMode (MODE_AppKeyPad); break; //VT52
820 
821  case TY_CSI_PG('c' ) : reportSecondaryAttributes( ); break; //VT100
822 
823  default:
824  reportDecodingError();
825  break;
826  };
827 }
828 
829 void Vt102Emulation::clearScreenAndSetColumns(int columnCount)
830 {
831  setImageSize(_currentScreen->getLines(),columnCount);
832  clearEntireScreen();
833  setDefaultMargins();
834  _currentScreen->setCursorYX(0,0);
835 }
836 
837 void Vt102Emulation::sendString(const char* s , int length)
838 {
839  if ( length >= 0 )
840  emit sendData(s,length);
841  else
842  emit sendData(s,qstrlen(s));
843 }
844 
845 void Vt102Emulation::reportCursorPosition()
846 {
847  char tmp[20];
848  snprintf(tmp, sizeof(tmp), "\033[%d;%dR", _currentScreen->getCursorY()+1, _currentScreen->getCursorX()+1);
849  sendString(tmp);
850 }
851 
852 void Vt102Emulation::reportTerminalType()
853 {
854  // Primary device attribute response (Request was: ^[[0c or ^[[c (from TT321 Users Guide))
855  // VT220: ^[[?63;1;2;3;6;7;8c (list deps on emul. capabilities)
856  // VT100: ^[[?1;2c
857  // VT101: ^[[?1;0c
858  // VT102: ^[[?6v
859  if (getMode(MODE_Ansi))
860  sendString("\033[?1;2c"); // I'm a VT100
861  else
862  sendString("\033/Z"); // I'm a VT52
863 }
864 
865 void Vt102Emulation::reportSecondaryAttributes()
866 {
867  // Secondary device attribute response (Request was: ^[[>0c or ^[[>c)
868  if (getMode(MODE_Ansi))
869  sendString("\033[>0;115;0c"); // Why 115? ;)
870  else
871  sendString("\033/Z"); // FIXME I don't think VT52 knows about it but kept for
872  // konsoles backward compatibility.
873 }
874 
875 /* DECREPTPARM – Report Terminal Parameters
876  ESC [ <sol>; <par>; <nbits>; <xspeed>; <rspeed>; <clkmul>; <flags> x
877 
878  http://vt100.net/docs/vt100-ug/chapter3.html
879 */
880 void Vt102Emulation::reportTerminalParms(int p)
881 {
882  char tmp[100];
883 /*
884  sol=1: This message is a request; report in response to a request.
885  par=1: No parity set
886  nbits=1: 8 bits per character
887  xspeed=112: 9600
888  rspeed=112: 9600
889  clkmul=1: The bit rate multiplier is 16.
890  flags=0: None
891 */
892  snprintf(tmp, sizeof(tmp), "\033[%d;1;1;112;112;1;0x", p); // not really true.
893  sendString(tmp);
894 }
895 
896 void Vt102Emulation::reportStatus()
897 {
898  sendString("\033[0n"); //VT100. Device status report. 0 = Ready.
899 }
900 
901 void Vt102Emulation::reportAnswerBack()
902 {
903  // FIXME - Test this with VTTEST
904  // This is really obsolete VT100 stuff.
905  const char* ANSWER_BACK = "";
906  sendString(ANSWER_BACK);
907 }
908 
919 void Vt102Emulation::sendMouseEvent(int cb, int cx, int cy , int eventType)
920 {
921  if (cx < 1 || cy < 1)
922  return;
923 
924  // With the exception of the 1006 mode, button release is encoded in cb.
925  // Note that if multiple extensions are enabled, the 1006 is used, so it's okay to check for only that.
926  if (eventType == 2 && !getMode(MODE_Mouse1006))
927  cb = 3;
928 
929  // normal buttons are passed as 0x20 + button,
930  // mouse wheel (buttons 4,5) as 0x5c + button
931  if (cb >= 4)
932  cb += 0x3c;
933 
934  //Mouse motion handling
935  if ((getMode(MODE_Mouse1002) || getMode(MODE_Mouse1003)) && eventType == 1)
936  cb += 0x20; //add 32 to signify motion event
937 
938  char command[32];
939  command[0] = '\0';
940  // Check the extensions in decreasing order of preference. Encoding the release event above assumes that 1006 comes first.
941  if (getMode(MODE_Mouse1006)) {
942  snprintf(command, sizeof(command), "\033[<%d;%d;%d%c", cb, cx, cy, eventType == 2 ? 'm' : 'M');
943  } else if (getMode(MODE_Mouse1015)) {
944  snprintf(command, sizeof(command), "\033[%d;%d;%dM", cb + 0x20, cx, cy);
945  } else if (getMode(MODE_Mouse1005)) {
946  if (cx <= 2015 && cy <= 2015) {
947  // The xterm extension uses UTF-8 (up to 2 bytes) to encode
948  // coordinate+32, no matter what the locale is. We could easily
949  // convert manually, but QString can also do it for us.
950  QChar coords[2];
951  coords[0] = cx + 0x20;
952  coords[1] = cy + 0x20;
953  QString coordsStr = QString(coords, 2);
954  QByteArray utf8 = coordsStr.toUtf8();
955  snprintf(command, sizeof(command), "\033[M%c%s", cb + 0x20, (const char *)utf8);
956  }
957  } else if (cx <= 223 && cy <= 223) {
958  snprintf(command, sizeof(command), "\033[M%c%c%c", cb + 0x20, cx + 0x20, cy + 0x20);
959  }
960 
961  sendString(command);
962 }
963 
964 void Vt102Emulation::sendText(const QString& text)
965 {
966  if (!text.isEmpty()) {
967  QKeyEvent event(QEvent::KeyPress,
968  0,
969  Qt::NoModifier,
970  text);
971  sendKeyEvent(&event); // expose as a big fat keypress event
972  }
973 }
974 void Vt102Emulation::sendKeyEvent(QKeyEvent* event)
975 {
976  const Qt::KeyboardModifiers modifiers = event->modifiers();
977  KeyboardTranslator::States states = KeyboardTranslator::NoState;
978 
979  // get current states
980  if (getMode(MODE_NewLine)) states |= KeyboardTranslator::NewLineState;
981  if (getMode(MODE_Ansi)) states |= KeyboardTranslator::AnsiState;
982  if (getMode(MODE_AppCuKeys)) states |= KeyboardTranslator::CursorKeysState;
983  if (getMode(MODE_AppScreen)) states |= KeyboardTranslator::AlternateScreenState;
984  if (getMode(MODE_AppKeyPad) && (modifiers & Qt::KeypadModifier))
985  states |= KeyboardTranslator::ApplicationKeypadState;
986 
987  // check flow control state
988  if (modifiers & Qt::ControlModifier) {
989  switch (event->key()) {
990  case Qt::Key_S:
991  emit flowControlKeyPressed(true);
992  break;
993  case Qt::Key_Q:
994  case Qt::Key_C: // cancel flow control
995  emit flowControlKeyPressed(false);
996  break;
997  }
998  }
999 
1000  // look up key binding
1001  if (_keyTranslator) {
1002  KeyboardTranslator::Entry entry = _keyTranslator->findEntry(
1003  event->key() ,
1004  modifiers,
1005  states);
1006 
1007  // send result to terminal
1008  QByteArray textToSend;
1009 
1010  // special handling for the Alt (aka. Meta) modifier. pressing
1011  // Alt+[Character] results in Esc+[Character] being sent
1012  // (unless there is an entry defined for this particular combination
1013  // in the keyboard modifier)
1014  const bool wantsAltModifier = entry.modifiers() & entry.modifierMask() & Qt::AltModifier;
1015  const bool wantsMetaModifier = entry.modifiers() & entry.modifierMask() & Qt::MetaModifier;
1016  const bool wantsAnyModifier = entry.state() &
1017  entry.stateMask() & KeyboardTranslator::AnyModifierState;
1018 
1019  if ( modifiers & Qt::AltModifier && !(wantsAltModifier || wantsAnyModifier)
1020  && !event->text().isEmpty() )
1021  {
1022  textToSend.prepend("\033");
1023  }
1024  if ( modifiers & Qt::MetaModifier && !(wantsMetaModifier || wantsAnyModifier)
1025  && !event->text().isEmpty() )
1026  {
1027  textToSend.prepend("\030@s");
1028  }
1029 
1030  if ( entry.command() != KeyboardTranslator::NoCommand )
1031  {
1032  TerminalDisplay * currentView = _currentScreen->currentTerminalDisplay();
1033 
1034  if (entry.command() & KeyboardTranslator::EraseCommand) {
1035  textToSend += eraseChar();
1036  } else if (entry.command() & KeyboardTranslator::ScrollPageUpCommand)
1037  currentView->scrollScreenWindow(ScreenWindow::ScrollPages, -1);
1038  else if (entry.command() & KeyboardTranslator::ScrollPageDownCommand)
1039  currentView->scrollScreenWindow(ScreenWindow::ScrollPages, 1);
1040  else if (entry.command() & KeyboardTranslator::ScrollLineUpCommand)
1041  currentView->scrollScreenWindow(ScreenWindow::ScrollLines, -1);
1042  else if (entry.command() & KeyboardTranslator::ScrollLineDownCommand)
1043  currentView->scrollScreenWindow(ScreenWindow::ScrollLines, 1);
1044  else if (entry.command() & KeyboardTranslator::ScrollUpToTopCommand)
1045  currentView->scrollScreenWindow(ScreenWindow::ScrollLines,
1046  - currentView->screenWindow()->currentLine());
1047  else if (entry.command() & KeyboardTranslator::ScrollDownToBottomCommand)
1048  currentView->scrollScreenWindow(ScreenWindow::ScrollLines, lineCount());
1049  }
1050  else if (!entry.text().isEmpty())
1051  {
1052  textToSend += _codec->fromUnicode(entry.text(true,modifiers));
1053  }
1054  else
1055  textToSend += _codec->fromUnicode(event->text());
1056 
1057  sendData(textToSend.constData(), textToSend.length());
1058  }
1059  else
1060  {
1061  // print an error message to the terminal if no key translator has been
1062  // set
1063  QString translatorError = i18n("No keyboard translator available. "
1064  "The information needed to convert key presses "
1065  "into characters to send to the terminal "
1066  "is missing.");
1067  reset();
1068  receiveData(translatorError.toAscii().constData(), translatorError.count());
1069  }
1070 }
1071 
1072 /* ------------------------------------------------------------------------- */
1073 /* */
1074 /* VT100 Charsets */
1075 /* */
1076 /* ------------------------------------------------------------------------- */
1077 
1078 // Character Set Conversion ------------------------------------------------ --
1079 
1080 /*
1081  The processing contains a VT100 specific code translation layer.
1082  It's still in use and mainly responsible for the line drawing graphics.
1083 
1084  These and some other glyphs are assigned to codes (0x5f-0xfe)
1085  normally occupied by the latin letters. Since this codes also
1086  appear within control sequences, the extra code conversion
1087  does not permute with the tokenizer and is placed behind it
1088  in the pipeline. It only applies to tokens, which represent
1089  plain characters.
1090 
1091  This conversion it eventually continued in TerminalDisplay.C, since
1092  it might involve VT100 enhanced fonts, which have these
1093  particular glyphs allocated in (0x00-0x1f) in their code page.
1094 */
1095 
1096 #define CHARSET _charset[_currentScreen==_screen[1]]
1097 
1098 // Apply current character map.
1099 
1100 unsigned short Vt102Emulation::applyCharset(unsigned short c)
1101 {
1102  if (CHARSET.graphic && 0x5f <= c && c <= 0x7e) return vt100_graphics[c - 0x5f];
1103  if (CHARSET.pound && c == '#') return 0xa3; //This mode is obsolete
1104  return c;
1105 }
1106 
1107 /*
1108  "Charset" related part of the emulation state.
1109  This configures the VT100 charset filter.
1110 
1111  While most operation work on the current _screen,
1112  the following two are different.
1113 */
1114 
1115 void Vt102Emulation::resetCharset(int scrno)
1116 {
1117  _charset[scrno].cu_cs = 0;
1118  qstrncpy(_charset[scrno].charset, "BBBB", 4);
1119  _charset[scrno].sa_graphic = false;
1120  _charset[scrno].sa_pound = false;
1121  _charset[scrno].graphic = false;
1122  _charset[scrno].pound = false;
1123 }
1124 
1125 void Vt102Emulation::setCharset(int n, int cs) // on both screens.
1126 {
1127  _charset[0].charset[n & 3] = cs; useCharset(_charset[0].cu_cs);
1128  _charset[1].charset[n & 3] = cs; useCharset(_charset[1].cu_cs);
1129 }
1130 
1131 void Vt102Emulation::setAndUseCharset(int n, int cs)
1132 {
1133  CHARSET.charset[n & 3] = cs;
1134  useCharset(n & 3);
1135 }
1136 
1137 void Vt102Emulation::useCharset(int n)
1138 {
1139  CHARSET.cu_cs = n & 3;
1140  CHARSET.graphic = (CHARSET.charset[n & 3] == '0');
1141  CHARSET.pound = (CHARSET.charset[n & 3] == 'A'); //This mode is obsolete
1142 }
1143 
1144 void Vt102Emulation::setDefaultMargins()
1145 {
1146  _screen[0]->setDefaultMargins();
1147  _screen[1]->setDefaultMargins();
1148 }
1149 
1150 void Vt102Emulation::setMargins(int t, int b)
1151 {
1152  _screen[0]->setMargins(t, b);
1153  _screen[1]->setMargins(t, b);
1154 }
1155 
1156 void Vt102Emulation::saveCursor()
1157 {
1158  CHARSET.sa_graphic = CHARSET.graphic;
1159  CHARSET.sa_pound = CHARSET.pound; //This mode is obsolete
1160  // we are not clear about these
1161  //sa_charset = charsets[cScreen->_charset];
1162  //sa_charset_num = cScreen->_charset;
1163  _currentScreen->saveCursor();
1164 }
1165 
1166 void Vt102Emulation::restoreCursor()
1167 {
1168  CHARSET.graphic = CHARSET.sa_graphic;
1169  CHARSET.pound = CHARSET.sa_pound; //This mode is obsolete
1170  _currentScreen->restoreCursor();
1171 }
1172 
1173 /* ------------------------------------------------------------------------- */
1174 /* */
1175 /* Mode Operations */
1176 /* */
1177 /* ------------------------------------------------------------------------- */
1178 
1179 /*
1180  Some of the emulations state is either added to the state of the screens.
1181 
1182  This causes some scoping problems, since different emulations choose to
1183  located the mode either to the current _screen or to both.
1184 
1185  For strange reasons, the extend of the rendition attributes ranges over
1186  all screens and not over the actual _screen.
1187 
1188  We decided on the precise precise extend, somehow.
1189 */
1190 
1191 // "Mode" related part of the state. These are all booleans.
1192 
1193 void Vt102Emulation::resetModes()
1194 {
1195  // MODE_Allow132Columns is not reset here
1196  // to match Xterm's behavior (see Xterm's VTReset() function)
1197 
1198  resetMode(MODE_132Columns); saveMode(MODE_132Columns);
1199  resetMode(MODE_Mouse1000); saveMode(MODE_Mouse1000);
1200  resetMode(MODE_Mouse1001); saveMode(MODE_Mouse1001);
1201  resetMode(MODE_Mouse1002); saveMode(MODE_Mouse1002);
1202  resetMode(MODE_Mouse1003); saveMode(MODE_Mouse1003);
1203  resetMode(MODE_Mouse1005); saveMode(MODE_Mouse1005);
1204  resetMode(MODE_Mouse1006); saveMode(MODE_Mouse1006);
1205  resetMode(MODE_Mouse1015); saveMode(MODE_Mouse1015);
1206  resetMode(MODE_BracketedPaste); saveMode(MODE_BracketedPaste);
1207 
1208  resetMode(MODE_AppScreen); saveMode(MODE_AppScreen);
1209  resetMode(MODE_AppCuKeys); saveMode(MODE_AppCuKeys);
1210  resetMode(MODE_AppKeyPad); saveMode(MODE_AppKeyPad);
1211  resetMode(MODE_NewLine);
1212  setMode(MODE_Ansi);
1213 }
1214 
1215 void Vt102Emulation::setMode(int m)
1216 {
1217  _currentModes.mode[m] = true;
1218  switch (m) {
1219  case MODE_132Columns:
1220  if (getMode(MODE_Allow132Columns))
1221  clearScreenAndSetColumns(132);
1222  else
1223  _currentModes.mode[m] = false;
1224  break;
1225  case MODE_Mouse1000:
1226  case MODE_Mouse1001:
1227  case MODE_Mouse1002:
1228  case MODE_Mouse1003:
1229  emit programUsesMouseChanged(false);
1230  break;
1231 
1232  case MODE_BracketedPaste:
1233  emit programBracketedPasteModeChanged(true);
1234  break;
1235 
1236  case MODE_AppScreen :
1237  _screen[1]->clearSelection();
1238  setScreen(1);
1239  break;
1240  }
1241  // FIXME: Currently this has a redundant condition as MODES_SCREEN is 6
1242  // and MODE_NewLine is 5
1243  if (m < MODES_SCREEN || m == MODE_NewLine) {
1244  _screen[0]->setMode(m);
1245  _screen[1]->setMode(m);
1246  }
1247 }
1248 
1249 void Vt102Emulation::resetMode(int m)
1250 {
1251  _currentModes.mode[m] = false;
1252  switch (m) {
1253  case MODE_132Columns:
1254  if (getMode(MODE_Allow132Columns))
1255  clearScreenAndSetColumns(80);
1256  break;
1257  case MODE_Mouse1000 :
1258  case MODE_Mouse1001 :
1259  case MODE_Mouse1002 :
1260  case MODE_Mouse1003 :
1261  emit programUsesMouseChanged(true);
1262  break;
1263 
1264  case MODE_BracketedPaste:
1265  emit programBracketedPasteModeChanged(false);
1266  break;
1267 
1268  case MODE_AppScreen :
1269  _screen[0]->clearSelection();
1270  setScreen(0);
1271  break;
1272  }
1273  // FIXME: Currently this has a redundant condition as MODES_SCREEN is 6
1274  // and MODE_NewLine is 5
1275  if (m < MODES_SCREEN || m == MODE_NewLine) {
1276  _screen[0]->resetMode(m);
1277  _screen[1]->resetMode(m);
1278  }
1279 }
1280 
1281 void Vt102Emulation::saveMode(int m)
1282 {
1283  _savedModes.mode[m] = _currentModes.mode[m];
1284 }
1285 
1286 void Vt102Emulation::restoreMode(int m)
1287 {
1288  if (_savedModes.mode[m])
1289  setMode(m);
1290  else
1291  resetMode(m);
1292 }
1293 
1294 bool Vt102Emulation::getMode(int m)
1295 {
1296  return _currentModes.mode[m];
1297 }
1298 
1299 char Vt102Emulation::eraseChar() const
1300 {
1301  KeyboardTranslator::Entry entry = _keyTranslator->findEntry(
1302  Qt::Key_Backspace,
1303  0,
1304  0);
1305  if (entry.text().count() > 0)
1306  return entry.text()[0];
1307  else
1308  return '\b';
1309 }
1310 
1311 #if 0
1312 // print contents of the scan buffer
1313 static void hexdump(int* s, int len)
1314 {
1315  int i;
1316  for (i = 0; i < len; i++) {
1317  if (s[i] == '\\')
1318  printf("\\\\");
1319  else if ((s[i]) > 32 && s[i] < 127)
1320  printf("%c", s[i]);
1321  else
1322  printf("\\%04x(hex)", s[i]);
1323  }
1324 }
1325 #endif
1326 
1327 // return contents of the scan buffer
1328 static QString hexdump2(int* s, int len)
1329 {
1330  int i;
1331  char dump[128];
1332  QString returnDump;
1333 
1334  for (i = 0; i < len; i++) {
1335  if (s[i] == '\\')
1336  snprintf(dump, sizeof(dump), "%s", "\\\\");
1337  else if ((s[i]) > 32 && s[i] < 127)
1338  snprintf(dump, sizeof(dump), "%c", s[i]);
1339  else
1340  snprintf(dump, sizeof(dump), "\\%04x(hex)", s[i]);
1341  returnDump.append(QString(dump));
1342  }
1343  return returnDump;
1344 }
1345 
1346 void Vt102Emulation::reportDecodingError()
1347 {
1348  if (tokenBufferPos == 0 || (tokenBufferPos == 1 && (tokenBuffer[0] & 0xff) >= 32))
1349  return;
1350 
1351 // printf("Undecodable sequence: ");
1352 // hexdump(tokenBuffer, tokenBufferPos);
1353 // printf("\n");
1354 
1355  QString outputError = QString("Undecodable sequence: ");
1356  outputError.append(hexdump2(tokenBuffer, tokenBufferPos));
1357  kDebug() << outputError;
1358 }
1359 
1360 #include "Vt102Emulation.moc"
1361 
Konsole::Vt102Emulation::~Vt102Emulation
~Vt102Emulation()
Definition: Vt102Emulation.cpp:79
TY_CSI_PG
#define TY_CSI_PG(A)
Definition: Vt102Emulation.cpp:180
QTextCodec::fromUnicode
QByteArray fromUnicode(const QString &str) const
Konsole::Screen::resetMode
void resetMode(int mode)
Resets (clears) the specified screen mode.
Definition: Screen.cpp:253
MODE_AppKeyPad
#define MODE_AppKeyPad
Definition: Vt102Emulation.h:38
QString::append
QString & append(QChar ch)
Konsole::Emulation::programBracketedPasteModeChanged
void programBracketedPasteModeChanged(bool bracketedPasteMode)
Konsole::KeyboardTranslator::EraseCommand
Echos the operating system specific erase character.
Definition: KeyboardTranslator.h:112
Konsole::vt100_graphics
unsigned short vt100_graphics[32]
Definition: Vt102Emulation.cpp:60
Konsole::Emulation::setImageSize
virtual void setImageSize(int lines, int columns)
Change the size of the emulation's image.
Definition: Emulation.cpp:338
Konsole::Emulation::titleChanged
void titleChanged(int title, const QString &newTitle)
Emitted when the program running in the terminal wishes to update the session's title.
CTL
const int CTL
Definition: Vt102Emulation.cpp:221
QListIterator::next
const T & next()
Konsole::Screen::getLines
int getLines() const
Return the number of lines.
Definition: Screen.h:382
QByteArray
ces
#define ces(C)
Definition: Vt102Emulation.cpp:284
COLOR_SPACE_RGB
#define COLOR_SPACE_RGB
Definition: CharacterColor.h:142
Konsole::Emulation::_currentScreen
Screen * _currentScreen
Definition: Emulation.h:445
TY_VT52
#define TY_VT52(A)
Definition: Vt102Emulation.cpp:179
Konsole::Emulation::sendData
void sendData(const char *data, int len)
Emitted when a buffer of data is ready to send to the standard input of the terminal.
Konsole::KeyboardTranslator::ScrollLineDownCommand
Scroll the terminal display down one line.
Definition: KeyboardTranslator.h:106
QChar
Konsole::ScreenWindow::currentLine
int currentLine() const
Returns the index of the line which is currently at the top of this window.
Definition: ScreenWindow.cpp:212
ees
#define ees(C)
Definition: Vt102Emulation.cpp:277
Konsole::Screen::clearEntireScreen
void clearEntireScreen()
Clear the whole screen, moving the current screen contents into the history first.
Definition: Screen.cpp:954
Konsole::KeyboardTranslator::ScrollUpToTopCommand
Scroll the terminal display up to the start of history.
Definition: KeyboardTranslator.h:108
Konsole::KeyboardTranslator::Entry::modifierMask
Qt::KeyboardModifiers modifierMask() const
Returns the keyboard modifiers which are valid in this entry.
Definition: KeyboardTranslator.h:464
MODE_BracketedPaste
#define MODE_BracketedPaste
Definition: Vt102Emulation.h:49
Screen.h
Konsole::KeyboardTranslator::CursorKeysState
TODO More documentation.
Definition: KeyboardTranslator.h:78
Konsole::KeyboardTranslator::Entry
Represents an association between a key sequence pressed by the user and the character sequence and c...
Definition: KeyboardTranslator.h:121
COLOR_SPACE_DEFAULT
#define COLOR_SPACE_DEFAULT
Definition: CharacterColor.h:139
Konsole::KeyboardTranslator::Entry::text
QByteArray text(bool expandWildCards=false, Qt::KeyboardModifiers keyboardModifiers=Qt::NoModifier) const
Returns the character sequence associated with this entry, optionally replacing wildcard '*' characte...
Definition: KeyboardTranslator.h:491
QByteArray::isEmpty
bool isEmpty() const
Konsole::KeyboardTranslator::AnyModifierState
Indicates that any of the modifier keys is active.
Definition: KeyboardTranslator.h:85
MODE_Mouse1000
#define MODE_Mouse1000
Definition: Vt102Emulation.h:39
Konsole::LINE_DOUBLEWIDTH
const int LINE_DOUBLEWIDTH
Definition: Character.h:35
Konsole::KeyboardTranslator::Entry::modifiers
Qt::KeyboardModifiers modifiers() const
Returns a bitwise-OR of the enabled keyboard modifiers associated with this entry.
Definition: KeyboardTranslator.h:455
Konsole::Emulation::Utf8Codec
Definition: Emulation.h:438
Konsole::RE_UNDERLINE
const int RE_UNDERLINE
Definition: Character.h:41
CPN
const int CPN
Definition: Vt102Emulation.cpp:223
Konsole::KeyboardTranslator::AlternateScreenState
Indicates that the alternate screen ( typically used by interactive programs such as screen or vim ) ...
Definition: KeyboardTranslator.h:83
QByteArray::length
int length() const
Konsole::KeyboardTranslator::NoState
Indicates that no special state is active.
Definition: KeyboardTranslator.h:65
Konsole::Vt102Emulation::reset
virtual void reset()
Resets the state of the terminal.
Definition: Vt102Emulation.cpp:88
epp
#define epp()
Definition: Vt102Emulation.cpp:279
Konsole::Vt102Emulation::sendMouseEvent
virtual void sendMouseEvent(int buttons, int column, int line, int eventType)
Definition: Vt102Emulation.cpp:919
MODE_Origin
#define MODE_Origin
Definition: Screen.h:36
MAX_ARGUMENT
const int MAX_ARGUMENT
Definition: Vt102Emulation.cpp:183
MODE_Insert
#define MODE_Insert
Definition: Screen.h:38
Konsole::Screen::currentTerminalDisplay
TerminalDisplay * currentTerminalDisplay()
Definition: Screen.h:569
MODES_SCREEN
#define MODES_SCREEN
Definition: Screen.h:42
MODE_Mouse1002
#define MODE_Mouse1002
Definition: Vt102Emulation.h:41
Konsole::Emulation::setCodec
void setCodec(const QTextCodec *)
Sets the codec used to decode incoming characters.
Definition: Emulation.cpp:149
Konsole::RE_BLINK
const int RE_BLINK
Definition: Character.h:40
COLOR_SPACE_256
#define COLOR_SPACE_256
Definition: CharacterColor.h:141
Konsole::Screen::setCursorYX
void setCursorYX(int y, int x)
Position the cursor at line y, column x.
Definition: Screen.cpp:799
Konsole::Emulation::_keyTranslator
const KeyboardTranslator * _keyTranslator
Definition: Emulation.h:458
Konsole::Emulation::LocaleCodec
Definition: Emulation.h:437
QObject::event
virtual bool event(QEvent *e)
MODE_Mouse1006
#define MODE_Mouse1006
Definition: Vt102Emulation.h:44
Konsole::Screen::setMargins
void setMargins(int topLine, int bottomLine)
Sets the margins for scrolling the screen.
Definition: Screen.cpp:130
Konsole::Vt102Emulation::receiveChar
virtual void receiveChar(int cc)
Processes an incoming character.
Definition: Vt102Emulation.cpp:291
Konsole::RE_ITALIC
const int RE_ITALIC
Definition: Character.h:44
Konsole::Emulation::bufferedUpdate
void bufferedUpdate()
Schedules an update of attached views.
Definition: Emulation.cpp:320
TY_ESC_DE
#define TY_ESC_DE(A)
Definition: Vt102Emulation.cpp:174
MAXARGS
#define MAXARGS
Definition: Vt102Emulation.h:136
MODE_Screen
#define MODE_Screen
Definition: Screen.h:39
Konsole::Emulation::programUsesMouseChanged
void programUsesMouseChanged(bool usesMouse)
This is emitted when the program running in the shell indicates whether or not it is interested in mo...
egt
#define egt()
Definition: Vt102Emulation.cpp:281
eec
#define eec(C)
Definition: Vt102Emulation.cpp:276
Konsole::Emulation::setScreen
void setScreen(int index)
Sets the active screen.
Definition: Emulation.cpp:118
CPS
const int CPS
Definition: Vt102Emulation.cpp:227
TerminalDisplay.h
Konsole::CharCodes::pound
bool pound
Definition: Vt102Emulation.h:61
Konsole::KeyboardTranslator::Entry::state
States state() const
Returns a bitwise-OR of the enabled state flags associated with this entry.
Definition: KeyboardTranslator.h:515
MAX_TOKEN_LENGTH
#define MAX_TOKEN_LENGTH
Definition: Vt102Emulation.h:132
MODE_Cursor
#define MODE_Cursor
Definition: Screen.h:40
KeyboardTranslator.h
TY_CSI_PS
#define TY_CSI_PS(A, N)
Definition: Vt102Emulation.cpp:175
QTimer
Konsole::KeyboardTranslator::AnsiState
Indicates that the terminal is in 'ANSI' mode.
Definition: KeyboardTranslator.h:74
TY_CSI_PR
#define TY_CSI_PR(A, N)
Definition: Vt102Emulation.cpp:177
Konsole::Vt102Emulation::eraseChar
virtual char eraseChar() const
Returns the special character used for erasing character.
Definition: Vt102Emulation.cpp:1299
Konsole::Vt102Emulation::sendText
virtual void sendText(const QString &text)
Definition: Vt102Emulation.cpp:964
Konsole::KeyboardTranslator::ScrollPageDownCommand
Scroll the terminal display down one page.
Definition: KeyboardTranslator.h:102
epe
#define epe()
Definition: Vt102Emulation.cpp:280
QByteArray::prepend
QByteArray & prepend(char ch)
Konsole::Vt102Emulation::resetMode
virtual void resetMode(int mode)
Definition: Vt102Emulation.cpp:1249
les
#define les(P, L, C)
Definition: Vt102Emulation.cpp:275
Konsole::Vt102Emulation::clearEntireScreen
virtual void clearEntireScreen()
Copies the current image into the history and clears the screen.
Definition: Vt102Emulation.cpp:82
Konsole::RE_REVERSE
const int RE_REVERSE
Definition: Character.h:42
QString::isEmpty
bool isEmpty() const
MODE_Ansi
#define MODE_Ansi
Definition: Vt102Emulation.h:46
Konsole::Vt102Emulation::sendString
virtual void sendString(const char *, int length=-1)
Definition: Vt102Emulation.cpp:837
QByteArray::constData
const char * constData() const
Vt102Emulation.h
TY_ESC
#define TY_ESC(A)
Definition: Vt102Emulation.cpp:172
QKeyEvent::text
QString text() const
Konsole::NOTIFYBELL
The terminal program has triggered a bell event to get the user's attention.
Definition: Emulation.h:57
Konsole::CharCodes::graphic
bool graphic
Definition: Vt102Emulation.h:60
Konsole::Emulation
Base class for terminal emulation back-ends.
Definition: Emulation.h:117
QByteArray::count
int count(char ch) const
TY_ESC_CS
#define TY_ESC_CS(A, B)
Definition: Vt102Emulation.cpp:173
QString
Konsole::KeyboardTranslator::findEntry
Entry findEntry(int keyCode, Qt::KeyboardModifiers modifiers, States state=NoState) const
Looks for an entry in this keyboard translator which matches the given key code, keyboard modifiers a...
Definition: KeyboardTranslator.cpp:680
TY_CHR
#define TY_CHR()
Definition: Vt102Emulation.cpp:170
QTextCodec
Konsole::Screen::restoreCursor
void restoreCursor()
Restores the position and appearance of the cursor.
Definition: Screen.cpp:288
Konsole::Emulation::lineCount
int lineCount() const
Returns the total number of lines, including those stored in the history.
Definition: Emulation.cpp:303
DEL
const int DEL
Definition: Vt102Emulation.cpp:288
SCS
const int SCS
Definition: Vt102Emulation.cpp:225
Konsole::CharCodes::sa_graphic
bool sa_graphic
Definition: Vt102Emulation.h:62
Konsole::Screen::clearSelection
void clearSelection()
Clears the current selection.
Definition: Screen.cpp:1029
Konsole::CharCodes::sa_pound
bool sa_pound
Definition: Vt102Emulation.h:63
MODE_Wrap
#define MODE_Wrap
Definition: Screen.h:37
QHash::keys
QList< Key > keys() const
GRP
const int GRP
Definition: Vt102Emulation.cpp:226
lec
#define lec(P, L, C)
Definition: Vt102Emulation.cpp:273
Konsole::KeyboardTranslator::Entry::stateMask
States stateMask() const
Returns the state flags which are valid in this entry.
Definition: KeyboardTranslator.h:524
hexdump2
static QString hexdump2(int *s, int len)
Definition: Vt102Emulation.cpp:1328
QHash::clear
void clear()
QKeyEvent::key
int key() const
QSize
eps
#define eps(C)
Definition: Vt102Emulation.cpp:278
MODE_AppScreen
#define MODE_AppScreen
Definition: Vt102Emulation.h:36
Konsole::Emulation::_codec
const QTextCodec * _codec
Definition: Emulation.h:456
Konsole::CharCodes::cu_cs
int cu_cs
Definition: Vt102Emulation.h:59
Konsole::KeyboardTranslator::ScrollDownToBottomCommand
Scroll the terminal display down to the end of history.
Definition: KeyboardTranslator.h:110
MODE_Allow132Columns
#define MODE_Allow132Columns
Definition: Vt102Emulation.h:48
Konsole::KeyboardTranslator::Entry::command
Command command() const
Returns the commands associated with this entry.
Definition: KeyboardTranslator.h:478
Konsole::Vt102Emulation
Provides an xterm compatible terminal emulation based on the DEC VT102 terminal.
Definition: Vt102Emulation.h:76
MODE_132Columns
#define MODE_132Columns
Definition: Vt102Emulation.h:47
QKeyEvent
Konsole::Screen::setDefaultMargins
void setDefaultMargins()
Resets the scrolling margins back to the top and bottom lines of the screen.
Definition: Screen.cpp:341
Konsole::KeyboardTranslator::NewLineState
TODO More documentation.
Definition: KeyboardTranslator.h:69
Konsole::Screen::getCursorX
int getCursorX() const
Returns the column which the cursor is positioned at.
Definition: Screen.cpp:830
ESC
const int ESC
Definition: Vt102Emulation.cpp:287
Konsole::TerminalDisplay::scrollScreenWindow
void scrollScreenWindow(enum ScreenWindow::RelativeScrollMode mode, int amount)
Scrolls current ScreenWindow.
Definition: TerminalDisplay.cpp:2933
MODE_Mouse1001
#define MODE_Mouse1001
Definition: Vt102Emulation.h:40
Konsole::CharCodes::charset
char charset[4]
Definition: Vt102Emulation.h:58
Konsole::Emulation::clearHistory
void clearHistory()
Clears the history scroll.
Definition: Emulation.cpp:133
QString::count
int count() const
Konsole::Screen::getCursorY
int getCursorY() const
Returns the line which the cursor is positioned on.
Definition: Screen.cpp:835
MODE_AppCuKeys
#define MODE_AppCuKeys
Definition: Vt102Emulation.h:37
Xpe
#define Xpe
Definition: Vt102Emulation.cpp:282
Konsole::KeyboardTranslator::NoCommand
Indicates that no command is associated with this command sequence.
Definition: KeyboardTranslator.h:96
CHARSET
#define CHARSET
Definition: Vt102Emulation.cpp:1096
MODE_Mouse1003
#define MODE_Mouse1003
Definition: Vt102Emulation.h:42
Konsole::Screen::reset
void reset(bool clearScreen=true)
Resets the state of the screen.
Definition: Screen.cpp:516
TY_CTL
#define TY_CTL(A)
Definition: Vt102Emulation.cpp:171
Konsole::Vt102Emulation::setMode
virtual void setMode(int mode)
Definition: Vt102Emulation.cpp:1215
Konsole::Emulation::changeTabTextColorRequest
void changeTabTextColorRequest(int color)
Requests that the color of the text used to represent the tabs associated with this emulation be chan...
Konsole::TerminalDisplay::screenWindow
ScreenWindow * screenWindow() const
Returns the terminal screen section which is displayed in this widget.
Definition: TerminalDisplay.cpp:103
Konsole::KeyboardTranslator::ScrollPageUpCommand
Scroll the terminal display up one page.
Definition: KeyboardTranslator.h:100
Konsole::RE_BOLD
const int RE_BOLD
Definition: Character.h:39
QString::reserve
void reserve(int size)
Konsole::KeyboardTranslator::ScrollLineUpCommand
Scroll the terminal display up one line.
Definition: KeyboardTranslator.h:104
Konsole::Emulation::receiveData
void receiveData(const char *buffer, int len)
Processes an incoming stream of characters.
Definition: Emulation.cpp:225
CHR
const int CHR
Definition: Vt102Emulation.cpp:222
QTimer::start
void start(int msec)
Konsole::Screen::setLineProperty
void setLineProperty(LineProperty property, bool enable)
Sets or clears an attribute of the current line.
Definition: Screen.cpp:1376
Konsole::Emulation::stateSet
void stateSet(int state)
Emitted when the activity state of the emulation is set.
Konsole::Vt102Emulation::sendKeyEvent
virtual void sendKeyEvent(QKeyEvent *)
Definition: Vt102Emulation.cpp:974
Konsole::Emulation::codec
const QTextCodec * codec() const
Returns the codec used to decode incoming characters.
Definition: Emulation.h:169
Konsole::Emulation::_screen
Screen * _screen[2]
Definition: Emulation.h:448
QListIterator
Konsole::Screen::saveCursor
void saveCursor()
Saves the current position and appearance (text color and style) of the cursor.
Definition: Screen.cpp:279
MODE_NewLine
#define MODE_NewLine
Definition: Screen.h:41
Konsole::Emulation::flowControlKeyPressed
void flowControlKeyPressed(bool suspendKeyPressed)
Emitted when a flow control key combination ( Ctrl+S or Ctrl+Q ) is pressed.
Konsole::KeyboardTranslator::ApplicationKeypadState
Indicates that the numpad is in application mode.
Definition: KeyboardTranslator.h:87
Konsole::Screen::setMode
void setMode(int mode)
Sets (enables) the specified screen mode.
Definition: Screen.cpp:242
Xte
#define Xte
Definition: Vt102Emulation.cpp:283
CNTL
#define CNTL(c)
Definition: Vt102Emulation.cpp:286
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
COLOR_SPACE_SYSTEM
#define COLOR_SPACE_SYSTEM
Definition: CharacterColor.h:140
MODE_Mouse1015
#define MODE_Mouse1015
Definition: Vt102Emulation.h:45
Konsole::Emulation::utf8
bool utf8() const
Convenience method.
Definition: Emulation.h:180
Konsole::TerminalDisplay
A widget which displays output from a terminal emulation and sends input keypresses and mouse activit...
Definition: TerminalDisplay.h:63
Konsole::Emulation::imageResizeRequest
void imageResizeRequest(const QSize &sizz)
Emitted after receiving the escape sequence which asks to change the terminal emulator's size...
TY_CSI_PE
#define TY_CSI_PE(A)
Definition: Vt102Emulation.cpp:181
Konsole::ScreenWindow::ScrollPages
Scroll the window down by a given number of pages, where one page is windowLines() lines...
Definition: ScreenWindow.h:200
DIG
const int DIG
Definition: Vt102Emulation.cpp:224
TY_CSI_PN
#define TY_CSI_PN(A)
Definition: Vt102Emulation.cpp:176
lun
#define lun()
Definition: Vt102Emulation.cpp:274
MODE_Mouse1005
#define MODE_Mouse1005
Definition: Vt102Emulation.h:43
QString::toAscii
QByteArray toAscii() const
QTimer::setSingleShot
void setSingleShot(bool singleShot)
Konsole::ScreenWindow::ScrollLines
Scroll the window down by a given number of lines.
Definition: ScreenWindow.h:195
Konsole::LINE_DOUBLEHEIGHT
const int LINE_DOUBLEHEIGHT
Definition: Character.h:36
Qt::KeyboardModifiers
typedef KeyboardModifiers
QString::toUtf8
QByteArray toUtf8() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:27 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
  • 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