To: vim-dev@vim.org Subject: Patch 6.1.049 (extra) Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.049 (extra) Problem: On a 32 bit display a valid color may cause an error message, because its pixel value is negative. (Chris Paulson-Ellis) Solution: Check for -11111 instead of the color being negative. Don't add one to the pixel value, -1 may be used for white. Files: src/globals.h, src/gui.c, src/gui.h, src/gui_amiga.c, src/gui_athena.c, src/gui_beos.cc, src/gui_gtk_x11.c, src/gui_mac.c, src/gui_motif.c, src/gui_photon.c, src/gui_riscos.c, src/gui_w16.c, src/gui_w32.c, src/gui_w48.c, src/gui_x11.c, src/mbyte.c, src/syntax.c *** ../vim61.048/src/globals.h Mon Apr 29 21:59:52 2002 --- src/globals.h Thu May 2 22:04:09 2002 *************** *** 620,627 **** # else EXTERN XIC xic INIT(= NULL); # endif ! EXTERN guicolor_T xim_fg_color INIT(= (guicolor_T)-1); ! EXTERN guicolor_T xim_bg_color INIT(= (guicolor_T)-1); #endif #ifdef FEAT_HANGULIN --- 620,627 ---- # else EXTERN XIC xic INIT(= NULL); # endif ! EXTERN guicolor_T xim_fg_color INIT(= INVALCOLOR); ! EXTERN guicolor_T xim_bg_color INIT(= INVALCOLOR); #endif #ifdef FEAT_HANGULIN *** ../vim61.048/src/gui.c Wed May 1 21:20:47 2002 --- src/gui.c Thu May 2 21:54:33 2002 *************** *** 830,837 **** id = shape_table[idx].id; /* get the colors and attributes for the cursor. Default is inverted */ ! cfg = (guicolor_T)-1; ! cbg = (guicolor_T)-1; cattr = HL_INVERSE; gui_mch_set_blinking(shape_table[idx].blinkwait, shape_table[idx].blinkon, --- 830,837 ---- id = shape_table[idx].id; /* get the colors and attributes for the cursor. Default is inverted */ ! cfg = INVALCOLOR; ! cbg = INVALCOLOR; cattr = HL_INVERSE; gui_mch_set_blinking(shape_table[idx].blinkwait, shape_table[idx].blinkon, *************** *** 850,863 **** if (iid > 0) { syn_id2colors(iid, &fg, &bg); ! if (bg > 0) cbg = bg; } } } #endif - --cbg; - --cfg; } /* --- 850,861 ---- if (iid > 0) { syn_id2colors(iid, &fg, &bg); ! if (bg != INVALCOLOR) cbg = bg; } } } #endif } /* *************** *** 870,898 **** if (aep != NULL) { attr = aep->ae_attr; ! if (cfg < 0) cfg = ((attr & HL_INVERSE) ? aep->ae_u.gui.bg_color ! : aep->ae_u.gui.fg_color) - 1; ! if (cbg < 0) cbg = ((attr & HL_INVERSE) ? aep->ae_u.gui.fg_color ! : aep->ae_u.gui.bg_color) - 1; } ! if (cfg < 0) cfg = (attr & HL_INVERSE) ? gui.back_pixel : gui.norm_pixel; ! if (cbg < 0) cbg = (attr & HL_INVERSE) ? gui.norm_pixel : gui.back_pixel; #ifdef FEAT_XIM if (aep != NULL) { xim_bg_color = ((attr & HL_INVERSE) ? aep->ae_u.gui.fg_color ! : aep->ae_u.gui.bg_color) - 1; xim_fg_color = ((attr & HL_INVERSE) ? aep->ae_u.gui.bg_color ! : aep->ae_u.gui.fg_color) - 1; ! if (xim_bg_color < 0) xim_bg_color = (attr & HL_INVERSE) ? gui.norm_pixel : gui.back_pixel; ! if (xim_fg_color < 0) xim_fg_color = (attr & HL_INVERSE) ? gui.back_pixel : gui.norm_pixel; } --- 868,896 ---- if (aep != NULL) { attr = aep->ae_attr; ! if (cfg == INVALCOLOR) cfg = ((attr & HL_INVERSE) ? aep->ae_u.gui.bg_color ! : aep->ae_u.gui.fg_color); ! if (cbg == INVALCOLOR) cbg = ((attr & HL_INVERSE) ? aep->ae_u.gui.fg_color ! : aep->ae_u.gui.bg_color); } ! if (cfg == INVALCOLOR) cfg = (attr & HL_INVERSE) ? gui.back_pixel : gui.norm_pixel; ! if (cbg == INVALCOLOR) cbg = (attr & HL_INVERSE) ? gui.norm_pixel : gui.back_pixel; #ifdef FEAT_XIM if (aep != NULL) { xim_bg_color = ((attr & HL_INVERSE) ? aep->ae_u.gui.fg_color ! : aep->ae_u.gui.bg_color); xim_fg_color = ((attr & HL_INVERSE) ? aep->ae_u.gui.bg_color ! : aep->ae_u.gui.fg_color); ! if (xim_bg_color == INVALCOLOR) xim_bg_color = (attr & HL_INVERSE) ? gui.norm_pixel : gui.back_pixel; ! if (xim_fg_color == INVALCOLOR) xim_fg_color = (attr & HL_INVERSE) ? gui.back_pixel : gui.norm_pixel; } *************** *** 1839,1853 **** else if (aep != NULL) { fg_color = aep->ae_u.gui.fg_color; ! if (fg_color == 0) fg_color = gui.norm_pixel; - else - --fg_color; bg_color = aep->ae_u.gui.bg_color; ! if (bg_color == 0) bg_color = gui.back_pixel; - else - --bg_color; } else fg_color = gui.norm_pixel; --- 1837,1847 ---- else if (aep != NULL) { fg_color = aep->ae_u.gui.fg_color; ! if (fg_color == INVALCOLOR) fg_color = gui.norm_pixel; bg_color = aep->ae_u.gui.bg_color; ! if (bg_color == INVALCOLOR) bg_color = gui.back_pixel; } else fg_color = gui.norm_pixel; *************** *** 3659,3668 **** void gui_check_colors() { ! if (gui.norm_pixel == gui.back_pixel || gui.norm_pixel == (guicolor_T)-1) { gui_set_bg_color((char_u *)"White"); ! if (gui.norm_pixel == gui.back_pixel || gui.norm_pixel == (guicolor_T)-1) gui_set_fg_color((char_u *)"Black"); } } --- 3653,3662 ---- void gui_check_colors() { ! if (gui.norm_pixel == gui.back_pixel || gui.norm_pixel == INVALCOLOR) { gui_set_bg_color((char_u *)"White"); ! if (gui.norm_pixel == gui.back_pixel || gui.norm_pixel == INVALCOLOR) gui_set_fg_color((char_u *)"Black"); } } *************** *** 3685,3691 **** /* * Allocate a color by name. ! * Returns -1 and gives an error message when failed. */ guicolor_T gui_get_color(name) --- 3679,3685 ---- /* * Allocate a color by name. ! * Returns INVALCOLOR and gives an error message when failed. */ guicolor_T gui_get_color(name) *************** *** 3694,3702 **** guicolor_T t; if (*name == NUL) ! return (guicolor_T)-1; t = gui_mch_get_color(name); ! if (t < 0 #if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) && gui.in_use #endif --- 3688,3696 ---- guicolor_T t; if (*name == NUL) ! return INVALCOLOR; t = gui_mch_get_color(name); ! if (t == INVALCOLOR #if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) && gui.in_use #endif *** ../vim61.048/src/gui.h Wed May 1 21:20:47 2002 --- src/gui.h Thu May 2 21:01:33 2002 *************** *** 224,229 **** --- 224,232 ---- typedef long guicolor_T; /* handle for a GUI color; for X11 this should be "Pixel", but that's an unsigned and we need a signed value */ + #define INVALCOLOR (guicolor_T)-11111 /* number for invalid color; on 32 bit + displays there is a tiny chance this is an + actual color */ #ifdef FEAT_GUI_GTK typedef GdkFont *GuiFont; /* handle for a GUI font */ *** ../vim61.048/src/gui_amiga.c Thu Feb 21 21:04:21 2002 --- src/gui_amiga.c Thu May 2 21:56:12 2002 *************** *** 943,948 **** --- 943,952 ---- #define RGB(a, b, c) ((a && 0xff) * 0x10000 + (b * 0xff) * 0x100 + (c & 0xff)) + /* + * Get color handle for color "name". + * Return INVALCOLOR when not possible. + */ guicolor_T gui_mch_get_color(char_u *name) { *************** *** 991,997 **** {NULL, NULL}, }; ! guicolor_T color = (guicolor_T)-1; int i; --- 995,1001 ---- {NULL, NULL}, }; ! guicolor_T color = INVALCOLOR; int i; *************** *** 1001,1013 **** color = table[i].color; } ! if (color == -1) { char *looky = NULL; color = strtol((char*)name, &looky, 10); if (*looky != NUL) ! color = -1; } return color; --- 1005,1017 ---- color = table[i].color; } ! if (color == INVALCOLOR) { char *looky = NULL; color = strtol((char*)name, &looky, 10); if (*looky != NUL) ! color = INVALCOLOR; } return color; *** ../vim61.048/src/gui_athena.c Thu Mar 21 22:36:36 2002 --- src/gui_athena.c Thu May 2 21:44:14 2002 *************** *** 218,224 **** XtNinsertPosition, athena_calculate_ins_pos, NULL); gui_athena_menu_colors(menuBar); ! if (gui.menu_fg_pixel != -1) XtVaSetValues(menuBar, XtNborderColor, gui.menu_fg_pixel, NULL); #endif --- 218,224 ---- XtNinsertPosition, athena_calculate_ins_pos, NULL); gui_athena_menu_colors(menuBar); ! if (gui.menu_fg_pixel != INVALCOLOR) XtVaSetValues(menuBar, XtNborderColor, gui.menu_fg_pixel, NULL); #endif *************** *** 1284,1290 **** { if (menuBar == (Widget)0) return; ! if (gui.menu_fg_pixel != -1) XtVaSetValues(menuBar, XtNborderColor, gui.menu_fg_pixel, NULL); gui_athena_menu_colors(menuBar); #ifdef FEAT_TOOLBAR --- 1284,1290 ---- { if (menuBar == (Widget)0) return; ! if (gui.menu_fg_pixel != INVALCOLOR) XtVaSetValues(menuBar, XtNborderColor, gui.menu_fg_pixel, NULL); gui_athena_menu_colors(menuBar); #ifdef FEAT_TOOLBAR *************** *** 2118,2126 **** gui_athena_menu_colors(id) Widget id; { ! if (gui.menu_bg_pixel != -1) XtVaSetValues(id, XtNbackground, gui.menu_bg_pixel, NULL); ! if (gui.menu_fg_pixel != -1) XtVaSetValues(id, XtNforeground, gui.menu_fg_pixel, NULL); } #endif --- 2118,2126 ---- gui_athena_menu_colors(id) Widget id; { ! if (gui.menu_bg_pixel != INVALCOLOR) XtVaSetValues(id, XtNbackground, gui.menu_bg_pixel, NULL); ! if (gui.menu_fg_pixel != INVALCOLOR) XtVaSetValues(id, XtNforeground, gui.menu_fg_pixel, NULL); } #endif *************** *** 2132,2139 **** gui_athena_scroll_colors(id) Widget id; { ! if (gui.scroll_bg_pixel != -1) XtVaSetValues(id, XtNbackground, gui.scroll_bg_pixel, NULL); ! if (gui.scroll_fg_pixel != -1) XtVaSetValues(id, XtNforeground, gui.scroll_fg_pixel, NULL); } --- 2132,2139 ---- gui_athena_scroll_colors(id) Widget id; { ! if (gui.scroll_bg_pixel != INVALCOLOR) XtVaSetValues(id, XtNbackground, gui.scroll_bg_pixel, NULL); ! if (gui.scroll_fg_pixel != INVALCOLOR) XtVaSetValues(id, XtNforeground, gui.scroll_fg_pixel, NULL); } *** ../vim61.048/src/gui_beos.cc Sun Feb 17 17:16:41 2002 --- src/gui_beos.cc Thu May 2 22:02:37 2002 *************** *** 2465,2471 **** * This function has been lifted from gui_w32.c and extended a bit. * * Return the Pixel value (color) for the given color name. ! * Return -1 for error. */ guicolor_T gui_mch_get_color( --- 2465,2471 ---- * This function has been lifted from gui_w32.c and extended a bit. * * Return the Pixel value (color) for the given color name. ! * Return INVALCOLOR for error. */ guicolor_T gui_mch_get_color( *************** *** 2530,2536 **** g = hex_digit(name[3]) * 16 + hex_digit(name[4]); b = hex_digit(name[5]) * 16 + hex_digit(name[6]); if (r < 0 || g < 0 || b < 0) ! return (guicolor_T)-1; return RGB(r, g, b); } else --- 2530,2536 ---- g = hex_digit(name[3]) * 16 + hex_digit(name[4]); b = hex_digit(name[5]) * 16 + hex_digit(name[6]); if (r < 0 || g < 0 || b < 0) ! return INVALCOLOR; return RGB(r, g, b); } else *************** *** 2552,2563 **** fname = expand_env_save((char_u *)"$VIM/rgb.txt"); if (fname == NULL) ! return (guicolor_T)-1; fd = fopen((char *)fname, "rt"); vim_free(fname); if (fd == NULL) ! return (guicolor_T)-1; while (!feof(fd)) { --- 2552,2563 ---- fname = expand_env_save((char_u *)"$VIM/rgb.txt"); if (fname == NULL) ! return INVALCOLOR; fd = fopen((char *)fname, "rt"); vim_free(fname); if (fd == NULL) ! return INVALCOLOR; while (!feof(fd)) { *************** *** 2606,2612 **** fclose(fd); } ! return (guicolor_T)-1; } /* --- 2606,2612 ---- fclose(fd); } ! return INVALCOLOR; } /* *** ../vim61.048/src/gui_gtk_x11.c Fri May 3 22:02:55 2002 --- src/gui_gtk_x11.c Fri May 3 20:43:39 2002 *************** *** 2830,2836 **** * Return the Pixel value (color) for the given color name. This routine was * pretty much taken from example code in the Silicon Graphics OSF/Motif * Programmer's Guide. ! * Return -1 for error. */ guicolor_T gui_mch_get_color(char_u * name) --- 2830,2836 ---- * Return the Pixel value (color) for the given color name. This routine was * pretty much taken from example code in the Silicon Graphics OSF/Motif * Programmer's Guide. ! * Return INVALCOLOR for error. */ guicolor_T gui_mch_get_color(char_u * name) *************** *** 2852,2858 **** }; if (!gui.in_use) /* can't do this when GUI not running */ ! return (guicolor_T)(-1); while (name != NULL) { --- 2852,2858 ---- }; if (!gui.in_use) /* can't do this when GUI not running */ ! return INVALCOLOR; while (name != NULL) { *************** *** 2913,2919 **** } } ! return (guicolor_T)(-1); } /* --- 2913,2919 ---- } } ! return INVALCOLOR; } /* *** ../vim61.048/src/gui_mac.c Thu Mar 21 20:39:48 2002 --- src/gui_mac.c Thu May 2 21:58:41 2002 *************** *** 3046,3051 **** --- 3046,3052 ---- * Return the Pixel value (color) for the given color name. This routine was * pretty much taken from example code in the Silicon Graphics OSF/Motif * Programmer's Guide. + * Return INVALCOLOR when failed. */ guicolor_T gui_mch_get_color(name) *************** *** 3111,3117 **** g = hex_digit(name[3]) * 16 + hex_digit(name[4]); b = hex_digit(name[5]) * 16 + hex_digit(name[6]); if (r < 0 || g < 0 || b < 0) ! return (guicolor_T) -1; return RGB(r, g, b); } else --- 3112,3118 ---- g = hex_digit(name[3]) * 16 + hex_digit(name[4]); b = hex_digit(name[5]) * 16 + hex_digit(name[6]); if (r < 0 || g < 0 || b < 0) ! return INVALCOLOR; return RGB(r, g, b); } else *************** *** 3143,3154 **** fname = expand_env_save((char_u *)"$VIMRUNTIME/rgb.txt"); #endif if (fname == NULL) ! return (guicolor_T)-1; fd = fopen((char *)fname, "rt"); vim_free(fname); if (fd == NULL) ! return (guicolor_T)-1; while (!feof(fd)) { --- 3144,3155 ---- fname = expand_env_save((char_u *)"$VIMRUNTIME/rgb.txt"); #endif if (fname == NULL) ! return INVALCOLOR; fd = fopen((char *)fname, "rt"); vim_free(fname); if (fd == NULL) ! return INVALCOLOR; while (!feof(fd)) { *************** *** 3179,3185 **** fclose(fd); } ! return -1; } /* --- 3180,3186 ---- fclose(fd); } ! return INVALCOLOR; } /* *** ../vim61.048/src/gui_motif.c Wed May 1 21:20:47 2002 --- src/gui_motif.c Thu May 2 21:48:29 2002 *************** *** 547,557 **** if (mouse_model_popup()) # endif { ! if (gui.menu_bg_pixel != -1) { XtSetArg(arg[0], XmNbackground, gui.menu_bg_pixel); n++; } ! if (gui.menu_fg_pixel != -1) { XtSetArg(arg[1], XmNforeground, gui.menu_fg_pixel); n++; } --- 547,557 ---- if (mouse_model_popup()) # endif { ! if (gui.menu_bg_pixel != INVALCOLOR) { XtSetArg(arg[0], XmNbackground, gui.menu_bg_pixel); n++; } ! if (gui.menu_fg_pixel != INVALCOLOR) { XtSetArg(arg[1], XmNforeground, gui.menu_fg_pixel); n++; } *************** *** 1445,1451 **** { if (sb->id != (Widget)0) { ! if (gui.scroll_bg_pixel != (guicolor_T)-1) { #if (XmVersion>=1002) XmChangeColor(sb->id, gui.scroll_bg_pixel); --- 1445,1451 ---- { if (sb->id != (Widget)0) { ! if (gui.scroll_bg_pixel != INVALCOLOR) { #if (XmVersion>=1002) XmChangeColor(sb->id, gui.scroll_bg_pixel); *************** *** 1456,1462 **** #endif } ! if (gui.scroll_fg_pixel != (guicolor_T)-1) XtVaSetValues(sb->id, XmNforeground, gui.scroll_fg_pixel, #if (XmVersion<1002) --- 1456,1462 ---- #endif } ! if (gui.scroll_fg_pixel != INVALCOLOR) XtVaSetValues(sb->id, XmNforeground, gui.scroll_fg_pixel, #if (XmVersion<1002) *************** *** 1620,1626 **** set_predefined_label(dialog_wgt, "Selection", _("Selection")); gui_motif_menu_colors(dialog_wgt); ! if (gui.scroll_bg_pixel != -1) XtVaSetValues(dialog_wgt, XmNtroughColor, gui.scroll_bg_pixel, NULL); XtAddCallback(dialog_wgt, XmNokCallback, DialogAcceptCB, (XtPointer)0); --- 1620,1626 ---- set_predefined_label(dialog_wgt, "Selection", _("Selection")); gui_motif_menu_colors(dialog_wgt); ! if (gui.scroll_bg_pixel != INVALCOLOR) XtVaSetValues(dialog_wgt, XmNtroughColor, gui.scroll_bg_pixel, NULL); XtAddCallback(dialog_wgt, XmNokCallback, DialogAcceptCB, (XtPointer)0); *************** *** 2490,2502 **** gui_motif_menu_colors(id) Widget id; { ! if (gui.menu_bg_pixel != (guicolor_T)-1) #if (XmVersion >= 1002) XmChangeColor(id, gui.menu_bg_pixel); #else XtVaSetValues(id, XmNbackground, gui.menu_bg_pixel, NULL); #endif ! if (gui.menu_fg_pixel != (guicolor_T)-1) XtVaSetValues(id, XmNforeground, gui.menu_fg_pixel, NULL); } --- 2490,2502 ---- gui_motif_menu_colors(id) Widget id; { ! if (gui.menu_bg_pixel != INVALCOLOR) #if (XmVersion >= 1002) XmChangeColor(id, gui.menu_bg_pixel); #else XtVaSetValues(id, XmNbackground, gui.menu_bg_pixel, NULL); #endif ! if (gui.menu_fg_pixel != INVALCOLOR) XtVaSetValues(id, XmNforeground, gui.menu_fg_pixel, NULL); } *************** *** 2507,2519 **** gui_motif_scroll_colors(id) Widget id; { ! if (gui.scroll_bg_pixel != (guicolor_T)-1) #if (XmVersion >= 1002) XmChangeColor(id, gui.scroll_bg_pixel); #else XtVaSetValues(id, XmNbackground, gui.scroll_bg_pixel, NULL); #endif ! if (gui.scroll_fg_pixel != (guicolor_T)-1) XtVaSetValues(id, XmNforeground, gui.scroll_fg_pixel, NULL); } --- 2507,2519 ---- gui_motif_scroll_colors(id) Widget id; { ! if (gui.scroll_bg_pixel != INVALCOLOR) #if (XmVersion >= 1002) XmChangeColor(id, gui.scroll_bg_pixel); #else XtVaSetValues(id, XmNbackground, gui.scroll_bg_pixel, NULL); #endif ! if (gui.scroll_fg_pixel != INVALCOLOR) XtVaSetValues(id, XmNforeground, gui.scroll_fg_pixel, NULL); } *** ../vim61.048/src/gui_photon.c Sun Feb 24 19:35:58 2002 --- src/gui_photon.c Thu May 2 21:59:59 2002 *************** *** 1992,1997 **** --- 1992,1998 ---- * every port does basically the same thing. * * This is the gui_w32.c version (i think..) + * Return INVALCOLOR when failed. */ guicolor_T *************** *** 2049,2055 **** g = hex_digit( name[3] ) * 16 + hex_digit( name[4] ); b = hex_digit( name[5] ) * 16 + hex_digit( name[6] ); if( r < 0 || g < 0 || b < 0 ) ! return( (guicolor_T) -1 ); return( RGB( r, g, b ) ); } --- 2050,2056 ---- g = hex_digit( name[3] ) * 16 + hex_digit( name[4] ); b = hex_digit( name[5] ) * 16 + hex_digit( name[6] ); if( r < 0 || g < 0 || b < 0 ) ! return INVALCOLOR; return( RGB( r, g, b ) ); } *************** *** 2070,2081 **** fname = expand_env_save((char_u *)"$VIMRUNTIME/rgb.txt"); if (fname == NULL) ! return( (guicolor_T) -1 ); fd = fopen((char *)fname, "rt"); vim_free(fname); if (fd == NULL) ! return( (guicolor_T) -1 ); while (!feof(fd)) { --- 2071,2082 ---- fname = expand_env_save((char_u *)"$VIMRUNTIME/rgb.txt"); if (fname == NULL) ! return INVALCOLOR; fd = fopen((char *)fname, "rt"); vim_free(fname); if (fd == NULL) ! return INVALCOLOR; while (!feof(fd)) { *************** *** 2108,2114 **** } ! return( (guicolor_T) -1 ); } void --- 2109,2115 ---- } ! return INVALCOLOR; } void *** ../vim61.048/src/gui_riscos.c Mon Mar 11 22:10:01 2002 --- src/gui_riscos.c Thu May 2 22:00:38 2002 *************** *** 1090,1096 **** /* * Return the Pixel value (colour) for the given colour name. ! * Return -1 for error. * NB: I've changed Green for now, since it looked really sick */ guicolor_T --- 1090,1096 ---- /* * Return the Pixel value (colour) for the given colour name. ! * Return INVALCOLOR for error. * NB: I've changed Green for now, since it looked really sick */ guicolor_T *************** *** 1165,1171 **** int level = (255 * atoi(name + 4)) / 100; return (guicolor_T) grgb(level, level, level); } ! return (guicolor_T) -1; } /* --- 1165,1171 ---- int level = (255 * atoi(name + 4)) / 100; return (guicolor_T) grgb(level, level, level); } ! return INVALCOLOR; } /* *** ../vim61.048/src/gui_w16.c Wed Jan 9 16:17:08 2002 --- src/gui_w16.c Thu May 2 22:23:59 2002 *************** *** 460,466 **** #endif gui.border_width = 0; ! gui.currBgColor = (long) -1; s_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); --- 460,466 ---- #endif gui.border_width = 0; ! gui.currBgColor = INVALCOLOR; s_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); *** ../vim61.048/src/gui_w32.c Sun Apr 28 22:08:02 2002 --- src/gui_w32.c Sat May 4 22:20:06 2002 *************** *** 1698,1704 **** * becomes a problem. - webb. */ static HBRUSH hbr_cache[2] = {NULL, NULL}; ! static guicolor_T brush_color[2] = {-1, -1}; static int brush_lru = 0; HBRUSH hbr; RECT rc; --- 1698,1704 ---- * becomes a problem. - webb. */ static HBRUSH hbr_cache[2] = {NULL, NULL}; ! static guicolor_T brush_color[2] = {INVALCOLOR, INVALCOLOR}; static int brush_lru = 0; HBRUSH hbr; RECT rc; *** ../vim61.048/src/gui_w48.c Wed May 1 21:20:47 2002 --- src/gui_w48.c Thu May 2 22:01:23 2002 *************** *** 1124,1130 **** } /* * Return the Pixel value (color) for the given color name. ! * Return -1 for error. */ guicolor_T gui_mch_get_color(char_u *name) --- 1124,1130 ---- } /* * Return the Pixel value (color) for the given color name. ! * Return INVALCOLOR for error. */ guicolor_T gui_mch_get_color(char_u *name) *************** *** 1226,1232 **** g = hex_digit(name[3]) * 16 + hex_digit(name[4]); b = hex_digit(name[5]) * 16 + hex_digit(name[6]); if (r < 0 || g < 0 || b < 0) ! return (guicolor_T)-1; return RGB(r, g, b); } else --- 1226,1232 ---- g = hex_digit(name[3]) * 16 + hex_digit(name[4]); b = hex_digit(name[5]) * 16 + hex_digit(name[6]); if (r < 0 || g < 0 || b < 0) ! return INVALCOLOR; return RGB(r, g, b); } else *************** *** 1255,1266 **** fname = expand_env_save((char_u *)"$VIMRUNTIME/rgb.txt"); if (fname == NULL) ! return (guicolor_T)-1; fd = fopen((char *)fname, "rt"); vim_free(fname); if (fd == NULL) ! return (guicolor_T)-1; while (!feof(fd)) { --- 1255,1266 ---- fname = expand_env_save((char_u *)"$VIMRUNTIME/rgb.txt"); if (fname == NULL) ! return INVALCOLOR; fd = fopen((char *)fname, "rt"); vim_free(fname); if (fd == NULL) ! return INVALCOLOR; while (!feof(fd)) { *************** *** 1292,1298 **** fclose(fd); } ! return (guicolor_T)-1; } /* * Return OK if the key with the termcap name "name" is supported. --- 1292,1298 ---- fclose(fd); } ! return INVALCOLOR; } /* * Return OK if the key with the termcap name "name" is supported. *** ../vim61.048/src/gui_x11.c Fri May 3 22:02:55 2002 --- src/gui_x11.c Fri May 3 20:45:52 2002 *************** *** 115,122 **** static int fontset_ascent __ARGS((XFontSet fs)); #endif ! static guicolor_T prev_fg_color = (guicolor_T)-1; ! static guicolor_T prev_bg_color = (guicolor_T)-1; #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) static XButtonPressedEvent last_mouse_event; --- 115,122 ---- static int fontset_ascent __ARGS((XFontSet fs)); #endif ! static guicolor_T prev_fg_color = INVALCOLOR; ! static guicolor_T prev_bg_color = INVALCOLOR; #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) static XButtonPressedEvent last_mouse_event; *************** *** 2122,2128 **** /* * Return the Pixel value (color) for the given color name. ! * Return -1 for error. */ guicolor_T gui_mch_get_color(reqname) --- 2122,2128 ---- /* * Return the Pixel value (color) for the given color name. ! * Return INVALCOLOR for error. */ guicolor_T gui_mch_get_color(reqname) *************** *** 2149,2155 **** /* can't do this when GUI not running */ if (!gui.in_use || *reqname == NUL) ! return (guicolor_T)-1; colormap = DefaultColormap(gui.dpy, XDefaultScreen(gui.dpy)); --- 2149,2155 ---- /* can't do this when GUI not running */ if (!gui.in_use || *reqname == NUL) ! return INVALCOLOR; colormap = DefaultColormap(gui.dpy, XDefaultScreen(gui.dpy)); *************** *** 2201,2207 **** } } ! return (guicolor_T)-1; } /* --- 2201,2207 ---- } } ! return INVALCOLOR; } /* *************** *** 2397,2403 **** XDrawString(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col), TEXT_Y(row), (char *)s, len); } ! else if (p_linespace #ifdef FEAT_XFONTSET || current_fontset != NULL #endif --- 2397,2403 ---- XDrawString(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col), TEXT_Y(row), (char *)s, len); } ! else if (p_linespace != 0 #ifdef FEAT_XFONTSET || current_fontset != NULL #endif *** ../vim61.048/src/mbyte.c Sat May 4 12:20:40 2002 --- src/mbyte.c Fri May 3 22:17:57 2002 *************** *** 3043,3049 **** } # endif /* FEAT_XFONTSET */ ! if (xim_fg_color < 0) { xim_fg_color = gui.def_norm_pixel; xim_bg_color = gui.def_back_pixel; --- 3043,3049 ---- } # endif /* FEAT_XFONTSET */ ! if (xim_fg_color == INVALCOLOR) { xim_fg_color = gui.def_norm_pixel; xim_bg_color = gui.def_back_pixel; *************** *** 3085,3091 **** if (input_style & XIMPreeditPosition) { ! if (xim_fg_color < 0) { xim_fg_color = gui.def_norm_pixel; xim_bg_color = gui.def_back_pixel; --- 3085,3091 ---- if (input_style & XIMPreeditPosition) { ! if (xim_fg_color == INVALCOLOR) { xim_fg_color = gui.def_norm_pixel; xim_bg_color = gui.def_back_pixel; *** ../vim61.048/src/syntax.c Mon Apr 8 22:11:31 2002 --- src/syntax.c Thu May 2 21:30:27 2002 *************** *** 36,44 **** #ifdef FEAT_GUI /* for when using the GUI */ int sg_gui; /* "gui=" highlighting attributes */ ! guicolor_T sg_gui_fg; /* GUI foreground color handle + 1 */ char_u *sg_gui_fg_name;/* GUI foreground color name */ ! guicolor_T sg_gui_bg; /* GUI background color handle + 1 */ char_u *sg_gui_bg_name;/* GUI background color name */ GuiFont sg_font; /* GUI font handle */ #ifdef FEAT_XFONTSET --- 36,44 ---- #ifdef FEAT_GUI /* for when using the GUI */ int sg_gui; /* "gui=" highlighting attributes */ ! guicolor_T sg_gui_fg; /* GUI foreground color handle */ char_u *sg_gui_fg_name;/* GUI foreground color name */ ! guicolor_T sg_gui_bg; /* GUI background color handle */ char_u *sg_gui_bg_name;/* GUI background color name */ GuiFont sg_font; /* GUI font handle */ #ifdef FEAT_XFONTSET *************** *** 6647,6655 **** if (!init) HL_TABLE()[idx].sg_set |= SG_GUI; ! /* Add one to the argument, to avoid zero */ ! i = color_name2handle(arg) + 1; ! if (i > 0 || STRCMP(arg, "NONE") == 0 || !gui.in_use) { HL_TABLE()[idx].sg_gui_fg = i; vim_free(HL_TABLE()[idx].sg_gui_fg_name); --- 6647,6654 ---- if (!init) HL_TABLE()[idx].sg_set |= SG_GUI; ! i = color_name2handle(arg); ! if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !gui.in_use) { HL_TABLE()[idx].sg_gui_fg = i; vim_free(HL_TABLE()[idx].sg_gui_fg_name); *************** *** 6659,6670 **** HL_TABLE()[idx].sg_gui_fg_name = NULL; # ifdef FEAT_GUI_X11 if (is_menu_group) ! gui.menu_fg_pixel = i - 1; if (is_scrollbar_group) ! gui.scroll_fg_pixel = i - 1; # ifdef FEAT_BEVAL if (is_tooltip_group) ! gui.tooltip_fg_pixel = i - 1; # endif do_colors = TRUE; # endif --- 6658,6669 ---- HL_TABLE()[idx].sg_gui_fg_name = NULL; # ifdef FEAT_GUI_X11 if (is_menu_group) ! gui.menu_fg_pixel = i; if (is_scrollbar_group) ! gui.scroll_fg_pixel = i; # ifdef FEAT_BEVAL if (is_tooltip_group) ! gui.tooltip_fg_pixel = i; # endif do_colors = TRUE; # endif *************** *** 6680,6688 **** if (!init) HL_TABLE()[idx].sg_set |= SG_GUI; ! /* Add one to the argument, to avoid zero */ ! i = color_name2handle(arg) + 1; ! if (i > 0 || STRCMP(arg, "NONE") == 0 || !gui.in_use) { HL_TABLE()[idx].sg_gui_bg = i; vim_free(HL_TABLE()[idx].sg_gui_bg_name); --- 6679,6686 ---- if (!init) HL_TABLE()[idx].sg_set |= SG_GUI; ! i = color_name2handle(arg); ! if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !gui.in_use) { HL_TABLE()[idx].sg_gui_bg = i; vim_free(HL_TABLE()[idx].sg_gui_bg_name); *************** *** 6692,6703 **** HL_TABLE()[idx].sg_gui_bg_name = NULL; # ifdef FEAT_GUI_X11 if (is_menu_group) ! gui.menu_bg_pixel = i - 1; if (is_scrollbar_group) ! gui.scroll_bg_pixel = i - 1; # ifdef FEAT_BEVAL if (is_tooltip_group) ! gui.tooltip_bg_pixel = i - 1; # endif do_colors = TRUE; # endif --- 6690,6701 ---- HL_TABLE()[idx].sg_gui_bg_name = NULL; # ifdef FEAT_GUI_X11 if (is_menu_group) ! gui.menu_bg_pixel = i; if (is_scrollbar_group) ! gui.scroll_bg_pixel = i; # ifdef FEAT_BEVAL if (is_tooltip_group) ! gui.tooltip_bg_pixel = i; # endif do_colors = TRUE; # endif *************** *** 6915,6924 **** HL_TABLE()[idx].sg_cterm_attr = 0; #ifdef FEAT_GUI /* in non-GUI fonts are simply ignored */ HL_TABLE()[idx].sg_gui = 0; ! HL_TABLE()[idx].sg_gui_fg = 0; vim_free(HL_TABLE()[idx].sg_gui_fg_name); HL_TABLE()[idx].sg_gui_fg_name = NULL; ! HL_TABLE()[idx].sg_gui_bg = 0; vim_free(HL_TABLE()[idx].sg_gui_bg_name); HL_TABLE()[idx].sg_gui_bg_name = NULL; gui_mch_free_font(HL_TABLE()[idx].sg_font); --- 6913,6922 ---- HL_TABLE()[idx].sg_cterm_attr = 0; #ifdef FEAT_GUI /* in non-GUI fonts are simply ignored */ HL_TABLE()[idx].sg_gui = 0; ! HL_TABLE()[idx].sg_gui_fg = INVALCOLOR; vim_free(HL_TABLE()[idx].sg_gui_fg_name); HL_TABLE()[idx].sg_gui_fg_name = NULL; ! HL_TABLE()[idx].sg_gui_bg = INVALCOLOR; vim_free(HL_TABLE()[idx].sg_gui_bg_name); HL_TABLE()[idx].sg_gui_bg_name = NULL; gui_mch_free_font(HL_TABLE()[idx].sg_font); *************** *** 6999,7010 **** { gui_do_one_color(idx, do_menu, do_tooltip); ! if (HL_TABLE()[idx].sg_gui_fg > 0) ! *fgp = HL_TABLE()[idx].sg_gui_fg - 1; else if (use_norm) *fgp = gui.def_norm_pixel; ! if (HL_TABLE()[idx].sg_gui_bg > 0) ! *bgp = HL_TABLE()[idx].sg_gui_bg - 1; else if (use_norm) *bgp = gui.def_back_pixel; return TRUE; --- 6997,7008 ---- { gui_do_one_color(idx, do_menu, do_tooltip); ! if (HL_TABLE()[idx].sg_gui_fg != INVALCOLOR) ! *fgp = HL_TABLE()[idx].sg_gui_fg; else if (use_norm) *fgp = gui.def_norm_pixel; ! if (HL_TABLE()[idx].sg_gui_bg != INVALCOLOR) ! *bgp = HL_TABLE()[idx].sg_gui_bg; else if (use_norm) *bgp = gui.def_back_pixel; return TRUE; *************** *** 7094,7107 **** /* * Return the handle for a color name. ! * Returns -1 when failed. */ static guicolor_T color_name2handle(name) char_u *name; { if (STRCMP(name, "NONE") == 0) ! return (guicolor_T)-1; if (STRICMP(name, "fg") == 0 || STRICMP(name, "foreground") == 0) return gui.norm_pixel; --- 7092,7105 ---- /* * Return the handle for a color name. ! * Returns INVALCOLOR when failed. */ static guicolor_T color_name2handle(name) char_u *name; { if (STRCMP(name, "NONE") == 0) ! return INVALCOLOR; if (STRICMP(name, "fg") == 0 || STRICMP(name, "foreground") == 0) return gui.norm_pixel; *************** *** 7571,7579 **** color = HL_TABLE()[id - 1].sg_gui_fg; else color = HL_TABLE()[id - 1].sg_gui_bg; ! if (color == 0) return NULL; ! rgb = gui_mch_get_rgb(color - 1); sprintf((char *)buf, "#%02x%02x%02x", (unsigned)(rgb >> 16), (unsigned)(rgb >> 8) & 255, --- 7569,7577 ---- color = HL_TABLE()[id - 1].sg_gui_fg; else color = HL_TABLE()[id - 1].sg_gui_bg; ! if (color == INVALCOLOR) return NULL; ! rgb = gui_mch_get_rgb(color); sprintf((char *)buf, "#%02x%02x%02x", (unsigned)(rgb >> 16), (unsigned)(rgb >> 8) & 255, *************** *** 7619,7628 **** else color = HL_TABLE()[id - 1].sg_gui_bg; ! if (color == 0) return 0L; ! return gui_mch_get_rgb(color - 1); } #endif --- 7617,7626 ---- else color = HL_TABLE()[id - 1].sg_gui_bg; ! if (color == INVALCOLOR) return 0L; ! return gui_mch_get_rgb(color); } #endif *************** *** 7689,7696 **** * For the GUI mode: If there are other than "normal" highlighting * attributes, need to allocate an attr number. */ ! if (HL_TABLE()[idx].sg_gui_fg == 0 ! && HL_TABLE()[idx].sg_gui_bg == 0 && HL_TABLE()[idx].sg_font == NOFONT # ifdef FEAT_XFONTSET && HL_TABLE()[idx].sg_fontset == NOFONTSET --- 7687,7694 ---- * For the GUI mode: If there are other than "normal" highlighting * attributes, need to allocate an attr number. */ ! if (HL_TABLE()[idx].sg_gui_fg == INVALCOLOR ! && HL_TABLE()[idx].sg_gui_bg == INVALCOLOR && HL_TABLE()[idx].sg_font == NOFONT # ifdef FEAT_XFONTSET && HL_TABLE()[idx].sg_fontset == NOFONTSET *************** *** 7853,7858 **** --- 7851,7858 ---- vim_memset(&(HL_TABLE()[highlight_ga.ga_len]), 0, sizeof(struct hl_group)); HL_TABLE()[highlight_ga.ga_len].sg_name = name; HL_TABLE()[highlight_ga.ga_len].sg_name_u = vim_strsave_up(name); + HL_TABLE()[highlight_ga.ga_len].sg_gui_bg = INVALCOLOR; + HL_TABLE()[highlight_ga.ga_len].sg_gui_fg = INVALCOLOR; ++highlight_ga.ga_len; --highlight_ga.ga_room; *************** *** 7904,7910 **** #ifdef FEAT_GUI /* * Get the GUI colors and attributes for a group ID. ! * NOTE: the colors will be 0 when not set, the color plus one otherwise. */ int syn_id2colors(hl_id, fgp, bgp) --- 7904,7910 ---- #ifdef FEAT_GUI /* * Get the GUI colors and attributes for a group ID. ! * NOTE: the colors will be INVALCOLOR when not set, the color otherwise. */ int syn_id2colors(hl_id, fgp, bgp) *************** *** 7987,7999 **** if (HL_TABLE()[idx].sg_gui_fg_name != NULL) { HL_TABLE()[idx].sg_gui_fg = ! color_name2handle(HL_TABLE()[idx].sg_gui_fg_name) + 1; didit = TRUE; } if (HL_TABLE()[idx].sg_gui_bg_name != NULL) { HL_TABLE()[idx].sg_gui_bg = ! color_name2handle(HL_TABLE()[idx].sg_gui_bg_name) + 1; didit = TRUE; } if (didit) /* need to get a new attr number */ --- 7987,7999 ---- if (HL_TABLE()[idx].sg_gui_fg_name != NULL) { HL_TABLE()[idx].sg_gui_fg = ! color_name2handle(HL_TABLE()[idx].sg_gui_fg_name); didit = TRUE; } if (HL_TABLE()[idx].sg_gui_bg_name != NULL) { HL_TABLE()[idx].sg_gui_bg = ! color_name2handle(HL_TABLE()[idx].sg_gui_bg_name); didit = TRUE; } if (didit) /* need to get a new attr number */ *** ../vim61.048/src/version.c Sat May 4 12:20:40 2002 --- src/version.c Sat May 4 12:25:23 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 49, /**/ -- Females are strictly forbidden to appear unshaven in public. [real standing law in New Mexico, United States of America] /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///