To: vim-dev@vim.org Subject: Patch 6.0.256 (extra) Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.256 (extra) Problem: Win32: ":highlight Comment guifg=asdf" does not give an error message. (Randall W. Morris) Also for other systems. Solution: Add gui_get_color() to give one error message for all systems. Files: src/gui.c, src/gui_amiga.c, src/gui_athena.c, src/gui_motif.c, src/gui_riscos.c, src/gui_x11.c, src/gui_gtk_x11.c, src/proto/gui.pro, src/syntax.c *** ../vim60.255/src/gui.c Thu Feb 21 13:59:30 2002 --- src/gui.c Thu Feb 21 21:11:42 2002 *************** *** 3665,3671 **** gui_set_fg_color(name) char_u *name; { ! gui.norm_pixel = gui_mch_get_color(name); hl_set_fg_color_name(vim_strsave(name)); } --- 3665,3671 ---- gui_set_fg_color(name) char_u *name; { ! gui.norm_pixel = gui_get_color(name); hl_set_fg_color_name(vim_strsave(name)); } *************** *** 3673,3680 **** gui_set_bg_color(name) char_u *name; { ! gui.back_pixel = gui_mch_get_color(name); hl_set_bg_color_name(vim_strsave(name)); } /* --- 3673,3700 ---- gui_set_bg_color(name) char_u *name; { ! gui.back_pixel = gui_get_color(name); hl_set_bg_color_name(vim_strsave(name)); + } + + /* + * Allocate a color by name. + * Returns -1 and gives an error message when failed. + */ + guicolor_T + gui_get_color(name) + char_u *name; + { + guicolor_T t; + + t = gui_mch_get_color(name); + if (t < 0 + #if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) + && gui.in_use + #endif + ) + EMSG2(_("E254: Cannot allocate color %s"), name); + return t; } /* *** ../vim60.255/src/gui_amiga.c Fri Aug 24 10:32:32 2001 --- src/gui_amiga.c Thu Feb 21 21:04:21 2002 *************** *** 1003,1016 **** if (color == -1) { ! char **looky = NULL; ! color = strtol((char*)name, looky, 10); ! if (looky) ! { ! printf("invalid number \n"); ! color = 1; ! } } return color; --- 1003,1013 ---- if (color == -1) { ! char *looky = NULL; ! color = strtol((char*)name, &looky, 10); ! if (*looky != NUL) ! color = -1; } return color; *** ../vim60.255/src/gui_athena.c Sun Feb 3 15:27:26 2002 --- src/gui_athena.c Thu Feb 21 21:05:29 2002 *************** *** 1679,1691 **** * Get the colors ourselves. Using the automatic conversion doesn't * handle looking for approximate colors. */ ! gui.menu_fg_pixel = gui_mch_get_color((char_u *)gui.rsrc_menu_fg_name); ! gui.menu_bg_pixel = gui_mch_get_color((char_u *)gui.rsrc_menu_bg_name); ! gui.scroll_fg_pixel = gui_mch_get_color((char_u *)gui.rsrc_scroll_fg_name); ! gui.scroll_bg_pixel = gui_mch_get_color((char_u *)gui.rsrc_scroll_bg_name); #ifdef FEAT_BEVAL ! gui.tooltip_fg_pixel = gui_mch_get_color((char_u *)gui.rsrc_tooltip_fg_name); ! gui.tooltip_bg_pixel = gui_mch_get_color((char_u *)gui.rsrc_tooltip_bg_name); #endif } --- 1679,1691 ---- * Get the colors ourselves. Using the automatic conversion doesn't * handle looking for approximate colors. */ ! gui.menu_fg_pixel = gui_get_color((char_u *)gui.rsrc_menu_fg_name); ! gui.menu_bg_pixel = gui_get_color((char_u *)gui.rsrc_menu_bg_name); ! gui.scroll_fg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_fg_name); ! gui.scroll_bg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_bg_name); #ifdef FEAT_BEVAL ! gui.tooltip_fg_pixel = gui_get_color((char_u *)gui.rsrc_tooltip_fg_name); ! gui.tooltip_bg_pixel = gui_get_color((char_u *)gui.rsrc_tooltip_bg_name); #endif } *** ../vim60.255/src/gui_motif.c Sun Feb 3 15:27:26 2002 --- src/gui_motif.c Thu Feb 21 21:06:59 2002 *************** *** 1252,1260 **** gui.scroll_bg_pixel = gui.scroll_def_bg_pixel; #ifdef FEAT_BEVAL gui.tooltip_fg_pixel = ! gui_mch_get_color((char_u *)gui.rsrc_tooltip_fg_name); gui.tooltip_bg_pixel = ! gui_mch_get_color((char_u *)gui.rsrc_tooltip_bg_name); #endif } } --- 1252,1260 ---- gui.scroll_bg_pixel = gui.scroll_def_bg_pixel; #ifdef FEAT_BEVAL gui.tooltip_fg_pixel = ! gui_get_color((char_u *)gui.rsrc_tooltip_fg_name); gui.tooltip_bg_pixel = ! gui_get_color((char_u *)gui.rsrc_tooltip_bg_name); #endif } } *** ../vim60.255/src/gui_riscos.c Fri Aug 24 10:33:57 2001 --- src/gui_riscos.c Thu Feb 21 21:08:45 2002 *************** *** 1164,1170 **** int level = (255 * atoi(name + 4)) / 100; return (guicolor_T) grgb(level, level, level); } - EMSG2(_("E242: Missing color: %s"), name); return (guicolor_T) -1; } --- 1164,1169 ---- *** ../vim60.255/src/gui_x11.c Fri Feb 8 10:29:46 2002 --- src/gui_x11.c Thu Feb 21 21:09:18 2002 *************** *** 1237,1249 **** /* NOTE: These next few lines are an exact duplicate of gui_athena.c's * gui_mch_def_colors(). Why? */ ! gui.menu_fg_pixel = gui_mch_get_color((char_u *)gui.rsrc_menu_fg_name); ! gui.menu_bg_pixel = gui_mch_get_color((char_u *)gui.rsrc_menu_bg_name); ! gui.scroll_fg_pixel = gui_mch_get_color((char_u *)gui.rsrc_scroll_fg_name); ! gui.scroll_bg_pixel = gui_mch_get_color((char_u *)gui.rsrc_scroll_bg_name); #ifdef FEAT_BEVAL ! gui.tooltip_fg_pixel = gui_mch_get_color((char_u *)gui.rsrc_tooltip_fg_name); ! gui.tooltip_bg_pixel = gui_mch_get_color((char_u *)gui.rsrc_tooltip_bg_name); #endif #if defined(FEAT_MENU) && defined(FEAT_GUI_ATHENA) --- 1237,1249 ---- /* NOTE: These next few lines are an exact duplicate of gui_athena.c's * gui_mch_def_colors(). Why? */ ! gui.menu_fg_pixel = gui_get_color((char_u *)gui.rsrc_menu_fg_name); ! gui.menu_bg_pixel = gui_get_color((char_u *)gui.rsrc_menu_bg_name); ! gui.scroll_fg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_fg_name); ! gui.scroll_bg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_bg_name); #ifdef FEAT_BEVAL ! gui.tooltip_fg_pixel = gui_get_color((char_u *)gui.rsrc_tooltip_fg_name); ! gui.tooltip_bg_pixel = gui_get_color((char_u *)gui.rsrc_tooltip_bg_name); #endif #if defined(FEAT_MENU) && defined(FEAT_GUI_ATHENA) *************** *** 1416,1422 **** } if (gui.color_approx) ! EMSG(_("Vim: (ec1) Cannot allocate colormap entry, some colors may be incorrect")); #ifdef FEAT_SUN_WORKSHOP if (usingSunWorkShop) --- 1416,1422 ---- } if (gui.color_approx) ! EMSG(_("Vim E458: Cannot allocate colormap entry, some colors may be incorrect")); #ifdef FEAT_SUN_WORKSHOP if (usingSunWorkShop) *************** *** 2200,2206 **** } } } - EMSG2(_("E254: Cannot allocate color %s"), reqname); return (guicolor_T)-1; } --- 2200,2205 ---- *** ../vim60.255/src/gui_gtk_x11.c Thu Feb 21 17:14:51 2002 --- src/gui_gtk_x11.c Thu Feb 21 21:11:54 2002 *************** *** 2151,2163 **** if (found_reverse_arg) { ! gui.def_norm_pixel = gui_mch_get_color((char_u *)"White"); ! gui.def_back_pixel = gui_mch_get_color((char_u *)"Black"); } else { ! gui.def_norm_pixel = gui_mch_get_color((char_u *)"Black"); ! gui.def_back_pixel = gui_mch_get_color((char_u *)"White"); } /* Get the colors from the "Normal" and "Menu" group (set in syntax.c or --- 2151,2163 ---- if (found_reverse_arg) { ! gui.def_norm_pixel = gui_get_color((char_u *)"White"); ! gui.def_back_pixel = gui_get_color((char_u *)"Black"); } else { ! gui.def_norm_pixel = gui_get_color((char_u *)"Black"); ! gui.def_back_pixel = gui_get_color((char_u *)"White"); } /* Get the colors from the "Normal" and "Menu" group (set in syntax.c or *************** *** 2844,2850 **** { if (vimnames[i][0] == NULL) { - EMSG2(_("E242: Color name not recognized: %s"), name); name = NULL; break; } --- 2844,2849 ---- *** ../vim60.255/src/proto/gui.pro Mon Feb 11 12:01:33 2002 --- src/proto/gui.pro Thu Feb 21 21:11:29 2002 *************** *** 43,48 **** --- 43,49 ---- void gui_check_colors __ARGS((void)); void gui_set_fg_color __ARGS((char_u *name)); void gui_set_bg_color __ARGS((char_u *name)); + guicolor_T gui_get_color __ARGS((char_u *name)); int gui_get_lightness __ARGS((guicolor_T pixel)); void gui_new_scrollbar_colors __ARGS((void)); void gui_focus_change __ARGS((int in_focus)); *** ../vim60.255/src/syntax.c Thu Jan 17 16:30:27 2002 --- src/syntax.c Thu Feb 21 21:11:38 2002 *************** *** 5939,5945 **** * everything anyway. */ return; ! if (TO_LOWER(*p_bg) == 'l') pp = highlight_init_light; else pp = highlight_init_dark; --- 5939,5945 ---- * everything anyway. */ return; ! if (*p_bg == 'l') pp = highlight_init_light; else pp = highlight_init_dark; *************** *** 7108,7114 **** if (STRICMP(name, "bg") == 0 || STRICMP(name, "background") == 0) return gui.back_pixel; ! return gui_mch_get_color(name); } /* --- 7108,7114 ---- if (STRICMP(name, "bg") == 0 || STRICMP(name, "background") == 0) return gui.back_pixel; ! return gui_get_color(name); } /* *** ../vim60.255/src/version.c Thu Feb 21 20:34:10 2002 --- src/version.c Thu Feb 21 21:14:53 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 256, /**/ -- Every engineer dreams about saving the universe and having sex with aliens. This is much more glamorous than the real life of an engineer, which consists of hiding from the universe and having sex without the participation of other life forms. (Scott Adams - The Dilbert principle) /// 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 ///