xterm-21.patch.txt

XFree86 3.1.2Ec - xterm patch #21 - T.Dickey
 
This patch does the following:
 
        + fixes some minor typography in the control-sequences documentation
          (it didn't occur to me til I'd sent the last patch that I could use
          ghostview for previewing the troff output ;-)
 
        + adjusts the shell's background color in ReverseVideo so that flicker
          in resizing is reduced
 
        + adds an ifdef OPT_ISO_COLORS to allow configuring xterm without
          the ISO color support (saves a lot of memory)
 
        + used that ifdef to isolate/modify logic so that if the user doesn't
          have the colorMode enabled, then ISO color support is disabled (saving
          memory).
 
          (If anyone needs numbers, I had savedLines set to 2000, and found
          a reduction from ~700k to ~400k of allocated memory, according to
          Purify).
 
To do:
        + I think I've got a double-negative in the color sense (if the
          xterm is started in reverse video, and the application clears it,
          I get a "white" background when my modified vttest says it should
          be black -- I'll investigate).
 
        + time-permitting, implement ech/ech1 terminal capabilities, and
          protected characters.
 
--------------------------------------------------------------------------------
 doc/specs/xterm/ctlseqs.ms |   14 !!!!
 programs/xterm/charproc.c  |   80 ++-!!!!!!!!!!!!!!!!!!!!!!!
 programs/xterm/ptyx.h      |   31 +++++!!!!!
 programs/xterm/screen.c    |  139 +++-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 programs/xterm/util.c      |   49 ++-!!!!!!!!!!!!!
 programs/xterm/xterm.h     |   34 ++++++++-!
 6 files changed, 72 insertions, 10 deletions, 265 modifications
--------------------------------------------------------------------------------
Index: ctlseqs.ms
*** /build/x11r6/XFree86-960721/xc/doc/specs/xterm/ctlseqs.ms   Wed Jul 24 21:03:44 1996
--- /build/x11r6/XFree86-current/xc/doc/specs/xterm/ctlseqs.ms  Thu Jul 25 06:29:05 1996
***************
*** 415,432 ****
    \*(Ps = \*7 \(-> Refresh the xterm window.
    \*(Ps = \*8 ; \fIheight ; width\fP \(-> Resize the text area to [height;width] in characters.
    \*(Ps = \*1\*1 \(-> Report xterm window state.
! If the xterm window is open (non-iconified), it returns ``\*(Es [ 1 t''.
! If the xterm window is iconified, it returns ``\*(Es [ 2 t''.
    \*(Ps = \*1\*3 \(-> Report xterm window position as
! \*(Es [ 3 ; x ; y t
    \*(Ps = \*1\*4 \(-> Report xterm window in pixels as
! \*(Es\*s\*([[\*s\*4\*s\*;\*sheight\*s\*;\*swidth\*s\*t
    \*(Ps = \*1\*8 \(-> Report the size of the text area in characters as
! \*(Es\*s\*([[\*s\*8\*s\*;\*sheight\*s\*;\*swidth t
    \*(Ps = \*2\*0 \(-> Report xterm window's icon label as
! \*(Es\*s\*]\*s\*L\*slabel\*s\*(Es\*s\*(bS
    \*(Ps = \*2\*1 \(-> Report xterm window's title as
! \*(Es\*s\*]\*s\*l\*stitle\*s\*(Es\*s\*(bS
  .IP \\*(Es\\*([[\\*(Ps\\*s\\*x
  Request Terminal Parameters (DECREQTPARM)
  .IP \\*(Es\\*([[\\*?\\*(Pm\\*s\\*h
--- 415,432 ----
    \*(Ps = \*7 \(-> Refresh the xterm window.
    \*(Ps = \*8 ; \fIheight ; width\fP \(-> Resize the text area to [height;width] in characters.
    \*(Ps = \*1\*1 \(-> Report xterm window state.
! If the xterm window is open (non-iconified), it returns \*(Es\*([[\*1\*t.
! If the xterm window is iconified, it returns \*(Es\*([[\*2\*t.
    \*(Ps = \*1\*3 \(-> Report xterm window position as
! \*(Es\*([[\*3\*;\*(Ix\*;\*(Iy\*t
    \*(Ps = \*1\*4 \(-> Report xterm window in pixels as
! \*(Es\*s\*([[\*s\*4\*s\*;\*s\fIheight\fP\*s\*;\*s\fIwidth\fP\*s\*t
    \*(Ps = \*1\*8 \(-> Report the size of the text area in characters as
! \*(Es\*s\*([[\*s\*8\*s\*;\*s\fIheight\fP\*s\*;\*s\fIwidth\fP\*t
    \*(Ps = \*2\*0 \(-> Report xterm window's icon label as
! \*(Es\*s\*]\*s\*L\*s\fIlabel\fP\*s\*(Es\*s\*(bS
    \*(Ps = \*2\*1 \(-> Report xterm window's title as
! \*(Es\*s\*]\*s\*l\*s\fItitle\fP\*s\*(Es\*s\*(bS
  .IP \\*(Es\\*([[\\*(Ps\\*s\\*x
  Request Terminal Parameters (DECREQTPARM)
  .IP \\*(Es\\*([[\\*?\\*(Pm\\*s\\*h
Index: charproc.c
*** /build/x11r6/XFree86-960721/xc/programs/xterm/charproc.c    Sun Jul 21 19:11:02 1996
--- /build/x11r6/XFree86-current/xc/programs/xterm/charproc.c   Wed Jul 24 20:09:29 1996
***************
*** 586,591 ****
--- 586,592 ----
        XtOffsetOf(XtermWidgetRec, misc.open_im),
        XtRImmediate, (XtPointer)TRUE},
  #endif
+ #if OPT_ISO_COLORS
  {XtNcolor0, XtCForeground, XtRPixel, sizeof(Pixel),
        XtOffsetOf(XtermWidgetRec, screen.Acolors[COLOR_0]),
        XtRString, "XtDefaultForeground"},
***************
*** 649,654 ****
--- 650,656 ----
  {XtNcolorBDMode, XtCColorMode, XtRBoolean, sizeof(Boolean),
        XtOffsetOf(XtermWidgetRec, screen.colorBDMode),
        XtRBoolean, (XtPointer) &defaultFALSE},
+ #endif /* OPT_ISO_COLORS */
  {XtNdynamicColors, XtCDynamicColors, XtRBoolean, sizeof(Boolean),
        XtOffsetOf(XtermWidgetRec, misc.dynamicColors),
        XtRBoolean, (XtPointer) &defaultTRUE},
***************
*** 709,714 ****
--- 711,717 ----
  
  WidgetClass xtermWidgetClass = (WidgetClass)&xtermClassRec;
  
+ #if OPT_ISO_COLORS
  /*
   * The terminal's foreground and background colors are set via two mechanisms:
   *    text (cur_foreground, cur_background values that are passed down to
***************
*** 754,759 ****
--- 757,763 ----
        XSetBackground(screen->display, screen->normalboldGC, bg);
        XSetForeground(screen->display, screen->reverseboldGC, bg);
  }
+ #endif /* OPT_ISO_COLORS */
  
  static void VTparse()
  {
***************
*** 1105,1139 ****
                                switch (param[row]) {
                                 case DEFAULT:
                                 case 0:
!                                       if (term->flags & FG_COLOR)
                                                SGR_Foreground(-1);
!                                       if (term->flags & BG_COLOR)
                                                SGR_Background(-1);
                                        term->flags &=
                                                ~(INVERSE|BOLD|UNDERLINE);
                                        break;
                                 case 1:
                                 case 5:        /* Blink, really.       */
                                        term->flags |= BOLD;
!                                       if( screen->colorMode && 
!                                           screen->colorBDMode) {
!                                         if (!(term->flags & FG_COLOR) ||
!                                             (term->cur_foreground==COLOR_UL)){
!                                           SGR_Foreground(COLOR_BD);
                                          }
!                                         else   /* Set highlight bit */
!                                             if (term->cur_foreground < 8)
!                                               term->cur_foreground |= 8;
!                                       }
                                        break;
                                 case 4:        /* Underscore           */
                                        term->flags |= UNDERLINE;
!                                       if( screen->colorMode && 
!                                           screen->colorULMode) {
!                                           if (!(term->flags & FG_COLOR)) {
!                                             SGR_Foreground(COLOR_UL);
                                          }
!                                         }
                                        break;
                                 case 7:
                                        term->flags |= INVERSE;
--- 1109,1147 ----
                                switch (param[row]) {
                                 case DEFAULT:
                                 case 0:
!                                       if_OPT_ISO_COLORS(screen,{
!                                           if (term->flags & FG_COLOR)
                                                SGR_Foreground(-1);
!                                           if (term->flags & BG_COLOR)
                                                SGR_Background(-1);
+                                       })
                                        term->flags &=
                                                ~(INVERSE|BOLD|UNDERLINE);
                                        break;
                                 case 1:
                                 case 5:        /* Blink, really.       */
                                        term->flags |= BOLD;
!                                       if_OPT_ISO_COLORS(screen,{
!                                         if (screen->colorBDMode) {
!                                           if (!(term->flags & FG_COLOR) ||
!                                               (term->cur_foreground==COLOR_UL)){
!                                             SGR_Foreground(COLOR_BD);
!                                           }
!                                           else   /* Set highlight bit */
!                                             if (term->cur_foreground < 8)
!                                               term->cur_foreground |= 8;
                                          }
!                                       })
                                        break;
                                 case 4:        /* Underscore           */
                                        term->flags |= UNDERLINE;
!                                       if_OPT_ISO_COLORS(screen,{
!                                         if (screen->colorULMode) {
!                                           if (!(term->flags & FG_COLOR)) {
!                                             SGR_Foreground(COLOR_UL);
!                                           }
                                          }
!                                       })
                                        break;
                                 case 7:
                                        term->flags |= INVERSE;
***************
*** 1159,1176 ****
                                 case 35:
                                 case 36:
                                 case 37:
!                                       if( screen->colorMode ) {
                                          SGR_Foreground(
                                                (param[row] - 30)
!                                               /* Set highlight bit if bold */
!                                               | ((term->flags & BOLD)
                                                  ? 8 : 0));
!                                       }
                                        break;
                                 case 39:
!                                       if( screen->colorMode ) {
                                          SGR_Foreground(-1);
!                                       }
                                        break;
                                 case 40:
                                 case 41:
--- 1167,1184 ----
                                 case 35:
                                 case 36:
                                 case 37:
!                                       if_OPT_ISO_COLORS(screen,{
                                          SGR_Foreground(
                                                (param[row] - 30)
!                                               /* Set highlight bit if bold */
!                                               | ((term->flags & BOLD)
                                                  ? 8 : 0));
!                                       })
                                        break;
                                 case 39:
!                                       if_OPT_ISO_COLORS(screen,{
                                          SGR_Foreground(-1);
!                                       })
                                        break;
                                 case 40:
                                 case 41:
***************
*** 1180,1201 ****
                                 case 45:
                                 case 46:
                                 case 47:
!                                       if( screen->colorMode ) {
                                          SGR_Background(param[row] - 40);
!                                       }
                                        break;
                                 case 49:
!                                       if( screen->colorMode ) {
                                          SGR_Background(-1);
!                                       }
                                        break;
                                 case 100:
!                                       if( screen->colorMode ) {
                                          if (term->flags & FG_COLOR)
                                            SGR_Foreground(-1);
                                          if (term->flags & BG_COLOR)
                                            SGR_Background(-1);
!                                       }
                                        break;
                                }
                        }
--- 1188,1209 ----
                                 case 45:
                                 case 46:
                                 case 47:
!                                       if_OPT_ISO_COLORS(screen,{
                                          SGR_Background(param[row] - 40);
!                                       })
                                        break;
                                 case 49:
!                                       if_OPT_ISO_COLORS(screen,{
                                          SGR_Background(-1);
!                                       })
                                        break;
                                 case 100:
!                                       if_OPT_ISO_COLORS(screen,{
                                          if (term->flags & FG_COLOR)
                                            SGR_Foreground(-1);
                                          if (term->flags & BG_COLOR)
                                            SGR_Background(-1);
!                                       })
                                        break;
                                }
                        }
***************
*** 2576,2582 ****
      register TScreen *screen;
  {
      register int rows = screen->max_row + 1;
!     char *save [MAX_PTRS * MAX_ROWS];
      Size_t len = MAX_PTRS * sizeof(char *) * rows;
  
      memcpy ( (char *)save,           (char *)screen->buf,    len);
--- 2584,2590 ----
      register TScreen *screen;
  {
      register int rows = screen->max_row + 1;
!     char *save [4 /* MAX_PTRS */ * MAX_ROWS];
      Size_t len = MAX_PTRS * sizeof(char *) * rows;
  
      memcpy ( (char *)save,           (char *)screen->buf,    len);
***************
*** 2849,2858 ****
     new->screen.menu_font_names[fontMenu_fontsel] = NULL;
     new->screen.menu_font_number = fontMenu_fontdefault;
  
     new->screen.colorMode = request->screen.colorMode;
     new->screen.colorULMode = request->screen.colorULMode;
     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];
     }
--- 2857,2867 ----
     new->screen.menu_font_names[fontMenu_fontsel] = NULL;
     new->screen.menu_font_number = fontMenu_fontdefault;
  
+ #if OPT_ISO_COLORS
+    new->num_ptrs = request->screen.colorMode ? 4 : 2;
     new->screen.colorMode = request->screen.colorMode;
     new->screen.colorULMode = request->screen.colorULMode;
     new->screen.colorBDMode = request->screen.colorBDMode;
     for (i = 0; i < MAXCOLORS; i++) {
         new->screen.Acolors[i] = request->screen.Acolors[i];
     }
***************
*** 2863,2868 ****
--- 2872,2879 ----
         new->screen.original_fg = request->screen.foreground;
         new->screen.original_bg = request->core.background_pixel;
     }
+ #endif /* OPT_ISO_COLORS */
+    new->screen.underline = request->screen.underline;
  
     new->cur_foreground = 0;
     new->cur_background = 0;
***************
*** 3378,3384 ****
  {
        register TScreen *screen = &term->screen;
        GC      currentGC;
!       register int x, y, flags, fg, bg;
        char c;
        Boolean in_selection;
  
--- 3389,3395 ----
  {
        register TScreen *screen = &term->screen;
        GC      currentGC;
!       register int x, y, flags, fg = 0, bg = 0;
        char c;
        Boolean in_selection;
  
***************
*** 3387,3394 ****
  
        c     = SCRN_BUF_CHARS(screen, screen->cursor_row)[screen->cursor_col];
        flags = SCRN_BUF_ATTRS(screen, screen->cursor_row)[screen->cursor_col];
!       fg    = SCRN_BUF_FORES(screen, screen->cursor_row)[screen->cursor_col];
!       bg    = SCRN_BUF_BACKS(screen, screen->cursor_row)[screen->cursor_col];
  
        if (screen->cursor_row > screen->endHRow ||
            (screen->cursor_row == screen->endHRow &&
--- 3398,3408 ----
  
        c     = SCRN_BUF_CHARS(screen, screen->cursor_row)[screen->cursor_col];
        flags = SCRN_BUF_ATTRS(screen, screen->cursor_row)[screen->cursor_col];
! 
!       if_OPT_ISO_COLORS(screen,{
!           fg = SCRN_BUF_FORES(screen, screen->cursor_row)[screen->cursor_col];
!           bg = SCRN_BUF_BACKS(screen, screen->cursor_row)[screen->cursor_col];
!       })
  
        if (screen->cursor_row > screen->endHRow ||
            (screen->cursor_row == screen->endHRow &&
Index: ptyx.h
*** /build/x11r6/XFree86-960721/xc/programs/xterm/ptyx.h        Thu Jul 18 22:00:40 1996
--- /build/x11r6/XFree86-current/xc/programs/xterm/ptyx.h       Wed Jul 24 20:09:29 1996
***************
*** 275,280 ****
--- 275,287 ----
  
  /***====================================================================***/
  
+ #define OPT_ISO_COLORS  1 /* true if xterm is configured with ISO colors */
+ 
+ /***====================================================================***/
+ 
+ #if OPT_ISO_COLORS
+ #define if_OPT_ISO_COLORS(screen, code) if(screen->colorMode) code
+ #define TERM_COLOR_FLAGS (term->flags & (FG_COLOR|BG_COLOR))
  #define MAXCOLORS 18
  #define COLOR_0               0
  #define COLOR_1               1
***************
*** 294,313 ****
  #define COLOR_15      15
  #define COLOR_BD      16
  #define COLOR_UL      17
! 
! #define MAX_PTRS 4    /* the number of pointers per row in 'ScrnBuf' */
  
        /* ScrnBuf-level macros */
  #define BUF_CHARS(buf, row) (buf[MAX_PTRS * (row) + 0])
  #define BUF_ATTRS(buf, row) (buf[MAX_PTRS * (row) + 1])
  #define BUF_FORES(buf, row) (buf[MAX_PTRS * (row) + 2])
  #define BUF_BACKS(buf, row) (buf[MAX_PTRS * (row) + 3])
  
        /* TScreen-level macros */
  #define SCRN_BUF_CHARS(screen, row) BUF_CHARS(screen->buf, row)
  #define SCRN_BUF_ATTRS(screen, row) BUF_ATTRS(screen->buf, row)
  #define SCRN_BUF_FORES(screen, row) BUF_FORES(screen->buf, row)
  #define SCRN_BUF_BACKS(screen, row) BUF_BACKS(screen->buf, row)
  
  typedef struct {
  /* These parameters apply to both windows */
--- 301,335 ----
  #define COLOR_15      15
  #define COLOR_BD      16
  #define COLOR_UL      17
! #else
! #define if_OPT_ISO_COLORS(screen, code) /* nothing */
! #define TERM_COLOR_FLAGS 0
! #endif        /* OPT_ISO_COLORS */
! 
!       /* the number of pointers per row in 'ScrnBuf' */
! #if OPT_ISO_COLORS
! #define MAX_PTRS term->num_ptrs
! #else
! #define MAX_PTRS 2
! #endif
  
        /* ScrnBuf-level macros */
  #define BUF_CHARS(buf, row) (buf[MAX_PTRS * (row) + 0])
  #define BUF_ATTRS(buf, row) (buf[MAX_PTRS * (row) + 1])
+ 
+ #if OPT_ISO_COLORS
  #define BUF_FORES(buf, row) (buf[MAX_PTRS * (row) + 2])
  #define BUF_BACKS(buf, row) (buf[MAX_PTRS * (row) + 3])
+ #endif
  
        /* TScreen-level macros */
  #define SCRN_BUF_CHARS(screen, row) BUF_CHARS(screen->buf, row)
  #define SCRN_BUF_ATTRS(screen, row) BUF_ATTRS(screen->buf, row)
+ 
+ #if OPT_ISO_COLORS
  #define SCRN_BUF_FORES(screen, row) BUF_FORES(screen->buf, row)
  #define SCRN_BUF_BACKS(screen, row) BUF_BACKS(screen->buf, row)
+ #endif
  
  typedef struct {
  /* These parameters apply to both windows */
***************
*** 333,344 ****
--- 355,368 ----
        Pixel           cursorcolor;    /* Cursor color                 */
        Pixel           mousecolor;     /* Mouse color                  */
        Pixel           mousecolorback; /* Mouse color background       */
+ #if OPT_ISO_COLORS
        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?          */
+ #endif
        int             border;         /* inner border                 */
        Cursor          arrow;          /* arrow cursor                 */
        unsigned short  send_mouse_pos; /* user wants mouse transition  */
***************
*** 570,575 ****
--- 594,602 ----
      unsigned  flags;          /* mode flags                   */
      unsigned    cur_foreground;       /* current foreground color     */
      unsigned    cur_background;       /* current background color     */
+ #if OPT_ISO_COLORS
+     int         num_ptrs;     /* number of pointers per row in 'ScrnBuf' */
+ #endif
      unsigned  initflags;      /* initial mode flags           */
      Tabs      tabs;           /* tabstops of the terminal     */
      Misc      misc;           /* miscellaneous parameters     */
Index: screen.c
*** /build/x11r6/XFree86-960721/xc/programs/xterm/screen.c      Sun Jul 21 19:11:02 1996
--- /build/x11r6/XFree86-current/xc/programs/xterm/screen.c     Wed Jul 24 20:09:29 1996
***************
*** 129,135 ****
        register Size_t mincols;
        Char *oldbuf;
        int move_down = 0, move_up = 0;
!       
        if (sbuf == NULL || *sbuf == NULL)
                return 0;
  
--- 129,135 ----
        register Size_t mincols;
        Char *oldbuf;
        int move_down = 0, move_up = 0;
! 
        if (sbuf == NULL || *sbuf == NULL)
                return 0;
  
***************
*** 206,212 ****
  register unsigned cur_fg, cur_bg;
  register int length;          /* length of string */
  {
!       register Char *attrs, *attrs0, *fgs, *bgs;
        register int avail  = screen->max_col - screen->cur_col + 1;
        register Char *col;
        register int wrappedbit;
--- 206,215 ----
  register unsigned cur_fg, cur_bg;
  register int length;          /* length of string */
  {
! #if OPT_ISO_COLORS
!       register Char *fgs = 0, *bgs = 0;
! #endif
!       register Char *attrs;
        register int avail  = screen->max_col - screen->cur_col + 1;
        register Char *col;
        register int wrappedbit;
***************
*** 218,236 ****
  
        col   = SCRN_BUF_CHARS(screen, screen->cur_row) + screen->cur_col;
        attrs = SCRN_BUF_ATTRS(screen, screen->cur_row) + screen->cur_col;
-       fgs   = SCRN_BUF_FORES(screen, screen->cur_row) + screen->cur_col;
-       bgs   = SCRN_BUF_BACKS(screen, screen->cur_row) + screen->cur_col;
  
!       attrs0 = attrs;
!       wrappedbit = *attrs0&LINEWRAPPED;
        flags &= ATTRIBUTES;
        flags |= CHARDRAWN;
        memcpy( col,   str,    length);
        memset( attrs, flags,  length);
!       memset( fgs,   cur_fg, length);
!       memset( bgs,   cur_bg, length);
        if (wrappedbit)
!           *attrs0 |= LINEWRAPPED;
  }
  
  static void
--- 221,245 ----
  
        col   = SCRN_BUF_CHARS(screen, screen->cur_row) + screen->cur_col;
        attrs = SCRN_BUF_ATTRS(screen, screen->cur_row) + screen->cur_col;
  
!       if_OPT_ISO_COLORS(screen,{
!           fgs = SCRN_BUF_FORES(screen, screen->cur_row) + screen->cur_col;
!           bgs = SCRN_BUF_BACKS(screen, screen->cur_row) + screen->cur_col;
!       })
! 
!       wrappedbit = *attrs & LINEWRAPPED;
        flags &= ATTRIBUTES;
        flags |= CHARDRAWN;
        memcpy( col,   str,    length);
        memset( attrs, flags,  length);
! 
!       if_OPT_ISO_COLORS(screen,{
!               memset( fgs,   cur_fg, length);
!               memset( bgs,   cur_bg, length);
!       })
! 
        if (wrappedbit)
!           *attrs |= LINEWRAPPED;
  }
  
  static void
***************
*** 250,258 ****
                 MAX_PTRS * sizeof(char *) * n);
  
        /* clear contents of old rows */
!       if (term->flags & (FG_COLOR|BG_COLOR)) {
                int last = (n * MAX_PTRS);
!               int flags = (term->flags & (FG_COLOR|BG_COLOR));
                for (i = 0; i < last; i += MAX_PTRS) {
                        bzero(save[i+0], size);
                        memset(save[i+1], flags, size);
--- 259,267 ----
                 MAX_PTRS * sizeof(char *) * n);
  
        /* clear contents of old rows */
!       if (TERM_COLOR_FLAGS) {
                int last = (n * MAX_PTRS);
!               int flags = TERM_COLOR_FLAGS;
                for (i = 0; i < last; i += MAX_PTRS) {
                        bzero(save[i+0], size);
                        memset(save[i+1], flags, size);
***************
*** 277,283 ****
  int last;
  register int where, n, size;
  {
!       char *save [MAX_PTRS * MAX_ROWS];
  
        /* save n lines at bottom */
        ScrnClearLines(save, sb, (last -= n - 1), n, size);
--- 286,292 ----
  int last;
  register int where, n, size;
  {
!       char *save [4 /* MAX_PTRS */ * MAX_ROWS];
  
        /* save n lines at bottom */
        ScrnClearLines(save, sb, (last -= n - 1), n, size);
***************
*** 313,319 ****
  register int n, last, size;
  int where;
  {
!       char *save [MAX_PTRS * MAX_ROWS];
  
        ScrnClearLines(save, sb, where, n, size);
  
--- 322,328 ----
  register int n, last, size;
  int where;
  {
!       char *save [4 /* MAX_PTRS */ * MAX_ROWS];
  
        ScrnClearLines(save, sb, where, n, size);
  
***************
*** 329,347 ****
  }
  
  void
! ScrnInsertChar (sb, row, col, n, size)
      /*
!       Inserts n blanks in sb at row, col.  Size is the size of each row.
!       */
!     ScrnBuf sb;
!     int row, size;
!     register int col, n;
  {
        register int i, j;
        register Char *ptr = BUF_CHARS(sb, row);
        register Char *attrs = BUF_ATTRS(sb, row);
        int wrappedbit = attrs[0]&LINEWRAPPED;
!       int flags = CHARDRAWN | (term->flags & (FG_COLOR|BG_COLOR));
  
        attrs[0] &= ~LINEWRAPPED; /* make sure the bit isn't moved */
        for (i = size - 1; i >= col + n; i--) {
--- 338,360 ----
  }
  
  void
! ScrnInsertChar (screen, n, size)
      /*
!      * Inserts n blanks in screen at current row, col.  Size is the size of each
!      * row.
!      */
!     register TScreen *screen;
!     register int n;
!     int size;
  {
+       ScrnBuf sb = screen->buf;
+       int row = screen->cur_row;
+       int col = screen->cur_col;
        register int i, j;
        register Char *ptr = BUF_CHARS(sb, row);
        register Char *attrs = BUF_ATTRS(sb, row);
        int wrappedbit = attrs[0]&LINEWRAPPED;
!       int flags = CHARDRAWN | TERM_COLOR_FLAGS;
  
        attrs[0] &= ~LINEWRAPPED; /* make sure the bit isn't moved */
        for (i = size - 1; i >= col + n; i--) {
***************
*** 353,376 ****
            ptr[i] = ' ';
        for (i=col; i<col+n; i++)
            attrs[i] = flags;
!       if (flags & FG_COLOR)
!           memset(BUF_FORES(sb, row) + col, term->cur_foreground, n);
!       if (flags & BG_COLOR)
!           memset(BUF_BACKS(sb, row) + col, term->cur_background, n);
  
        if (wrappedbit)
            attrs[0] |= LINEWRAPPED;
  }
  
  void
! ScrnDeleteChar (sb, row, col, n, size)
      /*
!       Deletes n characters in sb at row, col. Size is the size of each row.
        */
!     ScrnBuf sb;
!     register int row, size;
!     register int n, col;
  {
        register Char *ptr = BUF_CHARS(sb, row);
        register Char *attrs = BUF_ATTRS(sb, row);
        register Size_t nbytes = (size - n - col);
--- 366,394 ----
            ptr[i] = ' ';
        for (i=col; i<col+n; i++)
            attrs[i] = flags;
!       if_OPT_ISO_COLORS(screen,{
!           if (flags & FG_COLOR)
!               memset(BUF_FORES(sb, row) + col, term->cur_foreground, n);
!           if (flags & BG_COLOR)
!               memset(BUF_BACKS(sb, row) + col, term->cur_background, n);
!       })
  
        if (wrappedbit)
            attrs[0] |= LINEWRAPPED;
  }
  
  void
! ScrnDeleteChar (screen, n, size)
      /*
!       Deletes n characters at current row, col. Size is the size of each row.
        */
!     register TScreen *screen;
!     register int size;
!     register int n;
  {
+       ScrnBuf sb = screen->buf;
+       int row = screen->cur_row;
+       int col = screen->cur_col;
        register Char *ptr = BUF_CHARS(sb, row);
        register Char *attrs = BUF_ATTRS(sb, row);
        register Size_t nbytes = (size - n - col);
***************
*** 379,389 ****
        memcpy (ptr   + col, ptr   + col + n, nbytes);
        memcpy (attrs + col, attrs + col + n, nbytes);
        bzero  (ptr + size - n, n);
!       memset (attrs + size - n, term->flags & (FG_COLOR|BG_COLOR), n);
!       if (term->flags & FG_COLOR)
!           memset(BUF_FORES(sb, row) + size - n, term->cur_foreground, n);
!       if (term->flags & BG_COLOR)
!           memset(BUF_BACKS(sb, row) + size - n, term->cur_background, n);
        if (wrappedbit)
            attrs[0] |= LINEWRAPPED;
  }
--- 397,410 ----
        memcpy (ptr   + col, ptr   + col + n, nbytes);
        memcpy (attrs + col, attrs + col + n, nbytes);
        bzero  (ptr + size - n, n);
!       memset (attrs + size - n, TERM_COLOR_FLAGS, n);
! 
!       if_OPT_ISO_COLORS(screen,{
!           if (term->flags & FG_COLOR)
!               memset(BUF_FORES(sb, row) + size - n, term->cur_foreground, n);
!           if (term->flags & BG_COLOR)
!               memset(BUF_BACKS(sb, row) + size - n, term->cur_background, n);
!       })
        if (wrappedbit)
            attrs[0] |= LINEWRAPPED;
  }
***************
*** 414,427 ****
         screen->cursor_row <= maxrow + topline)
                screen->cursor_state = OFF;
        for (row = toprow; row <= maxrow; y += FontHeight(screen), row++) {
           register Char *chars;
           register Char *attrs;
-          register Char *fgs, *bgs;
           register int col = leftcol;
           int maxcol = leftcol + ncols - 1;
           int lastind;
           int flags;
!          int fg, bg;
           int x, n;
           GC gc;
           Boolean hilite;      
--- 435,450 ----
         screen->cursor_row <= maxrow + topline)
                screen->cursor_state = OFF;
        for (row = toprow; row <= maxrow; y += FontHeight(screen), row++) {
+ #if OPT_ISO_COLORS
+          register Char *fgs = 0, *bgs = 0;
+ #endif
           register Char *chars;
           register Char *attrs;
           register int col = leftcol;
           int maxcol = leftcol + ncols - 1;
           int lastind;
           int flags;
!          int fg = 0, bg = 0;
           int x, n;
           GC gc;
           Boolean hilite;      
***************
*** 436,448 ****
  
           chars = SCRN_BUF_CHARS(screen, lastind + topline);
           attrs = SCRN_BUF_ATTRS(screen, lastind + topline);
!          fgs   = SCRN_BUF_FORES(screen, lastind + topline);
!          bgs   = SCRN_BUF_BACKS(screen, lastind + topline);
  
           if (row < screen->startHRow || row > screen->endHRow ||
               (row == screen->startHRow && maxcol < screen->startHCol) ||
               (row == screen->endHRow && col >= screen->endHCol))
!              {
               /* row does not intersect selection; don't hilite */
               if (!force) {
                   while (col <= maxcol && (attrs[col] & ~BOLD) == 0 &&
--- 459,474 ----
  
           chars = SCRN_BUF_CHARS(screen, lastind + topline);
           attrs = SCRN_BUF_ATTRS(screen, lastind + topline);
! 
!          if_OPT_ISO_COLORS(screen,{
!                  fgs = SCRN_BUF_FORES(screen, lastind + topline);
!                  bgs = SCRN_BUF_BACKS(screen, lastind + topline);
!          })
  
           if (row < screen->startHRow || row > screen->endHRow ||
               (row == screen->startHRow && maxcol < screen->startHCol) ||
               (row == screen->endHRow && col >= screen->endHCol))
!          {
               /* row does not intersect selection; don't hilite */
               if (!force) {
                   while (col <= maxcol && (attrs[col] & ~BOLD) == 0 &&
***************
*** 474,481 ****
           if (col > maxcol) continue;
  
           flags = attrs[col];
!          fg = fgs[col];
!          bg = bgs[col];
           gc = updatedXtermGC(screen, flags, fg, bg, hilite);
           gc_changes |= (flags & (FG_COLOR|BG_COLOR));
  
--- 500,509 ----
           if (col > maxcol) continue;
  
           flags = attrs[col];
!          if_OPT_ISO_COLORS(screen,{
!               fg = fgs[col];
!               bg = bgs[col];
!          })
           gc = updatedXtermGC(screen, flags, fg, bg, hilite);
           gc_changes |= (flags & (FG_COLOR|BG_COLOR));
  
***************
*** 483,491 ****
           lastind = col;
  
           for (; col <= maxcol; col++) {
!               if ((attrs[col] != flags) ||
!                   ((flags & FG_COLOR) && (fgs[col] != fg)) ||
!                   ((flags & BG_COLOR) && (bgs[col] != bg))) {
  
                   XDrawImageString(screen->display, TextWindow(screen), 
                                gc, x, y, (char *) &chars[lastind], n = col - lastind);
--- 511,522 ----
           lastind = col;
  
           for (; col <= maxcol; col++) {
!               if ((attrs[col] != flags)
! #if OPT_ISO_COLORS
!                || ((flags & FG_COLOR) && (fgs[col] != fg))
!                || ((flags & BG_COLOR) && (bgs[col] != bg))
! #endif
!                ) {
  
                   XDrawImageString(screen->display, TextWindow(screen), 
                                gc, x, y, (char *) &chars[lastind], n = col - lastind);
***************
*** 501,508 ****
                   lastind = col;
  
                   flags = attrs[col];
!                  fg = fgs[col];
!                  bg = bgs[col];
                   gc = updatedXtermGC(screen, flags, fg, bg, hilite);
                   gc_changes |= (flags & (FG_COLOR|BG_COLOR));
                }
--- 532,541 ----
                   lastind = col;
  
                   flags = attrs[col];
!                  if_OPT_ISO_COLORS(screen,{
!                       fg = fgs[col];
!                       bg = bgs[col];
!                  })
                   gc = updatedXtermGC(screen, flags, fg, bg, hilite);
                   gc_changes |= (flags & (FG_COLOR|BG_COLOR));
                }
***************
*** 526,535 ****
         * screen foreground and background so that other functions (e.g.,
         * ClearRight) will get the correct colors.
         */
!       if (gc_changes & FG_COLOR)
                SGR_Foreground(term->cur_foreground);
!       if (gc_changes & BG_COLOR)
                SGR_Background(term->cur_background);
  }
  
  void
--- 559,570 ----
         * screen foreground and background so that other functions (e.g.,
         * ClearRight) will get the correct colors.
         */
!       if_OPT_ISO_COLORS(screen,{
!           if (gc_changes & FG_COLOR)
                SGR_Foreground(term->cur_foreground);
!           if (gc_changes & BG_COLOR)
                SGR_Background(term->cur_background);
+       })
  }
  
  void
***************
*** 544,558 ****
        ScrnBuf buf = screen->buf;
        int     len = screen->max_col + 1;
        register int row;
!       register int flags = term->flags & (FG_COLOR|BG_COLOR);
  
        for (row = first; row <= last; row++) {
!               bzero (BUF_CHARS(buf, row), len);
!               memset(BUF_ATTRS(buf, row), flags, len);
                memset(BUF_FORES(buf, row), 
                        (flags & FG_COLOR) ? term->cur_foreground : 0, len);
                memset(BUF_BACKS(buf, row), 
                        (flags & BG_COLOR) ? term->cur_background : 0, len);
        }
  }
  
--- 579,595 ----
        ScrnBuf buf = screen->buf;
        int     len = screen->max_col + 1;
        register int row;
!       register int flags = TERM_COLOR_FLAGS;
  
        for (row = first; row <= last; row++) {
!           bzero (BUF_CHARS(buf, row), len);
!           memset(BUF_ATTRS(buf, row), flags, len);
!           if_OPT_ISO_COLORS(screen,{
                memset(BUF_FORES(buf, row), 
                        (flags & FG_COLOR) ? term->cur_foreground : 0, len);
                memset(BUF_BACKS(buf, row), 
                        (flags & BG_COLOR) ? term->cur_background : 0, len);
+           })
        }
  }
  
Index: util.c
*** /build/x11r6/XFree86-960721/xc/programs/xterm/util.c        Thu Jul 18 22:00:40 1996
--- /build/x11r6/XFree86-current/xc/programs/xterm/util.c       Wed Jul 24 20:09:29 1996
***************
*** 508,515 ****
            }
        }
        /* adjust screen->buf */
!       ScrnInsertChar(screen->buf, screen->cur_row, screen->cur_col, n,
!                       screen->max_col + 1);
  }
  
  /*
--- 508,514 ----
            }
        }
        /* adjust screen->buf */
!       ScrnInsertChar(screen, n, screen->max_col + 1);
  }
  
  /*
***************
*** 549,556 ****
            }
        }
        /* adjust screen->buf */
!       ScrnDeleteChar (screen->buf, screen->cur_row, screen->cur_col, n,
!                       screen->max_col + 1);
  
  }
  
--- 548,554 ----
            }
        }
        /* adjust screen->buf */
!       ScrnDeleteChar (screen, n, screen->max_col + 1);
  
  }
  
***************
*** 637,649 ****
            }
        }
        bzero(BUF_CHARS(buf, screen->cur_row) + screen->cur_col, len);
!       memset(attrs, term->flags & (FG_COLOR|BG_COLOR), len);
!       memset(BUF_FORES(buf, screen->cur_row) + screen->cur_col,
                (term->flags & FG_COLOR)
                ? term->cur_foreground : 0, len);
!       memset(BUF_BACKS(buf, screen->cur_row) + screen->cur_col,
                (term->flags & BG_COLOR)
                ? term->cur_background : 0, len);
  
        /* with the right part cleared, we can't be wrapping */
        attrs[0] &= ~LINEWRAPPED;
--- 635,650 ----
            }
        }
        bzero(BUF_CHARS(buf, screen->cur_row) + screen->cur_col, len);
!       memset(attrs, TERM_COLOR_FLAGS, len);
! 
!       if_OPT_ISO_COLORS(screen,{
!           memset(BUF_FORES(buf, screen->cur_row) + screen->cur_col,
                (term->flags & FG_COLOR)
                ? term->cur_foreground : 0, len);
!           memset(BUF_BACKS(buf, screen->cur_row) + screen->cur_col,
                (term->flags & BG_COLOR)
                ? term->cur_background : 0, len);
+       })
  
        /* with the right part cleared, we can't be wrapping */
        attrs[0] &= ~LINEWRAPPED;
***************
*** 657,663 ****
      register TScreen *screen;
  {
        int len = screen->cur_col + 1;
!       int flags = CHARDRAWN | (term->flags & (FG_COLOR|BG_COLOR));
  
        if(screen->cursor_state)
                HideCursor();
--- 658,664 ----
      register TScreen *screen;
  {
        int len = screen->cur_col + 1;
!       int flags = CHARDRAWN | TERM_COLOR_FLAGS;
  
        if(screen->cursor_state)
                HideCursor();
***************
*** 679,689 ****
        
        memset(SCRN_BUF_CHARS(screen, screen->cur_row), ' ',   len);
        memset(SCRN_BUF_ATTRS(screen, screen->cur_row), flags, len);
!       memset(SCRN_BUF_FORES(screen, screen->cur_row),
                flags & FG_COLOR ? term->cur_foreground : 0, len);
!       memset(SCRN_BUF_BACKS(screen, screen->cur_row),
                flags & BG_COLOR ? term->cur_background : 0, len);
! 
  }
  
  /* 
--- 680,692 ----
        
        memset(SCRN_BUF_CHARS(screen, screen->cur_row), ' ',   len);
        memset(SCRN_BUF_ATTRS(screen, screen->cur_row), flags, len);
! 
!       if_OPT_ISO_COLORS(screen,{
!           memset(SCRN_BUF_FORES(screen, screen->cur_row),
                flags & FG_COLOR ? term->cur_foreground : 0, len);
!           memset(SCRN_BUF_BACKS(screen, screen->cur_row),
                flags & BG_COLOR ? term->cur_background : 0, len);
!       })
  }
  
  /* 
***************
*** 709,718 ****
                useCurBackground(FALSE);
            }
        }
        bzero (SCRN_BUF_CHARS(screen, screen->cur_row), (screen->max_col + 1));
        bzero (SCRN_BUF_ATTRS(screen, screen->cur_row), (screen->max_col + 1));
!       bzero (SCRN_BUF_FORES(screen, screen->cur_row), (screen->max_col + 1));
!       bzero (SCRN_BUF_BACKS(screen, screen->cur_row), (screen->max_col + 1));
  }
  
  void
--- 712,725 ----
                useCurBackground(FALSE);
            }
        }
+ 
        bzero (SCRN_BUF_CHARS(screen, screen->cur_row), (screen->max_col + 1));
        bzero (SCRN_BUF_ATTRS(screen, screen->cur_row), (screen->max_col + 1));
! 
!       if_OPT_ISO_COLORS(screen,{
!           bzero (SCRN_BUF_FORES(screen, screen->cur_row), (screen->max_col + 1));
!           bzero (SCRN_BUF_BACKS(screen, screen->cur_row), (screen->max_col + 1));
!       })
  }
  
  void
***************
*** 1067,1074 ****
         * 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)
--- 1074,1083 ----
         * We don't swap colors that happen to match the screen's foreground
         * and background because that tends to produce bizarre effects.
         */
!       if_OPT_ISO_COLORS(screen,{
!               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)
***************
*** 1095,1100 ****
--- 1104,1115 ----
                ScrollBarReverseVideo(screen->scrollWidget);
  
        XSetWindowBackground(screen->display, TextWindow(screen), termw->core.background_pixel);
+ 
+       /* the shell-window's background will be used in the first repainting
+        * on resizing
+        */
+       XSetWindowBackground(screen->display, VShellWindow, termw->core.background_pixel);
+ 
        if(tek) {
            TekReverseVideo(screen);
        }
***************
*** 1201,1207 ****
        }
  }
  
! /* GET_FG */
  Pixel
  getXtermForeground(flags, color)
        int flags;
--- 1216,1222 ----
        }
  }
  
! #if OPT_ISO_COLORS
  Pixel
  getXtermForeground(flags, color)
        int flags;
***************
*** 1217,1223 ****
        return fg;
  }
  
- /* GET_BG */
  Pixel
  getXtermBackground(flags, color)
        int flags;
--- 1232,1237 ----
***************
*** 1265,1267 ****
--- 1279,1282 ----
                left, top, width, height, FALSE);
        useCurBackground(FALSE);
  }
+ #endif /* OPT_ISO_COLORS */
Index: xterm.h
*** /build/x11r6/XFree86-960721/xc/programs/xterm/xterm.h       Sun Jun 30 12:03:00 1996
--- /build/x11r6/XFree86-current/xc/programs/xterm/xterm.h      Wed Jul 24 20:09:29 1996
***************
*** 48,55 ****
  extern int v_write PROTO((int f, char *d, int len));
  extern void FindFontSelection PROTO((char *atom_name, Bool justprobe));
  extern void HideCursor PROTO((void));
- extern void SGR_Background PROTO((int color));
- extern void SGR_Foreground PROTO((int color));
  extern void SetVTFont PROTO((int i, Bool doresize, char *name1, char *name2));
  extern void ShowCursor PROTO((void));
  extern void SwitchBufPtrs PROTO((TScreen *screen));
--- 48,53 ----
***************
*** 59,64 ****
--- 57,67 ----
  extern void unparseputc PROTO((int c, int fd));
  extern void unparseseq PROTO((ANSI *ap, int fd));
  
+ #if OPT_ISO_COLORS
+ extern void SGR_Background PROTO((int color));
+ extern void SGR_Foreground PROTO((int color));
+ #endif
+ 
  /* cursor.c */
  extern void CarriageReturn PROTO((TScreen *screen));
  extern void CursorBack PROTO((TScreen *screen, int  n));
***************
*** 140,148 ****
  extern int ScrnGetAttributes PROTO((TScreen *screen, int row, int col, Char *str, int length));
  extern void ClearBufRows PROTO((TScreen *screen, int first, int last));
  extern void ScreenWrite PROTO((TScreen *screen, char *str, unsigned flags, unsigned cur_fg, unsigned cur_bg, int length));
! extern void ScrnDeleteChar PROTO((ScrnBuf sb, int row, int size, int n, int col));
  extern void ScrnDeleteLine PROTO((ScrnBuf sb, int n, int last, int size, int where));
! extern void ScrnInsertChar PROTO((ScrnBuf sb, int row, int size, int col, int n));
  extern void ScrnInsertLine PROTO((ScrnBuf sb, int last, int where, int n, int size));
  extern void ScrnRefresh PROTO((TScreen *screen, int toprow, int leftcol, int nrows, int ncols, int force));
  extern void ScrnSetAttributes PROTO((TScreen *screen, int row, int col, unsigned mask, unsigned value, int length));
--- 143,151 ----
  extern int ScrnGetAttributes PROTO((TScreen *screen, int row, int col, Char *str, int length));
  extern void ClearBufRows PROTO((TScreen *screen, int first, int last));
  extern void ScreenWrite PROTO((TScreen *screen, char *str, unsigned flags, unsigned cur_fg, unsigned cur_bg, int length));
! extern void ScrnDeleteChar PROTO((TScreen *screen, int n, int size));
  extern void ScrnDeleteLine PROTO((ScrnBuf sb, int n, int last, int size, int where));
! extern void ScrnInsertChar PROTO((TScreen *screen, int n, int size));
  extern void ScrnInsertLine PROTO((ScrnBuf sb, int last, int where, int n, int size));
  extern void ScrnRefresh PROTO((TScreen *screen, int toprow, int leftcol, int nrows, int ncols, int force));
  extern void ScrnSetAttributes PROTO((TScreen *screen, int row, int col, unsigned mask, unsigned value, int length));
***************
*** 167,180 ****
  
  /* 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));
  extern void ClearAbove PROTO((TScreen *screen));
  extern void ClearBelow PROTO((TScreen *screen));
- extern void ClearCurBackground PROTO((TScreen *screen, int top, int left, unsigned height, unsigned width));
  extern void ClearLeft PROTO((TScreen *screen));
  extern void ClearLine PROTO((TScreen *screen));
  extern void ClearRight PROTO((TScreen *screen));
--- 170,180 ----
***************
*** 191,196 ****
--- 191,216 ----
  extern void recolor_cursor PROTO((Cursor cursor, unsigned long fg, unsigned long bg));
  extern void resetXtermGC PROTO((TScreen *screen, int flags, Bool hilite));
  extern void scrolling_copy_area PROTO((TScreen *screen, int firstline, int nlines, int amount));
+ 
+ #if OPT_ISO_COLORS
+ 
+ extern Pixel getXtermBackground PROTO((int flags, int color));
+ extern Pixel getXtermForeground PROTO((int flags, int color));
+ extern void ClearCurBackground PROTO((TScreen *screen, int top, int left, unsigned height, unsigned width));
  extern void useCurBackground PROTO((Bool flag));
+ 
+ #else /* !OPT_ISO_COLORS */
+ 
+ #define ClearCurBackground(screen, top, left, height, width) \
+       XClearArea (screen->display, TextWindow(screen), \
+               left, top, width, height, FALSE)
+ 
+               /* FIXME: Reverse-Video? */
+ #define getXtermBackground(flags, color) term->core.background_pixel
+ #define getXtermForeground(flags, color) term->screen.foreground
+ 
+ #define useCurBackground(flag) /*nothing*/
+ 
+ #endif        /* OPT_ISO_COLORS */
  
  #endif        /* included_xterm_h */