-rw-r--r-- | core/apps/embeddedkonsole/TEmuVt102.cpp | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/core/apps/embeddedkonsole/TEmuVt102.cpp b/core/apps/embeddedkonsole/TEmuVt102.cpp index 752c49f..275c18d 100644 --- a/core/apps/embeddedkonsole/TEmuVt102.cpp +++ b/core/apps/embeddedkonsole/TEmuVt102.cpp | |||
@@ -1,80 +1,80 @@ | |||
1 | /* ------------------------------------------------------------------------- */ | 1 | /* ------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [TEmuVt102.C] VT102 Terminal Emulation */ | 3 | /* [TEmuVt102.C] VT102 Terminal Emulation */ |
4 | /* */ | 4 | /* */ |
5 | /* ------------------------------------------------------------------------- */ | 5 | /* ------------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole - an X terminal for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* */ | 10 | /* */ |
11 | /* ------------------------------------------------------------------------- */ | 11 | /* ------------------------------------------------------------------------- */ |
12 | /* */ | 12 | /* */ |
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Konsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | 18 | ||
19 | /*! \class TEmuVt102 | 19 | /*! \class TEmuVt102 |
20 | 20 | ||
21 | \brief Actual Emulation for Konsole | 21 | \brief Actual Emulation for Konsole |
22 | 22 | ||
23 | \sa TEWidget \sa TEScreen | 23 | \sa TEWidget \sa TEScreen |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "TEmuVt102.h" | 26 | #include "TEmuVt102.h" |
27 | #include "TEWidget.h" | 27 | #include "TEWidget.h" |
28 | #include "TEScreen.h" | 28 | #include "TEScreen.h" |
29 | #include "keytrans.h" | 29 | #include "keytrans.h" |
30 | 30 | ||
31 | #include <stdio.h> | 31 | #include <stdio.h> |
32 | #include <unistd.h> | 32 | #include <unistd.h> |
33 | #include <qkeycode.h> | 33 | #include <qkeycode.h> |
34 | #include <qtextcodec.h> | 34 | #include <qtextcodec.h> |
35 | 35 | ||
36 | 36 | ||
37 | /* VT102 Terminal Emulation | 37 | /* VT102 Terminal Emulation |
38 | 38 | ||
39 | This class puts together the screens, the pty and the widget to a | 39 | This class puts together the screens, the pty and the widget to a |
40 | complete terminal emulation. Beside combining it's componentes, it | 40 | complete terminal emulation. Beside combining it's componentes, it |
41 | handles the emulations's protocol. | 41 | handles the emulations's protocol. |
42 | 42 | ||
43 | This module consists of the following sections: | 43 | This module consists of the following sections: |
44 | 44 | ||
45 | - Constructor/Destructor | 45 | - Constructor/Destructor |
46 | - Incoming Bytes Event pipeline | 46 | - Incoming Bytes Event pipeline |
47 | - Outgoing Bytes | 47 | - Outgoing Bytes |
48 | - Mouse Events | 48 | - Mouse Events |
49 | - Keyboard Events | 49 | - Keyboard Events |
50 | - Modes and Charset State | 50 | - Modes and Charset State |
51 | - Diagnostics | 51 | - Diagnostics |
52 | */ | 52 | */ |
53 | 53 | ||
54 | 54 | ||
55 | /* ------------------------------------------------------------------------- */ | 55 | /* ------------------------------------------------------------------------- */ |
56 | /* */ | 56 | /* */ |
57 | /* Constructor / Destructor */ | 57 | /* Constructor / Destructor */ |
58 | /* */ | 58 | /* */ |
59 | /* ------------------------------------------------------------------------- */ | 59 | /* ------------------------------------------------------------------------- */ |
60 | 60 | ||
61 | /* | 61 | /* |
62 | Nothing really intesting happens here. | 62 | Nothing really intesting happens here. |
63 | */ | 63 | */ |
64 | 64 | ||
65 | /*! | 65 | /*! |
66 | */ | 66 | */ |
67 | 67 | ||
68 | TEmuVt102::TEmuVt102(TEWidget* gui) : TEmulation(gui) | 68 | TEmuVt102::TEmuVt102(TEWidget* gui) : TEmulation(gui) |
69 | { | 69 | { |
70 | QObject::connect(gui,SIGNAL(mouseSignal(int,int,int)), | 70 | QObject::connect(gui,SIGNAL(mouseSignal(int,int,int)), |
71 | this,SLOT(onMouse(int,int,int))); | 71 | this,SLOT(onMouse(int,int,int))); |
72 | initTokenizer(); | 72 | initTokenizer(); |
73 | reset(); | 73 | reset(); |
74 | } | 74 | } |
75 | 75 | ||
76 | /*! | 76 | /*! |
77 | */ | 77 | */ |
78 | 78 | ||
79 | TEmuVt102::~TEmuVt102() | 79 | TEmuVt102::~TEmuVt102() |
80 | { | 80 | { |
@@ -682,130 +682,159 @@ void TEmuVt102::reportAnswerBack() | |||
682 | Mouse clicks are possibly reported to the client | 682 | Mouse clicks are possibly reported to the client |
683 | application if it has issued interest in them. | 683 | application if it has issued interest in them. |
684 | They are normally consumed by the widget for copy | 684 | They are normally consumed by the widget for copy |
685 | and paste, but may be propagated from the widget | 685 | and paste, but may be propagated from the widget |
686 | when gui->setMouseMarks is set via setMode(MODE_Mouse1000). | 686 | when gui->setMouseMarks is set via setMode(MODE_Mouse1000). |
687 | 687 | ||
688 | `x',`y' are 1-based. | 688 | `x',`y' are 1-based. |
689 | `ev' (event) indicates the button pressed (0-2) | 689 | `ev' (event) indicates the button pressed (0-2) |
690 | or a general mouse release (3). | 690 | or a general mouse release (3). |
691 | */ | 691 | */ |
692 | 692 | ||
693 | void TEmuVt102::onMouse( int cb, int cx, int cy ) | 693 | void TEmuVt102::onMouse( int cb, int cx, int cy ) |
694 | { char tmp[20]; | 694 | { char tmp[20]; |
695 | if (!connected) return; | 695 | if (!connected) return; |
696 | sprintf(tmp,"\033[M%c%c%c",cb+040,cx+040,cy+040); | 696 | sprintf(tmp,"\033[M%c%c%c",cb+040,cx+040,cy+040); |
697 | sendString(tmp); | 697 | sendString(tmp); |
698 | } | 698 | } |
699 | 699 | ||
700 | // Keyboard Handling ------------------------------------------------------- -- | 700 | // Keyboard Handling ------------------------------------------------------- -- |
701 | 701 | ||
702 | #define encodeMode(M,B) BITS(B,getMode(M)) | 702 | #define encodeMode(M,B) BITS(B,getMode(M)) |
703 | #define encodeStat(M,B) BITS(B,((ev->state() & (M)) == (M))) | 703 | #define encodeStat(M,B) BITS(B,((ev->state() & (M)) == (M))) |
704 | 704 | ||
705 | /* | 705 | /* |
706 | Keyboard event handling has been simplified somewhat by pushing | 706 | Keyboard event handling has been simplified somewhat by pushing |
707 | the complications towards a configuration file [see KeyTrans class]. | 707 | the complications towards a configuration file [see KeyTrans class]. |
708 | */ | 708 | */ |
709 | 709 | ||
710 | void TEmuVt102::onKeyPress( QKeyEvent* ev ) | 710 | void TEmuVt102::onKeyPress( QKeyEvent* ev ) |
711 | { | 711 | { |
712 | if (!connected) return; // someone else gets the keys | 712 | if (!connected) return; // someone else gets the keys |
713 | 713 | ||
714 | //printf("State/Key: 0x%04x 0x%04x (%d,%d)\n",ev->state(),ev->key(),ev->text().length(),ev->text().length()?ev->text().ascii()[0]:0); | 714 | //printf("State/Key: 0x%04x 0x%04x (%d,%d)\n",ev->state(),ev->key(),ev->text().length(),ev->text().length()?ev->text().ascii()[0]:0); |
715 | 715 | ||
716 | // revert to non-history when typing | 716 | // revert to non-history when typing |
717 | if (scr->getHistCursor() != scr->getHistLines()); | 717 | if (scr->getHistCursor() != scr->getHistLines()); |
718 | scr->setHistCursor(scr->getHistLines()); | 718 | scr->setHistCursor(scr->getHistLines()); |
719 | 719 | ||
720 | // lookup in keyboard translation table ... | 720 | // lookup in keyboard translation table ... |
721 | int cmd; const char* txt; int len; | 721 | int cmd; const char* txt; int len; |
722 | if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine , BITS_NewLine ) + // OLD, | 722 | if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine , BITS_NewLine ) + // OLD, |
723 | encodeMode(MODE_Ansi , BITS_Ansi ) + // OBSOLETE, | 723 | encodeMode(MODE_Ansi , BITS_Ansi ) + // OBSOLETE, |
724 | encodeMode(MODE_AppCuKeys, BITS_AppCuKeys ) + // VT100 stuff | 724 | encodeMode(MODE_AppCuKeys, BITS_AppCuKeys ) + // VT100 stuff |
725 | encodeStat(ControlButton , BITS_Control ) + | 725 | encodeStat(ControlButton , BITS_Control ) + |
726 | encodeStat(ShiftButton , BITS_Shift ) + | 726 | encodeStat(ShiftButton , BITS_Shift ) + |
727 | encodeStat(AltButton , BITS_Alt ), | 727 | encodeStat(AltButton , BITS_Alt ), |
728 | &cmd, &txt, &len )) | 728 | &cmd, &txt, &len )) |
729 | //printf("cmd: %d, %s, %d\n",cmd,txt,len); | 729 | //printf("cmd: %d, %s, %d\n",cmd,txt,len); |
730 | switch(cmd) // ... and execute if found. | 730 | switch(cmd) // ... and execute if found. |
731 | { | 731 | { |
732 | case CMD_emitSelection : gui->emitSelection(); return; | 732 | case CMD_emitSelection : gui->emitSelection(); return; |
733 | case CMD_scrollPageUp : gui->doScroll(-gui->Lines()/2); return; | 733 | case CMD_scrollPageUp : gui->doScroll(-gui->Lines()/2); return; |
734 | case CMD_scrollPageDown : gui->doScroll(+gui->Lines()/2); return; | 734 | case CMD_scrollPageDown : gui->doScroll(+gui->Lines()/2); return; |
735 | case CMD_scrollLineUp : gui->doScroll(-1 ); return; | 735 | case CMD_scrollLineUp : gui->doScroll(-1 ); return; |
736 | case CMD_scrollLineDown : gui->doScroll(+1 ); return; | 736 | case CMD_scrollLineDown : gui->doScroll(+1 ); return; |
737 | case CMD_send : emit sndBlock(txt,len); return; | 737 | case CMD_send : emit sndBlock(txt,len); return; |
738 | case CMD_prevSession : emit prevSession(); return; | 738 | case CMD_prevSession : emit prevSession(); return; |
739 | case CMD_nextSession : emit nextSession(); return; | 739 | case CMD_nextSession : emit nextSession(); return; |
740 | } | 740 | } |
741 | 741 | ||
742 | // fall back handling | 742 | // fall back handling |
743 | if (!ev->text().isEmpty()) | 743 | if (!ev->text().isEmpty()) |
744 | { | 744 | { |
745 | if (ev->state() & AltButton) sendString("\033"); // ESC, this is the ALT prefix | 745 | if (ev->state() & AltButton) sendString("\033"); // ESC, this is the ALT prefix |
746 | QCString s = codec->fromUnicode(ev->text()); // encode for application | 746 | /// very hacky |
747 | emit sndBlock(s.data(),s.length()); // we may well have s.length() > 1 | 747 | if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='A')) sendString("\01"); |
748 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='B')) sendString("\02"); | ||
749 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='C')) sendString("\03"); | ||
750 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='D')) sendString("\04"); | ||
751 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='E')) sendString("\05"); | ||
752 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='F')) sendString("\06"); | ||
753 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='G')) sendString("\07"); | ||
754 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='H')) sendString("\010"); | ||
755 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='I')) sendString("\011"); | ||
756 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='J')) sendString("\012"); | ||
757 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='K')) sendString("\013"); | ||
758 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='L')) sendString("\014"); | ||
759 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='M')) sendString("\015"); | ||
760 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='N')) sendString("\016"); | ||
761 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='O')) sendString("\017"); | ||
762 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='P')) sendString("\020"); | ||
763 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Q')) sendString("\021"); | ||
764 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='R')) sendString("\022"); | ||
765 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='S')) sendString("\023"); | ||
766 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='T')) sendString("\024"); | ||
767 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='U')) sendString("\025"); | ||
768 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='V')) sendString("\026"); | ||
769 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='W')) sendString("\027"); | ||
770 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='X')) sendString("\030"); | ||
771 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Y')) sendString("\031"); | ||
772 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Z')) sendString("\032"); | ||
773 | else { | ||
774 | QCString s = codec->fromUnicode(ev->text()); // encode for application | ||
775 | emit sndBlock(s.data(),s.length()); // we may well have s.length() > 1 | ||
776 | } | ||
748 | return; | 777 | return; |
749 | } | 778 | } |
750 | } | 779 | } |
751 | 780 | ||
752 | /* ------------------------------------------------------------------------- */ | 781 | /* ------------------------------------------------------------------------- */ |
753 | /* */ | 782 | /* */ |
754 | /* VT100 Charsets */ | 783 | /* VT100 Charsets */ |
755 | /* */ | 784 | /* */ |
756 | /* ------------------------------------------------------------------------- */ | 785 | /* ------------------------------------------------------------------------- */ |
757 | 786 | ||
758 | // Character Set Conversion ------------------------------------------------ -- | 787 | // Character Set Conversion ------------------------------------------------ -- |
759 | 788 | ||
760 | /* | 789 | /* |
761 | The processing contains a VT100 specific code translation layer. | 790 | The processing contains a VT100 specific code translation layer. |
762 | It's still in use and mainly responsible for the line drawing graphics. | 791 | It's still in use and mainly responsible for the line drawing graphics. |
763 | 792 | ||
764 | These and some other glyphs are assigned to codes (0x5f-0xfe) | 793 | These and some other glyphs are assigned to codes (0x5f-0xfe) |
765 | normally occupied by the latin letters. Since this codes also | 794 | normally occupied by the latin letters. Since this codes also |
766 | appear within control sequences, the extra code conversion | 795 | appear within control sequences, the extra code conversion |
767 | does not permute with the tokenizer and is placed behind it | 796 | does not permute with the tokenizer and is placed behind it |
768 | in the pipeline. It only applies to tokens, which represent | 797 | in the pipeline. It only applies to tokens, which represent |
769 | plain characters. | 798 | plain characters. |
770 | 799 | ||
771 | This conversion it eventually continued in TEWidget.C, since | 800 | This conversion it eventually continued in TEWidget.C, since |
772 | it might involve VT100 enhanced fonts, which have these | 801 | it might involve VT100 enhanced fonts, which have these |
773 | particular glyphs allocated in (0x00-0x1f) in their code page. | 802 | particular glyphs allocated in (0x00-0x1f) in their code page. |
774 | */ | 803 | */ |
775 | 804 | ||
776 | #define CHARSET charset[scr==screen[1]] | 805 | #define CHARSET charset[scr==screen[1]] |
777 | 806 | ||
778 | // Apply current character map. | 807 | // Apply current character map. |
779 | 808 | ||
780 | unsigned short TEmuVt102::applyCharset(unsigned short c) | 809 | unsigned short TEmuVt102::applyCharset(unsigned short c) |
781 | { | 810 | { |
782 | if (CHARSET.graphic && 0x5f <= c && c <= 0x7e) return vt100_graphics[c-0x5f]; | 811 | if (CHARSET.graphic && 0x5f <= c && c <= 0x7e) return vt100_graphics[c-0x5f]; |
783 | if (CHARSET.pound && c == '#' ) return 0xa3; //This mode is obsolete | 812 | if (CHARSET.pound && c == '#' ) return 0xa3; //This mode is obsolete |
784 | return c; | 813 | return c; |
785 | } | 814 | } |
786 | 815 | ||
787 | /* | 816 | /* |
788 | "Charset" related part of the emulation state. | 817 | "Charset" related part of the emulation state. |
789 | This configures the VT100 charset filter. | 818 | This configures the VT100 charset filter. |
790 | 819 | ||
791 | While most operation work on the current screen, | 820 | While most operation work on the current screen, |
792 | the following two are different. | 821 | the following two are different. |
793 | */ | 822 | */ |
794 | 823 | ||
795 | void TEmuVt102::resetCharset(int scrno) | 824 | void TEmuVt102::resetCharset(int scrno) |
796 | { | 825 | { |
797 | charset[scrno].cu_cs = 0; | 826 | charset[scrno].cu_cs = 0; |
798 | strncpy(charset[scrno].charset,"BBBB",4); | 827 | strncpy(charset[scrno].charset,"BBBB",4); |
799 | charset[scrno].sa_graphic = FALSE; | 828 | charset[scrno].sa_graphic = FALSE; |
800 | charset[scrno].sa_pound = FALSE; | 829 | charset[scrno].sa_pound = FALSE; |
801 | charset[scrno].graphic = FALSE; | 830 | charset[scrno].graphic = FALSE; |
802 | charset[scrno].pound = FALSE; | 831 | charset[scrno].pound = FALSE; |
803 | } | 832 | } |
804 | 833 | ||
805 | /*! | 834 | /*! |
806 | */ | 835 | */ |
807 | 836 | ||
808 | void TEmuVt102::setCharset(int n, int cs) // on both screens. | 837 | void TEmuVt102::setCharset(int n, int cs) // on both screens. |
809 | { | 838 | { |
810 | charset[0].charset[n&3] = cs; useCharset(charset[0].cu_cs); | 839 | charset[0].charset[n&3] = cs; useCharset(charset[0].cu_cs); |
811 | charset[1].charset[n&3] = cs; useCharset(charset[1].cu_cs); | 840 | charset[1].charset[n&3] = cs; useCharset(charset[1].cu_cs); |
@@ -830,129 +859,129 @@ void TEmuVt102::useCharset(int n) | |||
830 | CHARSET.pound = (CHARSET.charset[n&3] == 'A'); //This mode is obsolete | 859 | CHARSET.pound = (CHARSET.charset[n&3] == 'A'); //This mode is obsolete |
831 | } | 860 | } |
832 | 861 | ||
833 | /*! Save the cursor position and the rendition attribute settings. */ | 862 | /*! Save the cursor position and the rendition attribute settings. */ |
834 | 863 | ||
835 | void TEmuVt102::saveCursor() | 864 | void TEmuVt102::saveCursor() |
836 | { | 865 | { |
837 | CHARSET.sa_graphic = CHARSET.graphic; | 866 | CHARSET.sa_graphic = CHARSET.graphic; |
838 | CHARSET.sa_pound = CHARSET.pound; //This mode is obsolete | 867 | CHARSET.sa_pound = CHARSET.pound; //This mode is obsolete |
839 | // we are not clear about these | 868 | // we are not clear about these |
840 | //sa_charset = charsets[cScreen->charset]; | 869 | //sa_charset = charsets[cScreen->charset]; |
841 | //sa_charset_num = cScreen->charset; | 870 | //sa_charset_num = cScreen->charset; |
842 | scr->saveCursor(); | 871 | scr->saveCursor(); |
843 | } | 872 | } |
844 | 873 | ||
845 | /*! Restore the cursor position and the rendition attribute settings. */ | 874 | /*! Restore the cursor position and the rendition attribute settings. */ |
846 | 875 | ||
847 | void TEmuVt102::restoreCursor() | 876 | void TEmuVt102::restoreCursor() |
848 | { | 877 | { |
849 | CHARSET.graphic = CHARSET.sa_graphic; | 878 | CHARSET.graphic = CHARSET.sa_graphic; |
850 | CHARSET.pound = CHARSET.sa_pound; //This mode is obsolete | 879 | CHARSET.pound = CHARSET.sa_pound; //This mode is obsolete |
851 | scr->restoreCursor(); | 880 | scr->restoreCursor(); |
852 | } | 881 | } |
853 | 882 | ||
854 | /* ------------------------------------------------------------------------- */ | 883 | /* ------------------------------------------------------------------------- */ |
855 | /* */ | 884 | /* */ |
856 | /* Mode Operations */ | 885 | /* Mode Operations */ |
857 | /* */ | 886 | /* */ |
858 | /* ------------------------------------------------------------------------- */ | 887 | /* ------------------------------------------------------------------------- */ |
859 | 888 | ||
860 | /* | 889 | /* |
861 | Some of the emulations state is either added to the state of the screens. | 890 | Some of the emulations state is either added to the state of the screens. |
862 | 891 | ||
863 | This causes some scoping problems, since different emulations choose to | 892 | This causes some scoping problems, since different emulations choose to |
864 | located the mode either to the current screen or to both. | 893 | located the mode either to the current screen or to both. |
865 | 894 | ||
866 | For strange reasons, the extend of the rendition attributes ranges over | 895 | For strange reasons, the extend of the rendition attributes ranges over |
867 | all screens and not over the actual screen. | 896 | all screens and not over the actual screen. |
868 | 897 | ||
869 | We decided on the precise precise extend, somehow. | 898 | We decided on the precise precise extend, somehow. |
870 | */ | 899 | */ |
871 | 900 | ||
872 | // "Mode" related part of the state. These are all booleans. | 901 | // "Mode" related part of the state. These are all booleans. |
873 | 902 | ||
874 | void TEmuVt102::resetModes() | 903 | void TEmuVt102::resetModes() |
875 | { | 904 | { |
876 | resetMode(MODE_Mouse1000); saveMode(MODE_Mouse1000); | 905 | resetMode(MODE_Mouse1000); saveMode(MODE_Mouse1000); |
877 | resetMode(MODE_AppScreen); saveMode(MODE_AppScreen); | 906 | resetMode(MODE_AppScreen); saveMode(MODE_AppScreen); |
878 | // here come obsolete modes | 907 | // here come obsolete modes |
879 | resetMode(MODE_AppCuKeys); saveMode(MODE_AppCuKeys); | 908 | resetMode(MODE_AppCuKeys); saveMode(MODE_AppCuKeys); |
880 | resetMode(MODE_NewLine ); | 909 | resetMode(MODE_NewLine ); |
881 | setMode(MODE_Ansi ); | 910 | setMode(MODE_Ansi ); |
882 | } | 911 | } |
883 | 912 | ||
884 | void TEmuVt102::setMode(int m) | 913 | void TEmuVt102::setMode(int m) |
885 | { | 914 | { |
886 | currParm.mode[m] = TRUE; | 915 | currParm.mode[m] = TRUE; |
887 | switch (m) | 916 | switch (m) |
888 | { | 917 | { |
889 | case MODE_Mouse1000 : gui->setMouseMarks(FALSE); | 918 | case MODE_Mouse1000 : gui->setMouseMarks(FALSE); |
890 | break; | 919 | break; |
891 | case MODE_AppScreen : screen[1]->clearSelection(); | 920 | case MODE_AppScreen : screen[1]->clearSelection(); |
892 | screen[1]->clearEntireScreen(); | 921 | screen[1]->clearEntireScreen(); |
893 | setScreen(1); | 922 | setScreen(1); |
894 | break; | 923 | break; |
895 | } | 924 | } |
896 | if (m < MODES_SCREEN || m == MODE_NewLine) | 925 | if (m < MODES_SCREEN || m == MODE_NewLine) |
897 | { | 926 | { |
898 | screen[0]->setMode(m); | 927 | screen[0]->setMode(m); |
899 | screen[1]->setMode(m); | 928 | screen[1]->setMode(m); |
900 | } | 929 | } |
901 | } | 930 | } |
902 | 931 | ||
903 | void TEmuVt102::resetMode(int m) | 932 | void TEmuVt102::resetMode(int m) |
904 | { | 933 | { |
905 | currParm.mode[m] = FALSE; | 934 | currParm.mode[m] = FALSE; |
906 | switch (m) | 935 | switch (m) |
907 | { | 936 | { |
908 | case MODE_Mouse1000 : gui->setMouseMarks(TRUE); | 937 | case MODE_Mouse1000 : gui->setMouseMarks(TRUE); |
909 | break; | 938 | break; |
910 | case MODE_AppScreen : screen[0]->clearSelection(); | 939 | case MODE_AppScreen : screen[0]->clearSelection(); |
911 | setScreen(0); | 940 | setScreen(0); |
912 | break; | 941 | break; |
913 | } | 942 | } |
914 | if (m < MODES_SCREEN || m == MODE_NewLine) | 943 | if (m < MODES_SCREEN || m == MODE_NewLine) |
915 | { | 944 | { |
916 | screen[0]->resetMode(m); | 945 | screen[0]->resetMode(m); |
917 | screen[1]->resetMode(m); | 946 | screen[1]->resetMode(m); |
918 | } | 947 | } |
919 | } | 948 | } |
920 | 949 | ||
921 | void TEmuVt102::saveMode(int m) | 950 | void TEmuVt102::saveMode(int m) |
922 | { | 951 | { |
923 | saveParm.mode[m] = currParm.mode[m]; | 952 | saveParm.mode[m] = currParm.mode[m]; |
924 | } | 953 | } |
925 | 954 | ||
926 | void TEmuVt102::restoreMode(int m) | 955 | void TEmuVt102::restoreMode(int m) |
927 | { | 956 | { |
928 | if(saveParm.mode[m]) setMode(m); else resetMode(m); | 957 | if(saveParm.mode[m]) setMode(m); else resetMode(m); |
929 | } | 958 | } |
930 | 959 | ||
931 | BOOL TEmuVt102::getMode(int m) | 960 | BOOL TEmuVt102::getMode(int m) |
932 | { | 961 | { |
933 | return currParm.mode[m]; | 962 | return currParm.mode[m]; |
934 | } | 963 | } |
935 | 964 | ||
936 | void TEmuVt102::setConnect(bool c) | 965 | void TEmuVt102::setConnect(bool c) |
937 | { | 966 | { |
938 | TEmulation::setConnect(c); | 967 | TEmulation::setConnect(c); |
939 | if (c) | 968 | if (c) |
940 | { // refresh mouse mode | 969 | { // refresh mouse mode |
941 | if (getMode(MODE_Mouse1000)) | 970 | if (getMode(MODE_Mouse1000)) |
942 | setMode(MODE_Mouse1000); | 971 | setMode(MODE_Mouse1000); |
943 | else | 972 | else |
944 | resetMode(MODE_Mouse1000); | 973 | resetMode(MODE_Mouse1000); |
945 | } | 974 | } |
946 | } | 975 | } |
947 | 976 | ||
948 | /* ------------------------------------------------------------------------- */ | 977 | /* ------------------------------------------------------------------------- */ |
949 | /* */ | 978 | /* */ |
950 | /* Diagnostic */ | 979 | /* Diagnostic */ |
951 | /* */ | 980 | /* */ |
952 | /* ------------------------------------------------------------------------- */ | 981 | /* ------------------------------------------------------------------------- */ |
953 | 982 | ||
954 | /*! shows the contents of the scan buffer. | 983 | /*! shows the contents of the scan buffer. |
955 | 984 | ||
956 | This functions is used for diagnostics. It is called by \e ReportErrorToken | 985 | This functions is used for diagnostics. It is called by \e ReportErrorToken |
957 | to inform about strings that cannot be decoded or handled by the emulation. | 986 | to inform about strings that cannot be decoded or handled by the emulation. |
958 | 987 | ||