xterm-129.patch.txt

# ------------------------------------------------------------------------------
#  charproc.c     |   28 ++++++++++++++++------------
#  misc.c         |   36 ++++++++++++++++++++++++++++--------
#  ptyx.h         |   53 ++++++++++++++++++++++++++++++++++++++---------------
#  termcap        |    2 +-
#  terminfo       |   12 ++++++------
#  util.c         |   11 +++--------
#  version.h      |    4 ++--
#  xterm.h        |   13 +++++++++++--
#  xterm.log.html |   13 +++++++++++++
#  9 files changed, 118 insertions, 54 deletions
# ------------------------------------------------------------------------------
Index: charproc.c
--- xterm-128+/charproc.c       Mon Feb 21 23:08:50 2000
+++ xterm-129/charproc.c        Sat Feb 26 16:35:15 2000
@@ -196,7 +196,7 @@
 #if DFT_COLORMODE
 #define DFT_COLOR(name) name
 #else
-#define DFT_COLOR(name) "XtDefaultForeground"
+#define DFT_COLOR(name) XtDefaultForeground
 #endif
 #endif
 
@@ -411,9 +411,9 @@
        XtRBoolean, (XtPointer) &defaultFALSE},
 {XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel),
        XtOffsetOf(XtermWidgetRec, core.background_pixel),
-       XtRString, "XtDefaultBackground"},
-COLOR_RES(XtNforeground,       screen.foreground,      "XtDefaultForeground"),
-COLOR_RES(XtNcursorColor,      screen.cursorcolor,     "XtDefaultForeground"),
+       XtRString, XtDefaultBackground},
+Cres(XtNforeground,    screen.foreground,      XtDefaultForeground),
+Cres(XtNcursorColor,   screen.cursorcolor,     XtDefaultForeground),
 #if OPT_BLINK_CURS
 {XtNcursorBlink, XtCCursorBlink, XtRBoolean, sizeof(Boolean),
        XtOffsetOf(XtermWidgetRec, screen.cursor_blink),
@@ -488,7 +488,7 @@
 {XtNmarginBell, XtCMarginBell, XtRBoolean, sizeof(Boolean),
        XtOffsetOf(XtermWidgetRec, screen.marginbell),
        XtRBoolean, (XtPointer) &defaultFALSE},
-COLOR_RES(XtNpointerColor,     screen.mousecolor,      "XtDefaultForeground"),
+Cres(XtNpointerColor,  screen.mousecolor,      XtDefaultForeground),
 {XtNpointerColorBackground, XtCBackground, XtRPixel, sizeof(Pixel),
        XtOffsetOf(XtermWidgetRec, screen.mousecolorback),
        XtRString, "XtDefaultBackground"},
@@ -659,9 +659,9 @@
 #elif OPT_88_COLORS
 # include <88colres.h>
 #endif
-COLOR_RES(XtNcolorBD,  screen.Acolors[COLOR_BD],       DFT_COLOR("XtDefaultForeground")),
-COLOR_RES(XtNcolorBL,  screen.Acolors[COLOR_BL],       DFT_COLOR("XtDefaultForeground")),
-COLOR_RES(XtNcolorUL,  screen.Acolors[COLOR_UL],       DFT_COLOR("XtDefaultForeground")),
+COLOR_RES(XtNcolorBD,  screen.Acolors[COLOR_BD],       DFT_COLOR(XtDefaultForeground)),
+COLOR_RES(XtNcolorBL,  screen.Acolors[COLOR_BL],       DFT_COLOR(XtDefaultForeground)),
+COLOR_RES(XtNcolorUL,  screen.Acolors[COLOR_UL],       DFT_COLOR(XtDefaultForeground)),
 {XtNcolorMode, XtCColorMode, XtRBoolean, sizeof(Boolean),
        XtOffsetOf(XtermWidgetRec, screen.colorMode),
        XtRBoolean, (XtPointer) &defaultCOLORMODE},
@@ -685,7 +685,7 @@
        XtOffsetOf(XtermWidgetRec, misc.dynamicColors),
        XtRBoolean, (XtPointer) &defaultTRUE},
 #if OPT_HIGHLIGHT_COLOR
-COLOR_RES(XtNhighlightColor,   screen.highlightcolor,  "XtDefaultForeground"),
+Cres(XtNhighlightColor,        screen.highlightcolor,  XtDefaultForeground),
 #endif /* OPT_HIGHLIGHT_COLOR */
 {XtNboldMode, XtCBoldMode, XtRBoolean, sizeof(Boolean),
        XtOffsetOf(XtermWidgetRec, screen.bold_mode),
@@ -857,7 +857,6 @@
 {
        int fg = term->sgr_foreground;
 
-#if NUM_ANSI_COLORS < 256
        if (term->screen.colorAttrMode
         || (fg < 0)) {
                if (term->screen.colorULMode && (term->flags & UNDERLINE))
@@ -867,7 +866,6 @@
                if (term->screen.colorBLMode && (term->flags & BLINK))
                        fg = COLOR_BL;
        }
-#endif
 
        /* This implements the IBM PC-style convention of 8-colors, with one
         * bit for bold, thus mapping the 0-7 codes to 8-15.  It won't make
@@ -4306,12 +4304,18 @@
    wnew->screen.colorULMode   = request->screen.colorULMode;
 
    for (i = 0, color_ok = False; i < MAXCOLORS; i++) {
-       TRACE(("Acolors[%d] = %#lx\n", i, request->screen.Acolors[i]));
        wnew->screen.Acolors[i] = request->screen.Acolors[i];
+#if OPT_COLOR_RES
+       TRACE(("Acolors[%d] = %s\n", i, request->screen.Acolors[i].resource));
+       if (strcmp(wnew->screen.Acolors[i].resource, XtDefaultForeground))
+          color_ok = True;
+#else
+       TRACE(("Acolors[%d] = %#lx\n", i, request->screen.Acolors[i]));
        if (wnew->screen.Acolors[i] != wnew->dft_foreground
        && wnew->screen.Acolors[i] != request->screen.foreground
        && wnew->screen.Acolors[i] != request->core.background_pixel)
           color_ok = True;
+#endif
    }
 
    /* If none of the colors are anything other than the foreground or
Index: misc.c
--- xterm-128+/misc.c   Wed Feb  9 17:47:18 2000
+++ xterm-129/misc.c    Sat Feb 26 15:48:56 2000
@@ -1017,7 +1017,7 @@
        char buffer[80];
 
        TRACE(("ReportAnsiColorRequest %d\n", colornum));
-       color.pixel = pTerm->screen.Acolors[colornum];
+       color.pixel = GET_COLOR_RES(pTerm->screen.Acolors[colornum]);
        XQueryColor(term->screen.display, cmap, &color);
        sprintf(buffer, "4;%d;rgb:%04x/%04x/%04x",
                colornum,
@@ -1032,23 +1032,43 @@
 static Boolean
 AllocateAnsiColor(
        XtermWidget      pTerm,
-       int              color,
-       char            *name)
+       ColorRes        *res,
+       char            *spec)
 {
 XColor                  def;
 register TScreen       *screen =       &pTerm->screen;
 Colormap                cmap =         pTerm->core.colormap;
 
-    if (XParseColor(screen->display, cmap, name, &def)
+    if (XParseColor(screen->display, cmap, spec, &def)
      && XAllocColor(screen->display, cmap, &def)) {
-       screen->Acolors[color] = def.pixel;
-       TRACE(("AllocateAnsiColor #%d: %s (pixel %#lx)\n", color, name, def.pixel));
+       SET_COLOR_RES(res, def.pixel);
+       TRACE(("AllocateAnsiColor %s (pixel %#lx)\n", spec, def.pixel));
        return(TRUE);
     }
-    TRACE(("AllocateAnsiColor #%d: %s (failed)\n", color, name));
+    TRACE(("AllocateAnsiColor %s (failed)\n", spec));
     return(FALSE);
 }
 
+#if OPT_COLOR_RES
+Pixel
+xtermGetColorRes(ColorRes *res)
+{
+       if (!res->mode) {
+               if (AllocateAnsiColor(term, res, res->resource)) {
+                       res->mode = True;
+               } else {
+                       res->value = term->screen.foreground;
+                       res->mode = -True;
+                       fprintf(stderr,
+                               "%s: Cannot allocate color %s\n",
+                               xterm_name,
+                               res->resource);
+               }
+       }
+       return res->value;
+}
+#endif
+
 static Boolean
 ChangeAnsiColorRequest(
        XtermWidget     pTerm,
@@ -1077,7 +1097,7 @@
        }
        if (!strcmp(name, "?"))
            ReportAnsiColorRequest(pTerm, color, final);
-       else if (!AllocateAnsiColor(pTerm, color, name))
+       else if (!AllocateAnsiColor(pTerm, &(pTerm->screen.Acolors[color]), name))
            break;
        /* FIXME:  free old color somehow?  We aren't for the other color
         * change style (dynamic colors).
Index: ptyx.h
--- xterm-128+/ptyx.h   Sun Feb 13 08:01:12 2000
+++ xterm-129/ptyx.h    Sat Feb 26 16:17:35 2000
@@ -322,28 +322,25 @@
 #define RES_OFFSET(offset) XtOffsetOf(XtermWidgetRec, offset)
 #endif
 
+#define RES_NAME(name) name
+#define RES_CLASS(name) name
+
 #define Bres(name,class,offset,value) \
-       {name, class, XtRBoolean, sizeof(Boolean), \
+       {RES_NAME(name), RES_CLASS(class), XtRBoolean, sizeof(Boolean), \
         RES_OFFSET(offset), XtRImmediate, (XtPointer) value}
 
+#define Cres(name,offset,value) \
+       {RES_NAME(name), XtCForeground, XtRPixel, sizeof(Pixel), \
+        RES_OFFSET(offset), XtRString, value}
+
 #define Ires(name,class,offset,value) \
-       {name, class, XtRInt, sizeof(int), \
-        RES_OFFSET(offset), XtRInt, (XtPointer) value}
+       {RES_NAME(name), RES_CLASS(class), XtRInt, sizeof(int), \
+        RES_OFFSET(offset), XtRImmediate, (XtPointer) value}
 
 #define Sres(name,class,offset,value) \
-       {name, class, XtRString, sizeof(String), \
+       {RES_NAME(name), RES_CLASS(class), XtRString, sizeof(char *), \
         RES_OFFSET(offset), XtRString, (XtPointer) value}
 
-#define COLOR_RES(name,offset,value) \
-       {name, XtCForeground, XtRPixel, sizeof(Pixel), \
-        RES_OFFSET(offset), XtRString, value}
-
-typedef struct {
-       unsigned        which;  /* must have NCOLORS bits */
-       Pixel           colors[NCOLORS];
-       char            *names[NCOLORS];
-} ScrnColors;
-
 /***====================================================================***/
 
 #if (XtSpecificationRelease < 6)
@@ -368,6 +365,10 @@
 #define OPT_CLIP_BOLD  1 /* true if xterm uses clipping to avoid bold-trash */
 #endif
 
+#ifndef OPT_COLOR_RES
+#define OPT_COLOR_RES   1 /* true if xterm delays color-resource evaluation */
+#endif
+
 #ifndef OPT_DEC_CHRSET
 #define OPT_DEC_CHRSET  1 /* true if xterm is configured for DEC charset */
 #endif
@@ -583,6 +584,12 @@
 # define if_OPT_ISO_TRADITIONAL_COLORS(screen, code) /*nothing*/
 #endif
 
+#if OPT_COLOR_RES
+#define COLOR_RES(name,offset,value) Sres(name, XtCForeground, offset.resource, value)
+#else
+#define COLOR_RES(name,offset,value) Cres(name, offset, value)
+#endif
+
 /***====================================================================***/
 
 #if OPT_DEC_CHRSET
@@ -806,6 +813,22 @@
 
 #define NUM_POPUP_MENUS 4
 
+#if OPT_COLOR_RES
+typedef struct {
+       String          resource;
+       Pixel           value;
+       int             mode;
+} ColorRes;
+#else
+#define ColorRes Pixel
+#endif
+
+typedef struct {
+       unsigned        which;  /* must have NCOLORS bits */
+       Pixel           colors[NCOLORS];
+       char            *names[NCOLORS];
+} ScrnColors;
+
 typedef struct {
        Boolean         saved;
        int             row;
@@ -873,7 +896,7 @@
        Pixel           mousecolor;     /* Mouse color                  */
        Pixel           mousecolorback; /* Mouse color background       */
 #if OPT_ISO_COLORS
-       Pixel           Acolors[MAXCOLORS]; /* ANSI color emulation     */
+       ColorRes        Acolors[MAXCOLORS]; /* ANSI color emulation     */
        Boolean         boldColors;     /* can we make bold colors?     */
        Boolean         colorMode;      /* are we using color mode?     */
        Boolean         colorULMode;    /* use color for underline?     */
Index: termcap
--- xterm-128+/termcap  Wed Feb  9 17:47:18 2000
+++ xterm-129/termcap   Sat Feb 26 22:41:51 2000
@@ -116,7 +116,7 @@
        :nd=\233C:rc=\E8:sc=\E7:se=\23327m:sf=^J:so=\2337m:sr=\215:\
        :st=\210:ta=^I:te=\233?1049l:ti=\233?1049h:ue=\23324m:\
        :up=\233A:us=\2334m:vb=\233?5h\233?5l:ve=\233?25h:\
-       :vi=\233?25l:vs=\233?25h:
+       :vi=\233?25l:
 #
 hp|xterm-hp|XFree86 xterm with hpterm function keys:\
        :k1=\Ep:k2=\Eq:k3=\Er:k4=\Es:k5=\Et:\
Index: terminfo
--- xterm-128+/terminfo Wed Feb  9 17:47:18 2000
+++ xterm-129/terminfo  Sat Feb 26 23:05:48 2000
@@ -92,6 +92,7 @@
 # pageup and pagedown for window manager functions. 
 #
 xterm-xfree86|xterm-new|xterm terminal emulator (XFree86),
+       npc,
        kDC=\E[3;5~,
        kEND=\EO5F,
        kHOM=\EO5H,
@@ -196,7 +197,6 @@
        cup=\E[%i%p1%d;%p2%dH,
        cuu=\E[%p1%dA,
        cuu1=\E[A,
-       cvvis=\E[?25h,
        dch=\E[%p1%dP,
        dch1=\E[P,
        dl=\E[%p1%dM,
@@ -206,7 +206,7 @@
        el=\E[K,
        el1=\E[1K,
        enacs=\E(B\E)0,
-       flash=\E[?5h\E[?5l,
+       flash=\E[?5h$<100/>\E[?5l,
        home=\E[H,
        hpa=\E[%i%p1%dG,
        ht=^I,
@@ -242,7 +242,7 @@
        setaf=\E[3%p1%dm,
        setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
        setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
-       sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
+       sgr=\E[0%?%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
        sgr0=\E[m\017,
        smacs=^N,
        smam=\E[?7h,
@@ -577,6 +577,7 @@
        mc5i,
        mir,
        msgr,
+       npc,
        xenl,
        colors#8,
        cols#80,
@@ -602,7 +603,6 @@
        cup=\233%i%p1%d;%p2%dH,
        cuu=\233%p1%dA,
        cuu1=\233A,
-       cvvis=\233?25h,
        dch=\233%p1%dP,
        dch1=\233P,
        dl=\233%p1%dM,
@@ -612,7 +612,7 @@
        el=\233K,
        el1=\2331K,
        enacs=\E(B\E)0,
-       flash=\233?5h\233?5l,
+       flash=\233?5h$<100/>\233?5l,
        home=\233H,
        hpa=\233%i%p1%dG,
        ht=^I,
@@ -686,7 +686,7 @@
        setaf=\2333%p1%dm,
        setb=\2334%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
        setf=\2333%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
-       sgr=\2330%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
+       sgr=\2330%?%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
        sgr0=\233m^O,
        smacs=^N,
        smam=\233?7h,
Index: util.c
--- xterm-128+/util.c   Sat Feb 12 06:47:41 2000
+++ xterm-129/util.c    Sat Feb 26 16:35:43 2000
@@ -1266,8 +1266,9 @@
         * 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 )
+               ColorRes tmp2;
+               EXCHANGE( screen->Acolors[0], screen->Acolors[7],  tmp2 )
+               EXCHANGE( screen->Acolors[8], screen->Acolors[15], tmp2 )
        })
 
        tmp = termw->core.background_pixel;
@@ -1752,11 +1753,6 @@
        fg = (int) ((color >> 4) & 0xf);
 #endif
 
-       /*
-        * If we allow exactly 256 colors, there is no room in a byte for
-        * the bold/blink/underline colors.
-        */
-#if NUM_ANSI_COLORS < 256
        if (term->screen.colorAttrMode
         || (fg == extract_bg(color))) {
                if (term->screen.colorULMode && (flags & UNDERLINE))
@@ -1766,7 +1762,6 @@
                if (term->screen.colorBLMode && (flags & BLINK))
                        fg = COLOR_BL;
        }
-#endif
        return fg;
 }
 
Index: version.h
--- xterm-128+/version.h        Thu Feb 17 17:33:19 2000
+++ xterm-129/version.h Sat Feb 26 16:52:07 2000
@@ -6,5 +6,5 @@
  * XFree86 to which this version of xterm has been built.  The number in
  * parentheses is my patch number (T.Dickey).
  */
-#define XTERM_PATCH   128
-#define XFREE86_VERSION "XFree86 3.9.18"
+#define XTERM_PATCH   129
+#define XFREE86_VERSION "XFree86 3.9.18a"
Index: xterm.h
--- xterm-128+/xterm.h  Sun Feb 13 08:01:12 2000
+++ xterm-129/xterm.h   Sat Feb 26 13:47:46 2000
@@ -701,13 +701,22 @@
 
 #define getXtermForeground(flags, color) \
        (((flags) & FG_COLOR) && ((color) >= 0) \
-                       ? term->screen.Acolors[color] \
+                       ? GET_COLOR_RES(term->screen.Acolors[color]) \
                        : term->screen.foreground)
 
 #define getXtermBackground(flags, color) \
        (((flags) & BG_COLOR) && ((color) >= 0) \
-                       ? term->screen.Acolors[color] \
+                       ? GET_COLOR_RES(term->screen.Acolors[color]) \
                        : term->core.background_pixel)
+
+#if OPT_COLOR_RES
+#define GET_COLOR_RES(res) xtermGetColorRes(&res)
+#define SET_COLOR_RES(res,color) res->value = color
+extern Pixel xtermGetColorRes(ColorRes *res);
+#else
+#define GET_COLOR_RES(res) res
+#define SET_COLOR_RES(res,color) *res = color
+#endif
 
 #if OPT_EXT_COLORS
 #define extract_bg(color) ((int)((color) & 0xff))
Index: xterm.log.html
--- xterm-128+/xterm.log.html   Thu Feb 17 17:33:19 2000
+++ xterm-129/xterm.log.html    Sat Feb 26 22:21:12 2000
@@ -41,6 +41,7 @@
 xc/programs/Xserver/hw/xfree86).
 
 <UL>
+<LI><A HREF="#xterm_129">Patch #129 - 2000/2/26 - XFree86 3.9.18a</A>
 <LI><A HREF="#xterm_128">Patch #128 - 2000/2/17 - XFree86 3.9.18</A>
 <LI><A HREF="#xterm_127">Patch #127 - 2000/2/12 - XFree86 3.9.17e</A>
 <LI><A HREF="#xterm_126">Patch #126 - 2000/2/8 - XFree86 3.9.17c</A>
@@ -171,6 +172,18 @@
 <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_129">Patch #129 - 2000/2/26 - XFree86 3.9.18a</A></H1>
+<ul>
+       <li>improve initialization of ANSI colors by delaying allocation until
+         each color is first used.
+
+       <li>remove ifdef that prevented colorBD/colorUL/colorBL resources from
+         working when 256-color configuration was built (reported by
+         Todd Larason).
+
+       <li>fix some minor inconsistencies in terminfo (Debian #58530).
+</ul>
 
 <H1><A NAME="xterm_128">Patch #128 - 2000/2/17 - XFree86 3.9.18</A></H1>
 <ul>