MauiKit Terminal

Vt102Emulation.cpp
1/*
2 This file is part of Konsole, an X terminal.
3
4 SPDX-FileCopyrightText: 2007-2008 Robert Knight <robert.knight@gmail.com>
5 SPDX-FileCopyrightText: 1997, 1998 Lars Doelle <lars.doelle@on-line.de>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301 USA.
18*/
19
20// Own
21#include "Vt102Emulation.h"
22#include "tools.h"
23
24// XKB
25// #include <config-konsole.h>
26
27// this allows konsole to be compiled without XKB and XTEST extensions
28// even though it might be available on a particular system.
29#if defined(AVOID_XKB)
30#undef HAVE_XKB
31#endif
32
33#if defined(HAVE_XKB)
34void scrolllock_set_off();
35void scrolllock_set_on();
36#endif
37
38// Standard
39#include <cstdio>
40#include <unistd.h>
41
42// Qt
43#include <QDebug>
44#include <QEvent>
45#include <QKeyEvent>
46
47// KDE
48// #include <kdebug.h>
49// #include <klocale.h>
50
51// Konsole
52#include "KeyboardTranslator.h"
53#include "Screen.h"
54
55using namespace Konsole;
56
58 : Emulation()
59 , prevCC(0)
60 , _titleUpdateTimer(new QTimer(this))
61 , _reportFocusEvents(false)
62{
63 _titleUpdateTimer->setSingleShot(true);
64 QObject::connect(_titleUpdateTimer, &QTimer::timeout, this, &Vt102Emulation::updateTitle);
65
66 initTokenizer();
67 reset();
68}
69
70Vt102Emulation::~Vt102Emulation()
71{
72}
73
75{
76 _currentScreen->clearEntireScreen();
78}
79
81{
82 resetTokenizer();
83 resetModes();
84 resetCharset(0);
85 _primaryScreen->reset();
86 resetCharset(1);
87 _alternateScreen->reset();
88 setCodec(LocaleCodec);
89
91}
92
93/* ------------------------------------------------------------------------- */
94/* */
95/* Processing the incoming byte stream */
96/* */
97/* ------------------------------------------------------------------------- */
98
99/* Incoming Bytes Event pipeline
100
101 This section deals with decoding the incoming character stream.
102 Decoding means here, that the stream is first separated into `tokens'
103 which are then mapped to a `meaning' provided as operations by the
104 `Screen' class or by the emulation class itself.
105
106 The pipeline proceeds as follows:
107
108 - Tokenizing the ESC codes (onReceiveChar)
109 - VT100 code page translation of plain characters (applyCharset)
110 - Interpretation of ESC codes (processToken)
111
112 The escape codes and their meaning are described in the
113 technical reference of this program.
114*/
115
116// Tokens ------------------------------------------------------------------ --
117
118/*
119 Since the tokens are the central notion if this section, we've put them
120 in front. They provide the syntactical elements used to represent the
121 terminals operations as byte sequences.
122
123 They are encodes here into a single machine word, so that we can later
124 switch over them easily. Depending on the token itself, additional
125 argument variables are filled with parameter values.
126
127 The tokens are defined below:
128
129 - CHR - Printable characters (32..255 but DEL (=127))
130 - CTL - Control characters (0..31 but ESC (= 27), DEL)
131 - ESC - Escape codes of the form <ESC><CHR but `[]()+*#'>
132 - ESC_DE - Escape codes of the form <ESC><any of `()+*#%'> C
133 - CSI_PN - Escape codes of the form <ESC>'[' {Pn} ';' {Pn} C
134 - CSI_PS - Escape codes of the form <ESC>'[' {Pn} ';' ... C
135 - CSI_PS_SP - Escape codes of the form <ESC>'[' {Pn} ';' ... {Space} C
136 - CSI_PR - Escape codes of the form <ESC>'[' '?' {Pn} ';' ... C
137 - CSI_PE - Escape codes of the form <ESC>'[' '!' {Pn} ';' ... C
138 - VT52 - VT52 escape codes
139 - <ESC><Chr>
140 - <ESC>'Y'{Pc}{Pc}
141 - XTE_HA - Xterm window/terminal attribute commands
142 of the form <ESC>`]' {Pn} `;' {Text} <BEL>
143 (Note that these are handled differently to the other formats)
144
145 The last two forms allow list of arguments. Since the elements of
146 the lists are treated individually the same way, they are passed
147 as individual tokens to the interpretation. Further, because the
148 meaning of the parameters are names (althought represented as numbers),
149 they are includes within the token ('N').
150
151*/
152
153#define TY_CONSTRUCT(T, A, N) (((((int)N) & 0xffff) << 16) | ((((int)A) & 0xff) << 8) | (((int)T) & 0xff))
154
155#define TY_CHR() TY_CONSTRUCT(0, 0, 0)
156#define TY_CTL(A) TY_CONSTRUCT(1, A, 0)
157#define TY_ESC(A) TY_CONSTRUCT(2, A, 0)
158#define TY_ESC_CS(A, B) TY_CONSTRUCT(3, A, B)
159#define TY_ESC_DE(A) TY_CONSTRUCT(4, A, 0)
160#define TY_CSI_PS(A, N) TY_CONSTRUCT(5, A, N)
161#define TY_CSI_PN(A) TY_CONSTRUCT(6, A, 0)
162#define TY_CSI_PR(A, N) TY_CONSTRUCT(7, A, N)
163#define TY_CSI_PS_SP(A, N) TY_CONSTRUCT(11, A, N)
164
165#define TY_VT52(A) TY_CONSTRUCT(8, A, 0)
166#define TY_CSI_PG(A) TY_CONSTRUCT(9, A, 0)
167#define TY_CSI_PE(A) TY_CONSTRUCT(10, A, 0)
168
169#define MAX_ARGUMENT 4096
170
171// Tokenizer --------------------------------------------------------------- --
172
173/* The tokenizer's state
174
175 The state is represented by the buffer (tokenBuffer, tokenBufferPos),
176 and accompanied by decoded arguments kept in (argv,argc).
177 Note that they are kept internal in the tokenizer.
178*/
179
180void Vt102Emulation::resetTokenizer()
181{
182 tokenBufferPos = 0;
183 argc = 0;
184 argv[0] = 0;
185 argv[1] = 0;
186 prevCC = 0;
187}
188
189void Vt102Emulation::addDigit(int digit)
190{
191 if (argv[argc] < MAX_ARGUMENT)
192 argv[argc] = 10 * argv[argc] + digit;
193}
194
195void Vt102Emulation::addArgument()
196{
197 argc = qMin(argc + 1, MAXARGS - 1);
198 argv[argc] = 0;
199}
200
201void Vt102Emulation::addToCurrentToken(char16_t cc)
202{
203 tokenBuffer[tokenBufferPos] = cc;
204 tokenBufferPos = qMin(tokenBufferPos + 1, MAX_TOKEN_LENGTH - 1);
205}
206
207// Character Class flags used while decoding
208#define CTL 1 // Control character
209#define CHR 2 // Printable character
210#define CPN 4 // TODO: Document me
211#define DIG 8 // Digit
212#define SCS 16 // TODO: Document me
213#define GRP 32 // TODO: Document me
214#define CPS \
215 64 // Character which indicates end of window resize
216 // escape sequence '\e[8;<row>;<col>t'
217
218void Vt102Emulation::initTokenizer()
219{
220 int i;
221 quint8 *s;
222 for (i = 0; i < 256; ++i)
223 charClass[i] = 0;
224 for (i = 0; i < 32; ++i)
225 charClass[i] |= CTL;
226 for (i = 32; i < 256; ++i)
227 charClass[i] |= CHR;
228 for (s = (quint8 *)"@ABCDGHILMPSTXZbcdfry"; *s; ++s)
229 charClass[*s] |= CPN;
230 // resize = \e[8;<row>;<col>t
231 for (s = (quint8 *)"t"; *s; ++s)
232 charClass[*s] |= CPS;
233 for (s = (quint8 *)"0123456789"; *s; ++s)
234 charClass[*s] |= DIG;
235 for (s = (quint8 *)"()+*%"; *s; ++s)
236 charClass[*s] |= SCS;
237 for (s = (quint8 *)"()+*#[]%"; *s; ++s)
238 charClass[*s] |= GRP;
239
240 resetTokenizer();
241}
242
243/* Ok, here comes the nasty part of the decoder.
244
245 Instead of keeping an explicit state, we deduce it from the
246 token scanned so far. It is then immediately combined with
247 the current character to form a scanning decision.
248
249 This is done by the following defines.
250
251 - P is the length of the token scanned so far.
252 - L (often P-1) is the position on which contents we base a decision.
253 - C is a character or a group of characters (taken from 'charClass').
254
255 - 'cc' is the current character
256 - 's' is a pointer to the start of the token buffer
257 - 'p' is the current position within the token buffer
258
259 Note that they need to applied in proper order.
260*/
261
262#define lec(P, L, C) (p == (P) && s[(L)] == (C))
263#define lun() (p == 1 && cc >= 32)
264#define les(P, L, C) (p == (P) && s[L] < 256 && (charClass[s[(L)]] & (C)) == (C))
265#define eec(C) (p >= 3 && cc == (C))
266#define ees(C) (p >= 3 && cc < 256 && (charClass[cc] & (C)) == (C))
267#define eps(C) (p >= 3 && s[2] != '?' && s[2] != '!' && s[2] != '>' && cc < 256 && (charClass[cc] & (C)) == (C))
268#define epp() (p >= 3 && s[2] == '?')
269#define epe() (p >= 3 && s[2] == '!')
270#define egt() (p >= 3 && s[2] == '>')
271#define esp() (p == 4 && s[3] == ' ')
272#define Xpe (tokenBufferPos >= 2 && tokenBuffer[1] == ']')
273#define Xte (Xpe && (cc == 7 || (prevCC == 27 && cc == 92))) // 27, 92 => "\e\\" (ST, String Terminator)
274#define ces(C) (cc < 256 && (charClass[cc] & (C)) == (C) && !Xte)
275
276#define CNTL(c) ((c) - '@')
277#define ESC 27
278#define DEL 127
279
280// process an incoming unicode character
282{
283 char16_t cc = character.unicode();
284
285 if (cc == DEL)
286 return; // VT100: ignore.
287
288 if (ces(CTL)) {
289 // ignore control characters in the text part of Xpe (aka OSC) "ESC]"
290 // escape sequences; this matches what XTERM docs say
291 if (Xpe) {
292 prevCC = cc;
293 return;
294 }
295
296 // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100
297 // This means, they do neither a resetTokenizer() nor a pushToToken(). Some of them, do
298 // of course. Guess this originates from a weakly layered handling of the X-on
299 // X-off protocol, which comes really below this level.
300 if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC)
301 resetTokenizer(); // VT100: CAN or SUB
302 if (cc != ESC) {
303 processToken(TY_CTL(cc + '@'), 0, 0);
304 return;
305 }
306 }
307 // advance the state
308 addToCurrentToken(cc);
309
310 char16_t *s = tokenBuffer;
311 int p = tokenBufferPos;
312
313 if (getMode(MODE_Ansi)) {
314 if (lec(1, 0, ESC)) {
315 return;
316 }
317 if (lec(1, 0, ESC + 128)) {
318 s[0] = ESC;
319 receiveChar(u'[');
320 return;
321 }
322 if (les(2, 1, GRP)) {
323 return;
324 }
325 if (Xte) {
326 processWindowAttributeChange();
327 resetTokenizer();
328 return;
329 }
330 if (Xpe) {
331 prevCC = cc;
332 return;
333 }
334 if (lec(3, 2, '?')) {
335 return;
336 }
337 if (lec(3, 2, '>')) {
338 return;
339 }
340 if (lec(3, 2, '!')) {
341 return;
342 }
343 if (lun()) {
344 processToken(TY_CHR(), applyCharset(cc), 0);
345 resetTokenizer();
346 return;
347 }
348 if (lec(2, 0, ESC)) {
349 processToken(TY_ESC(s[1]), 0, 0);
350 resetTokenizer();
351 return;
352 }
353 if (les(3, 1, SCS)) {
354 processToken(TY_ESC_CS(s[1], s[2]), 0, 0);
355 resetTokenizer();
356 return;
357 }
358 if (lec(3, 1, '#')) {
359 processToken(TY_ESC_DE(s[2]), 0, 0);
360 resetTokenizer();
361 return;
362 }
363 if (eps(CPN)) {
364 processToken(TY_CSI_PN(cc), argv[0], argv[1]);
365 resetTokenizer();
366 return;
367 }
368 if (esp()) {
369 return;
370 }
371 if (lec(5, 4, 'q') && s[3] == ' ') {
372 processToken(TY_CSI_PS_SP(cc, argv[0]), argv[0], 0);
373 resetTokenizer();
374 return;
375 }
376
377 // resize = \e[8;<row>;<col>t
378 if (eps(CPS)) {
379 processToken(TY_CSI_PS(cc, argv[0]), argv[1], argv[2]);
380 resetTokenizer();
381 return;
382 }
383
384 if (epe()) {
385 processToken(TY_CSI_PE(cc), 0, 0);
386 resetTokenizer();
387 return;
388 }
389 if (ees(DIG)) {
390 addDigit(cc - '0');
391 return;
392 }
393 if (eec(';') || eec(':')) {
394 addArgument();
395 return;
396 }
397 for (int i = 0; i <= argc; i++) {
398 if (epp())
399 processToken(TY_CSI_PR(cc, argv[i]), 0, 0);
400 else if (egt())
401 processToken(TY_CSI_PG(cc), 0, 0); // spec. case for ESC]>0c or ESC]>c
402 else if (cc == 'm' && argc - i >= 4 && (argv[i] == 38 || argv[i] == 48) && argv[i + 1] == 2) {
403 // ESC[ ... 48;2;<red>;<green>;<blue> ... m -or- ESC[ ... 38;2;<red>;<green>;<blue> ... m
404 i += 2;
405 processToken(TY_CSI_PS(cc, argv[i - 2]), COLOR_SPACE_RGB, (argv[i] << 16) | (argv[i + 1] << 8) | argv[i + 2]);
406 i += 2;
407 } else if (cc == 'm' && argc - i >= 2 && (argv[i] == 38 || argv[i] == 48) && argv[i + 1] == 5) {
408 // ESC[ ... 48;5;<index> ... m -or- ESC[ ... 38;5;<index> ... m
409 i += 2;
410 processToken(TY_CSI_PS(cc, argv[i - 2]), COLOR_SPACE_256, argv[i]);
411 } else
412 processToken(TY_CSI_PS(cc, argv[i]), 0, 0);
413 }
414 resetTokenizer();
415 } else {
416 // VT52 Mode
417 if (lec(1, 0, ESC))
418 return;
419 if (les(1, 0, CHR)) {
420 processToken(TY_CHR(), s[0], 0);
421 resetTokenizer();
422 return;
423 }
424 if (lec(2, 1, 'Y'))
425 return;
426
427 if (lec(3, 1, 'Y'))
428 return;
429
430 if (p < 4) {
431 processToken(TY_VT52(s[1]), 0, 0);
432 resetTokenizer();
433 return;
434 }
435 processToken(TY_VT52(s[1]), s[2], s[3]);
436 resetTokenizer();
437 return;
438 }
439}
440void Vt102Emulation::processWindowAttributeChange()
441{
442 // Describes the window or terminal session attribute to change
443 // See Session::UserTitleChange for possible values
444 int attributeToChange = 0;
445 int i;
446 for (i = 2; i < tokenBufferPos && tokenBuffer[i] >= '0' && tokenBuffer[i] <= '9'; i++) {
447 attributeToChange = 10 * attributeToChange + (tokenBuffer[i] - '0');
448 }
449
450 if (tokenBuffer[i] != ';') {
451 reportDecodingError();
452 return;
453 }
454
455 // copy from the first char after ';', and skipping the ending delimiter
456 // 0x07 or 0x92. Note that as control characters in OSC text parts are
457 // ignored, only the second char in ST ("\e\\") is appended to tokenBuffer.
458 QString newValue = QString::fromUtf16(tokenBuffer + i + 1, tokenBufferPos - i - 2);
459
460 _pendingTitleUpdates[attributeToChange] = newValue;
461 _titleUpdateTimer->start(20);
462}
463
464void Vt102Emulation::updateTitle()
465{
466 QListIterator<int> iter(_pendingTitleUpdates.keys());
467 while (iter.hasNext()) {
468 int arg = iter.next();
469 Q_EMIT titleChanged(arg, _pendingTitleUpdates[arg]);
470 }
471 _pendingTitleUpdates.clear();
472}
473
474// Interpreting Codes ---------------------------------------------------------
475
476/*
477 Now that the incoming character stream is properly tokenized,
478 meaning is assigned to them. These are either operations of
479 the current _screen, or of the emulation class itself.
480
481 The token to be interpreteted comes in as a machine word
482 possibly accompanied by two parameters.
483
484 Likewise, the operations assigned to, come with up to two
485 arguments. One could consider to make up a proper table
486 from the function below.
487
488 The technical reference manual provides more information
489 about this mapping.
490*/
491
492void Vt102Emulation::processToken(int token, char16_t p, int q)
493{
494 switch (token) {
495 case TY_CHR():
496 _currentScreen->displayCharacter(p);
497 break; // UTF16
498
499 // 127 DEL : ignored on input
500
501 case TY_CTL('@'): /* NUL: ignored */
502 break;
503 case TY_CTL('A'): /* SOH: ignored */
504 break;
505 case TY_CTL('B'): /* STX: ignored */
506 break;
507 case TY_CTL('C'): /* ETX: ignored */
508 break;
509 case TY_CTL('D'): /* EOT: ignored */
510 break;
511 case TY_CTL('E'):
512 reportAnswerBack();
513 break; // VT100
514 case TY_CTL('F'): /* ACK: ignored */
515 break;
516 case TY_CTL('G'):
517 Q_EMIT stateSet(NOTIFYBELL);
518 break; // VT100
519 case TY_CTL('H'):
520 _currentScreen->backspace();
521 break; // VT100
522 case TY_CTL('I'):
523 _currentScreen->tab();
524 break; // VT100
525 case TY_CTL('J'):
526 _currentScreen->newLine();
527 break; // VT100
528 case TY_CTL('K'):
529 _currentScreen->newLine();
530 break; // VT100
531 case TY_CTL('L'):
532 _currentScreen->newLine();
533 break; // VT100
534 case TY_CTL('M'):
535 _currentScreen->toStartOfLine();
536 break; // VT100
537
538 case TY_CTL('N'):
539 useCharset(1);
540 break; // VT100
541 case TY_CTL('O'):
542 useCharset(0);
543 break; // VT100
544
545 case TY_CTL('P'): /* DLE: ignored */
546 break;
547 case TY_CTL('Q'): /* DC1: XON continue */
548 break; // VT100
549 case TY_CTL('R'): /* DC2: ignored */
550 break;
551 case TY_CTL('S'): /* DC3: XOFF halt */
552 break; // VT100
553 case TY_CTL('T'): /* DC4: ignored */
554 break;
555 case TY_CTL('U'): /* NAK: ignored */
556 break;
557 case TY_CTL('V'): /* SYN: ignored */
558 break;
559 case TY_CTL('W'): /* ETB: ignored */
560 break;
561 case TY_CTL('X'):
562 _currentScreen->displayCharacter(QChar(0x2592));
563 break; // VT100
564 case TY_CTL('Y'): /* EM : ignored */
565 break;
566 case TY_CTL('Z'):
567 _currentScreen->displayCharacter(QChar(0x2592));
568 break; // VT100
569 case TY_CTL('['): /* ESC: cannot be seen here. */
570 break;
571 case TY_CTL('\\'): /* FS : ignored */
572 break;
573 case TY_CTL(']'): /* GS : ignored */
574 break;
575 case TY_CTL('^'): /* RS : ignored */
576 break;
577 case TY_CTL('_'): /* US : ignored */
578 break;
579
580 case TY_ESC('D'):
581 _currentScreen->index();
582 break; // VT100
583 case TY_ESC('E'):
584 _currentScreen->nextLine();
585 break; // VT100
586 case TY_ESC('H'):
587 _currentScreen->changeTabStop(true);
588 break; // VT100
589 case TY_ESC('M'):
590 _currentScreen->reverseIndex();
591 break; // VT100
592 case TY_ESC('Z'):
593 reportTerminalType();
594 break;
595 case TY_ESC('c'):
596 reset();
597 break;
598
599 case TY_ESC('n'):
600 useCharset(2);
601 break;
602 case TY_ESC('o'):
603 useCharset(3);
604 break;
605 case TY_ESC('7'):
606 saveCursor();
607 break;
608 case TY_ESC('8'):
609 restoreCursor();
610 break;
611
612 case TY_ESC('='):
613 setMode(MODE_AppKeyPad);
614 break;
615 case TY_ESC('>'):
616 resetMode(MODE_AppKeyPad);
617 break;
618 case TY_ESC('<'):
619 setMode(MODE_Ansi);
620 break; // VT100
621
622 case TY_ESC_CS('(', '0'):
623 setCharset(0, '0');
624 break; // VT100
625 case TY_ESC_CS('(', 'A'):
626 setCharset(0, 'A');
627 break; // VT100
628 case TY_ESC_CS('(', 'B'):
629 setCharset(0, 'B');
630 break; // VT100
631
632 case TY_ESC_CS(')', '0'):
633 setCharset(1, '0');
634 break; // VT100
635 case TY_ESC_CS(')', 'A'):
636 setCharset(1, 'A');
637 break; // VT100
638 case TY_ESC_CS(')', 'B'):
639 setCharset(1, 'B');
640 break; // VT100
641
642 case TY_ESC_CS('*', '0'):
643 setCharset(2, '0');
644 break; // VT100
645 case TY_ESC_CS('*', 'A'):
646 setCharset(2, 'A');
647 break; // VT100
648 case TY_ESC_CS('*', 'B'):
649 setCharset(2, 'B');
650 break; // VT100
651
652 case TY_ESC_CS('+', '0'):
653 setCharset(3, '0');
654 break; // VT100
655 case TY_ESC_CS('+', 'A'):
656 setCharset(3, 'A');
657 break; // VT100
658 case TY_ESC_CS('+', 'B'):
659 setCharset(3, 'B');
660 break; // VT100
661
662 case TY_ESC_CS('%', 'G'):
663 setCodec(Utf8Codec);
664 break; // LINUX
665 case TY_ESC_CS('%', '@'):
666 setCodec(LocaleCodec);
667 break; // LINUX
668
669 case TY_ESC_DE('3'): /* Double height line, top half */
670 _currentScreen->setLineProperty(LINE_DOUBLEWIDTH, true);
671 _currentScreen->setLineProperty(LINE_DOUBLEHEIGHT, true);
672 break;
673 case TY_ESC_DE('4'): /* Double height line, bottom half */
674 _currentScreen->setLineProperty(LINE_DOUBLEWIDTH, true);
675 _currentScreen->setLineProperty(LINE_DOUBLEHEIGHT, true);
676 break;
677 case TY_ESC_DE('5'): /* Single width, single height line*/
678 _currentScreen->setLineProperty(LINE_DOUBLEWIDTH, false);
679 _currentScreen->setLineProperty(LINE_DOUBLEHEIGHT, false);
680 break;
681 case TY_ESC_DE('6'): /* Double width, single height line*/
682 _currentScreen->setLineProperty(LINE_DOUBLEWIDTH, true);
683 _currentScreen->setLineProperty(LINE_DOUBLEHEIGHT, false);
684 break;
685 case TY_ESC_DE('8'):
686 _currentScreen->helpAlign();
687 break;
688
689 // resize = \e[8;<row>;<col>t
690 case TY_CSI_PS('t', 8):
691 setImageSize(p /*lines */, q /* columns */);
693 break;
694
695 // change tab text color : \e[28;<color>t color: 0-16,777,215
696 case TY_CSI_PS('t', 28):
698 break;
699
700 case TY_CSI_PS('K', 0):
701 _currentScreen->clearToEndOfLine();
702 break;
703 case TY_CSI_PS('K', 1):
704 _currentScreen->clearToBeginOfLine();
705 break;
706 case TY_CSI_PS('K', 2):
707 _currentScreen->clearEntireLine();
708 break;
709 case TY_CSI_PS('J', 0):
710 _currentScreen->clearToEndOfScreen();
711 break;
712 case TY_CSI_PS('J', 1):
713 _currentScreen->clearToBeginOfScreen();
714 break;
715 case TY_CSI_PS('J', 2):
716 _currentScreen->clearEntireScreen();
717 break;
718 case TY_CSI_PS('J', 3):
719 clearHistory();
720 break;
721 case TY_CSI_PS('g', 0):
722 _currentScreen->changeTabStop(false);
723 break; // VT100
724 case TY_CSI_PS('g', 3):
725 _currentScreen->clearTabStops();
726 break; // VT100
727 case TY_CSI_PS('h', 4):
728 _currentScreen->setMode(MODE_Insert);
729 break;
730 case TY_CSI_PS('h', 20):
731 setMode(MODE_NewLine);
732 break;
733 case TY_CSI_PS('i', 0): /* IGNORE: attached printer */
734 break; // VT100
735 case TY_CSI_PS('l', 4):
736 _currentScreen->resetMode(MODE_Insert);
737 break;
738 case TY_CSI_PS('l', 20):
739 resetMode(MODE_NewLine);
740 break;
741 case TY_CSI_PS('s', 0):
742 saveCursor();
743 break;
744 case TY_CSI_PS('u', 0):
745 restoreCursor();
746 break;
747
748 case TY_CSI_PS('m', 0):
749 _currentScreen->setDefaultRendition();
750 break;
751 case TY_CSI_PS('m', 1):
752 _currentScreen->setRendition(RE_BOLD);
753 break; // VT100
754 case TY_CSI_PS('m', 2):
755 _currentScreen->setRendition(RE_FAINT);
756 break;
757 case TY_CSI_PS('m', 3):
758 _currentScreen->setRendition(RE_ITALIC);
759 break; // VT100
760 case TY_CSI_PS('m', 4):
761 _currentScreen->setRendition(RE_UNDERLINE);
762 break; // VT100
763 case TY_CSI_PS('m', 5):
764 _currentScreen->setRendition(RE_BLINK);
765 break; // VT100
766 case TY_CSI_PS('m', 7):
767 _currentScreen->setRendition(RE_REVERSE);
768 break;
769 case TY_CSI_PS('m', 8):
770 _currentScreen->setRendition(RE_CONCEAL);
771 break;
772 case TY_CSI_PS('m', 9):
773 _currentScreen->setRendition(RE_STRIKEOUT);
774 break;
775 case TY_CSI_PS('m', 53):
776 _currentScreen->setRendition(RE_OVERLINE);
777 break;
778 case TY_CSI_PS('m', 10): /* IGNORED: mapping related */
779 break; // LINUX
780 case TY_CSI_PS('m', 11): /* IGNORED: mapping related */
781 break; // LINUX
782 case TY_CSI_PS('m', 12): /* IGNORED: mapping related */
783 break; // LINUX
784 case TY_CSI_PS('m', 21):
785 _currentScreen->resetRendition(RE_BOLD);
786 break;
787 case TY_CSI_PS('m', 22):
788 _currentScreen->resetRendition(RE_BOLD);
789 _currentScreen->resetRendition(RE_FAINT);
790 break;
791 case TY_CSI_PS('m', 23):
792 _currentScreen->resetRendition(RE_ITALIC);
793 break; // VT100
794 case TY_CSI_PS('m', 24):
795 _currentScreen->resetRendition(RE_UNDERLINE);
796 break;
797 case TY_CSI_PS('m', 25):
798 _currentScreen->resetRendition(RE_BLINK);
799 break;
800 case TY_CSI_PS('m', 27):
801 _currentScreen->resetRendition(RE_REVERSE);
802 break;
803 case TY_CSI_PS('m', 28):
804 _currentScreen->resetRendition(RE_CONCEAL);
805 break;
806 case TY_CSI_PS('m', 29):
807 _currentScreen->resetRendition(RE_STRIKEOUT);
808 break;
809 case TY_CSI_PS('m', 55):
810 _currentScreen->resetRendition(RE_OVERLINE);
811 break;
812
813 case TY_CSI_PS('m', 30):
814 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 0);
815 break;
816 case TY_CSI_PS('m', 31):
817 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 1);
818 break;
819 case TY_CSI_PS('m', 32):
820 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 2);
821 break;
822 case TY_CSI_PS('m', 33):
823 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 3);
824 break;
825 case TY_CSI_PS('m', 34):
826 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 4);
827 break;
828 case TY_CSI_PS('m', 35):
829 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 5);
830 break;
831 case TY_CSI_PS('m', 36):
832 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 6);
833 break;
834 case TY_CSI_PS('m', 37):
835 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 7);
836 break;
837
838 case TY_CSI_PS('m', 38):
839 _currentScreen->setForeColor(p, q);
840 break;
841
842 case TY_CSI_PS('m', 39):
843 _currentScreen->setForeColor(COLOR_SPACE_DEFAULT, 0);
844 break;
845
846 case TY_CSI_PS('m', 40):
847 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 0);
848 break;
849 case TY_CSI_PS('m', 41):
850 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 1);
851 break;
852 case TY_CSI_PS('m', 42):
853 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 2);
854 break;
855 case TY_CSI_PS('m', 43):
856 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 3);
857 break;
858 case TY_CSI_PS('m', 44):
859 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 4);
860 break;
861 case TY_CSI_PS('m', 45):
862 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 5);
863 break;
864 case TY_CSI_PS('m', 46):
865 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 6);
866 break;
867 case TY_CSI_PS('m', 47):
868 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 7);
869 break;
870
871 case TY_CSI_PS('m', 48):
872 _currentScreen->setBackColor(p, q);
873 break;
874
875 case TY_CSI_PS('m', 49):
876 _currentScreen->setBackColor(COLOR_SPACE_DEFAULT, 1);
877 break;
878
879 case TY_CSI_PS('m', 90):
880 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 8);
881 break;
882 case TY_CSI_PS('m', 91):
883 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 9);
884 break;
885 case TY_CSI_PS('m', 92):
886 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 10);
887 break;
888 case TY_CSI_PS('m', 93):
889 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 11);
890 break;
891 case TY_CSI_PS('m', 94):
892 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 12);
893 break;
894 case TY_CSI_PS('m', 95):
895 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 13);
896 break;
897 case TY_CSI_PS('m', 96):
898 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 14);
899 break;
900 case TY_CSI_PS('m', 97):
901 _currentScreen->setForeColor(COLOR_SPACE_SYSTEM, 15);
902 break;
903
904 case TY_CSI_PS('m', 100):
905 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 8);
906 break;
907 case TY_CSI_PS('m', 101):
908 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 9);
909 break;
910 case TY_CSI_PS('m', 102):
911 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 10);
912 break;
913 case TY_CSI_PS('m', 103):
914 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 11);
915 break;
916 case TY_CSI_PS('m', 104):
917 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 12);
918 break;
919 case TY_CSI_PS('m', 105):
920 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 13);
921 break;
922 case TY_CSI_PS('m', 106):
923 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 14);
924 break;
925 case TY_CSI_PS('m', 107):
926 _currentScreen->setBackColor(COLOR_SPACE_SYSTEM, 15);
927 break;
928
929 case TY_CSI_PS('n', 5):
930 reportStatus();
931 break;
932 case TY_CSI_PS('n', 6):
933 reportCursorPosition();
934 break;
935 case TY_CSI_PS('q', 0): /* IGNORED: LEDs off */
936 break; // VT100
937 case TY_CSI_PS('q', 1): /* IGNORED: LED1 on */
938 break; // VT100
939 case TY_CSI_PS('q', 2): /* IGNORED: LED2 on */
940 break; // VT100
941 case TY_CSI_PS('q', 3): /* IGNORED: LED3 on */
942 break; // VT100
943 case TY_CSI_PS('q', 4): /* IGNORED: LED4 on */
944 break; // VT100
945 case TY_CSI_PS('x', 0):
946 reportTerminalParms(2);
947 break; // VT100
948 case TY_CSI_PS('x', 1):
949 reportTerminalParms(3);
950 break; // VT100
951
952 case TY_CSI_PS_SP('q', 0): /* fall through */
953 case TY_CSI_PS_SP('q', 1):
954 Q_EMIT cursorChanged(KeyboardCursorShape::BlockCursor, true);
955 break;
956 case TY_CSI_PS_SP('q', 2):
957 Q_EMIT cursorChanged(KeyboardCursorShape::BlockCursor, false);
958 break;
959 case TY_CSI_PS_SP('q', 3):
960 Q_EMIT cursorChanged(KeyboardCursorShape::UnderlineCursor, true);
961 break;
962 case TY_CSI_PS_SP('q', 4):
963 Q_EMIT cursorChanged(KeyboardCursorShape::UnderlineCursor, false);
964 break;
965 case TY_CSI_PS_SP('q', 5):
966 Q_EMIT cursorChanged(KeyboardCursorShape::IBeamCursor, true);
967 break;
968 case TY_CSI_PS_SP('q', 6):
969 Q_EMIT cursorChanged(KeyboardCursorShape::IBeamCursor, false);
970 break;
971
972 case TY_CSI_PN('@'):
973 _currentScreen->insertChars(p);
974 break;
975 case TY_CSI_PN('A'):
976 _currentScreen->cursorUp(p);
977 break; // VT100
978 case TY_CSI_PN('B'):
979 _currentScreen->cursorDown(p);
980 break; // VT100
981 case TY_CSI_PN('C'):
982 _currentScreen->cursorRight(p);
983 break; // VT100
984 case TY_CSI_PN('D'):
985 _currentScreen->cursorLeft(p);
986 break; // VT100
987 case TY_CSI_PN('E'): /* Not implemented: cursor next p lines */
988 break; // VT100
989 case TY_CSI_PN('F'): /* Not implemented: cursor preceding p lines */
990 break; // VT100
991 case TY_CSI_PN('G'):
992 _currentScreen->setCursorX(p);
993 break; // LINUX
994 case TY_CSI_PN('H'):
995 _currentScreen->setCursorYX(p, q);
996 break; // VT100
997 case TY_CSI_PN('I'):
998 _currentScreen->tab(p);
999 break;
1000 case TY_CSI_PN('L'):
1001 _currentScreen->insertLines(p);
1002 break;
1003 case TY_CSI_PN('M'):
1004 _currentScreen->deleteLines(p);
1005 break;
1006 case TY_CSI_PN('P'):
1007 _currentScreen->deleteChars(p);
1008 break;
1009 case TY_CSI_PN('S'):
1010 _currentScreen->scrollUp(p);
1011 break;
1012 case TY_CSI_PN('T'):
1013 _currentScreen->scrollDown(p);
1014 break;
1015 case TY_CSI_PN('X'):
1016 _currentScreen->eraseChars(p);
1017 break;
1018 case TY_CSI_PN('Z'):
1019 _currentScreen->backtab(p);
1020 break;
1021 case TY_CSI_PN('b'):
1022 _currentScreen->repeatChars(p);
1023 break;
1024 case TY_CSI_PN('c'):
1025 reportTerminalType();
1026 break; // VT100
1027 case TY_CSI_PN('d'):
1028 _currentScreen->setCursorY(p);
1029 break; // LINUX
1030 case TY_CSI_PN('f'):
1031 _currentScreen->setCursorYX(p, q);
1032 break; // VT100
1033 case TY_CSI_PN('r'):
1034 setMargins(p, q);
1035 break; // VT100
1036 case TY_CSI_PN('y'): /* IGNORED: Confidence test */
1037 break; // VT100
1038
1039 case TY_CSI_PR('h', 1):
1040 setMode(MODE_AppCuKeys);
1041 break; // VT100
1042 case TY_CSI_PR('l', 1):
1043 resetMode(MODE_AppCuKeys);
1044 break; // VT100
1045 case TY_CSI_PR('s', 1):
1046 saveMode(MODE_AppCuKeys);
1047 break; // FIXME
1048 case TY_CSI_PR('r', 1):
1049 restoreMode(MODE_AppCuKeys);
1050 break; // FIXME
1051
1052 case TY_CSI_PR('l', 2):
1053 resetMode(MODE_Ansi);
1054 break; // VT100
1055
1056 case TY_CSI_PR('h', 3):
1057 setMode(MODE_132Columns);
1058 break; // VT100
1059 case TY_CSI_PR('l', 3):
1060 resetMode(MODE_132Columns);
1061 break; // VT100
1062
1063 case TY_CSI_PR('h', 4): /* IGNORED: soft scrolling */
1064 break; // VT100
1065 case TY_CSI_PR('l', 4): /* IGNORED: soft scrolling */
1066 break; // VT100
1067
1068 case TY_CSI_PR('h', 5):
1069 _currentScreen->setMode(MODE_Screen);
1070 break; // VT100
1071 case TY_CSI_PR('l', 5):
1072 _currentScreen->resetMode(MODE_Screen);
1073 break; // VT100
1074
1075 case TY_CSI_PR('h', 6):
1076 _currentScreen->setMode(MODE_Origin);
1077 break; // VT100
1078 case TY_CSI_PR('l', 6):
1079 _currentScreen->resetMode(MODE_Origin);
1080 break; // VT100
1081 case TY_CSI_PR('s', 6):
1082 _currentScreen->saveMode(MODE_Origin);
1083 break; // FIXME
1084 case TY_CSI_PR('r', 6):
1085 _currentScreen->restoreMode(MODE_Origin);
1086 break; // FIXME
1087
1088 case TY_CSI_PR('h', 7):
1089 _currentScreen->setMode(MODE_Wrap);
1090 break; // VT100
1091 case TY_CSI_PR('l', 7):
1092 _currentScreen->resetMode(MODE_Wrap);
1093 break; // VT100
1094 case TY_CSI_PR('s', 7):
1095 _currentScreen->saveMode(MODE_Wrap);
1096 break; // FIXME
1097 case TY_CSI_PR('r', 7):
1098 _currentScreen->restoreMode(MODE_Wrap);
1099 break; // FIXME
1100
1101 case TY_CSI_PR('h', 8): /* IGNORED: autorepeat on */
1102 break; // VT100
1103 case TY_CSI_PR('l', 8): /* IGNORED: autorepeat off */
1104 break; // VT100
1105 case TY_CSI_PR('s', 8): /* IGNORED: autorepeat on */
1106 break; // VT100
1107 case TY_CSI_PR('r', 8): /* IGNORED: autorepeat off */
1108 break; // VT100
1109
1110 case TY_CSI_PR('h', 9): /* IGNORED: interlace */
1111 break; // VT100
1112 case TY_CSI_PR('l', 9): /* IGNORED: interlace */
1113 break; // VT100
1114 case TY_CSI_PR('s', 9): /* IGNORED: interlace */
1115 break; // VT100
1116 case TY_CSI_PR('r', 9): /* IGNORED: interlace */
1117 break; // VT100
1118
1119 case TY_CSI_PR('h', 12): /* IGNORED: Cursor blink */
1120 break; // att610
1121 case TY_CSI_PR('l', 12): /* IGNORED: Cursor blink */
1122 break; // att610
1123 case TY_CSI_PR('s', 12): /* IGNORED: Cursor blink */
1124 break; // att610
1125 case TY_CSI_PR('r', 12): /* IGNORED: Cursor blink */
1126 break; // att610
1127
1128 case TY_CSI_PR('h', 25):
1129 setMode(MODE_Cursor);
1130 break; // VT100
1131 case TY_CSI_PR('l', 25):
1132 resetMode(MODE_Cursor);
1133 break; // VT100
1134 case TY_CSI_PR('s', 25):
1135 saveMode(MODE_Cursor);
1136 break; // VT100
1137 case TY_CSI_PR('r', 25):
1138 restoreMode(MODE_Cursor);
1139 break; // VT100
1140
1141 case TY_CSI_PR('h', 40):
1142 setMode(MODE_Allow132Columns);
1143 break; // XTERM
1144 case TY_CSI_PR('l', 40):
1145 resetMode(MODE_Allow132Columns);
1146 break; // XTERM
1147
1148 case TY_CSI_PR('h', 41): /* IGNORED: obsolete more(1) fix */
1149 break; // XTERM
1150 case TY_CSI_PR('l', 41): /* IGNORED: obsolete more(1) fix */
1151 break; // XTERM
1152 case TY_CSI_PR('s', 41): /* IGNORED: obsolete more(1) fix */
1153 break; // XTERM
1154 case TY_CSI_PR('r', 41): /* IGNORED: obsolete more(1) fix */
1155 break; // XTERM
1156
1157 case TY_CSI_PR('h', 47):
1158 setMode(MODE_AppScreen);
1159 break; // VT100
1160 case TY_CSI_PR('l', 47):
1161 resetMode(MODE_AppScreen);
1162 break; // VT100
1163 case TY_CSI_PR('s', 47):
1164 saveMode(MODE_AppScreen);
1165 break; // XTERM
1166 case TY_CSI_PR('r', 47):
1167 restoreMode(MODE_AppScreen);
1168 break; // XTERM
1169
1170 case TY_CSI_PR('h', 67): /* IGNORED: DECBKM */
1171 break; // XTERM
1172 case TY_CSI_PR('l', 67): /* IGNORED: DECBKM */
1173 break; // XTERM
1174 case TY_CSI_PR('s', 67): /* IGNORED: DECBKM */
1175 break; // XTERM
1176 case TY_CSI_PR('r', 67): /* IGNORED: DECBKM */
1177 break; // XTERM
1178
1179 // XTerm defines the following modes:
1180 // SET_VT200_MOUSE 1000
1181 // SET_VT200_HIGHLIGHT_MOUSE 1001
1182 // SET_BTN_EVENT_MOUSE 1002
1183 // SET_ANY_EVENT_MOUSE 1003
1184 //
1185
1186 // Note about mouse modes:
1187 // There are four mouse modes which xterm-compatible terminals can support - 1000,1001,1002,1003
1188 // Konsole currently supports mode 1000 (basic mouse press and release) and mode 1002 (dragging the mouse).
1189 // TODO: Implementation of mouse modes 1001 (something called hilight tracking) and
1190 // 1003 (a slight variation on dragging the mouse)
1191 //
1192
1193 case TY_CSI_PR('h', 1000):
1194 setMode(MODE_Mouse1000);
1195 break; // XTERM
1196 case TY_CSI_PR('l', 1000):
1197 resetMode(MODE_Mouse1000);
1198 break; // XTERM
1199 case TY_CSI_PR('s', 1000):
1200 saveMode(MODE_Mouse1000);
1201 break; // XTERM
1202 case TY_CSI_PR('r', 1000):
1203 restoreMode(MODE_Mouse1000);
1204 break; // XTERM
1205
1206 case TY_CSI_PR('h', 1001): /* IGNORED: hilite mouse tracking */
1207 break; // XTERM
1208 case TY_CSI_PR('l', 1001):
1209 resetMode(MODE_Mouse1001);
1210 break; // XTERM
1211 case TY_CSI_PR('s', 1001): /* IGNORED: hilite mouse tracking */
1212 break; // XTERM
1213 case TY_CSI_PR('r', 1001): /* IGNORED: hilite mouse tracking */
1214 break; // XTERM
1215
1216 case TY_CSI_PR('h', 1002):
1217 setMode(MODE_Mouse1002);
1218 break; // XTERM
1219 case TY_CSI_PR('l', 1002):
1220 resetMode(MODE_Mouse1002);
1221 break; // XTERM
1222 case TY_CSI_PR('s', 1002):
1223 saveMode(MODE_Mouse1002);
1224 break; // XTERM
1225 case TY_CSI_PR('r', 1002):
1226 restoreMode(MODE_Mouse1002);
1227 break; // XTERM
1228
1229 case TY_CSI_PR('h', 1003):
1230 setMode(MODE_Mouse1003);
1231 break; // XTERM
1232 case TY_CSI_PR('l', 1003):
1233 resetMode(MODE_Mouse1003);
1234 break; // XTERM
1235 case TY_CSI_PR('s', 1003):
1236 saveMode(MODE_Mouse1003);
1237 break; // XTERM
1238 case TY_CSI_PR('r', 1003):
1239 restoreMode(MODE_Mouse1003);
1240 break; // XTERM
1241
1242 case TY_CSI_PR('h', 1004):
1243 _reportFocusEvents = true;
1244 break;
1245 case TY_CSI_PR('l', 1004):
1246 _reportFocusEvents = false;
1247 break;
1248
1249 case TY_CSI_PR('h', 1005):
1250 setMode(MODE_Mouse1005);
1251 break; // XTERM
1252 case TY_CSI_PR('l', 1005):
1253 resetMode(MODE_Mouse1005);
1254 break; // XTERM
1255 case TY_CSI_PR('s', 1005):
1256 saveMode(MODE_Mouse1005);
1257 break; // XTERM
1258 case TY_CSI_PR('r', 1005):
1259 restoreMode(MODE_Mouse1005);
1260 break; // XTERM
1261
1262 case TY_CSI_PR('h', 1006):
1263 setMode(MODE_Mouse1006);
1264 break; // XTERM
1265 case TY_CSI_PR('l', 1006):
1266 resetMode(MODE_Mouse1006);
1267 break; // XTERM
1268 case TY_CSI_PR('s', 1006):
1269 saveMode(MODE_Mouse1006);
1270 break; // XTERM
1271 case TY_CSI_PR('r', 1006):
1272 restoreMode(MODE_Mouse1006);
1273 break; // XTERM
1274
1275 case TY_CSI_PR('h', 1015):
1276 setMode(MODE_Mouse1015);
1277 break; // URXVT
1278 case TY_CSI_PR('l', 1015):
1279 resetMode(MODE_Mouse1015);
1280 break; // URXVT
1281 case TY_CSI_PR('s', 1015):
1282 saveMode(MODE_Mouse1015);
1283 break; // URXVT
1284 case TY_CSI_PR('r', 1015):
1285 restoreMode(MODE_Mouse1015);
1286 break; // URXVT
1287
1288 case TY_CSI_PR('h', 1034): /* IGNORED: 8bitinput activation */
1289 break; // XTERM
1290
1291 case TY_CSI_PR('h', 1047):
1292 setMode(MODE_AppScreen);
1293 break; // XTERM
1294 case TY_CSI_PR('l', 1047):
1295 _alternateScreen->clearEntireScreen();
1296 resetMode(MODE_AppScreen);
1297 break; // XTERM
1298 case TY_CSI_PR('s', 1047):
1299 saveMode(MODE_AppScreen);
1300 break; // XTERM
1301 case TY_CSI_PR('r', 1047):
1302 restoreMode(MODE_AppScreen);
1303 break; // XTERM
1304
1305 // FIXME: Unitoken: save translations
1306 case TY_CSI_PR('h', 1048):
1307 saveCursor();
1308 break; // XTERM
1309 case TY_CSI_PR('l', 1048):
1310 restoreCursor();
1311 break; // XTERM
1312 case TY_CSI_PR('s', 1048):
1313 saveCursor();
1314 break; // XTERM
1315 case TY_CSI_PR('r', 1048):
1316 restoreCursor();
1317 break; // XTERM
1318
1319 // FIXME: every once new sequences like this pop up in xterm.
1320 // Here's a guess of what they could mean.
1321 case TY_CSI_PR('h', 1049):
1322 saveCursor();
1323 _alternateScreen->clearEntireScreen();
1324 setMode(MODE_AppScreen);
1325 break; // XTERM
1326 case TY_CSI_PR('l', 1049):
1327 resetMode(MODE_AppScreen);
1328 restoreCursor();
1329 break; // XTERM
1330
1331 case TY_CSI_PR('h', 2004):
1332 setMode(MODE_BracketedPaste);
1333 break; // XTERM
1334 case TY_CSI_PR('l', 2004):
1335 resetMode(MODE_BracketedPaste);
1336 break; // XTERM
1337 case TY_CSI_PR('s', 2004):
1338 saveMode(MODE_BracketedPaste);
1339 break; // XTERM
1340 case TY_CSI_PR('r', 2004):
1341 restoreMode(MODE_BracketedPaste);
1342 break; // XTERM
1343
1344 // FIXME: weird DEC reset sequence
1345 case TY_CSI_PE('p'): /* IGNORED: reset ( ) */
1346 break;
1347
1348 // FIXME: when changing between vt52 and ansi mode evtl do some resetting.
1349 case TY_VT52('A'):
1350 _currentScreen->cursorUp(1);
1351 break; // VT52
1352 case TY_VT52('B'):
1353 _currentScreen->cursorDown(1);
1354 break; // VT52
1355 case TY_VT52('C'):
1356 _currentScreen->cursorRight(1);
1357 break; // VT52
1358 case TY_VT52('D'):
1359 _currentScreen->cursorLeft(1);
1360 break; // VT52
1361
1362 case TY_VT52('F'):
1363 setAndUseCharset(0, '0');
1364 break; // VT52
1365 case TY_VT52('G'):
1366 setAndUseCharset(0, 'B');
1367 break; // VT52
1368
1369 case TY_VT52('H'):
1370 _currentScreen->setCursorYX(1, 1);
1371 break; // VT52
1372 case TY_VT52('I'):
1373 _currentScreen->reverseIndex();
1374 break; // VT52
1375 case TY_VT52('J'):
1376 _currentScreen->clearToEndOfScreen();
1377 break; // VT52
1378 case TY_VT52('K'):
1379 _currentScreen->clearToEndOfLine();
1380 break; // VT52
1381 case TY_VT52('Y'):
1382 _currentScreen->setCursorYX(p - 31, q - 31);
1383 break; // VT52
1384 case TY_VT52('Z'):
1385 reportTerminalType();
1386 break; // VT52
1387 case TY_VT52('<'):
1388 setMode(MODE_Ansi);
1389 break; // VT52
1390 case TY_VT52('='):
1391 setMode(MODE_AppKeyPad);
1392 break; // VT52
1393 case TY_VT52('>'):
1394 resetMode(MODE_AppKeyPad);
1395 break; // VT52
1396
1397 case TY_CSI_PG('c'):
1398 reportSecondaryAttributes();
1399 break; // VT100
1400
1401 default:
1402 reportDecodingError();
1403 break;
1404 };
1405}
1406
1407void Vt102Emulation::clearScreenAndSetColumns(int columnCount)
1408{
1409 setImageSize(_currentScreen->getLines(), columnCount);
1411 setDefaultMargins();
1412 _currentScreen->setCursorYX(0, 0);
1413}
1414
1415void Vt102Emulation::sendString(const char *s, int length)
1416{
1417 if (length >= 0)
1418 Q_EMIT sendData(s, length);
1419 else
1420 Q_EMIT sendData(s, strlen(s));
1421}
1422
1423void Vt102Emulation::reportCursorPosition()
1424{
1425 const size_t sz = 20;
1426 char tmp[sz];
1427 const size_t r = snprintf(tmp, sz, "\033[%d;%dR", _currentScreen->getCursorY() + 1, _currentScreen->getCursorX() + 1);
1428 if (sz <= r) {
1429 qWarning("Vt102Emulation::reportCursorPosition: Buffer too small\n");
1430 }
1431 sendString(tmp);
1432}
1433
1434void Vt102Emulation::reportTerminalType()
1435{
1436 // Primary device attribute response (Request was: ^[[0c or ^[[c (from TT321 Users Guide))
1437 // VT220: ^[[?63;1;2;3;6;7;8c (list deps on emul. capabilities)
1438 // VT100: ^[[?1;2c
1439 // VT101: ^[[?1;0c
1440 // VT102: ^[[?6v
1441 if (getMode(MODE_Ansi))
1442 sendString("\033[?1;2c"); // I'm a VT100
1443 else
1444 sendString("\033/Z"); // I'm a VT52
1445}
1446
1447void Vt102Emulation::reportSecondaryAttributes()
1448{
1449 // Seconday device attribute response (Request was: ^[[>0c or ^[[>c)
1450 if (getMode(MODE_Ansi))
1451 sendString("\033[>0;115;0c"); // Why 115? ;)
1452 else
1453 sendString("\033/Z"); // FIXME I don't think VT52 knows about it but kept for
1454 // konsoles backward compatibility.
1455}
1456
1457void Vt102Emulation::reportTerminalParms(int p)
1458// DECREPTPARM
1459{
1460 const size_t sz = 100;
1461 char tmp[sz];
1462 const size_t r = snprintf(tmp, sz, "\033[%d;1;1;112;112;1;0x", p); // not really true.
1463 if (sz <= r) {
1464 qWarning("Vt102Emulation::reportTerminalParms: Buffer too small\n");
1465 }
1466 sendString(tmp);
1467}
1468
1469void Vt102Emulation::reportStatus()
1470{
1471 sendString("\033[0n"); // VT100. Device status report. 0 = Ready.
1472}
1473
1474void Vt102Emulation::reportAnswerBack()
1475{
1476 // FIXME - Test this with VTTEST
1477 // This is really obsolete VT100 stuff.
1478 const char *ANSWER_BACK = "";
1479 sendString(ANSWER_BACK);
1480}
1481
1482/*!
1483 `cx',`cy' are 1-based.
1484 `cb' indicates the button pressed or released (0-2) or scroll event (4-5).
1485
1486 eventType represents the kind of mouse action that occurred:
1487 0 = Mouse button press
1488 1 = Mouse drag
1489 2 = Mouse button release
1490*/
1491
1492void Vt102Emulation::sendMouseEvent(int cb, int cx, int cy, int eventType)
1493{
1494 if (cx < 1 || cy < 1)
1495 return;
1496
1497 // With the exception of the 1006 mode, button release is encoded in cb.
1498 // Note that if multiple extensions are enabled, the 1006 is used, so it's okay to check for only that.
1499 if (eventType == 2 && !getMode(MODE_Mouse1006))
1500 cb = 3;
1501
1502 // normal buttons are passed as 0x20 + button,
1503 // mouse wheel (buttons 4,5) as 0x5c + button
1504 if (cb >= 4)
1505 cb += 0x3c;
1506
1507 // Mouse motion handling
1508 if ((getMode(MODE_Mouse1002) || getMode(MODE_Mouse1003)) && eventType == 1)
1509 cb += 0x20; // add 32 to signify motion event
1510
1511 char command[32];
1512 command[0] = '\0';
1513 // Check the extensions in decreasing order of preference. Encoding the release event above assumes that 1006 comes first.
1514 if (getMode(MODE_Mouse1006)) {
1515 snprintf(command, sizeof(command), "\033[<%d;%d;%d%c", cb, cx, cy, eventType == 2 ? 'm' : 'M');
1516 } else if (getMode(MODE_Mouse1015)) {
1517 snprintf(command, sizeof(command), "\033[%d;%d;%dM", cb + 0x20, cx, cy);
1518 } else if (getMode(MODE_Mouse1005)) {
1519 if (cx <= 2015 && cy <= 2015) {
1520 // The xterm extension uses UTF-8 (up to 2 bytes) to encode
1521 // coordinate+32, no matter what the locale is. We could easily
1522 // convert manually, but QString can also do it for us.
1523 QChar coords[2];
1524 coords[0] = QChar(cx + 0x20);
1525 coords[1] = QChar(cy + 0x20);
1526 QString coordsStr = QString(coords, 2);
1527 QByteArray utf8 = coordsStr.toUtf8();
1528 snprintf(command, sizeof(command), "\033[M%c%s", cb + 0x20, utf8.constData());
1529 }
1530 } else if (cx <= 223 && cy <= 223) {
1531 snprintf(command, sizeof(command), "\033[M%c%c%c", cb + 0x20, cx + 0x20, cy + 0x20);
1532 }
1533
1534 sendString(command);
1535}
1536
1537/**
1538 * The focus lost event can be used by Vim (or other terminal applications)
1539 * to recognize that the konsole window has lost focus.
1540 * The escape sequence is also used by iTerm2.
1541 * Vim needs the following plugin to be installed to convert the escape
1542 * sequence into the FocusLost autocmd: https://github.com/sjl/vitality.vim
1543 */
1545{
1546 if (_reportFocusEvents)
1547 sendString("\033[O");
1548}
1549
1550/**
1551 * The focus gained event can be used by Vim (or other terminal applications)
1552 * to recognize that the konsole window has gained focus again.
1553 * The escape sequence is also used by iTerm2.
1554 * Vim needs the following plugin to be installed to convert the escape
1555 * sequence into the FocusGained autocmd: https://github.com/sjl/vitality.vim
1556 */
1558{
1559 if (_reportFocusEvents)
1560 sendString("\033[I");
1561}
1562
1563void Vt102Emulation::sendText(const QString &text)
1564{
1565 if (!text.isEmpty()) {
1567 sendKeyEvent(&event, false); // expose as a big fat keypress event
1568 }
1569}
1570//<<<<<<< HEAD
1571
1572QKeyEvent *Vt102Emulation::remapKeyModifiersForMac(QKeyEvent *event)
1573{
1574 Qt::KeyboardModifiers modifiers = event->modifiers();
1575
1576 QFlags<Qt::KeyboardModifier> isTheLabeledKeyCommandPressed = modifiers & Qt::ControlModifier;
1577 QFlags<Qt::KeyboardModifier> isTheLabeledKeyControlPressed = modifiers & Qt::MetaModifier;
1578 if (isTheLabeledKeyCommandPressed) {
1579 qDebug("Command is pressed.");
1580 modifiers &= ~Qt::ControlModifier;
1581 modifiers |= Qt::MetaModifier;
1582 } else {
1583 modifiers &= ~Qt::MetaModifier;
1584 }
1585
1586 if (isTheLabeledKeyControlPressed) {
1587 qDebug("Control is pressed.");
1588 modifiers &= ~Qt::MetaModifier;
1589 modifiers |= Qt::ControlModifier;
1590 } else {
1591 modifiers &= ~Qt::ControlModifier;
1592 }
1593
1594 return new QKeyEvent(QEvent::None,
1595 event->key(),
1596 modifiers,
1597 event->nativeScanCode(),
1598 event->nativeVirtualKey(),
1599 event->nativeModifiers(),
1600 event->text(),
1601 event->isAutoRepeat(),
1602 event->count());
1603}
1604
1605void Vt102Emulation::sendKeyEvent(QKeyEvent *origEvent, bool fromPaste)
1606{
1607#if defined(Q_OS_MAC)
1608 QScopedPointer<QKeyEvent> event(remapKeyModifiersForMac(origEvent));
1609#else
1610 QKeyEvent *event = origEvent;
1611#endif
1612 Qt::KeyboardModifiers modifiers = event->modifiers();
1614
1615 // get current states
1616 if (getMode(MODE_NewLine))
1618 if (getMode(MODE_Ansi))
1620 if (getMode(MODE_AppCuKeys))
1622 if (getMode(MODE_AppScreen))
1624 if (getMode(MODE_AppKeyPad) && (modifiers & Qt::KeypadModifier))
1626
1627 // check flow control state
1628 if (modifiers & KeyboardTranslator::CTRL_MOD) {
1629 switch (event->key()) {
1630 case Qt::Key_S:
1632 break;
1633 case Qt::Key_Q:
1634 case Qt::Key_C: // cancel flow control
1636 break;
1637 }
1638 }
1639
1640 // lookup key binding
1641 if (_keyTranslator) {
1642 KeyboardTranslator::Entry entry = _keyTranslator->findEntry(event->key(), modifiers, states);
1643 // send result to terminal
1644 QByteArray textToSend;
1645
1646 // special handling for the Alt (aka. Meta) modifier. pressing
1647 // Alt+[Character] results in Esc+[Character] being sent
1648 // (unless there is an entry defined for this particular combination
1649 // in the keyboard modifier)
1650
1651 bool wantsAltModifier = entry.modifiers() & entry.modifierMask() & Qt::AltModifier;
1652 bool wantsMetaModifier = entry.modifiers() & entry.modifierMask() & Qt::MetaModifier;
1653 bool wantsAnyModifier = entry.state() & entry.stateMask() & KeyboardTranslator::AnyModifierState;
1654
1655 if (modifiers & Qt::AltModifier && !(wantsAltModifier || wantsAnyModifier) && !event->text().isEmpty()) {
1656 textToSend.prepend("\033");
1657 }
1658 if (modifiers & Qt::MetaModifier && !(wantsMetaModifier || wantsAnyModifier) && !event->text().isEmpty()) {
1659 textToSend.prepend("\030@s");
1660 }
1661
1662 if (entry.command() != KeyboardTranslator::NoCommand) {
1664 textToSend += eraseChar();
1665 } else {
1666 Q_EMIT handleCommandFromKeyboard(entry.command());
1667 }
1668
1669 // TODO command handling
1670 } else if (!entry.text().isEmpty()) {
1671 textToSend += entry.text(true, modifiers);
1672 } else if ((modifiers & KeyboardTranslator::CTRL_MOD) && event->key() >= 0x40 && event->key() < 0x5f) {
1673 textToSend += (event->key() & 0x1f);
1674 } else if (event->key() == Qt::Key_Tab) {
1675 textToSend += 0x09;
1676 } else if (event->key() == Qt::Key_PageUp) {
1677 textToSend += "\033[5~";
1678 } else if (event->key() == Qt::Key_PageDown) {
1679 textToSend += "\033[6~";
1680 } else {
1681 textToSend += _codec->fromUnicode(event->text());
1682 }
1683
1684 if (!fromPaste && textToSend.length()) {
1685 Q_EMIT outputFromKeypressEvent();
1686 }
1687 Q_EMIT sendData(textToSend.constData(), textToSend.length());
1688 } else {
1689 // print an error message to the terminal if no key translator has been
1690 // set
1691 QString translatorError =
1692 tr("No keyboard translator available. "
1693 "The information needed to convert key presses "
1694 "into characters to send to the terminal "
1695 "is missing.");
1696 reset();
1697 receiveData(translatorError.toUtf8().constData(), translatorError.size());
1698 }
1699}
1700
1701/* ------------------------------------------------------------------------- */
1702/* */
1703/* VT100 Charsets */
1704/* */
1705/* ------------------------------------------------------------------------- */
1706
1707// Character Set Conversion ------------------------------------------------ --
1708
1709/*
1710 The processing contains a VT100 specific code translation layer.
1711 It's still in use and mainly responsible for the line drawing graphics.
1712
1713 These and some other glyphs are assigned to codes (0x5f-0xfe)
1714 normally occupied by the latin letters. Since this codes also
1715 appear within control sequences, the extra code conversion
1716 does not permute with the tokenizer and is placed behind it
1717 in the pipeline. It only applies to tokens, which represent
1718 plain characters.
1719
1720 This conversion it eventually continued in TerminalDisplay.C, since
1721 it might involve VT100 enhanced fonts, which have these
1722 particular glyphs allocated in (0x00-0x1f) in their code page.
1723*/
1724
1725#define CHARSET _charset[_currentScreen == _alternateScreen.get()]
1726
1727// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i.
1728
1729constexpr std::array<unsigned short, 32> vt100_graphics = { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15
1730 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
1731 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7};
1732
1733// Apply current character map.
1734
1735wchar_t Vt102Emulation::applyCharset(char16_t c)
1736{
1737 if (CHARSET.graphic && 0x5f <= c && c <= 0x7e)
1738 return vt100_graphics[c - 0x5f];
1739 if (CHARSET.pound && c == '#')
1740 return 0xa3; // This mode is obsolete
1741 return c;
1742}
1743
1744/*
1745 "Charset" related part of the emulation state.
1746 This configures the VT100 charset filter.
1747
1748 While most operation work on the current _screen,
1749 the following two are different.
1750*/
1751
1752void Vt102Emulation::resetCharset(int scrno)
1753{
1754 _charset[scrno].cu_cs = 0;
1755 qstrncpy(_charset[scrno].charset, "BBBB", 4);
1756 _charset[scrno].sa_graphic = false;
1757 _charset[scrno].sa_pound = false;
1758 _charset[scrno].graphic = false;
1759 _charset[scrno].pound = false;
1760}
1761
1762void Vt102Emulation::setCharset(int n, int cs) // on both screens.
1763{
1764 _charset[0].charset[n & 3] = cs;
1765 useCharset(_charset[0].cu_cs);
1766 _charset[1].charset[n & 3] = cs;
1767 useCharset(_charset[1].cu_cs);
1768}
1769
1770void Vt102Emulation::setAndUseCharset(int n, int cs)
1771{
1772 CHARSET.charset[n & 3] = cs;
1773 useCharset(n & 3);
1774}
1775
1776void Vt102Emulation::useCharset(int n)
1777{
1778 CHARSET.cu_cs = n & 3;
1779 CHARSET.graphic = (CHARSET.charset[n & 3] == '0');
1780 CHARSET.pound = (CHARSET.charset[n & 3] == 'A'); // This mode is obsolete
1781}
1782
1783void Vt102Emulation::setDefaultMargins()
1784{
1785 _primaryScreen->setDefaultMargins();
1786 _alternateScreen->setDefaultMargins();
1787}
1788
1789void Vt102Emulation::setMargins(int t, int b)
1790{
1791 _primaryScreen->setMargins(t, b);
1792 _alternateScreen->setMargins(t, b);
1793}
1794
1795void Vt102Emulation::saveCursor()
1796{
1797 CHARSET.sa_graphic = CHARSET.graphic;
1798 CHARSET.sa_pound = CHARSET.pound; // This mode is obsolete
1799 // we are not clear about these
1800 // sa_charset = charsets[cScreen->_charset];
1801 // sa_charset_num = cScreen->_charset;
1802 _currentScreen->saveCursor();
1803}
1804
1805void Vt102Emulation::restoreCursor()
1806{
1807 CHARSET.graphic = CHARSET.sa_graphic;
1808 CHARSET.pound = CHARSET.sa_pound; // This mode is obsolete
1809 _currentScreen->restoreCursor();
1810}
1811
1812/* ------------------------------------------------------------------------- */
1813/* */
1814/* Mode Operations */
1815/* */
1816/* ------------------------------------------------------------------------- */
1817
1818/*
1819 Some of the emulations state is either added to the state of the screens.
1820
1821 This causes some scoping problems, since different emulations choose to
1822 located the mode either to the current _screen or to both.
1823
1824 For strange reasons, the extend of the rendition attributes ranges over
1825 all screens and not over the actual _screen.
1826
1827 We decided on the precise precise extend, somehow.
1828*/
1829
1830// "Mode" related part of the state. These are all booleans.
1831
1832void Vt102Emulation::resetModes()
1833{
1834 // MODE_Allow132Columns is not reset here
1835 // to match Xterm's behaviour (see Xterm's VTReset() function)
1836
1837 resetMode(MODE_132Columns);
1838 saveMode(MODE_132Columns);
1839 resetMode(MODE_Mouse1000);
1840 saveMode(MODE_Mouse1000);
1841 resetMode(MODE_Mouse1001);
1842 saveMode(MODE_Mouse1001);
1843 resetMode(MODE_Mouse1002);
1844 saveMode(MODE_Mouse1002);
1845 resetMode(MODE_Mouse1003);
1846 saveMode(MODE_Mouse1003);
1847 resetMode(MODE_Mouse1005);
1848 saveMode(MODE_Mouse1005);
1849 resetMode(MODE_Mouse1006);
1850 saveMode(MODE_Mouse1006);
1851 resetMode(MODE_Mouse1015);
1852 saveMode(MODE_Mouse1015);
1853 resetMode(MODE_BracketedPaste);
1854 saveMode(MODE_BracketedPaste);
1855
1856 resetMode(MODE_AppScreen);
1857 saveMode(MODE_AppScreen);
1858 resetMode(MODE_AppCuKeys);
1859 saveMode(MODE_AppCuKeys);
1860 resetMode(MODE_AppKeyPad);
1861 saveMode(MODE_AppKeyPad);
1862 resetMode(MODE_NewLine);
1863 setMode(MODE_Ansi);
1864}
1865
1866void Vt102Emulation::setMode(int m)
1867{
1868 _currentModes.mode[m] = true;
1869 switch (m) {
1870 case MODE_132Columns:
1871 if (getMode(MODE_Allow132Columns))
1872 clearScreenAndSetColumns(132);
1873 else
1874 _currentModes.mode[m] = false;
1875 break;
1876 case MODE_Mouse1000:
1877 case MODE_Mouse1001:
1878 case MODE_Mouse1002:
1879 case MODE_Mouse1003:
1881 break;
1882
1883 case MODE_BracketedPaste:
1884 Q_EMIT programBracketedPasteModeChanged(true);
1885
1886 break;
1887
1888 case MODE_AppScreen:
1889 _alternateScreen->clearSelection();
1890 setScreen(1);
1891 break;
1892 }
1893 if (m < MODES_SCREEN || m == MODE_NewLine) {
1894 _primaryScreen->setMode(m);
1895 _alternateScreen->setMode(m);
1896 }
1897}
1898
1899void Vt102Emulation::resetMode(int m)
1900{
1901 _currentModes.mode[m] = false;
1902 switch (m) {
1903 case MODE_132Columns:
1904 if (getMode(MODE_Allow132Columns))
1905 clearScreenAndSetColumns(80);
1906 break;
1907 case MODE_Mouse1000:
1908 case MODE_Mouse1001:
1909 case MODE_Mouse1002:
1910 case MODE_Mouse1003:
1912 break;
1913
1914 case MODE_BracketedPaste:
1915 Q_EMIT programBracketedPasteModeChanged(false);
1916 break;
1917
1918 case MODE_AppScreen:
1919 _primaryScreen->clearSelection();
1920 setScreen(0);
1921 break;
1922 }
1923 if (m < MODES_SCREEN || m == MODE_NewLine) {
1924 _primaryScreen->resetMode(m);
1925 _alternateScreen->resetMode(m);
1926 }
1927}
1928
1929void Vt102Emulation::saveMode(int m)
1930{
1931 _savedModes.mode[m] = _currentModes.mode[m];
1932}
1933
1934void Vt102Emulation::restoreMode(int m)
1935{
1936 if (_savedModes.mode[m])
1937 setMode(m);
1938 else
1939 resetMode(m);
1940}
1941
1942bool Vt102Emulation::getMode(int m)
1943{
1944 return _currentModes.mode[m];
1945}
1946
1948{
1950 if (entry.text().size() > 0)
1951 return entry.text().at(0);
1952 else
1953 return '\b';
1954}
1955
1956void Vt102Emulation::reportDecodingError()
1957{
1958 if (tokenBufferPos == 0 || (tokenBufferPos == 1 && (tokenBuffer[0] & 0xff) >= 32))
1959 return;
1960 qDebug() << "Undecodable sequence:" << QString::fromUtf16(tokenBuffer, tokenBufferPos);
1961}
1962
1963// #include "Vt102Emulation.moc"
Base class for terminal emulation back-ends.
Definition Emulation.h:120
void programUsesMouseChanged(bool usesMouse)
This is emitted when the program running in the shell indicates whether or not it is interested in mo...
void imageResizeRequest(const QSize &sizz)
Emitted after receiving the escape sequence which asks to change the terminal emulator's size.
void receiveData(const char *buffer, int len)
Processes an incoming stream of characters.
@ UnderlineCursor
A single flat line which occupies the space at the bottom of the cursor character's area.
@ BlockCursor
A rectangular block which covers the entire area of the cursor character.
@ IBeamCursor
An cursor shaped like the capital letter 'I', similar to the IBeam cursor used in Qt/KDE text editors...
void bufferedUpdate()
Schedules an update of attached views.
void changeTabTextColorRequest(int color)
Requests that the color of the text used to represent the tabs associated with this emulation be chan...
void stateSet(int state)
Emitted when the activity state of the emulation is set.
void flowControlKeyPressed(bool suspendKeyPressed)
Emitted when a flow control key combination ( Ctrl+S or Ctrl+Q ) is pressed.
virtual void setImageSize(int lines, int columns)
Change the size of the emulation's image.
void setScreen(int index)
Sets the active screen.
void titleChanged(int title, const QString &newTitle)
Emitted when the program running in the terminal wishes to update the session's title.
void clearHistory()
Clears the history scroll.
bool utf8() const
Convenience method.
Definition Emulation.h:212
void cursorChanged(KeyboardCursorShape cursorShape, bool blinkingCursorEnabled)
Emitted when the cursor shape or its blinking state is changed via DECSCUSR sequences.
void sendData(const char *data, int len)
Emitted when a buffer of data is ready to send to the standard input of the terminal.
void setCodec(const QTextCodec *)
Sets the codec used to decode incoming characters.
Represents an association between a key sequence pressed by the user and the character sequence and c...
Command command() const
Returns the commands associated with this entry.
Qt::KeyboardModifiers modifierMask() const
Returns the keyboard modifiers which are valid in this entry.
States state() const
Returns a bitwise-OR of the enabled state flags associated with this entry.
States stateMask() const
Returns the state flags which are valid in this entry.
Qt::KeyboardModifiers modifiers() const
Returns a bitwise-OR of the enabled keyboard modifiers associated with this entry.
QByteArray text(bool expandWildCards=false, Qt::KeyboardModifiers modifiers=Qt::NoModifier) const
Returns the character sequence associated with this entry, optionally replacing wildcard '*' characte...
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...
static const Qt::KeyboardModifier CTRL_MOD
The modifier code for the actual Ctrl key on this OS.
@ AnsiState
Indicates that the terminal is in 'Ansi' mode.
@ NoState
Indicates that no special state is active.
@ AlternateScreenState
Indicates that the alternate screen ( typically used by interactive programs such as screen or vim ) ...
@ AnyModifierState
Indicates that any of the modifier keys is active.
@ NewLineState
TODO More documentation.
@ CursorKeysState
TODO More documentation.
@ ApplicationKeypadState
Indicates that the numpad is in application mode.
@ NoCommand
Indicates that no command is associated with this command sequence.
@ EraseCommand
Echos the operating system specific erase character.
void setCursorYX(int y, int x)
Position the cursor at line y, column x.
Definition Screen.cpp:790
int getCursorY() const
Returns the line which the cursor is positioned on.
Definition Screen.cpp:828
void clearEntireScreen()
Clear the whole screen, moving the current screen contents into the history first.
Definition Screen.cpp:947
void saveCursor()
Saves the current position and appearance (text color and style) of the cursor.
Definition Screen.cpp:305
int getCursorX() const
Returns the column which the cursor is positioned at.
Definition Screen.cpp:823
int getLines() const
Return the number of lines.
Definition Screen.h:385
void setLineProperty(LineProperty property, bool enable)
Sets or clears an attribute of the current line.
Definition Screen.cpp:1322
void resetRendition(int rendition)
Disables the given rendition flag.
Definition Screen.cpp:988
void restoreCursor()
Restores the position and appearance of the cursor.
Definition Screen.cpp:314
void clearEntireScreen() override
Copies the current image into the history and clears the screen.
void reset() override
Resets the state of the terminal.
virtual void focusLost()
The focus lost event can be used by Vim (or other terminal applications) to recognize that the konsol...
void receiveChar(QChar cc) override
Processes an incoming character.
char eraseChar() const override
TODO Document me.
Vt102Emulation()
Constructs a new emulation.
virtual void focusGained()
The focus gained event can be used by Vim (or other terminal applications) to recognize that the kons...
void sendMouseEvent(int buttons, int column, int line, int eventType) override
char at(qsizetype i) const const
const char * constData() const const
bool isEmpty() const const
qsizetype length() const const
QByteArray & prepend(QByteArrayView ba)
qsizetype size() const const
char16_t & unicode()
void clear()
QList< Key > keys() const const
Qt::KeyboardModifiers modifiers() const const
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
virtual bool event(QEvent *e)
QString tr(const char *sourceText, const char *disambiguation, int n)
QString fromUtf16(const char16_t *unicode, qsizetype size)
bool isEmpty() const const
qsizetype size() const const
QByteArray toUtf8() const const
NoModifier
void setSingleShot(bool singleShot)
void start()
void timeout()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:55:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.