# ------------------------------------------------------------------------------
 #  Makefile.in                  |   22 ++-
 #  Tekproc.c                    |    2 
 #  XTerm.ad                     |    1 
 #  button.c                     |    6 
 #  charproc.c                   |   31 ++++-
 #  ctlseqs.ms                   |  105 ++++++++++++-----
 #  input.c                      |  104 ++++++++++++----
 #  main.c                       |   28 ++--
 #  menu.c                       |   51 ++++++--
 #  menu.h                       |   23 +++
 #  misc.c                       |  252 ++++++++++++++++++++++++++---------------
 #  ptyx.h                       |    4 
 #  resize.c                     |    6 
 #  screen.c                     |    9 +
 #  scrollbar.c                  |    2 
 #  termcap                      |    2 
 #  terminfo                     |   34 +++--
 #  version.h                    |    2 
 #  xterm-94/vttests/16colors.sh |   63 ++++++++++
 #  xterm-94/vttests/8colors.sh  |   51 ++++++++
 #  xterm-94/vttests/dynamic.sh  |   28 ++++
 #  xterm-94/vttests/resize.sh   |   51 ++++++++
 #  xterm-94/vttests/title.sh    |   22 +++
 #  xterm.h                      |   16 --
 #  xterm.log.html               |   87 ++++++++++++++
 #  xterm.man                    |   47 ++++++-
 #  26 files changed, 820 insertions, 229 deletions
 # ------------------------------------------------------------------------------
 Index: Makefile.in
--- xterm-93+/Makefile.in       Sun Mar 14 14:59:36 1999
 +++ xterm-94/Makefile.in        Mon Mar 22 21:19:37 1999
 @@ -32,6 +32,8 @@
  libdir         = $(exec_prefix)/lib
 mandir         = $(prefix)/man/man$(manext)
 
+appsdir                = $(libdir)/X11/app-defaults
 +
 #### End of system configuration section. ####
 
 SHELL          = /bin/sh
@@ -39,7 +41,7 @@
 
 LDFLAGS                =
 
-INSTALL_DIRS    = $(bindir) $(libdir) $(mandir)
 +INSTALL_DIRS    = $(bindir) $(appsdir) $(mandir)
  
 EXTRAHDR       = @EXTRAHDRS@
 EXTRASRC       = @EXTRASRCS@
@@ -85,11 +87,13 @@
 resize : $(OBJS2)
        @ECHO_LD@$(LINK) $(LDFLAGS) -o $@ $(OBJS2) $(X_LIBS) $(X_EXTRA_LIBS) $(LIBS)
 
-install: $(INSTALL_DIRS) xterm resize
 +install : $(INSTALL_DIRS) xterm resize
         $(INSTALL_PROGRAM) -s -m @XTERM_MODE@ xterm  $(bindir)/xterm
        $(INSTALL_PROGRAM) -s -m  755 resize $(bindir)/resize
-       $(INSTALL_DATA) xterm.man  $(mandir)/xterm.$(manext)
 -       $(INSTALL_DATA) resize.man $(mandir)/resize.$(manext)
 +       $(INSTALL_DATA) xterm.man    $(mandir)/xterm.$(manext)
 +       $(INSTALL_DATA) resize.man   $(mandir)/resize.$(manext)
 +       $(INSTALL_DATA) XTerm.ad     $(appsdir)/XTerm
 +       $(INSTALL_DATA) XTerm-col.ad $(appsdir)/XTerm-color
         @echo 'Completed installation of executables and documentation.'
        @echo 'Use "make install-ti" to install terminfo description.'
 
@@ -99,10 +103,12 @@
 installdirs: $(INSTALL_DIRS)
 
 uninstall:
-       -$(RM) $(bindir)/xterm \
 -               $(bindir)/resize \
 -               $(mandir)/xterm.$(manext) \
 -               $(mandir)/resize.$(manext)
 +       -$(RM) $(bindir)/xterm
 +       -$(RM) $(bindir)/resize
 +       -$(RM) $(mandir)/xterm.$(manext)
 +       -$(RM) $(mandir)/resize.$(manext)
 +       -$(RM) $(appsdir)/XTerm
 +       -$(RM) $(appsdir)/XTerm-color
  
 mostlyclean:
        -$(RM) *.[ois] XtermLog.* .pure core *~ *.BAK *.out
Index: Tekproc.c
--- xterm-93+/Tekproc.c Sun Oct 25 13:31:39 1998
 +++ xterm-94/Tekproc.c  Sat Mar 27 17:14:57 1999
 @@ -657,7 +657,7 @@
                                         buf2[len++] = c2;
                                }
                                if (c2 == BEL)
-                                       do_osc(buf2, len);
 +                                       do_osc(buf2, len, BEL);
                         }
                        Tparsestate = curstate;
                        break;
Index: XTerm.ad
--- xterm-93+/XTerm.ad  Sun Dec 20 22:50:38 1998
 +++ xterm-94/XTerm.ad   Fri Mar 26 18:41:35 1999
 @@ -23,6 +23,7 @@
  *mainMenu*redraw*Label:  Redraw Window
 *mainMenu*8-bit control*Label: 8-Bit Controls
 *mainMenu*backarrow key*Label: Backarrow Key
+*mainMenu*num-lock*Label: Alt/NumLock Modifiers
  *mainMenu*sun function-keys*Label: Sun Function-Keys
 *mainMenu*sun keyboard*Label: Sun/PC Keyboard
 *mainMenu*hp function-keys*Label: HP Function-Keys
Index: button.c
--- xterm-93+/button.c  Sun Feb  7 12:54:50 1999
 +++ xterm-94/button.c   Sun Mar 21 13:38:47 1999
 @@ -21,7 +21,7 @@
   * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  * SOFTWARE.
  */
-/* $XFree86: xc/programs/xterm/button.c,v 3.29 1999/02/07 06:18:53 dawes Exp $ */
 +/* $XFree86: xc/programs/xterm/button.c,v 3.30 1999/03/21 07:35:40 dawes Exp $ */
  
 /*
 button.c       Handles button events in the terminal emulator.
@@ -1273,7 +1273,7 @@
        Atom* std_targets;
        unsigned long std_length;
        XmuConvertStandardSelection(w, screen->selection_time, selection,
-                                   target, type, (XMU_POINTER *)&std_targets,
 +                                   target, type, (XPointer *)&std_targets,
                                     &std_length, format);
        *length = std_length + 5;
        targetP = (Atom*)XtMalloc(sizeof(Atom)*(*length));
@@ -1338,7 +1338,7 @@
        return True;
     }
     if (XmuConvertStandardSelection(w, screen->selection_time, selection,
-                                   target, type, (XMU_POINTER *)value,
 +                                   target, type, (XPointer *)value,
                                     length, format))
        return True;
 
Index: charproc.c
--- xterm-93+/charproc.c        Sun Mar 14 14:59:36 1999
 +++ xterm-94/charproc.c Sat Mar 27 17:25:54 1999
 @@ -499,6 +499,9 @@
      { "maximize",              HandleMaximize },
     { "restore",               HandleRestoreSize },
 #endif
+#if OPT_NUM_LOCK
+    { "set-num-lock",          HandleNumLock },
 +#endif
 #if OPT_SHIFT_KEYS
     { "larger-vt-font",                HandleLargerFont },
     { "smaller-vt-font",       HandleSmallerFont },
@@ -1195,7 +1198,7 @@
                        if (string_mode == OSC) {
                                if (string_used)
                                        string_area[--string_used] = '\0';
-                               do_osc(string_area, string_used);
 +                               do_osc(string_area, string_used, c);
                                 parsestate = groundtable;
                        } else {
                                /* bell */
@@ -1973,7 +1976,7 @@
                                do_dcs(string_area, string_used);
                                break;
                        case OSC:
-                               do_osc(string_area, string_used);
 +                               do_osc(string_area, string_used, c);
                                 break;
                        case PM:
                                /* ignored */
@@ -2855,7 +2858,7 @@
                                ToggleScrollBar(termw);
                        break;
 #if OPT_SHIFT_KEYS
-               case 35:
 +               case 35:                /* rxvt */
                         term->misc.shift_keys = (func == bitset) ? ON : OFF;
                        break;
 #endif
@@ -2936,7 +2939,8 @@
                        }
                        break;
                case 66:        /* DECNKM */
-                       /* FIXME: VT300 numeric keypad */
 +                       (*func)(&termw->keyboard.flags, MODE_DECKPAM);
 +                       update_appkeypad();
                         break;
                case 67:        /* DECBKM */
                        /* back-arrow mapped to backspace or delete(D)*/
@@ -2971,6 +2975,11 @@
                        screen->scrollkey = (func == bitset) ? ON : OFF;
                        update_scrollkey();
                        break;
+#if OPT_NUM_LOCK
+               case 1035:
 +                       term->misc.real_NumLock = (func == bitset) ? ON : OFF;
 +                       break;
 +#endif
                case 1048:
                        if (!termw->misc.titeInhibit) {
                                if(func == bitset)
@@ -3356,8 +3365,8 @@
                reply.a_pintro = 0;
                reply.a_nparam = 3;
                reply.a_param[0] = 9;
-               reply.a_param[1] = root_height;
 -               reply.a_param[2] = root_width;
 +               reply.a_param[1] = root_height / FontHeight(screen);
 +               reply.a_param[2] = root_width / FontWidth(screen);
                 reply.a_inters = 0;
                reply.a_final  = 't';
                unparseseq(&reply, screen->respond);
@@ -3484,6 +3493,13 @@
 }
 
 void
+unparseputs(Char *s, int fd)
+{
 +       while (*s)
 +               unparseputc(*s++, fd);
 +}
+
+void
 ToggleAlternate(register TScreen *screen)
 {
        if (screen->alternate)
@@ -3872,6 +3888,9 @@
 
    wnew->screen.ansi_level = (wnew->screen.terminal_id / 100);
    wnew->screen.visualbell = request->screen.visualbell;
+#if OPT_NUM_LOCK
+   wnew->misc.real_NumLock = request->misc.real_NumLock;
 +#endif
 #if OPT_SHIFT_KEYS
    wnew->misc.shift_keys = request->misc.shift_keys;
 #endif
Index: ctlseqs.ms
--- xterm-93+/ctlseqs.ms        Sun Mar 14 14:59:36 1999
 +++ xterm-94/ctlseqs.ms Sat Mar 27 16:50:45 1999
 @@ -826,7 +826,8 @@
  (normally disabled by a compile-time option)
   \*(Ps = \*4\*7 \(-> Use Alternate Screen Buffer (unless
 disabled by the \fBtiteInhibit\fP resource)
-  \*(Ps = \*6\*7 \(-> Backarrow key (DECBKM)
 +  \*(Ps = \*6\*6 \(-> Application keypad (DECNKM)
 +  \*(Ps = \*6\*7 \(-> Backarrow key sends delete (DECBKM)
    \*(Ps = \*1\*0\*0\*0 \(-> Send Mouse X & Y on button press and release.
 See the section \fBMouse Tracking\fP.
   \*(Ps = \*1\*0\*0\*1 \(-> Use Hilite Mouse Tracking.
@@ -834,6 +835,7 @@
   \*(Ps = \*1\*0\*0\*3 \(-> Use All Motion Mouse Tracking.
   \*(Ps = \*1\*0\*1\*0 \(-> Scroll to bottom on tty output (rxvt).
   \*(Ps = \*1\*0\*1\*1 \(-> Scroll to bottom on key press (rxvt).
+  \*(Ps = \*1\*0\*3\*5 \(-> Enable special modifiers for Alt and NumLock keys.
    \*(Ps = \*1\*0\*4\*7 \(-> Use Alternate Screen Buffer (unless
 disabled by the \fBtiteInhibit\fP resource)
   \*(Ps = \*1\*0\*4\*8 \(-> Save cursor as in DECSC (unless
@@ -869,7 +871,8 @@
   \*(Ps = \*4\*6 \(-> Stop Logging
 (normally disabled by a compile-time option)
   \*(Ps = \*4\*7 \(-> Use Normal Screen Buffer
-  \*(Ps = \*6\*7 \(-> Backarrow key (DECBKM)
 +  \*(Ps = \*6\*6 \(-> Numeric keypad (DECNKM)
 +  \*(Ps = \*6\*7 \(-> Backarrow key sends backspace (DECBKM)
    \*(Ps = \*1\*0\*0\*0 \(-> Don't Send Mouse X & Y on button press and
 release.
 See the section \fBMouse Tracking\fP.
@@ -878,6 +881,7 @@
   \*(Ps = \*1\*0\*0\*3 \(-> Don't Use All Motion Mouse Tracking
   \*(Ps = \*1\*0\*1\*0 \(-> Don't scroll to bottom on tty output (rxvt).
   \*(Ps = \*1\*0\*1\*1 \(-> Don't scroll to bottom on key press (rxvt).
+  \*(Ps = \*1\*0\*3\*5 \(-> Disable special modifiers for Alt and NumLock keys.
    \*(Ps = \*1\*0\*4\*7 \(-> Use Normal Screen Buffer, clearing screen
 first if in the Alternate Screen (unless
 disabled by the \fBtiteInhibit\fP resource)
@@ -900,12 +904,18 @@
 .sp
 .IP \\*(Os\\*(Ps\\*s\\*;\\*(Pt\\*s\\*(ST
 .IP \\*(Os\\*(Ps\\*s\\*;\\*(Pt\\*s\\*(Be
-Set Text Parameters
+Set Text Parameters.
+For colors and font,
+if \*(Pt is a "?", the control sequence elicits a response which consists
 +of the control sequence which would set the corresponding value.
 +The \fIdtterm\fP control sequences allow you to determine the icon name
 +and window title.
   \*(Ps = \*0 \(-> Change Icon Name and Window Title to \*(Pt
   \*(Ps = \*1 \(-> Change Icon Name to \*(Pt
   \*(Ps = \*2 \(-> Change Window Title to \*(Pt
-  \*(Ps = \*1\*0 \(-> Change color names starting with text foreground to \*(Pt (a
 -list of one or more color names, separated by semicolon, up to seven).
 +  \*(Ps = \*1\*0 \(-> Change color names starting with text foreground to \*(Pt
 +(a list of one or more color names or RGB specifications, separated by
 +semicolon, up to eight, as per \fIXParseColor\fP).
    \*(Ps = \*1\*1 \(-> Change colors starting with text background to \*(Pt
   \*(Ps = \*1\*2 \(-> Change colors starting with text cursor to \*(Pt
   \*(Ps = \*1\*3 \(-> Change colors starting with mouse foreground to \*(Pt
@@ -916,6 +926,10 @@
   \*(Ps = \*4\*6 \(-> Change Log File to \*(Pt (normally disabled by a
 compile-time option)
   \*(Ps = \*5\*0 \(-> Set Font to \*(Pt
+If \*(Pt begins with a "#", index in the font menu, relative (if the
 +next character is a plus or minus sign) or absolute.  A number is
 +expected but not required after the sign (the default is the current
 +entry for relative, zero for absolute indexing).
  .
 .sp
 .IP \\*(PM\\*(Pt\\*s\\*(ST
@@ -935,6 +949,12 @@
 Both have cursor and scrolling operations printed on the keypad,
 which duplicate the smaller cursor and scrolling keypads.
 .LP
+X does not predefine NumLock (used for VT220 keyboards) or Alt (used as
 +an extension for the Sun/PC keyboards) as modifiers.
 +These keys are recognized as modifiers when enabled
 +by the \fBnumLock\fP resource,
+or by the DECSET \*1\*0\*3\*5 control sequence.
 +.LP
 The cursor keys transmit the following escape sequences depending on the
 mode specified via the \fBDECCKM\fP escape sequence.
 .TS
@@ -957,34 +977,34 @@
 the program.
 .TS
 center;
-cf3    cf3     cf3
 -lf3w(2c)       lf3w(2c)        lf3w(2c) .
 -Key    Numeric Application
+cf3    cf3     cf3     cf3     cf3
 +lf3w(2c)       lf3w(2c)        lf3w(2c)        lf3w(2c)        lf3w(2c) .
 +Key    Numeric Application     Terminfo        Termcap
  _
-Space  \*(Sp   \*(S3\*(Sp
-Tab    \*(Ta   \*(S3\*I
 -Enter  \*(Cr   \*(S3\*M
-PF1    \*(S3\*P        \*(S3\*P
 -PF2    \*(S3\*Q        \*(S3\*Q
 -PF3    \*(S3\*R        \*(S3\*R
 -PF4    \*(S3\*S        \*(S3\*S
 -* \f1(multiply)\fP     *       \*(S3\*j
 -+ \f1(add)\fP  +       \*(S3\*k
 -, \f1(comma)\fP        ,       \*(S3\*l
 -- \f1(minus)\fP        -       \*(S3\*m
 -\. \f1(Delete)\fP      \.      \*(S3\*3\*(c~
 -/ \f1(divide)\fP       /       \*(S3\*o
 -0 \f1(Insert)\fP       0       \*(Cs\*2\*(c~
 -1 \f1(End)\fP  1       \*(Cs\*4\*(c~
 -2 \f1(DownArrow)\fP    2       \*(Cs\*(cB
 -3 \f1(PageDown)\fP     3       \*(Cs\*5\*(c~
 -4 \f1(LeftArrow)\fP    4       \*(Cs\*D
 -5 \f1(Begin)\fP        5       \*(Cs\*E
 -6 \f1(RightArrow)\fP   6       \*(Cs\*C
 -7 \f1(Home)\fP 7       \*(Cs\*1\*(c~
 -8 \f1(UpArrow)\fP      8       \*(Cs\*A
 -9 \f1(PageUp)\fP       9       \*(Cs\*5\*(c~
 -= (equal)      \&=     \*(S3\*(XX
 +Space  \*(Sp   \*(S3\*(Sp      -       -
 +Tab    \*(Ta   \*(S3\*I        -       -
 +Enter  \*(Cr   \*(S3\*M        kent    @8
 +PF1    \*(S3\*P        \*(S3\*P        kf1     k1
 +PF2    \*(S3\*Q        \*(S3\*Q        kf2     k2
 +PF3    \*(S3\*R        \*(S3\*R        kf3     k3
 +PF4    \*(S3\*S        \*(S3\*S        kf4     k4
 +* \f1(multiply)\fP     *       \*(S3\*j        -       -
 ++ \f1(add)\fP  +       \*(S3\*k        -       -
 +, \f1(comma)\fP        ,       \*(S3\*l        -       -
 +- \f1(minus)\fP        -       \*(S3\*m        -       -
 +\. \f1(Delete)\fP      \.      \*(S3\*3\*(c~   -       -
 +/ \f1(divide)\fP       /       \*(S3\*o        -       -
 +0 \f1(Insert)\fP       0       \*(Cs\*2\*(c~   -       -
 +1 \f1(End)\fP  1       \*(Cs\*4\*(c~   kc1     K4
 +2 \f1(DownArrow)\fP    2       \*(Cs\*(cB      -       -
 +3 \f1(PageDown)\fP     3       \*(Cs\*5\*(c~   kc3     K5
 +4 \f1(LeftArrow)\fP    4       \*(Cs\*D        -       -
 +5 \f1(Begin)\fP        5       \*(Cs\*E        kb2     K2
 +6 \f1(RightArrow)\fP   6       \*(Cs\*C        -       -
 +7 \f1(Home)\fP 7       \*(Cs\*1\*(c~   ka1     K1
 +8 \f1(UpArrow)\fP      8       \*(Cs\*A        -       -
 +9 \f1(PageUp)\fP       9       \*(Cs\*5\*(c~   ka3     K3
 += (equal)      \&=     \*(S3\*(XX      -       -
 .TE
 They also provide 12 function keys, as well as a few other special-purpose keys.
 .TS
@@ -1022,10 +1042,33 @@
 F3     \*(Cs\*1\*3\*(c~
 F4     \*(Cs\*1\*4\*(c~
 .TE
+In normal mode, i.e., a Sun/PC keyboard
 +when the \fBsunKeyboard\fP resource is false,
 +\fIxterm\fP recognizes function key modifiers
 +which are parameters appended before the final character
 +of the control sequence.
+.TS
 +center;
+cf3    lf3
+cf3w(2c)       lf3w(2c) .
 +Code   Modifiers
+_
+2      Shift
+3      Alt
 +4      Shift + Alt
 +5      Control
+6      Shift + Control
 +7      Alt + Control
 +8      Shift + Alt + Control
 +.TE
+For example, shift-F5 would be sent as
 +\*(Cs\*1\*5\*;\*2\*(c~
 .SH
 VT220-Style Function Keys
 .LP
 However, \fIxterm\fP is most useful as a DEC VT102 or VT220 emulator.
+Set the \fBsunKeyboard\fP resource to true to force a Sun/PC keyboard
 +to act like a VT220 keyboard.
  .LP
 The VT102/VT220 application keypad transmits unique escape sequences in
 application mode, which are distinct from the cursor and scrolling keypad:
Index: input.c
--- xterm-93+/input.c   Sun Mar 14 14:59:36 1999
 +++ xterm-94/input.c    Sat Mar 27 18:15:56 1999
 @@ -170,6 +170,7 @@
                 { XK_Home,         XK_Find },
                { XK_End,          XK_Select },
 #ifdef XK_KP_Home
+               { XK_Delete,       XK_KP_Decimal },
                 { XK_KP_Delete,    XK_KP_Decimal },
                { XK_KP_Insert,    XK_KP_0 },
                { XK_KP_End,       XK_KP_1 },
@@ -195,6 +196,7 @@
        return keysym;
 }
 #endif
+
 /*
  * Modifiers other than shift, control and numlock should be reserved for the
  * user.  We use the first two explicitly to support VT220 keyboard, and the
@@ -215,6 +217,12 @@
                reply.a_type = ESC; \
                })
 
+#define MODIFIER_PARM \
+       if (modify_parm > 1) { \
 +           reply.a_param[(int) reply.a_nparam] = modify_parm; \
 +           reply.a_nparam += 1; \
 +       }
+
  void
 Input (
        register TKeyboard *keyboard,
@@ -233,6 +241,8 @@
        KeySym  keysym = 0;
        ANSI    reply;
        int     dec_code;
+       short   modify_parm = 0;
 +       int     keypad_mode = ((keyboard->flags & MODE_DECKPAM) != 0);
  
        /* Ignore characters typed at the keyboard */
        if (keyboard->flags & MODE_KAM)
@@ -279,29 +289,69 @@
         * - it's a pain for users to work around.
         */
        if (!sunFunctionKeys
+        && (event->state & ShiftMask) == 0
          && sunKeyboard
-        && keysym == XK_KP_Add)
 +        && keysym == XK_KP_Add) {
                 keysym = XK_KP_Separator;
+               TRACE(("...Input keypad(+), change keysym to %#04lx\n", keysym))
 +       }
 #endif
 
        /*
         * The keyboard tables may give us different keypad codes according to
         * whether NumLock is pressed.  Use this check to simplify the process
         * of determining whether we generate an escape sequence for a keypad
-        * key, or use the string returned by the keyboard tables.  There is no
 -        * fixed modifier for this feature, so we assume that it is the one
 -        * assigned to the NumLock key.
 +        * key, or force it to the value kypd_num[].  There is no fixed
 +        * modifier for this feature, so we assume that it is the one assigned
 +        * to the NumLock key.
 +        *
+        * This check used to try to return the contents of strbuf, but that
 +        * does not work properly when a control modifier is given (trash is
 +        * returned in the buffer in some cases -- perhaps an X bug).
          */
 #if OPT_NUM_LOCK
        if (nbytes == 1
         && IsKeypadKey(keysym)
         && term->misc.real_NumLock
         && (term->misc.num_lock & event->state) != 0) {
-               keysym = *string;
 -               TRACE(("...Input num_lock, change keysym to %#04lx\n", keysym))
 +               keypad_mode = 0;
 +               TRACE(("...Input num_lock, force keypad_mode off\n"))
         }
 #endif
 
+       /*
+        * If we are in the normal (possibly Sun/PC) keyboard state, allow
 +        * modifiers to add a parameter to the function-key control sequences.
 +        */
+       if (event->state != 0
 +        && !(IsKeypadKey(keysym) && keypad_mode)
 +#if OPT_SUNPC_KBD
+        && !sunKeyboard
 +#endif
+#if OPT_VT52_MODE
+        && screen->ansi_level != 0
 +#endif
+       ) {
+#define ModifierParm(ctl,normal) \
 +           modify_parm = (event->state & ControlMask) ? ctl : normal
 +#if OPT_NUM_LOCK
+           if (term->misc.real_NumLock
 +            && (event->state & term->misc.alt_left
 +             || event->state & term->misc.alt_right)) {
 +               if (event->state & ShiftMask) {
 +                   ModifierParm(8, 4);
 +               } else {
 +                   ModifierParm(7, 3);
 +               }
 +           } else
 +#endif
+           if (event->state & ShiftMask) {
 +               ModifierParm(6, 2);
 +           } else {
 +               ModifierParm(5, 1);
 +           }
 +       }
+
  #if OPT_SHIFT_KEYS
        if (term->misc.shift_keys
         && (event->state & ShiftMask) != 0) {
@@ -328,20 +378,6 @@
                }
        }
 
-       /*
-        * VT220 & up:  users expect that the Delete key on the editing keypad
 -        * should be mapped to \E[3~.  However, we won't get there unless it is
 -        * treated as a keypad key, which XK_Delete is not.  This presumes that
 -        * we have a backarrow key to supply a DEL character, which is still
 -        * needed in a number of applications.
 -        */
-#ifdef XK_KP_Delete
 -       if (keysym == XK_Delete) {
 -               keysym = XK_KP_Delete;
 -               TRACE(("...Input delete changed to %#04lx\n", keysym))
 -       }
-#endif
 -
        /* VT300 & up: backarrow toggle */
        if ((nbytes == 1)
         && (((term->keyboard.flags & MODE_DECBKM) == 0)
@@ -370,6 +406,7 @@
        if (hpFunctionKeys
         && (reply.a_final = hpfuncvalue (keysym)) != 0) {
                reply.a_type = ESC;
+               MODIFIER_PARM
                 unparseseq(&reply, pty);
        } else
 #endif
@@ -377,6 +414,7 @@
                reply.a_type = SS3;
                reply.a_final = keysym-XK_KP_F1+'P';
                VT52_CURSOR_KEYS
+               MODIFIER_PARM
                 unparseseq(&reply, pty);
                key = TRUE;
 #if 0  /* OPT_SUNPC_KBD should suppress - but only for vt220 compatibility */
@@ -392,11 +430,13 @@
                        reply.a_type = SS3;
                        reply.a_final = curfinal[keysym-XK_Home];
                        VT52_CURSOR_KEYS
+                       MODIFIER_PARM
                         unparseseq(&reply, pty);
                } else {
                        reply.a_type = CSI;
                        if_OPT_VT52_MODE(screen,{ reply.a_type = ESC; })
                        reply.a_final = curfinal[keysym-XK_Home];
+                       MODIFIER_PARM
                         unparseseq(&reply, pty);
                }
                key = TRUE;
@@ -404,10 +444,11 @@
                || IsMiscFunctionKey(keysym)
                || IsEditFunctionKey(keysym)) {
 #if OPT_SUNPC_KBD
-               if ((event->state & ControlMask)
 -                && sunKeyboard
 -                && (keysym >= XK_F1 && keysym <= XK_F12))
 -                       keysym += 12;
 +               if (sunKeyboard) {
 +                       if ((event->state & ControlMask)
 +                        && (keysym >= XK_F1 && keysym <= XK_F12))
 +                               keysym += 12;
 +               }
  #endif
 
                dec_code = decfuncvalue(keysym);
@@ -427,6 +468,7 @@
                        reply.a_type = SS3;
                        VT52_CURSOR_KEYS
                        reply.a_final = dec_code - 11 + 'P';
+                       MODIFIER_PARM
                         unparseseq(&reply, pty);
                }
 #endif
@@ -440,15 +482,17 @@
                                reply.a_param[0] = dec_code;
                                reply.a_final = '~';
                        }
+                       MODIFIER_PARM
                         if (reply.a_param[0] > 0)
                                unparseseq(&reply, pty);
                }
                key = TRUE;
        } else if (IsKeypadKey(keysym)) {
-               if ((keyboard->flags & MODE_DECKPAM) != 0) {
 +               if (keypad_mode) {
                         reply.a_type  = SS3;
                        reply.a_final = kypd_apl[keysym-XK_KP_Space];
                        VT52_KEYPAD
+                       MODIFIER_PARM
                         unparseseq(&reply, pty);
                } else {
                        unparseputc(kypd_num[keysym-XK_KP_Space], pty);
@@ -665,6 +709,16 @@
                        TRACE(("numlock mask %#lx is%s modifier\n",
                                term->misc.num_lock,
                                ModifierName(term->misc.num_lock)))
+                   } else if (keysym == XK_Alt_L) {
 +                       term->misc.alt_left = (1<<i);
 +                       TRACE(("alt_left mask %#lx is%s modifier\n",
 +                               term->misc.alt_left,
 +                               ModifierName(term->misc.alt_left)))
 +                   } else if (keysym == XK_Alt_R) {
 +                       term->misc.alt_right = (1<<i);
 +                       TRACE(("alt_right mask %#lx is%s modifier\n",
 +                               term->misc.alt_right,
 +                               ModifierName(term->misc.alt_right)))
                     }
                }
                k++;
Index: main.c
--- xterm-93+/main.c    Sun Mar 14 14:59:36 1999
 +++ xterm-94/main.c     Wed Mar 24 17:50:15 1999
 @@ -148,7 +148,7 @@
  static Bool IsPts = False;
 #endif
 
-#if defined(ATT) && !defined(__sgi)
 +#if (defined(ATT) && !defined(__sgi)) || (defined(SYSV) && defined(i386)) || (defined (__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1))
  #define USE_USG_PTYS
 #else
 #define USE_HANDSHAKE
@@ -563,10 +563,10 @@
 #ifdef TIOCLSET
 static unsigned int d_lmode;
 #endif /* TIOCLSET */
-#else /* not USE_SYSV_TERMIO */
-#ifdef USE_POSIX_TERMIOS
 +
+#elif defined(USE_POSIX_TERMIOS)
 static struct termios d_tio;
-#else /* not USE_POSIX_TERMIOS */
 +#else /* !USE_SYSV_TERMIO && !USE_POSIX_TERMIOS */
  static struct  sgttyb d_sg = {
         0, 0, 0177, CKILL, EVENP|ODDP|ECHO|XTABS|CRMOD
 };
@@ -586,7 +586,6 @@
        'J', 'B'
 };
 #endif /* sony */
-#endif /* USE_POSIX_TERMIOS */
 #endif /* USE_SYSV_TERMIO */
 
 /* allow use of system default characters if defined and reasonable */
@@ -602,6 +601,9 @@
 #ifndef CEOL
 #define CEOL 0
 #endif
+#ifndef CNUL
+#define CNUL 0
+#endif
 #ifndef CSWTCH
 #define CSWTCH 0
 #endif
@@ -673,6 +675,8 @@
 { NULL, 0, 0, '\0' },                  /* end of data */
 };
 
+#define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value
 +
 static int parse_tty_modes (char *s, struct _xttymodes *modelist);
 
 #ifdef USE_SYSV_UTMP
@@ -1463,7 +1467,7 @@
        d_lmode = 0;
 #endif /* } TIOCLSET */
 #endif  /* } macII, ATT, CRAY */
-#endif /* MINIX, etc */
+#endif /* } MINIX, etc */
  #endif  /* AMOEBA */
 
        /* Init the Toolkit. */
@@ -1885,7 +1889,7 @@
          */
         if (pty_search(pty) == 0)
            return 0;
-#elif defined(ATT) && !defined(__sgi)
 +#elif defined(USE_USG_PTYS)
        if ((*pty = open ("/dev/ptmx", O_RDWR)) < 0) {
            return 1;
        }
@@ -2286,7 +2290,7 @@
                no_dev_tty = FALSE;
                if (tty < 0) {
                        if (tty_got_hung || errno == ENXIO || errno == EIO ||
-                           errno == EINVAL || errno == ENOTTY) {
 +                           errno == EINVAL || errno == ENOTTY || errno == EACCES) {
                                 no_dev_tty = TRUE;
 #ifdef HAS_LTCHARS
                                ltc = d_ltc;
@@ -2514,6 +2518,7 @@
                if ((ptyfd = open (ptsname(screen->respond), O_RDWR)) < 0) {
                    SysError (1);
                }
+#ifdef I_PUSH
                if (ioctl (ptyfd, I_PUSH, "ptem") < 0) {
                    SysError (2);
                }
@@ -2530,6 +2535,7 @@
                    SysError (5);
                }
 #endif /* SVR4 */
+#endif
                tty = ptyfd;
                close (screen->respond);
 #ifdef TIOCSWINSZ
@@ -2795,7 +2801,6 @@
 #ifdef VDSUSP
                    tio.c_cc[VDSUSP] = CDSUSP;
 #endif
-#define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value;
                     if (override_tty_modes) {
                        /* sysv-specific */
                        TMODE (XTTYMODE_intr, tio.c_cc[VINTR]);
@@ -2850,7 +2855,6 @@
                        TMODE (XTTYMODE_lnext, ltc.t_lnextc);
 #endif
                    }
-#undef TMODE
 
 #ifdef HAS_LTCHARS
 #ifdef __hpux
@@ -2891,7 +2895,8 @@
                    jmode &= ~KM_KANJI;
 #endif /* sony */
 
-#define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value;
 +                   ltc = d_ltc;
 +
                    if (override_tty_modes) {
                        TMODE (XTTYMODE_intr, tc.t_intrc);
                        TMODE (XTTYMODE_quit, tc.t_quitc);
@@ -2909,7 +2914,6 @@
                        TMODE (XTTYMODE_weras, ltc.t_werasc);
                        TMODE (XTTYMODE_lnext, ltc.t_lnextc);
                    }
-#undef TMODE
 
                    if (ioctl (tty, TIOCSETP, (char *)&sg) == -1)
                            HsSysError (cp_pipe[1], ERROR_TIOCSETP);
Index: menu.c
--- xterm-93+/menu.c    Sun Feb  7 12:54:50 1999
 +++ xterm-94/menu.c     Fri Mar 26 18:36:19 1999
 @@ -101,6 +101,10 @@
  static void do_hp_fkeys        PROTO_XT_CALLBACK_ARGS;
 #endif
 
+#if OPT_NUM_LOCK
+static void do_num_lock        PROTO_XT_CALLBACK_ARGS;
 +#endif
+
 #if OPT_SUNPC_KBD
 static void do_sun_kbd         PROTO_XT_CALLBACK_ARGS;
 #endif
@@ -139,6 +143,9 @@
     { "line1",         NULL,           NULL },
     { "8-bit control", do_8bit_control, NULL },
     { "backarrow key", do_backarrow,   NULL },
+#if OPT_NUM_LOCK
+    { "num-lock",      do_num_lock,    NULL },
 +#endif
     { "sun function-keys",do_sun_fkeys,        NULL },
 #if OPT_SUNPC_KBD
     { "sun keyboard",  do_sun_kbd,     NULL },
@@ -196,6 +203,7 @@
     { "font4",         do_vtfont,      NULL },
     { "font5",         do_vtfont,      NULL },
     { "font6",         do_vtfont,      NULL },
+    /* this is after the last builtin font; the other entries are special */
      { "fontescape",    do_vtfont,      NULL },
     { "fontsel",       do_vtfont,      NULL },
     /* down to here should match NMENUFONTS in ptyx.h */
@@ -235,15 +243,6 @@
 
 static void handle_send_signal (Widget gw, int sig);
 
-static void handle_toggle (
-               void (*proc)PROTO_XT_CALLBACK_ARGS,
 -               int var,
 -               String *params,
 -               Cardinal nparams,
 -               Widget w,
 -               XtPointer closure,
 -               XtPointer data);
 -
 extern Widget toplevel;
 
 
@@ -284,11 +283,10 @@
                                            XtNumber(mainMenuEntries));
            update_securekbd();
            update_allowsends();
-#ifdef ALLOWLOGGING
            update_logging();
-#endif
            update_8bit_control();
            update_decbkm();
+           update_num_lock();
             update_sun_kbd();
            if (screen->terminal_id < 200) {
                set_sensitivity (screen->mainMenu,
@@ -587,6 +585,18 @@
     update_sun_fkeys();
 }
 
+#if OPT_NUM_LOCK
+static void do_num_lock (
+       Widget gw GCC_UNUSED,
 +       XtPointer closure GCC_UNUSED,
 +       XtPointer data GCC_UNUSED)
 +{
+    term->misc.real_NumLock = ! term->misc.real_NumLock;
 +    update_num_lock();
+}
 +#endif
+
+
 #if OPT_SUNPC_KBD
 static void do_sun_kbd (
        Widget gw GCC_UNUSED,
@@ -723,7 +733,10 @@
 {
     term->flags ^= REVERSE_VIDEO;
     ReverseVideo (term);
-    /* update_reversevideo done in ReverseVideo */
 +
+    /* cancel out the internal state changes, so menus are decoupled */
 +    term->flags ^= REVERSE_VIDEO;
 +    term->misc.re_verse = !term->misc.re_verse;
  }
 
 
@@ -1309,6 +1322,18 @@
                   params, *param_count, w, (XtPointer)0, (XtPointer)0);
 }
 
+#if OPT_NUM_LOCK
+void HandleNumLock(
+       Widget w,
 +       XEvent *event GCC_UNUSED,
 +       String *params,
 +       Cardinal *param_count)
 +{
+    handle_toggle (do_num_lock, (int) term->misc.real_NumLock,
 +                  params, *param_count, w, (XtPointer)0, (XtPointer)0);
 +}
+#endif
+
 #if OPT_SUNPC_KBD
 void HandleSunKeyboard(
        Widget w,
@@ -1359,7 +1384,7 @@
        String *params,
        Cardinal *param_count)
 {
-    handle_toggle (do_reversevideo, (int) (term->flags & REVERSE_VIDEO),
 +    handle_toggle (do_reversevideo, (int) (term->misc.re_verse0),
                    params, *param_count, w, (XtPointer)0, (XtPointer)0);
 }
 
Index: menu.h
--- xterm-93+/menu.h    Sun Feb  7 12:54:50 1999
 +++ xterm-94/menu.h     Fri Mar 26 18:33:32 1999
 @@ -70,6 +70,7 @@
  extern void HandleHpFunctionKeys   PROTO_XT_ACTIONS_ARGS;
 extern void HandleJumpscroll       PROTO_XT_ACTIONS_ARGS;
 extern void HandleLogging          PROTO_XT_ACTIONS_ARGS;
+extern void HandleNumLock          PROTO_XT_ACTIONS_ARGS;
  extern void HandleMarginBell       PROTO_XT_ACTIONS_ARGS;
 extern void HandlePopupMenu        PROTO_XT_ACTIONS_ARGS;
 extern void HandlePrint            PROTO_XT_ACTIONS_ARGS;
@@ -114,6 +115,9 @@
     mainMenu_line1,
     mainMenu_8bit_ctrl,
     mainMenu_backarrow,
+#if OPT_NUM_LOCK
+    mainMenu_num_lock,
+#endif
      mainMenu_sun_fkeys,
 #if OPT_SUNPC_KBD
     mainMenu_sun_kbd,
@@ -161,9 +165,11 @@
     vtMenu_hardreset,
     vtMenu_clearsavedlines,
     vtMenu_line2,
+#if OPT_TEK4014
     vtMenu_tekshow,
     vtMenu_tekmode,
     vtMenu_vthide,
+#endif
     vtMenu_altscreen,
     vtMenu_LAST
 } vtMenuIndices;
@@ -185,9 +191,13 @@
 /* number of non-line items down to here should match NMENUFONTS in ptyx.h */
 #if OPT_DEC_CHRSET
     fontMenu_line1,
+#if OPT_DEC_CHRSET
     fontMenu_font_doublesize,
+#endif
+#if OPT_DEC_SOFTFONT
     fontMenu_font_loadable,
 #endif
+#endif
     fontMenu_LAST
 } fontMenuIndices;
 
@@ -195,6 +205,7 @@
 /*
  * items in tek4014 mode menu
  */
+#if OPT_TEK4014
 typedef enum {
     tekMenu_tektextlarge,
     tekMenu_tektext2,
@@ -210,6 +221,7 @@
     tekMenu_tekhide,
     tekMenu_LAST
 } tekMenuIndices;
+#endif
 
 
 /*
@@ -243,6 +255,8 @@
   update_menu_item (term->screen.mainMenu, \
                    mainMenuEntries[mainMenu_logging].widget, \
                    term->screen.logging)
+#else
+#define update_logging() /*nothing*/
 #endif
 
 #define update_8bit_control() \
@@ -254,6 +268,15 @@
   update_menu_item (term->screen.mainMenu, \
                    mainMenuEntries[mainMenu_backarrow].widget, \
                    term->keyboard.flags & MODE_DECBKM)
+
+#if OPT_NUM_LOCK
+#define update_num_lock() \
+  update_menu_item (term->screen.mainMenu, \
 +                   mainMenuEntries[mainMenu_num_lock].widget, \
 +                   term->misc.real_NumLock)
 +#else
+#define update_num_lock() /*nothing*/
+#endif
  
 #define update_sun_fkeys() \
   update_menu_item (term->screen.mainMenu, \
Index: misc.c
--- xterm-93+/misc.c    Sun Mar 14 14:59:36 1999
 +++ xterm-94/misc.c     Sat Mar 27 17:28:14 1999
 @@ -113,7 +113,7 @@
                    (event.xcrossing.window == XtWindow(XtParent(term))))
 #endif
 
-static Boolean ChangeColorsRequest (XtermWidget pTerm, int start, char *names);
 +static Boolean ChangeColorsRequest (XtermWidget pTerm, int start, char *names, int final);
  static void DoSpecialEnterNotify (XEnterWindowEvent *ev);
 static void DoSpecialLeaveNotify (XEnterWindowEvent *ev);
 static void selectwindow (TScreen *screen, int flag);
@@ -945,15 +945,20 @@
 #endif /* ALLOWLOGGING */
 
 void
-do_osc(Char *oscbuf, int len GCC_UNUSED)
 +do_osc(Char *oscbuf, int len GCC_UNUSED, int final)
  {
+       register TScreen *screen = &(term->screen);
         register int mode;
        register Char *cp;
        int state = 0;
        char *buf = 0;
 
        /*
-        * lines should be of the form <OSC> number ; string <ST>
 +        * Lines should be of the form <OSC> number ; string <ST>, however
 +        * older xterms can accept <BEL> as a final character.  We will respond
 +        * with the same final character as the application sends to make this
 +        * work better with shell scripts, which may have trouble reading an
 +        * <ESC><backslash>, which is the 7-bit equivalent to <ST>.
          */
        mode = 0;
        for (cp = oscbuf; *cp != '\0'; cp++) {
@@ -993,14 +998,12 @@
                Changetitle(buf);
                break;
 
-        case 10:       case 11:        case 12:
 -        case 13:       case 14:        case 15:
 -        case 16:
 -               {
 -                   if (term->misc.dynamicColors)
 -                       ChangeColorsRequest(term,mode-10,buf);
 -               }
 -               break;
 +       case 10:        case 11:        case 12:
 +       case 13:        case 14:        case 15:
 +       case 16:        case 17:
 +               if (term->misc.dynamicColors)
 +                      ChangeColorsRequest(term, mode-10, buf, final);
 +               break;
  
 #ifdef ALLOWLOGGING
         case 46:       /* new log file */
@@ -1009,21 +1012,74 @@
                 * Warning, enabling this feature allows people to overwrite
                 * arbitrary files accessible to the person running xterm.
                 */
-               if((cp = malloc((unsigned)strlen(buf) + 1)) == NULL)
 +               if (buf != 0
 +                && strcmp(buf, "?")
 +                && ((cp = malloc((unsigned)strlen(buf) + 1)) != NULL) {
 +                       strcpy(cp, buf);
 +                       if(screen->logfile)
 +                               free(screen->logfile);
 +                       screen->logfile = cp;
                         break;
-               strcpy(cp, buf);
 -               if(term->screen.logfile)
 -                       free(term->screen.logfile);
 -               term->screen.logfile = cp;
 -#else
+               }
 +#endif
                Bell(XkbBI_Info,0);
                Bell(XkbBI_Info,0);
-#endif
                break;
 #endif /* ALLOWLOGGING */
 
        case 50:
-               SetVTFont (fontMenu_fontescape, True, buf, NULL);
 +               if (buf != 0 && !strcmp(buf, "?")) {
 +                   int num = screen->menu_font_number;
 +
+                   unparseputc1(OSC,   screen->respond);
 +                   unparseputs("50",   screen->respond);
 +
+                   if ((buf = screen->menu_font_names[num]) != 0) {
 +                       unparseputc(';', screen->respond);
 +                       unparseputs(buf, screen->respond);
 +                   }
 +                   unparseputc1(final,    screen->respond);
 +               } else {
 +                   /*
 +                    * If the font specification is a "#", followed by an
 +                    * optional sign and optional number, lookup the
 +                    * corresponding menu font entry.
 +                    */
 +                   if (buf != 0 && *buf == '#') {
 +                       int num = screen->menu_font_number;
 +                       int rel = 0;
 +
+                       if (*++buf == '+') {
 +                           rel = 1;
 +                           buf++;
 +                       } else if (*buf == '-') {
 +                           rel = -1;
 +                           buf++;
 +                       }
 +
+                       if (isdigit(*buf)) {
 +                           int val = atoi(buf);
 +                           if (rel > 0)
 +                               num += val;
 +                           else if (rel < 1)
 +                               num -= val;
 +                           else
 +                               num = val;
 +                       } else if (rel) {
 +                           num += rel;
 +                       } else {
 +                           num = 0;
 +                       }
 +
+                       if (num < 0
 +                        || num > fontMenu_lastBuiltin 
 +                        || (buf = screen->menu_font_names[num]) == 0) {
 +                           Bell(XkbBI_MinorError,0);
 +                           break;
 +                       }
 +                   }
 +                   SetVTFont (fontMenu_fontescape, True, buf, NULL);
 +               }
                 break;
 
        /*
@@ -1121,8 +1177,7 @@
                        unparseputc('r', screen->respond);
                        if (okay)
                                cp = reply;
-                       while (*cp != '\0')
 -                               unparseputc(*cp++, screen->respond);
 +                       unparseputs(cp, screen->respond);
                         unparseputc1(ST, screen->respond);
                } else {
                        unparseputc(CAN, screen->respond);
@@ -1227,6 +1282,8 @@
 void
 Changename(register char *name)
 {
+    if (name == 0)
 +       name = "";
  #if OPT_ZICONBEEP      /* If warning should be given then give it */
     if ( zIconBeep && zIconBeep_flagged ) {
        char *newname = (char *)malloc(strlen(name)+ 4 + 1);
@@ -1257,22 +1314,41 @@
 GetOldColors(XtermWidget pTerm)
 {
 int    i;
-    if (pOldColors==NULL) {
 -       pOldColors=     (ScrnColors *)XtMalloc(sizeof(ScrnColors));
 -       if (pOldColors==NULL) {
 +    if (pOldColors == NULL) {
 +       pOldColors = (ScrnColors *)XtMalloc(sizeof(ScrnColors));
 +       if (pOldColors == NULL) {
             fprintf(stderr,"allocation failure in GetOldColors\n");
            return(FALSE);
        }
-       pOldColors->which=      0;
 -       for (i=0;i<NCOLORS;i++) {
 -           pOldColors->colors[i]=      0;
 -           pOldColors->names[i]=       NULL;
 +       pOldColors->which = 0;
 +       for (i = 0; i < NCOLORS; i++) {
 +           pOldColors->colors[i] = 0;
 +           pOldColors->names[i] = NULL;
         }
        GetColors(pTerm,pOldColors);
     }
     return(TRUE);
 }
 
+static void ReportColorRequest(XtermWidget pTerm, int ndx, int final)
 +{
+       XColor color;
 +       Colormap cmap = pTerm->core.colormap;
 +       char buffer[80];
 +
+       GetOldColors(pTerm);
 +       color.pixel = pOldColors->colors[ndx];
 +       TRACE(("ReportColors %d: %#lx\n", ndx, pOldColors->colors[ndx]))
 +       XQueryColor(term->screen.display, cmap, &color);
 +       sprintf(buffer, "%d;rgb:%04x/%04x/%04x", ndx + 10,
 +               color.red,
 +               color.green,
 +               color.blue);
 +       unparseputc1(OSC,   pTerm->screen.respond);
 +       unparseputs(buffer, pTerm->screen.respond);
 +       unparseputc1(final, pTerm->screen.respond);
 +}
+
 static Boolean
 UpdateOldColors(
        XtermWidget     pTerm GCC_UNUSED,
@@ -1287,16 +1363,16 @@
      * (clearly) fails is if someone is trying a boatload of colors, in
      * which case they can restart xterm
      */
-    for (i=0;i<NCOLORS;i++) {
 -       if (COLOR_DEFINED(pNew,i)) {
 -           if (pOldColors->names[i]!=NULL) {
 +    for (i = 0; i < NCOLORS; i++) {
 +       if (COLOR_DEFINED(pNew, i)) {
 +           if (pOldColors->names[i] != NULL) {
                 XtFree(pOldColors->names[i]);
-               pOldColors->names[i]= NULL;
 +               pOldColors->names[i] = NULL;
             }
            if (pNew->names[i]) {
-               pOldColors->names[i]= pNew->names[i];
 +               pOldColors->names[i] = pNew->names[i];
             }
-           pOldColors->colors[i]=      pNew->colors[i];
 +           pOldColors->colors[i] = pNew->colors[i];
         }
     }
     return(TRUE);
@@ -1311,14 +1387,14 @@
 
     if (pOld) {
        /* change text cursor, if necesary */
-       if (pOld->colors[TEXT_CURSOR]==pOld->colors[TEXT_FG]) {
 -           pOld->colors[TEXT_CURSOR]=  pOld->colors[TEXT_BG];
 +       if (pOld->colors[TEXT_CURSOR] == pOld->colors[TEXT_FG]) {
 +           pOld->colors[TEXT_CURSOR] =  pOld->colors[TEXT_BG];
             if (pOld->names[TEXT_CURSOR]) {
                XtFree(pOldColors->names[TEXT_CURSOR]);
-               pOld->names[TEXT_CURSOR]= NULL;
 +               pOld->names[TEXT_CURSOR] = NULL;
             }
            if (pOld->names[TEXT_BG]) {
-               tmpName= XtMalloc(strlen(pOld->names[TEXT_BG])+1);
 +               tmpName = XtMalloc(strlen(pOld->names[TEXT_BG])+1);
                 if (tmpName) {
                    strcpy(tmpName,pOld->names[TEXT_BG]);
                    pOld->names[TEXT_CURSOR]= tmpName;
@@ -1326,29 +1402,14 @@
            }
        }
 
-       /* swap text FG and BG */
 -       tmpPix=         pOld->colors[TEXT_FG];
 -       tmpName=        pOld->names[TEXT_FG];
 -       pOld->colors[TEXT_FG]=  pOld->colors[TEXT_BG];
 -       pOld->names[TEXT_FG]=   pOld->names[TEXT_BG];
 -       pOld->colors[TEXT_BG]=  tmpPix;
 -       pOld->names[TEXT_BG]=   tmpName;
 -
-       /* swap mouse FG and BG */
 -       tmpPix=         pOld->colors[MOUSE_FG];
 -       tmpName=        pOld->names[MOUSE_FG];
 -       pOld->colors[MOUSE_FG]= pOld->colors[MOUSE_BG];
 -       pOld->names[MOUSE_FG]=  pOld->names[MOUSE_BG];
 -       pOld->colors[MOUSE_BG]= tmpPix;
 -       pOld->names[MOUSE_BG]=  tmpName;
 -
-       /* swap Tek FG and BG */
 -       tmpPix=         pOld->colors[TEK_FG];
 -       tmpName=        pOld->names[TEK_FG];
 -       pOld->colors[TEK_FG]=   pOld->colors[TEK_BG];
 -       pOld->names[TEK_FG]=    pOld->names[TEK_BG];
 -       pOld->colors[TEK_BG]=   tmpPix;
 -       pOld->names[TEK_BG]=    tmpName;
 +       EXCHANGE(pOld->colors[TEXT_FG], pOld->colors[TEXT_BG], tmpPix);
 +       EXCHANGE(pOld->names[TEXT_FG],  pOld->names[TEXT_BG], tmpName);
 +
+       EXCHANGE(pOld->colors[MOUSE_FG],pOld->colors[MOUSE_BG], tmpPix);
 +       EXCHANGE(pOld->names[MOUSE_FG], pOld->names[MOUSE_BG], tmpName);
 +
+       EXCHANGE(pOld->colors[TEK_FG],  pOld->colors[TEK_BG], tmpPix);
 +       EXCHANGE(pOld->names[TEK_FG],   pOld->names[TEK_BG], tmpName);
      }
     return;
 }
@@ -1361,20 +1422,20 @@
        char            *name)
 {
 XColor                  def;
-register TScreen       *screen=        &pTerm->screen;
 -Colormap                cmap=          pTerm->core.colormap;
 +register TScreen       *screen =       &pTerm->screen;
 +Colormap                cmap =         pTerm->core.colormap;
  char                   *newName;
 
-    if ((XParseColor(screen->display,cmap,name,&def))&&
 -       (XAllocColor(screen->display,cmap,&def))) {
 -       SET_COLOR_VALUE(pNew,ndx,def.pixel);
 -       newName= XtMalloc(strlen(name)+1);
 -       if (newName) {
 -           strcpy(newName,name);
 -           SET_COLOR_NAME(pNew,ndx,newName);
 -       }
+    if (XParseColor(screen->display, cmap, name, &def)
 +     && XAllocColor(screen->display, cmap, &def)
 +     && (newName = XtMalloc(strlen(name)+1)) != 0) {
 +       SET_COLOR_VALUE(pNew, ndx, def.pixel);
 +       strcpy(newName, name);
 +       SET_COLOR_NAME(pNew, ndx, newName);
 +       TRACE(("AllocateColor #%d: %s (pixel %#lx)\n", ndx, newName, def.pixel))
         return(TRUE);
     }
+    TRACE(("AllocateColor #%d: %s (failed)\n", ndx, name))
      return(FALSE);
 }
 
@@ -1382,46 +1443,53 @@
 ChangeColorsRequest(
        XtermWidget     pTerm,
        int             start,
-       register char   *names)
 +       register char   *names,
 +       int             final)
  {
 char           *thisName;
 ScrnColors     newColors;
-int            i,ndx;
 +int            i, ndx;
 +
+    TRACE(("ChangeColorsRequest start=%d, names='%s'\n", start, names))
  
-    if ((pOldColors==NULL)&&(!GetOldColors(pTerm))) {
 +    if ((pOldColors == NULL)
 +     && (!GetOldColors(pTerm))) {
         return(FALSE);
     }
-    newColors.which=   0;
 -    for (i=0;i<NCOLORS;i++) {
 -       newColors.names[i]=     NULL;
 -    }
-    for (i=start;i<NCOLORS;i++) {
 -       if (term->misc.re_verse)        ndx=    OPPOSITE_COLOR(i);
 -       else                            ndx=    i;
 -       if ((names==NULL)||(names[0]=='\0')) {
 -           newColors.names[ndx]=       NULL;
 +    newColors.which = 0;
 +    for (i = 0; i < NCOLORS; i++) {
 +       newColors.names[i] = NULL;
 +    }
+    for (i = start; i < NCOLORS; i++) {
 +       if (term->misc.re_verse)        ndx = OPPOSITE_COLOR(i);
 +       else                            ndx = i;
 +       if ((names == NULL) || (names[0] == '\0')) {
 +           newColors.names[ndx] = NULL;
         }
        else {
-           if (names[0]==';')
 +           if (names[0] == ';')
                  thisName=      NULL;
            else thisName=      names;
-           names = strchr(names,';');
 -           if (names!=NULL) {
 +           names = strchr(names, ';');
 +           if (names != NULL) {
                 *names= '\0';
                names++;
            }
-           if ((!pOldColors->names[ndx])||
 -               (thisName&&(strcmp(thisName,pOldColors->names[ndx])))) {
 -               AllocateColor(pTerm,&newColors,ndx,thisName);
 +           if (thisName != 0 && !strcmp(thisName, "?"))
 +               ReportColorRequest(pTerm, ndx, final);
 +           else if (!pOldColors->names[ndx]
 +            || (thisName
 +             && strcmp(thisName, pOldColors->names[ndx]))) {
 +               AllocateColor(pTerm, &newColors, ndx, thisName);
             }
        }
     }
 
-    if (newColors.which==0)
 +    if (newColors.which == 0)
         return(TRUE);
 
-    ChangeColors(pTerm,&newColors);
 -    UpdateOldColors(pTerm,&newColors);
 +    ChangeColors(pTerm, &newColors);
 +    UpdateOldColors(pTerm, &newColors);
      return(TRUE);
 }
 
Index: ptyx.h
--- xterm-93+/ptyx.h    Sun Mar 14 14:59:36 1999
 +++ xterm-94/ptyx.h     Wed Mar 24 05:39:09 1999
 @@ -967,7 +967,9 @@
  #endif
 #if OPT_NUM_LOCK
     Boolean real_NumLock;      /* true if we treat NumLock key specially */
-    unsigned long num_lock;
 +    unsigned long num_lock;    /* modifier for Num_Lock */
 +    unsigned long alt_left;    /* modifier for Alt_L */
 +    unsigned long alt_right;   /* modifier for Alt_R */
  #endif
 } Misc;
 
Index: resize.c
--- xterm-93+/resize.c  Sun Mar 14 14:59:36 1999
 +++ xterm-94/resize.c   Mon Mar 22 19:50:45 1999
 @@ -37,7 +37,7 @@
  #include <stdio.h>
 #include <ctype.h>
 
-#if defined(att) || (defined(SYSV) && defined(i386))
 +#if defined(att)
 #define ATT
 #endif
 
@@ -52,7 +52,7 @@
 #define ATT
 #endif
 
-#ifdef ATT
+#if (defined(ATT) && !defined(__sgi)) || (defined(SYSV) && defined(i386)) || (defined (__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1))
  #define USE_USG_PTYS
 #endif
 
@@ -122,10 +122,12 @@
 # endif /* USE_TERMIOS */
 #endif /* USE_SYSV_TERMIO */
 
+#ifdef SYSV
 #ifdef USE_USG_PTYS
 #include <sys/stream.h>
 #ifndef SVR4
 #include <sys/ptem.h>
+#endif
 #endif
 #endif
 
Index: screen.c
--- xterm-93+/screen.c  Sun Mar 14 14:59:36 1999
 +++ xterm-94/screen.c   Mon Mar 22 19:56:46 1999
 @@ -36,7 +36,12 @@
  
 #include <signal.h>
 
+#ifdef att
+#define ATT
+#endif
+
 #ifdef SVR4
+#undef SYSV
 #define SYSV
 #include <termios.h>
 #else
@@ -52,6 +57,10 @@
 
 #ifdef __hpux
 #include <sys/termio.h>
+#endif
+
+#if (defined(ATT) && !defined(__sgi)) || (defined(SYSV) && defined(i386)) || (defined (__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1))
 +#define USE_USG_PTYS
 #endif
 
 #ifdef SYSV
Index: scrollbar.c
--- xterm-93+/scrollbar.c       Sun Mar 14 14:59:36 1999
 +++ xterm-94/scrollbar.c        Sun Mar 21 19:19:08 1999
 @@ -218,7 +218,7 @@
         args[1].value = (XtArgVal) bg;
        nargs--;                                /* don't set border_pixmap */
        if (bdpix == XtUnspecifiedPixmap) {     /* if not pixmap then pixel */
-           args[2].value = (XtArgVal) bdr;     /* keep old border color */
 +           args[2].value = args[1].value;      /* keep border visible */
         } else {                                /* ignore since pixmap */
            nargs--;                            /* don't set border pixel */
        }
Index: termcap
--- xterm-93+/termcap   Sun Mar 14 14:59:36 1999
 +++ xterm-94/termcap    Sun Mar 21 15:50:23 1999
 @@ -127,6 +127,6 @@
  # This is the only entry which you should have to customize, since "xterm"
 # is widely used for a variety of incompatible terminal emulations including
 # color_xterm and rxvt.
-v0|xterm|X Windows terminal emulator:\
 +v0|xterm|X11 terminal emulator:\
        :tc=xterm-xfree86:
 #      :tc=xterm-r6:
Index: terminfo
--- xterm-93+/terminfo  Sun Mar 14 14:59:36 1999
 +++ xterm-94/terminfo   Sun Mar 21 15:51:43 1999
 @@ -133,18 +133,18 @@
         ind=^J,
        invis=\E[8m,
        is2=\E[!p\E[?3;4l\E[4l\E>,
-       ka1=\EOw,
-       ka3=\EOu,
 -       kb2=\EOy,
+       ka1=\EOH,
 +       ka3=\E[5~,
 +       kb2=\EOE,
        kbeg=\EOE,
        kbs=^H,
-       kc1=\EOq,
-       kc3=\EOs,
 +       kc1=\EOF,
+       kc3=\E[6~,
         kcub1=\EOD,
        kcud1=\EOB,
        kcuf1=\EOC,
        kcuu1=\EOA,
-       kdch1=\E[3~,
 +       kdch1=\177,
         kend=\EOF,
        kent=\EOM,
        kf1=\EOP,
@@ -221,11 +221,17 @@
 #      + uses DEC-style control sequences for the application keypad.
 #        
 xterm-vt220|XFree86 xterm emulating vt220,
+       ka1=\EOw,
+       ka3=\EOy,
 +       kb2=\EOu,
+       kbeg=\EOu,
 +       kc1=\EOq,
+       kc3=\EOs,
         kdch1=\E[3~,
        kend=\E[4~,
        khome=\E[1~,
        use=xterm-xfree86,
-
+#
 xterm-vt52|XFree86 xterm emulating dec vt52,
        cols#80,
        it#8,
@@ -253,7 +259,7 @@
        ri=\EI,
        rmacs=\EG,
        smacs=\EF,
-
+#
 # kf30-kf45 are keysyms XK_R1 through XK_R15 on the Sun keyboard.
 xterm-sun|XFree86 xterm with sun function keys,
        kb2=\E[218z,
@@ -293,7 +299,7 @@
        kich1=\E[2z,
        kpp=\E[216z,
        use=xterm,
-
+#
 xterm-hp|XFree86 xterm with hpterm function keys,
        kclr=\EJ,
        kcub1=\ED,
@@ -315,7 +321,7 @@
        knp=\ES,
        kpp=\ET,
        use=xterm,
-
+#
 # Other variants:
 xterm-24|xterms|vs100|xterm terminal emulator (X Window System),
        lines#24,
@@ -394,7 +400,7 @@
 # Originally I suppressed setaf/setab, since ANSI specifies only 8 colors, but
 # Stephen Marley persuaded me to allow the "ANSI" color controls to extend to
 # 16 colors.  (Note that ncurses 4.2 uses setf/setb from this description;
-# however 4.3 will select either according to their availability).  - T.Dickey
 +# however 5.0 selects either according to their availability).  - T.Dickey
  #
 # SVr4 curses does not use more than 8 colors anyway, so using 16 colors is
 # either for terminfo-level applications or via ncurses.
@@ -407,8 +413,10 @@
        setb=%p1%{8}%/%{6}%*%{4}%+\E[%d%p1%{8}%m%Pa%?%ga%{1}%=%t4%e%ga%{3}%=%t6%e%ga%{4}%=%t1%e%ga%{6}%=%t3%e%ga%d%;m,
        setf=%p1%{8}%/%{6}%*%{3}%+\E[%d%p1%{8}%m%Pa%?%ga%{1}%=%t4%e%ga%{3}%=%t6%e%ga%{4}%=%t1%e%ga%{6}%=%t3%e%ga%d%;m,
        use=xterm-xfree86,
+#
 # This is an 8-bit version of xterm, which emulates DEC vt220 with ANSI color.
-# To use it, your decTerminalID resource must be set to 200 or above.
 +# To use it, your decTerminalID resource must be set to 200 or above, and the
 +# sunKeyboard resource set to true.
  #
 #      HTS     \E H    \210
 #      RI      \E M    \215
@@ -742,6 +750,6 @@
 # This is the only entry which you should have to customize, since "xterm"
 # is widely used for a variety of incompatible terminal emulations including
 # color_xterm and rxvt.
-xterm|X Windows terminal emulator,
+xterm|X11 terminal emulator,
         use=xterm-xfree86,
 #      use=xterm-r6,
Index: version.h
--- xterm-93+/version.h Sun Mar 14 14:59:36 1999
 +++ xterm-94/version.h  Sat Mar 27 16:51:32 1999
 @@ -6,4 +6,4 @@
   * version of xterm has been built.  The number in parentheses is my patch
  * number (T.Dickey).
  */
-#define XTERM_VERSION "XFree86 3.9Pd(93)"
 +#define XTERM_VERSION "XFree86 3.9Pf(94)"
 Index: vttests/16colors.sh
--- /dev/null   Sun Jul 17 19:46:18 1994
 +++ xterm-94/vttests/16colors.sh        Sat Mar 27 12:15:14 1999
 @@ -0,0 +1,63 @@
 +#!/bin/sh
+# $XFree86$
+#
+# -- Thomas Dickey (1999/3/27)
+# Show a simple 16-color test pattern.  It is a little more confusing than
 +# 8colors.sh, since everything is abbreviated to fit on an 80-column line.
 +# The high (8-15) combinations for foreground or background are marked with
 +# a '+' sign.
+
+trap 'echo -n "^[[0m"; exit' 0 1 2 5 15
 +echo "^[[0m"
+while true
+do
+    for AT in 0 1 4 7
 +    do
+       case $AT in
 +       0) attr="   ";;
 +       1) attr="BO ";;
 +       4) attr="UN ";;
 +       7) attr="RV ";;
 +       esac
+       for FG in 0 1 2 3 4 5 6 7
 +       do
+           case $FG in
 +           0) fcolor="BLK ";;
 +           1) fcolor="RED ";;
 +           2) fcolor="GRN ";;
 +           3) fcolor="YEL ";;
 +           4) fcolor="BLU ";;
 +           5) fcolor="MAG ";;
 +           6) fcolor="CYN ";;
 +           7) fcolor="WHT ";;
 +           esac
+           for HI in 3 9
 +           do
 +               if test $HI = 3 ; then
 +                   color=" $fcolor"
 +               else
 +                   color="+$fcolor"
 +               fi
 +               echo -n "^[[0;${AT}m$attr"
 +               echo -n "^[[${HI}${FG}m$color"
 +               for BG in 1 2 3 4 5 6 7
 +               do
 +                   case $BG in
 +                   0) bcolor="BLK ";;
 +                   1) bcolor="RED ";;
 +                   2) bcolor="GRN ";;
 +                   3) bcolor="YEL ";;
 +                   4) bcolor="BLU ";;
 +                   5) bcolor="MAG ";;
 +                   6) bcolor="CYN ";;
 +                   7) bcolor="WHT ";;
 +                   esac
 +                   echo -n "^[[4${BG}m$bcolor"
 +                   echo -n "^[[10${BG}m+$bcolor"
 +               done
 +               echo "^[[0m"
 +           done
 +       done
+       sleep 1
 +    done
+done
Index: vttests/8colors.sh
--- /dev/null   Sun Jul 17 19:46:18 1994
 +++ xterm-94/vttests/8colors.sh Sat Mar 27 12:15:19 1999
 @@ -0,0 +1,51 @@
 +#!/bin/sh
+# $XFree86$
+#
+# -- Thomas Dickey (1999/3/27)
+# Show a simple 8-color test pattern
 +
+trap 'echo -n "^[[0m"; exit' 0 1 2 5 15
 +echo "^[[0m"
+while true
+do
+    for AT in 0 1 4 7
 +    do
+       case $AT in
 +       0) attr="normal  ";;
 +       1) attr="bold    ";;
 +       4) attr="under   ";;
 +       7) attr="reverse ";;
 +       esac
+       for FG in 0 1 2 3 4 5 6 7
 +       do
+           case $FG in
 +           0) fcolor="black   ";;
 +           1) fcolor="red     ";;
 +           2) fcolor="green   ";;
 +           3) fcolor="yellow  ";;
 +           4) fcolor="blue    ";;
 +           5) fcolor="magenta ";;
 +           6) fcolor="cyan    ";;
 +           7) fcolor="white   ";;
 +           esac
 +           echo -n "^[[0;${AT}m$attr"
 +           echo -n "^[[3${FG}m$fcolor"
 +           for BG in 1 2 3 4 5 6 7
 +           do
 +               case $BG in
 +               0) bcolor="black   ";;
 +               1) bcolor="red     ";;
 +               2) bcolor="green   ";;
 +               3) bcolor="yellow  ";;
 +               4) bcolor="blue    ";;
 +               5) bcolor="magenta ";;
 +               6) bcolor="cyan    ";;
 +               7) bcolor="white   ";;
 +               esac
 +               echo -n "^[[4${BG}m$bcolor"
 +           done
 +           echo "^[[0m"
 +       done
+       sleep 1
 +    done
+done
Index: vttests/dynamic.sh
--- /dev/null   Sun Jul 17 19:46:18 1994
 +++ xterm-94/vttests/dynamic.sh Sat Mar 27 17:19:38 1999
 @@ -0,0 +1,28 @@
 +#!/bin/sh
+# $XFree86$
+#
+# -- Thomas Dickey (1999/3/27)
+# Demonstrate the use of dynamic colors by setting the background successively
 +# to different values.
+
 +LIST="00 30 d0 ff"
+
 +exec </dev/tty
+old=`stty -g`
+stty raw -echo min 0  time 0
 +echo -n '^[]11;?^G' > /dev/tty
+read original
+stty $old
+
+trap 'echo -n "$original"; exit' 0 1 2 5 15
 +for R in $LIST
+do
+    for G in $LIST
 +    do
+       for B in $LIST
 +       do
+           echo -n "^[]11;rgb:$R/$G/$B^G"
 +           sleep 1
 +       done
+    done
 +done
Index: vttests/resize.sh
--- /dev/null   Sun Jul 17 19:46:18 1994
 +++ xterm-94/vttests/resize.sh  Sat Mar 27 12:16:44 1999
 @@ -0,0 +1,51 @@
 +#!/bin/sh
+# $XFree86$
+#
+# -- Thomas Dickey (1999/3/27)
+# Obtain the current screen size, then resize the terminal to the nominal
 +# screen width/height, and restore the size.
 +
+exec </dev/tty
+old=`stty -g`
+stty raw -echo min 0  time 0
 +
+echo -n "^[[18t" > /dev/tty
+IFS=';' read junk height width
 +
+echo -n "^[[19t" > /dev/tty
+IFS=';' read junk maxheight maxwidth
 +
+stty $old
+
+width=`echo $width|sed -e 's/t.*//'`
+maxwidth=`echo $maxwidth|sed -e 's/t.*//'`
 +
+trap 'echo -n "^[[8;${height};${width}t"; exit' 0 1 2 5 15
 +w=$width
+h=$height
+a=1
+while true
+do
+#      sleep 1
+       echo resizing to $h by $w
 +       echo -n "^[[8;${h};${w}t"
 +       if test $a = 1 ; then
 +               if test $w = $maxwidth ; then
 +                       h=`expr $h + $a`
 +                       if test $h = $maxheight ; then
 +                               a=-1
 +                       fi
 +               else
 +                       w=`expr $w + $a`
 +               fi
 +       else
+               if test $w = $width ; then
 +                       h=`expr $h + $a`
 +                       if test $h = $height ; then
 +                               a=1
 +                       fi
 +               else
 +                       w=`expr $w + $a`
 +               fi
 +       fi
+done
 Index: vttests/title.sh
--- /dev/null   Sun Jul 17 19:46:18 1994
 +++ xterm-94/vttests/title.sh   Sat Mar 27 12:16:30 1999
 @@ -0,0 +1,22 @@
 +#!/bin/sh
+# $XFree86$
+#
+# -- Thomas Dickey (1999/3/27)
+# Obtain the current title of the window, set up a simple clock which runs
 +# until this script is interrupted, then restore the title.
 +
+exec </dev/tty
+old=`stty -g`
+stty raw -echo min 0  time 0
 +echo -n "^[[21t" > /dev/tty
+read title
 +stty $old
+
+title=`echo "$title" |sed -e 's/^...//' -e 's/.$//'`
 +
+trap 'echo -n "^[]2;$title^G"; exit' 0 1 2 5 15
 +while true
+do
+       sleep 1
 +       echo -n "^[]2;`date`^G"
 +done
Index: xterm.h
--- xterm-93+/xterm.h   Sun Mar 14 14:59:36 1999
 +++ xterm-94/xterm.h    Sat Mar 27 17:18:16 1999
 @@ -1,4 +1,4 @@
 -/* $XFree86: xc/programs/xterm/xterm.h,v 3.35 1999/03/14 03:22:45 dawes Exp $ */
 +/* $XFree86: xc/programs/xterm/xterm.h,v 3.36 1999/03/21 07:35:40 dawes Exp $ */
  
 /************************************************************
 
@@ -84,8 +84,6 @@
 #define HAVE_TCGETATTR 1
 #endif
 
-#define XMU_POINTER XtPointer
-
  #endif /* HAVE_CONFIG_H */
 
 /***====================================================================***/
@@ -122,13 +120,6 @@
 #undef HAVE_WAITPID
 #endif
 
-/*
- * FIXME:  Xmu interface in XFree86 3.9N* introduces an incompatibility.
 - */
-#ifndef XMU_POINTER
-#define XMU_POINTER XPointer
-#endif
 -
 /***====================================================================***/
 
 #include <proto.h>
@@ -189,6 +180,7 @@
 extern void set_cursor_gcs (TScreen *screen);
 extern void unparseputc (int c, int fd);
 extern void unparseputc1 (int c, int fd);
+extern void unparseputs (Char *s, int fd);
  extern void unparseseq (ANSI *ap, int fd);
 
 #if OPT_ISO_COLORS
@@ -225,7 +217,9 @@
 /* input.c */
 extern void Input (TKeyboard *keyboard, TScreen *screen, XKeyEvent *event, Bool eightbit);
 extern void StringInput (TScreen *screen, char *string, size_t nbytes);
+#if OPT_NUM_LOCK
 extern void VTInitModifiers(void);
+#endif
 
 /* main.c */
 #ifndef __EMX__
@@ -276,7 +270,7 @@
 extern void VisualBell (void);
 extern void creat_as (int uid, int gid, char *pathname, int mode);
 extern void do_dcs (Char *buf, size_t len);
-extern void do_osc (Char *buf, int len);
 +extern void do_osc (Char *buf, int len, int final);
  extern void do_xevents (void);
 extern void end_tek_mode (void);
 extern void end_vt_mode (void);
Index: xterm.log.html
--- xterm-93+/xterm.log.html    Sun Mar 14 14:59:36 1999
 +++ xterm-94/xterm.log.html     Sat Mar 27 17:25:29 1999
 @@ -41,6 +41,7 @@
  xc/programs/Xserver/hw/xfree86).
 
 <UL>
+<LI><A HREF="#xterm_94">Patch #94 - 1999/3/27 - XFree86 3.9Pf</A>
  <LI><A HREF="#xterm_93">Patch #93 - 1999/3/14 - XFree86 3.9Pd</A>
 <LI><A HREF="#xterm_92">Patch #92 - 1999/2/5 - XFree86 3.9Nz</A>
 <LI><A HREF="#xterm_91">Patch #91 - 1999/1/21 - XFree86 3.9Nw</A>
@@ -136,6 +137,92 @@
 <LI><A HREF="#xterm_02">Patch #2 - 1996/1/7</A>
 <LI><A HREF="#xterm_01">Patch #1 - 1996/1/6</A>
 </UL>
+
+<H1><A NAME="xterm_94">Patch #94 - 1999/3/27 - XFree86 3.9Pf</A></H1>
 +<ul>
+       <li>further fixes for terminfo: ka1, ka3, etc., differ between the
 +         default xterm-xfree86 and xterm-vt220 entries.
 +
+       <li>change default (with sunKeyboard resource false) behavior of
 +         the editing keypad "Delete" to send a 127, like xterm-r6.
 +         The VT220-style <code><esc>[3~</code> is sent when
 +         sunKeyboard is true (reported by Tomas Vanhala).
 +
+       <li>add parameters to function keys to indicate if shift, control
 +         or alt are set.  The codes are based on a description of
 +         a DEC VT510 with a PC keyboard, from Jeffrey Altman
 +         <jaltman@watsun.cc.columbia.edu>.
 +
+       <li>add control sequence 1035, set-num-lock action and num-lock
 +         menu entry to control the use of the NumLock and Alt keys for
 +         the Sun/PC and VT220 keyboard extensions.
 +
+       <li>implement DECSET/DECRST numeric keypad (DECNKM) mode.
 +
+       <li>modify terminfo and termcap to use recommended "X Window" or "X11"
 +         names rather than "X Windows" (reported by Tomas Vanhala).
 +
+       <li>suppress translation of shifted keypad "+" when sunKeyboard
 +         is true.
 +
+       <li>workaround unexpected behavior (perhaps bug) in XmbLookupString,
 +         which returns trash in the string buffer for numlock and control-key
 +         combined with keypad-keys.
 +
+       <li>modify ScrollBarReverseVideo() to keep scrollbar border visible
 +         when reverse video is toggled.
 +
+       <li>correct missing case for parameter 17 (set highlight color) in
 +         dynamic colors control sequences.
 +
+       <li>extend dynamic colors control sequences to allow users to
 +         determine the colors and font which are currently active.
 +
+       <li>minor tweak to OSC responses, to use BEL if the application used
 +         that to end the request, rather than ST.  This works better with
 +         shell scripts, which may not handle an
 +         <code><esc>backslash</code> very well.
 +
+       <li>separate menu settings for reverse video from that done under
 +         program control.
 +
+       <li>corrected ifdef's for menus, which did not allow tek4014 to
 +         be suppressed properly (reported by Clark Morgan).
 +
+       <li>integrated patch from Pavel Roskin
 +         <pavel_roskin@geocities.com> 
 +         for Linux-2.2.x with GLibc-2.1 and
 +         /dev/ptmx support:
 +       <ul>
 +         <li>main.c and resize.c were using different rules to determine
 +           whether ATT should be defined (actually USE_USG_PTYS is more
 +           apt).
 +
+         <li>copy definitions from main.c to resize.c to prevent
 +           sys/stream.h and sys/ptem.h from inclusion when SYSV is not
 +           defined
 +
+         <li>define CNUL if not already defined like other variables.
 +
+         <li>/dev/tty does exist in Linux, but it doesn't mean, it
 +           should be used.  Therefore EACCES is now an acceptable
 +           result. 
 + 
+         <li>ifdef'd several calls such as <code>ioctl (ptyfd, I_PUSH,
 +           "ptem")</code> to build on Linux (I_PUSH is not defined when
 +           sys/stropts.h is not included).
 +       </ul>
 +
+       <li>initialize second "ltc" variable in main.c (reported by David
 +         Dawes).
 +
+       <li>provide definition for USE_USG_PTYS in screen.c
 +
+       <li>add resource-files to install rule in standalone Makefile.in
 +
+       <li>add sample scripts to illustrate titlebar controls, resizing
 +         and colors.
 +</ul>
 
 <H1><A NAME="xterm_93">Patch #93 - 1999/3/14 - XFree86 3.9Pd</A></H1>
 Here are several fixes and minor enhancements.  The chief ones
Index: xterm.man
--- xterm-93+/xterm.man Sun Mar 14 14:59:36 1999
 +++ xterm-94/xterm.man  Fri Mar 26 19:03:04 1999
 @@ -687,7 +687,8 @@
  and
 CTRL-F1 to F13, CTRL-F2 to F14, etc.,
 so \fIxterm\fP emulates a DEC VT220 more accurately.
-Otherwise (the default), \fIxterm\fP uses PC-style bindings for the function keys and keypad.
 +Otherwise (the default, with \fBsunKeyboard\fP set to ``false''),
 +\fIxterm\fP uses PC-style bindings for the function keys and keypad.
  .TP 8
 .B "termName (\fPclass\fB TermName)"
 Specifies the terminal type name to be set in the TERM environment variable.
@@ -698,14 +699,35 @@
 .TP 8
 .B "ttyModes (\fPclass\fB TtyModes)"
 Specifies a string containing terminal setting keywords and the characters
-to which they may be bound.  Allowable keywords include: intr, quit,
 -erase, kill, eof, eol, swtch, start, stop, brk, susp, dsusp, rprnt, flush,
 -weras, and lnext.  Control characters may be specified as ^char (e.g. ^c or ^u)
 -and ^? may be used to indicate Delete.
 -Use ^- to denote undef.
+to which they may be bound.  Allowable keywords include:
 +intr,
+quit,
+erase,
+kill,
+eof,
+eol,
+swtch,
+start,
+stop,
+brk,
+susp,
+dsusp,
+rprnt,
+flush,
+weras,
+lnext and
+status.
+Control characters may be specified as ^char (e.g., ^c or ^u)
 +and \fB^?\fP may be used to indicate Delete.
 +Use \fB^-\fP to denote undef.
+Use \fB\\034\fP to represent \fB^\\\fP, since a literal backslash in
 +an X resource escapes the next character.
 +.sp
 This is very useful for overriding
 the default terminal settings without having to do an \fIstty\fP every time
 an \fIxterm\fP is started.
+Note, however, that the stty program on a given host may use different
 +keywords; xterm's table is builtin.
  .TP 8
 .B "useInsertMode (\fPclass\fB UseInsertMode)
 Force use of insert mode by adding appropriate entries to the TERMCAP
@@ -1048,8 +1070,11 @@
 .TP 8
 .B "numLock (\fPclass\fB NumLock)"
 If true, xterm checks if NumLock is used as a modifier (see \fIxmodmap\fP(1)).
-If so, this modifier is used to simplify the logic when implementing NumLock
 -mode for the \fBsunKeyboard\fP resource.
 +If so, this modifier is used to simplify the logic when implementing special
 +NumLock for the \fBsunKeyboard\fP resource.
 +Also (when \fBsunKeyboard\fP is false), similar logic is used to find the
 +modifier associated with the left and right Alt keys.
 +The default is ``true.''
 .TP 8
 .B "oldXtermFKeys (\fPclass\fB OldXtermFKeys)"
 If true, xterm will use old-style control sequences for function keys F1 to F4,
@@ -1270,6 +1295,9 @@
 .B "backarrow key (\fPclass\fB SmeBSB)"
 This entry invokes the \fBset-backarrow(toggle)\fP action.
 .TP 8
+.B "num-lock (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-num-lock(toggle)\fP action.
 +.TP 8
 .B "sun\ function-keys (\fPclass\fB SmeBSB)"
 This entry invokes the \fBsun\ function-keys(toggle)\fP action.
 .TP 8
@@ -1954,6 +1982,9 @@
 .B "set-marginbell(\fIon/off/toggle\fP)"
 This action toggles the \fBmarginBell\fP resource and is also invoked from
 the \fBmarginbell\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-num-lock()"
+This action toggles the state of the \fBnumLock\fP resource.
  .TP 8
 .B "set-reverse-video(\fIon/off/toggle\fP)"
 This action toggles the \fIreverseVideo\fP resource and is also invoked by