patch 8.2.3562: cannot add color names

Problem:    Cannot add color names.
Solution:   Add the v:colornames dictionary. (Drew Vogel, closes #8761)
This commit is contained in:
Drew Vogel
2021-10-24 20:35:07 +01:00
committed by Bram Moolenaar
parent 3c5904d2a5
commit e30d10253f
26 changed files with 1364 additions and 398 deletions

View File

@ -798,6 +798,7 @@ RT_SCRIPTS = \
runtime/autoload/xml/*.vim \
runtime/colors/*.vim \
runtime/colors/README.txt \
runtime/colors/lists/*.vim \
runtime/colors/tools/*.vim \
runtime/compiler/*.vim \
runtime/compiler/README.txt \
@ -850,7 +851,6 @@ RT_AMI_DOS = \
# DOS runtime (also in the extra archive)
RT_DOS = \
README_dos.txt \
runtime/rgb.txt \
vimtutor.bat \
# DOS runtime without CR-LF translation (also in the extra archive)

View File

@ -26,7 +26,6 @@ src/os_win32.* Files for the Win32 port.
src/gui_w32.* Files for the Win32 GUI.
src/gui_w48.* Files for the Win32 and Win16 GUI.
src/Make_mvc.mak MS Visual C++ makefile for the Win32 GUI.
runtime/rgb.txt File with color definitions for the Win32 GUI.
src/if_ole.* OLE automation interface, for MS Windows 95 and NT.

View File

@ -357,7 +357,6 @@ Section "$(str_section_exe)" id_section_exe
File ..\README.txt
File ..\uninstall.txt
File ${VIMRT}\*.vim
File ${VIMRT}\rgb.txt
File ${VIMTOOLS}\diff.exe
File ${VIMTOOLS}\winpty${BIT}.dll
@ -367,6 +366,8 @@ Section "$(str_section_exe)" id_section_exe
File ${VIMRT}\colors\*.*
SetOutPath $0\colors\tools
File ${VIMRT}\colors\tools\*.*
SetOutPath $0\colors\lists
File ${VIMRT}\colors\lists\*.*
SetOutPath $0\compiler
File ${VIMRT}\compiler\*.*

View File

@ -87,4 +87,5 @@ please check the following items:
- In the GUI, is it easy to find the cursor, also in a file with lots of
syntax highlighting?
- Do not use hard coded escape sequences, these will not work in other
terminals. Always use color names or #RRGGBB for the GUI.
terminals. Always use color names or #RRGGBB for the GUI. See v:colornames
for details on how to define your own color names.

View File

@ -0,0 +1,166 @@
" Maintainer: Drew Vogel <dvogel@sidejump.org>
" Last Change: 2021 Jul 25
" Similar in spirit to rgb.txt, this plugin establishes a human-friendly name
" for every color listed in the CSS standard:
"
" https://www.w3.org/TR/css-color-3/
let s:keepcpo= &cpo
set cpo&vim
call extend(v:colornames, {
\ 'css_black': '#000000',
\ 'css_silver': '#c0c0c0',
\ 'css_gray': '#808080',
\ 'css_white': '#FFFFFF',
\ 'css_maroon': '#800000',
\ 'css_red': '#FF0000',
\ 'css_purple': '#800080',
\ 'css_fuchsia': '#FF00FF',
\ 'css_green': '#008000',
\ 'css_lime': '#00FF00',
\ 'css_olive': '#808000',
\ 'css_yellow': '#FFFF00',
\ 'css_navy': '#000080',
\ 'css_blue': '#0000FF',
\ 'css_teal': '#008080',
\ 'css_aqua': '#00FFFF',
\
\ 'css_aliceblue': '#f0f8ff',
\ 'css_antiquewhite': '#faebd7',
\ 'css_aquamarine': '#7fffd4',
\ 'css_azure': '#f0ffff',
\ 'css_beige': '#f5f5dc',
\ 'css_bisque': '#ffe4c4',
\ 'css_blanchedalmond': '#ffebcd',
\ 'css_blueviolet': '#8a2be2',
\ 'css_brown': '#a52a2a',
\ 'css_burlywood': '#deb887',
\ 'css_cadetblue': '#5f9ea0',
\ 'css_chartreuse': '#7fff00',
\ 'css_chocolate': '#d2691e',
\ 'css_coral': '#ff7f50',
\ 'css_cornflowerblue': '#6495ed',
\ 'css_cornsilk': '#fff8dc',
\ 'css_crimson': '#dc143c',
\ 'css_cyan': '#00ffff',
\ 'css_darkblue': '#00008b',
\ 'css_darkcyan': '#008b8b',
\ 'css_darkgoldenrod': '#b8860b',
\ 'css_darkgray': '#a9a9a9',
\ 'css_darkgreen': '#006400',
\ 'css_darkgrey': '#a9a9a9',
\ 'css_darkkhaki': '#bdb76b',
\ 'css_darkmagenta': '#8b008b',
\ 'css_darkolivegreen': '#556b2f',
\ 'css_darkorange': '#ff8c00',
\ 'css_darkorchid': '#9932cc',
\ 'css_darkred': '#8b0000',
\ 'css_darksalmon': '#e9967a',
\ 'css_darkseagreen': '#8fbc8f',
\ 'css_darkslateblue': '#483d8b',
\ 'css_darkslategray': '#2f4f4f',
\ 'css_darkslategrey': '#2f4f4f',
\ 'css_darkturquoise': '#00ced1',
\ 'css_darkviolet': '#9400d3',
\ 'css_deeppink': '#ff1493',
\ 'css_deepskyblue': '#00bfff',
\ 'css_dimgray': '#696969',
\ 'css_dimgrey': '#696969',
\ 'css_dodgerblue': '#1e90ff',
\ 'css_firebrick': '#b22222',
\ 'css_floralwhite': '#fffaf0',
\ 'css_forestgreen': '#228b22',
\ 'css_gainsboro': '#dcdcdc',
\ 'css_ghostwhite': '#f8f8ff',
\ 'css_gold': '#ffd700',
\ 'css_goldenrod': '#daa520',
\ 'css_greenyellow': '#adff2f',
\ 'css_grey': '#808080',
\ 'css_honeydew': '#f0fff0',
\ 'css_hotpink': '#ff69b4',
\ 'css_indianred': '#cd5c5c',
\ 'css_indigo': '#4b0082',
\ 'css_ivory': '#fffff0',
\ 'css_khaki': '#f0e68c',
\ 'css_lavender': '#e6e6fa',
\ 'css_lavenderblush': '#fff0f5',
\ 'css_lawngreen': '#7cfc00',
\ 'css_lemonchiffon': '#fffacd',
\ 'css_lightblue': '#add8e6',
\ 'css_lightcoral': '#f08080',
\ 'css_lightcyan': '#e0ffff',
\ 'css_lightgoldenrodyellow': '#fafad2',
\ 'css_lightgray': '#d3d3d3',
\ 'css_lightgreen': '#90ee90',
\ 'css_lightgrey': '#d3d3d3',
\ 'css_lightpink': '#ffb6c1',
\ 'css_lightsalmon': '#ffa07a',
\ 'css_lightseagreen': '#20b2aa',
\ 'css_lightskyblue': '#87cefa',
\ 'css_lightslategray': '#778899',
\ 'css_lightslategrey': '#778899',
\ 'css_lightsteelblue': '#b0c4de',
\ 'css_lightyellow': '#ffffe0',
\ 'css_limegreen': '#32cd32',
\ 'css_linen': '#faf0e6',
\ 'css_magenta': '#ff00ff',
\ 'css_mediumaquamarine': '#66cdaa',
\ 'css_mediumblue': '#0000cd',
\ 'css_mediumorchid': '#ba55d3',
\ 'css_mediumpurple': '#9370db',
\ 'css_mediumseagreen': '#3cb371',
\ 'css_mediumslateblue': '#7b68ee',
\ 'css_mediumspringgreen': '#00fa9a',
\ 'css_mediumturquoise': '#48d1cc',
\ 'css_mediumvioletred': '#c71585',
\ 'css_midnightblue': '#191970',
\ 'css_mintcream': '#f5fffa',
\ 'css_mistyrose': '#ffe4e1',
\ 'css_moccasin': '#ffe4b5',
\ 'css_navajowhite': '#ffdead',
\ 'css_oldlace': '#fdf5e6',
\ 'css_olivedrab': '#6b8e23',
\ 'css_orange': '#ffa500',
\ 'css_orangered': '#ff4500',
\ 'css_orchid': '#da70d6',
\ 'css_palegoldenrod': '#eee8aa',
\ 'css_palegreen': '#98fb98',
\ 'css_paleturquoise': '#afeeee',
\ 'css_palevioletred': '#db7093',
\ 'css_papayawhip': '#ffefd5',
\ 'css_peachpuff': '#ffdab9',
\ 'css_peru': '#cd853f',
\ 'css_pink': '#ffc0cb',
\ 'css_plum': '#dda0dd',
\ 'css_powderblue': '#b0e0e6',
\ 'css_rosybrown': '#bc8f8f',
\ 'css_royalblue': '#4169e1',
\ 'css_saddlebrown': '#8b4513',
\ 'css_salmon': '#fa8072',
\ 'css_sandybrown': '#f4a460',
\ 'css_seagreen': '#2e8b57',
\ 'css_seashell': '#fff5ee',
\ 'css_sienna': '#a0522d',
\ 'css_skyblue': '#87ceeb',
\ 'css_slateblue': '#6a5acd',
\ 'css_slategray': '#708090',
\ 'css_slategrey': '#708090',
\ 'css_snow': '#fffafa',
\ 'css_springgreen': '#00ff7f',
\ 'css_steelblue': '#4682b4',
\ 'css_tan': '#d2b48c',
\ 'css_thistle': '#d8bfd8',
\ 'css_tomato': '#ff6347',
\ 'css_turquoise': '#40e0d0',
\ 'css_violet': '#ee82ee',
\ 'css_wheat': '#f5deb3',
\ 'css_whitesmoke': '#f5f5f5',
\ 'css_yellowgreen': '#9acd32',
\ }, 'keep')
let &cpo= s:keepcpo
unlet s:keepcpo
"vim: sw=4

View File

@ -0,0 +1,801 @@
" Maintainer: Drew Vogel <dvogel@sidejump.org>
" Last Change: 2021 Jul 25
"
" Replaced rgb.txt as the source of de facto standard color names. This is
" sourced each time the colorscheme command is run. It is also sourced each
" time the highlight command fails to recognize a gui color. You can override
" these colors by introducing a new colors/lists/default.vim file earlier in
" the runtimepath.
let s:keepcpo= &cpo
set cpo&vim
call extend(v:colornames, {
\ 'snow': '#fffafa',
\ 'ghost white': '#f8f8ff',
\ 'ghostwhite': '#f8f8ff',
\ 'white smoke': '#f5f5f5',
\ 'whitesmoke': '#f5f5f5',
\ 'gainsboro': '#dcdcdc',
\ 'floral white': '#fffaf0',
\ 'floralwhite': '#fffaf0',
\ 'old lace': '#fdf5e6',
\ 'oldlace': '#fdf5e6',
\ 'linen': '#faf0e6',
\ 'antique white': '#faebd7',
\ 'antiquewhite': '#faebd7',
\ 'papaya whip': '#ffefd5',
\ 'papayawhip': '#ffefd5',
\ 'blanched almond': '#ffebcd',
\ 'blanchedalmond': '#ffebcd',
\ 'bisque': '#ffe4c4',
\ 'peach puff': '#ffdab9',
\ 'peachpuff': '#ffdab9',
\ 'navajo white': '#ffdead',
\ 'navajowhite': '#ffdead',
\ 'moccasin': '#ffe4b5',
\ 'cornsilk': '#fff8dc',
\ 'ivory': '#fffff0',
\ 'lemon chiffon': '#fffacd',
\ 'lemonchiffon': '#fffacd',
\ 'seashell': '#fff5ee',
\ 'honeydew': '#f0fff0',
\ 'mint cream': '#f5fffa',
\ 'mintcream': '#f5fffa',
\ 'azure': '#f0ffff',
\ 'alice blue': '#f0f8ff',
\ 'aliceblue': '#f0f8ff',
\ 'lavender': '#e6e6fa',
\ 'lavender blush': '#fff0f5',
\ 'lavenderblush': '#fff0f5',
\ 'misty rose': '#ffe4e1',
\ 'mistyrose': '#ffe4e1',
\ 'white': '#ffffff',
\ 'black': '#000000',
\ 'dark slate gray': '#2f4f4f',
\ 'darkslategray': '#2f4f4f',
\ 'dark slate grey': '#2f4f4f',
\ 'darkslategrey': '#2f4f4f',
\ 'dim gray': '#696969',
\ 'dimgray': '#696969',
\ 'dim grey': '#696969',
\ 'dimgrey': '#696969',
\ 'slate gray': '#708090',
\ 'slategray': '#708090',
\ 'slate grey': '#708090',
\ 'slategrey': '#708090',
\ 'light slate gray': '#778899',
\ 'lightslategray': '#778899',
\ 'light slate grey': '#778899',
\ 'lightslategrey': '#778899',
\ 'gray': '#bebebe',
\ 'grey': '#bebebe',
\ 'x11 gray': '#bebebe',
\ 'x11gray': '#bebebe',
\ 'x11 grey': '#bebebe',
\ 'x11grey': '#bebebe',
\ 'web gray': '#808080',
\ 'webgray': '#808080',
\ 'web grey': '#808080',
\ 'webgrey': '#808080',
\ 'light grey': '#d3d3d3',
\ 'lightgrey': '#d3d3d3',
\ 'light gray': '#d3d3d3',
\ 'lightgray': '#d3d3d3',
\ 'midnight blue': '#191970',
\ 'midnightblue': '#191970',
\ 'navy': '#000080',
\ 'navy blue': '#000080',
\ 'navyblue': '#000080',
\ 'cornflower blue': '#6495ed',
\ 'cornflowerblue': '#6495ed',
\ 'dark slate blue': '#483d8b',
\ 'darkslateblue': '#483d8b',
\ 'slate blue': '#6a5acd',
\ 'slateblue': '#6a5acd',
\ 'medium slate blue': '#7b68ee',
\ 'mediumslateblue': '#7b68ee',
\ 'light slate blue': '#8470ff',
\ 'lightslateblue': '#8470ff',
\ 'medium blue': '#0000cd',
\ 'mediumblue': '#0000cd',
\ 'royal blue': '#4169e1',
\ 'royalblue': '#4169e1',
\ 'blue': '#0000ff',
\ 'dodger blue': '#1e90ff',
\ 'dodgerblue': '#1e90ff',
\ 'deep sky blue': '#00bfff',
\ 'deepskyblue': '#00bfff',
\ 'sky blue': '#87ceeb',
\ 'skyblue': '#87ceeb',
\ 'light sky blue': '#87cefa',
\ 'lightskyblue': '#87cefa',
\ 'steel blue': '#4682b4',
\ 'steelblue': '#4682b4',
\ 'light steel blue': '#b0c4de',
\ 'lightsteelblue': '#b0c4de',
\ 'light blue': '#add8e6',
\ 'lightblue': '#add8e6',
\ 'powder blue': '#b0e0e6',
\ 'powderblue': '#b0e0e6',
\ 'pale turquoise': '#afeeee',
\ 'paleturquoise': '#afeeee',
\ 'dark turquoise': '#00ced1',
\ 'darkturquoise': '#00ced1',
\ 'medium turquoise': '#48d1cc',
\ 'mediumturquoise': '#48d1cc',
\ 'turquoise': '#40e0d0',
\ 'cyan': '#00ffff',
\ 'aqua': '#00ffff',
\ 'light cyan': '#e0ffff',
\ 'lightcyan': '#e0ffff',
\ 'cadet blue': '#5f9ea0',
\ 'cadetblue': '#5f9ea0',
\ 'medium aquamarine': '#66cdaa',
\ 'mediumaquamarine': '#66cdaa',
\ 'aquamarine': '#7fffd4',
\ 'dark green': '#006400',
\ 'darkgreen': '#006400',
\ 'dark olive green': '#556b2f',
\ 'darkolivegreen': '#556b2f',
\ 'dark sea green': '#8fbc8f',
\ 'darkseagreen': '#8fbc8f',
\ 'sea green': '#2e8b57',
\ 'seagreen': '#2e8b57',
\ 'medium sea green': '#3cb371',
\ 'mediumseagreen': '#3cb371',
\ 'light sea green': '#20b2aa',
\ 'lightseagreen': '#20b2aa',
\ 'pale green': '#98fb98',
\ 'palegreen': '#98fb98',
\ 'spring green': '#00ff7f',
\ 'springgreen': '#00ff7f',
\ 'lawn green': '#7cfc00',
\ 'lawngreen': '#7cfc00',
\ 'green': '#00ff00',
\ 'lime': '#00ff00',
\ 'x11 green': '#00ff00',
\ 'x11green': '#00ff00',
\ 'web green': '#008000',
\ 'webgreen': '#008000',
\ 'chartreuse': '#7fff00',
\ 'medium spring green': '#00fa9a',
\ 'mediumspringgreen': '#00fa9a',
\ 'green yellow': '#adff2f',
\ 'greenyellow': '#adff2f',
\ 'lime green': '#32cd32',
\ 'limegreen': '#32cd32',
\ 'yellow green': '#9acd32',
\ 'yellowgreen': '#9acd32',
\ 'forest green': '#228b22',
\ 'forestgreen': '#228b22',
\ 'olive drab': '#6b8e23',
\ 'olivedrab': '#6b8e23',
\ 'dark khaki': '#bdb76b',
\ 'darkkhaki': '#bdb76b',
\ 'khaki': '#f0e68c',
\ 'pale goldenrod': '#eee8aa',
\ 'palegoldenrod': '#eee8aa',
\ 'light goldenrod yellow': '#fafad2',
\ 'lightgoldenrodyellow': '#fafad2',
\ 'light yellow': '#ffffe0',
\ 'lightyellow': '#ffffe0',
\ 'yellow': '#ffff00',
\ 'gold': '#ffd700',
\ 'light goldenrod': '#eedd82',
\ 'lightgoldenrod': '#eedd82',
\ 'goldenrod': '#daa520',
\ 'dark goldenrod': '#b8860b',
\ 'darkgoldenrod': '#b8860b',
\ 'rosy brown': '#bc8f8f',
\ 'rosybrown': '#bc8f8f',
\ 'indian red': '#cd5c5c',
\ 'indianred': '#cd5c5c',
\ 'saddle brown': '#8b4513',
\ 'saddlebrown': '#8b4513',
\ 'sienna': '#a0522d',
\ 'peru': '#cd853f',
\ 'burlywood': '#deb887',
\ 'beige': '#f5f5dc',
\ 'wheat': '#f5deb3',
\ 'sandy brown': '#f4a460',
\ 'sandybrown': '#f4a460',
\ 'tan': '#d2b48c',
\ 'chocolate': '#d2691e',
\ 'firebrick': '#b22222',
\ 'brown': '#a52a2a',
\ 'dark salmon': '#e9967a',
\ 'darksalmon': '#e9967a',
\ 'salmon': '#fa8072',
\ 'light salmon': '#ffa07a',
\ 'lightsalmon': '#ffa07a',
\ 'orange': '#ffa500',
\ 'dark orange': '#ff8c00',
\ 'darkorange': '#ff8c00',
\ 'coral': '#ff7f50',
\ 'light coral': '#f08080',
\ 'lightcoral': '#f08080',
\ 'tomato': '#ff6347',
\ 'orange red': '#ff4500',
\ 'orangered': '#ff4500',
\ 'red': '#ff0000',
\ 'hot pink': '#ff69b4',
\ 'hotpink': '#ff69b4',
\ 'deep pink': '#ff1493',
\ 'deeppink': '#ff1493',
\ 'pink': '#ffc0cb',
\ 'light pink': '#ffb6c1',
\ 'lightpink': '#ffb6c1',
\ 'pale violet red': '#db7093',
\ 'palevioletred': '#db7093',
\ 'maroon': '#b03060',
\ 'x11 maroon': '#b03060',
\ 'x11maroon': '#b03060',
\ 'web maroon': '#800000',
\ 'webmaroon': '#800000',
\ 'medium violet red': '#c71585',
\ 'mediumvioletred': '#c71585',
\ 'violet red': '#d02090',
\ 'violetred': '#d02090',
\ 'magenta': '#ff00ff',
\ 'fuchsia': '#ff00ff',
\ 'violet': '#ee82ee',
\ 'plum': '#dda0dd',
\ 'orchid': '#da70d6',
\ 'medium orchid': '#ba55d3',
\ 'mediumorchid': '#ba55d3',
\ 'dark orchid': '#9932cc',
\ 'darkorchid': '#9932cc',
\ 'dark violet': '#9400d3',
\ 'darkviolet': '#9400d3',
\ 'blue violet': '#8a2be2',
\ 'blueviolet': '#8a2be2',
\ 'purple': '#a020f0',
\ 'x11 purple': '#a020f0',
\ 'x11purple': '#a020f0',
\ 'web purple': '#800080',
\ 'webpurple': '#800080',
\ 'medium purple': '#9370db',
\ 'mediumpurple': '#9370db',
\ 'thistle': '#d8bfd8',
\ 'snow1': '#fffafa',
\ 'snow2': '#eee9e9',
\ 'snow3': '#cdc9c9',
\ 'snow4': '#8b8989',
\ 'seashell1': '#fff5ee',
\ 'seashell2': '#eee5de',
\ 'seashell3': '#cdc5bf',
\ 'seashell4': '#8b8682',
\ 'antiquewhite1': '#ffefdb',
\ 'antiquewhite2': '#eedfcc',
\ 'antiquewhite3': '#cdc0b0',
\ 'antiquewhite4': '#8b8378',
\ 'bisque1': '#ffe4c4',
\ 'bisque2': '#eed5b7',
\ 'bisque3': '#cdb79e',
\ 'bisque4': '#8b7d6b',
\ 'peachpuff1': '#ffdab9',
\ 'peachpuff2': '#eecbad',
\ 'peachpuff3': '#cdaf95',
\ 'peachpuff4': '#8b7765',
\ 'navajowhite1': '#ffdead',
\ 'navajowhite2': '#eecfa1',
\ 'navajowhite3': '#cdb38b',
\ 'navajowhite4': '#8b795e',
\ 'lemonchiffon1': '#fffacd',
\ 'lemonchiffon2': '#eee9bf',
\ 'lemonchiffon3': '#cdc9a5',
\ 'lemonchiffon4': '#8b8970',
\ 'cornsilk1': '#fff8dc',
\ 'cornsilk2': '#eee8cd',
\ 'cornsilk3': '#cdc8b1',
\ 'cornsilk4': '#8b8878',
\ 'ivory1': '#fffff0',
\ 'ivory2': '#eeeee0',
\ 'ivory3': '#cdcdc1',
\ 'ivory4': '#8b8b83',
\ 'honeydew1': '#f0fff0',
\ 'honeydew2': '#e0eee0',
\ 'honeydew3': '#c1cdc1',
\ 'honeydew4': '#838b83',
\ 'lavenderblush1': '#fff0f5',
\ 'lavenderblush2': '#eee0e5',
\ 'lavenderblush3': '#cdc1c5',
\ 'lavenderblush4': '#8b8386',
\ 'mistyrose1': '#ffe4e1',
\ 'mistyrose2': '#eed5d2',
\ 'mistyrose3': '#cdb7b5',
\ 'mistyrose4': '#8b7d7b',
\ 'azure1': '#f0ffff',
\ 'azure2': '#e0eeee',
\ 'azure3': '#c1cdcd',
\ 'azure4': '#838b8b',
\ 'slateblue1': '#836fff',
\ 'slateblue2': '#7a67ee',
\ 'slateblue3': '#6959cd',
\ 'slateblue4': '#473c8b',
\ 'royalblue1': '#4876ff',
\ 'royalblue2': '#436eee',
\ 'royalblue3': '#3a5fcd',
\ 'royalblue4': '#27408b',
\ 'blue1': '#0000ff',
\ 'blue2': '#0000ee',
\ 'blue3': '#0000cd',
\ 'blue4': '#00008b',
\ 'dodgerblue1': '#1e90ff',
\ 'dodgerblue2': '#1c86ee',
\ 'dodgerblue3': '#1874cd',
\ 'dodgerblue4': '#104e8b',
\ 'steelblue1': '#63b8ff',
\ 'steelblue2': '#5cacee',
\ 'steelblue3': '#4f94cd',
\ 'steelblue4': '#36648b',
\ 'deepskyblue1': '#00bfff',
\ 'deepskyblue2': '#00b2ee',
\ 'deepskyblue3': '#009acd',
\ 'deepskyblue4': '#00688b',
\ 'skyblue1': '#87ceff',
\ 'skyblue2': '#7ec0ee',
\ 'skyblue3': '#6ca6cd',
\ 'skyblue4': '#4a708b',
\ 'lightskyblue1': '#b0e2ff',
\ 'lightskyblue2': '#a4d3ee',
\ 'lightskyblue3': '#8db6cd',
\ 'lightskyblue4': '#607b8b',
\ 'slategray1': '#c6e2ff',
\ 'slategray2': '#b9d3ee',
\ 'slategray3': '#9fb6cd',
\ 'slategray4': '#6c7b8b',
\ 'lightsteelblue1': '#cae1ff',
\ 'lightsteelblue2': '#bcd2ee',
\ 'lightsteelblue3': '#a2b5cd',
\ 'lightsteelblue4': '#6e7b8b',
\ 'lightblue1': '#bfefff',
\ 'lightblue2': '#b2dfee',
\ 'lightblue3': '#9ac0cd',
\ 'lightblue4': '#68838b',
\ 'lightcyan1': '#e0ffff',
\ 'lightcyan2': '#d1eeee',
\ 'lightcyan3': '#b4cdcd',
\ 'lightcyan4': '#7a8b8b',
\ 'paleturquoise1': '#bbffff',
\ 'paleturquoise2': '#aeeeee',
\ 'paleturquoise3': '#96cdcd',
\ 'paleturquoise4': '#668b8b',
\ 'cadetblue1': '#98f5ff',
\ 'cadetblue2': '#8ee5ee',
\ 'cadetblue3': '#7ac5cd',
\ 'cadetblue4': '#53868b',
\ 'turquoise1': '#00f5ff',
\ 'turquoise2': '#00e5ee',
\ 'turquoise3': '#00c5cd',
\ 'turquoise4': '#00868b',
\ 'cyan1': '#00ffff',
\ 'cyan2': '#00eeee',
\ 'cyan3': '#00cdcd',
\ 'cyan4': '#008b8b',
\ 'darkslategray1': '#97ffff',
\ 'darkslategray2': '#8deeee',
\ 'darkslategray3': '#79cdcd',
\ 'darkslategray4': '#528b8b',
\ 'aquamarine1': '#7fffd4',
\ 'aquamarine2': '#76eec6',
\ 'aquamarine3': '#66cdaa',
\ 'aquamarine4': '#458b74',
\ 'darkseagreen1': '#c1ffc1',
\ 'darkseagreen2': '#b4eeb4',
\ 'darkseagreen3': '#9bcd9b',
\ 'darkseagreen4': '#698b69',
\ 'seagreen1': '#54ff9f',
\ 'seagreen2': '#4eee94',
\ 'seagreen3': '#43cd80',
\ 'seagreen4': '#2e8b57',
\ 'palegreen1': '#9aff9a',
\ 'palegreen2': '#90ee90',
\ 'palegreen3': '#7ccd7c',
\ 'palegreen4': '#548b54',
\ 'springgreen1': '#00ff7f',
\ 'springgreen2': '#00ee76',
\ 'springgreen3': '#00cd66',
\ 'springgreen4': '#008b45',
\ 'green1': '#00ff00',
\ 'green2': '#00ee00',
\ 'green3': '#00cd00',
\ 'green4': '#008b00',
\ 'chartreuse1': '#7fff00',
\ 'chartreuse2': '#76ee00',
\ 'chartreuse3': '#66cd00',
\ 'chartreuse4': '#458b00',
\ 'olivedrab1': '#c0ff3e',
\ 'olivedrab2': '#b3ee3a',
\ 'olivedrab3': '#9acd32',
\ 'olivedrab4': '#698b22',
\ 'darkolivegreen1': '#caff70',
\ 'darkolivegreen2': '#bcee68',
\ 'darkolivegreen3': '#a2cd5a',
\ 'darkolivegreen4': '#6e8b3d',
\ 'khaki1': '#fff68f',
\ 'khaki2': '#eee685',
\ 'khaki3': '#cdc673',
\ 'khaki4': '#8b864e',
\ 'lightgoldenrod1': '#ffec8b',
\ 'lightgoldenrod2': '#eedc82',
\ 'lightgoldenrod3': '#cdbe70',
\ 'lightgoldenrod4': '#8b814c',
\ 'lightyellow1': '#ffffe0',
\ 'lightyellow2': '#eeeed1',
\ 'lightyellow3': '#cdcdb4',
\ 'lightyellow4': '#8b8b7a',
\ 'yellow1': '#ffff00',
\ 'yellow2': '#eeee00',
\ 'yellow3': '#cdcd00',
\ 'yellow4': '#8b8b00',
\ 'gold1': '#ffd700',
\ 'gold2': '#eec900',
\ 'gold3': '#cdad00',
\ 'gold4': '#8b7500',
\ 'goldenrod1': '#ffc125',
\ 'goldenrod2': '#eeb422',
\ 'goldenrod3': '#cd9b1d',
\ 'goldenrod4': '#8b6914',
\ 'darkgoldenrod1': '#ffb90f',
\ 'darkgoldenrod2': '#eead0e',
\ 'darkgoldenrod3': '#cd950c',
\ 'darkgoldenrod4': '#8b6508',
\ 'rosybrown1': '#ffc1c1',
\ 'rosybrown2': '#eeb4b4',
\ 'rosybrown3': '#cd9b9b',
\ 'rosybrown4': '#8b6969',
\ 'indianred1': '#ff6a6a',
\ 'indianred2': '#ee6363',
\ 'indianred3': '#cd5555',
\ 'indianred4': '#8b3a3a',
\ 'sienna1': '#ff8247',
\ 'sienna2': '#ee7942',
\ 'sienna3': '#cd6839',
\ 'sienna4': '#8b4726',
\ 'burlywood1': '#ffd39b',
\ 'burlywood2': '#eec591',
\ 'burlywood3': '#cdaa7d',
\ 'burlywood4': '#8b7355',
\ 'wheat1': '#ffe7ba',
\ 'wheat2': '#eed8ae',
\ 'wheat3': '#cdba96',
\ 'wheat4': '#8b7e66',
\ 'tan1': '#ffa54f',
\ 'tan2': '#ee9a49',
\ 'tan3': '#cd853f',
\ 'tan4': '#8b5a2b',
\ 'chocolate1': '#ff7f24',
\ 'chocolate2': '#ee7621',
\ 'chocolate3': '#cd661d',
\ 'chocolate4': '#8b4513',
\ 'firebrick1': '#ff3030',
\ 'firebrick2': '#ee2c2c',
\ 'firebrick3': '#cd2626',
\ 'firebrick4': '#8b1a1a',
\ 'brown1': '#ff4040',
\ 'brown2': '#ee3b3b',
\ 'brown3': '#cd3333',
\ 'brown4': '#8b2323',
\ 'salmon1': '#ff8c69',
\ 'salmon2': '#ee8262',
\ 'salmon3': '#cd7054',
\ 'salmon4': '#8b4c39',
\ 'lightsalmon1': '#ffa07a',
\ 'lightsalmon2': '#ee9572',
\ 'lightsalmon3': '#cd8162',
\ 'lightsalmon4': '#8b5742',
\ 'orange1': '#ffa500',
\ 'orange2': '#ee9a00',
\ 'orange3': '#cd8500',
\ 'orange4': '#8b5a00',
\ 'darkorange1': '#ff7f00',
\ 'darkorange2': '#ee7600',
\ 'darkorange3': '#cd6600',
\ 'darkorange4': '#8b4500',
\ 'coral1': '#ff7256',
\ 'coral2': '#ee6a50',
\ 'coral3': '#cd5b45',
\ 'coral4': '#8b3e2f',
\ 'tomato1': '#ff6347',
\ 'tomato2': '#ee5c42',
\ 'tomato3': '#cd4f39',
\ 'tomato4': '#8b3626',
\ 'orangered1': '#ff4500',
\ 'orangered2': '#ee4000',
\ 'orangered3': '#cd3700',
\ 'orangered4': '#8b2500',
\ 'red1': '#ff0000',
\ 'red2': '#ee0000',
\ 'red3': '#cd0000',
\ 'red4': '#8b0000',
\ 'deeppink1': '#ff1493',
\ 'deeppink2': '#ee1289',
\ 'deeppink3': '#cd1076',
\ 'deeppink4': '#8b0a50',
\ 'hotpink1': '#ff6eb4',
\ 'hotpink2': '#ee6aa7',
\ 'hotpink3': '#cd6090',
\ 'hotpink4': '#8b3a62',
\ 'pink1': '#ffb5c5',
\ 'pink2': '#eea9b8',
\ 'pink3': '#cd919e',
\ 'pink4': '#8b636c',
\ 'lightpink1': '#ffaeb9',
\ 'lightpink2': '#eea2ad',
\ 'lightpink3': '#cd8c95',
\ 'lightpink4': '#8b5f65',
\ 'palevioletred1': '#ff82ab',
\ 'palevioletred2': '#ee799f',
\ 'palevioletred3': '#cd6889',
\ 'palevioletred4': '#8b475d',
\ 'maroon1': '#ff34b3',
\ 'maroon2': '#ee30a7',
\ 'maroon3': '#cd2990',
\ 'maroon4': '#8b1c62',
\ 'violetred1': '#ff3e96',
\ 'violetred2': '#ee3a8c',
\ 'violetred3': '#cd3278',
\ 'violetred4': '#8b2252',
\ 'magenta1': '#ff00ff',
\ 'magenta2': '#ee00ee',
\ 'magenta3': '#cd00cd',
\ 'magenta4': '#8b008b',
\ 'orchid1': '#ff83fa',
\ 'orchid2': '#ee7ae9',
\ 'orchid3': '#cd69c9',
\ 'orchid4': '#8b4789',
\ 'plum1': '#ffbbff',
\ 'plum2': '#eeaeee',
\ 'plum3': '#cd96cd',
\ 'plum4': '#8b668b',
\ 'mediumorchid1': '#e066ff',
\ 'mediumorchid2': '#d15fee',
\ 'mediumorchid3': '#b452cd',
\ 'mediumorchid4': '#7a378b',
\ 'darkorchid1': '#bf3eff',
\ 'darkorchid2': '#b23aee',
\ 'darkorchid3': '#9a32cd',
\ 'darkorchid4': '#68228b',
\ 'purple1': '#9b30ff',
\ 'purple2': '#912cee',
\ 'purple3': '#7d26cd',
\ 'purple4': '#551a8b',
\ 'mediumpurple1': '#ab82ff',
\ 'mediumpurple2': '#9f79ee',
\ 'mediumpurple3': '#8968cd',
\ 'mediumpurple4': '#5d478b',
\ 'thistle1': '#ffe1ff',
\ 'thistle2': '#eed2ee',
\ 'thistle3': '#cdb5cd',
\ 'thistle4': '#8b7b8b',
\ 'gray0': '#000000',
\ 'grey0': '#000000',
\ 'gray1': '#030303',
\ 'grey1': '#030303',
\ 'gray2': '#050505',
\ 'grey2': '#050505',
\ 'gray3': '#080808',
\ 'grey3': '#080808',
\ 'gray4': '#0a0a0a',
\ 'grey4': '#0a0a0a',
\ 'gray5': '#0d0d0d',
\ 'grey5': '#0d0d0d',
\ 'gray6': '#0f0f0f',
\ 'grey6': '#0f0f0f',
\ 'gray7': '#121212',
\ 'grey7': '#121212',
\ 'gray8': '#141414',
\ 'grey8': '#141414',
\ 'gray9': '#171717',
\ 'grey9': '#171717',
\ 'gray10': '#1a1a1a',
\ 'grey10': '#1a1a1a',
\ 'gray11': '#1c1c1c',
\ 'grey11': '#1c1c1c',
\ 'gray12': '#1f1f1f',
\ 'grey12': '#1f1f1f',
\ 'gray13': '#212121',
\ 'grey13': '#212121',
\ 'gray14': '#242424',
\ 'grey14': '#242424',
\ 'gray15': '#262626',
\ 'grey15': '#262626',
\ 'gray16': '#292929',
\ 'grey16': '#292929',
\ 'gray17': '#2b2b2b',
\ 'grey17': '#2b2b2b',
\ 'gray18': '#2e2e2e',
\ 'grey18': '#2e2e2e',
\ 'gray19': '#303030',
\ 'grey19': '#303030',
\ 'gray20': '#333333',
\ 'grey20': '#333333',
\ 'gray21': '#363636',
\ 'grey21': '#363636',
\ 'gray22': '#383838',
\ 'grey22': '#383838',
\ 'gray23': '#3b3b3b',
\ 'grey23': '#3b3b3b',
\ 'gray24': '#3d3d3d',
\ 'grey24': '#3d3d3d',
\ 'gray25': '#404040',
\ 'grey25': '#404040',
\ 'gray26': '#424242',
\ 'grey26': '#424242',
\ 'gray27': '#454545',
\ 'grey27': '#454545',
\ 'gray28': '#474747',
\ 'grey28': '#474747',
\ 'gray29': '#4a4a4a',
\ 'grey29': '#4a4a4a',
\ 'gray30': '#4d4d4d',
\ 'grey30': '#4d4d4d',
\ 'gray31': '#4f4f4f',
\ 'grey31': '#4f4f4f',
\ 'gray32': '#525252',
\ 'grey32': '#525252',
\ 'gray33': '#545454',
\ 'grey33': '#545454',
\ 'gray34': '#575757',
\ 'grey34': '#575757',
\ 'gray35': '#595959',
\ 'grey35': '#595959',
\ 'gray36': '#5c5c5c',
\ 'grey36': '#5c5c5c',
\ 'gray37': '#5e5e5e',
\ 'grey37': '#5e5e5e',
\ 'gray38': '#616161',
\ 'grey38': '#616161',
\ 'gray39': '#636363',
\ 'grey39': '#636363',
\ 'gray40': '#666666',
\ 'grey40': '#666666',
\ 'gray41': '#696969',
\ 'grey41': '#696969',
\ 'gray42': '#6b6b6b',
\ 'grey42': '#6b6b6b',
\ 'gray43': '#6e6e6e',
\ 'grey43': '#6e6e6e',
\ 'gray44': '#707070',
\ 'grey44': '#707070',
\ 'gray45': '#737373',
\ 'grey45': '#737373',
\ 'gray46': '#757575',
\ 'grey46': '#757575',
\ 'gray47': '#787878',
\ 'grey47': '#787878',
\ 'gray48': '#7a7a7a',
\ 'grey48': '#7a7a7a',
\ 'gray49': '#7d7d7d',
\ 'grey49': '#7d7d7d',
\ 'gray50': '#7f7f7f',
\ 'grey50': '#7f7f7f',
\ 'gray51': '#828282',
\ 'grey51': '#828282',
\ 'gray52': '#858585',
\ 'grey52': '#858585',
\ 'gray53': '#878787',
\ 'grey53': '#878787',
\ 'gray54': '#8a8a8a',
\ 'grey54': '#8a8a8a',
\ 'gray55': '#8c8c8c',
\ 'grey55': '#8c8c8c',
\ 'gray56': '#8f8f8f',
\ 'grey56': '#8f8f8f',
\ 'gray57': '#919191',
\ 'grey57': '#919191',
\ 'gray58': '#949494',
\ 'grey58': '#949494',
\ 'gray59': '#969696',
\ 'grey59': '#969696',
\ 'gray60': '#999999',
\ 'grey60': '#999999',
\ 'gray61': '#9c9c9c',
\ 'grey61': '#9c9c9c',
\ 'gray62': '#9e9e9e',
\ 'grey62': '#9e9e9e',
\ 'gray63': '#a1a1a1',
\ 'grey63': '#a1a1a1',
\ 'gray64': '#a3a3a3',
\ 'grey64': '#a3a3a3',
\ 'gray65': '#a6a6a6',
\ 'grey65': '#a6a6a6',
\ 'gray66': '#a8a8a8',
\ 'grey66': '#a8a8a8',
\ 'gray67': '#ababab',
\ 'grey67': '#ababab',
\ 'gray68': '#adadad',
\ 'grey68': '#adadad',
\ 'gray69': '#b0b0b0',
\ 'grey69': '#b0b0b0',
\ 'gray70': '#b3b3b3',
\ 'grey70': '#b3b3b3',
\ 'gray71': '#b5b5b5',
\ 'grey71': '#b5b5b5',
\ 'gray72': '#b8b8b8',
\ 'grey72': '#b8b8b8',
\ 'gray73': '#bababa',
\ 'grey73': '#bababa',
\ 'gray74': '#bdbdbd',
\ 'grey74': '#bdbdbd',
\ 'gray75': '#bfbfbf',
\ 'grey75': '#bfbfbf',
\ 'gray76': '#c2c2c2',
\ 'grey76': '#c2c2c2',
\ 'gray77': '#c4c4c4',
\ 'grey77': '#c4c4c4',
\ 'gray78': '#c7c7c7',
\ 'grey78': '#c7c7c7',
\ 'gray79': '#c9c9c9',
\ 'grey79': '#c9c9c9',
\ 'gray80': '#cccccc',
\ 'grey80': '#cccccc',
\ 'gray81': '#cfcfcf',
\ 'grey81': '#cfcfcf',
\ 'gray82': '#d1d1d1',
\ 'grey82': '#d1d1d1',
\ 'gray83': '#d4d4d4',
\ 'grey83': '#d4d4d4',
\ 'gray84': '#d6d6d6',
\ 'grey84': '#d6d6d6',
\ 'gray85': '#d9d9d9',
\ 'grey85': '#d9d9d9',
\ 'gray86': '#dbdbdb',
\ 'grey86': '#dbdbdb',
\ 'gray87': '#dedede',
\ 'grey87': '#dedede',
\ 'gray88': '#e0e0e0',
\ 'grey88': '#e0e0e0',
\ 'gray89': '#e3e3e3',
\ 'grey89': '#e3e3e3',
\ 'gray90': '#e5e5e5',
\ 'grey90': '#e5e5e5',
\ 'gray91': '#e8e8e8',
\ 'grey91': '#e8e8e8',
\ 'gray92': '#ebebeb',
\ 'grey92': '#ebebeb',
\ 'gray93': '#ededed',
\ 'grey93': '#ededed',
\ 'gray94': '#f0f0f0',
\ 'grey94': '#f0f0f0',
\ 'gray95': '#f2f2f2',
\ 'grey95': '#f2f2f2',
\ 'gray96': '#f5f5f5',
\ 'grey96': '#f5f5f5',
\ 'gray97': '#f7f7f7',
\ 'grey97': '#f7f7f7',
\ 'gray98': '#fafafa',
\ 'grey98': '#fafafa',
\ 'gray99': '#fcfcfc',
\ 'grey99': '#fcfcfc',
\ 'gray100': '#ffffff',
\ 'grey100': '#ffffff',
\ 'dark grey': '#a9a9a9',
\ 'darkgrey': '#a9a9a9',
\ 'dark gray': '#a9a9a9',
\ 'darkgray': '#a9a9a9',
\ 'dark blue': '#00008b',
\ 'darkblue': '#00008b',
\ 'dark cyan': '#008b8b',
\ 'darkcyan': '#008b8b',
\ 'dark magenta': '#8b008b',
\ 'darkmagenta': '#8b008b',
\ 'dark red': '#8b0000',
\ 'darkred': '#8b0000',
\ 'light green': '#90ee90',
\ 'lightgreen': '#90ee90',
\ 'crimson': '#dc143c',
\ 'indigo': '#4b0082',
\ 'olive': '#808000',
\ 'rebecca purple': '#663399',
\ 'rebeccapurple': '#663399',
\ 'silver': '#c0c0c0',
\ 'teal': '#008080'
\ }, 'keep')
let &cpo= s:keepcpo
unlet s:keepcpo
"vim: sw=4

View File

@ -1840,6 +1840,43 @@ v:collate The current locale setting for collation order of the runtime
command.
See |multi-lang|.
*v:colornames*
v:colornames A dictionary that maps color names to hex color strings. These
color names can be used with the |highlight-guifg|,
|highlight-guibg|, and |highlight-guisp| parameters. Updating
an entry in v:colornames has no immediate effect on the syntax
highlighting. The highlight commands (probably in a
colorscheme script) need to be re-evaluated in order to use
the updated color values. For example: >
:let v:colornames['fuscia'] = '#cf3ab4'
:let v:colornames['mauve'] = '#915f6d'
:highlight Normal guifg=fuscia guibg=mauve
<
This cannot be used to override the |cterm-colors| but it can
be used to override other colors. For example, the X11 colors
defined in the `colors/lists/default.vim` (previously defined
in |rgb.txt|). When defining new color names in a plugin, the
recommended practice is to set a color entry only when it does
not already exist. For example: >
:call extend(v:colornames, {
\ 'fuscia': '#cf3ab4',
\ 'mauve': '#915f6d,
\ }, 'keep')
<
Using |extend| with the 'keep' option updates each color only
if it did not exist in |v:colornames|. Doing so allows the
user to choose the precise color value for a common name
by setting it in their |.vimrc|.
It is possible to remove entries from this dictionary but
doing so is *NOT* recommended. Doing so is disruptive to
other scripts. It is also unlikely to achieve the desired
result because the |colorscheme| and |highlight| commands will
both automatically load all `colors/lists/default.vim` color
scripts.
*v:completed_item* *completed_item-variable*
v:completed_item
|Dictionary| containing the |complete-items| for the most

View File

@ -323,20 +323,10 @@ These extra colors are also available:
Gray, Grey, LightYellow, SeaGreen, Orange, Purple, SlateBlue, Violet,
*rgb.txt*
Additionally, colors defined by a "rgb.txt" file can be used. This file is
well known from X11. A few lines from it: >
255 218 185 peach puff
205 133 63 peru
255 181 197 pink
This shows the layout of the file: First the R, G and B value as a decimal
number, followed by the name of the color. The four fields are separated by
spaces.
You can get an rgb.txt file from any X11 distribution. It is located in a
directory like "/usr/X11R6/lib/X11/". For Vim it must be located in the
$VIMRUNTIME directory. Thus the file can be found with "$VIMRUNTIME/rgb.txt".
Additionally, colors defined by a default color list can be used. For more
info see |:colorscheme|. These colors used to be defined in
$VIMRUNTIME/rgb.txt, now they are in |v:colornames| which is initialized from
$VIMRUNTIME/colors/lists/default.vim.
==============================================================================
*gui-w32-dialogs* *dialog*

View File

@ -141,6 +141,11 @@ larger. When it's more there probably is an endless loop. Probably a
The color name {name} is unknown. See |gui-colors| for a list of colors that
are available on most systems.
*E1244* >
Bad color string: {str}
The provided color did not conform to the pattern #rrggbb
*E458* >
Cannot allocate colormap entry, some colors may be incorrect

View File

@ -194,9 +194,8 @@ $VIM/macros/swapmous.vim for an example. |gui-mouse-mapping|
11. Color names *haiku-colors*
Vim has a number of color names built-in. Additional names are read from the
file $VIMRUNTIME/rgb.txt, if present. This file is basically the color
database from X. Names used from this file are cached for efficiency.
Vim has a number of color names built-in. Additional names can be defined in
|v:colornames|. See |:colorscheme| for details.
12. GUI Toolbar Images *haiku-toolbar-images*

View File

@ -5143,8 +5143,35 @@ guisp={color-name} *highlight-guisp*
"gg" is the Green value
"bb" is the Blue value
All values are hexadecimal, range from "00" to "ff". Examples: >
:highlight Comment guifg=#11f0c3 guibg=#ff00ff
:highlight Comment guifg=#11f0c3 guibg=#ff00ff
<
If you are authoring a color scheme and use the same hexademical value
repeatedly, you can define a name for it in |v:colornames|. For
example: >
# provide a default value for this color but allow the user to
# override it.
:call extend(v:colornames, {'alt_turquoise': '#11f0c3'}, 'keep')
:highlight Comment guifg=alt_turquoise guibg=magenta
<
If you are using a color scheme that relies on named colors and you
would like to adjust the precise appearance of those colors, you can
do so by overriding the values in |v:colornames| prior to loading the
scheme: >
let v:colornames['alt_turquoise'] = '#22f0d3'
colorscheme alt
<
If you want to develop a color list that can be relied on by others,
it is best to prefix your color names. By convention these color lists
are placed in the colors/lists directory. You can see an example in
'$VIMRUNTIME/colors/lists/csscolors.vim'. This list would be sourced
by a color scheme using: >
:runtime colors/lists/csscolors.vim
:highlight Comment guifg=css_turquoise
<
*highlight-groups* *highlight-default*
These are the default highlighting groups. These groups are used by the
'highlight' option default. Note that the highlighting depends on the value

View File

@ -184,7 +184,30 @@ this command: >
:runtime syntax/colortest.vim
You will see text in various color combinations. You can check which ones are
readable and look nice.
readable and look nice. These aren't the only colors available to you though.
You can specify #rrggbb hex colors and you can define new names for hex
colors in |v:colornames| like so: >
let v:colornames['mine_red'] = '#aa0000'
<
If you are authoring a color scheme for others to use, it is important
to define these colors only when they do not exist: >
call extend(v:colornames, {'mine_red': '#aa0000'}, 'keep')
This allows users of the color scheme to override the precise definition of
that color prior to loading your color scheme. For example, in a |.vimrc|
file:
runtime colors/lists/css_colors.vim
let v:colornames['your_red'] = v:colornames['css_red']
colorscheme yourscheme
As a color scheme author, you should be able to rely on some color names for
GUI colors. These are defined in `colors/lists/default.vim`. All such files
found on the |runtimepath| are loaded each time the colorscheme command is
run. A canonical list is provided by the vim distribution, which should
include all X11 colors (previously defined in rgb.txt).
==============================================================================
*06.4* With colors or without colors

View File

@ -1136,9 +1136,6 @@ SYS_DELMENU_FILE = $(DESTDIR)$(SCRIPTLOC)/delmenu.vim
### Name of the bugreport file target.
SYS_BUGR_FILE = $(DESTDIR)$(SCRIPTLOC)/bugreport.vim
### Name of the rgb.txt file target.
SYS_RGB_FILE = $(DESTDIR)$(SCRIPTLOC)/rgb.txt
### Name of the file type detection file target.
SYS_FILETYPE_FILE = $(DESTDIR)$(SCRIPTLOC)/filetype.vim
@ -2449,9 +2446,6 @@ installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(DEST_RT) \
chmod $(VIMSCRIPTMOD) $(EVIM_FILE)
$(INSTALL_DATA) $(SCRIPTSOURCE)/mswin.vim $(MSWIN_FILE)
chmod $(VIMSCRIPTMOD) $(MSWIN_FILE)
# install the rgb.txt file
$(INSTALL_DATA) $(SCRIPTSOURCE)/rgb.txt $(SYS_RGB_FILE)
chmod $(VIMSCRIPTMOD) $(SYS_RGB_FILE)
# install the bugreport file
$(INSTALL_DATA) $(SCRIPTSOURCE)/bugreport.vim $(SYS_BUGR_FILE)
chmod $(VIMSCRIPTMOD) $(SYS_BUGR_FILE)
@ -2481,7 +2475,7 @@ installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(DEST_RT) \
cd $(PRINTSOURCE); $(INSTALL_DATA) *.ps $(DEST_PRINT)
cd $(DEST_PRINT); chmod $(FILEMOD) *.ps
# install the colorscheme files
cd $(COLSOURCE); $(INSTALL_DATA_R) *.vim tools README.txt $(DEST_COL)
cd $(COLSOURCE); $(INSTALL_DATA_R) *.vim lists tools README.txt $(DEST_COL)
cd $(DEST_COL); chmod $(DIRMOD) tools
cd $(DEST_COL); chmod $(HELPMOD) *.vim README.txt tools/*.vim
# install the syntax files
@ -2894,7 +2888,6 @@ uninstall_runtime:
-rm -f $(DEST_MAN_RU)/xxd.1 $(DEST_MAN_RU_U)/xxd.1
-rm -f $(DEST_HELP)/*.txt $(DEST_HELP)/tags $(DEST_HELP)/*.pl
-rm -f $(DEST_HELP)/*.??x $(DEST_HELP)/tags-??
-rm -f $(SYS_RGB_FILE)
-rm -f $(SYS_MENU_FILE) $(SYS_SYNMENU_FILE) $(SYS_DELMENU_FILE)
-rm -f $(SYS_BUGR_FILE) $(VIM_DEFAULTS_FILE) $(EVIM_FILE) $(MSWIN_FILE)
-rm -f $(DEST_SCRIPT)/gvimrc_example.vim $(DEST_SCRIPT)/vimrc_example.vim
@ -3666,12 +3659,10 @@ Makefile:
# This rule:
# - add resources to already installed vim binary to avoid
# stripping them during install;
# - copy rgb.txt to runtime directory;
# - update system MIME database with info about vim application.
#
install_haiku_extra: $(DEST_BIN)/$(VIMTARGET) objects/os_haiku.rsrc
xres -o $(DEST_BIN)/$(VIMTARGET) objects/os_haiku.rsrc
$(INSTALL_DATA) $(SCRIPTSOURCE)/rgb.txt $(DEST_RT)
mimeset $(DEST_BIN)/$(VIMTARGET)
# List of g*-links that should be replaced with shell script equivalents.

View File

@ -147,6 +147,10 @@ EXTERN char e_no_such_user_defined_command_str[]
EXTERN char e_no_digraphs_version[]
INIT(= N_("E196: No digraphs in this version"));
#endif
#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
EXTERN char e_cannot_allocate_color_str[]
INIT(= N_("E254: Cannot allocate color %s"));
#endif
EXTERN char e_ambiguous_use_of_user_defined_command[]
INIT(= N_("E464: Ambiguous use of user-defined command"));
EXTERN char e_invalid_command[]
@ -678,3 +682,5 @@ EXTERN char e_no_white_space_allowed_before_separator_str[]
INIT(= N_("E1242: No white space allowed before separator: %s"));
EXTERN char e_ascii_code_not_in_range[]
INIT(= N_("E1243: ASCII code not in 32-127 range"));
EXTERN char e_bad_color_string_str[]
INIT(= N_("E1244: Bad color string: %s"));

View File

@ -149,6 +149,7 @@ static struct vimvar
{VV_NAME("argv", VAR_LIST), VV_RO},
{VV_NAME("collate", VAR_STRING), VV_RO},
{VV_NAME("exiting", VAR_SPECIAL), VV_RO},
{VV_NAME("colornames", VAR_DICT), VV_RO},
};
// shorthand
@ -248,6 +249,8 @@ evalvars_init(void)
set_vim_var_nr(VV_ECHOSPACE, sc_col - 1);
set_vim_var_dict(VV_COLORNAMES, dict_alloc());
// Default for v:register is not 0 but '"'. This is adjusted once the
// clipboard has been setup by calling reset_reg_var().
set_reg_var(0);

View File

@ -1774,9 +1774,6 @@ EXTERN char e_nowhitespace[] INIT(= N_("E274: No white space allowed before pare
EXTERN char e_lock_unlock[] INIT(= N_("E940: Cannot lock or unlock variable %s"));
#endif
#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
EXTERN char e_alloc_color[] INIT(= N_("E254: Cannot allocate color %s"));
#endif
EXTERN char e_chan_or_job_req[] INIT(= N_("E706: Channel or Job required"));
EXTERN char e_jobreq[] INIT(= N_("E693: Job required"));

View File

@ -4785,7 +4785,7 @@ gui_get_color(char_u *name)
&& gui.in_use
#endif
)
semsg(_(e_alloc_color), name);
semsg(_(e_cannot_allocate_color_str), name);
return t;
}

View File

@ -4054,164 +4054,7 @@ guicolor_T
gui_mch_get_color(
char_u *name)
{
typedef struct GuiColourTable
{
const char *name;
guicolor_T colour;
} GuiColourTable;
#define NSTATIC_COLOURS 50 // 32
#define NDYNAMIC_COLOURS 33
#define NCOLOURS (NSTATIC_COLOURS + NDYNAMIC_COLOURS)
static GuiColourTable table[NCOLOURS] =
{
{"Black", RGB(0x00, 0x00, 0x00)},
{"DarkGray", RGB(0x80, 0x80, 0x80)},
{"DarkGrey", RGB(0x80, 0x80, 0x80)},
{"Gray", RGB(0xC0, 0xC0, 0xC0)},
{"Grey", RGB(0xC0, 0xC0, 0xC0)},
{"LightGray", RGB(0xD3, 0xD3, 0xD3)},
{"LightGrey", RGB(0xD3, 0xD3, 0xD3)},
{"Gray10", RGB(0x1A, 0x1A, 0x1A)},
{"Grey10", RGB(0x1A, 0x1A, 0x1A)},
{"Gray20", RGB(0x33, 0x33, 0x33)},
{"Grey20", RGB(0x33, 0x33, 0x33)},
{"Gray30", RGB(0x4D, 0x4D, 0x4D)},
{"Grey30", RGB(0x4D, 0x4D, 0x4D)},
{"Gray40", RGB(0x66, 0x66, 0x66)},
{"Grey40", RGB(0x66, 0x66, 0x66)},
{"Gray50", RGB(0x7F, 0x7F, 0x7F)},
{"Grey50", RGB(0x7F, 0x7F, 0x7F)},
{"Gray60", RGB(0x99, 0x99, 0x99)},
{"Grey60", RGB(0x99, 0x99, 0x99)},
{"Gray70", RGB(0xB3, 0xB3, 0xB3)},
{"Grey70", RGB(0xB3, 0xB3, 0xB3)},
{"Gray80", RGB(0xCC, 0xCC, 0xCC)},
{"Grey80", RGB(0xCC, 0xCC, 0xCC)},
{"Gray90", RGB(0xE5, 0xE5, 0xE5)},
{"Grey90", RGB(0xE5, 0xE5, 0xE5)},
{"White", RGB(0xFF, 0xFF, 0xFF)},
{"DarkRed", RGB(0x80, 0x00, 0x00)},
{"Red", RGB(0xFF, 0x00, 0x00)},
{"LightRed", RGB(0xFF, 0xA0, 0xA0)},
{"DarkBlue", RGB(0x00, 0x00, 0x80)},
{"Blue", RGB(0x00, 0x00, 0xFF)},
{"LightBlue", RGB(0xA0, 0xA0, 0xFF)},
{"DarkGreen", RGB(0x00, 0x80, 0x00)},
{"Green", RGB(0x00, 0xFF, 0x00)},
{"LightGreen", RGB(0xA0, 0xFF, 0xA0)},
{"DarkCyan", RGB(0x00, 0x80, 0x80)},
{"Cyan", RGB(0x00, 0xFF, 0xFF)},
{"LightCyan", RGB(0xA0, 0xFF, 0xFF)},
{"DarkMagenta", RGB(0x80, 0x00, 0x80)},
{"Magenta", RGB(0xFF, 0x00, 0xFF)},
{"LightMagenta", RGB(0xFF, 0xA0, 0xFF)},
{"Brown", RGB(0x80, 0x40, 0x40)},
{"Yellow", RGB(0xFF, 0xFF, 0x00)},
{"LightYellow", RGB(0xFF, 0xFF, 0xA0)},
{"DarkYellow", RGB(0xBB, 0xBB, 0x00)},
{"SeaGreen", RGB(0x2E, 0x8B, 0x57)},
{"Orange", RGB(0xFF, 0xA5, 0x00)},
{"Purple", RGB(0xA0, 0x20, 0xF0)},
{"SlateBlue", RGB(0x6A, 0x5A, 0xCD)},
{"Violet", RGB(0xEE, 0x82, 0xEE)},
// NOTE: some entries are zero-allocated for NDDYNAMIC_COLORS
// in this table!
};
static int endColour = NSTATIC_COLOURS;
static int newColour = NSTATIC_COLOURS;
int r, g, b;
int i;
if (name[0] == '#' && STRLEN(name) == 7)
{
// Name is in "#rrggbb" format
r = hex_digit(name[1]) * 16 + hex_digit(name[2]);
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
{
// Check if the name is one of the colours we know
for (i = 0; i < endColour; i++)
if (STRICMP(name, table[i].name) == 0)
return table[i].colour;
}
/*
* Last attempt. Look in the file "$VIMRUNTIME/rgb.txt".
*/
{
#define LINE_LEN 100
FILE *fd;
char line[LINE_LEN];
char_u *fname;
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))
{
int len;
int pos;
char *colour;
fgets(line, LINE_LEN, fd);
len = strlen(line);
if (len <= 1 || line[len-1] != '\n')
continue;
line[len-1] = '\0';
i = sscanf(line, "%d %d %d %n", &r, &g, &b, &pos);
if (i != 3)
continue;
colour = line + pos;
if (STRICMP(colour, name) == 0)
{
fclose(fd);
/*
* Now remember this colour in the table.
* A LRU scheme might be better but this is simpler.
* Or could use a growing array.
*/
guicolor_T gcolour = RGB(r,g,b);
// NOTE: see note above in table allocation! We are working here with
// dynamically allocated names, not constant ones!
vim_free((char*)table[newColour].name);
table[newColour].name = (char *)vim_strsave((char_u *)colour);
table[newColour].colour = gcolour;
newColour++;
if (newColour >= NCOLOURS)
newColour = NSTATIC_COLOURS;
if (endColour < NCOLOURS)
endColour = newColour;
return gcolour;
}
}
fclose(fd);
}
return INVALCOLOR;
return gui_get_color_cmn(name);
}
/*

View File

@ -475,6 +475,9 @@ load_colors(char_u *name)
buf = alloc(STRLEN(name) + 12);
if (buf != NULL)
{
#ifdef FEAT_EVAL
load_default_colors_lists();
#endif
apply_autocmds(EVENT_COLORSCHEMEPRE, name,
curbuf->b_fname, FALSE, curbuf);
sprintf((char *)buf, "colors/%s.vim", name);
@ -1190,7 +1193,7 @@ highlight_set_guibg(
HL_TABLE()[idx].sg_set |= SG_GUI;
# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
// In GUI guifg colors are only used when recognized
// In GUI guibg colors are only used when recognized
i = color_name2handle(arg);
if (i != INVALCOLOR || STRCMP(arg, "NONE") == 0 || !USE_24BIT)
{
@ -2231,6 +2234,234 @@ color_name2handle(char_u *name)
return GUI_GET_COLOR(name);
}
// On MS-Windows an RGB macro is available and it produces 0x00bbggrr color
// values as used by the MS-Windows GDI api. It should be used only for
// MS-Windows GDI builds.
# if defined(RGB) && defined(MSWIN) && !defined(FEAT_GUI)
# undef RGB
# endif
# ifndef RGB
# define RGB(r, g, b) ((r<<16) | (g<<8) | (b))
# endif
# ifdef VIMDLL
static guicolor_T
gui_adjust_rgb(guicolor_T c)
{
if (gui.in_use)
return c;
else
return ((c & 0xff) << 16) | (c & 0x00ff00) | ((c >> 16) & 0xff);
}
# else
# define gui_adjust_rgb(c) (c)
# endif
static int
hex_digit(int c)
{
if (isdigit(c))
return c - '0';
c = TOLOWER_ASC(c);
if (c >= 'a' && c <= 'f')
return c - 'a' + 10;
return 0x1ffffff;
}
guicolor_T
decode_hex_color(char_u *hex)
{
guicolor_T color;
if (hex[0] != '#' || STRLEN(hex) != 7)
return INVALCOLOR;
// Name is in "#rrggbb" format
color = RGB(((hex_digit(hex[1]) << 4) + hex_digit(hex[2])),
((hex_digit(hex[3]) << 4) + hex_digit(hex[4])),
((hex_digit(hex[5]) << 4) + hex_digit(hex[6])));
if (color > 0xffffff)
return INVALCOLOR;
return gui_adjust_rgb(color);
}
#if defined(FEAT_EVAL)
// Returns the color currently mapped to the given name or INVALCOLOR if no
// such name exists in the color table. The convention is to use lowercase for
// all keys in the v:colornames dictionary. The value can be either a string in
// the form #rrggbb or a number, either of which is converted to a guicolor_T.
guicolor_T
colorname2rgb(char_u *name)
{
dict_T *colornames_table = get_vim_var_dict(VV_COLORNAMES);
char_u *lc_name;
dictitem_T *colentry;
char_u *colstr;
varnumber_T colnum;
lc_name = strlow_save(name);
if (lc_name == NULL)
return INVALCOLOR;
colentry = dict_find(colornames_table, lc_name, -1);
vim_free(lc_name);
if (colentry == NULL)
return INVALCOLOR;
if (colentry->di_tv.v_type == VAR_STRING)
{
colstr = tv_get_string_strict(&colentry->di_tv);
if ((STRLEN(colstr) == 7) && (*colstr == '#'))
{
return decode_hex_color(colstr);
}
else
{
semsg(_(e_bad_color_string_str), colstr);
return INVALCOLOR;
}
}
if (colentry->di_tv.v_type == VAR_NUMBER)
{
colnum = tv_get_number(&colentry->di_tv);
return (guicolor_T)colnum;
}
return INVALCOLOR;
}
// Maps the given name to the given color value, overwriting any current
// mapping. If allocation fails the named color will no longer exist in the
// table and the user will receive an error message.
void
save_colorname_hexstr(int r, int g, int b, char_u *name)
{
int result;
dict_T *colornames_table;
dictitem_T *existing;
char_u hexstr[8];
if (vim_snprintf((char *)hexstr, sizeof(hexstr),
"#%02x%02x%02x", r, g, b) < 0)
{
semsg(_(e_cannot_allocate_color_str), name);
return;
}
colornames_table = get_vim_var_dict(VV_COLORNAMES);
// The colornames_table dict is safe to use here because it is allocated at
// startup in evalvars.c
existing = dict_find(colornames_table, name, -1);
if (existing != NULL)
{
dictitem_remove(colornames_table, existing);
existing = NULL; // dictitem_remove freed the item
}
result = dict_add_string(colornames_table, (char *)name, hexstr);
if (result == FAIL)
semsg(_(e_cannot_allocate_color_str), name);
}
/*
* Load a default color list. Intended to support legacy color names but allows
* the user to override the color values. Only loaded once.
*/
void
load_default_colors_lists()
{
// Lacking a default color list isn't the end of the world but it is likely
// an inconvenience so users should know when it is missing.
if (source_runtime((char_u *)"colors/lists/default.vim", DIP_ALL) != OK)
msg("failed to load colors/lists/default.vim");
}
#endif
guicolor_T
gui_get_color_cmn(char_u *name)
{
int i;
guicolor_T color;
struct rgbcolor_table_S {
char_u *color_name;
guicolor_T color;
};
// Only non X11 colors (not present in rgb.txt) and colors in
// color_names[], useful when $VIMRUNTIME is not found,.
static struct rgbcolor_table_S rgb_table[] = {
{(char_u *)"black", RGB(0x00, 0x00, 0x00)},
{(char_u *)"blue", RGB(0x00, 0x00, 0xFF)},
{(char_u *)"brown", RGB(0xA5, 0x2A, 0x2A)},
{(char_u *)"cyan", RGB(0x00, 0xFF, 0xFF)},
{(char_u *)"darkblue", RGB(0x00, 0x00, 0x8B)},
{(char_u *)"darkcyan", RGB(0x00, 0x8B, 0x8B)},
{(char_u *)"darkgray", RGB(0xA9, 0xA9, 0xA9)},
{(char_u *)"darkgreen", RGB(0x00, 0x64, 0x00)},
{(char_u *)"darkgrey", RGB(0xA9, 0xA9, 0xA9)},
{(char_u *)"darkmagenta", RGB(0x8B, 0x00, 0x8B)},
{(char_u *)"darkred", RGB(0x8B, 0x00, 0x00)},
{(char_u *)"darkyellow", RGB(0x8B, 0x8B, 0x00)}, // No X11
{(char_u *)"gray", RGB(0xBE, 0xBE, 0xBE)},
{(char_u *)"green", RGB(0x00, 0xFF, 0x00)},
{(char_u *)"grey", RGB(0xBE, 0xBE, 0xBE)},
{(char_u *)"grey40", RGB(0x66, 0x66, 0x66)},
{(char_u *)"grey50", RGB(0x7F, 0x7F, 0x7F)},
{(char_u *)"grey90", RGB(0xE5, 0xE5, 0xE5)},
{(char_u *)"lightblue", RGB(0xAD, 0xD8, 0xE6)},
{(char_u *)"lightcyan", RGB(0xE0, 0xFF, 0xFF)},
{(char_u *)"lightgray", RGB(0xD3, 0xD3, 0xD3)},
{(char_u *)"lightgreen", RGB(0x90, 0xEE, 0x90)},
{(char_u *)"lightgrey", RGB(0xD3, 0xD3, 0xD3)},
{(char_u *)"lightmagenta", RGB(0xFF, 0x8B, 0xFF)}, // No X11
{(char_u *)"lightred", RGB(0xFF, 0x8B, 0x8B)}, // No X11
{(char_u *)"lightyellow", RGB(0xFF, 0xFF, 0xE0)},
{(char_u *)"magenta", RGB(0xFF, 0x00, 0xFF)},
{(char_u *)"red", RGB(0xFF, 0x00, 0x00)},
{(char_u *)"seagreen", RGB(0x2E, 0x8B, 0x57)},
{(char_u *)"white", RGB(0xFF, 0xFF, 0xFF)},
{(char_u *)"yellow", RGB(0xFF, 0xFF, 0x00)},
};
color = decode_hex_color(name);
if (color != INVALCOLOR)
return color;
// Check if the name is one of the colors we know
for (i = 0; i < (int)ARRAY_LENGTH(rgb_table); i++)
if (STRICMP(name, rgb_table[i].color_name) == 0)
return gui_adjust_rgb(rgb_table[i].color);
#if defined(FEAT_EVAL)
/*
* Not a traditional color. Load additional color aliases and then consult the alias table.
*/
color = colorname2rgb(name);
if (color == INVALCOLOR)
{
load_default_colors_lists();
color = colorname2rgb(name);
}
return color;
#else
return INVALCOLOR;
#endif
}
guicolor_T
gui_get_rgb_color_cmn(int r, int g, int b)
{
guicolor_T color = RGB(r, g, b);
if (color > 0xffffff)
return INVALCOLOR;
return gui_adjust_rgb(color);
}
#endif
/*

View File

@ -559,7 +559,7 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
{
if (called_emsg_before == called_emsg)
// may not get the error if the GUI didn't start
semsg(_(e_alloc_color), color_name);
semsg(_(e_cannot_allocate_color_str), color_name);
return FAIL;
}

View File

@ -14,6 +14,12 @@ void hl_set_font_name(char_u *font_name);
void hl_set_bg_color_name(char_u *name);
void hl_set_fg_color_name(char_u *name);
guicolor_T color_name2handle(char_u *name);
guicolor_T decode_hex_color(char_u *hex);
guicolor_T colorname2rgb(char_u *name);
void save_colorname_hexstr(int r, int g, int b, char_u *name);
void load_default_colors_lists(void);
guicolor_T gui_get_color_cmn(char_u *name);
guicolor_T gui_get_rgb_color_cmn(int r, int g, int b);
int get_cterm_attr_idx(int attr, int fg, int bg);
int get_tgc_attr_idx(int attr, guicolor_T fg, guicolor_T bg);
int get_gui_attr_idx(int attr, guicolor_T fg, guicolor_T bg);

View File

@ -83,8 +83,6 @@ void show_termcodes(void);
int show_one_termcode(char_u *name, char_u *code, int printit);
void update_tcap(int attr);
void swap_tcap(void);
guicolor_T gui_get_color_cmn(char_u *name);
guicolor_T gui_get_rgb_color_cmn(int r, int g, int b);
void cterm_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx);
void term_replace_bs_del_keycode(char_u *ta_buf, int ta_len, int len);
/* vim: set ft=c : */

View File

@ -1353,7 +1353,7 @@ termgui_get_color(char_u *name)
t = termgui_mch_get_color(name);
if (t == INVALCOLOR)
semsg(_(e_alloc_color), name);
semsg(_(e_cannot_allocate_color_str), name);
return t;
}
@ -6630,203 +6630,6 @@ swap_tcap(void)
#endif
#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) || defined(PROTO)
static int
hex_digit(int c)
{
if (isdigit(c))
return c - '0';
c = TOLOWER_ASC(c);
if (c >= 'a' && c <= 'f')
return c - 'a' + 10;
return 0x1ffffff;
}
# ifdef VIMDLL
static guicolor_T
gui_adjust_rgb(guicolor_T c)
{
if (gui.in_use)
return c;
else
return ((c & 0xff) << 16) | (c & 0x00ff00) | ((c >> 16) & 0xff);
}
# else
# define gui_adjust_rgb(c) (c)
# endif
guicolor_T
gui_get_color_cmn(char_u *name)
{
// On MS-Windows an RGB macro is available and it produces 0x00bbggrr color
// values as used by the MS-Windows GDI api. It should be used only for
// MS-Windows GDI builds.
# if defined(RGB) && defined(MSWIN) && !defined(FEAT_GUI)
# undef RGB
# endif
# ifndef RGB
# define RGB(r, g, b) ((r<<16) | (g<<8) | (b))
# endif
# define LINE_LEN 100
FILE *fd;
char line[LINE_LEN];
char_u *fname;
int r, g, b, i;
guicolor_T color;
struct rgbcolor_table_S {
char_u *color_name;
guicolor_T color;
};
// Only non X11 colors (not present in rgb.txt) and colors in
// color_names[], useful when $VIMRUNTIME is not found,.
static struct rgbcolor_table_S rgb_table[] = {
{(char_u *)"black", RGB(0x00, 0x00, 0x00)},
{(char_u *)"blue", RGB(0x00, 0x00, 0xFF)},
{(char_u *)"brown", RGB(0xA5, 0x2A, 0x2A)},
{(char_u *)"cyan", RGB(0x00, 0xFF, 0xFF)},
{(char_u *)"darkblue", RGB(0x00, 0x00, 0x8B)},
{(char_u *)"darkcyan", RGB(0x00, 0x8B, 0x8B)},
{(char_u *)"darkgray", RGB(0xA9, 0xA9, 0xA9)},
{(char_u *)"darkgreen", RGB(0x00, 0x64, 0x00)},
{(char_u *)"darkgrey", RGB(0xA9, 0xA9, 0xA9)},
{(char_u *)"darkmagenta", RGB(0x8B, 0x00, 0x8B)},
{(char_u *)"darkred", RGB(0x8B, 0x00, 0x00)},
{(char_u *)"darkyellow", RGB(0x8B, 0x8B, 0x00)}, // No X11
{(char_u *)"gray", RGB(0xBE, 0xBE, 0xBE)},
{(char_u *)"green", RGB(0x00, 0xFF, 0x00)},
{(char_u *)"grey", RGB(0xBE, 0xBE, 0xBE)},
{(char_u *)"grey40", RGB(0x66, 0x66, 0x66)},
{(char_u *)"grey50", RGB(0x7F, 0x7F, 0x7F)},
{(char_u *)"grey90", RGB(0xE5, 0xE5, 0xE5)},
{(char_u *)"lightblue", RGB(0xAD, 0xD8, 0xE6)},
{(char_u *)"lightcyan", RGB(0xE0, 0xFF, 0xFF)},
{(char_u *)"lightgray", RGB(0xD3, 0xD3, 0xD3)},
{(char_u *)"lightgreen", RGB(0x90, 0xEE, 0x90)},
{(char_u *)"lightgrey", RGB(0xD3, 0xD3, 0xD3)},
{(char_u *)"lightmagenta", RGB(0xFF, 0x8B, 0xFF)}, // No X11
{(char_u *)"lightred", RGB(0xFF, 0x8B, 0x8B)}, // No X11
{(char_u *)"lightyellow", RGB(0xFF, 0xFF, 0xE0)},
{(char_u *)"magenta", RGB(0xFF, 0x00, 0xFF)},
{(char_u *)"red", RGB(0xFF, 0x00, 0x00)},
{(char_u *)"seagreen", RGB(0x2E, 0x8B, 0x57)},
{(char_u *)"white", RGB(0xFF, 0xFF, 0xFF)},
{(char_u *)"yellow", RGB(0xFF, 0xFF, 0x00)},
};
static struct rgbcolor_table_S *colornames_table;
static int size = 0;
if (name[0] == '#' && STRLEN(name) == 7)
{
// Name is in "#rrggbb" format
color = RGB(((hex_digit(name[1]) << 4) + hex_digit(name[2])),
((hex_digit(name[3]) << 4) + hex_digit(name[4])),
((hex_digit(name[5]) << 4) + hex_digit(name[6])));
if (color > 0xffffff)
return INVALCOLOR;
return gui_adjust_rgb(color);
}
// Check if the name is one of the colors we know
for (i = 0; i < (int)ARRAY_LENGTH(rgb_table); i++)
if (STRICMP(name, rgb_table[i].color_name) == 0)
return gui_adjust_rgb(rgb_table[i].color);
/*
* Last attempt. Look in the file "$VIMRUNTIME/rgb.txt".
*/
if (size == 0)
{
int counting;
// colornames_table not yet initialized
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)
{
if (p_verbose > 1)
verb_msg(_("Cannot open $VIMRUNTIME/rgb.txt"));
size = -1; // don't try again
return INVALCOLOR;
}
for (counting = 1; counting >= 0; --counting)
{
if (!counting)
{
colornames_table = ALLOC_MULT(struct rgbcolor_table_S, size);
if (colornames_table == NULL)
{
fclose(fd);
return INVALCOLOR;
}
rewind(fd);
}
size = 0;
while (!feof(fd))
{
size_t len;
int pos;
vim_ignoredp = fgets(line, LINE_LEN, fd);
len = strlen(line);
if (len <= 1 || line[len - 1] != '\n')
continue;
line[len - 1] = '\0';
i = sscanf(line, "%d %d %d %n", &r, &g, &b, &pos);
if (i != 3)
continue;
if (!counting)
{
char_u *s = vim_strsave((char_u *)line + pos);
if (s == NULL)
{
fclose(fd);
return INVALCOLOR;
}
colornames_table[size].color_name = s;
colornames_table[size].color = (guicolor_T)RGB(r, g, b);
}
size++;
// The distributed rgb.txt has less than 1000 entries. Limit to
// 10000, just in case the file was messed up.
if (size == 10000)
break;
}
}
fclose(fd);
}
for (i = 0; i < size; i++)
if (STRICMP(name, colornames_table[i].color_name) == 0)
return gui_adjust_rgb(colornames_table[i].color);
return INVALCOLOR;
}
guicolor_T
gui_get_rgb_color_cmn(int r, int g, int b)
{
guicolor_T color = RGB(r, g, b);
if (color > 0xffffff)
return INVALCOLOR;
return gui_adjust_rgb(color);
}
#endif
#if (defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))) || defined(FEAT_TERMINAL) \
|| defined(PROTO)

View File

@ -934,4 +934,40 @@ func Test_highlight_default_colorscheme_restores_links()
hi clear
endfunc
func Test_colornames_assignment_and_lookup()
" Ensure highlight command can find custom color.
let v:colornames['a redish white'] = '#ffeedd'
highlight Normal guifg='a redish white'
highlight clear
endfunc
func Test_colornames_default_list()
" Ensure default lists are loaded automatically and can be used for all gui fields.
highlight Normal guifg='rebecca purple' guibg='rebecca purple' guisp='rebecca purple'
highlight clear
endfunc
func Test_colornames_overwrite_default()
" Ensure entries in v:colornames can be overwritten.
" Load default color scheme to trigger default color list loading.
colorscheme default
let old_rebecca_purple = v:colornames['rebecca purple']
highlight Normal guifg='rebecca purple' guibg='rebecca purple'
let v:colornames['rebecca purple'] = '#550099'
highlight Normal guifg='rebecca purple' guibg='rebecca purple'
let v:colornames['rebecca purple'] = old_rebecca_purple
highlight clear
endfunc
func Test_colornames_assignment_and_unassignment()
" Ensure we cannot overwrite the v:colornames dict.
call assert_fails("let v:colornames = {}", 'E46:')
" Ensure we can delete entries from the v:colornames dict.
let v:colornames['x1'] = '#111111'
call assert_equal(v:colornames['x1'], '#111111')
unlet v:colornames['x1']
call assert_fails("echo v:colornames['x1']")
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -757,6 +757,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3562,
/**/
3561,
/**/

View File

@ -2044,7 +2044,8 @@ typedef int sock_T;
#define VV_ARGV 96
#define VV_COLLATE 97
#define VV_EXITING 98
#define VV_LEN 99 // number of v: vars
#define VV_COLORNAMES 99
#define VV_LEN 100 // number of v: vars
// used for v_number in VAR_BOOL and VAR_SPECIAL
#define VVAL_FALSE 0L // VAR_BOOL