xterm-31.patch.txt

xterm - patch #31 - T.Dickey
 
This implements vt52 emulation in xterm (ifdef'd so it can be removed).
I've been using it for testing for the past month or so.
 
--------------------------------------------------------------------------------
 VTPrsTbl.c  |  655 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 VTparse.def |    1 
 VTparse.h   |   10 
 charproc.c  |  105 ++++++++-
 ctlseqs.ms  |   62 ++++-
 input.c     |   52 ++++
 ptyx.h      |   10 
 xterm.man   |    1 
 8 files changed, 868 insertions, 28 deletions
--------------------------------------------------------------------------------
Index: VTPrsTbl.c
--- xterm-29+/VTPrsTbl.c        Sun Sep 15 21:51:25 1996
+++ xterm-30/VTPrsTbl.c Sat Oct  5 20:36:26 1996
@@ -28,12 +28,15 @@
 
 #include "VTparse.h"
 
+/* FIXME: there should be a single config.h */
+#define OPT_VT52_MODE   1 /* true if xterm supports VT52 emulation */
+
 /*
  * Stupid Apollo C preprocessor can't handle long lines.  So... To keep
  * it happy, we put each onto a separate line....  Sigh...
  */
 
-Const PARSE_T groundtable[] =
+Const PARSE_T ansi_table[] =
 {
 /*     NUL             SOH             STX             ETX     */
 CASE_IGNORE,
@@ -4572,3 +4575,653 @@
 CASE_IGNORE,
 CASE_IGNORE,
 };
+
+#if OPT_VT52_MODE
+Const PARSE_T vt52_table[] =
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_IGNORE,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     $               %               &               '       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     (               )               *               +       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     ,               -               .               /       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     0               1               2               3       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     4               5               6               7       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     8               9               :               ;       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     <               =               >               ?       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT, 
+/*     @               A               B               C       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     D               E               F               G       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     H               I               J               K       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     L               M               N               O       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     P               Q               R               S       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     T               U               V               W       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     X               Y               Z               [       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     \               ]               ^               _       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     `               a               b               c       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     d               e               f               g       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     h               i               j               k       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     l               m               n               o       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     p               q               r               s       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     t               u               v               w       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     x               y               z               {       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     |               }               ~               DEL     */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x90            0x91            0x92            0x93    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+};
+
+Const PARSE_T vt52_esc_table[] =
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     BS              HT              NL              VT      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     NP              CR              SO              SI      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     $               %               &               '       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     (               )               *               +       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     ,               -               .               /       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     0               1               2               3       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     4               5               6               7       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     8               9               :               ;       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     <               =               >               ?       */
+CASE_ANSI_LEVEL_1,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE, 
+/*     @               A               B               C       */
+CASE_IGNORE,
+CASE_CUU,
+CASE_CUD,
+CASE_CUF,
+/*     D               E               F               G       */
+CASE_CUB,
+CASE_IGNORE,
+CASE_SO,
+CASE_SI,
+/*     H               I               J               K       */
+CASE_CUP,
+CASE_RI,
+CASE_ED,
+CASE_EL,
+/*     L               M               N               O       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     P               Q               R               S       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     T               U               V               W       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     X               Y               Z               [       */
+CASE_IGNORE,
+CASE_VT52_CUP,
+CASE_DECID,
+CASE_IGNORE,
+/*     \               ]               ^               _       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     `               a               b               c       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     d               e               f               g       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     h               i               j               k       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     l               m               n               o       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     p               q               r               s       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     t               u               v               w       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     x               y               z               {       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     |               }               ~               DEL     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x90            0x91            0x92            0x93    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+};
+#endif /* OPT_VT52_MODE */
Index: VTparse.def
--- xterm-29+/VTparse.def       Sun Sep 15 21:42:20 1996
+++ xterm-30/VTparse.def        Sat Oct  5 20:35:38 1996
@@ -112,3 +112,4 @@
 CASE_DA2
 CASE_DEC3_STATE
 CASE_DECRPTUI
+CASE_VT52_CUP
Index: VTparse.h
--- xterm-29+/VTparse.h Sun Sep 15 21:48:11 1996
+++ xterm-30/VTparse.h  Sat Oct  5 20:35:38 1996
@@ -36,21 +36,26 @@
  */
 typedef char PARSE_T;
 
+extern Const PARSE_T ansi_table[];
 extern Const PARSE_T csi_quo_table[];
 extern Const PARSE_T csi_table[];
-extern Const PARSE_T dec_table[];
 extern Const PARSE_T dec2_table[];
 extern Const PARSE_T dec3_table[];
+extern Const PARSE_T dec_table[];
 extern Const PARSE_T eigtable[];
 extern Const PARSE_T esc_sp_table[];
 extern Const PARSE_T esc_table[];
-extern Const PARSE_T groundtable[];
 extern Const PARSE_T iestable[];
 extern Const PARSE_T igntable[];
 extern Const PARSE_T scrtable[];
 extern Const PARSE_T scstable[];
 extern Const PARSE_T sos_table[];
 
+#if OPT_VT52_MODE
+extern Const PARSE_T vt52_table[];
+extern Const PARSE_T vt52_esc_table[];
+#endif
+
 /*
  * The following list of definitions is generated from VTparse.def using the
  * following command line:
@@ -168,3 +173,4 @@
 #define CASE_DA2 103
 #define CASE_DEC3_STATE 104
 #define CASE_DECRPTUI 105
+#define CASE_VT52_CUP 106
Index: charproc.c
--- xterm-29+/charproc.c        Sun Sep 15 21:47:26 1996
+++ xterm-30/charproc.c Sat Oct  5 20:36:19 1996
@@ -321,7 +321,7 @@
 static  int    defaultNMarginBell = N_MARGINBELL;
 static  int    defaultMultiClickTime = MULTICLICKTIME;
 static  int    defaultBellSuppressTime = BELLSUPPRESSMSEC;
-static int     default_DECID = MIN_DECID;
+static int     default_DECID = DFT_DECID;
 static char *  _Font_Selected_ = "yes";  /* string is arbitrary */
 
 #if OPT_BLINK_CURS
@@ -847,6 +847,11 @@
        static Char *string_area;
        static Size_t string_size, string_used;
 
+#if OPT_VT52_MODE
+       static Bool vt52_cup = FALSE;
+#endif
+
+       Const PARSE_T *groundtable = ansi_table;
        register TScreen *screen = &term->screen;
        register Const PARSE_T *parsestate;
        register unsigned int c;
@@ -858,6 +863,7 @@
        /* We longjmp back to this point in VTReset() */
        (void)setjmp(vtjmpbuf);
 
+       groundtable = screen->ansi_level ? ansi_table : vt52_table;
        parsestate = groundtable;
        scstype = 0;
        private_function = False;
@@ -881,6 +887,29 @@
                string_used = 0;
            }
 
+           /*
+            * VT52 is a little ugly in the one place it has a parameterized
+            * control sequence, since the parameter falls after the character
+            * that denotes the type of sequence.
+            */
+#if OPT_VT52_MODE
+           if (vt52_cup) {
+               param[nparam++] = (c & 0x7f) - 32;
+               if (nparam < 2)
+                       continue;
+               vt52_cup = FALSE;
+               if((row = param[0]) < 0)
+                       row = 0;
+               if((col = param[1]) < 0)
+                       col = 0;
+               CursorSet(screen, row, col, term->flags);
+               parsestate = vt52_table;
+               param[0] = 0;
+               param[1] = 0;
+               continue;
+           }
+#endif
+
            switch (parsestate[c]) {
                 case CASE_PRINT:
                        /* printable characters */
@@ -888,6 +917,10 @@
                        cp = bptr;
                        *--bptr = c;
                        while(top > 0 && isprint(*cp & 0x7f)) {
+#if OPT_VT52_MODE
+                               if (screen->ansi_level <= 1)
+                                       *cp &= 0x7f;
+#endif
                                top--;
                                bcnt--;
                                cp++;
@@ -959,9 +992,19 @@
 
                 case CASE_ESC:
                        /* escape */
+                       if_OPT_VT52_MODE(screen,{
+                               parsestate = vt52_esc_table;
+                               break;})
                        parsestate = esc_table;
                        break;
 
+#if OPT_VT52_MODE
+                case CASE_VT52_CUP:
+                       vt52_cup = TRUE;
+                       nparam = 0;
+                       break;
+#endif
+
                 case CASE_VMOT:
                        /*
                         * form feed, line feed, vertical tab
@@ -998,10 +1041,12 @@
 
                 case CASE_SI:
                        screen->curgl = 0;
+                       parsestate = groundtable;
                        break;
 
                 case CASE_SO:
                        screen->curgl = 1;
+                       parsestate = groundtable;
                        break;
 
                 case CASE_SCR_STATE:
@@ -1202,6 +1247,13 @@
                        break;
 
                 case CASE_DECID:
+                       if_OPT_VT52_MODE(screen,{
+                               unparseputc(ESC,  screen->respond);
+                               unparseputc('/',  screen->respond);
+                               unparseputc('Z',  screen->respond);
+                               parsestate = groundtable;
+                               break;
+                               })
                        param[0] = -1;          /* Default ID parameter */
                        /* FALLTHRU */
                 case CASE_DA1:
@@ -1519,6 +1571,12 @@
                 case CASE_DECRST:
                        /* DECRST */
                        dpmodes(term, bitclr);
+#if OPT_VT52_MODE
+                       if (screen->ansi_level == 0)
+                               groundtable = vt52_table;
+                       else if (screen->terminal_id >= 100)
+                               groundtable = ansi_table;
+#endif
                        parsestate = groundtable;
                        break;
 
@@ -1583,14 +1641,22 @@
                         * equivalents of DECSCL - T.Dickey)
                         */
                 case CASE_ANSI_LEVEL_1:
-                       screen->ansi_level = 1;
-                       screen->control_eight_bits = False;
+                       if (screen->terminal_id >= 100) {
+                               screen->ansi_level = 1;
+                               screen->control_eight_bits = False;
+#if OPT_VT52_MODE
+                               groundtable =
+                               parsestate = ansi_table;
+#endif
+                       }
                        break;
                 case CASE_ANSI_LEVEL_2:
-                       screen->ansi_level = 2;
+                       if (screen->terminal_id >= 200)
+                               screen->ansi_level = 2;
                        break;
                 case CASE_ANSI_LEVEL_3:
-                       screen->ansi_level = 3;
+                       if (screen->terminal_id >= 300)
+                               screen->ansi_level = 3;
                        break;
 
                 case CASE_DECSCL:
@@ -1772,6 +1838,10 @@
                        break;
 
                 case CASE_S8C1T:
+#if OPT_VT52_MODE
+                       if (screen->ansi_level <= 1)
+                               break;
+#endif
                        screen->control_eight_bits = True;
                        parsestate = groundtable;
                        break;
@@ -2333,14 +2403,26 @@
                        update_appcursor();
                        break;
                case 2:                 /* ANSI/VT52 mode               */
-                       if (func == bitset) {
+                       if (func == bitset) {   /* ANSI (VT100) */
                                screen->gsets[0] =
-                                       screen->gsets[1] =
-                                       screen->gsets[2] =
-                                       screen->gsets[3] = 'B';
+                               screen->gsets[1] =
+                               screen->gsets[2] =
+                               screen->gsets[3] = 'B';
                                screen->curgl = 0;
                                screen->curgr = 2;
+                               if_OPT_VT52_MODE(screen,{
+                                       screen->ansi_level = 1;})
+                       }
+#if OPT_VT52_MODE
+                       else if (screen->terminal_id >= 100) {  /* VT52 */
+                               screen->ansi_level = 0;
+                               param[0] = 0;
+                               param[1] = 0;
+                               screen->curgl = 0;
+                               screen->gsets[0] = 'B';
+                               screen->gsets[1] = '0';
                        }
+#endif
                        break;
                case 3:                 /* DECCOLM                      */
                        if(screen->c132) {
@@ -2449,6 +2531,9 @@
                                FromAlternate(screen);
                        }
                        break;
+               case 66:        /* DECNKM */
+                       /* FIXME: numeric keypad */
+                       break;
                case 67:        /* DECBKM */
                        /* FIXME: back-arrow mapped to backspace or delete(D)*/
                        break;
@@ -2867,7 +2952,7 @@
        register int    inters;
 
        unparseputc1(c = ap->a_type, fd);
-       if (c==ESC || c==DCS || c==CSI || c==OSC || c==PM || c==APC) {
+       if (c==ESC || c==DCS || c==CSI || c==OSC || c==PM || c==APC || c==SS3) {
                if (ap->a_pintro != 0)
                        unparseputc((char) ap->a_pintro, fd);
                for (i=0; i<ap->a_nparam; ++i) {
Index: ctlseqs.ms
--- xterm-29+/ctlseqs.ms        Sun Sep 15 22:00:25 1996
+++ xterm-30/ctlseqs.ms Sat Oct  5 20:35:39 1996
@@ -135,6 +135,8 @@
 .[] : :
 .[] ; ;
 .[] = =
+.[] / /
+.[] < <
 .[] > >
 .[] ? ?
 .[] @ @
@@ -160,6 +162,7 @@
 .[] V V
 .[] W W
 .[] XX X
+.[] Y Y
 .[] Z Z
 .[] [[ [
 .[] ]] ]
@@ -295,8 +298,8 @@
 .LP
 Most of these control sequences are standard VT102 control sequences,
 but there is support for later DEC VT terminals (i.e., VT220 and VT320), too.
-VT102 features not supported are double size
-characters, blinking characters, and VT52 mode.
+VT102 features not supported are
+double size characters and blinking characters.
 There are additional control sequences to provide
 \fIxterm-\fPdependent functions, such as the scrollbar or window size.
 Where the function is specified by DEC or ISO 6429, the code assigned
@@ -539,7 +542,7 @@
 .IP \\*(Cs\\*(Ps\\*s\\*S
 Scroll up \*(Ps lines (default = 1) (SU)
 .
-.IP \\*(Cs\\*(Ps\\*s\\*\\*T
+.IP \\*(Cs\\*(Ps\\*s\\*T
 Scroll down \*(Ps lines (default = 1) (SD, according to DEC)
 .
 .IP \\*(Cs\\*(Ps\\*s\\*;\\*(Ps\\*s\\*;\\*(Ps\\*s\\*;\\*(Ps\\*s\\*;\\*(Ps\\*s\\*T
@@ -553,7 +556,7 @@
 .IP \\*(Cs\\*(Ps\\*s\\*Z
 Cursor Backward Tabulation \*(Ps tab stops (default = 1) (CBT)
 .
-.IP \\*(Cs\\*(Ps\\*s\\*\\*^
+.IP \\*(Cs\\*(Ps\\*s\\*^
 Scroll down \*(Ps lines (default = 1) (SD, according to ISO)
 .
 .IP \\*(Cs\\*(Ps\\*s\\*c
@@ -691,9 +694,8 @@
 .IP \\*(Cs\\*?\\*(Pm\\*s\\*h
 DEC Private Mode Set (DECSET)
   \*(Ps = \*1 \(-> Application Cursor Keys (DECCKM)
-  \*(Ps = \*2 \(-> Designate USASCII for character sets G0-G3.
-(In the VT102, this selects VT52 mode (DECANM), which \fIxterm\fP
-doesn't support.)
+  \*(Ps = \*2 \(-> Designate USASCII for character sets G0-G3 (DECANM),
+and set VT100 mode.
   \*(Ps = \*3 \(-> 132 Column Mode (DECCOLM)
   \*(Ps = \*4 \(-> Smooth (Slow) Scroll (DECSCLM)
   \*(Ps = \*5 \(-> Reverse Video (DECSCNM)
@@ -720,6 +722,7 @@
 .IP \\*(Cs\\*?\\*(Pm\\*s\\*l
 DEC Private Mode Reset (DECRST)
   \*(Ps = \*1 \(-> Normal Cursor Keys (DECCKM)
+  \*(Ps = \*2 \(-> Designate VT52 mode (DECANM).
   \*(Ps = \*3 \(-> 80 Column Mode (DECCOLM)
   \*(Ps = \*4 \(-> Jump (Fast) Scroll (DECSCLM)
   \*(Ps = \*5 \(-> Normal Video (DECSCNM)
@@ -934,4 +937,49 @@
 .IP \\*(Us
 Alpha Mode (Ctrl-_)
 .Ed
+.
+.
+.br
+.ds RH VT52 Mode
+.SH
+VT52 Mode
+.LP
+Parameters for cursor movement are at the end of the \*(Es\*Y escape sequence.
+Each ordinate is encoded in a single character as \fIvalue\fP+040.
+For example, \*! is 1.
+The screen coodinate system is 0-based.
+.St
+.IP \\*(Es\\*A
+Cursor up.
+.IP \\*(Es\\*(cB
+Cursor down.
+.IP \\*(Es\\*C
+Cursor right.
+.IP \\*(Es\\*D
+Cursor left.
+.IP \\*(Es\\*F
+Enter graphics mode.
+.IP \\*(Es\\*G
+Exit graphics mode.
+.IP \\*(Es\\*H
+Move the cursor to the home position.
+.IP \\*(Es\\*I
+Reverse line feed.
+.IP \\*(Es\\*J
+Erase from the cursor to the end of the screen.
+.IP \\*(Es\\*K
+Erase from the cursor to the end of the line.
+.IP \\*(Es\\*Y\\*(Ps\\*s\\*(Ps
+Move the cursor to given row and column.
+.IP \\*(Es\\*Z
+Identify
+  \(-> \*(Es\*s\*/\*s\*Z (``I am a VT52.'')
+.IP \\*(Es\\*=
+Enter alternate keypad mode.
+.IP \\*(Es\\*>
+Exit alternate keypad mode.
+.IP \\*(Es\\*<
+Exit VT52 mode (Enter VT100 mode).
+.Ed
+.
 .if n .pl \n(nlu+1v
Index: input.c
--- xterm-29+/input.c   Tue Aug 13 14:51:20 1996
+++ xterm-30/input.c    Sat Oct  5 20:35:39 1996
@@ -109,19 +109,33 @@
            keysym += XK_Home - XK_KP_Home;
        }
 
+#define VT52_KEYPAD \
+       if_OPT_VT52_MODE(screen,{ \
+               reply.a_type = ESC; \
+               reply.a_pintro = '?'; \
+               })
+
+#define VT52_CURSOR_KEYS \
+       if_OPT_VT52_MODE(screen,{ \
+               reply.a_type = ESC; \
+               })
+
        if (IsPFKey(keysym)) {
                reply.a_type = SS3;
+               reply.a_final = keysym-XK_KP_F1+'P';
+               VT52_CURSOR_KEYS
                unparseseq(&reply, pty);
-               unparseputc((char)(keysym-XK_KP_F1+'P'), pty);
                key = TRUE;
         } else if (IsCursorKey(keysym) &&
                keysym != XK_Prior && keysym != XK_Next) {
                        if (keyboard->flags & CURSOR_APL) {
                        reply.a_type = SS3;
+                       reply.a_final = cur[keysym-XK_Home];
+                       VT52_CURSOR_KEYS
                        unparseseq(&reply, pty);
-                       unparseputc(cur[keysym-XK_Home], pty);
                } else {
                        reply.a_type = CSI;
+                       if_OPT_VT52_MODE(screen,{ reply.a_type = ESC; })
                        reply.a_final = cur[keysym-XK_Home];
                        unparseseq(&reply, pty);
                }
@@ -130,17 +144,32 @@
                keysym == XK_Prior || keysym == XK_Next ||
                keysym == DXK_Remove || keysym == XK_KP_Delete ||
                keysym == XK_KP_Insert) {
-               if ((string = udk_lookup(funcvalue(keysym), &nbytes)) != 0) {
+               int dec_code = funcvalue(keysym);
+               if ((string = udk_lookup(dec_code, &nbytes)) != 0) {
                        while (nbytes-- > 0)
                                unparseputc(*string++, pty);
-               } else {
+               }
+#if OPT_VT52_MODE
+               /*
+                * Interpret F1-F4 as PF1-PF4 for VT52, VT100
+                */
+               else if (screen->ansi_level <= 1
+                 && (dec_code >= 11 && dec_code <= 14))
+               {
+                       reply.a_type = SS3;
+                       VT52_CURSOR_KEYS
+                       reply.a_final = dec_code - 11 + 'P';
+                       unparseseq(&reply, pty);
+               }
+#endif
+               else {
                        reply.a_type = CSI;
                        reply.a_nparam = 1;
                        if (sunFunctionKeys) {
                                reply.a_param[0] = sunfuncvalue (keysym);
                                reply.a_final = 'z';
                        } else {
-                               reply.a_param[0] = funcvalue (keysym);
+                               reply.a_param[0] = dec_code;
                                reply.a_final = '~';
                        }
                        if (reply.a_param[0] > 0)
@@ -148,10 +177,21 @@
                }
                key = TRUE;
        } else if (IsKeypadKey(keysym)) {
+#if OPT_VT52_MODE
+               /*
+                * DEC keyboards don't have keypad(+), but do have keypad(,)
+                * instead.  Other (Sun, PC) keyboards commonly have keypad(+),
+                * but no keypad(,) - it's a pain for users to work around.
+                */
+               if (!sunFunctionKeys
+                && keysym == XK_KP_Add)
+                       keysym = XK_KP_Separator;
+#endif
                if (keyboard->flags & KYPD_APL) {
                        reply.a_type   = SS3;
+                       reply.a_final = kypd_apl[keysym-XK_KP_Space];
+                       VT52_KEYPAD
                        unparseseq(&reply, pty);
-                       unparseputc(kypd_apl[keysym-XK_KP_Space], pty);
                } else
                        unparseputc(kypd_num[keysym-XK_KP_Space], pty);
                key = TRUE;
Index: ptyx.h
--- xterm-29+/ptyx.h    Sun Sep 15 21:27:09 1996
+++ xterm-30/ptyx.h     Sat Oct  5 20:35:39 1996
@@ -188,7 +188,8 @@
 #define        APC     0x9F
 #define        RDEL    0xFF
 
-#define MIN_DECID 100                  /* emulate VT100 */
+#define MIN_DECID  52                  /* can emulate VT52 */
+#define DFT_DECID 100                  /* default VT100 */
 #define MAX_DECID 420                  /* ...through VT420 */
 
 #define NMENUFONTS 9                   /* entries in fontMenu */
@@ -286,6 +287,7 @@
 
 #define OPT_ISO_COLORS  1 /* true if xterm is configured with ISO colors */
 #define OPT_BLINK_CURS  0 /* FIXME: do this later (96/7/31) */
+#define OPT_VT52_MODE   1 /* true if xterm supports VT52 emulation */
 
 /***====================================================================***/
 
@@ -321,6 +323,12 @@
 #define MAX_PTRS term->num_ptrs
 #else
 #define MAX_PTRS 2
+#endif
+
+#if OPT_VT52_MODE
+#define if_OPT_VT52_MODE(screen, code) if(screen->ansi_level == 0) code
+#else
+#define if_OPT_VT52_MODE(screen, code) /* nothing */
 #endif
 
        /* ScrnBuf-level macros */
Index: xterm.man
--- xterm-29+/xterm.man Sun Sep 15 19:58:11 1996
+++ xterm-30/xterm.man  Sat Oct  5 20:35:39 1996
@@ -56,7 +56,6 @@
 menu in the 4014 window.
 .SH EMULATIONS
 The VT102 emulation is fairly complete, but does not support
-VT52 mode,
 autorepeat,
 the blinking character attribute
 nor the double-wide and double-size character sets.