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

Konsole

  • sources
  • kde-4.12
  • applications
  • konsole
  • src
Vt102Emulation.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('G' ) : _currentScreen->setCursorX (p ); break; //LINUX
646  case TY_CSI_PN('H' ) : _currentScreen->setCursorYX (p, q); break; //VT100
647  case TY_CSI_PN('I' ) : _currentScreen->tab (p ); break;
648  case TY_CSI_PN('L' ) : _currentScreen->insertLines (p ); break;
649  case TY_CSI_PN('M' ) : _currentScreen->deleteLines (p ); break;
650  case TY_CSI_PN('P' ) : _currentScreen->deleteChars (p ); break;
651  case TY_CSI_PN('S' ) : _currentScreen->scrollUp (p ); break;
652  case TY_CSI_PN('T' ) : _currentScreen->scrollDown (p ); break;
653  case TY_CSI_PN('X' ) : _currentScreen->eraseChars (p ); break;
654  case TY_CSI_PN('Z' ) : _currentScreen->backtab (p ); break;
655  case TY_CSI_PN('c' ) : reportTerminalType ( ); break; //VT100
656  case TY_CSI_PN('d' ) : _currentScreen->setCursorY (p ); break; //LINUX
657  case TY_CSI_PN('f' ) : _currentScreen->setCursorYX (p, q); break; //VT100
658  case TY_CSI_PN('r' ) : setMargins (p, q); break; //VT100
659  case TY_CSI_PN('y' ) : /* IGNORED: Confidence test */ break; //VT100
660 
661  case TY_CSI_PR('h', 1) : setMode (MODE_AppCuKeys); break; //VT100
662  case TY_CSI_PR('l', 1) : resetMode (MODE_AppCuKeys); break; //VT100
663  case TY_CSI_PR('s', 1) : saveMode (MODE_AppCuKeys); break; //FIXME
664  case TY_CSI_PR('r', 1) : restoreMode (MODE_AppCuKeys); break; //FIXME
665 
666  case TY_CSI_PR('l', 2) : resetMode (MODE_Ansi ); break; //VT100
667 
668  case TY_CSI_PR('h', 3) : setMode (MODE_132Columns); break; //VT100
669  case TY_CSI_PR('l', 3) : resetMode (MODE_132Columns); break; //VT100
670 
671  case TY_CSI_PR('h', 4) : /* IGNORED: soft scrolling */ break; //VT100
672  case TY_CSI_PR('l', 4) : /* IGNORED: soft scrolling */ break; //VT100
673 
674  case TY_CSI_PR('h', 5) : _currentScreen-> setMode (MODE_Screen ); break; //VT100
675  case TY_CSI_PR('l', 5) : _currentScreen-> resetMode (MODE_Screen ); break; //VT100
676 
677  case TY_CSI_PR('h', 6) : _currentScreen-> setMode (MODE_Origin ); break; //VT100
678  case TY_CSI_PR('l', 6) : _currentScreen-> resetMode (MODE_Origin ); break; //VT100
679  case TY_CSI_PR('s', 6) : _currentScreen-> saveMode (MODE_Origin ); break; //FIXME
680  case TY_CSI_PR('r', 6) : _currentScreen->restoreMode (MODE_Origin ); break; //FIXME
681 
682  case TY_CSI_PR('h', 7) : _currentScreen-> setMode (MODE_Wrap ); break; //VT100
683  case TY_CSI_PR('l', 7) : _currentScreen-> resetMode (MODE_Wrap ); break; //VT100
684  case TY_CSI_PR('s', 7) : _currentScreen-> saveMode (MODE_Wrap ); break; //FIXME
685  case TY_CSI_PR('r', 7) : _currentScreen->restoreMode (MODE_Wrap ); break; //FIXME
686 
687  case TY_CSI_PR('h', 8) : /* IGNORED: autorepeat on */ break; //VT100
688  case TY_CSI_PR('l', 8) : /* IGNORED: autorepeat off */ break; //VT100
689  case TY_CSI_PR('s', 8) : /* IGNORED: autorepeat on */ break; //VT100
690  case TY_CSI_PR('r', 8) : /* IGNORED: autorepeat off */ break; //VT100
691 
692  case TY_CSI_PR('h', 9) : /* IGNORED: interlace */ break; //VT100
693  case TY_CSI_PR('l', 9) : /* IGNORED: interlace */ break; //VT100
694  case TY_CSI_PR('s', 9) : /* IGNORED: interlace */ break; //VT100
695  case TY_CSI_PR('r', 9) : /* IGNORED: interlace */ break; //VT100
696 
697  case TY_CSI_PR('h', 12) : /* IGNORED: Cursor blink */ break; //att610
698  case TY_CSI_PR('l', 12) : /* IGNORED: Cursor blink */ break; //att610
699  case TY_CSI_PR('s', 12) : /* IGNORED: Cursor blink */ break; //att610
700  case TY_CSI_PR('r', 12) : /* IGNORED: Cursor blink */ break; //att610
701 
702  case TY_CSI_PR('h', 25) : setMode (MODE_Cursor ); break; //VT100
703  case TY_CSI_PR('l', 25) : resetMode (MODE_Cursor ); break; //VT100
704  case TY_CSI_PR('s', 25) : saveMode (MODE_Cursor ); break; //VT100
705  case TY_CSI_PR('r', 25) : restoreMode (MODE_Cursor ); break; //VT100
706 
707  case TY_CSI_PR('h', 40) : setMode(MODE_Allow132Columns ); break; // XTERM
708  case TY_CSI_PR('l', 40) : resetMode(MODE_Allow132Columns ); break; // XTERM
709 
710  case TY_CSI_PR('h', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM
711  case TY_CSI_PR('l', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM
712  case TY_CSI_PR('s', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM
713  case TY_CSI_PR('r', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM
714 
715  case TY_CSI_PR('h', 47) : setMode (MODE_AppScreen); break; //VT100
716  case TY_CSI_PR('l', 47) : resetMode (MODE_AppScreen); break; //VT100
717  case TY_CSI_PR('s', 47) : saveMode (MODE_AppScreen); break; //XTERM
718  case TY_CSI_PR('r', 47) : restoreMode (MODE_AppScreen); break; //XTERM
719 
720  case TY_CSI_PR('h', 67) : /* IGNORED: DECBKM */ break; //XTERM
721  case TY_CSI_PR('l', 67) : /* IGNORED: DECBKM */ break; //XTERM
722  case TY_CSI_PR('s', 67) : /* IGNORED: DECBKM */ break; //XTERM
723  case TY_CSI_PR('r', 67) : /* IGNORED: DECBKM */ break; //XTERM
724 
725  // XTerm defines the following modes:
726  // SET_VT200_MOUSE 1000
727  // SET_VT200_HIGHLIGHT_MOUSE 1001
728  // SET_BTN_EVENT_MOUSE 1002
729  // SET_ANY_EVENT_MOUSE 1003
730  //
731 
732  //Note about mouse modes:
733  //There are four mouse modes which xterm-compatible terminals can support - 1000,1001,1002,1003
734  //Konsole currently supports mode 1000 (basic mouse press and release) and mode 1002 (dragging the mouse).
735  //TODO: Implementation of mouse modes 1001 (something called hilight tracking) and
736  //1003 (a slight variation on dragging the mouse)
737  //
738 
739  case TY_CSI_PR('h', 1000) : setMode (MODE_Mouse1000); break; //XTERM
740  case TY_CSI_PR('l', 1000) : resetMode (MODE_Mouse1000); break; //XTERM
741  case TY_CSI_PR('s', 1000) : saveMode (MODE_Mouse1000); break; //XTERM
742  case TY_CSI_PR('r', 1000) : restoreMode (MODE_Mouse1000); break; //XTERM
743 
744  case TY_CSI_PR('h', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM
745  case TY_CSI_PR('l', 1001) : resetMode (MODE_Mouse1001); break; //XTERM
746  case TY_CSI_PR('s', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM
747  case TY_CSI_PR('r', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM
748 
749  case TY_CSI_PR('h', 1002) : setMode (MODE_Mouse1002); break; //XTERM
750  case TY_CSI_PR('l', 1002) : resetMode (MODE_Mouse1002); break; //XTERM
751  case TY_CSI_PR('s', 1002) : saveMode (MODE_Mouse1002); break; //XTERM
752  case TY_CSI_PR('r', 1002) : restoreMode (MODE_Mouse1002); break; //XTERM
753 
754  case TY_CSI_PR('h', 1003) : setMode (MODE_Mouse1003); break; //XTERM
755  case TY_CSI_PR('l', 1003) : resetMode (MODE_Mouse1003); break; //XTERM
756  case TY_CSI_PR('s', 1003) : saveMode (MODE_Mouse1003); break; //XTERM
757  case TY_CSI_PR('r', 1003) : restoreMode (MODE_Mouse1003); break; //XTERM
758 
759  case TY_CSI_PR('h', 1005) : setMode (MODE_Mouse1005); break; //XTERM
760  case TY_CSI_PR('l', 1005) : resetMode (MODE_Mouse1005); break; //XTERM
761  case TY_CSI_PR('s', 1005) : saveMode (MODE_Mouse1005); break; //XTERM
762  case TY_CSI_PR('r', 1005) : restoreMode (MODE_Mouse1005); break; //XTERM
763 
764  case TY_CSI_PR('h', 1006) : setMode (MODE_Mouse1006); break; //XTERM
765  case TY_CSI_PR('l', 1006) : resetMode (MODE_Mouse1006); break; //XTERM
766  case TY_CSI_PR('s', 1006) : saveMode (MODE_Mouse1006); break; //XTERM
767  case TY_CSI_PR('r', 1006) : restoreMode (MODE_Mouse1006); break; //XTERM
768 
769  case TY_CSI_PR('h', 1015) : setMode (MODE_Mouse1015); break; //URXVT
770  case TY_CSI_PR('l', 1015) : resetMode (MODE_Mouse1015); break; //URXVT
771  case TY_CSI_PR('s', 1015) : saveMode (MODE_Mouse1015); break; //URXVT
772  case TY_CSI_PR('r', 1015) : restoreMode (MODE_Mouse1015); break; //URXVT
773 
774  case TY_CSI_PR('h', 1034) : /* IGNORED: 8bitinput activation */ break; //XTERM
775 
776  case TY_CSI_PR('h', 1047) : setMode (MODE_AppScreen); break; //XTERM
777  case TY_CSI_PR('l', 1047) : _screen[1]->clearEntireScreen(); resetMode(MODE_AppScreen); break; //XTERM
778  case TY_CSI_PR('s', 1047) : saveMode (MODE_AppScreen); break; //XTERM
779  case TY_CSI_PR('r', 1047) : restoreMode (MODE_AppScreen); break; //XTERM
780 
781  //FIXME: Unitoken: save translations
782  case TY_CSI_PR('h', 1048) : saveCursor ( ); break; //XTERM
783  case TY_CSI_PR('l', 1048) : restoreCursor ( ); break; //XTERM
784  case TY_CSI_PR('s', 1048) : saveCursor ( ); break; //XTERM
785  case TY_CSI_PR('r', 1048) : restoreCursor ( ); break; //XTERM
786 
787  //FIXME: every once new sequences like this pop up in xterm.
788  // Here's a guess of what they could mean.
789  case TY_CSI_PR('h', 1049) : saveCursor(); _screen[1]->clearEntireScreen(); setMode(MODE_AppScreen); break; //XTERM
790  case TY_CSI_PR('l', 1049) : resetMode(MODE_AppScreen); restoreCursor(); break; //XTERM
791 
792  //FIXME: weird DEC reset sequence
793  case TY_CSI_PE('p' ) : /* IGNORED: reset ( ) */ break;
794 
795  //FIXME: when changing between vt52 and ansi mode evtl do some resetting.
796  case TY_VT52('A' ) : _currentScreen->cursorUp ( 1); break; //VT52
797  case TY_VT52('B' ) : _currentScreen->cursorDown ( 1); break; //VT52
798  case TY_VT52('C' ) : _currentScreen->cursorRight ( 1); break; //VT52
799  case TY_VT52('D' ) : _currentScreen->cursorLeft ( 1); break; //VT52
800 
801  case TY_VT52('F' ) : setAndUseCharset (0, '0'); break; //VT52
802  case TY_VT52('G' ) : setAndUseCharset (0, 'B'); break; //VT52
803 
804  case TY_VT52('H' ) : _currentScreen->setCursorYX (1,1 ); break; //VT52
805  case TY_VT52('I' ) : _currentScreen->reverseIndex ( ); break; //VT52
806  case TY_VT52('J' ) : _currentScreen->clearToEndOfScreen ( ); break; //VT52
807  case TY_VT52('K' ) : _currentScreen->clearToEndOfLine ( ); break; //VT52
808  case TY_VT52('Y' ) : _currentScreen->setCursorYX (p-31,q-31 ); break; //VT52
809  case TY_VT52('Z' ) : reportTerminalType ( ); break; //VT52
810  case TY_VT52('<' ) : setMode (MODE_Ansi ); break; //VT52
811  case TY_VT52('=' ) : setMode (MODE_AppKeyPad); break; //VT52
812  case TY_VT52('>' ) : resetMode (MODE_AppKeyPad); break; //VT52
813 
814  case TY_CSI_PG('c' ) : reportSecondaryAttributes( ); break; //VT100
815 
816  default:
817  reportDecodingError();
818  break;
819  };
820 }
821 
822 void Vt102Emulation::clearScreenAndSetColumns(int columnCount)
823 {
824  setImageSize(_currentScreen->getLines(),columnCount);
825  clearEntireScreen();
826  setDefaultMargins();
827  _currentScreen->setCursorYX(0,0);
828 }
829 
830 void Vt102Emulation::sendString(const char* s , int length)
831 {
832  if ( length >= 0 )
833  emit sendData(s,length);
834  else
835  emit sendData(s,qstrlen(s));
836 }
837 
838 void Vt102Emulation::reportCursorPosition()
839 {
840  char tmp[20];
841  snprintf(tmp, sizeof(tmp), "\033[%d;%dR", _currentScreen->getCursorY()+1, _currentScreen->getCursorX()+1);
842  sendString(tmp);
843 }
844 
845 void Vt102Emulation::reportTerminalType()
846 {
847  // Primary device attribute response (Request was: ^[[0c or ^[[c (from TT321 Users Guide))
848  // VT220: ^[[?63;1;2;3;6;7;8c (list deps on emul. capabilities)
849  // VT100: ^[[?1;2c
850  // VT101: ^[[?1;0c
851  // VT102: ^[[?6v
852  if (getMode(MODE_Ansi))
853  sendString("\033[?1;2c"); // I'm a VT100
854  else
855  sendString("\033/Z"); // I'm a VT52
856 }
857 
858 void Vt102Emulation::reportSecondaryAttributes()
859 {
860  // Secondary device attribute response (Request was: ^[[>0c or ^[[>c)
861  if (getMode(MODE_Ansi))
862  sendString("\033[>0;115;0c"); // Why 115? ;)
863  else
864  sendString("\033/Z"); // FIXME I don't think VT52 knows about it but kept for
865  // konsoles backward compatibility.
866 }
867 
868 /* DECREPTPARM – Report Terminal Parameters
869  ESC [ <sol>; <par>; <nbits>; <xspeed>; <rspeed>; <clkmul>; <flags> x
870 
871  http://vt100.net/docs/vt100-ug/chapter3.html
872 */
873 void Vt102Emulation::reportTerminalParms(int p)
874 {
875  char tmp[100];
876 /*
877  sol=1: This message is a request; report in response to a request.
878  par=1: No parity set
879  nbits=1: 8 bits per character
880  xspeed=112: 9600
881  rspeed=112: 9600
882  clkmul=1: The bit rate multiplier is 16.
883  flags=0: None
884 */
885  snprintf(tmp, sizeof(tmp), "\033[%d;1;1;112;112;1;0x", p); // not really true.
886  sendString(tmp);
887 }
888 
889 void Vt102Emulation::reportStatus()
890 {
891  sendString("\033[0n"); //VT100. Device status report. 0 = Ready.
892 }
893 
894 void Vt102Emulation::reportAnswerBack()
895 {
896  // FIXME - Test this with VTTEST
897  // This is really obsolete VT100 stuff.
898  const char* ANSWER_BACK = "";
899  sendString(ANSWER_BACK);
900 }
901 
912 void Vt102Emulation::sendMouseEvent(int cb, int cx, int cy , int eventType)
913 {
914  if (cx < 1 || cy < 1)
915  return;
916 
917  // With the exception of the 1006 mode, button release is encoded in cb.
918  // Note that if multiple extensions are enabled, the 1006 is used, so it's okay to check for only that.
919  if (eventType == 2 && !getMode(MODE_Mouse1006))
920  cb = 3;
921 
922  // normal buttons are passed as 0x20 + button,
923  // mouse wheel (buttons 4,5) as 0x5c + button
924  if (cb >= 4)
925  cb += 0x3c;
926 
927  //Mouse motion handling
928  if ((getMode(MODE_Mouse1002) || getMode(MODE_Mouse1003)) && eventType == 1)
929  cb += 0x20; //add 32 to signify motion event
930 
931  char command[32];
932  command[0] = '\0';
933  // Check the extensions in decreasing order of preference. Encoding the release event above assumes that 1006 comes first.
934  if (getMode(MODE_Mouse1006)) {
935  snprintf(command, sizeof(command), "\033[<%d;%d;%d%c", cb, cx, cy, eventType == 2 ? 'm' : 'M');
936  } else if (getMode(MODE_Mouse1015)) {
937  snprintf(command, sizeof(command), "\033[%d;%d;%dM", cb + 0x20, cx, cy);
938  } else if (getMode(MODE_Mouse1005)) {
939  if (cx <= 2015 && cy <= 2015) {
940  // The xterm extension uses UTF-8 (up to 2 bytes) to encode
941  // coordinate+32, no matter what the locale is. We could easily
942  // convert manually, but QString can also do it for us.
943  QChar coords[2];
944  coords[0] = cx + 0x20;
945  coords[1] = cy + 0x20;
946  QString coordsStr = QString(coords, 2);
947  QByteArray utf8 = coordsStr.toUtf8();
948  snprintf(command, sizeof(command), "\033[M%c%s", cb + 0x20, (const char *)utf8);
949  }
950  } else if (cx <= 223 && cy <= 223) {
951  snprintf(command, sizeof(command), "\033[M%c%c%c", cb + 0x20, cx + 0x20, cy + 0x20);
952  }
953 
954  sendString(command);
955 }
956 
957 void Vt102Emulation::sendText(const QString& text)
958 {
959  if (!text.isEmpty()) {
960  QKeyEvent event(QEvent::KeyPress,
961  0,
962  Qt::NoModifier,
963  text);
964  sendKeyEvent(&event); // expose as a big fat keypress event
965  }
966 }
967 void Vt102Emulation::sendKeyEvent(QKeyEvent* event)
968 {
969  const Qt::KeyboardModifiers modifiers = event->modifiers();
970  KeyboardTranslator::States states = KeyboardTranslator::NoState;
971 
972  // get current states
973  if (getMode(MODE_NewLine)) states |= KeyboardTranslator::NewLineState;
974  if (getMode(MODE_Ansi)) states |= KeyboardTranslator::AnsiState;
975  if (getMode(MODE_AppCuKeys)) states |= KeyboardTranslator::CursorKeysState;
976  if (getMode(MODE_AppScreen)) states |= KeyboardTranslator::AlternateScreenState;
977  if (getMode(MODE_AppKeyPad) && (modifiers & Qt::KeypadModifier))
978  states |= KeyboardTranslator::ApplicationKeypadState;
979 
980  // check flow control state
981  if (modifiers & Qt::ControlModifier) {
982  switch (event->key()) {
983  case Qt::Key_S:
984  emit flowControlKeyPressed(true);
985  break;
986  case Qt::Key_Q:
987  case Qt::Key_C: // cancel flow control
988  emit flowControlKeyPressed(false);
989  break;
990  }
991  }
992 
993  // look up key binding
994  if (_keyTranslator) {
995  KeyboardTranslator::Entry entry = _keyTranslator->findEntry(
996  event->key() ,
997  modifiers,
998  states);
999 
1000  // send result to terminal
1001  QByteArray textToSend;
1002 
1003  // special handling for the Alt (aka. Meta) modifier. pressing
1004  // Alt+[Character] results in Esc+[Character] being sent
1005  // (unless there is an entry defined for this particular combination
1006  // in the keyboard modifier)
1007  const bool wantsAltModifier = entry.modifiers() & entry.modifierMask() & Qt::AltModifier;
1008  const bool wantsMetaModifier = entry.modifiers() & entry.modifierMask() & Qt::MetaModifier;
1009  const bool wantsAnyModifier = entry.state() &
1010  entry.stateMask() & KeyboardTranslator::AnyModifierState;
1011 
1012  if ( modifiers & Qt::AltModifier && !(wantsAltModifier || wantsAnyModifier)
1013  && !event->text().isEmpty() )
1014  {
1015  textToSend.prepend("\033");
1016  }
1017  if ( modifiers & Qt::MetaModifier && !(wantsMetaModifier || wantsAnyModifier)
1018  && !event->text().isEmpty() )
1019  {
1020  textToSend.prepend("\030@s");
1021  }
1022 
1023  if ( entry.command() != KeyboardTranslator::NoCommand )
1024  {
1025  TerminalDisplay * currentView = _currentScreen->currentTerminalDisplay();
1026 
1027  if (entry.command() & KeyboardTranslator::EraseCommand) {
1028  textToSend += eraseChar();
1029  } else if (entry.command() & KeyboardTranslator::ScrollPageUpCommand)
1030  currentView->scrollScreenWindow(ScreenWindow::ScrollPages, -1);
1031  else if (entry.command() & KeyboardTranslator::ScrollPageDownCommand)
1032  currentView->scrollScreenWindow(ScreenWindow::ScrollPages, 1);
1033  else if (entry.command() & KeyboardTranslator::ScrollLineUpCommand)
1034  currentView->scrollScreenWindow(ScreenWindow::ScrollLines, -1);
1035  else if (entry.command() & KeyboardTranslator::ScrollLineDownCommand)
1036  currentView->scrollScreenWindow(ScreenWindow::ScrollLines, 1);
1037  else if (entry.command() & KeyboardTranslator::ScrollUpToTopCommand)
1038  currentView->scrollScreenWindow(ScreenWindow::ScrollLines,
1039  - currentView->screenWindow()->currentLine());
1040  else if (entry.command() & KeyboardTranslator::ScrollDownToBottomCommand)
1041  currentView->scrollScreenWindow(ScreenWindow::ScrollLines, lineCount());
1042  }
1043  else if (!entry.text().isEmpty())
1044  {
1045  textToSend += _codec->fromUnicode(entry.text(true,modifiers));
1046  }
1047  else
1048  textToSend += _codec->fromUnicode(event->text());
1049 
1050  sendData(textToSend.constData(), textToSend.length());
1051  }
1052  else
1053  {
1054  // print an error message to the terminal if no key translator has been
1055  // set
1056  QString translatorError = i18n("No keyboard translator available. "
1057  "The information needed to convert key presses "
1058  "into characters to send to the terminal "
1059  "is missing.");
1060  reset();
1061  receiveData(translatorError.toAscii().constData(), translatorError.count());
1062  }
1063 }
1064 
1065 /* ------------------------------------------------------------------------- */
1066 /* */
1067 /* VT100 Charsets */
1068 /* */
1069 /* ------------------------------------------------------------------------- */
1070 
1071 // Character Set Conversion ------------------------------------------------ --
1072 
1073 /*
1074  The processing contains a VT100 specific code translation layer.
1075  It's still in use and mainly responsible for the line drawing graphics.
1076 
1077  These and some other glyphs are assigned to codes (0x5f-0xfe)
1078  normally occupied by the latin letters. Since this codes also
1079  appear within control sequences, the extra code conversion
1080  does not permute with the tokenizer and is placed behind it
1081  in the pipeline. It only applies to tokens, which represent
1082  plain characters.
1083 
1084  This conversion it eventually continued in TerminalDisplay.C, since
1085  it might involve VT100 enhanced fonts, which have these
1086  particular glyphs allocated in (0x00-0x1f) in their code page.
1087 */
1088 
1089 #define CHARSET _charset[_currentScreen==_screen[1]]
1090 
1091 // Apply current character map.
1092 
1093 unsigned short Vt102Emulation::applyCharset(unsigned short c)
1094 {
1095  if (CHARSET.graphic && 0x5f <= c && c <= 0x7e) return vt100_graphics[c - 0x5f];
1096  if (CHARSET.pound && c == '#') return 0xa3; //This mode is obsolete
1097  return c;
1098 }
1099 
1100 /*
1101  "Charset" related part of the emulation state.
1102  This configures the VT100 charset filter.
1103 
1104  While most operation work on the current _screen,
1105  the following two are different.
1106 */
1107 
1108 void Vt102Emulation::resetCharset(int scrno)
1109 {
1110  _charset[scrno].cu_cs = 0;
1111  qstrncpy(_charset[scrno].charset, "BBBB", 4);
1112  _charset[scrno].sa_graphic = false;
1113  _charset[scrno].sa_pound = false;
1114  _charset[scrno].graphic = false;
1115  _charset[scrno].pound = false;
1116 }
1117 
1118 void Vt102Emulation::setCharset(int n, int cs) // on both screens.
1119 {
1120  _charset[0].charset[n & 3] = cs; useCharset(_charset[0].cu_cs);
1121  _charset[1].charset[n & 3] = cs; useCharset(_charset[1].cu_cs);
1122 }
1123 
1124 void Vt102Emulation::setAndUseCharset(int n, int cs)
1125 {
1126  CHARSET.charset[n & 3] = cs;
1127  useCharset(n & 3);
1128 }
1129 
1130 void Vt102Emulation::useCharset(int n)
1131 {
1132  CHARSET.cu_cs = n & 3;
1133  CHARSET.graphic = (CHARSET.charset[n & 3] == '0');
1134  CHARSET.pound = (CHARSET.charset[n & 3] == 'A'); //This mode is obsolete
1135 }
1136 
1137 void Vt102Emulation::setDefaultMargins()
1138 {
1139  _screen[0]->setDefaultMargins();
1140  _screen[1]->setDefaultMargins();
1141 }
1142 
1143 void Vt102Emulation::setMargins(int t, int b)
1144 {
1145  _screen[0]->setMargins(t, b);
1146  _screen[1]->setMargins(t, b);
1147 }
1148 
1149 void Vt102Emulation::saveCursor()
1150 {
1151  CHARSET.sa_graphic = CHARSET.graphic;
1152  CHARSET.sa_pound = CHARSET.pound; //This mode is obsolete
1153  // we are not clear about these
1154  //sa_charset = charsets[cScreen->_charset];
1155  //sa_charset_num = cScreen->_charset;
1156  _currentScreen->saveCursor();
1157 }
1158 
1159 void Vt102Emulation::restoreCursor()
1160 {
1161  CHARSET.graphic = CHARSET.sa_graphic;
1162  CHARSET.pound = CHARSET.sa_pound; //This mode is obsolete
1163  _currentScreen->restoreCursor();
1164 }
1165 
1166 /* ------------------------------------------------------------------------- */
1167 /* */
1168 /* Mode Operations */
1169 /* */
1170 /* ------------------------------------------------------------------------- */
1171 
1172 /*
1173  Some of the emulations state is either added to the state of the screens.
1174 
1175  This causes some scoping problems, since different emulations choose to
1176  located the mode either to the current _screen or to both.
1177 
1178  For strange reasons, the extend of the rendition attributes ranges over
1179  all screens and not over the actual _screen.
1180 
1181  We decided on the precise precise extend, somehow.
1182 */
1183 
1184 // "Mode" related part of the state. These are all booleans.
1185 
1186 void Vt102Emulation::resetModes()
1187 {
1188  // MODE_Allow132Columns is not reset here
1189  // to match Xterm's behavior (see Xterm's VTReset() function)
1190 
1191  resetMode(MODE_132Columns); saveMode(MODE_132Columns);
1192  resetMode(MODE_Mouse1000); saveMode(MODE_Mouse1000);
1193  resetMode(MODE_Mouse1001); saveMode(MODE_Mouse1001);
1194  resetMode(MODE_Mouse1002); saveMode(MODE_Mouse1002);
1195  resetMode(MODE_Mouse1003); saveMode(MODE_Mouse1003);
1196  resetMode(MODE_Mouse1005); saveMode(MODE_Mouse1005);
1197  resetMode(MODE_Mouse1006); saveMode(MODE_Mouse1006);
1198  resetMode(MODE_Mouse1015); saveMode(MODE_Mouse1015);
1199 
1200  resetMode(MODE_AppScreen); saveMode(MODE_AppScreen);
1201  resetMode(MODE_AppCuKeys); saveMode(MODE_AppCuKeys);
1202  resetMode(MODE_AppKeyPad); saveMode(MODE_AppKeyPad);
1203  resetMode(MODE_NewLine);
1204  setMode(MODE_Ansi);
1205 }
1206 
1207 void Vt102Emulation::setMode(int m)
1208 {
1209  _currentModes.mode[m] = true;
1210  switch (m) {
1211  case MODE_132Columns:
1212  if (getMode(MODE_Allow132Columns))
1213  clearScreenAndSetColumns(132);
1214  else
1215  _currentModes.mode[m] = false;
1216  break;
1217  case MODE_Mouse1000:
1218  case MODE_Mouse1001:
1219  case MODE_Mouse1002:
1220  case MODE_Mouse1003:
1221  emit programUsesMouseChanged(false);
1222  break;
1223 
1224  case MODE_AppScreen :
1225  _screen[1]->clearSelection();
1226  setScreen(1);
1227  break;
1228  }
1229  // FIXME: Currently this has a redundant condition as MODES_SCREEN is 6
1230  // and MODE_NewLine is 5
1231  if (m < MODES_SCREEN || m == MODE_NewLine) {
1232  _screen[0]->setMode(m);
1233  _screen[1]->setMode(m);
1234  }
1235 }
1236 
1237 void Vt102Emulation::resetMode(int m)
1238 {
1239  _currentModes.mode[m] = false;
1240  switch (m) {
1241  case MODE_132Columns:
1242  if (getMode(MODE_Allow132Columns))
1243  clearScreenAndSetColumns(80);
1244  break;
1245  case MODE_Mouse1000 :
1246  case MODE_Mouse1001 :
1247  case MODE_Mouse1002 :
1248  case MODE_Mouse1003 :
1249  emit programUsesMouseChanged(true);
1250  break;
1251 
1252  case MODE_AppScreen :
1253  _screen[0]->clearSelection();
1254  setScreen(0);
1255  break;
1256  }
1257  // FIXME: Currently this has a redundant condition as MODES_SCREEN is 6
1258  // and MODE_NewLine is 5
1259  if (m < MODES_SCREEN || m == MODE_NewLine) {
1260  _screen[0]->resetMode(m);
1261  _screen[1]->resetMode(m);
1262  }
1263 }
1264 
1265 void Vt102Emulation::saveMode(int m)
1266 {
1267  _savedModes.mode[m] = _currentModes.mode[m];
1268 }
1269 
1270 void Vt102Emulation::restoreMode(int m)
1271 {
1272  if (_savedModes.mode[m])
1273  setMode(m);
1274  else
1275  resetMode(m);
1276 }
1277 
1278 bool Vt102Emulation::getMode(int m)
1279 {
1280  return _currentModes.mode[m];
1281 }
1282 
1283 char Vt102Emulation::eraseChar() const
1284 {
1285  KeyboardTranslator::Entry entry = _keyTranslator->findEntry(
1286  Qt::Key_Backspace,
1287  0,
1288  0);
1289  if (entry.text().count() > 0)
1290  return entry.text()[0];
1291  else
1292  return '\b';
1293 }
1294 
1295 #if 0
1296 // print contents of the scan buffer
1297 static void hexdump(int* s, int len)
1298 {
1299  int i;
1300  for (i = 0; i < len; i++) {
1301  if (s[i] == '\\')
1302  printf("\\\\");
1303  else if ((s[i]) > 32 && s[i] < 127)
1304  printf("%c", s[i]);
1305  else
1306  printf("\\%04x(hex)", s[i]);
1307  }
1308 }
1309 #endif
1310 
1311 // return contents of the scan buffer
1312 static QString hexdump2(int* s, int len)
1313 {
1314  int i;
1315  char dump[128];
1316  QString returnDump;
1317 
1318  for (i = 0; i < len; i++) {
1319  if (s[i] == '\\')
1320  snprintf(dump, sizeof(dump), "%s", "\\\\");
1321  else if ((s[i]) > 32 && s[i] < 127)
1322  snprintf(dump, sizeof(dump), "%c", s[i]);
1323  else
1324  snprintf(dump, sizeof(dump), "\\%04x(hex)", s[i]);
1325  returnDump.append(QString(dump));
1326  }
1327  return returnDump;
1328 }
1329 
1330 void Vt102Emulation::reportDecodingError()
1331 {
1332  if (tokenBufferPos == 0 || (tokenBufferPos == 1 && (tokenBuffer[0] & 0xff) >= 32))
1333  return;
1334 
1335 // printf("Undecodable sequence: ");
1336 // hexdump(tokenBuffer, tokenBufferPos);
1337 // printf("\n");
1338 
1339  QString outputError = QString("Undecodable sequence: ");
1340  outputError.append(hexdump2(tokenBuffer, tokenBufferPos));
1341  kDebug() << outputError;
1342 }
1343 
1344 #include "Vt102Emulation.moc"
1345 
Konsole::Vt102Emulation::~Vt102Emulation
~Vt102Emulation()
Definition: Vt102Emulation.cpp:79
TY_CSI_PG
#define TY_CSI_PG(A)
Definition: Vt102Emulation.cpp:180
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
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:326
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
Konsole::Screen::getLines
int getLines() const
Return the number of lines.
Definition: Screen.h:382
ces
#define ces(C)
Definition: Vt102Emulation.cpp:284
COLOR_SPACE_RGB
#define COLOR_SPACE_RGB
Definition: CharacterColor.h:143
Konsole::Emulation::_currentScreen
Screen * _currentScreen
Definition: Emulation.h:441
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
Konsole::ScreenWindow::currentLine
int currentLine() const
Returns the index of the line which is currently at the top of this window.
Definition: ScreenWindow.cpp:211
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
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:140
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
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:434
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
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:912
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:137
Konsole::RE_BLINK
const int RE_BLINK
Definition: Character.h:40
COLOR_SPACE_256
#define COLOR_SPACE_256
Definition: CharacterColor.h:142
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:454
Konsole::Emulation::LocaleCodec
Definition: Emulation.h:433
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:308
TY_ESC_DE
#define TY_ESC_DE(A)
Definition: Vt102Emulation.cpp:174
MAXARGS
#define MAXARGS
Definition: Vt102Emulation.h:135
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:106
CPS
const int CPS
Definition: Vt102Emulation.cpp:227
TerminalDisplay.h
Konsole::CharCodes::pound
bool pound
Definition: Vt102Emulation.h:60
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:131
MODE_Cursor
#define MODE_Cursor
Definition: Screen.h:40
KeyboardTranslator.h
TY_CSI_PS
#define TY_CSI_PS(A, N)
Definition: Vt102Emulation.cpp:175
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:1283
Konsole::Vt102Emulation::sendText
virtual void sendText(const QString &text)
Definition: Vt102Emulation.cpp:957
Konsole::KeyboardTranslator::ScrollPageDownCommand
Scroll the terminal display down one page.
Definition: KeyboardTranslator.h:102
epe
#define epe()
Definition: Vt102Emulation.cpp:280
Konsole::Vt102Emulation::resetMode
virtual void resetMode(int mode)
Definition: Vt102Emulation.cpp:1237
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
MODE_Ansi
#define MODE_Ansi
Definition: Vt102Emulation.h:46
Konsole::Vt102Emulation::sendString
virtual void sendString(const char *, int length=-1)
Definition: Vt102Emulation.cpp:830
Vt102Emulation.h
TY_ESC
#define TY_ESC(A)
Definition: Vt102Emulation.cpp:172
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:59
Konsole::Emulation
Base class for terminal emulation back-ends.
Definition: Emulation.h:117
TY_ESC_CS
#define TY_ESC_CS(A, B)
Definition: Vt102Emulation.cpp:173
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
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:291
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:61
Konsole::Screen::clearSelection
void clearSelection()
Clears the current selection.
Definition: Screen.cpp:1029
Konsole::CharCodes::sa_pound
bool sa_pound
Definition: Vt102Emulation.h:62
MODE_Wrap
#define MODE_Wrap
Definition: Screen.h:37
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:1312
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:452
Konsole::CharCodes::cu_cs
int cu_cs
Definition: Vt102Emulation.h:58
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:75
MODE_132Columns
#define MODE_132Columns
Definition: Vt102Emulation.h:47
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:2899
MODE_Mouse1001
#define MODE_Mouse1001
Definition: Vt102Emulation.h:40
Konsole::CharCodes::charset
char charset[4]
Definition: Vt102Emulation.h:57
Konsole::Emulation::clearHistory
void clearHistory()
Clears the history scroll.
Definition: Emulation.cpp:121
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:1089
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:1207
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
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:213
CHR
const int CHR
Definition: Vt102Emulation.cpp:222
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:967
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:444
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
COLOR_SPACE_SYSTEM
#define COLOR_SPACE_SYSTEM
Definition: CharacterColor.h:141
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
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
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:24 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Konsole

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

applications API Reference

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

Search



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

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