@@ -3705,17 +3705,6 @@ gui_mch_free_font(GuiFont font)
37053705 */
37063706}
37073707
3708- static int
3709- hex_digit (int c )
3710- {
3711- if (isdigit (c ))
3712- return c - '0' ;
3713- c = TOLOWER_ASC (c );
3714- if (c >= 'a' && c <= 'f' )
3715- return c - 'a' + 10 ;
3716- return -1000 ;
3717- }
3718-
37193708/*
37203709 * Return the Pixel value (color) for the given color name. This routine was
37213710 * pretty much taken from example code in the Silicon Graphics OSF/Motif
@@ -3728,146 +3717,13 @@ gui_mch_get_color(char_u *name)
37283717 /* TODO: Add support for the new named color of MacOS 8
37293718 */
37303719 RGBColor MacColor ;
3731- // guicolor_T color = 0;
3732-
3733- typedef struct guicolor_tTable
3734- {
3735- char * name ;
3736- guicolor_T color ;
3737- } guicolor_tTable ;
3738-
3739- /*
3740- * The comment at the end of each line is the source
3741- * (Mac, Window, Unix) and the number is the unix rgb.txt value
3742- */
3743- static guicolor_tTable table [] =
3744- {
3745- {"Black" , RGB (0x00 , 0x00 , 0x00 )},
3746- {"darkgray" , RGB (0x80 , 0x80 , 0x80 )}, /*W*/
3747- {"darkgrey" , RGB (0x80 , 0x80 , 0x80 )}, /*W*/
3748- {"Gray" , RGB (0xC0 , 0xC0 , 0xC0 )}, /*W*/
3749- {"Grey" , RGB (0xC0 , 0xC0 , 0xC0 )}, /*W*/
3750- {"lightgray" , RGB (0xE0 , 0xE0 , 0xE0 )}, /*W*/
3751- {"lightgrey" , RGB (0xE0 , 0xE0 , 0xE0 )}, /*W*/
3752- {"gray10" , RGB (0x1A , 0x1A , 0x1A )}, /*W*/
3753- {"grey10" , RGB (0x1A , 0x1A , 0x1A )}, /*W*/
3754- {"gray20" , RGB (0x33 , 0x33 , 0x33 )}, /*W*/
3755- {"grey20" , RGB (0x33 , 0x33 , 0x33 )}, /*W*/
3756- {"gray30" , RGB (0x4D , 0x4D , 0x4D )}, /*W*/
3757- {"grey30" , RGB (0x4D , 0x4D , 0x4D )}, /*W*/
3758- {"gray40" , RGB (0x66 , 0x66 , 0x66 )}, /*W*/
3759- {"grey40" , RGB (0x66 , 0x66 , 0x66 )}, /*W*/
3760- {"gray50" , RGB (0x7F , 0x7F , 0x7F )}, /*W*/
3761- {"grey50" , RGB (0x7F , 0x7F , 0x7F )}, /*W*/
3762- {"gray60" , RGB (0x99 , 0x99 , 0x99 )}, /*W*/
3763- {"grey60" , RGB (0x99 , 0x99 , 0x99 )}, /*W*/
3764- {"gray70" , RGB (0xB3 , 0xB3 , 0xB3 )}, /*W*/
3765- {"grey70" , RGB (0xB3 , 0xB3 , 0xB3 )}, /*W*/
3766- {"gray80" , RGB (0xCC , 0xCC , 0xCC )}, /*W*/
3767- {"grey80" , RGB (0xCC , 0xCC , 0xCC )}, /*W*/
3768- {"gray90" , RGB (0xE5 , 0xE5 , 0xE5 )}, /*W*/
3769- {"grey90" , RGB (0xE5 , 0xE5 , 0xE5 )}, /*W*/
3770- {"white" , RGB (0xFF , 0xFF , 0xFF )},
3771- {"darkred" , RGB (0x80 , 0x00 , 0x00 )}, /*W*/
3772- {"red" , RGB (0xDD , 0x08 , 0x06 )}, /*M*/
3773- {"lightred" , RGB (0xFF , 0xA0 , 0xA0 )}, /*W*/
3774- {"DarkBlue" , RGB (0x00 , 0x00 , 0x80 )}, /*W*/
3775- {"Blue" , RGB (0x00 , 0x00 , 0xD4 )}, /*M*/
3776- {"lightblue" , RGB (0xA0 , 0xA0 , 0xFF )}, /*W*/
3777- {"DarkGreen" , RGB (0x00 , 0x80 , 0x00 )}, /*W*/
3778- {"Green" , RGB (0x00 , 0x64 , 0x11 )}, /*M*/
3779- {"lightgreen" , RGB (0xA0 , 0xFF , 0xA0 )}, /*W*/
3780- {"DarkCyan" , RGB (0x00 , 0x80 , 0x80 )}, /*W ?0x307D7E */
3781- {"cyan" , RGB (0x02 , 0xAB , 0xEA )}, /*M*/
3782- {"lightcyan" , RGB (0xA0 , 0xFF , 0xFF )}, /*W*/
3783- {"darkmagenta" , RGB (0x80 , 0x00 , 0x80 )}, /*W*/
3784- {"magenta" , RGB (0xF2 , 0x08 , 0x84 )}, /*M*/
3785- {"lightmagenta" ,RGB (0xF0 , 0xA0 , 0xF0 )}, /*W*/
3786- {"brown" , RGB (0x80 , 0x40 , 0x40 )}, /*W*/
3787- {"yellow" , RGB (0xFC , 0xF3 , 0x05 )}, /*M*/
3788- {"lightyellow" , RGB (0xFF , 0xFF , 0xA0 )}, /*M*/
3789- {"darkyellow" , RGB (0xBB , 0xBB , 0x00 )}, /*U*/
3790- {"SeaGreen" , RGB (0x2E , 0x8B , 0x57 )}, /*W 0x4E8975 */
3791- {"orange" , RGB (0xFC , 0x80 , 0x00 )}, /*W 0xF87A17 */
3792- {"Purple" , RGB (0xA0 , 0x20 , 0xF0 )}, /*W 0x8e35e5 */
3793- {"SlateBlue" , RGB (0x6A , 0x5A , 0xCD )}, /*W 0x737CA1 */
3794- {"Violet" , RGB (0x8D , 0x38 , 0xC9 )}, /*U*/
3795- };
3796-
3797- int r , g , b ;
3798- int i ;
3799-
3800- if (name [0 ] == '#' && strlen ((char * ) name ) == 7 )
3801- {
3802- /* Name is in "#rrggbb" format */
3803- r = hex_digit (name [1 ]) * 16 + hex_digit (name [2 ]);
3804- g = hex_digit (name [3 ]) * 16 + hex_digit (name [4 ]);
3805- b = hex_digit (name [5 ]) * 16 + hex_digit (name [6 ]);
3806- if (r < 0 || g < 0 || b < 0 )
3807- return INVALCOLOR ;
3808- return RGB (r , g , b );
3809- }
3810- else
3811- {
3812- if (STRICMP (name , "hilite" ) == 0 )
3813- {
3814- LMGetHiliteRGB (& MacColor );
3815- return (RGB (MacColor .red >> 8 , MacColor .green >> 8 , MacColor .blue >> 8 ));
3816- }
3817- /* Check if the name is one of the colors we know */
3818- for (i = 0 ; i < sizeof (table ) / sizeof (table [0 ]); i ++ )
3819- if (STRICMP (name , table [i ].name ) == 0 )
3820- return table [i ].color ;
3821- }
38223720
3823- /*
3824- * Last attempt. Look in the file "$VIM/rgb.txt".
3825- */
3721+ if (STRICMP (name , "hilite" ) == 0 )
38263722 {
3827- #define LINE_LEN 100
3828- FILE * fd ;
3829- char line [LINE_LEN ];
3830- char_u * fname ;
3831-
3832- fname = expand_env_save ((char_u * )"$VIMRUNTIME/rgb.txt" );
3833- if (fname == NULL )
3834- return INVALCOLOR ;
3835-
3836- fd = fopen ((char * )fname , "rt" );
3837- vim_free (fname );
3838- if (fd == NULL )
3839- return INVALCOLOR ;
3840-
3841- while (!feof (fd ))
3842- {
3843- int len ;
3844- int pos ;
3845- char * color ;
3846-
3847- fgets (line , LINE_LEN , fd );
3848- len = strlen (line );
3849-
3850- if (len <= 1 || line [len - 1 ] != '\n' )
3851- continue ;
3852-
3853- line [len - 1 ] = '\0' ;
3854-
3855- i = sscanf (line , "%d %d %d %n" , & r , & g , & b , & pos );
3856- if (i != 3 )
3857- continue ;
3858-
3859- color = line + pos ;
3860-
3861- if (STRICMP (color , name ) == 0 )
3862- {
3863- fclose (fd );
3864- return (guicolor_T ) RGB (r , g , b );
3865- }
3866- }
3867- fclose (fd );
3723+ LMGetHiliteRGB (& MacColor );
3724+ return (RGB (MacColor .red >> 8 , MacColor .green >> 8 , MacColor .blue >> 8 ));
38683725 }
3869-
3870- return INVALCOLOR ;
3726+ return gui_get_color_cmn (name );
38713727}
38723728
38733729/*
0 commit comments