xterm-11.patch.txt

XFree86 3.1.2Db - xterm patch #11 - 1996/3/5 - T.Dickey (dickey@clark.net)
 
This patch corrects the behavior of the ANSI colors in xterm when reverse
video is used, as well as some other lesser sins:
 
        button.c
                (compiler warnings: shadowing of 'time', redundant cast)
 
        charproc.c
                renamed screen.colors[] array to screen.Acolors[] to more
                easily distinguish the non-ANSI colors from the ANSI colors.
 
                moved logic of SGR_Save() into VTInitialize, getting rid of
                local private variables original_fg and original_bg.
 
                moved some logic into getXtermForeground and getXtermBackground
                from SGR_Foreground, SGR_Background, etc.
 
                corrected misleading 'row' to 'col' in case for CUF, CUB
                sequences.
 
        ctlseqs.ms
        xterm.man
                (correct a misconception which I'd added that the color0
                through color6 resource values apply to non-ANSI colors)
 
        ptyx.h
                added original_fg, original_bg to TScreen structure.
 
        scrollbar.c
                (compiler warnings: redundant cast)
 
        util.c
                new functions getXtermForeground and getXtermBackground replace
                the macros GET_FG and GET_BG, with the added functionality of
                checking for the reverse-video status of xterm.
 
                in ReverseVideo, swap the SGR foreground and background colors
                also.
 
--------------------------------------------------------------------------------
 button.c    |   20 !!!!!!!!!!!!
 charproc.c  |   93 +--------------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 ctlseqs.ms  |   14 !!!!!!!!!
 ptyx.h      |    6 !!!
 scrollbar.c |   10 !!!!!!
 util.c      |   71 +++++++++++++++++++++-!!!!!!!!!!!!!!!!!!!!!!!!
 xterm.h     |    5 +--
 xterm.man   |   21 ------------!
 8 files changed, 38 insertions, 45 deletions, 157 modifications
--------------------------------------------------------------------------------
Index: ctlseqs.ms
*** /build/x11r6/XFree86-3.1.2Db/xc/doc/specs/xterm/ctlseqs.ms  Mon Feb 12 12:35:46 1996
--- /build/x11r6/XFree86-patched/xc/doc/specs/xterm/ctlseqs.ms  Tue Mar  5 21:38:29 1996
***************
*** 452,465 ****
    \*(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 color0 to \*(Pt (a
  list of one or more color names, separated by semicolon, up to color6).
!   \*(Ps = \*1\*1 \(-> Change color names starting with color1 to \*(Pt
!   \*(Ps = \*1\*2 \(-> Change color names starting with color2 to \*(Pt
!   \*(Ps = \*1\*3 \(-> Change color names starting with color3 to \*(Pt
!   \*(Ps = \*1\*4 \(-> Change color names starting with color4 to \*(Pt
!   \*(Ps = \*1\*5 \(-> Change color names starting with color5 to \*(Pt
!   \*(Ps = \*1\*6 \(-> Change color names starting with color6 to \*(Pt
    \*(Ps = \*4\*6 \(-> Change Log File to \*(Pt (normally disabled by a
  compile-time option)
    \*(Ps = \*5\*0 \(-> Set Font to \*(Pt
--- 452,465 ----
    \*(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 color6).
!   \*(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
!   \*(Ps = \*1\*4 \(-> Change colors starting with mouse background to \*(Pt
!   \*(Ps = \*1\*5 \(-> Change colors starting with Tek foreground to \*(Pt
!   \*(Ps = \*1\*6 \(-> Change colors starting with Tek background to \*(Pt
    \*(Ps = \*4\*6 \(-> Change Log File to \*(Pt (normally disabled by a
  compile-time option)
    \*(Ps = \*5\*0 \(-> Set Font to \*(Pt
Index: button.c
*** /build/x11r6/XFree86-3.1.2Db/xc/programs/xterm/button.c     Tue Jan 16 15:43:01 1996
--- /build/x11r6/XFree86-patched/xc/programs/xterm/button.c     Sun Mar  3 15:42:39 1996
***************
*** 125,131 ****
  static void SetSelectUnit PROTO((Time buttonDownTime, SelectUnit defaultUnit));
  static void StartSelect PROTO((int startrow, int startcol));
  static void TrackDown PROTO((XButtonEvent *event));
! static void _GetSelection PROTO((Widget w, Time time, String *params, Cardinal num_params));
  static void _OwnSelection PROTO((XtermWidget termw, String *selections, Cardinal count));
  static void do_select_end PROTO((Widget w, XEvent *event, String *params, Cardinal *num_params, Bool use_cursor_loc));
  static void do_select_start PROTO((Widget w, XEvent *event, int startrow, int startcol));
--- 125,131 ----
  static void SetSelectUnit PROTO((Time buttonDownTime, SelectUnit defaultUnit));
  static void StartSelect PROTO((int startrow, int startcol));
  static void TrackDown PROTO((XButtonEvent *event));
! static void _GetSelection PROTO((Widget w, Time ev_time, String *params, Cardinal num_params));
  static void _OwnSelection PROTO((XtermWidget termw, String *selections, Cardinal count));
  static void do_select_end PROTO((Widget w, XEvent *event, String *params, Cardinal *num_params, Bool use_cursor_loc));
  static void do_select_start PROTO((Widget w, XEvent *event, int startrow, int startcol));
***************
*** 317,325 ****
  };
  
  
! static void _GetSelection(w, time, params, num_params)
  Widget w;
! Time time;
  String *params;                       /* selections in precedence order */
  Cardinal num_params;
  {
--- 317,325 ----
  };
  
  
! static void _GetSelection(w, ev_time, params, num_params)
  Widget w;
! Time ev_time;
  String *params;                       /* selections in precedence order */
  Cardinal num_params;
  {
***************
*** 350,366 ****
            SelectionReceived(w, NULL, &selection, &type, (XtPointer)line,
                              &nbytes, &fmt8);
        else if (num_params > 1)
!           _GetSelection(w, time, params+1, num_params-1);
      } else {
        struct _SelectionList* list;
        if (--num_params) {
            list = XtNew(struct _SelectionList);
            list->params = params + 1;
            list->count = num_params; /* decremented above */
!           list->time = time;
        } else list = NULL;
        XtGetSelectionValue(w, selection, XA_STRING, SelectionReceived,
!                           (XtPointer)list, time);
      }
  }
  
--- 350,366 ----
            SelectionReceived(w, NULL, &selection, &type, (XtPointer)line,
                              &nbytes, &fmt8);
        else if (num_params > 1)
!           _GetSelection(w, ev_time, params+1, num_params-1);
      } else {
        struct _SelectionList* list;
        if (--num_params) {
            list = XtNew(struct _SelectionList);
            list->params = params + 1;
            list->count = num_params; /* decremented above */
!           list->time = ev_time;
        } else list = NULL;
        XtGetSelectionValue(w, selection, XA_STRING, SelectionReceived,
!                           (XtPointer)list, ev_time);
      }
  }
  
***************
*** 1503,1515 ****
      String *params;           /* [0] = volume */
      Cardinal *param_count;    /* 0 or 1 */
  {
!     Time time = CurrentTime;
  
      if ((event->xany.type == KeyPress) ||
        (event->xany.type == KeyRelease))
!       time = event->xkey.time;
      else if ((event->xany.type == ButtonPress) ||
             (event->xany.type == ButtonRelease))
!       time = event->xbutton.time;
!     DoSecureKeyboard (time);
  }
--- 1503,1515 ----
      String *params;           /* [0] = volume */
      Cardinal *param_count;    /* 0 or 1 */
  {
!     Time ev_time = CurrentTime;
  
      if ((event->xany.type == KeyPress) ||
        (event->xany.type == KeyRelease))
!       ev_time = event->xkey.time;
      else if ((event->xany.type == ButtonPress) ||
             (event->xany.type == ButtonRelease))
!         ev_time = event->xbutton.time;
!     DoSecureKeyboard (ev_time);
  }
Index: charproc.c
*** /build/x11r6/XFree86-3.1.2Db/xc/programs/xterm/charproc.c   Sat Feb 24 09:02:11 1996
--- /build/x11r6/XFree86-patched/xc/programs/xterm/charproc.c   Tue Mar  5 20:41:33 1996
***************
*** 123,129 ****
  static int set_character_class PROTO((char *s));
  static void DoSetSelectedFont PROTO_XT_SEL_CB_ARGS;
  static void FromAlternate PROTO((TScreen *screen));
- static void SGR_Save PROTO((void));
  static void SwitchBufs PROTO((TScreen *screen));
  static void ToAlternate PROTO((TScreen *screen));
  static void VTGraphicsOrNoExpose PROTO((XEvent *event));
--- 123,128 ----
***************
*** 580,637 ****
        XtRImmediate, (XtPointer)TRUE},
  #endif
  {XtNcolor0, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_0]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor1, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_1]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor2, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_2]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor3, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_3]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor4, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_4]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor5, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_5]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor6, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_6]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor7, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_7]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor8, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_8]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor9, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_9]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor10, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_10]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor11, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_11]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor12, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_12]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor13, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_13]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor14, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_14]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor15, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_15]),
        XtRString, "XtDefaultForeground"},
  {XtNcolorBD, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_BD]),
        XtRString, "XtDefaultForeground"},
  {XtNcolorUL, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.colors[COLOR_UL]),
        XtRString, "XtDefaultForeground"},
  {XtNcolorMode, XtCColorMode, XtRBoolean, sizeof(Boolean),
        XtOffsetOf(XtermWidgetRec, screen.colorMode),
--- 579,636 ----
        XtRImmediate, (XtPointer)TRUE},
  #endif
  {XtNcolor0, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_0]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor1, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_1]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor2, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_2]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor3, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_3]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor4, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_4]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor5, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_5]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor6, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_6]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor7, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_7]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor8, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_8]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor9, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_9]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor10, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_10]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor11, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_11]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor12, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_12]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor13, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_13]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor14, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_14]),
        XtRString, "XtDefaultForeground"},
  {XtNcolor15, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_15]),
        XtRString, "XtDefaultForeground"},
  {XtNcolorBD, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_BD]),
        XtRString, "XtDefaultForeground"},
  {XtNcolorUL, XtCForeground, XtRPixel, sizeof(Pixel),
!       XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_UL]),
        XtRString, "XtDefaultForeground"},
  {XtNcolorMode, XtCColorMode, XtRBoolean, sizeof(Boolean),
        XtOffsetOf(XtermWidgetRec, screen.colorMode),
***************
*** 702,720 ****
  
  WidgetClass xtermWidgetClass = (WidgetClass)&xtermClassRec;
  
- static        Pixel   original_fg;
- static        Pixel   original_bg;
- 
- static void SGR_Save()
- {
-       static  int     initialized;
-       if (!initialized) {
-               original_fg = term->screen.foreground;
-               original_bg = term->core.background_pixel;
-               initialized = TRUE;
-       }
- }
- 
  /*
   * The terminal's foreground and background colors are set via two mechanisms:
   *    text (cur_foreground, cur_background values that are passed down to
--- 701,706 ----
***************
*** 727,741 ****
        register TScreen *screen = &term->screen;
        Pixel   fg;
  
-       SGR_Save();
-       
        if (color >= 0) {
-               fg = COLOR_VALUE(screen,color);
                term->flags |= FG_COLOR;
        } else {
-               fg = original_fg;
                term->flags &= ~FG_COLOR;
        }
        term->cur_foreground = color;
  
        XSetForeground(screen->display, screen->normalGC, fg);
--- 713,724 ----
        register TScreen *screen = &term->screen;
        Pixel   fg;
  
        if (color >= 0) {
                term->flags |= FG_COLOR;
        } else {
                term->flags &= ~FG_COLOR;
        }
+       fg = getXtermForeground(term->flags, color);
        term->cur_foreground = color;
  
        XSetForeground(screen->display, screen->normalGC, fg);
***************
*** 750,764 ****
        register TScreen *screen = &term->screen;
        Pixel   bg;
  
-       SGR_Save();
-       
        if (color >= 0) {
-               bg = COLOR_VALUE(screen,color);
                term->flags |= BG_COLOR;
        } else {
-               bg = original_bg;
                term->flags &= ~BG_COLOR;
        }
        term->cur_background = color;
  
        XSetBackground(screen->display, screen->normalGC, bg);
--- 733,744 ----
        register TScreen *screen = &term->screen;
        Pixel   bg;
  
        if (color >= 0) {
                term->flags |= BG_COLOR;
        } else {
                term->flags &= ~BG_COLOR;
        }
+       bg = getXtermBackground(term->flags, color);
        term->cur_background = color;
  
        XSetBackground(screen->display, screen->normalGC, bg);
***************
*** 960,976 ****
  
                 case CASE_CUF:
                        /* CUF */
!                       if((row = param[0]) < 1)
!                               row = 1;
!                       CursorForward(screen, row);
                        parsestate = groundtable;
                        break;
  
                 case CASE_CUB:
                        /* CUB */
!                       if((row = param[0]) < 1)
!                               row = 1;
!                       CursorBack(screen, row);
                        parsestate = groundtable;
                        break;
  
--- 940,956 ----
  
                 case CASE_CUF:
                        /* CUF */
!                       if((col = param[0]) < 1)
!                               col = 1;
!                       CursorForward(screen, col);
                        parsestate = groundtable;
                        break;
  
                 case CASE_CUB:
                        /* CUB */
!                       if((col = param[0]) < 1)
!                               col = 1;
!                       CursorBack(screen, col);
                        parsestate = groundtable;
                        break;
  
***************
*** 2629,2635 ****
     new->screen.colorBDMode = request->screen.colorBDMode;
     new->screen.underline = request->screen.underline;
     for (i = 0; i < MAXCOLORS; i++) {
!        new->screen.colors[i] = request->screen.colors[i];
     }
  
     new->cur_foreground = 0;
--- 2609,2622 ----
     new->screen.colorBDMode = request->screen.colorBDMode;
     new->screen.underline = request->screen.underline;
     for (i = 0; i < MAXCOLORS; i++) {
!        new->screen.Acolors[i] = request->screen.Acolors[i];
!    }
!    if (request->misc.re_verse) {
!        new->screen.original_bg = request->screen.foreground;
!        new->screen.original_fg = request->core.background_pixel;
!    } else {
!        new->screen.original_fg = request->screen.foreground;
!        new->screen.original_bg = request->core.background_pixel;
     }
  
     new->cur_foreground = 0;
***************
*** 3601,3608 ****
      mask = (GCFont | GCForeground | GCBackground | GCGraphicsExposures |
            GCFunction);
  
!     new_normal = GET_FG(term->flags, term->cur_foreground);
!     new_revers = GET_BG(term->flags, term->cur_background);
  
      xgcv.font = nfs->fid;
      xgcv.foreground = new_normal;
--- 3588,3595 ----
      mask = (GCFont | GCForeground | GCBackground | GCGraphicsExposures |
            GCFunction);
  
!     new_normal = getXtermForeground(term->flags, term->cur_foreground);
!     new_revers = getXtermBackground(term->flags, term->cur_background);
  
      xgcv.font = nfs->fid;
      xgcv.foreground = new_normal;
***************
*** 3735,3744 ****
      TScreen *screen;
  {
      XGCValues xgcv;
!     unsigned long mask;
!     unsigned long cc = screen->cursorcolor;
!     unsigned long fg = screen->foreground;
!     unsigned long bg = term->core.background_pixel;
      GC new_cursorGC = NULL, new_reversecursorGC = NULL;
      GC new_cursoroutlineGC = NULL;
  
--- 3722,3731 ----
      TScreen *screen;
  {
      XGCValues xgcv;
!     XtGCMask mask;
!     Pixel cc = screen->cursorcolor;
!     Pixel fg = screen->foreground;
!     Pixel bg = term->core.background_pixel;
      GC new_cursorGC = NULL, new_reversecursorGC = NULL;
      GC new_cursoroutlineGC = NULL;
  
Index: ptyx.h
*** /build/x11r6/XFree86-3.1.2Db/xc/programs/xterm/ptyx.h       Mon Feb 12 12:35:46 1996
--- /build/x11r6/XFree86-patched/xc/programs/xterm/ptyx.h       Tue Mar  5 20:09:06 1996
***************
*** 268,274 ****
                                 ((n)==TEXT_BG?TEK_FG:(n))))))))
  
  typedef struct {
!       unsigned        which;
        Pixel           colors[NCOLORS];
        char            *names[NCOLORS];
  } ScrnColors;
--- 268,274 ----
                                 ((n)==TEXT_BG?TEK_FG:(n))))))))
  
  typedef struct {
!       unsigned        which;  /* must have NCOLORS bits */
        Pixel           colors[NCOLORS];
        char            *names[NCOLORS];
  } ScrnColors;
***************
*** 333,339 ****
        Pixel           cursorcolor;    /* Cursor color                 */
        Pixel           mousecolor;     /* Mouse color                  */
        Pixel           mousecolorback; /* Mouse color background       */
!       Pixel           colors[MAXCOLORS]; /* ANSI color emulation      */
        Boolean         colorMode;      /* are we using color mode?     */
        Boolean         colorULMode;    /* use color for underline?     */
        Boolean         colorBDMode;    /* use color for bold?          */
--- 333,341 ----
        Pixel           cursorcolor;    /* Cursor color                 */
        Pixel           mousecolor;     /* Mouse color                  */
        Pixel           mousecolorback; /* Mouse color background       */
!       Pixel           Acolors[MAXCOLORS]; /* ANSI color emulation     */
!       Pixel           original_fg;    /* reference for SGR reset fg   */
!       Pixel           original_bg;    /* reference for SGR reset bg   */
        Boolean         colorMode;      /* are we using color mode?     */
        Boolean         colorULMode;    /* use color for underline?     */
        Boolean         colorBDMode;    /* use color for bold?          */
Index: scrollbar.c
*** /build/x11r6/XFree86-3.1.2Db/xc/programs/xterm/scrollbar.c  Tue Jan 30 15:59:20 1996
--- /build/x11r6/XFree86-patched/xc/programs/xterm/scrollbar.c  Sun Mar  3 15:35:26 1996
***************
*** 51,57 ****
  #include "xterm.h"
  
  static Widget CreateScrollBar PROTO((XtermWidget xw, int x, int y, int height));
! static int params_to_pixels PROTO((TScreen *screen, String *params, int n));
  static int specialcmplowerwiths PROTO((char *a, char *b));
  static void RealizeScrollBar PROTO((Widget sbw, TScreen *screen));
  static void ResizeScreen PROTO((XtermWidget xw, int min_width, int min_height));
--- 51,57 ----
  #include "xterm.h"
  
  static Widget CreateScrollBar PROTO((XtermWidget xw, int x, int y, int height));
! static int params_to_pixels PROTO((TScreen *screen, String *params, Cardinal n));
  static int specialcmplowerwiths PROTO((char *a, char *b));
  static void RealizeScrollBar PROTO((Widget sbw, TScreen *screen));
  static void ResizeScreen PROTO((XtermWidget xw, int min_width, int min_height));
***************
*** 477,485 ****
  static int params_to_pixels (screen, params, n)
      TScreen *screen;
      String *params;
!     int n;
  {
!     register mult = 1;
      register char *s;
  
      switch (n > 2 ? 2 : n) {
--- 477,485 ----
  static int params_to_pixels (screen, params, n)
      TScreen *screen;
      String *params;
!     Cardinal n;
  {
!     register int mult = 1;
      register char *s;
  
      switch (n > 2 ? 2 : n) {
***************
*** 517,523 ****
      register TScreen *screen = &w->screen;
  
      ScrollTextUpDownBy (gw, (XtPointer) NULL,
!                       (XtPointer)params_to_pixels (screen, params, (int) *nparams));
      return;
  }
  
--- 517,523 ----
      register TScreen *screen = &w->screen;
  
      ScrollTextUpDownBy (gw, (XtPointer) NULL,
!                       (XtPointer)(params_to_pixels (screen, params, *nparams)));
      return;
  }
  
***************
*** 533,538 ****
      register TScreen *screen = &w->screen;
  
      ScrollTextUpDownBy (gw, (XtPointer) NULL,
!                       (XtPointer)-params_to_pixels (screen, params, (int) *nparams));
      return;
  }
--- 533,538 ----
      register TScreen *screen = &w->screen;
  
      ScrollTextUpDownBy (gw, (XtPointer) NULL,
!                       (XtPointer)(-params_to_pixels (screen, params, *nparams)));
      return;
  }
Index: util.c
*** /build/x11r6/XFree86-3.1.2Db/xc/programs/xterm/util.c       Sun Feb 18 12:46:26 1996
--- /build/x11r6/XFree86-patched/xc/programs/xterm/util.c       Tue Mar  5 20:43:59 1996
***************
*** 1051,1056 ****
--- 1051,1058 ----
  
  /***====================================================================***/
  
+ #define EXCHANGE(a,b,tmp) tmp = a; a = b; b = tmp;
+ 
  void
  ReverseVideo (termw)
        XtermWidget termw;
***************
*** 1058,1064 ****
        register TScreen *screen = &termw->screen;
        GC tmpGC;
        Window tek = TWindow(screen);
!       unsigned long tmp;
  
        tmp = termw->core.background_pixel;
        if(screen->cursorcolor == screen->foreground)
--- 1060,1078 ----
        register TScreen *screen = &termw->screen;
        GC tmpGC;
        Window tek = TWindow(screen);
!       Pixel tmp;
! 
!       /*
!        * Swap SGR foreground and background colors.  By convention, these are
!        * the colors assigned to "black" (SGR #0) and "white" (SGR #7).  Also,
!        * SGR #8 and SGR #15 are the bold (or bright) versions of SGR #0 and
!        * #7, respectively.
!        *
!        * We don't swap colors that happen to match the screen's foreground
!        * and background because that tends to produce bizarre effects.
!        */
!       EXCHANGE( screen->Acolors[0], screen->Acolors[7],  tmp )
!       EXCHANGE( screen->Acolors[8], screen->Acolors[15], tmp )
  
        tmp = termw->core.background_pixel;
        if(screen->cursorcolor == screen->foreground)
***************
*** 1066,1082 ****
        termw->core.background_pixel = screen->foreground;
        screen->foreground = tmp;
  
!       tmp = screen->mousecolorback;
!       screen->mousecolorback = screen->mousecolor;
!       screen->mousecolor = tmp;
! 
!       tmpGC = screen->normalGC;
!       screen->normalGC = screen->reverseGC;
!       screen->reverseGC = tmpGC;
! 
!       tmpGC = screen->normalboldGC;
!       screen->normalboldGC = screen->reverseboldGC;
!       screen->reverseboldGC = tmpGC;
  
        recolor_cursor (screen->pointer_cursor, 
                        screen->mousecolor, screen->mousecolorback);
--- 1080,1088 ----
        termw->core.background_pixel = screen->foreground;
        screen->foreground = tmp;
  
!       EXCHANGE( screen->mousecolor,    screen->mousecolorback, tmp )
!       EXCHANGE( screen->normalGC,      screen->reverseGC,      tmpGC )
!       EXCHANGE( screen->normalboldGC,  screen->reverseboldGC,  tmpGC )
  
        recolor_cursor (screen->pointer_cursor, 
                        screen->mousecolor, screen->mousecolorback);
***************
*** 1089,1095 ****
        if(tek)
                XDefineCursor(screen->display, tek, screen->arrow);
  
-       
        if(screen->scrollWidget)
                ScrollBarReverseVideo(screen->scrollWidget);
  
--- 1095,1100 ----
***************
*** 1138,1145 ****
        int bg;
        Bool hilite;
  {
!       Pixel fg_pix = GET_FG(flags,fg);
!       Pixel bg_pix = GET_BG(flags,bg);
        GC gc;
  
        if ( (!hilite && (flags & INVERSE) != 0)
--- 1143,1150 ----
        int bg;
        Bool hilite;
  {
!       Pixel fg_pix = getXtermForeground(flags,fg);
!       Pixel bg_pix = getXtermBackground(flags,bg);
        GC gc;
  
        if ( (!hilite && (flags & INVERSE) != 0)
***************
*** 1175,1182 ****
        int flags;
        Bool hilite;
  {
!       Pixel fg_pix = GET_FG(flags,term->cur_foreground);
!       Pixel bg_pix = GET_BG(flags,term->cur_background);
        GC gc;
  
        if ( (!hilite && (flags & INVERSE) != 0)
--- 1180,1187 ----
        int flags;
        Bool hilite;
  {
!       Pixel fg_pix = getXtermForeground(flags,term->cur_foreground);
!       Pixel bg_pix = getXtermBackground(flags,term->cur_background);
        GC gc;
  
        if ( (!hilite && (flags & INVERSE) != 0)
***************
*** 1198,1201 ****
--- 1203,1238 ----
                XSetForeground(screen->display, gc, fg_pix);
                XSetBackground(screen->display, gc, bg_pix);
        }
+ }
+ 
+ /* GET_FG */
+ Pixel
+ getXtermForeground(flags, color)
+       int flags;
+       int color;
+ {
+       Pixel fg = (flags & FG_COLOR)
+                       ? term->screen.Acolors[color]
+                       : term->screen.foreground;
+ 
+       if (term->misc.re_verse && (fg == term->screen.original_fg))
+               fg = term->screen.original_bg;
+ 
+       return fg;
+ }
+ 
+ /* GET_BG */
+ Pixel
+ getXtermBackground(flags, color)
+       int flags;
+       int color;
+ {
+       Pixel bg = (flags & BG_COLOR)
+                       ? term->screen.Acolors[color]
+                       : term->core.background_pixel;
+ 
+       if (term->misc.re_verse && (bg == term->screen.original_bg))
+               bg = term->screen.original_fg;
+ 
+       return bg;
  }
Index: xterm.h
*** /build/x11r6/XFree86-3.1.2Db/xc/programs/xterm/xterm.h      Sun Feb 18 12:46:26 1996
--- /build/x11r6/XFree86-patched/xc/programs/xterm/xterm.h      Tue Mar  5 20:40:45 1996
***************
*** 7,15 ****
  
  #include "proto.h"
  
- #define GET_FG(flags,color) ((flags&FG_COLOR) ? screen->colors[color] : screen->foreground)
- #define GET_BG(flags,color) ((flags&BG_COLOR) ? screen->colors[color] : term->core.background_pixel)
- 
  /* Tekproc.c */
  extern int TekInit PROTO((void));
  extern void ChangeTekColors PROTO((TScreen *screen, ScrnColors *pNew));
--- 7,12 ----
***************
*** 170,175 ****
--- 167,174 ----
  
  /* util.c */
  extern GC updatedXtermGC PROTO((TScreen *screen, int flags, int fg, int bg, Bool hilite));
+ extern Pixel getXtermBackground PROTO((int flags, int color));
+ extern Pixel getXtermForeground PROTO((int flags, int color));
  extern int AddToRefresh PROTO((TScreen *screen));
  extern int HandleExposure PROTO((TScreen *screen, XEvent *event));
  extern void ChangeColors PROTO((XtermWidget tw, ScrnColors *pNew));
Index: xterm.man
*** /build/x11r6/XFree86-3.1.2Db/xc/programs/xterm/xterm.man    Mon Feb 12 12:35:46 1996
--- /build/x11r6/XFree86-patched/xc/programs/xterm/xterm.man    Tue Mar  5 21:51:53 1996
***************
*** 666,690 ****
  .B "color7 (\fPclass\fB Foreground)"
  These specify the colors for the ISO 6429 extension.  The defaults are,
  respectively, black, red, green, yellow, blue, magenta, cyan, and white.
- If \fIcolorMode\fP is not active,
- the resources \fIcolor0\fP through \fIcolor6\fP
- are interpreted differently:
- .RS
- .TP 8
- .B "color0\fP text foreground"
- .TP 8
- .B "color1\fP text background"
- .TP 8
- .B "color2\fP text cursor"
- .TP 8
- .B "color3\fP mouse foreground"
- .TP 8
- .B "color4\fP mouse background"
- .TP 8
- .B "color5\fP Tektronix foreground"
- .TP 8
- .B "color6\fP Tektronix background"
- .RE
  .TP 8
  .B "color8 (\fPclass\fB Foreground)"
  .TP 8
--- 666,671 ----
***************
*** 1038,1044 ****
  .B "hardreset (\fPclass\fB SmeBSB)"
  This entry invokes the \fBhard-reset()\fP action.
  .TP 8
! .B "clearsavedlines" (\fPclass\fB SmeBSB)"
  This entry invokes the \fBclear-saved-lines()\fP action.
  .TP 8
  .B "line2 (\fPclass\fB SmeLine)"
--- 1019,1025 ----
  .B "hardreset (\fPclass\fB SmeBSB)"
  This entry invokes the \fBhard-reset()\fP action.
  .TP 8
! .B "clearsavedlines (\fPclass\fB SmeBSB)"
  This entry invokes the \fBclear-saved-lines()\fP action.
  .TP 8
  .B "line2 (\fPclass\fB SmeLine)"