Vt102Emulation.cpp 60.3 KB
Newer Older
1 2
/*
    This file is part of Konsole, an X terminal.
3

4 5
    Copyright 2007-2008 by Robert Knight <robert.knight@gmail.com>
    Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301  USA.
*/
22

23 24 25
// Own
#include "Vt102Emulation.h"

Jekyll Wu's avatar
Jekyll Wu committed
26
// Standard
27 28 29
#include <stdio.h>
#include <unistd.h>

30
// Qt
31 32 33
#include <QEvent>
#include <QTimer>
#include <QKeyEvent>
34

35
// KDE
36
#include <KLocalizedString>
37 38

// Konsole
39
#include "KeyboardTranslator.h"
40
#include "SessionController.h"
41
#include "TerminalDisplay.h"
42

43
using Konsole::Vt102Emulation;
44

45 46 47 48 49 50 51
/*
   The VT100 has 32 special graphical characters. The usual vt100 extended
   xterm fonts have these at 0x00..0x1f.

   QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals
   come in here as proper unicode characters.

52
   We treat non-iso10646 fonts as VT100 extended and do the required mapping
53 54 55 56 57 58
   from unicode to 0x00..0x1f. The remaining translation is then left to the
   QCodec.
*/

// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i.

59 60 61 62 63 64
unsigned short Konsole::vt100_graphics[32] = {
    // 0/8     1/9    2/10    3/11    4/12    5/13    6/14    7/15
    0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0,
    0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
    0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534,
    0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7
65 66
};

Kurt Hindenburg's avatar
Kurt Hindenburg committed
67 68 69 70
Vt102Emulation::Vt102Emulation() :
    Emulation(),
    _titleUpdateTimer(new QTimer(this)),
    _reportFocusEvents(false)
71
{
72
    _titleUpdateTimer->setSingleShot(true);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
73 74
    QObject::connect(_titleUpdateTimer, &QTimer::timeout, this,
                     &Konsole::Vt102Emulation::updateTitle);
75

76 77
    initTokenizer();
    reset();
78 79
}

80
Vt102Emulation::~Vt102Emulation() = default;
81

82
void Vt102Emulation::clearEntireScreen()
83
{
84 85
    _currentScreen->clearEntireScreen();
    bufferedUpdate();
86 87
}

88
void Vt102Emulation::reset()
89
{
90 91
    // Save the current codec so we can set it later.
    // Ideally we would want to use the profile setting
Kurt Hindenburg's avatar
Kurt Hindenburg committed
92
    const QTextCodec *currentCodec = codec();
93 94 95 96 97 98 99 100

    resetTokenizer();
    resetModes();
    resetCharset(0);
    _screen[0]->reset();
    resetCharset(1);
    _screen[1]->reset();

Kurt Hindenburg's avatar
Kurt Hindenburg committed
101
    if (currentCodec != nullptr) {
102
        setCodec(currentCodec);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
103
    } else {
104
        setCodec(LocaleCodec);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
105
    }
106

107
    bufferedUpdate();
108 109 110 111 112 113 114 115 116 117 118
}

/* ------------------------------------------------------------------------- */
/*                                                                           */
/*                     Processing the incoming byte stream                   */
/*                                                                           */
/* ------------------------------------------------------------------------- */

/* Incoming Bytes Event pipeline

   This section deals with decoding the incoming character stream.
Thorsten Roeder's avatar
Thorsten Roeder committed
119
   Decoding means here, that the stream is first separated into `tokens'
120
   which are then mapped to a `meaning' provided as operations by the
121
   `Screen' class or by the emulation class itself.
122 123 124

   The pipeline proceeds as follows:

125
   - Tokenizing the ESC codes (onReceiveChar)
126
   - VT100 code page translation of plain characters (applyCharset)
127
   - Interpretation of ESC codes (processToken)
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152

   The escape codes and their meaning are described in the
   technical reference of this program.
*/

// Tokens ------------------------------------------------------------------ --

/*
   Since the tokens are the central notion if this section, we've put them
   in front. They provide the syntactical elements used to represent the
   terminals operations as byte sequences.

   They are encodes here into a single machine word, so that we can later
   switch over them easily. Depending on the token itself, additional
   argument variables are filled with parameter values.

   The tokens are defined below:

   - CHR        - Printable characters     (32..255 but DEL (=127))
   - CTL        - Control characters       (0..31 but ESC (= 27), DEL)
   - ESC        - Escape codes of the form <ESC><CHR but `[]()+*#'>
   - ESC_DE     - Escape codes of the form <ESC><any of `()+*#%'> C
   - CSI_PN     - Escape codes of the form <ESC>'['     {Pn} ';' {Pn} C
   - CSI_PS     - Escape codes of the form <ESC>'['     {Pn} ';' ...  C
   - CSI_PR     - Escape codes of the form <ESC>'[' '?' {Pn} ';' ...  C
Waldo Bastian's avatar
Waldo Bastian committed
153
   - CSI_PE     - Escape codes of the form <ESC>'[' '!' {Pn} ';' ...  C
154 155 156
   - VT52       - VT52 escape codes
                  - <ESC><Chr>
                  - <ESC>'Y'{Pc}{Pc}
157
   - XTE_HA     - Xterm window/terminal attribute commands
158 159
                  of the form <ESC>`]' {Pn} `;' {Text} <BEL>
                  (Note that these are handled differently to the other formats)
160 161 162 163

   The last two forms allow list of arguments. Since the elements of
   the lists are treated individually the same way, they are passed
   as individual tokens to the interpretation. Further, because the
164
   meaning of the parameters are names (although represented as numbers),
165 166 167 168
   they are includes within the token ('N').

*/

169
#define TY_CONSTRUCT(T,A,N) ( ((((int)(N)) & 0xffff) << 16) | ((((int)(A)) & 0xff) << 8) | (((int)(T)) & 0xff) )
170

171 172 173 174 175 176 177 178
#define TY_CHR(   )     TY_CONSTRUCT(0,0,0)
#define TY_CTL(A  )     TY_CONSTRUCT(1,A,0)
#define TY_ESC(A  )     TY_CONSTRUCT(2,A,0)
#define TY_ESC_CS(A,B)  TY_CONSTRUCT(3,A,B)
#define TY_ESC_DE(A  )  TY_CONSTRUCT(4,A,0)
#define TY_CSI_PS(A,N)  TY_CONSTRUCT(5,A,N)
#define TY_CSI_PN(A  )  TY_CONSTRUCT(6,A,0)
#define TY_CSI_PR(A,N)  TY_CONSTRUCT(7,A,N)
179

180 181 182
#define TY_VT52(A)    TY_CONSTRUCT(8,A,0)
#define TY_CSI_PG(A)  TY_CONSTRUCT(9,A,0)
#define TY_CSI_PE(A)  TY_CONSTRUCT(10,A,0)
183

184
const int MAX_ARGUMENT = 4096;
185

186 187
// Tokenizer --------------------------------------------------------------- --

188
/* The tokenizer's state
189

190
   The state is represented by the buffer (tokenBuffer, tokenBufferPos),
191 192 193 194
   and accompanied by decoded arguments kept in (argv,argc).
   Note that they are kept internal in the tokenizer.
*/

195
void Vt102Emulation::resetTokenizer()
196
{
197 198 199 200
    tokenBufferPos = 0;
    argc = 0;
    argv[0] = 0;
    argv[1] = 0;
201 202
}

203
void Vt102Emulation::addDigit(int digit)
204
{
Kurt Hindenburg's avatar
Kurt Hindenburg committed
205
    if (argv[argc] < MAX_ARGUMENT) {
206
        argv[argc] = 10 * argv[argc] + digit;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
207
    }
208 209
}

210
void Vt102Emulation::addArgument()
211
{
212 213
    argc = qMin(argc + 1, MAXARGS - 1);
    argv[argc] = 0;
214 215
}

216
void Vt102Emulation::addToCurrentToken(int cc)
217
{
218 219
    tokenBuffer[tokenBufferPos] = cc;
    tokenBufferPos = qMin(tokenBufferPos + 1, MAX_TOKEN_LENGTH - 1);
220 221
}

222
// Character Class flags used while decoding
Kurt Hindenburg's avatar
Kurt Hindenburg committed
223 224 225 226
const int CTL = 1;   // Control character
const int CHR = 2;   // Printable character
const int CPN = 4;   // TODO: Document me
const int DIG = 8;   // Digit
227
const int SCS = 16;  // Select Character Set
Kurt Hindenburg's avatar
Kurt Hindenburg committed
228 229
const int GRP = 32;  // TODO: Document me
const int CPS = 64;  // Character which indicates end of window resize
230

231
void Vt102Emulation::initTokenizer()
232 233
{
    int i;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
234 235
    quint8 *s;
    for (i = 0; i < 256; ++i) {
236
        charClass[i] = 0;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
237 238
    }
    for (i = 0; i < 32; ++i) {
239
        charClass[i] |= CTL;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
240 241
    }
    for (i = 32; i < 256; ++i) {
242
        charClass[i] |= CHR;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
243
    }
244
    for (s = (quint8 *)"@ABCDGHILMPSTXZbcdfry"; *s != 0u; ++s) {
245
        charClass[*s] |= CPN;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
246
    }
247
    // resize = \e[8;<row>;<col>t
Kurt Hindenburg's avatar
Kurt Hindenburg committed
248
    for (s = (quint8 *)"t"; *s != 0u; ++s) {
249
        charClass[*s] |= CPS;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
250 251
    }
    for (s = (quint8 *)"0123456789"; *s != 0u; ++s) {
252
        charClass[*s] |= DIG;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
253 254
    }
    for (s = (quint8 *)"()+*%"; *s != 0u; ++s) {
255
        charClass[*s] |= SCS;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
256 257
    }
    for (s = (quint8 *)"()+*#[]%"; *s != 0u; ++s) {
258
        charClass[*s] |= GRP;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
259
    }
260 261

    resetTokenizer();
262 263 264 265 266 267 268 269 270 271 272 273
}

/* Ok, here comes the nasty part of the decoder.

   Instead of keeping an explicit state, we deduce it from the
   token scanned so far. It is then immediately combined with
   the current character to form a scanning decision.

   This is done by the following defines.

   - P is the length of the token scanned so far.
   - L (often P-1) is the position on which contents we base a decision.
274
   - C is a character or a group of characters (taken from 'charClass').
275

276 277
   - 'cc' is the current character
   - 's' is a pointer to the start of the token buffer
278
   - 'p' is the current position within the token buffer
279 280 281 282

   Note that they need to applied in proper order.
*/

283 284 285 286 287 288 289 290 291 292
#define lec(P,L,C) (p == (P) && s[(L)] == (C))
#define lun(     ) (p ==  1  && cc >= 32 )
#define les(P,L,C) (p == (P) && s[L] < 256 && (charClass[s[(L)]] & (C)) == (C))
#define eec(C)     (p >=  3  && cc == (C))
#define ees(C)     (p >=  3  && cc < 256 && (charClass[cc] & (C)) == (C))
#define eps(C)     (p >=  3  && s[2] != '?' && s[2] != '!' && s[2] != '>' && cc < 256 && (charClass[cc] & (C)) == (C))
#define epp( )     (p >=  3  && s[2] == '?')
#define epe( )     (p >=  3  && s[2] == '!')
#define egt( )     (p >=  3  && s[2] == '>')
#define Xpe        (tokenBufferPos >= 2 && tokenBuffer[1] == ']')
293
#define Xte        (Xpe      && (cc ==  7 || cc == 27))
294
#define ces(C)     (cc < 256 && (charClass[cc] & (C)) == (C) && !Xte)
Albert Astals Cid's avatar
Albert Astals Cid committed
295
#define dcs        (p >= 2   && s[0] == ESC && s[1] == 'P')
296 297

#define CNTL(c) ((c)-'@')
Kurt Hindenburg's avatar
Kurt Hindenburg committed
298
const int ESC = 27;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
299
const int DEL = 127;
300 301

// process an incoming unicode character
302
void Vt102Emulation::receiveChar(int cc)
303
{
Kurt Hindenburg's avatar
Kurt Hindenburg committed
304
  if (cc == DEL) {
305
    return; //VT100: ignore.
Kurt Hindenburg's avatar
Kurt Hindenburg committed
306
  }
307

308
  if (ces(CTL))
309
  {
310 311
    // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100
    // This means, they do neither a resetTokenizer() nor a pushToToken(). Some of them, do
312 313
    // of course. Guess this originates from a weakly layered handling of the X-on
    // X-off protocol, which comes really below this level.
Kurt Hindenburg's avatar
Kurt Hindenburg committed
314
    if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC) {
315
        resetTokenizer(); //VT100: CAN or SUB
Kurt Hindenburg's avatar
Kurt Hindenburg committed
316
    }
317 318 319 320
    if (cc != ESC)
    {
        processToken(TY_CTL(cc+'@' ),0,0);
        return;
321
    }
322
  }
323
  // advance the state
324
  addToCurrentToken(cc);
325

326
  int* s = tokenBuffer;
327
  const int  p = tokenBufferPos;
328

329
  if (getMode(MODE_Ansi))
330
  {
331 332 333
    if (lec(1,0,ESC)) { return; }
    if (lec(1,0,ESC+128)) { s[0] = ESC; receiveChar('['); return; }
    if (les(2,1,GRP)) { return; }
334
    if (Xte         ) { processWindowAttributeRequest(); resetTokenizer(); return; }
335 336 337 338 339
    if (Xpe         ) { return; }
    if (lec(3,2,'?')) { return; }
    if (lec(3,2,'>')) { return; }
    if (lec(3,2,'!')) { return; }
    if (lun(       )) { processToken( TY_CHR(), applyCharset(cc), 0);   resetTokenizer(); return; }
Albert Astals Cid's avatar
Albert Astals Cid committed
340
    if (dcs         ) { return; /* TODO We don't xterm DCS, so we just eat it */ }
341 342 343 344 345 346
    if (lec(2,0,ESC)) { processToken( TY_ESC(s[1]), 0, 0);              resetTokenizer(); return; }
    if (les(3,1,SCS)) { processToken( TY_ESC_CS(s[1],s[2]), 0, 0);      resetTokenizer(); return; }
    if (lec(3,1,'#')) { processToken( TY_ESC_DE(s[2]), 0, 0);           resetTokenizer(); return; }
    if (eps(    CPN)) { processToken( TY_CSI_PN(cc), argv[0],argv[1]);  resetTokenizer(); return; }

    // resize = \e[8;<row>;<col>t
347 348 349 350 351
    if (eps(CPS))
    {
        processToken( TY_CSI_PS(cc, argv[0]), argv[1], argv[2]);
        resetTokenizer();
        return;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
352
    }
353 354 355 356

    if (epe(   )) { processToken( TY_CSI_PE(cc), 0, 0); resetTokenizer(); return; }
    if (ees(DIG)) { addDigit(cc-'0'); return; }
    if (eec(';')) { addArgument();    return; }
357
    for (int i = 0; i <= argc; i++)
358
    {
Kurt Hindenburg's avatar
Kurt Hindenburg committed
359
        if (epp()) {
360
            processToken(TY_CSI_PR(cc,argv[i]), 0, 0);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
361
        } else if (egt()) {
362
            processToken(TY_CSI_PG(cc), 0, 0); // spec. case for ESC]>0c or ESC]>c
Kurt Hindenburg's avatar
Kurt Hindenburg committed
363
        } else if (cc == 'm' && argc - i >= 4 && (argv[i] == 38 || argv[i] == 48) && argv[i+1] == 2)
364
        {
365 366
            // ESC[ ... 48;2;<red>;<green>;<blue> ... m -or- ESC[ ... 38;2;<red>;<green>;<blue> ... m
            i += 2;
367
            processToken(TY_CSI_PS(cc, argv[i-2]), COLOR_SPACE_RGB, (argv[i] << 16) | (argv[i+1] << 8) | argv[i+2]);
368 369 370
            i += 2;
        }
        else if (cc == 'm' && argc - i >= 2 && (argv[i] == 38 || argv[i] == 48) && argv[i+1] == 5)
371
        {
372 373
            // ESC[ ... 48;5;<index> ... m -or- ESC[ ... 38;5;<index> ... m
            i += 2;
374
            processToken(TY_CSI_PS(cc, argv[i-2]), COLOR_SPACE_256, argv[i]);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
375
        } else {
376
            processToken(TY_CSI_PS(cc,argv[i]), 0, 0);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
377
        }
Kurt Hindenburg's avatar
Kurt Hindenburg committed
378
    }
379
    resetTokenizer();
Kurt Hindenburg's avatar
Kurt Hindenburg committed
380
  } else {
381
    // VT52 Mode
Kurt Hindenburg's avatar
Kurt Hindenburg committed
382
    if (lec(1,0,ESC)) {
383
        return;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
384
    }
385 386 387 388
    if (les(1,0,CHR))
    {
        processToken( TY_CHR(), s[0], 0);
        resetTokenizer();
389 390
        return;
    }
Kurt Hindenburg's avatar
Kurt Hindenburg committed
391
    if (lec(2,1,'Y')) {
392
        return;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
393 394
    }
    if (lec(3,1,'Y')) {
395
        return;
Kurt Hindenburg's avatar
Kurt Hindenburg committed
396
    }
397 398 399 400
    if (p < 4)
    {
        processToken(TY_VT52(s[1] ), 0, 0);
        resetTokenizer();
401 402
        return;
    }
403 404
    processToken(TY_VT52(s[1]), s[2], s[3]);
    resetTokenizer();
405
    return;
406 407
  }
}
408 409

void Vt102Emulation::processWindowAttributeRequest()
410 411 412
{
  // Describes the window or terminal session attribute to change
  // See Session::UserTitleChange for possible values
413
  int attribute = 0;
414
  int i;
415 416
  for (i = 2; i < tokenBufferPos     &&
              tokenBuffer[i] >= '0'  &&
417
              tokenBuffer[i] <= '9'; i++)
418
  {
419
    attribute = 10 * attribute + (tokenBuffer[i]-'0');
420
  }
421

422 423 424 425
  if (tokenBuffer[i] != ';')
  {
    reportDecodingError();
    return;
426
  }
427

428 429
  QString value;
  value.reserve(tokenBufferPos-i-2);
Kurt Hindenburg's avatar
Kurt Hindenburg committed
430
  for (int j = 0; j < tokenBufferPos-i-2; j++) {
431
    value[j] = tokenBuffer[i+1+j];
Kurt Hindenburg's avatar
Kurt Hindenburg committed
432
  }
433

434
  if (value == QLatin1String("?")) {
435 436 437
      emit sessionAttributeRequest(attribute);
      return;
  }
438

439
  _pendingTitleUpdates[attribute] = value;
440
  _titleUpdateTimer->start(20);
441 442
}

443
void Vt102Emulation::updateTitle()
444
{
Jekyll Wu's avatar
Jekyll Wu committed
445 446 447
    QListIterator<int> iter( _pendingTitleUpdates.keys() );
    while (iter.hasNext()) {
        int arg = iter.next();
448
        emit titleChanged( arg , _pendingTitleUpdates[arg] );
449
    }
450
    _pendingTitleUpdates.clear();
451 452
}

453 454 455 456 457
// Interpreting Codes ---------------------------------------------------------

/*
   Now that the incoming character stream is properly tokenized,
   meaning is assigned to them. These are either operations of
458
   the current _screen, or of the emulation class itself.
459

460
   The token to be interpreted comes in as a machine word
461 462 463 464 465 466
   possibly accompanied by two parameters.

   Likewise, the operations assigned to, come with up to two
   arguments. One could consider to make up a proper table
   from the function below.

Thorsten Roeder's avatar
Thorsten Roeder committed
467
   The technical reference manual provides more information
468 469 470
   about this mapping.
*/

471
void Vt102Emulation::processToken(int token, int p, int q)
Waldo Bastian's avatar
Waldo Bastian committed
472
{
473 474
  switch (token)
  {
475
    case TY_CHR(         ) : _currentScreen->displayCharacter     (p         ); break; //UTF16
476 477 478

    //             127 DEL    : ignored on input

Kurt Hindenburg's avatar
Kurt Hindenburg committed
479 480 481 482 483 484 485
    case TY_CTL('@'      ) : /* NUL: ignored                      */ break;
    case TY_CTL('A'      ) : /* SOH: ignored                      */ break;
    case TY_CTL('B'      ) : /* STX: ignored                      */ break;
    case TY_CTL('C'      ) : /* ETX: ignored                      */ break;
    case TY_CTL('D'      ) : /* EOT: ignored                      */ break;
    case TY_CTL('E'      ) :      reportAnswerBack     (          ); break; //VT100
    case TY_CTL('F'      ) : /* ACK: ignored                      */ break;
486
    case TY_CTL('G'      ) : emit stateSet(NOTIFYBELL);
487
                                break; //VT100
488 489 490 491 492 493
    case TY_CTL('H'      ) : _currentScreen->backspace            (          ); break; //VT100
    case TY_CTL('I'      ) : _currentScreen->tab                  (          ); break; //VT100
    case TY_CTL('J'      ) : _currentScreen->newLine              (          ); break; //VT100
    case TY_CTL('K'      ) : _currentScreen->newLine              (          ); break; //VT100
    case TY_CTL('L'      ) : _currentScreen->newLine              (          ); break; //VT100
    case TY_CTL('M'      ) : _currentScreen->toStartOfLine        (          ); break; //VT100
Kurt Hindenburg's avatar
Kurt Hindenburg committed
494 495 496 497 498 499 500 501 502 503 504 505

    case TY_CTL('N'      ) :      useCharset           (         1); break; //VT100
    case TY_CTL('O'      ) :      useCharset           (         0); break; //VT100

    case TY_CTL('P'      ) : /* DLE: ignored                      */ break;
    case TY_CTL('Q'      ) : /* DC1: XON continue                 */ break; //VT100
    case TY_CTL('R'      ) : /* DC2: ignored                      */ break;
    case TY_CTL('S'      ) : /* DC3: XOFF halt                    */ break; //VT100
    case TY_CTL('T'      ) : /* DC4: ignored                      */ break;
    case TY_CTL('U'      ) : /* NAK: ignored                      */ break;
    case TY_CTL('V'      ) : /* SYN: ignored                      */ break;
    case TY_CTL('W'      ) : /* ETB: ignored                      */ break;
506
    case TY_CTL('X'      ) : _currentScreen->displayCharacter     (    0x2592); break; //VT100
Kurt Hindenburg's avatar
Kurt Hindenburg committed
507
    case TY_CTL('Y'      ) : /* EM : ignored                      */ break;
508
    case TY_CTL('Z'      ) : _currentScreen->displayCharacter     (    0x2592); break; //VT100
Kurt Hindenburg's avatar
Kurt Hindenburg committed
509 510 511 512 513 514
    case TY_CTL('['      ) : /* ESC: cannot be seen here.         */ break;
    case TY_CTL('\\'     ) : /* FS : ignored                      */ break;
    case TY_CTL(']'      ) : /* GS : ignored                      */ break;
    case TY_CTL('^'      ) : /* RS : ignored                      */ break;
    case TY_CTL('_'      ) : /* US : ignored                      */ break;

515
    case TY_ESC('D'      ) : _currentScreen->index                (          ); break; //VT100
516
    case TY_ESC('E'      ) : _currentScreen->nextLine             (          ); break; //VT100
517 518
    case TY_ESC('H'      ) : _currentScreen->changeTabStop        (true      ); break; //VT100
    case TY_ESC('M'      ) : _currentScreen->reverseIndex         (          ); break; //VT100
Kurt Hindenburg's avatar
Kurt Hindenburg committed
519 520 521 522 523 524 525 526 527 528 529
    case TY_ESC('Z'      ) :      reportTerminalType   (          ); break;
    case TY_ESC('c'      ) :      reset                (          ); break;

    case TY_ESC('n'      ) :      useCharset           (         2); break;
    case TY_ESC('o'      ) :      useCharset           (         3); break;
    case TY_ESC('7'      ) :      saveCursor           (          ); break;
    case TY_ESC('8'      ) :      restoreCursor        (          ); break;

    case TY_ESC('='      ) :          setMode      (MODE_AppKeyPad); break;
    case TY_ESC('>'      ) :        resetMode      (MODE_AppKeyPad); break;
    case TY_ESC('<'      ) :          setMode      (MODE_Ansi     ); break; //VT100
530

531 532 533
    case TY_ESC_CS('(', '0') :      setCharset           (0,    '0'); break; //VT100
    case TY_ESC_CS('(', 'A') :      setCharset           (0,    'A'); break; //VT100
    case TY_ESC_CS('(', 'B') :      setCharset           (0,    'B'); break; //VT100
534

535 536 537
    case TY_ESC_CS(')', '0') :      setCharset           (1,    '0'); break; //VT100
    case TY_ESC_CS(')', 'A') :      setCharset           (1,    'A'); break; //VT100
    case TY_ESC_CS(')', 'B') :      setCharset           (1,    'B'); break; //VT100
538

539 540 541
    case TY_ESC_CS('*', '0') :      setCharset           (2,    '0'); break; //VT100
    case TY_ESC_CS('*', 'A') :      setCharset           (2,    'A'); break; //VT100
    case TY_ESC_CS('*', 'B') :      setCharset           (2,    'B'); break; //VT100
542

543 544 545
    case TY_ESC_CS('+', '0') :      setCharset           (3,    '0'); break; //VT100
    case TY_ESC_CS('+', 'A') :      setCharset           (3,    'A'); break; //VT100
    case TY_ESC_CS('+', 'B') :      setCharset           (3,    'B'); break; //VT100
546

547 548
    case TY_ESC_CS('%', 'G') :      setCodec             (Utf8Codec   ); break; //LINUX
    case TY_ESC_CS('%', '@') :      setCodec             (LocaleCodec ); break; //LINUX
549

550
    case TY_ESC_DE('3'      ) : /* Double height line, top half    */
551 552 553
                                _currentScreen->setLineProperty( LINE_DOUBLEWIDTH , true );
                                _currentScreen->setLineProperty( LINE_DOUBLEHEIGHT , true );
                                    break;
554
    case TY_ESC_DE('4'      ) : /* Double height line, bottom half */
555 556 557
                                _currentScreen->setLineProperty( LINE_DOUBLEWIDTH , true );
                                _currentScreen->setLineProperty( LINE_DOUBLEHEIGHT , true );
                                    break;
558
    case TY_ESC_DE('5'      ) : /* Single width, single height line*/
559 560 561
                                _currentScreen->setLineProperty( LINE_DOUBLEWIDTH , false);
                                _currentScreen->setLineProperty( LINE_DOUBLEHEIGHT , false);
                                break;
562 563
    case TY_ESC_DE('6'      ) : /* Double width, single height line*/
                                _currentScreen->setLineProperty( LINE_DOUBLEWIDTH , true);
564 565
                                _currentScreen->setLineProperty( LINE_DOUBLEHEIGHT , false);
                                break;
566
    case TY_ESC_DE('8'      ) : _currentScreen->helpAlign            (          ); break;
567

568
// resize = \e[8;<row>;<col>t
569 570 571
    case TY_CSI_PS('t',   8) : setImageSize( p /*lines */, q /* columns */ );
                               emit imageResizeRequest(QSize(q, p));
                               break;
572

Kurt Hindenburg's avatar
 
Kurt Hindenburg committed
573
// change tab text color : \e[28;<color>t  color: 0-16,777,215
574
    case TY_CSI_PS('t',   28) : emit changeTabTextColorRequest      ( p        );          break;
575

576 577 578 579 580 581
    case TY_CSI_PS('K',   0) : _currentScreen->clearToEndOfLine     (          ); break;
    case TY_CSI_PS('K',   1) : _currentScreen->clearToBeginOfLine   (          ); break;
    case TY_CSI_PS('K',   2) : _currentScreen->clearEntireLine      (          ); break;
    case TY_CSI_PS('J',   0) : _currentScreen->clearToEndOfScreen   (          ); break;
    case TY_CSI_PS('J',   1) : _currentScreen->clearToBeginOfScreen (          ); break;
    case TY_CSI_PS('J',   2) : _currentScreen->clearEntireScreen    (          ); break;
582
    case TY_CSI_PS('J',      3) : clearHistory();                            break;
583 584 585
    case TY_CSI_PS('g',   0) : _currentScreen->changeTabStop        (false     ); break; //VT100
    case TY_CSI_PS('g',   3) : _currentScreen->clearTabStops        (          ); break; //VT100
    case TY_CSI_PS('h',   4) : _currentScreen->    setMode      (MODE_Insert   ); break;
586 587
    case TY_CSI_PS('h',  20) :          setMode      (MODE_NewLine  ); break;
    case TY_CSI_PS('i',   0) : /* IGNORE: attached printer          */ break; //VT100
588
    case TY_CSI_PS('l',   4) : _currentScreen->  resetMode      (MODE_Insert   ); break;
589 590 591 592
    case TY_CSI_PS('l',  20) :        resetMode      (MODE_NewLine  ); break;
    case TY_CSI_PS('s',   0) :      saveCursor           (          ); break;
    case TY_CSI_PS('u',   0) :      restoreCursor        (          ); break;

593 594
    case TY_CSI_PS('m',   0) : _currentScreen->setDefaultRendition  (          ); break;
    case TY_CSI_PS('m',   1) : _currentScreen->  setRendition     (RE_BOLD     ); break; //VT100
595
    case TY_CSI_PS('m',   2) : _currentScreen->  setRendition     (RE_FAINT    ); break;
596
    case TY_CSI_PS('m',   3) : _currentScreen->  setRendition     (RE_ITALIC   ); break; //VT100
597 598 599
    case TY_CSI_PS('m',   4) : _currentScreen->  setRendition     (RE_UNDERLINE); break; //VT100
    case TY_CSI_PS('m',   5) : _currentScreen->  setRendition     (RE_BLINK    ); break; //VT100
    case TY_CSI_PS('m',   7) : _currentScreen->  setRendition     (RE_REVERSE  ); break;
600 601 602
    case TY_CSI_PS('m',   8) : _currentScreen->  setRendition     (RE_CONCEAL  ); break;
    case TY_CSI_PS('m',   9) : _currentScreen->  setRendition     (RE_STRIKEOUT); break;
    case TY_CSI_PS('m',  53) : _currentScreen->  setRendition     (RE_OVERLINE ); break;
603 604 605
    case TY_CSI_PS('m',  10) : /* IGNORED: mapping related          */ break; //LINUX
    case TY_CSI_PS('m',  11) : /* IGNORED: mapping related          */ break; //LINUX
    case TY_CSI_PS('m',  12) : /* IGNORED: mapping related          */ break; //LINUX
606 607 608
    case TY_CSI_PS('m',  21) : _currentScreen->resetRendition     (RE_BOLD     ); break;
    case TY_CSI_PS('m',  22) : _currentScreen->resetRendition     (RE_BOLD     );
                               _currentScreen->resetRendition     (RE_FAINT    ); break;
609
    case TY_CSI_PS('m',  23) : _currentScreen->resetRendition     (RE_ITALIC   ); break; //VT100
610 611 612
    case TY_CSI_PS('m',  24) : _currentScreen->resetRendition     (RE_UNDERLINE); break;
    case TY_CSI_PS('m',  25) : _currentScreen->resetRendition     (RE_BLINK    ); break;
    case TY_CSI_PS('m',  27) : _currentScreen->resetRendition     (RE_REVERSE  ); break;
613 614 615
    case TY_CSI_PS('m',  28) : _currentScreen->resetRendition     (RE_CONCEAL  ); break;
    case TY_CSI_PS('m',  29) : _currentScreen->resetRendition     (RE_STRIKEOUT); break;
    case TY_CSI_PS('m',  55) : _currentScreen->resetRendition     (RE_OVERLINE ); break;
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659

    case TY_CSI_PS('m',   30) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM,  0); break;
    case TY_CSI_PS('m',   31) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM,  1); break;
    case TY_CSI_PS('m',   32) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM,  2); break;
    case TY_CSI_PS('m',   33) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM,  3); break;
    case TY_CSI_PS('m',   34) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM,  4); break;
    case TY_CSI_PS('m',   35) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM,  5); break;
    case TY_CSI_PS('m',   36) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM,  6); break;
    case TY_CSI_PS('m',   37) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM,  7); break;

    case TY_CSI_PS('m',   38) : _currentScreen->setForeColor         (p,       q); break;

    case TY_CSI_PS('m',   39) : _currentScreen->setForeColor         (COLOR_SPACE_DEFAULT,  0); break;

    case TY_CSI_PS('m',   40) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM,  0); break;
    case TY_CSI_PS('m',   41) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM,  1); break;
    case TY_CSI_PS('m',   42) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM,  2); break;
    case TY_CSI_PS('m',   43) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM,  3); break;
    case TY_CSI_PS('m',   44) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM,  4); break;
    case TY_CSI_PS('m',   45) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM,  5); break;
    case TY_CSI_PS('m',   46) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM,  6); break;
    case TY_CSI_PS('m',   47) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM,  7); break;

    case TY_CSI_PS('m',   48) : _currentScreen->setBackColor         (p,       q); break;

    case TY_CSI_PS('m',   49) : _currentScreen->setBackColor         (COLOR_SPACE_DEFAULT,  1); break;

    case TY_CSI_PS('m',   90) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM,  8); break;
    case TY_CSI_PS('m',   91) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM,  9); break;
    case TY_CSI_PS('m',   92) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM, 10); break;
    case TY_CSI_PS('m',   93) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM, 11); break;
    case TY_CSI_PS('m',   94) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM, 12); break;
    case TY_CSI_PS('m',   95) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM, 13); break;
    case TY_CSI_PS('m',   96) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM, 14); break;
    case TY_CSI_PS('m',   97) : _currentScreen->setForeColor         (COLOR_SPACE_SYSTEM, 15); break;

    case TY_CSI_PS('m',  100) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM,  8); break;
    case TY_CSI_PS('m',  101) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM,  9); break;
    case TY_CSI_PS('m',  102) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM, 10); break;
    case TY_CSI_PS('m',  103) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM, 11); break;
    case TY_CSI_PS('m',  104) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM, 12); break;
    case TY_CSI_PS('m',  105) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM, 13); break;
    case TY_CSI_PS('m',  106) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM, 14); break;
    case TY_CSI_PS('m',  107) : _currentScreen->setBackColor         (COLOR_SPACE_SYSTEM, 15); break;
660 661 662 663 664 665 666 667 668 669

    case TY_CSI_PS('n',   5) :      reportStatus         (          ); break;
    case TY_CSI_PS('n',   6) :      reportCursorPosition (          ); break;
    case TY_CSI_PS('q',   0) : /* IGNORED: LEDs off                 */ break; //VT100
    case TY_CSI_PS('q',   1) : /* IGNORED: LED1 on                  */ break; //VT100
    case TY_CSI_PS('q',   2) : /* IGNORED: LED2 on                  */ break; //VT100
    case TY_CSI_PS('q',   3) : /* IGNORED: LED3 on                  */ break; //VT100
    case TY_CSI_PS('q',   4) : /* IGNORED: LED4 on                  */ break; //VT100
    case TY_CSI_PS('x',   0) :      reportTerminalParms  (         2); break; //VT100
    case TY_CSI_PS('x',   1) :      reportTerminalParms  (         3); break; //VT100
670

671 672 673 674 675
    case TY_CSI_PN('@'      ) : _currentScreen->insertChars          (p         ); break;
    case TY_CSI_PN('A'      ) : _currentScreen->cursorUp             (p         ); break; //VT100
    case TY_CSI_PN('B'      ) : _currentScreen->cursorDown           (p         ); break; //VT100
    case TY_CSI_PN('C'      ) : _currentScreen->cursorRight          (p         ); break; //VT100
    case TY_CSI_PN('D'      ) : _currentScreen->cursorLeft           (p         ); break; //VT100
676 677
    case TY_CSI_PN('E'      ) : /* Not implemented: cursor next p lines */         break; //VT100
    case TY_CSI_PN('F'      ) : /* Not implemented: cursor preceding p lines */    break; //VT100
678 679
    case TY_CSI_PN('G'      ) : _currentScreen->setCursorX           (p         ); break; //LINUX
    case TY_CSI_PN('H'      ) : _currentScreen->setCursorYX          (p,      q); break; //VT100
680
    case TY_CSI_PN('I'      ) : _currentScreen->tab                  (p         ); break;
681 682 683 684 685 686
    case TY_CSI_PN('L'      ) : _currentScreen->insertLines          (p         ); break;
    case TY_CSI_PN('M'      ) : _currentScreen->deleteLines          (p         ); break;
    case TY_CSI_PN('P'      ) : _currentScreen->deleteChars          (p         ); break;
    case TY_CSI_PN('S'      ) : _currentScreen->scrollUp             (p         ); break;
    case TY_CSI_PN('T'      ) : _currentScreen->scrollDown           (p         ); break;
    case TY_CSI_PN('X'      ) : _currentScreen->eraseChars           (p         ); break;
687
    case TY_CSI_PN('Z'      ) : _currentScreen->backtab              (p         ); break;
688
    case TY_CSI_PN('b'      ) : _currentScreen->repeatChars          (p         ); break;
689
    case TY_CSI_PN('c'      ) :      reportTerminalType   (          ); break; //VT100
690 691
    case TY_CSI_PN('d'      ) : _currentScreen->setCursorY           (p         ); break; //LINUX
    case TY_CSI_PN('f'      ) : _currentScreen->setCursorYX          (p,      q); break; //VT100
692
    case TY_CSI_PN('r'      ) :      setMargins           (p,      q); break; //VT100
693 694
    case TY_CSI_PN('y'      ) : /* IGNORED: Confidence test          */ break; //VT100

695 696 697 698
    case TY_CSI_PR('h',   1) :          setMode      (MODE_AppCuKeys); break; //VT100
    case TY_CSI_PR('l',   1) :        resetMode      (MODE_AppCuKeys); break; //VT100
    case TY_CSI_PR('s',   1) :         saveMode      (MODE_AppCuKeys); break; //FIXME
    case TY_CSI_PR('r',   1) :      restoreMode      (MODE_AppCuKeys); break; //FIXME
699

700
    case TY_CSI_PR('l',   2) :        resetMode      (MODE_Ansi     ); break; //VT100
701

702 703
    case TY_CSI_PR('h',   3) :          setMode      (MODE_132Columns); break; //VT100
    case TY_CSI_PR('l',   3) :        resetMode      (MODE_132Columns); break; //VT100
704

705 706
    case TY_CSI_PR('h',   4) : /* IGNORED: soft scrolling           */ break; //VT100
    case TY_CSI_PR('l',   4) : /* IGNORED: soft scrolling           */ break; //VT100
707

708 709
    case TY_CSI_PR('h',   5) : _currentScreen->    setMode      (MODE_Screen   ); break; //VT100
    case TY_CSI_PR('l',   5) : _currentScreen->  resetMode      (MODE_Screen   ); break; //VT100
710

711 712 713 714
    case TY_CSI_PR('h',   6) : _currentScreen->    setMode      (MODE_Origin   ); break; //VT100
    case TY_CSI_PR('l',   6) : _currentScreen->  resetMode      (MODE_Origin   ); break; //VT100
    case TY_CSI_PR('s',   6) : _currentScreen->   saveMode      (MODE_Origin   ); break; //FIXME
    case TY_CSI_PR('r',   6) : _currentScreen->restoreMode      (MODE_Origin   ); break; //FIXME
715

716 717 718 719
    case TY_CSI_PR('h',   7) : _currentScreen->    setMode      (MODE_Wrap     ); break; //VT100
    case TY_CSI_PR('l',   7) : _currentScreen->  resetMode      (MODE_Wrap     ); break; //VT100
    case TY_CSI_PR('s',   7) : _currentScreen->   saveMode      (MODE_Wrap     ); break; //FIXME
    case TY_CSI_PR('r',   7) : _currentScreen->restoreMode      (MODE_Wrap     ); break; //FIXME
720

721 722 723 724
    case TY_CSI_PR('h',   8) : /* IGNORED: autorepeat on            */ break; //VT100
    case TY_CSI_PR('l',   8) : /* IGNORED: autorepeat off           */ break; //VT100
    case TY_CSI_PR('s',   8) : /* IGNORED: autorepeat on            */ break; //VT100
    case TY_CSI_PR('r',   8) : /* IGNORED: autorepeat off           */ break; //VT100
725

726 727 728 729
    case TY_CSI_PR('h',   9) : /* IGNORED: interlace                */ break; //VT100
    case TY_CSI_PR('l',   9) : /* IGNORED: interlace                */ break; //VT100
    case TY_CSI_PR('s',   9) : /* IGNORED: interlace                */ break; //VT100
    case TY_CSI_PR('r',   9) : /* IGNORED: interlace                */ break; //VT100
730

731 732 733 734
    case TY_CSI_PR('h',  12) : /* IGNORED: Cursor blink             */ break; //att610
    case TY_CSI_PR('l',  12) : /* IGNORED: Cursor blink             */ break; //att610
    case TY_CSI_PR('s',  12) : /* IGNORED: Cursor blink             */ break; //att610
    case TY_CSI_PR('r',  12) : /* IGNORED: Cursor blink             */ break; //att610
735

736 737 738 739
    case TY_CSI_PR('h',  25) :          setMode      (MODE_Cursor   ); break; //VT100
    case TY_CSI_PR('l',  25) :        resetMode      (MODE_Cursor   ); break; //VT100
    case TY_CSI_PR('s',  25) :         saveMode      (MODE_Cursor   ); break; //VT100
    case TY_CSI_PR('r',  25) :      restoreMode      (MODE_Cursor   ); break; //VT100
740

741 742 743
    case TY_CSI_PR('h',  40) :         setMode(MODE_Allow132Columns ); break; // XTERM
    case TY_CSI_PR('l',  40) :       resetMode(MODE_Allow132Columns ); break; // XTERM

744 745 746 747
    case TY_CSI_PR('h',  41) : /* IGNORED: obsolete more(1) fix     */ break; //XTERM
    case TY_CSI_PR('l',  41) : /* IGNORED: obsolete more(1) fix     */ break; //XTERM
    case TY_CSI_PR('s',  41) : /* IGNORED: obsolete more(1) fix     */ break; //XTERM
    case TY_CSI_PR('r',  41) : /* IGNORED: obsolete more(1) fix     */ break; //XTERM
748

749 750 751 752
    case TY_CSI_PR('h',  47) :          setMode      (MODE_AppScreen); break; //VT100
    case TY_CSI_PR('l',  47) :        resetMode      (MODE_AppScreen); break; //VT100
    case TY_CSI_PR('s',  47) :         saveMode      (MODE_AppScreen); break; //XTERM
    case TY_CSI_PR('r',  47) :      restoreMode      (MODE_AppScreen); break; //XTERM
753

754 755 756 757
    case TY_CSI_PR('h',  67) : /* IGNORED: DECBKM                   */ break; //XTERM
    case TY_CSI_PR('l',  67) : /* IGNORED: DECBKM                   */ break; //XTERM
    case TY_CSI_PR('s',  67) : /* IGNORED: DECBKM                   */ break; //XTERM
    case TY_CSI_PR('r',  67) : /* IGNORED: DECBKM                   */ break; //XTERM
Waldo Bastian's avatar
Waldo Bastian committed
758

759 760 761 762 763 764
    // XTerm defines the following modes:
    // SET_VT200_MOUSE             1000
    // SET_VT200_HIGHLIGHT_MOUSE   1001
    // SET_BTN_EVENT_MOUSE         1002
    // SET_ANY_EVENT_MOUSE         1003
    //
765

766 767 768
    //Note about mouse modes:
    //There are four mouse modes which xterm-compatible terminals can support - 1000,1001,1002,1003
    //Konsole currently supports mode 1000 (basic mouse press and release) and mode 1002 (dragging the mouse).
769
    //TODO:  Implementation of mouse modes 1001 (something called hilight tracking) and
770 771
    //1003 (a slight variation on dragging the mouse)
    //
772

773 774 775 776 777 778
    case TY_CSI_PR('h', 1000) :          setMode      (MODE_Mouse1000); break; //XTERM
    case TY_CSI_PR('l', 1000) :        resetMode      (MODE_Mouse1000); break; //XTERM
    case TY_CSI_PR('s', 1000) :         saveMode      (MODE_Mouse1000); break; //XTERM
    case TY_CSI_PR('r', 1000) :      restoreMode      (MODE_Mouse1000); break; //XTERM

    case TY_CSI_PR('h', 1001) : /* IGNORED: hilite mouse tracking    */ break; //XTERM
779
    case TY_CSI_PR('l', 1001) :        resetMode      (MODE_Mouse1001); break; //XTERM
780 781 782
    case TY_CSI_PR('s', 1001) : /* IGNORED: hilite mouse tracking    */ break; //XTERM
    case TY_CSI_PR('r', 1001) : /* IGNORED: hilite mouse tracking    */ break; //XTERM

783 784 785 786
    case TY_CSI_PR('h', 1002) :          setMode      (MODE_Mouse1002); break; //XTERM
    case TY_CSI_PR('l', 1002) :        resetMode      (MODE_Mouse1002); break; //XTERM
    case TY_CSI_PR('s', 1002) :         saveMode      (MODE_Mouse1002); break; //XTERM
    case TY_CSI_PR('r', 1002) :      restoreMode      (MODE_Mouse1002); break; //XTERM
787

788 789 790 791
    case TY_CSI_PR('h', 1003) :          setMode      (MODE_Mouse1003); break; //XTERM
    case TY_CSI_PR('l', 1003) :        resetMode      (MODE_Mouse1003); break; //XTERM
    case TY_CSI_PR('s', 1003) :         saveMode      (MODE_Mouse1003); break; //XTERM
    case TY_CSI_PR('r', 1003) :      restoreMode      (MODE_Mouse1003); break; //XTERM
792

793 794 795
    case TY_CSI_PR('h',  1004) : _reportFocusEvents = true; break;
    case TY_CSI_PR('l',  1004) : _reportFocusEvents = false; break;

796 797 798 799 800
    case TY_CSI_PR('h', 1005) :          setMode      (MODE_Mouse1005); break; //XTERM
    case TY_CSI_PR('l', 1005) :        resetMode      (MODE_Mouse1005); break; //XTERM
    case TY_CSI_PR('s', 1005) :         saveMode      (MODE_Mouse1005); break; //XTERM
    case TY_CSI_PR('r', 1005) :      restoreMode      (MODE_Mouse1005); break; //XTERM

801 802 803 804 805
    case TY_CSI_PR('h', 1006) :          setMode      (MODE_Mouse1006); break; //XTERM
    case TY_CSI_PR('l', 1006) :        resetMode      (MODE_Mouse1006); break; //XTERM
    case TY_CSI_PR('s', 1006) :         saveMode      (MODE_Mouse1006); break; //XTERM
    case TY_CSI_PR('r', 1006) :      restoreMode      (MODE_Mouse1006); break; //XTERM

806 807 808 809 810
    case TY_CSI_PR('h', 1015) :          setMode      (MODE_Mouse1015); break; //URXVT
    case TY_CSI_PR('l', 1015) :        resetMode      (MODE_Mouse1015); break; //URXVT
    case TY_CSI_PR('s', 1015) :         saveMode      (MODE_Mouse1015); break; //URXVT
    case TY_CSI_PR('r', 1015) :      restoreMode      (MODE_Mouse1015); break; //URXVT

811 812
    case TY_CSI_PR('h', 1034) : /* IGNORED: 8bitinput activation     */ break; //XTERM

813
    case TY_CSI_PR('h', 1047) :          setMode      (MODE_AppScreen); break; //XTERM
814
    case TY_CSI_PR('l', 1047) : _screen[1]->clearEntireScreen(); resetMode(MODE_AppScreen); break; //XTERM
Waldo Bastian's avatar
Waldo Bastian committed
815 816
    case TY_CSI_PR('s', 1047) :         saveMode      (MODE_AppScreen); break; //XTERM
    case TY_CSI_PR('r', 1047) :      restoreMode      (MODE_AppScreen); break; //XTERM
817 818 819 820

    //FIXME: Unitoken: save translations
    case TY_CSI_PR('h', 1048) :      saveCursor           (          ); break; //XTERM
    case TY_CSI_PR('l', 1048) :      restoreCursor        (          ); break; //XTERM
Waldo Bastian's avatar
Waldo Bastian committed
821 822
    case TY_CSI_PR('s', 1048) :      saveCursor           (          ); break; //XTERM
    case TY_CSI_PR('r', 1048) :      restoreCursor        (          ); break; //XTERM
823 824 825

    //FIXME: every once new sequences like this pop up in xterm.
    //       Here's a guess of what they could mean.
826
    case TY_CSI_PR('h', 1049) : saveCursor(); _screen[1]->clearEntireScreen(); setMode(MODE_AppScreen); break; //XTERM
Waldo Bastian's avatar
Waldo Bastian committed
827
    case TY_CSI_PR('l', 1049) : resetMode(MODE_AppScreen); restoreCursor(); break; //XTERM
828

829 830 831 832 833
    case TY_CSI_PR('h', 2004) :          setMode      (MODE_BracketedPaste); break; //XTERM
    case TY_CSI_PR('l', 2004) :        resetMode      (MODE_BracketedPaste); break; //XTERM
    case TY_CSI_PR('s', 2004) :         saveMode      (MODE_BracketedPaste); break; //XTERM
    case TY_CSI_PR('r', 2004) :      restoreMode      (MODE_BracketedPaste); break; //XTERM

Waldo Bastian's avatar
Waldo Bastian committed
834 835 836
    //FIXME: weird DEC reset sequence
    case TY_CSI_PE('p'      ) : /* IGNORED: reset         (        ) */ break;

837
    //FIXME: when changing between vt52 and ansi mode evtl do some resetting.
838 839 840 841
    case TY_VT52('A'      ) : _currentScreen->cursorUp             (         1); break; //VT52
    case TY_VT52('B'      ) : _currentScreen->cursorDown           (         1); break; //VT52
    case TY_VT52('C'      ) : _currentScreen->cursorRight          (         1); break; //VT52
    case TY_VT52('D'      ) : _currentScreen->cursorLeft           (         1); break; //VT52
Kurt Hindenburg's avatar
Kurt Hindenburg committed
842

843 844
    case TY_VT52('F'      ) :      setAndUseCharset     (0,    '0'); break; //VT52
    case TY_VT52('G'      ) :      setAndUseCharset     (0,    'B'); break; //VT52
Kurt Hindenburg's avatar
Kurt Hindenburg committed
845

846 847 848 849 850
    case TY_VT52('H'      ) : _currentScreen->setCursorYX          (1,1       ); break; //VT52
    case TY_VT52('I'      ) : _currentScreen->reverseIndex         (          ); break; //VT52
    case TY_VT52('J'      ) : _currentScreen->clearToEndOfScreen   (          ); break; //VT52
    case TY_VT52('K'      ) : _currentScreen->clearToEndOfLine     (          ); break; //VT52
    case TY_VT52('Y'      ) : _currentScreen->setCursorYX          (p-31,q-31 ); break; //VT52
Kurt Hindenburg's avatar
Kurt Hindenburg committed
851 852 853 854
    case TY_VT52('Z'      ) :      reportTerminalType   (           ); break; //VT52
    case TY_VT52('<'      ) :          setMode      (MODE_Ansi     ); break; //VT52
    case TY_VT52('='      ) :          setMode      (MODE_AppKeyPad); break; //VT52
    case TY_VT52('>'      ) :        resetMode      (MODE_AppKeyPad); break; //VT52
855

856 857
    case TY_CSI_PG('c'      ) :  reportSecondaryAttributes(          ); break; //VT100