Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Version 3.50

Fix a major regression that prevented the Eterm and Konsole colors from being correctly snapshotted

Fix a related bug causing incorrect terminal colors after calling :CSApproxSnapshot

Fix a bug causing black to be used instead of dark grey

Have snapshots calculate g:colors_name programmatically

Introduce many tweaks for better speed

Clarify some things at :help csapprox-terminal-example

Default to using our own list of rgb.txt colors rather than searching, for performance.  Add a new variable, g:CSApprox_use_showrgb, which forces us to try finding the colors using the "showrgb" program instead, and fall back on our own list if it isn't available

Remove g:CSApprox_extra_rgb_txt_dirs - not needed in light of the above change
  • Loading branch information...
commit ce2b1fda9f901da183e99936abb446cd9ab00c3c 1 parent a7e0d0c
Matt Wozniski authored committed
Showing with 1,161 additions and 964 deletions.
  1. +810 −0 autoload/csapprox.vim
  2. +110 −65 doc/CSApprox.txt
  3. +0 −752 doc/rgb.txt
  4. +241 −147 plugin/CSApprox.vim
View
810 autoload/csapprox.vim
@@ -0,0 +1,810 @@
+let s:rgb = {}
+
+let s:rgb["alice blue"] = "#f0f8ff"
+let s:rgb["aliceblue"] = "#f0f8ff"
+let s:rgb["antique white"] = "#faebd7"
+let s:rgb["antiquewhite"] = "#faebd7"
+let s:rgb["antiquewhite1"] = "#ffefdb"
+let s:rgb["antiquewhite2"] = "#eedfcc"
+let s:rgb["antiquewhite3"] = "#cdc0b0"
+let s:rgb["antiquewhite4"] = "#8b8378"
+let s:rgb["aquamarine"] = "#7fffd4"
+let s:rgb["aquamarine1"] = "#7fffd4"
+let s:rgb["aquamarine2"] = "#76eec6"
+let s:rgb["aquamarine3"] = "#66cdaa"
+let s:rgb["aquamarine4"] = "#458b74"
+let s:rgb["azure"] = "#f0ffff"
+let s:rgb["azure1"] = "#f0ffff"
+let s:rgb["azure2"] = "#e0eeee"
+let s:rgb["azure3"] = "#c1cdcd"
+let s:rgb["azure4"] = "#838b8b"
+let s:rgb["beige"] = "#f5f5dc"
+let s:rgb["bisque"] = "#ffe4c4"
+let s:rgb["bisque1"] = "#ffe4c4"
+let s:rgb["bisque2"] = "#eed5b7"
+let s:rgb["bisque3"] = "#cdb79e"
+let s:rgb["bisque4"] = "#8b7d6b"
+let s:rgb["black"] = "#000000"
+let s:rgb["blanched almond"] = "#ffebcd"
+let s:rgb["blanchedalmond"] = "#ffebcd"
+let s:rgb["blue violet"] = "#8a2be2"
+let s:rgb["blue"] = "#0000ff"
+let s:rgb["blue1"] = "#0000ff"
+let s:rgb["blue2"] = "#0000ee"
+let s:rgb["blue3"] = "#0000cd"
+let s:rgb["blue4"] = "#00008b"
+let s:rgb["blueviolet"] = "#8a2be2"
+let s:rgb["brown"] = "#a52a2a"
+let s:rgb["brown1"] = "#ff4040"
+let s:rgb["brown2"] = "#ee3b3b"
+let s:rgb["brown3"] = "#cd3333"
+let s:rgb["brown4"] = "#8b2323"
+let s:rgb["burlywood"] = "#deb887"
+let s:rgb["burlywood1"] = "#ffd39b"
+let s:rgb["burlywood2"] = "#eec591"
+let s:rgb["burlywood3"] = "#cdaa7d"
+let s:rgb["burlywood4"] = "#8b7355"
+let s:rgb["cadet blue"] = "#5f9ea0"
+let s:rgb["cadetblue"] = "#5f9ea0"
+let s:rgb["cadetblue1"] = "#98f5ff"
+let s:rgb["cadetblue2"] = "#8ee5ee"
+let s:rgb["cadetblue3"] = "#7ac5cd"
+let s:rgb["cadetblue4"] = "#53868b"
+let s:rgb["chartreuse"] = "#7fff00"
+let s:rgb["chartreuse1"] = "#7fff00"
+let s:rgb["chartreuse2"] = "#76ee00"
+let s:rgb["chartreuse3"] = "#66cd00"
+let s:rgb["chartreuse4"] = "#458b00"
+let s:rgb["chocolate"] = "#d2691e"
+let s:rgb["chocolate1"] = "#ff7f24"
+let s:rgb["chocolate2"] = "#ee7621"
+let s:rgb["chocolate3"] = "#cd661d"
+let s:rgb["chocolate4"] = "#8b4513"
+let s:rgb["coral"] = "#ff7f50"
+let s:rgb["coral1"] = "#ff7256"
+let s:rgb["coral2"] = "#ee6a50"
+let s:rgb["coral3"] = "#cd5b45"
+let s:rgb["coral4"] = "#8b3e2f"
+let s:rgb["cornflower blue"] = "#6495ed"
+let s:rgb["cornflowerblue"] = "#6495ed"
+let s:rgb["cornsilk"] = "#fff8dc"
+let s:rgb["cornsilk1"] = "#fff8dc"
+let s:rgb["cornsilk2"] = "#eee8cd"
+let s:rgb["cornsilk3"] = "#cdc8b1"
+let s:rgb["cornsilk4"] = "#8b8878"
+let s:rgb["cyan"] = "#00ffff"
+let s:rgb["cyan1"] = "#00ffff"
+let s:rgb["cyan2"] = "#00eeee"
+let s:rgb["cyan3"] = "#00cdcd"
+let s:rgb["cyan4"] = "#008b8b"
+let s:rgb["dark blue"] = "#00008b"
+let s:rgb["dark cyan"] = "#008b8b"
+let s:rgb["dark goldenrod"] = "#b8860b"
+let s:rgb["dark gray"] = "#a9a9a9"
+let s:rgb["dark green"] = "#006400"
+let s:rgb["dark grey"] = "#a9a9a9"
+let s:rgb["dark khaki"] = "#bdb76b"
+let s:rgb["dark magenta"] = "#8b008b"
+let s:rgb["dark olive green"] = "#556b2f"
+let s:rgb["dark orange"] = "#ff8c00"
+let s:rgb["dark orchid"] = "#9932cc"
+let s:rgb["dark red"] = "#8b0000"
+let s:rgb["dark salmon"] = "#e9967a"
+let s:rgb["dark sea green"] = "#8fbc8f"
+let s:rgb["dark slate blue"] = "#483d8b"
+let s:rgb["dark slate gray"] = "#2f4f4f"
+let s:rgb["dark slate grey"] = "#2f4f4f"
+let s:rgb["dark turquoise"] = "#00ced1"
+let s:rgb["dark violet"] = "#9400d3"
+let s:rgb["dark yellow"] = "#bbbb00"
+let s:rgb["darkblue"] = "#00008b"
+let s:rgb["darkcyan"] = "#008b8b"
+let s:rgb["darkgoldenrod"] = "#b8860b"
+let s:rgb["darkgoldenrod1"] = "#ffb90f"
+let s:rgb["darkgoldenrod2"] = "#eead0e"
+let s:rgb["darkgoldenrod3"] = "#cd950c"
+let s:rgb["darkgoldenrod4"] = "#8b6508"
+let s:rgb["darkgray"] = "#a9a9a9"
+let s:rgb["darkgreen"] = "#006400"
+let s:rgb["darkgrey"] = "#a9a9a9"
+let s:rgb["darkkhaki"] = "#bdb76b"
+let s:rgb["darkmagenta"] = "#8b008b"
+let s:rgb["darkolivegreen"] = "#556b2f"
+let s:rgb["darkolivegreen1"] = "#caff70"
+let s:rgb["darkolivegreen2"] = "#bcee68"
+let s:rgb["darkolivegreen3"] = "#a2cd5a"
+let s:rgb["darkolivegreen4"] = "#6e8b3d"
+let s:rgb["darkorange"] = "#ff8c00"
+let s:rgb["darkorange1"] = "#ff7f00"
+let s:rgb["darkorange2"] = "#ee7600"
+let s:rgb["darkorange3"] = "#cd6600"
+let s:rgb["darkorange4"] = "#8b4500"
+let s:rgb["darkorchid"] = "#9932cc"
+let s:rgb["darkorchid1"] = "#bf3eff"
+let s:rgb["darkorchid2"] = "#b23aee"
+let s:rgb["darkorchid3"] = "#9a32cd"
+let s:rgb["darkorchid4"] = "#68228b"
+let s:rgb["darkred"] = "#8b0000"
+let s:rgb["darksalmon"] = "#e9967a"
+let s:rgb["darkseagreen"] = "#8fbc8f"
+let s:rgb["darkseagreen1"] = "#c1ffc1"
+let s:rgb["darkseagreen2"] = "#b4eeb4"
+let s:rgb["darkseagreen3"] = "#9bcd9b"
+let s:rgb["darkseagreen4"] = "#698b69"
+let s:rgb["darkslateblue"] = "#483d8b"
+let s:rgb["darkslategray"] = "#2f4f4f"
+let s:rgb["darkslategray1"] = "#97ffff"
+let s:rgb["darkslategray2"] = "#8deeee"
+let s:rgb["darkslategray3"] = "#79cdcd"
+let s:rgb["darkslategray4"] = "#528b8b"
+let s:rgb["darkslategrey"] = "#2f4f4f"
+let s:rgb["darkturquoise"] = "#00ced1"
+let s:rgb["darkviolet"] = "#9400d3"
+let s:rgb["darkyellow"] = "#bbbb00"
+let s:rgb["deep pink"] = "#ff1493"
+let s:rgb["deep sky blue"] = "#00bfff"
+let s:rgb["deeppink"] = "#ff1493"
+let s:rgb["deeppink1"] = "#ff1493"
+let s:rgb["deeppink2"] = "#ee1289"
+let s:rgb["deeppink3"] = "#cd1076"
+let s:rgb["deeppink4"] = "#8b0a50"
+let s:rgb["deepskyblue"] = "#00bfff"
+let s:rgb["deepskyblue1"] = "#00bfff"
+let s:rgb["deepskyblue2"] = "#00b2ee"
+let s:rgb["deepskyblue3"] = "#009acd"
+let s:rgb["deepskyblue4"] = "#00688b"
+let s:rgb["dim gray"] = "#696969"
+let s:rgb["dim grey"] = "#696969"
+let s:rgb["dimgray"] = "#696969"
+let s:rgb["dimgrey"] = "#696969"
+let s:rgb["dodger blue"] = "#1e90ff"
+let s:rgb["dodgerblue"] = "#1e90ff"
+let s:rgb["dodgerblue1"] = "#1e90ff"
+let s:rgb["dodgerblue2"] = "#1c86ee"
+let s:rgb["dodgerblue3"] = "#1874cd"
+let s:rgb["dodgerblue4"] = "#104e8b"
+let s:rgb["firebrick"] = "#b22222"
+let s:rgb["firebrick1"] = "#ff3030"
+let s:rgb["firebrick2"] = "#ee2c2c"
+let s:rgb["firebrick3"] = "#cd2626"
+let s:rgb["firebrick4"] = "#8b1a1a"
+let s:rgb["floral white"] = "#fffaf0"
+let s:rgb["floralwhite"] = "#fffaf0"
+let s:rgb["forest green"] = "#228b22"
+let s:rgb["forestgreen"] = "#228b22"
+let s:rgb["gainsboro"] = "#dcdcdc"
+let s:rgb["ghost white"] = "#f8f8ff"
+let s:rgb["ghostwhite"] = "#f8f8ff"
+let s:rgb["gold"] = "#ffd700"
+let s:rgb["gold1"] = "#ffd700"
+let s:rgb["gold2"] = "#eec900"
+let s:rgb["gold3"] = "#cdad00"
+let s:rgb["gold4"] = "#8b7500"
+let s:rgb["goldenrod"] = "#daa520"
+let s:rgb["goldenrod1"] = "#ffc125"
+let s:rgb["goldenrod2"] = "#eeb422"
+let s:rgb["goldenrod3"] = "#cd9b1d"
+let s:rgb["goldenrod4"] = "#8b6914"
+let s:rgb["gray"] = "#bebebe"
+let s:rgb["gray0"] = "#000000"
+let s:rgb["gray1"] = "#030303"
+let s:rgb["gray10"] = "#1a1a1a"
+let s:rgb["gray100"] = "#ffffff"
+let s:rgb["gray11"] = "#1c1c1c"
+let s:rgb["gray12"] = "#1f1f1f"
+let s:rgb["gray13"] = "#212121"
+let s:rgb["gray14"] = "#242424"
+let s:rgb["gray15"] = "#262626"
+let s:rgb["gray16"] = "#292929"
+let s:rgb["gray17"] = "#2b2b2b"
+let s:rgb["gray18"] = "#2e2e2e"
+let s:rgb["gray19"] = "#303030"
+let s:rgb["gray2"] = "#050505"
+let s:rgb["gray20"] = "#333333"
+let s:rgb["gray21"] = "#363636"
+let s:rgb["gray22"] = "#383838"
+let s:rgb["gray23"] = "#3b3b3b"
+let s:rgb["gray24"] = "#3d3d3d"
+let s:rgb["gray25"] = "#404040"
+let s:rgb["gray26"] = "#424242"
+let s:rgb["gray27"] = "#454545"
+let s:rgb["gray28"] = "#474747"
+let s:rgb["gray29"] = "#4a4a4a"
+let s:rgb["gray3"] = "#080808"
+let s:rgb["gray30"] = "#4d4d4d"
+let s:rgb["gray31"] = "#4f4f4f"
+let s:rgb["gray32"] = "#525252"
+let s:rgb["gray33"] = "#545454"
+let s:rgb["gray34"] = "#575757"
+let s:rgb["gray35"] = "#595959"
+let s:rgb["gray36"] = "#5c5c5c"
+let s:rgb["gray37"] = "#5e5e5e"
+let s:rgb["gray38"] = "#616161"
+let s:rgb["gray39"] = "#636363"
+let s:rgb["gray4"] = "#0a0a0a"
+let s:rgb["gray40"] = "#666666"
+let s:rgb["gray41"] = "#696969"
+let s:rgb["gray42"] = "#6b6b6b"
+let s:rgb["gray43"] = "#6e6e6e"
+let s:rgb["gray44"] = "#707070"
+let s:rgb["gray45"] = "#737373"
+let s:rgb["gray46"] = "#757575"
+let s:rgb["gray47"] = "#787878"
+let s:rgb["gray48"] = "#7a7a7a"
+let s:rgb["gray49"] = "#7d7d7d"
+let s:rgb["gray5"] = "#0d0d0d"
+let s:rgb["gray50"] = "#7f7f7f"
+let s:rgb["gray51"] = "#828282"
+let s:rgb["gray52"] = "#858585"
+let s:rgb["gray53"] = "#878787"
+let s:rgb["gray54"] = "#8a8a8a"
+let s:rgb["gray55"] = "#8c8c8c"
+let s:rgb["gray56"] = "#8f8f8f"
+let s:rgb["gray57"] = "#919191"
+let s:rgb["gray58"] = "#949494"
+let s:rgb["gray59"] = "#969696"
+let s:rgb["gray6"] = "#0f0f0f"
+let s:rgb["gray60"] = "#999999"
+let s:rgb["gray61"] = "#9c9c9c"
+let s:rgb["gray62"] = "#9e9e9e"
+let s:rgb["gray63"] = "#a1a1a1"
+let s:rgb["gray64"] = "#a3a3a3"
+let s:rgb["gray65"] = "#a6a6a6"
+let s:rgb["gray66"] = "#a8a8a8"
+let s:rgb["gray67"] = "#ababab"
+let s:rgb["gray68"] = "#adadad"
+let s:rgb["gray69"] = "#b0b0b0"
+let s:rgb["gray7"] = "#121212"
+let s:rgb["gray70"] = "#b3b3b3"
+let s:rgb["gray71"] = "#b5b5b5"
+let s:rgb["gray72"] = "#b8b8b8"
+let s:rgb["gray73"] = "#bababa"
+let s:rgb["gray74"] = "#bdbdbd"
+let s:rgb["gray75"] = "#bfbfbf"
+let s:rgb["gray76"] = "#c2c2c2"
+let s:rgb["gray77"] = "#c4c4c4"
+let s:rgb["gray78"] = "#c7c7c7"
+let s:rgb["gray79"] = "#c9c9c9"
+let s:rgb["gray8"] = "#141414"
+let s:rgb["gray80"] = "#cccccc"
+let s:rgb["gray81"] = "#cfcfcf"
+let s:rgb["gray82"] = "#d1d1d1"
+let s:rgb["gray83"] = "#d4d4d4"
+let s:rgb["gray84"] = "#d6d6d6"
+let s:rgb["gray85"] = "#d9d9d9"
+let s:rgb["gray86"] = "#dbdbdb"
+let s:rgb["gray87"] = "#dedede"
+let s:rgb["gray88"] = "#e0e0e0"
+let s:rgb["gray89"] = "#e3e3e3"
+let s:rgb["gray9"] = "#171717"
+let s:rgb["gray90"] = "#e5e5e5"
+let s:rgb["gray91"] = "#e8e8e8"
+let s:rgb["gray92"] = "#ebebeb"
+let s:rgb["gray93"] = "#ededed"
+let s:rgb["gray94"] = "#f0f0f0"
+let s:rgb["gray95"] = "#f2f2f2"
+let s:rgb["gray96"] = "#f5f5f5"
+let s:rgb["gray97"] = "#f7f7f7"
+let s:rgb["gray98"] = "#fafafa"
+let s:rgb["gray99"] = "#fcfcfc"
+let s:rgb["green yellow"] = "#adff2f"
+let s:rgb["green"] = "#00ff00"
+let s:rgb["green1"] = "#00ff00"
+let s:rgb["green2"] = "#00ee00"
+let s:rgb["green3"] = "#00cd00"
+let s:rgb["green4"] = "#008b00"
+let s:rgb["greenyellow"] = "#adff2f"
+let s:rgb["grey"] = "#bebebe"
+let s:rgb["grey0"] = "#000000"
+let s:rgb["grey1"] = "#030303"
+let s:rgb["grey10"] = "#1a1a1a"
+let s:rgb["grey100"] = "#ffffff"
+let s:rgb["grey11"] = "#1c1c1c"
+let s:rgb["grey12"] = "#1f1f1f"
+let s:rgb["grey13"] = "#212121"
+let s:rgb["grey14"] = "#242424"
+let s:rgb["grey15"] = "#262626"
+let s:rgb["grey16"] = "#292929"
+let s:rgb["grey17"] = "#2b2b2b"
+let s:rgb["grey18"] = "#2e2e2e"
+let s:rgb["grey19"] = "#303030"
+let s:rgb["grey2"] = "#050505"
+let s:rgb["grey20"] = "#333333"
+let s:rgb["grey21"] = "#363636"
+let s:rgb["grey22"] = "#383838"
+let s:rgb["grey23"] = "#3b3b3b"
+let s:rgb["grey24"] = "#3d3d3d"
+let s:rgb["grey25"] = "#404040"
+let s:rgb["grey26"] = "#424242"
+let s:rgb["grey27"] = "#454545"
+let s:rgb["grey28"] = "#474747"
+let s:rgb["grey29"] = "#4a4a4a"
+let s:rgb["grey3"] = "#080808"
+let s:rgb["grey30"] = "#4d4d4d"
+let s:rgb["grey31"] = "#4f4f4f"
+let s:rgb["grey32"] = "#525252"
+let s:rgb["grey33"] = "#545454"
+let s:rgb["grey34"] = "#575757"
+let s:rgb["grey35"] = "#595959"
+let s:rgb["grey36"] = "#5c5c5c"
+let s:rgb["grey37"] = "#5e5e5e"
+let s:rgb["grey38"] = "#616161"
+let s:rgb["grey39"] = "#636363"
+let s:rgb["grey4"] = "#0a0a0a"
+let s:rgb["grey40"] = "#666666"
+let s:rgb["grey41"] = "#696969"
+let s:rgb["grey42"] = "#6b6b6b"
+let s:rgb["grey43"] = "#6e6e6e"
+let s:rgb["grey44"] = "#707070"
+let s:rgb["grey45"] = "#737373"
+let s:rgb["grey46"] = "#757575"
+let s:rgb["grey47"] = "#787878"
+let s:rgb["grey48"] = "#7a7a7a"
+let s:rgb["grey49"] = "#7d7d7d"
+let s:rgb["grey5"] = "#0d0d0d"
+let s:rgb["grey50"] = "#7f7f7f"
+let s:rgb["grey51"] = "#828282"
+let s:rgb["grey52"] = "#858585"
+let s:rgb["grey53"] = "#878787"
+let s:rgb["grey54"] = "#8a8a8a"
+let s:rgb["grey55"] = "#8c8c8c"
+let s:rgb["grey56"] = "#8f8f8f"
+let s:rgb["grey57"] = "#919191"
+let s:rgb["grey58"] = "#949494"
+let s:rgb["grey59"] = "#969696"
+let s:rgb["grey6"] = "#0f0f0f"
+let s:rgb["grey60"] = "#999999"
+let s:rgb["grey61"] = "#9c9c9c"
+let s:rgb["grey62"] = "#9e9e9e"
+let s:rgb["grey63"] = "#a1a1a1"
+let s:rgb["grey64"] = "#a3a3a3"
+let s:rgb["grey65"] = "#a6a6a6"
+let s:rgb["grey66"] = "#a8a8a8"
+let s:rgb["grey67"] = "#ababab"
+let s:rgb["grey68"] = "#adadad"
+let s:rgb["grey69"] = "#b0b0b0"
+let s:rgb["grey7"] = "#121212"
+let s:rgb["grey70"] = "#b3b3b3"
+let s:rgb["grey71"] = "#b5b5b5"
+let s:rgb["grey72"] = "#b8b8b8"
+let s:rgb["grey73"] = "#bababa"
+let s:rgb["grey74"] = "#bdbdbd"
+let s:rgb["grey75"] = "#bfbfbf"
+let s:rgb["grey76"] = "#c2c2c2"
+let s:rgb["grey77"] = "#c4c4c4"
+let s:rgb["grey78"] = "#c7c7c7"
+let s:rgb["grey79"] = "#c9c9c9"
+let s:rgb["grey8"] = "#141414"
+let s:rgb["grey80"] = "#cccccc"
+let s:rgb["grey81"] = "#cfcfcf"
+let s:rgb["grey82"] = "#d1d1d1"
+let s:rgb["grey83"] = "#d4d4d4"
+let s:rgb["grey84"] = "#d6d6d6"
+let s:rgb["grey85"] = "#d9d9d9"
+let s:rgb["grey86"] = "#dbdbdb"
+let s:rgb["grey87"] = "#dedede"
+let s:rgb["grey88"] = "#e0e0e0"
+let s:rgb["grey89"] = "#e3e3e3"
+let s:rgb["grey9"] = "#171717"
+let s:rgb["grey90"] = "#e5e5e5"
+let s:rgb["grey91"] = "#e8e8e8"
+let s:rgb["grey92"] = "#ebebeb"
+let s:rgb["grey93"] = "#ededed"
+let s:rgb["grey94"] = "#f0f0f0"
+let s:rgb["grey95"] = "#f2f2f2"
+let s:rgb["grey96"] = "#f5f5f5"
+let s:rgb["grey97"] = "#f7f7f7"
+let s:rgb["grey98"] = "#fafafa"
+let s:rgb["grey99"] = "#fcfcfc"
+let s:rgb["honeydew"] = "#f0fff0"
+let s:rgb["honeydew1"] = "#f0fff0"
+let s:rgb["honeydew2"] = "#e0eee0"
+let s:rgb["honeydew3"] = "#c1cdc1"
+let s:rgb["honeydew4"] = "#838b83"
+let s:rgb["hot pink"] = "#ff69b4"
+let s:rgb["hotpink"] = "#ff69b4"
+let s:rgb["hotpink1"] = "#ff6eb4"
+let s:rgb["hotpink2"] = "#ee6aa7"
+let s:rgb["hotpink3"] = "#cd6090"
+let s:rgb["hotpink4"] = "#8b3a62"
+let s:rgb["indian red"] = "#cd5c5c"
+let s:rgb["indianred"] = "#cd5c5c"
+let s:rgb["indianred1"] = "#ff6a6a"
+let s:rgb["indianred2"] = "#ee6363"
+let s:rgb["indianred3"] = "#cd5555"
+let s:rgb["indianred4"] = "#8b3a3a"
+let s:rgb["ivory"] = "#fffff0"
+let s:rgb["ivory1"] = "#fffff0"
+let s:rgb["ivory2"] = "#eeeee0"
+let s:rgb["ivory3"] = "#cdcdc1"
+let s:rgb["ivory4"] = "#8b8b83"
+let s:rgb["khaki"] = "#f0e68c"
+let s:rgb["khaki1"] = "#fff68f"
+let s:rgb["khaki2"] = "#eee685"
+let s:rgb["khaki3"] = "#cdc673"
+let s:rgb["khaki4"] = "#8b864e"
+let s:rgb["lavender blush"] = "#fff0f5"
+let s:rgb["lavender"] = "#e6e6fa"
+let s:rgb["lavenderblush"] = "#fff0f5"
+let s:rgb["lavenderblush1"] = "#fff0f5"
+let s:rgb["lavenderblush2"] = "#eee0e5"
+let s:rgb["lavenderblush3"] = "#cdc1c5"
+let s:rgb["lavenderblush4"] = "#8b8386"
+let s:rgb["lawn green"] = "#7cfc00"
+let s:rgb["lawngreen"] = "#7cfc00"
+let s:rgb["lemon chiffon"] = "#fffacd"
+let s:rgb["lemonchiffon"] = "#fffacd"
+let s:rgb["lemonchiffon1"] = "#fffacd"
+let s:rgb["lemonchiffon2"] = "#eee9bf"
+let s:rgb["lemonchiffon3"] = "#cdc9a5"
+let s:rgb["lemonchiffon4"] = "#8b8970"
+let s:rgb["light blue"] = "#add8e6"
+let s:rgb["light coral"] = "#f08080"
+let s:rgb["light cyan"] = "#e0ffff"
+let s:rgb["light goldenrod yellow"] = "#fafad2"
+let s:rgb["light goldenrod"] = "#eedd82"
+let s:rgb["light gray"] = "#d3d3d3"
+let s:rgb["light green"] = "#90ee90"
+let s:rgb["light grey"] = "#d3d3d3"
+let s:rgb["light magenta"] = "#ffbbff"
+let s:rgb["light pink"] = "#ffb6c1"
+let s:rgb["light red"] = "#ffbbbb"
+let s:rgb["light salmon"] = "#ffa07a"
+let s:rgb["light sea green"] = "#20b2aa"
+let s:rgb["light sky blue"] = "#87cefa"
+let s:rgb["light slate blue"] = "#8470ff"
+let s:rgb["light slate gray"] = "#778899"
+let s:rgb["light slate grey"] = "#778899"
+let s:rgb["light steel blue"] = "#b0c4de"
+let s:rgb["light yellow"] = "#ffffe0"
+let s:rgb["lightblue"] = "#add8e6"
+let s:rgb["lightblue1"] = "#bfefff"
+let s:rgb["lightblue2"] = "#b2dfee"
+let s:rgb["lightblue3"] = "#9ac0cd"
+let s:rgb["lightblue4"] = "#68838b"
+let s:rgb["lightcoral"] = "#f08080"
+let s:rgb["lightcyan"] = "#e0ffff"
+let s:rgb["lightcyan1"] = "#e0ffff"
+let s:rgb["lightcyan2"] = "#d1eeee"
+let s:rgb["lightcyan3"] = "#b4cdcd"
+let s:rgb["lightcyan4"] = "#7a8b8b"
+let s:rgb["lightgoldenrod"] = "#eedd82"
+let s:rgb["lightgoldenrod1"] = "#ffec8b"
+let s:rgb["lightgoldenrod2"] = "#eedc82"
+let s:rgb["lightgoldenrod3"] = "#cdbe70"
+let s:rgb["lightgoldenrod4"] = "#8b814c"
+let s:rgb["lightgoldenrodyellow"] = "#fafad2"
+let s:rgb["lightgray"] = "#d3d3d3"
+let s:rgb["lightgreen"] = "#90ee90"
+let s:rgb["lightgrey"] = "#d3d3d3"
+let s:rgb["lightmagenta"] = "#ffbbff"
+let s:rgb["lightpink"] = "#ffb6c1"
+let s:rgb["lightpink1"] = "#ffaeb9"
+let s:rgb["lightpink2"] = "#eea2ad"
+let s:rgb["lightpink3"] = "#cd8c95"
+let s:rgb["lightpink4"] = "#8b5f65"
+let s:rgb["lightred"] = "#ffbbbb"
+let s:rgb["lightsalmon"] = "#ffa07a"
+let s:rgb["lightsalmon1"] = "#ffa07a"
+let s:rgb["lightsalmon2"] = "#ee9572"
+let s:rgb["lightsalmon3"] = "#cd8162"
+let s:rgb["lightsalmon4"] = "#8b5742"
+let s:rgb["lightseagreen"] = "#20b2aa"
+let s:rgb["lightskyblue"] = "#87cefa"
+let s:rgb["lightskyblue1"] = "#b0e2ff"
+let s:rgb["lightskyblue2"] = "#a4d3ee"
+let s:rgb["lightskyblue3"] = "#8db6cd"
+let s:rgb["lightskyblue4"] = "#607b8b"
+let s:rgb["lightslateblue"] = "#8470ff"
+let s:rgb["lightslategray"] = "#778899"
+let s:rgb["lightslategrey"] = "#778899"
+let s:rgb["lightsteelblue"] = "#b0c4de"
+let s:rgb["lightsteelblue1"] = "#cae1ff"
+let s:rgb["lightsteelblue2"] = "#bcd2ee"
+let s:rgb["lightsteelblue3"] = "#a2b5cd"
+let s:rgb["lightsteelblue4"] = "#6e7b8b"
+let s:rgb["lightyellow"] = "#ffffe0"
+let s:rgb["lightyellow1"] = "#ffffe0"
+let s:rgb["lightyellow2"] = "#eeeed1"
+let s:rgb["lightyellow3"] = "#cdcdb4"
+let s:rgb["lightyellow4"] = "#8b8b7a"
+let s:rgb["lime green"] = "#32cd32"
+let s:rgb["limegreen"] = "#32cd32"
+let s:rgb["linen"] = "#faf0e6"
+let s:rgb["magenta"] = "#ff00ff"
+let s:rgb["magenta1"] = "#ff00ff"
+let s:rgb["magenta2"] = "#ee00ee"
+let s:rgb["magenta3"] = "#cd00cd"
+let s:rgb["magenta4"] = "#8b008b"
+let s:rgb["maroon"] = "#b03060"
+let s:rgb["maroon1"] = "#ff34b3"
+let s:rgb["maroon2"] = "#ee30a7"
+let s:rgb["maroon3"] = "#cd2990"
+let s:rgb["maroon4"] = "#8b1c62"
+let s:rgb["medium aquamarine"] = "#66cdaa"
+let s:rgb["medium blue"] = "#0000cd"
+let s:rgb["medium orchid"] = "#ba55d3"
+let s:rgb["medium purple"] = "#9370db"
+let s:rgb["medium sea green"] = "#3cb371"
+let s:rgb["medium slate blue"] = "#7b68ee"
+let s:rgb["medium spring green"] = "#00fa9a"
+let s:rgb["medium turquoise"] = "#48d1cc"
+let s:rgb["medium violet red"] = "#c71585"
+let s:rgb["mediumaquamarine"] = "#66cdaa"
+let s:rgb["mediumblue"] = "#0000cd"
+let s:rgb["mediumorchid"] = "#ba55d3"
+let s:rgb["mediumorchid1"] = "#e066ff"
+let s:rgb["mediumorchid2"] = "#d15fee"
+let s:rgb["mediumorchid3"] = "#b452cd"
+let s:rgb["mediumorchid4"] = "#7a378b"
+let s:rgb["mediumpurple"] = "#9370db"
+let s:rgb["mediumpurple1"] = "#ab82ff"
+let s:rgb["mediumpurple2"] = "#9f79ee"
+let s:rgb["mediumpurple3"] = "#8968cd"
+let s:rgb["mediumpurple4"] = "#5d478b"
+let s:rgb["mediumseagreen"] = "#3cb371"
+let s:rgb["mediumslateblue"] = "#7b68ee"
+let s:rgb["mediumspringgreen"] = "#00fa9a"
+let s:rgb["mediumturquoise"] = "#48d1cc"
+let s:rgb["mediumvioletred"] = "#c71585"
+let s:rgb["midnight blue"] = "#191970"
+let s:rgb["midnightblue"] = "#191970"
+let s:rgb["mint cream"] = "#f5fffa"
+let s:rgb["mintcream"] = "#f5fffa"
+let s:rgb["misty rose"] = "#ffe4e1"
+let s:rgb["mistyrose"] = "#ffe4e1"
+let s:rgb["mistyrose1"] = "#ffe4e1"
+let s:rgb["mistyrose2"] = "#eed5d2"
+let s:rgb["mistyrose3"] = "#cdb7b5"
+let s:rgb["mistyrose4"] = "#8b7d7b"
+let s:rgb["moccasin"] = "#ffe4b5"
+let s:rgb["navajo white"] = "#ffdead"
+let s:rgb["navajowhite"] = "#ffdead"
+let s:rgb["navajowhite1"] = "#ffdead"
+let s:rgb["navajowhite2"] = "#eecfa1"
+let s:rgb["navajowhite3"] = "#cdb38b"
+let s:rgb["navajowhite4"] = "#8b795e"
+let s:rgb["navy blue"] = "#000080"
+let s:rgb["navy"] = "#000080"
+let s:rgb["navyblue"] = "#000080"
+let s:rgb["old lace"] = "#fdf5e6"
+let s:rgb["oldlace"] = "#fdf5e6"
+let s:rgb["olive drab"] = "#6b8e23"
+let s:rgb["olivedrab"] = "#6b8e23"
+let s:rgb["olivedrab1"] = "#c0ff3e"
+let s:rgb["olivedrab2"] = "#b3ee3a"
+let s:rgb["olivedrab3"] = "#9acd32"
+let s:rgb["olivedrab4"] = "#698b22"
+let s:rgb["orange red"] = "#ff4500"
+let s:rgb["orange"] = "#ffa500"
+let s:rgb["orange1"] = "#ffa500"
+let s:rgb["orange2"] = "#ee9a00"
+let s:rgb["orange3"] = "#cd8500"
+let s:rgb["orange4"] = "#8b5a00"
+let s:rgb["orangered"] = "#ff4500"
+let s:rgb["orangered1"] = "#ff4500"
+let s:rgb["orangered2"] = "#ee4000"
+let s:rgb["orangered3"] = "#cd3700"
+let s:rgb["orangered4"] = "#8b2500"
+let s:rgb["orchid"] = "#da70d6"
+let s:rgb["orchid1"] = "#ff83fa"
+let s:rgb["orchid2"] = "#ee7ae9"
+let s:rgb["orchid3"] = "#cd69c9"
+let s:rgb["orchid4"] = "#8b4789"
+let s:rgb["pale goldenrod"] = "#eee8aa"
+let s:rgb["pale green"] = "#98fb98"
+let s:rgb["pale turquoise"] = "#afeeee"
+let s:rgb["pale violet red"] = "#db7093"
+let s:rgb["palegoldenrod"] = "#eee8aa"
+let s:rgb["palegreen"] = "#98fb98"
+let s:rgb["palegreen1"] = "#9aff9a"
+let s:rgb["palegreen2"] = "#90ee90"
+let s:rgb["palegreen3"] = "#7ccd7c"
+let s:rgb["palegreen4"] = "#548b54"
+let s:rgb["paleturquoise"] = "#afeeee"
+let s:rgb["paleturquoise1"] = "#bbffff"
+let s:rgb["paleturquoise2"] = "#aeeeee"
+let s:rgb["paleturquoise3"] = "#96cdcd"
+let s:rgb["paleturquoise4"] = "#668b8b"
+let s:rgb["palevioletred"] = "#db7093"
+let s:rgb["palevioletred1"] = "#ff82ab"
+let s:rgb["palevioletred2"] = "#ee799f"
+let s:rgb["palevioletred3"] = "#cd6889"
+let s:rgb["palevioletred4"] = "#8b475d"
+let s:rgb["papaya whip"] = "#ffefd5"
+let s:rgb["papayawhip"] = "#ffefd5"
+let s:rgb["peach puff"] = "#ffdab9"
+let s:rgb["peachpuff"] = "#ffdab9"
+let s:rgb["peachpuff1"] = "#ffdab9"
+let s:rgb["peachpuff2"] = "#eecbad"
+let s:rgb["peachpuff3"] = "#cdaf95"
+let s:rgb["peachpuff4"] = "#8b7765"
+let s:rgb["peru"] = "#cd853f"
+let s:rgb["pink"] = "#ffc0cb"
+let s:rgb["pink1"] = "#ffb5c5"
+let s:rgb["pink2"] = "#eea9b8"
+let s:rgb["pink3"] = "#cd919e"
+let s:rgb["pink4"] = "#8b636c"
+let s:rgb["plum"] = "#dda0dd"
+let s:rgb["plum1"] = "#ffbbff"
+let s:rgb["plum2"] = "#eeaeee"
+let s:rgb["plum3"] = "#cd96cd"
+let s:rgb["plum4"] = "#8b668b"
+let s:rgb["powder blue"] = "#b0e0e6"
+let s:rgb["powderblue"] = "#b0e0e6"
+let s:rgb["purple"] = "#a020f0"
+let s:rgb["purple1"] = "#9b30ff"
+let s:rgb["purple2"] = "#912cee"
+let s:rgb["purple3"] = "#7d26cd"
+let s:rgb["purple4"] = "#551a8b"
+let s:rgb["red"] = "#ff0000"
+let s:rgb["red1"] = "#ff0000"
+let s:rgb["red2"] = "#ee0000"
+let s:rgb["red3"] = "#cd0000"
+let s:rgb["red4"] = "#8b0000"
+let s:rgb["rosy brown"] = "#bc8f8f"
+let s:rgb["rosybrown"] = "#bc8f8f"
+let s:rgb["rosybrown1"] = "#ffc1c1"
+let s:rgb["rosybrown2"] = "#eeb4b4"
+let s:rgb["rosybrown3"] = "#cd9b9b"
+let s:rgb["rosybrown4"] = "#8b6969"
+let s:rgb["royal blue"] = "#4169e1"
+let s:rgb["royalblue"] = "#4169e1"
+let s:rgb["royalblue1"] = "#4876ff"
+let s:rgb["royalblue2"] = "#436eee"
+let s:rgb["royalblue3"] = "#3a5fcd"
+let s:rgb["royalblue4"] = "#27408b"
+let s:rgb["saddle brown"] = "#8b4513"
+let s:rgb["saddlebrown"] = "#8b4513"
+let s:rgb["salmon"] = "#fa8072"
+let s:rgb["salmon1"] = "#ff8c69"
+let s:rgb["salmon2"] = "#ee8262"
+let s:rgb["salmon3"] = "#cd7054"
+let s:rgb["salmon4"] = "#8b4c39"
+let s:rgb["sandy brown"] = "#f4a460"
+let s:rgb["sandybrown"] = "#f4a460"
+let s:rgb["sea green"] = "#2e8b57"
+let s:rgb["seagreen"] = "#2e8b57"
+let s:rgb["seagreen1"] = "#54ff9f"
+let s:rgb["seagreen2"] = "#4eee94"
+let s:rgb["seagreen3"] = "#43cd80"
+let s:rgb["seagreen4"] = "#2e8b57"
+let s:rgb["seashell"] = "#fff5ee"
+let s:rgb["seashell1"] = "#fff5ee"
+let s:rgb["seashell2"] = "#eee5de"
+let s:rgb["seashell3"] = "#cdc5bf"
+let s:rgb["seashell4"] = "#8b8682"
+let s:rgb["sienna"] = "#a0522d"
+let s:rgb["sienna1"] = "#ff8247"
+let s:rgb["sienna2"] = "#ee7942"
+let s:rgb["sienna3"] = "#cd6839"
+let s:rgb["sienna4"] = "#8b4726"
+let s:rgb["sky blue"] = "#87ceeb"
+let s:rgb["skyblue"] = "#87ceeb"
+let s:rgb["skyblue1"] = "#87ceff"
+let s:rgb["skyblue2"] = "#7ec0ee"
+let s:rgb["skyblue3"] = "#6ca6cd"
+let s:rgb["skyblue4"] = "#4a708b"
+let s:rgb["slate blue"] = "#6a5acd"
+let s:rgb["slate gray"] = "#708090"
+let s:rgb["slate grey"] = "#708090"
+let s:rgb["slateblue"] = "#6a5acd"
+let s:rgb["slateblue1"] = "#836fff"
+let s:rgb["slateblue2"] = "#7a67ee"
+let s:rgb["slateblue3"] = "#6959cd"
+let s:rgb["slateblue4"] = "#473c8b"
+let s:rgb["slategray"] = "#708090"
+let s:rgb["slategray1"] = "#c6e2ff"
+let s:rgb["slategray2"] = "#b9d3ee"
+let s:rgb["slategray3"] = "#9fb6cd"
+let s:rgb["slategray4"] = "#6c7b8b"
+let s:rgb["slategrey"] = "#708090"
+let s:rgb["snow"] = "#fffafa"
+let s:rgb["snow1"] = "#fffafa"
+let s:rgb["snow2"] = "#eee9e9"
+let s:rgb["snow3"] = "#cdc9c9"
+let s:rgb["snow4"] = "#8b8989"
+let s:rgb["spring green"] = "#00ff7f"
+let s:rgb["springgreen"] = "#00ff7f"
+let s:rgb["springgreen1"] = "#00ff7f"
+let s:rgb["springgreen2"] = "#00ee76"
+let s:rgb["springgreen3"] = "#00cd66"
+let s:rgb["springgreen4"] = "#008b45"
+let s:rgb["steel blue"] = "#4682b4"
+let s:rgb["steelblue"] = "#4682b4"
+let s:rgb["steelblue1"] = "#63b8ff"
+let s:rgb["steelblue2"] = "#5cacee"
+let s:rgb["steelblue3"] = "#4f94cd"
+let s:rgb["steelblue4"] = "#36648b"
+let s:rgb["tan"] = "#d2b48c"
+let s:rgb["tan1"] = "#ffa54f"
+let s:rgb["tan2"] = "#ee9a49"
+let s:rgb["tan3"] = "#cd853f"
+let s:rgb["tan4"] = "#8b5a2b"
+let s:rgb["thistle"] = "#d8bfd8"
+let s:rgb["thistle1"] = "#ffe1ff"
+let s:rgb["thistle2"] = "#eed2ee"
+let s:rgb["thistle3"] = "#cdb5cd"
+let s:rgb["thistle4"] = "#8b7b8b"
+let s:rgb["tomato"] = "#ff6347"
+let s:rgb["tomato1"] = "#ff6347"
+let s:rgb["tomato2"] = "#ee5c42"
+let s:rgb["tomato3"] = "#cd4f39"
+let s:rgb["tomato4"] = "#8b3626"
+let s:rgb["turquoise"] = "#40e0d0"
+let s:rgb["turquoise1"] = "#00f5ff"
+let s:rgb["turquoise2"] = "#00e5ee"
+let s:rgb["turquoise3"] = "#00c5cd"
+let s:rgb["turquoise4"] = "#00868b"
+let s:rgb["violet red"] = "#d02090"
+let s:rgb["violet"] = "#ee82ee"
+let s:rgb["violetred"] = "#d02090"
+let s:rgb["violetred1"] = "#ff3e96"
+let s:rgb["violetred2"] = "#ee3a8c"
+let s:rgb["violetred3"] = "#cd3278"
+let s:rgb["violetred4"] = "#8b2252"
+let s:rgb["wheat"] = "#f5deb3"
+let s:rgb["wheat1"] = "#ffe7ba"
+let s:rgb["wheat2"] = "#eed8ae"
+let s:rgb["wheat3"] = "#cdba96"
+let s:rgb["wheat4"] = "#8b7e66"
+let s:rgb["white smoke"] = "#f5f5f5"
+let s:rgb["white"] = "#ffffff"
+let s:rgb["whitesmoke"] = "#f5f5f5"
+let s:rgb["yellow green"] = "#9acd32"
+let s:rgb["yellow"] = "#ffff00"
+let s:rgb["yellow1"] = "#ffff00"
+let s:rgb["yellow2"] = "#eeee00"
+let s:rgb["yellow3"] = "#cdcd00"
+let s:rgb["yellow4"] = "#8b8b00"
+let s:rgb["yellowgreen"] = "#9acd32"
+
+if has('mac') && !has('macunix')
+ let s:rgb["dark gray"] = "0x808080"
+ let s:rgb["darkgray"] = "0x808080"
+ let s:rgb["dark grey"] = "0x808080"
+ let s:rgb["darkgrey"] = "0x808080"
+ let s:rgb["gray"] = "0xc0c0c0"
+ let s:rgb["grey"] = "0xc0c0c0"
+ let s:rgb["light gray"] = "0xe0e0e0"
+ let s:rgb["lightgray"] = "0xe0e0e0"
+ let s:rgb["light grey"] = "0xe0e0e0"
+ let s:rgb["lightgrey"] = "0xe0e0e0"
+ let s:rgb["dark red"] = "0x800000"
+ let s:rgb["darkred"] = "0x800000"
+ let s:rgb["red"] = "0xdd0806"
+ let s:rgb["light red"] = "0xffa0a0"
+ let s:rgb["lightred"] = "0xffa0a0"
+ let s:rgb["dark blue"] = "0x000080"
+ let s:rgb["darkblue"] = "0x000080"
+ let s:rgb["blue"] = "0x0000d4"
+ let s:rgb["light blue"] = "0xa0a0ff"
+ let s:rgb["lightblue"] = "0xa0a0ff"
+ let s:rgb["dark green"] = "0x008000"
+ let s:rgb["darkgreen"] = "0x008000"
+ let s:rgb["green"] = "0x006411"
+ let s:rgb["light green"] = "0xa0ffa0"
+ let s:rgb["lightgreen"] = "0xa0ffa0"
+ let s:rgb["dark cyan"] = "0x008080"
+ let s:rgb["darkcyan"] = "0x008080"
+ let s:rgb["cyan"] = "0x02abea"
+ let s:rgb["light cyan"] = "0xa0ffff"
+ let s:rgb["lightcyan"] = "0xa0ffff"
+ let s:rgb["dark magenta"] = "0x800080"
+ let s:rgb["darkmagenta"] = "0x800080"
+ let s:rgb["magenta"] = "0xf20884"
+ let s:rgb["light magenta"] = "0xf0a0f0"
+ let s:rgb["lightmagenta"] = "0xf0a0f0"
+ let s:rgb["brown"] = "0x804040"
+ let s:rgb["yellow"] = "0xfcf305"
+ let s:rgb["light yellow"] = "0xffffa0"
+ let s:rgb["lightyellow"] = "0xffffa0"
+ let s:rgb["orange"] = "0xfc8000"
+ let s:rgb["purple"] = "0xa020f0"
+ let s:rgb["slateblue"] = "0x6a5acd"
+ let s:rgb["violet"] = "0x8d38c9"
+endif
+
+function! csapprox#rgb()
+ return s:rgb
+endfunction
View
175 doc/CSApprox.txt
@@ -8,7 +8,7 @@
\___//___//_/ |_|/ .__// .__//_/ \___//_\_\ ~
/_/ /_/ ~
For Vim version 7.0 or newer
- Last changed 31 Jan 2009
+ Last changed 01 Apr 2009
By Matt Wozniski
mjw@drexel.edu
@@ -17,7 +17,7 @@
*csapprox-toc*
-1. Description |csapprox-intro|
+1. Introduction |csapprox-intro|
2. Requirements |csapprox-requirements|
3. Configuration |csapprox-configure|
4. Rationale/Design |csapprox-design|
@@ -32,48 +32,37 @@ variable in your |vimrc| file: >
:let g:CSApprox_loaded = 1
==============================================================================
-1. Description *csapprox-intro*
-
-There is a wealth of colorschemes available for Vim. Unfortunately, since
-traditional terminal emulators have only supported 2, 8 or 16 colors,
-colorscheme authors have tended to avoid writing colorschemes for terminal
-Vim, sticking instead to GVim. Even now that nearly every popular terminal
-supports either 88 or 256 colors, few colorschemes are written to support
-them. This may be because the terminal color codes are just numbers from 0 to
-87 or 255 with no semantic meaning, or because the same number doesn't yield
-the same color in all terminals, or simply because the colorscheme author
-doesn't use the terminal and doesn't want to take the time to support
-terminals.
-
-Whatever the reason, this leaves users of many modern terminal emulators in
-the awkward position of having a terminal emulator that supports many colors,
-but having very few colorschemes that were written to utilize those colors.
-
-This is where CSApprox comes in. It attempts to fill this void allowing GVim
-colorschemes to be used in terminal Vim. CSApprox has two distinct modes of
-operation. In the first mode, it attempts to make GVim colorschemes
-transparently backwards compatible with terminal Vim in a high color terminal.
-Basically, whenever a colorscheme is run it should set some colors for the
-GUI, and this script will then run and attempt to figure out the closest color
-available in the terminal's color palette to the color the scheme author asked
-for. Unfortunately, this does not work well all the time, and it has some
-limitations (see |csapprox-limitations|). Most of the time, however, this
-gives a very close approximation to the GVim colors without requiring any
-changes to the colorscheme, or any user interaction. It only requires that
-the plugin be installed on the machine where Vim is being run, and that the
-user's environment meets the needs specified at |csapprox-requirements|.
-
+1. Introduction *csapprox-intro*
+
+It's hard to find colorschemes for terminal Vim. Most colorschemes are
+written to only support GVim, and don't work at all in terminal Vim.
+
+This plugin makes GVim-only colorschemes Just Work in terminal Vim, as long
+as the terminal supports 88 or 256 colors - and most do these days. This
+usually requires no user interaction (but see below for what to do if things
+don't Just Work). After getting this plugin happily installed, any time you
+use :colorscheme it will do its magic and make the colorscheme Just Work.
+
+Whenever you change colorschemes using the :colorscheme command this script
+will be executed. It will take the colors that the scheme specified for use
+in the GUI and use an approximation algorithm to try to gracefully degrade
+them to the closest color available in your terminal. If you are running in
+a GUI or if your terminal doesn't support 88 or 256 colors, no changes are
+made. Also, no changes will be made if the colorscheme seems to have been
+high color already.
+
+If for some reason this transparent method isn't suitable to you (for instance
+if your environment can't be configured to meet the |csapprox-requirements|,
+or you need to work in Vim 6), another option is also available: using the
+|:CSApproxSnapshot| command to create a new GUI/88-/256-color terminal
+colorscheme. To use this command, a user would generally start GVim, choose a
+colorscheme that sets up the desired colors, and then use |:CSApproxSnapshot|
+to create a new colorscheme based on those colors that works in high color
+terminals. This method is more flexible than the transparent mode and works
+in more places, but also requires more user intervention, and makes it harder
+to deal with colorschemes being updated and such.
*:CSApproxSnapshot*
-The other mode of operation allows creating a colorscheme suitable for use in
-high color terminals from the colorscheme currently in use. To use this mode,
-a user would generally start GVim, choose a colorscheme that sets up the
-desired colors, and then use |:CSApproxSnapshot| to create a new colorscheme
-based on those colors that works in high color terminals. This method has
-several advantages over the transparent mode of operation - for example, it
-doesn't cause any extra slowdown in Vim's starting and doesn't require a "vim"
-built with +gui on the machine where the scheme is used - but it requires
-action on the part of the user and can't be done transparently, making it much
-less convenient. The syntax for the command is: >
+The full syntax for the command is: >
:CSApproxSnapshot[!] /path/to/new/colorscheme
< For example: >
:CSApproxSnapshot ~/.vim/colors/foobar.vim
@@ -157,12 +146,20 @@ To turn on high color support without fixing $TERM, you can change t_Co in
your .vimrc, and set either CSApprox_konsole or CSApprox_eterm if appropriate.
One way would be to put something like this into your |vimrc|:
>
- if (&term == 'xterm' || &term =? '^screen') && hostname() == 'my-machine'
+ if (&term == 'xterm' || &term =~? '^screen') && hostname() == 'my-machine'
" On my machine, I use Konsole with 256 color support
set t_Co=256
let g:CSApprox_konsole = 1
endif
+Gnome Terminal, as of the time that I am writing this, doesn't support having
+the terminal emulator set $TERM to something adequately descriptive. In cases
+like this, something like the following would be appropriate:
+>
+ if &term =~ '^\(xterm\|screen\)$' && $COLORTERM == 'gnome-terminal'
+ set t_Co=256
+ endif
+
==============================================================================
3. Configuration *csapprox-configure*
@@ -292,24 +289,13 @@ g:CSApprox_hook_{scheme}_post *csapprox-hooks*
colorscheme named "123 foo_bar-baz456.vim", the hook searched for
will be, eg, g:CSApprox_hook_foo_barbaz456_post
-g:CSApprox_extra_rgb_txt_dirs *g:CSApprox_extra_rgb_txt_dirs*
- When the colorscheme author uses a color by name, CSApprox needs to figure
- out what #rrggbb value it stands for. When not running in GVim, Vim can't
- tell it, so it does this by parsing rgb.txt - but first needs to locate
- it. It has a default search path included, and will also search in any
- directory in the user's 'runtimepath', but first any directory included in
- this variable will be searched. Failing to find any valid rgb.txt is an
- unrecoverable error, but it should never happen since CSApprox includes an
- rgb.txt in its distribution. The only reason for preferring other rgb.txt
- files on the system to the one distributed with CSApprox is that they
- might more accurately reflect the colors used in GVim; different rgb.txt
- files might have different values for some colors. Default search path:
->
- [ /usr/local/share/X11, /usr/share/X11, /etc/X11, /usr/local/lib/X11,
- /usr/lib/X11, /usr/local/X11R6/lib/X11, /usr/X11R6/lib/X11 ]
-<
- Snapshotted schemes will never contain colors by name, so this option is
- unneeded and won't be used.
+g:CSApprox_use_showrgb *g:CSApprox_use_showrgb*
+ By default, CSApprox will use a built in mapping of color names to values.
+ This optimization greatly helps speed, but means that colors addressed by
+ name might not match up perfectly between gvim (which uses the system's
+ real rgb database) and CSApprox (which uses the builtin database). To
+ force CSApprox to try the systemwide database first, and only fall back on
+ the builtin database if it isn't available, set this variable non-zero.
g:CSApprox_approximator_function *g:CSApprox_approximator_function*
If the default approximation function doesn't work well enough, the user
@@ -336,6 +322,37 @@ g:CSApprox_redirfallback *g:CSApprox_redirfallback*
==============================================================================
4. Rationale/Design *csapprox-design*
+There is a wealth of colorschemes available for Vim. Unfortunately, since
+traditional terminal emulators have only supported 2, 8 or 16 colors,
+colorscheme authors have tended to avoid writing colorschemes for terminal
+Vim, sticking instead to GVim. Even now that nearly every popular terminal
+supports either 88 or 256 colors, few colorschemes are written to support
+them. This may be because the terminal color codes are just numbers from 0 to
+87 or 255 with no semantic meaning, or because the same number doesn't yield
+the same color in all terminals, or simply because the colorscheme author
+doesn't use the terminal and doesn't want to take the time to support
+terminals.
+
+Whatever the reason, this leaves users of many modern terminal emulators in
+the awkward position of having a terminal emulator that supports many colors,
+but having very few colorschemes that were written to utilize those colors.
+
+This is where CSApprox comes in. It attempts to fill this void allowing GVim
+colorschemes to be used in terminal Vim. CSApprox has two distinct modes of
+operation. In the first mode, it attempts to make GVim colorschemes
+transparently backwards compatible with terminal Vim in a high color terminal.
+Basically, whenever a colorscheme is run it should set some colors for the
+GUI, and this script will then run and attempt to figure out the closest color
+available in the terminal's color palette to the color the scheme author asked
+for. Unfortunately, this does not work well all the time, and it has some
+limitations (see |csapprox-limitations|). Most of the time, however, this
+gives a very close approximation to the GVim colors without requiring any
+changes to the colorscheme, or any user interaction. It only requires that
+the plugin be installed on the machine where Vim is being run, and that the
+user's environment meets the needs specified at |csapprox-requirements|. In
+the event that this doesn't work, a second option - using :CSApproxSnapshot
+to create a new, 88-/256-color capable colorscheme - is available.
+
Ideally, the aim is for CSApprox to be completely transparent to the user.
This is why the approach I take is entirely different from the GuiColorScheme
script, which will break on any but the simplest colorschemes. Unfortunately,
@@ -348,9 +365,11 @@ to make it easy to override my choice of defaults when necessary (through
g:CSApprox_approximator_function, g:CSApprox_konsole, g:CSApprox_eterm,
g:CSApprox_attr_map, etc).
-In the event that the transparent solution is undesirable, |:CSApproxSnapshot|
-should provide a workable alternative - less cool, and less flexible, but it
-will work in more environments, and the snapshot will even work in Vim 6.
+In the event that the transparent solution is undesirable, or that the user's
+environment can't be configured to allow it (no GVim and no Vim with +gui, for
+instance), |:CSApproxSnapshot| should provide a workable alternative - less
+cool, and less flexible, but it will work in more environments, and the
+snapshotted colorscheme will even work in Vim 6.
If any of my design choices seem to be causing extra work with no real
advantages, though, I'd like to hear about it. Feel free to email me with any
@@ -406,6 +425,9 @@ Transparently adapting schemes is slow.
since all of the hard evaluations are made when they're made instead of when
they're used.
+ NOTE: As of CSApprox 3.50, the overhead is down to about 0.10 seconds on my
+ test machine.
+
==============================================================================
6. Appendix - Terminals and Palettes *csapprox-terminal-list*
@@ -507,6 +529,29 @@ kterm (as of version 6.2.0)
==============================================================================
7. Changelog *csapprox-changelog*
+ 3.50 01 Apr 2009 Fix a major regression that prevented the Eterm and
+ Konsole colors from being correctly snapshotted
+
+ Fix a related bug causing incorrect terminal colors
+ after calling :CSApproxSnapshot
+
+ Fix a bug causing black to be used instead of dark grey
+
+ Have snapshots calculate g:colors_name programmatically
+
+ Introduce many tweaks for better speed
+
+ Clarify some things at :help csapprox-terminal-example
+
+ Default to using our own list of rgb.txt colors rather
+ than searching, for performance. Add a new variable,
+ g:CSApprox_use_showrgb, which forces us to try finding
+ the colors using the "showrgb" program instead, and fall
+ back on our own list if it isn't available
+
+ Remove g:CSApprox_extra_rgb_txt_dirs - not needed in
+ light of the above change
+
3.05 31 Jan 2009 Fix a harmless "Undefined variable" error in
:CSApproxSnapshot
View
752 doc/rgb.txt
@@ -1,752 +0,0 @@
-255 250 250 snow
-248 248 255 ghost white
-248 248 255 GhostWhite
-245 245 245 white smoke
-245 245 245 WhiteSmoke
-220 220 220 gainsboro
-255 250 240 floral white
-255 250 240 FloralWhite
-253 245 230 old lace
-253 245 230 OldLace
-250 240 230 linen
-250 235 215 antique white
-250 235 215 AntiqueWhite
-255 239 213 papaya whip
-255 239 213 PapayaWhip
-255 235 205 blanched almond
-255 235 205 BlanchedAlmond
-255 228 196 bisque
-255 218 185 peach puff
-255 218 185 PeachPuff
-255 222 173 navajo white
-255 222 173 NavajoWhite
-255 228 181 moccasin
-255 248 220 cornsilk
-255 255 240 ivory
-255 250 205 lemon chiffon
-255 250 205 LemonChiffon
-255 245 238 seashell
-240 255 240 honeydew
-245 255 250 mint cream
-245 255 250 MintCream
-240 255 255 azure
-240 248 255 alice blue
-240 248 255 AliceBlue
-230 230 250 lavender
-255 240 245 lavender blush
-255 240 245 LavenderBlush
-255 228 225 misty rose
-255 228 225 MistyRose
-255 255 255 white
- 0 0 0 black
- 47 79 79 dark slate gray
- 47 79 79 DarkSlateGray
- 47 79 79 dark slate grey
- 47 79 79 DarkSlateGrey
-105 105 105 dim gray
-105 105 105 DimGray
-105 105 105 dim grey
-105 105 105 DimGrey
-112 128 144 slate gray
-112 128 144 SlateGray
-112 128 144 slate grey
-112 128 144 SlateGrey
-119 136 153 light slate gray
-119 136 153 LightSlateGray
-119 136 153 light slate grey
-119 136 153 LightSlateGrey
-190 190 190 gray
-190 190 190 grey
-211 211 211 light grey
-211 211 211 LightGrey
-211 211 211 light gray
-211 211 211 LightGray
- 25 25 112 midnight blue
- 25 25 112 MidnightBlue
- 0 0 128 navy
- 0 0 128 navy blue
- 0 0 128 NavyBlue
-100 149 237 cornflower blue
-100 149 237 CornflowerBlue
- 72 61 139 dark slate blue
- 72 61 139 DarkSlateBlue
-106 90 205 slate blue
-106 90 205 SlateBlue
-123 104 238 medium slate blue
-123 104 238 MediumSlateBlue
-132 112 255 light slate blue
-132 112 255 LightSlateBlue
- 0 0 205 medium blue
- 0 0 205 MediumBlue
- 65 105 225 royal blue
- 65 105 225 RoyalBlue
- 0 0 255 blue
- 30 144 255 dodger blue
- 30 144 255 DodgerBlue
- 0 191 255 deep sky blue
- 0 191 255 DeepSkyBlue
-135 206 235 sky blue
-135 206 235 SkyBlue
-135 206 250 light sky blue
-135 206 250 LightSkyBlue
- 70 130 180 steel blue
- 70 130 180 SteelBlue
-176 196 222 light steel blue
-176 196 222 LightSteelBlue
-173 216 230 light blue
-173 216 230 LightBlue
-176 224 230 powder blue
-176 224 230 PowderBlue
-175 238 238 pale turquoise
-175 238 238 PaleTurquoise
- 0 206 209 dark turquoise
- 0 206 209 DarkTurquoise
- 72 209 204 medium turquoise
- 72 209 204 MediumTurquoise
- 64 224 208 turquoise
- 0 255 255 cyan
-224 255 255 light cyan
-224 255 255 LightCyan
- 95 158 160 cadet blue
- 95 158 160 CadetBlue
-102 205 170 medium aquamarine
-102 205 170 MediumAquamarine
-127 255 212 aquamarine
- 0 100 0 dark green
- 0 100 0 DarkGreen
- 85 107 47 dark olive green
- 85 107 47 DarkOliveGreen
-143 188 143 dark sea green
-143 188 143 DarkSeaGreen
- 46 139 87 sea green
- 46 139 87 SeaGreen
- 60 179 113 medium sea green
- 60 179 113 MediumSeaGreen
- 32 178 170 light sea green
- 32 178 170 LightSeaGreen
-152 251 152 pale green
-152 251 152 PaleGreen
- 0 255 127 spring green
- 0 255 127 SpringGreen
-124 252 0 lawn green
-124 252 0 LawnGreen
- 0 255 0 green
-127 255 0 chartreuse
- 0 250 154 medium spring green
- 0 250 154 MediumSpringGreen
-173 255 47 green yellow
-173 255 47 GreenYellow
- 50 205 50 lime green
- 50 205 50 LimeGreen
-154 205 50 yellow green
-154 205 50 YellowGreen
- 34 139 34 forest green
- 34 139 34 ForestGreen
-107 142 35 olive drab
-107 142 35 OliveDrab
-189 183 107 dark khaki
-189 183 107 DarkKhaki
-240 230 140 khaki
-238 232 170 pale goldenrod
-238 232 170 PaleGoldenrod
-250 250 210 light goldenrod yellow
-250 250 210 LightGoldenrodYellow
-255 255 224 light yellow
-255 255 224 LightYellow
-255 255 0 yellow
-255 215 0 gold
-238 221 130 light goldenrod
-238 221 130 LightGoldenrod
-218 165 32 goldenrod
-184 134 11 dark goldenrod
-184 134 11 DarkGoldenrod
-188 143 143 rosy brown
-188 143 143 RosyBrown
-205 92 92 indian red
-205 92 92 IndianRed
-139 69 19 saddle brown
-139 69 19 SaddleBrown
-160 82 45 sienna
-205 133 63 peru
-222 184 135 burlywood
-245 245 220 beige
-245 222 179 wheat
-244 164 96 sandy brown
-244 164 96 SandyBrown
-210 180 140 tan
-210 105 30 chocolate
-178 34 34 firebrick
-165 42 42 brown
-233 150 122 dark salmon
-233 150 122 DarkSalmon
-250 128 114 salmon
-255 160 122 light salmon
-255 160 122 LightSalmon
-255 165 0 orange
-255 140 0 dark orange
-255 140 0 DarkOrange
-255 127 80 coral
-240 128 128 light coral
-240 128 128 LightCoral
-255 99 71 tomato
-255 69 0 orange red
-255 69 0 OrangeRed
-255 0 0 red
-255 105 180 hot pink
-255 105 180 HotPink
-255 20 147 deep pink
-255 20 147 DeepPink
-255 192 203 pink
-255 182 193 light pink
-255 182 193 LightPink
-219 112 147 pale violet red
-219 112 147 PaleVioletRed
-176 48 96 maroon
-199 21 133 medium violet red
-199 21 133 MediumVioletRed
-208 32 144 violet red
-208 32 144 VioletRed
-255 0 255 magenta
-238 130 238 violet
-221 160 221 plum
-218 112 214 orchid
-186 85 211 medium orchid
-186 85 211 MediumOrchid
-153 50 204 dark orchid
-153 50 204 DarkOrchid
-148 0 211 dark violet
-148 0 211 DarkViolet
-138 43 226 blue violet
-138 43 226 BlueViolet
-160 32 240 purple
-147 112 219 medium purple
-147 112 219 MediumPurple
-216 191 216 thistle
-255 250 250 snow1
-238 233 233 snow2
-205 201 201 snow3
-139 137 137 snow4
-255 245 238 seashell1
-238 229 222 seashell2
-205 197 191 seashell3
-139 134 130 seashell4
-255 239 219 AntiqueWhite1
-238 223 204 AntiqueWhite2
-205 192 176 AntiqueWhite3
-139 131 120 AntiqueWhite4
-255 228 196 bisque1
-238 213 183 bisque2
-205 183 158 bisque3
-139 125 107 bisque4
-255 218 185 PeachPuff1
-238 203 173 PeachPuff2
-205 175 149 PeachPuff3
-139 119 101 PeachPuff4
-255 222 173 NavajoWhite1
-238 207 161 NavajoWhite2
-205 179 139 NavajoWhite3
-139 121 94 NavajoWhite4
-255 250 205 LemonChiffon1
-238 233 191 LemonChiffon2
-205 201 165 LemonChiffon3
-139 137 112 LemonChiffon4
-255 248 220 cornsilk1
-238 232 205 cornsilk2
-205 200 177 cornsilk3
-139 136 120 cornsilk4
-255 255 240 ivory1
-238 238 224 ivory2
-205 205 193 ivory3
-139 139 131 ivory4
-240 255 240 honeydew1
-224 238 224 honeydew2
-193 205 193 honeydew3
-131 139 131 honeydew4
-255 240 245 LavenderBlush1
-238 224 229 LavenderBlush2
-205 193 197 LavenderBlush3
-139 131 134 LavenderBlush4
-255 228 225 MistyRose1
-238 213 210 MistyRose2
-205 183 181 MistyRose3
-139 125 123 MistyRose4
-240 255 255 azure1
-224 238 238 azure2
-193 205 205 azure3
-131 139 139 azure4
-131 111 255 SlateBlue1
-122 103 238 SlateBlue2
-105 89 205 SlateBlue3
- 71 60 139 SlateBlue4
- 72 118 255 RoyalBlue1
- 67 110 238 RoyalBlue2
- 58 95 205 RoyalBlue3
- 39 64 139 RoyalBlue4
- 0 0 255 blue1
- 0 0 238 blue2
- 0 0 205 blue3
- 0 0 139 blue4
- 30 144 255 DodgerBlue1
- 28 134 238 DodgerBlue2
- 24 116 205 DodgerBlue3
- 16 78 139 DodgerBlue4
- 99 184 255 SteelBlue1
- 92 172 238 SteelBlue2
- 79 148 205 SteelBlue3
- 54 100 139 SteelBlue4
- 0 191 255 DeepSkyBlue1
- 0 178 238 DeepSkyBlue2
- 0 154 205 DeepSkyBlue3
- 0 104 139 DeepSkyBlue4
-135 206 255 SkyBlue1
-126 192 238 SkyBlue2
-108 166 205 SkyBlue3
- 74 112 139 SkyBlue4
-176 226 255 LightSkyBlue1
-164 211 238 LightSkyBlue2
-141 182 205 LightSkyBlue3
- 96 123 139 LightSkyBlue4
-198 226 255 SlateGray1
-185 211 238 SlateGray2
-159 182 205 SlateGray3
-108 123 139 SlateGray4
-202 225 255 LightSteelBlue1
-188 210 238 LightSteelBlue2
-162 181 205 LightSteelBlue3
-110 123 139 LightSteelBlue4
-191 239 255 LightBlue1
-178 223 238 LightBlue2
-154 192 205 LightBlue3
-104 131 139 LightBlue4
-224 255 255 LightCyan1
-209 238 238 LightCyan2
-180 205 205 LightCyan3
-122 139 139 LightCyan4
-187 255 255 PaleTurquoise1
-174 238 238 PaleTurquoise2
-150 205 205 PaleTurquoise3
-102 139 139 PaleTurquoise4
-152 245 255 CadetBlue1
-142 229 238 CadetBlue2
-122 197 205 CadetBlue3
- 83 134 139 CadetBlue4
- 0 245 255 turquoise1
- 0 229 238 turquoise2
- 0 197 205 turquoise3
- 0 134 139 turquoise4
- 0 255 255 cyan1
- 0 238 238 cyan2
- 0 205 205 cyan3
- 0 139 139 cyan4
-151 255 255 DarkSlateGray1
-141 238 238 DarkSlateGray2
-121 205 205 DarkSlateGray3
- 82 139 139 DarkSlateGray4
-127 255 212 aquamarine1
-118 238 198 aquamarine2
-102 205 170 aquamarine3
- 69 139 116 aquamarine4
-193 255 193 DarkSeaGreen1
-180 238 180 DarkSeaGreen2
-155 205 155 DarkSeaGreen3
-105 139 105 DarkSeaGreen4
- 84 255 159 SeaGreen1
- 78 238 148 SeaGreen2
- 67 205 128 SeaGreen3
- 46 139 87 SeaGreen4
-154 255 154 PaleGreen1
-144 238 144 PaleGreen2
-124 205 124 PaleGreen3
- 84 139 84 PaleGreen4
- 0 255 127 SpringGreen1
- 0 238 118 SpringGreen2
- 0 205 102 SpringGreen3
- 0 139 69 SpringGreen4
- 0 255 0 green1
- 0 238 0 green2
- 0 205 0 green3
- 0 139 0 green4
-127 255 0 chartreuse1
-118 238 0 chartreuse2
-102 205 0 chartreuse3
- 69 139 0 chartreuse4
-192 255 62 OliveDrab1
-179 238 58 OliveDrab2
-154 205 50 OliveDrab3
-105 139 34 OliveDrab4
-202 255 112 DarkOliveGreen1
-188 238 104 DarkOliveGreen2
-162 205 90 DarkOliveGreen3
-110 139 61 DarkOliveGreen4
-255 246 143 khaki1
-238 230 133 khaki2
-205 198 115 khaki3
-139 134 78 khaki4
-255 236 139 LightGoldenrod1
-238 220 130 LightGoldenrod2
-205 190 112 LightGoldenrod3
-139 129 76 LightGoldenrod4
-255 255 224 LightYellow1
-238 238 209 LightYellow2
-205 205 180 LightYellow3
-139 139 122 LightYellow4
-255 255 0 yellow1
-238 238 0 yellow2
-205 205 0 yellow3
-139 139 0 yellow4
-255 215 0 gold1
-238 201 0 gold2
-205 173 0 gold3
-139 117 0 gold4
-255 193 37 goldenrod1
-238 180 34 goldenrod2
-205 155 29 goldenrod3
-139 105 20 goldenrod4
-255 185 15 DarkGoldenrod1
-238 173 14 DarkGoldenrod2
-205 149 12 DarkGoldenrod3
-139 101 8 DarkGoldenrod4
-255 193 193 RosyBrown1
-238 180 180 RosyBrown2
-205 155 155 RosyBrown3
-139 105 105 RosyBrown4
-255 106 106 IndianRed1
-238 99 99 IndianRed2
-205 85 85 IndianRed3
-139 58 58 IndianRed4
-255 130 71 sienna1
-238 121 66 sienna2
-205 104 57 sienna3
-139 71 38 sienna4
-255 211 155 burlywood1
-238 197 145 burlywood2
-205 170 125 burlywood3
-139 115 85 burlywood4
-255 231 186 wheat1
-238 216 174 wheat2
-205 186 150 wheat3
-139 126 102 wheat4
-255 165 79 tan1
-238 154 73 tan2
-205 133 63 tan3
-139 90 43 tan4
-255 127 36 chocolate1
-238 118 33 chocolate2
-205 102 29 chocolate3
-139 69 19 chocolate4
-255 48 48 firebrick1
-238 44 44 firebrick2
-205 38 38 firebrick3
-139 26 26 firebrick4
-255 64 64 brown1
-238 59 59 brown2
-205 51 51 brown3
-139 35 35 brown4
-255 140 105 salmon1
-238 130 98 salmon2
-205 112 84 salmon3
-139 76 57 salmon4
-255 160 122 LightSalmon1
-238 149 114 LightSalmon2
-205 129 98 LightSalmon3
-139 87 66 LightSalmon4
-255 165 0 orange1
-238 154 0 orange2
-205 133 0 orange3
-139 90 0 orange4
-255 127 0 DarkOrange1
-238 118 0 DarkOrange2
-205 102 0 DarkOrange3
-139 69 0 DarkOrange4
-255 114 86 coral1
-238 106 80 coral2
-205 91 69 coral3
-139 62 47 coral4
-255 99 71 tomato1
-238 92 66 tomato2
-205 79 57 tomato3
-139 54 38 tomato4
-255 69 0 OrangeRed1
-238 64 0 OrangeRed2
-205 55 0 OrangeRed3
-139 37 0 OrangeRed4
-255 0 0 red1
-238 0 0 red2
-205 0 0 red3
-139 0 0 red4
-255 20 147 DeepPink1
-238 18 137 DeepPink2
-205 16 118 DeepPink3
-139 10 80 DeepPink4
-255 110 180 HotPink1
-238 106 167 HotPink2
-205 96 144 HotPink3
-139 58 98 HotPink4
-255 181 197 pink1
-238 169 184 pink2
-205 145 158 pink3
-139 99 108 pink4
-255 174 185 LightPink1
-238 162 173 LightPink2
-205 140 149 LightPink3
-139 95 101 LightPink4
-255 130 171 PaleVioletRed1
-238 121 159 PaleVioletRed2
-205 104 137 PaleVioletRed3
-139 71 93 PaleVioletRed4
-255 52 179 maroon1
-238 48 167 maroon2
-205 41 144 maroon3
-139 28 98 maroon4
-255 62 150 VioletRed1
-238 58 140 VioletRed2
-205 50 120 VioletRed3
-139 34 82 VioletRed4
-255 0 255 magenta1
-238 0 238 magenta2
-205 0 205 magenta3
-139 0 139 magenta4
-255 131 250 orchid1
-238 122 233 orchid2
-205 105 201 orchid3
-139 71 137 orchid4
-255 187 255 plum1
-238 174 238 plum2
-205 150 205 plum3
-139 102 139 plum4
-224 102 255 MediumOrchid1
-209 95 238 MediumOrchid2
-180 82 205 MediumOrchid3
-122 55 139 MediumOrchid4
-191 62 255 DarkOrchid1
-178 58 238 DarkOrchid2
-154 50 205 DarkOrchid3
-104 34 139 DarkOrchid4
-155 48 255 purple1
-145 44 238 purple2
-125 38 205 purple3
- 85 26 139 purple4
-171 130 255 MediumPurple1
-159 121 238 MediumPurple2
-137 104 205 MediumPurple3
- 93 71 139 MediumPurple4
-255 225 255 thistle1
-238 210 238 thistle2
-205 181 205 thistle3
-139 123 139 thistle4
- 0 0 0 gray0
- 0 0 0 grey0
- 3 3 3 gray1
- 3 3 3 grey1
- 5 5 5 gray2
- 5 5 5 grey2
- 8 8 8 gray3
- 8 8 8 grey3
- 10 10 10 gray4
- 10 10 10 grey4
- 13 13 13 gray5
- 13 13 13 grey5
- 15 15 15 gray6
- 15 15 15 grey6
- 18 18 18 gray7
- 18 18 18 grey7
- 20 20 20 gray8
- 20 20 20 grey8
- 23 23 23 gray9
- 23 23 23 grey9
- 26 26 26 gray10
- 26 26 26 grey10
- 28 28 28 gray11
- 28 28 28 grey11
- 31 31 31 gray12
- 31 31 31 grey12
- 33 33 33 gray13
- 33 33 33 grey13
- 36 36 36 gray14
- 36 36 36 grey14
- 38 38 38 gray15
- 38 38 38 grey15
- 41 41 41 gray16
- 41 41 41 grey16
- 43 43 43 gray17
- 43 43 43 grey17
- 46 46 46 gray18
- 46 46 46 grey18
- 48 48 48 gray19
- 48 48 48 grey19
- 51 51 51 gray20
- 51 51 51 grey20
- 54 54 54 gray21
- 54 54 54 grey21
- 56 56 56 gray22
- 56 56 56 grey22
- 59 59 59 gray23
- 59 59 59 grey23
- 61 61 61 gray24
- 61 61 61 grey24
- 64 64 64 gray25
- 64 64 64 grey25
- 66 66 66 gray26
- 66 66 66 grey26
- 69 69 69 gray27
- 69 69 69 grey27
- 71 71 71 gray28
- 71 71 71 grey28
- 74 74 74 gray29
- 74 74 74 grey29
- 77 77 77 gray30
- 77 77 77 grey30
- 79 79 79 gray31
- 79 79 79 grey31
- 82 82 82 gray32
- 82 82 82 grey32
- 84 84 84 gray33
- 84 84 84 grey33
- 87 87 87 gray34
- 87 87 87 grey34
- 89 89 89 gray35
- 89 89 89 grey35
- 92 92 92 gray36
- 92 92 92 grey36
- 94 94 94 gray37
- 94 94 94 grey37
- 97 97 97 gray38
- 97 97 97 grey38
- 99 99 99 gray39
- 99 99 99 grey39
-102 102 102 gray40
-102 102 102 grey40
-105 105 105 gray41
-105 105 105 grey41
-107 107 107 gray42
-107 107 107 grey42
-110 110 110 gray43
-110 110 110 grey43
-112 112 112 gray44
-112 112 112 grey44
-115 115 115 gray45
-115 115 115 grey45
-117 117 117 gray46
-117 117 117 grey46
-120 120 120 gray47
-120 120 120 grey47
-122 122 122 gray48
-122 122 122 grey48
-125 125 125 gray49
-125 125 125 grey49
-127 127 127 gray50
-127 127 127 grey50
-130 130 130 gray51
-130 130 130 grey51
-133 133 133 gray52
-133 133 133 grey52
-135 135 135 gray53
-135 135 135 grey53
-138 138 138 gray54
-138 138 138 grey54
-140 140 140 gray55
-140 140 140 grey55
-143 143 143 gray56
-143 143 143 grey56
-145 145 145 gray57
-145 145 145 grey57
-148 148 148 gray58
-148 148 148 grey58
-150 150 150 gray59
-150 150 150 grey59
-153 153 153 gray60
-153 153 153 grey60
-156 156 156 gray61
-156 156 156 grey61
-158 158 158 gray62
-158 158 158 grey62
-161 161 161 gray63
-161 161 161 grey63
-163 163 163 gray64
-163 163 163 grey64
-166 166 166 gray65
-166 166 166 grey65
-168 168 168 gray66
-168 168 168 grey66
-171 171 171 gray67
-171 171 171 grey67
-173 173 173 gray68
-173 173 173 grey68
-176 176 176 gray69
-176 176 176 grey69
-179 179 179 gray70
-179 179 179 grey70
-181 181 181 gray71
-181 181 181 grey71
-184 184 184 gray72
-184 184 184 grey72
-186 186 186 gray73
-186 186 186 grey73
-189 189 189 gray74
-189 189 189 grey74
-191 191 191 gray75
-191 191 191 grey75
-194 194 194 gray76
-194 194 194 grey76
-196 196 196 gray77
-196 196 196 grey77
-199 199 199 gray78
-199 199 199 grey78
-201 201 201 gray79
-201 201 201 grey79
-204 204 204 gray80
-204 204 204 grey80
-207 207 207 gray81
-207 207 207 grey81
-209 209 209 gray82
-209 209 209 grey82
-212 212 212 gray83
-212 212 212 grey83
-214 214 214 gray84
-214 214 214 grey84
-217 217 217 gray85
-217 217 217 grey85
-219 219 219 gray86
-219 219 219 grey86
-222 222 222 gray87
-222 222 222 grey87
-224 224 224 gray88
-224 224 224 grey88
-227 227 227 gray89
-227 227 227 grey89
-229 229 229 gray90
-229 229 229 grey90
-232 232 232 gray91
-232 232 232 grey91
-235 235 235 gray92
-235 235 235 grey92
-237 237 237 gray93
-237 237 237 grey93
-240 240 240 gray94
-240 240 240 grey94
-242 242 242 gray95
-242 242 242 grey95
-245 245 245 gray96
-245 245 245 grey96
-247 247 247 gray97
-247 247 247 grey97
-250 250 250 gray98
-250 250 250 grey98
-252 252 252 gray99
-252 252 252 grey99
-255 255 255 gray100
-255 255 255 grey100
-169 169 169 dark grey
-169 169 169 DarkGrey
-169 169 169 dark gray
-169 169 169 DarkGray
-0 0 139 dark blue
-0 0 139 DarkBlue
-0 139 139 dark cyan
-0 139 139 DarkCyan
-139 0 139 dark magenta
-139 0 139 DarkMagenta
-139 0 0 dark red
-139 0 0 DarkRed
-144 238 144 light green
-144 238 144 LightGreen
View
388 plugin/CSApprox.vim
@@ -1,17 +1,52 @@
-" CSApprox: Make gvim-only colorschemes work terminal vim
+" CSApprox: Make gvim-only colorschemes Just Work terminal vim
" Maintainer: Matthew Wozniski (mjw@drexel.edu)
-" Date: Sat, 31 Jan 2009 04:14:27 -0500
-" Version: 3.05
+" Date: Wed, 01 Apr 2009 22:10:19 -0400
+" Version: 3.50
" History: :help csapprox-changelog
-
-" Whenever you change colorschemes using the :colorscheme command, this script
-" will be executed. If you're running in 256 color terminal or an 88 color
-" terminal, as reported by the command ":set t_Co?", it will take the colors
-" that the scheme specified for use in the gui and use an approximation
-" algorithm to try to gracefully degrade them to the closest color available.
-" If you are running in a gui or if t_Co is reported as less than 88 colors,
-" no changes are made. Also, no changes will be made if the colorscheme seems
-" to have been high color already.
+"
+" Long Description:
+" It's hard to find colorschemes for terminal Vim. Most colorschemes are
+" written to only support GVim, and don't work at all in terminal Vim.
+"
+" This plugin makes GVim-only colorschemes Just Work in terminal Vim, as long
+" as the terminal supports 88 or 256 colors - and most do these days. This
+" usually requires no user interaction (but see below for what to do if things
+" don't Just Work). After getting this plugin happily installed, any time you
+" use :colorscheme it will do its magic and make the colorscheme Just Work.
+"
+" Whenever you change colorschemes using the :colorscheme command this script
+" will be executed. It will take the colors that the scheme specified for use
+" in the GUI and use an approximation algorithm to try to gracefully degrade
+" them to the closest color available in your terminal. If you are running in
+" a GUI or if your terminal doesn't support 88 or 256 colors, no changes are
+" made. Also, no changes will be made if the colorscheme seems to have been
+" high color already.
+"
+" License:
+" Copyright (c) 2009, Matthew J. Wozniski
+" All rights reserved.
+"
+" Redistribution and use in source and binary forms, with or without
+" modification, are permitted provided that the following conditions are met:
+" * Redistributions of source code must retain the above copyright notice,
+" this list of conditions and the following disclaimer.
+" * Redistributions in binary form must reproduce the above copyright
+" notice, this list of conditions and the following disclaimer in the
+" documentation and/or other materials provided with the distribution.
+" * The names of the contributors may not be used to endorse or promote
+" products derived from this software without specific prior written
+" permission.
+"
+" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS
+" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+" NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT,
+" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+" OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" {>1} Basic plugin setup
@@ -19,7 +54,7 @@
" Quit if the user doesn't want or need us or is missing the gui feature. We
" need +gui to be able to check the gui color settings; vim doesn't bother to
" store them if it is not built with +gui.
-if ! has("gui") || exists('g:CSApprox_loaded')
+if !has('gui') || exists('g:CSApprox_loaded')
" XXX This depends upon knowing the default for g:CSApprox_verbose_level
let s:verbose = 1
if exists("g:CSApprox_verbose_level")
@@ -66,8 +101,8 @@ endfunc
" {>2} Approximator
" Takes 3 decimal values for r, g, and b, and returns the closest cube number.
" Uses &term to determine which cube should be used, though if &term is set to
-" "xterm" the variables g:CSApprox_eterm and g:CSApprox_konsole can be used to
-" change the default palette.
+" "xterm" or begins with "screen", the variables g:CSApprox_eterm and
+" g:CSApprox_konsole can be used to select a different palette.
"
" This approximator considers closeness based upon the individiual components.
" For each of r, g, and b, it finds the closest cube component available on
@@ -118,7 +153,7 @@ function! s:ApproximatePerComponent(r,g,b)
let b = s:NearestElemInList(a:b, greys_colors)
let len = len(colors)
- if (r == g && g == b && index(greys, r) > 0)
+ if (r == g && g == b && index(greys, r) != -1)
let rv = 16 + len * len * len + index(greys, r)
else
let r = s:NearestElemInList(a:r, colors)
@@ -168,7 +203,7 @@ endfunction
" numbers for keys and values that are dictionaries with four keys each,
" 'name', 'term', 'cterm', and 'gui'. 'name' holds the group name, and each
" of the others holds highlight information for that particular mode.
-function! s:Highlights()
+function! s:Highlights(modes)
let rv = {}
let i = 0
@@ -188,30 +223,20 @@ function! s:Highlights()
let rv[i] = {}
let rv[i].name = synIDattr(i, "name")
- for where in [ "term", "cterm", "gui" ]
+ for where in a:modes
let rv[i][where] = {}
for attr in [ "bold", "italic", "reverse", "underline", "undercurl" ]
let rv[i][where][attr] = synIDattr(i, attr, where)
endfor
- for attr in [ "fg", "bg", "sp" ]
+ for attr in [ "fg", "bg" ]
let rv[i][where][attr] = synIDattr(i, attr.'#', where)
endfor
- if s:NeedRedirFallback()
- redir => temp
- exe 'sil hi ' . rv[i].name
- redir END
- let temp = matchstr(temp, where.'sp=\zs.*')
- if len(temp) == 0 || temp[0] =~ '\s'
- let temp = ""
- else
- " Make sure we can handle guisp='dark red'
- let temp = substitute(temp, '[\x00].*', '', '')
- let temp = substitute(temp, '\s*\(c\=term\|gui\).*', '', '')
- let temp = substitute(temp, '\s*$', '', '')
- endif
- let rv[i][where]["sp"] = temp
+ if where == "gui"
+ let rv[i][where]["sp"] = s:SynGuiSp(i, rv[i].name)
+ else
+ let rv[i][where]["sp"] = -1
endif
for attr in [ "fg", "bg", "sp" ]
@@ -225,6 +250,39 @@ function! s:Highlights()
return rv
endfunction
+" {>2} Retrieve guisp
+
+" Get guisp using whichever method is specified by _redir_fallback
+function! s:SynGuiSp(idx, name)
+ if !s:NeedRedirFallback()
+ return s:SynGuiSpAttr(a:idx)
+ else
+ return s:SynGuiSpRedir(a:name)
+ endif
+endfunction
+
+" {>3} Implementation for retrieving guisp with redir hack
+function! s:SynGuiSpRedir(name)
+ redir => temp
+ exe 'sil hi ' . a:name
+ redir END
+ let temp = matchstr(temp, 'guisp=\zs.*')
+ if len(temp) == 0 || temp[0] =~ '\s'
+ let temp = ""
+ else
+ " Make sure we can handle guisp='dark red'
+ let temp = substitute(temp, '[\x00].*', '', '')
+ let temp = substitute(temp, '\s*\(c\=term\|gui\).*', '', '')
+ let temp = substitute(temp, '\s*$', '', '')
+ endif
+ return temp
+endfunction
+
+" {>3} Implementation for retrieving guisp with synIDattr()
+function! s:SynGuiSpAttr(idx)
+ return synIDattr(a:idx, 'sp#', 'gui')
+endfunction
+
" {>1} Handle color names
" Place to store rgb.txt name to color mappings - lazy loaded if needed
@@ -232,8 +290,9 @@ let s:rgb = {}
" {>2} Builtin gui color names
" gui_x11.c and gui_gtk_x11.c have some default colors names that are searched
-" if a color is not in rgb.txt. We'll pretend they're in rgb.txt with these
-" values, and overwrite them with a different value if we find them...
+" if the x server doesn't know about a color. If 'showrgb' is available,
+" we'll default to using these color names and values, and overwrite them with
+" other values if 'showrgb' tells us about those colors.
let s:rgb_defaults = { "lightred" : "#FFBBBB",
\ "lightgreen" : "#88FF88",
\ "lightmagenta" : "#FFBBFF",
@@ -262,57 +321,74 @@ let s:rgb_defaults = { "lightred" : "#FFBBBB",
\ "gray90" : "#E5E5E5",
\ "grey90" : "#E5E5E5" }
-" {>2} Find and parse rgb.txt
-" Search for an rgb.txt in a set of default directories. If the user wishes
-" to override the default search path, he can specify a list of other
-" directories to search first in g:CSApprox_extra_rgb_txt_dirs. When rgb.txt
-" has been located, and verified to be good (by having enough non-blank
-" non-comment correctly formatted lines), the parsed information is stored to
-" the dictionary s:rgb - the keys are color names (in lowercase), the values
-" are strings representing color values (as '#rrggbb').
+" {>2} Colors that vim will use by name in one of the default schemes, either
+" for bg=light or for bg=dark. This lets us avoid loading the entire rgb.txt
+" database when the scheme itself doesn't ask for colors by name.
+let s:rgb_presets = { "black" : "#000000",
+ \ "blue" : "#0000ff",
+ \ "brown" : "#a52a2a",
+ \ "cyan" : "#00ffff",
+ \ "darkblue" : "#00008b",
+ \ "darkcyan" : "#008b8b",
+ \ "darkgrey" : "#a9a9a9",
+ \ "darkmagenta" : "#8b008b",
+ \ "green" : "#00ff00",
+ \ "grey" : "#bebebe",
+ \ "grey40" : "#666666",
+ \ "grey90" : "#e5e5e5",
+ \ "lightblue" : "#add8e6",
+ \ "lightcyan" : "#e0ffff",
+ \ "lightgrey" : "#d3d3d3",
+ \ "lightmagenta" : "#ffbbff",
+ \ "magenta" : "#ff00ff",
+ \ "red" : "#ff0000",
+ \ "seagreen" : "#2e8b57",
+ \ "white" : "#ffffff",
+ \ "yellow" : "#ffff00" }
+
+" {>2} Find available color names
+" Find the valid named colors. By default, use our own rgb list, but try to
+" retrieve the system's list if g:CSApprox_use_showrgb is set to true. Store
+" the color names and color values to the dictionary s:rgb - the keys are
+" color names (in lowercase), the values are strings representing color values
+" (as '#rrggbb').
function! s:UpdateRgbHash()
- " Pattern for ignored lines - all blanks, or blanks then !
- let ignorepat = '^\s*\%(!.*\)\=$'
- " fmt is (blanks?)(red)(blanks)(green)(blanks)(blue)(blanks)(name)
- let parsepat = '^\s*\(\d\+\)\s\+\(\d\+\)\s\+\(\d\+\)\s\+\(.*\)$'
-
- let user = []
- if exists("g:CSApprox_extra_rgb_txt_dirs")
- if type(g:CSApprox_extra_rgb_txt_dirs) == type([])
- let user = g:CSApprox_extra_rgb_txt_dirs
- else
- let user = [ g:CSApprox_extra_rgb_txt_dirs ]
+ try
+ if !exists("g:CSApprox_use_showrgb") || !g:CSApprox_use_showrgb
+ throw "Not using showrgb"
+ endif
+
+ " We want to use the 'showrgb' program, if it's around
+ let lines = split(system('showrgb'), '\n')
+
+ if v:shell_error || !exists('lines') || empty(lines)
+ throw "'showrgb' didn't give us an rgb.txt"
endif
- endif
- for dir in user + [ '/usr/local/share/X11',
- \ '/usr/share/X11',
- \ '/etc/X11',
- \ '/usr/local/lib/X11',
- \ '/usr/lib/X11',
- \ '/usr/local/X11R6/lib/X11',
- \ '/usr/X11R6/lib/X11' ]
- \ + split(globpath(&rtp, ''), '\n')
let s:rgb = copy(s:rgb_defaults)
- sil! let lines = readfile(dir . '/rgb.txt')
+
+ " fmt is (blanks?)(red)(blanks)(green)(blanks)(blue)(blanks)(name)
+ let parsepat = '^\s*\(\d\+\)\s\+\(\d\+\)\s\+\(\d\+\)\s\+\(.*\)$'
for line in lines
- if line =~ ignorepat
- continue " Line is blank, entirely spaces, or a comment
- endif
let v = matchlist(line, parsepat)
- if len(v) > 0
- let s:rgb[tolower(v[4])] = printf("#%02x%02x%02x", v[1], v[2], v[3])
+ if len(v) < 0
+ throw "CSApprox: Bad RGB line: " . string(line)
endif
+ let s:rgb[tolower(v[4])] = printf("#%02x%02x%02x", v[1], v[2], v[3])
endfor
+ catch
+ try
+ let s:rgb = csapprox#rgb()
+ catch
+ echohl ErrorMsg
+ echomsg "Can't call rgb() from autoload/csapprox.vim"
+ echomsg "Named colors will not be available!"
+ echohl None
+ endtry
+ endtry
- if len(s:rgb) > 50
- return 0 " Long enough, must have been valid
- endif
- endfor
-
- let s:rgb = {}
- throw "Failed to find a valid rgb.txt!"
+ return 0
endfunction
" {>1} Derive and set cterm attributes
@@ -329,44 +405,50 @@ endfunction
" can look up, to string values, representing the attribute mapped to or an
" empty string to disable the given attribute entirely.
function! s:attr_map(attr)
- let attr = tolower(a:attr)
+ let rv = get(g:CSApprox_attr_map, a:attr, a:attr)
- if attr == 'inverse'
- let attr = 'reverse'
- endif
+ return rv
+endfunction
+
+function! s:NormalizeAttrMap(map)
+ let old = copy(a:map)
+ let new = filter(a:map, '0')
let valid_attrs = [ 'bg', 'fg', 'sp', 'bold', 'italic',
\ 'reverse', 'underline', 'undercurl' ]
- if index(valid_attrs, attr) == -1
- throw "Looking up invalid attribute '" . attr . "'"
- endif
-
- if !exists("g:CSApprox_attr_map") || type(g:CSApprox_attr_map) != type({})
- let g:CSApprox_attr_map = { 'italic' : 'underline', 'sp' : 'fg' }
- endif
-
- let rv = get(g:CSApprox_attr_map, attr, attr)
+ let colorattrs = [ 'fg', 'bg', 'sp' ]
- if index(valid_attrs, rv) == -1 && rv != ''
- " The user mapped 'attr' to something invalid
- throw "Bad attr map: '" . attr . "' to unknown attribute '" . rv . "'"
- endif
+ for olhs in keys(old)
+ if olhs ==? 'inverse'
+ let nlhs = 'reverse'
+ endif
- let colorattrs = [ 'fg', 'bg', 'sp' ]
- if rv != '' && !!(index(colorattrs, attr)+1) != !!(index(colorattrs, rv)+1)
- " The attribute the user mapped to was valid, but of a different type.
- throw "Bad attr map: Can't map color attr to boolean (".attr."->".rv.")"
- endif
+ let orhs = old[olhs]
- if rv == 'inverse'
- let rv = 'reverse' " Internally always use 'reverse' instead of 'inverse'
- elseif rv == 'sp'
- " Terminals can't handle the guisp attribute; disable it if it was left on
- let rv = ''
- endif
+ if orhs ==? 'inverse'
+ let nrhs = 'reverse'
+ endif
- return rv
+ let nlhs = tolower(olhs)
+ let nrhs = tolower(orhs)
+
+ try
+ if index(valid_attrs, nlhs) == -1
+ echomsg "CSApprox: Bad attr map (removing unrecognized attribute " . olhs . ")"
+ elseif nrhs != '' && index(valid_attrs, nrhs) == -1
+ echomsg "CSApprox: Bad attr map (removing unrecognized attribute " . orhs . ")"
+ elseif nrhs != '' && !!(index(colorattrs, nlhs)+1) != !!(index(colorattrs, nrhs)+1)
+ echomsg "CSApprox: Bad attr map (removing " . olhs . "; type mismatch with " . orhs . ")"
+ elseif nrhs == 'sp'
+ echomsg "CSApprox: Bad attr map (removing " . olhs . "; can't map to 'sp')"
+ else
+ let new[nlhs] = nrhs
+ endif
+ catch
+ echo v:exception
+ endtry
+ endfor
endfunction
" {>2} Normalize the GUI settings of a highlight group
@@ -396,6 +478,10 @@ endfunction
function! s:FixupCtermInfo(highlights)
for hl in values(a:highlights)
+ if !has_key(hl, 'cterm')
+ let hl["cterm"] = {}
+ endif
+
" Find attributes to be set in the terminal
for attr in [ "bold", "italic", "reverse", "underline", "undercurl" ]
let hl.cterm[attr] = ''
@@ -462,16 +548,23 @@ function! s:SetCtermFromGui(hl)
" Try translating anything but 'fg', 'bg', #rrggbb, and rrggbb from an
" rgb.txt color to a #rrggbb color
if val !~? '^[fb]g$' && val !~ '^#\=\x\{6}$'
- if empty(s:rgb)
- call s:UpdateRgbHash()
- endif
try
- let val = s:rgb[tolower(val)]
+ " First see if it is in our preset-by-vim rgb list
+ let val = s:rgb_presets[tolower(val)]
catch
- if &verbose
- echomsg "CSApprox: Colorscheme uses unknown color \"" . val . "\""
+ " Then try loading and checking our real rgb list
+ if empty(s:rgb)
+ call s:UpdateRgbHash()
endif
- continue
+ try
+ let val = s:rgb[tolower(val)]
+ catch
+ " And then barf if we still haven't found it
+ if &verbose
+ echomsg "CSApprox: Colorscheme uses unknown color \"" . val . "\""
+ endif
+ continue
+ endtry
endtry
endif
@@ -480,9 +573,9 @@ function! s:SetCtermFromGui(hl)
let hl.cterm[which] = val
elseif val =~ '^#\=\x\{6}$'
let val = substitute(val, '^#', '', '')
- let r = str2nr(val[0] . val[1], 16)
- let g = str2nr(val[2] . val[3], 16)
- let b = str2nr(val[4] . val[5], 16)
+ let r = str2nr(val[0:1], 16)
+ let g = str2nr(val[2:3], 16)
+ let b = str2nr(val[4:5], 16)
let hl.cterm[which] = g:CSApprox_approximator_function(r, g, b)
exe 'hi ' . hl.name . ' cterm' . which . '=' . hl.cterm[which]
else
@@ -542,21 +635,6 @@ let s:presets_256 += [224] " LightRed
let s:presets_256 += [225] " LightMagenta
let s:presets_256 += [229] " LightYellow
-" {>2} Highlight comparator
-" Comparator that sorts numbers matching the highlight id of the 'Normal'
-" group before anything else; all others stay in random order. This allows us
-" to ensure that the Normal group is the first group we set. If it weren't,
-" we could get E419 or E420 if a later color used guibg=bg or the likes.
-function! s:SortNormalFirst(num1, num2)
- if a:num1 == s:hlid_normal && a:num1 != a:num2
- return -1
- elseif a:num2 == s:hlid_normal && a:num1 != a:num2
- return 1
- else
- return 0
- endif
-endfunction
-
" {>2} Wrapper around :exe to allow :executing multiple commands.
" "cmd" is the command to be :executed.
" If the variable is a String, it is :executed.
@@ -621,6 +699,12 @@ function! s:CSApprox()
set lz
+ if exists("g:CSApprox_attr_map") && type(g:CSApprox_attr_map) == type({})
+ call s:NormalizeAttrMap(g:CSApprox_attr_map)
+ else
+ let g:CSApprox_attr_map = { 'italic' : 'underline', 'sp' : 'fg' }
+ endif
+
" colors_name must be unset and reset, or vim will helpfully reload the
" colorscheme when we set the background for the Normal group.
" See the help entries ':hi-normal-cterm' and 'g:colors_name'
@@ -680,7 +764,7 @@ function! s:CSApproxImpl()
endif
" Get the current highlight colors
- let highlights = s:Highlights()
+ let highlights = s:Highlights(["gui"])
let hinums = keys(highlights)
@@ -692,17 +776,17 @@ function! s:CSApproxImpl()
" XXX: s:inhibit_hicolor_test allows this test to be skipped for snapshots
if !exists("s:inhibit_hicolor_test") || !s:inhibit_hicolor_test
for hlid in hinums
- let val = highlights[hlid]
- if ( val.cterm.bg > 15
- \ && index(s:presets_{&t_Co}, str2nr(val.cterm.bg)) < 0)
- \ || ( val.cterm.fg > 15
- \ && index(s:presets_{&t_Co}, str2nr(val.cterm.fg)) < 0)
- " The value is set above 15, and wasn't set by vim.
- if &verbose >= 2
- echomsg 'CSApprox: Exiting - high color found for' val.name
+ for type in [ 'bg', 'fg' ]
+ let color = synIDattr(hlid, type, 'cterm')
+
+ if color > 15 && index(s:presets_{&t_Co}, str2nr(color)) < 0
+ " The value is set above 15, and wasn't set by vim.
+ if &verbose >= 2
+ echomsg 'CSApprox: Exiting - high' type 'color found for' highlights[hlid].name
+ endif
+ return
endif
- return
- endif
+ endfor
endfor
endif